When we faced Delta Token Unavailable Exception for multiple Projects across the Globe, we didn't find a direct solution and have reach out to SAP specialists for solution. We are writing this Blog to make the solution available for everyone by following these simple steps.
What is a Delta Token?
To enhance API performance, SAP introduced the concept of a Delta Token to optimize data retrieval and reduce unnecessary processing.
Problem Statement
Consider an API that returns a list of tasks, where the response size is around 10,000 records. Traditionally, the app fetches this entire dataset daily when the user opens the app. However, on any given day, only 10 to 15 new records might be added. Despite this, the API still retrieves the entire dataset, leading to performance issues due to the large response size and increased processing time.
SAP’s Delta Token Solution
SAP addresses this inefficiency with the Delta Token mechanism.
/IWBEP/CX_QRL_DELTA_UNAVAILABL Exception
Below is a screenshot of the UserDetailSet entity's fresh request, where the response includes a Delta Token
After a day, when the mobile device attempts to make a delta request using the previously generated Delta Token, the response returns an exception: /IWBEP/CX_QRL_DELTA_UNAVAILABLE.
What is a Delta Token Unavailable Exception?
As mentioned earlier, every Delta Token generated by SAP OData is stored in the DELTA_TABLE. However, a scheduled process runs at predefined intervals to clear old records from this table. If a request is made after the Delta Token has been purged, the system will be unable to find it, resulting in a Delta Token Unavailable Exception.
Understanding the Exception with an Example
Solution
SAP recommends handling the Delta Token Unavailable Exception by capturing it in the OData service and returning a 410 (Gone) status code. This status code indicates that the Delta Token is no longer available.
When Mobile Services receive a 410 response, it recognizes that the Delta Token is missing and automatically triggers a fresh request for the same entity. This fresh request retrieves the entire dataset along with a new Delta Token, ensuring that data synchronisation continues smoothly.
Code snippet OData
Write the Custom Exception Message with Status code as 410 whenever the delta token unavailable exception /iwbep/cx_qrl_delta_unavailabl is raised.
How to check/change delta token schedular
Monitor the standard jobname /IWBEP/QUERY_RESULT_LOG_CLEANUP which uses the standard program - /IWBEP/R_CLEAN_UP_QRL scheduled based on required days to clear the delta token from the system saved as variant.
Note: The standard job can be updated with required scheduled cycle from tcode - SM36
and on execution the cache memory of delta query will be removed.
Conclusion
If you have any questions related to the same, feel free to post a question here
Please make sure to follow my profile to know more about my upcoming blog where I will write on how to design a complex MDK application with multiple screens and API.
If you have any further queries, feel free to comment.
Authors
Name : | Nabsri Subha Sourya | |
Name : | Jagadisha N | |
Name : | Navarathana Kumar |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |