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,
erdat,
erzet,
ernam,
audat,
netwr,
waerk,
vkorg,
vtweg FROM vbak
ORDER BY vbeln
INTO CORRESPONDING FIELDS OF TABLE @et_entityset
OFFSET @is_paging-skip UP TO @is_paging-top ROWS.
ELSE.
"Logic goes here for without paging i.e selecting ALL
ENDIF.
ENDMETHOD.
URI: /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$top=5&$skip=0
URI: /sap/opu/odata/SAP/ZXYZ_SAMPLE_ODATA_SRV/OrderrHeaderSet?$top=5&$skip=5
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)
Previous Part:Query Operation(GET_ENTITYSET) in OData – Part 5-ABAP Skill
Next Part:
2 Comments
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 […]