Skip to Content

Hello,

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)

method DO_PAGING.

* 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_pagingtop.

     lv_skip = is_pagingskip.

     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.

     REFRESH 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 sytabix > 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.

             EXIT.

           ENDIF.

         ENDIF.

       ENDLOOP.

       “No Paging

     ELSE.

       ct_entityset = <ft_data>.

     ENDIF.

   endmethod.

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.

Kind regards,

Michael

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Holger Neven

    Hi Michael,

    looks like a nice piece of code, thanks for sharing it with us!

    I had the same problem and found class /IWBEP/CL_MGW_DATA_UTIL, method PAGING. It does exactly the same. The class even supports filtering and ordering, though These implementations do not always work out of the box…

    So the Gateway Developers even thought of this 🙂

    Have fun using it!

    Regards

    Holger

    (0) 

Leave a Reply