SAP Odata実行命令(2)
前言
$ skiptokenは、アプリケーションに送信されるエントリ数を制限するために使用されます。 膨大な数のエントリが要求された場合、これはパフォーマンスの向上にも役立ちます。次のリンクがアプリケーションに戻って提供され、次の大量のデータを取得します。
構文
http://<server>:<port>/sap/opu/odata/sap/<service_name>/ProductsSet?$skiptoken=
使い方法
- サーバーでページサイズ、つまりDPC_EXTクラスのGET_ENTITYSETメソッドを定義する必要があります。
- エンティティセットのエントリがページサイズより大きい場合は、エントリをページサイズで割ります。
- skiptoken値と、次のエントリセットへの次のリンクに基づいて、要求されたエントリセットをアプリケーションに送信します。 詳細は下の画像をご覧ください。

Step.1

Step.2
PRODUCTSSET_GET_ENTITYSET ソースコードは以下のようです。
DATA: ls_order TYPE /iwbep/s_mgw_sorting_order,
lt_products TYPE STANDARD TABLE OF bapi_epm_product_header,
ls_products TYPE bapi_epm_product_header,
ls_entityset TYPE zcl_zdemo_gw_srv_mpc=>ts_products,
lt_entityset TYPE zcl_zdemo_gw_srv_mpc=>tt_products,
lv_max_rows TYPE bapi_epm_max_rows,
ls_filter TYPE /iwbep/s_mgw_select_option,
lr_product_id TYPE TABLE OF bapi_epm_product_id_range,
ls_product_id TYPE bapi_epm_product_id_range,
ls_select_options TYPE /iwbep/s_cod_select_option. * >> Check if $filter option is available
* Get the filter option for product ID
READ TABLE it_filter_select_options
INTO ls_filter
WITH KEY property = 'ProductId'.
IF sy-subrc = 0.
LOOP AT ls_filter-select_options INTO ls_select_options.
MOVE-CORRESPONDING ls_select_options TO ls_product_id.
APPEND ls_product_id TO lr_product_id.
ENDLOOP.
ENDIF. * Call the BAPI by providing the filter options
* if no filter, BAPI will get the entire list of products
CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST'
TABLES
headerdata = lt_products
selparamproductid = lr_product_id.
IF lt_products IS NOT INITIAL.
LOOP AT lt_products INTO ls_products.
MOVE-CORRESPONDING ls_products TO ls_entityset.
APPEND ls_entityset TO et_entityset.
ENDLOOP.
ENDIF.
上記のソースだとすべてデータを取得しますので、
$skiptoken オプションでページサイズを設定します。
Step.3
PRODUCTSSET_GET_ENTITYSETに以下のようにページサイズを設定します。
DATA: ls_order TYPE /iwbep/s_mgw_sorting_order,
lt_products TYPE STANDARD TABLE OF bapi_epm_product_header,
ls_products TYPE bapi_epm_product_header,
ls_entityset TYPE zcl_zdemo_gw_srv_mpc=>ts_products,
lt_entityset TYPE zcl_zdemo_gw_srv_mpc=>tt_products,
lv_max_rows TYPE bapi_epm_max_rows,
ls_filter TYPE /iwbep/s_mgw_select_option,
lr_product_id TYPE TABLE OF bapi_epm_product_id_range,
ls_product_id TYPE bapi_epm_product_id_range,
ls_select_options TYPE /iwbep/s_cod_select_option. * >> Check if $filter option is available
* Get the filter option for roduct ID
READ TABLE it_filter_select_options
INTO ls_filter
WITH KEY property = 'ProductId'.
IF sy-subrc = 0.
LOOP AT ls_filter-select_options INTO ls_select_options.
MOVE-CORRESPONDING ls_select_options TO ls_product_id.
APPEND ls_product_id TO lr_product_id.
ENDLOOP.
ENDIF. * Call the BAPI by providing the filter options
* if no filter, BAPI will get the entire list of products
CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_LIST'
TABLES
headerdata = lt_products
selparamproductid = lr_product_id.
IF lt_products IS NOT INITIAL.
LOOP AT lt_products INTO ls_products.
MOVE-CORRESPONDING ls_products TO ls_entityset.
APPEND ls_entityset TO lt_entityset.
ENDLOOP.
ENDIF. DATA: lv_page_size TYPE i VALUE 50, " Define the Page Size/
lv_index_start TYPE i,
lv_skiptoken TYPE string,
lv_index_end TYPE i,
lv_table_size TYPE i. * Obtain the $skiptoken value if it exists in the URL
lv_skiptoken = io_tech_request_context->get_skiptoken( ). * Clear the skiptoken, if the result is empty
DESCRIBE TABLE lt_entityset LINES lv_table_size.
IF lv_table_size IS INITIAL.
CLEAR es_response_context-skiptoken.
EXIT.
ENDIF. * If the table size is less than the predefined page size,
* send all the data
IF lv_table_size < lv_page_size.
et_entityset = lt_entityset. * If the table size is beyond the predefined page size,
* cut the whole table into pieces with the page size
ELSE.
lv_index_start = lv_skiptoken.
lv_index_end = lv_skiptoken + lv_page_size.
ENDIF. LOOP AT lt_entityset INTO ls_entityset.
IF sy-tabix > lv_index_start AND
sy-tabix <= lv_index_end.
APPEND ls_entityset TO et_entityset.
ENDIF.
ENDLOOP. * Next Link
es_response_context-skiptoken = lv_index_end + 1.
CONDENSE es_response_context-skiptoken.
Step.4
/sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/ProductsSet?$skiptoken=0′.
/sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/ProductsSet?$skiptoken=10′.

※画像では$skiptoken=20書いてますが、正しくは$skiptoken=10です。
SAP Odata実行命令(2)的更多相关文章
- SAP Odata実行命令(1)
$count $Orderby:desc/asc ※$Orderby=ソートする項目 desc降順/asc昇順 を指定すること $Filter: $Skip,Top and Inline count: ...
- SAP OData $batch processing
例として.1回の呼び出しで100個の新しい商品を作成したい場合.最も簡単な方法は.$ batch要求を使用して100個のPOST呼び出しすべてを単一のサービス呼び出しにまとめることです. URIの末尾 ...
- dat文件中如何编写DOS的多行命令
dat文件中如何编写DOS的多行命令 2012-10-15 11:29 四海柔情108 分享到: 2012-10-16 23:36 提问者采纳 你问的应该是BAT文件吧?BAT是DOS命令的批 ...
- MySql命令行命令和SQL语句
一.常用mysql命令行命令 1.启动MYSQL服务 net start mysql 停止MYSQL服务 net stop mysql 2.netstat -na|findstr 3306 查看被监听 ...
- Windows命令行命令集锦
原文:Windows命令行命令集锦 转自:http://www.me2wg.com/bbs/forum.php?mod=viewthread&tid=15830 winver--------- ...
- iOS工程师常用的命令行命令总结
感觉有点标题党了. 作为一个iOS工程师,没有做过服务端,主要用的是mac电脑,此篇博文是记录我在工作,学习的过程中用的命令行命令的记录和归纳总结 一. mac命令行 1. cd /Users/xxx ...
- WPF DataGrid 绑定行双击行命令
WPF DataGrid 绑定行双击行命令 <DataGrid ...> <DataGrid.InputBindings> <MouseBinding MouseActi ...
- Windows与Linux的命令行命令对比
Windows与Linux的命令行命令对比 * Windows不区分大小写,Linux区分大小写的. sn DOS Command UNIX Equivalent Effect 影响 1 ASSIGN ...
- [转载]Selenium実行中にJavaScriptのコードを実行する
Selenium実行中にJavaScriptのコードを実行する JavaScriptで画面の値を取得/設定するコードをメモ. WebDriverEx.cs // JavaScriptを実行(戻り値なし ...
随机推荐
- ZT 怎么样才算熟悉设计模式? [问题点数:40分,结帖人jiaoyun007]
http://bbs.csdn.net/topics/390448668?page=1#post-394406161 近日面试,因为个人简历里有“熟悉设计模式”这句话,面试官边侃侃发问了:什么是装饰模 ...
- 云来储存型XSS漏洞+越权修改应用封面
0x001. 今天本来想看看场景应用有什么新功能没,于是乎随便打开了一个场景应用,然后上传了一张图片修改下封面,结果我看到firefox 网络竟然有2个post,不由得勾起我的好奇心,好奇害死猫嘿嘿. ...
- 027class_part1
因为有基础,我直接简单写了##定义类,创建对象,调用对象方法,返回值 class person: def speak(self,x): print('love',x) return x + '**** ...
- css3实现渐变
chrome,苹果浏览器:—webkit- firebox浏览器:-moz- Opera浏览器:-o- 渐变分为:线性渐变(Linear Gradients)向下/向上/向左/向右/对角方向 径向渐变 ...
- PowerDNS简单教程(3):管理篇
目录: PowerDNS简单教程(1):安装篇 http://www.cnblogs.com/anpengapple/p/5205130.html PowerDNS简单教程(2):功能篇 http:/ ...
- SOJ4478 Easy Problem II(模拟、栈)
Time Limit: 3000 MS Memory Limit: 131072 K Description 在数据结构中 我们学习过 栈 这种数据结构 通过栈 我们可以将1,2,3,...,n转化成 ...
- Struts2注解开发
Hibernate和spring框架的开发前边总结了,这次看一下流行的MVC流程框架Struts2的注解开发吧.Struts2主要解决了从JSP到Action上的流程管理,如何进行Uri和action ...
- gluoncv 目标检测,训练自己的数据集
https://gluon-cv.mxnet.io/build/examples_datasets/detection_custom.html 官方提供两种方案,一种是lst文件,一种是xml文件(v ...
- C++禁止使用拷贝构造函数和赋值运算符方法
1.将拷贝构造函数和赋值运算符声明为私有,并不予实现 class Uncopyable { private: Uncopyable(const Uncopyable &); // 阻止copy ...
- WPF引用ActiveX提示没有注册类或不是有效的Win32程序
VS2017开发WPF时,需要引用UKey组件读取插入的Ukey编号和密钥 该组件在网页端调用时使用ObjectId进行ActiveX注册即可,后来做成WPF客户端进行读取遇到该问题. 解决: 右键项 ...