In enterprise systems, data volumes can be enormous, and transferring complete datasets repeatedly is neither efficient nor practical. This is especially true for mobile apps, Fiori UIs, or third-party integrations interacting with SAP backend systems via OData services. To solve this, Delta Handling in SAP Gateway enables clients to retrieve only the changed, newly created, or deleted data since the last data fetch, significantly optimizing performance and reducing bandwidth usage.
Delta Handling refers to the ability of an OData service to deliver only the changes (deltas) that have occurred since a previous data retrieval. Instead of reloading entire datasets, delta queries return only:
This is particularly useful for mobile applications, background sync jobs, and UI5 applications that rely on data synchronization rather than full reloads.
In OData version 2, SAP Gateway supports delta handling through:
Initial Read
GET call is made to the collection (e.g., /Employees).__deltaLink containing the delta token.Subsequent Read
/Employees?$deltatoken=ABC123) to fetch only changes since the initial call.Backend Logic
To implement delta handling in a custom OData service, follow these key steps:
Override the DEFINE method to enable delta support:
method DEFINE.
super->define( ).
DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ.
lo_entity_type = model->get_entity_type( 'Employee' ).
lo_entity_type->set_delta_supported( abap_true ).
endmethod.
Implement the method GET_ENTITYSET_DELTA to return changed data based on delta token:
method EMPLOYEESET_GET_ENTITYSET_DELTA.
" Read delta token from import parameters
DATA: lv_deltatoken TYPE string.
lv_deltatoken = io_tech_request_context->get_delta_token( ).
" Query delta changes from DB or change log based on token
" Example pseudo-code:
" SELECT * FROM zemployee WHERE last_changed > lv_deltatoken
" Populate et_entityset with changed data
endmethod.
Generate and include a delta token in the initial response using:
io_delta_token->set_delta_token( 'timestamp-or-custom-id' ).
This token will be passed back by the client in the next delta call.
Delta handling is supported for:
Entity Sets (not single entities)
Flat data structures (complex associations require custom handling)
Use cases with identifiable change tracking, such as:
You can monitor delta-related calls in SAP Gateway using:
$deltatoken queriesDelta handling is a must-have optimization for modern SAP Gateway-based integrations. By intelligently tracking and transmitting only the changes in data, SAP systems can drastically improve responsiveness, user experience, and resource efficiency.
Whether you're building SAP Fiori apps, mobile sync scenarios, or real-time dashboards, mastering delta handling ensures your solution scales effectively without overloading the network or backend systems.