前言

$ 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

上記の手順で行ったこと。最初にすべての商品を入手してから、$ skiptokenクエリオプションが要求されているかどうかを確認し、ページサイズに基づいて大量のデータのみを送信します。
 
Step.5
sap gateway client(トランザクションコード/IWFND/GW_CLIENT)テストを行います。
 
Step.6

/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)的更多相关文章

  1. SAP Odata実行命令(1)

    $count $Orderby:desc/asc ※$Orderby=ソートする項目 desc降順/asc昇順 を指定すること $Filter: $Skip,Top and Inline count: ...

  2. SAP OData $batch processing

    例として.1回の呼び出しで100個の新しい商品を作成したい場合.最も簡単な方法は.$ batch要求を使用して100個のPOST呼び出しすべてを単一のサービス呼び出しにまとめることです. URIの末尾 ...

  3. dat文件中如何编写DOS的多行命令

    dat文件中如何编写DOS的多行命令 2012-10-15 11:29 四海柔情108 分享到:   2012-10-16 23:36 提问者采纳   你问的应该是BAT文件吧?BAT是DOS命令的批 ...

  4. MySql命令行命令和SQL语句

    一.常用mysql命令行命令 1.启动MYSQL服务 net start mysql 停止MYSQL服务 net stop mysql 2.netstat -na|findstr 3306 查看被监听 ...

  5. Windows命令行命令集锦

    原文:Windows命令行命令集锦 转自:http://www.me2wg.com/bbs/forum.php?mod=viewthread&tid=15830 winver--------- ...

  6. iOS工程师常用的命令行命令总结

    感觉有点标题党了. 作为一个iOS工程师,没有做过服务端,主要用的是mac电脑,此篇博文是记录我在工作,学习的过程中用的命令行命令的记录和归纳总结 一. mac命令行 1. cd /Users/xxx ...

  7. WPF DataGrid 绑定行双击行命令

    WPF DataGrid 绑定行双击行命令 <DataGrid ...> <DataGrid.InputBindings> <MouseBinding MouseActi ...

  8. Windows与Linux的命令行命令对比

    Windows与Linux的命令行命令对比 * Windows不区分大小写,Linux区分大小写的. sn DOS Command UNIX Equivalent Effect 影响 1 ASSIGN ...

  9. [转载]Selenium実行中にJavaScriptのコードを実行する

    Selenium実行中にJavaScriptのコードを実行する JavaScriptで画面の値を取得/設定するコードをメモ. WebDriverEx.cs // JavaScriptを実行(戻り値なし ...

随机推荐

  1. Nginx配置虚拟机,url重写,防盗链

    配置目录: ·     虚拟主机 ·     PHP支持 ·     URL重写 ·     防止盗链 ·     持续更新… 一.虚拟主机 1.创建 文件格式:{域名}.conf 具体如下: $ s ...

  2. 阶&原根

    求阶的方法: 根据性质2,直接对ϕ(m)求出因子即可,从小到大依次判断是不是符合ad = 1(mod m)(d是ϕ(m)的因子) 求最小的原根的方法: 根据性质8,对ϕ(m)求出素因子,从1开始不断测 ...

  3. LVS的DR模式负载均衡

    参考项目:http://www.cnblogs.com/along21/p/7833261.html#auto_id_3 LVS的DR模式实现负载均衡 1.环境 lvs-server :192.168 ...

  4. 下载安装Redis+使用

    Window 下安装 第一步:安装 下载地址:https://github.com/MSOpenTech/redis/releases 第二步:解压(盘符) 第三步:打开一个 cmd 窗口 使用 cd ...

  5. 创建Cookie抛出异常:java.lang.IllegalArgumentException: Control character in cookie value

    调用Cookie对象的构造函数可以创建Cookie.Cookie对象的构造函数有两个字符串参数:Cookie名字和Cookie值.   名字和值都不能包含空白字符以及下列字符:[ ] ( ) < ...

  6. jdk8新特性之双冒号 :: 用法及详解

    jdk8的新特性有很多,最亮眼的当属函数式编程的语法糖,本文主要讲解下双冒号::的用法. 概念 类名::方法名,相当于对这个方法闭包的引用,类似js中的一个function.比如: Function& ...

  7. webpack之理解loader

    我们在写webpack配置文件的时候,应该有注意到经常用到loader这个配置项,那么loader是用来做什么的呢? loader其实是用来将源文件经过转化处理之后再输出新文件. 如果是数组形式的话, ...

  8. 『ACM C++』 PTA 天梯赛练习集L1 | 050-51

    加油加油,努力刷题 ------------------------------------------------L1-050------------------------------------ ...

  9. FreeImage 生成带透明通道的GIF

    主要方法: 加载图像及读取参数 FreeImage_Load FreeImage_GetWidth FreeImage_GetHeight FreeImage_Allocate FreeImage_G ...

  10. 执行SQL查询导致磁盘耗尽故障演示

            a fellow in IMG wechat group 2 met an error about running out of disk space when using MySQL ...