Paging concept in Odata service
2023-11-19 03:29:11 Author: blogs.sap.com(查看原文) 阅读量:5 收藏

Introduction :

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

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

it%20will%20give%20top%20five%20sales%20orders%20without%20skipping%20any%20records%20i.e%20from%20Vbeln%201%20to%205

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

It%20will%20give%20the%20next%205%20records%20by%20skipping%20the%20first%20five%20records%20i.e%20from%206%20to%2010

It will give the next 5 records by skipping the first five records i.e from 6 to 10

Output To give an overview of how these $top and $skip in UI5/Fiori Application

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

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

hope this blog made it easier for you to understand how to use paging in Odata service with Fiori application. Please leave any comments or suggestions you might have.


文章来源: https://blogs.sap.com/2023/11/18/paging-concept-in-odata-service/
如有侵权请联系:admin#unsafe.sh