Paging with oData on Entityset Itab – Example implementation
i would like to share some code, that can be used to handle the paging (top, skip) parameters on an entityset internal table. I use this often if the entityset is not that big or if i cant handle top skip with select statements.
I hope this can be an example to start from if you have to impelemnt top skip parameters from gateway.
The method has the following parameters:
is_paging type /IWBEP/S_MGW_PAGING. (IMPORTING)
ct_entityset type table (CHANGING)
* Handle Top/Skip
DATA: lv_top TYPE int4,
lv_skip TYPE int4,
lv_table_size TYPE i,
lo_tabdesc TYPE REF TO cl_abap_tabledescr,
lo_strucdesc TYPE REF TO cl_abap_datadescr,
rs_data TYPE REF TO data,
rt_data TYPE REF TO data.
FIELD-SYMBOLS: <fs_data> TYPE any,
<ft_data> TYPE ANY TABLE.
* Top/Skip assign local
lv_top = is_paging–top.
lv_skip = is_paging–skip.
lo_tabdesc ?= cl_abap_tabledescr=>describe_by_data( p_data = ct_entityset ).
lo_strucdesc = lo_tabdesc->get_table_line_type( ).
CREATE DATA rs_data TYPE (lo_strucdesc->absolute_name).
CREATE DATA rt_data TYPE STANDARD TABLE OF (lo_strucdesc->absolute_name).
ASSIGN rs_data->* TO <fs_data>.
ASSIGN rt_data->* TO <ft_data>.
<ft_data> = ct_entityset.
“Client Paging (top/skip)
IF lv_top IS NOT INITIAL OR
lv_skip IS NOT INITIAL.
LOOP AT <ft_data> ASSIGNING <fs_data>.
IF sy–tabix > lv_skip.
APPEND <fs_data> TO ct_entityset.
DESCRIBE TABLE ct_entityset LINES lv_table_size.
IF lv_top IS NOT INITIAL AND
lv_table_size >= lv_top.
ct_entityset = <ft_data>.
By now after completing several implementations using the netweaver gateway i really enjoy to work with the netweaver gateway. We realised several services that are used by sap and non-sap frontends and i personally think, that the netweaver is a great product of sap & will be really important for future development tasks. Especially i think the product is really stable as i did not have a single critical issue during productive use of the gateway. Only once we forgot to update the metadata of the service in production – but this was a 2 minute thing to solve. @Gateway Developers: Keep up the good work! Can’t wait to see new features comming up.
Thanks for your feedback & rating the document if it was helpful to you.
I wish you a nice day.