Paging is used for restricting data(instead of feeding ALL) from the backend to the frontend which helps to improve the performance by reducing the records in the response.

Let’s take an example, suppose there is a UI5/Fiori application in which you need to display the list of sales orders. In that case, we need to fetch the list of sales orders from the database and send it as a response in that case the data volume will be huge and it degrades the performance of the application. Hence the concept of Paging.

There are two keywords used in paging – one is $top and the other is $skip. top always holds the fix value i.e the list of rows to be displayed on the page. Skip contains the incremental value like for the first page it will be 0 (means it will start from the beginning ) for the next page it will 0 + top like so on.

top and skip are used for get_entityset method ( Part 5 for more details ). Before implementing the logic there is a concept called offset and up to rows in Select query in ABAP.(you can check more details on the link ). So offset is used for skip and up to rows is used for top.

Note: In order to use offset, there must be order by clause in the select query

  METHOD orderrheaderset_get_entityset.
    IF is_paging IS NOT INITIAL.   "importing param only filled when $top $skip are used
      SELECT  vbeln,
              vtweg FROM vbak
              ORDER BY vbeln
      OFFSET @is_paging-skip UP TO @is_paging-top ROWS.
      "Logic goes here for without paging i.e selecting ALL
IS_Paging importing parameters
IS_PAGING will be filed when $top and $skip passed from the URI

URI: /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$top=5&$skip=0

$top $skip for the first page
it will give top five sales orders without skipping any records i.e from Vbeln 1 to 5

URI: /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$top=5&$skip=5

$top $skip for the next page
It will give the next 5 records by skipping the first five records i.e from 6 to 10

To give an overview of how these $top and $skip in UI5/Fiori Application. (We will discuss a real-time scenario application in the upcoming blogs)

The event can also be set during page scrolling/button press

Previous Part:Query Operation(GET_ENTITYSET) in OData – Part 5-ABAP Skill

Next Part:


Query Operation(GET_ENTITYSET) in OData SAP – Part 5-ABAP Skill · July 18, 2021 at 7:38 am

[…] Next Part : Paging in OData Service ($top,$skip)- Part 6- ABAP Skill SAP […]

Create(Create_entity) Method in OData SAP-Part 7-ABAP Skill · July 30, 2021 at 1:29 am

[…] Previous Part: Paging in OData Service ($top,$skip)- Part 6- ABAP Skill SAP […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *