Offline Support
Offline support is useful for projects where performance is critical and loading the full payload each time is not acceptable.
When delta query is implemented, the back-end system logs all creations, changes, and deletions of a specific data set (for example a list of products). Delta querying basically means “give me all the entities that were created, changed, or deleted since I last asked”. It defines a pull-model protocol for clients to obtain changes in an entity set.
When the client requests a data set, the server issues a delta token with a time stamp, which is returned to the client along with the requested data set. The next time the client requests the same data set, it returns the delta token to the server. The server compares the time stamp on the delta token to the time stamps of the records in the change log. Only records that are new, changed, or deleted since the delta token was issued are returned to the client.
Delta querying is useful for projects where performance is critical and loading the full payload each time is not acceptable.
Delta Query Support in Gateway OData Services
SAP Gateway, starting from version 2.0 SP07, provides delta query support for hosted OData services. The methods GET_ENTITYSET and GET_ENTITYSET_DELTA are used to manage delta handling. There is limited support for JSON protocol (no tombstones).
When the client requests the entity set the first time, the GET_ENTITYSET method is called and will return the entire collection along with a delta token. The delta token is normally a date time stamp combined with a GUID. When the client requests the entity set again and includes the delta token in the request, the GET_ENTITYSET_DELTA method will be called and will return the delta collection along with a fresh delta token.
Delta Query Data Flow Between Client and Gateway
The GET_ENTITYSET method has the following characteristics:
The GET_ENTITYSET_DELTA method has the following characteristics:
In the figure, GET_ENTITYSET is called on the initial request or when the client does not provide a delta token in the request. A full entity set is returned.
A relative link marked with rel=“delta” that contains the delta token is provided at the end of the feed.
GET_ENTITYSET_DELTA is called when the client provides a delta token in the request. Delta entity set is returned.
Delta Determination Timeline
Delta determination occurs at the following points in time:
Delta Token Implementation
You can implement delta tokens in several ways. These options can be grouped into two main approaches.
The first approach, which is based on the Syclo Exchange framework or which can be implemented by custom coding, calculates deltas at modification time: The ABAP system tracks relevant changes when they occur. At request time, the deltas are already prepared and therefore available. On the one hand this approach requires more development. On the other hand it’s more scalable and has an optimized overall performance.
The second approach is based on delta determination at request time where the system compares the old and new state to find out which records have been changed or deleted. The implementation effort is rather small but it does not optimize the performance of the back end. That means, the more records you have in the full collection, the longer the response time of the request.