cancel
Showing results for 
Search instead for 
Did you mean: 

Testing Odata service (soft-state activated) in GW_CLIENT

FranklinAsis
Explorer

Background: I've created an Odata Service that exposes 2 entity sets, one from a custom table and one from SAP Standard tables. Both entity sets will return a significant amount of records, and as such, server side pagination is required. The pagination would only make sense if I enable soft-state, otherwise, subsequent calls to the 'NEXT' link will always get the data from the database.

What I've done so far (based on this link and this link😞

  • Activated the soft-state for the service
    • Redefined the MPC method 'DEFINE' and set SET_SOFT_STATE_ENABLED = true
    • Redefined the DPC methods OPERATION_START and OPERATION_END
    • Set the session timeout of the service to 30 minutes and reloaded the metadata
  • Keep values in a stateful Odata session using soft-state
    • Created static attributes for the DPC to hold the data to be held in soft-state
    • Added logic to populate the static attribute and access the static attribute when its already populated, instead of extracting from the database again
  • Splitting the entity set into pages
    • Added the logic to paginate (applied to the static attribute)
    • Added the logic to include the link for the next skip token in the response context

Issue Encountered: I'm testing the service in the gateway client. The payload is paginated, i.e. returns only 100 records including the link to the next skip token (next 100 items). When executing the link for the next 100 records, the service is not accessing the created internal session supposedly where the cached data is, therefore, getting data from the database again and creating another internal session - I checked that in AL08, every time I execute the query, a new session is created. I tried using the "Reuse HTTP Connection (e.g. for soft-state)" option, but when I execute a query for the 'next' skip token link, I get a 404 - indicating that the service is not found.

Help Needed: How do I ensure that the subsequent queries in GW_CLIENT for the 'NEXT' link will access the cached data instead of going thru the database again?

**Update: we tested the service call from SAP CPI and every call for the subsequent page creates a new user session instead of using the resources of the initial load.

Thanks

Frank

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
Active Contributor

What is the release you're running on? Would using CDS be an option? There you get client side paging with $top & $skip for free.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Totally agree. If data is being retrieved from two tables it should be possible to use CDS views given the fact that Softstate is only available as of 750 and as of 750 you can even use the Referenced Data Source approach to create an OData service which uses CDS views as its data source.

grabz
Employee
Employee
0 Kudos

Usually what we recommend is to follow this Blog below. Do you see any significant difference between your implementation and/or config? One important part might be, is adding the below line in the DEFINE method:

model->set_soft_state_enabled( abap_true ).

#4 – How To Use Delta Query and Server Side Paging with Soft State