Show TOC

Handling Server-Side Paging (Next Links)Locate this document in the navigation structure

When requesting entity sets such as Groups, SAP Jam does not return all entities at once, but uses server-side paging to limit the size of the response body. In this case, the response XML contains a part of the entity set ("first page") plus a next link. The next link is a URL that can be used to request the "next page" containing the next part of the entity set. For more information, see the specification of the OData v2 standard.

To handle server-side paging, ABAP SMI provides the following methods in the IF_ODL_ENTITYSET interface:

Method Description
has_next This method returns abap_true if and only if the entity set provides a next link.
get_next This method creates and submits a request for the next link and returns this request object.
Note
  • To reduce the risk of errors, call get_next only if has_next returns abap_true.
  • The get_next method already submits the request for the next link to prevent its URL from being modified. Otherwise, modifying the URL for the next link could result in erroneous behavior. Therefore, for the returned request object, you only need to collect the result by calling one of the methods (typically get_result_entityset) described in Collecting the Results.
Example

You have an lo_request request object for which the submit method has been called. You can iterate over all parts of the entity set as follows:

DATA: lo_entityset_part TYPE REF TO if_odl_entityset.
lo_entityset_part = lo_request->get_result_entityset( ).
WHILE lo_entityset_part->has_next( ) = abap_true.
  lo_request = lo_entityset_part->get_next( ).
  lo_entityset_part = lo_request->get_result_entityset( ).
ENDWHILE.