on 09-18-2013 1:00 PM
Hello Experst,
How to develop delta query in SAP Gateway, we want to bring last changed data.
I am referring this URL http://help.sap.com/saphelp_nw74/helpdata/en/19/a426519eff236ee10000000a445394/content.htm
but i don't know where to use this code and how my oData query stream will look like.
Please Suggest
Regards
Manish
http://help.sap.com/saphelp_gateway20sp06/helpdata/en/2e/d7d9ee0f0f4c3292a555ec1c2952b1/frameset.htm
Hi Manish,
These are my thoughts. I have not tried them before.
To support Delta token, first you need to issue delta token with your all query outputs. That is done by filling ES_RESPONSE_CONTEXT-deltatoken. Delta token can be date and time, and it is upto you to decide the format and content. Once you put in the above variable, it should be available to the client in the form of response headers.
When the client wants to query the Collection again and wants to use the delta functionality, then it has to use the last delta token and pass it as part of the URI. ($delta)
Example: ....../PincodeCollection?$deltatoken=20120101
Inside the DPC class, get_entityset method, you fetch the delta token value from the code given in your link. (example of handling a delta token link).
Then you use it to query your application data and pass only the ones which are changed after that date. Also remember to issue the delta token, so that client can use it next time.
Let us know what is your business case and how it went. Interested to know.
Thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Manish,
For the delta synchronization, you have to create something which knows how old your data is. For example, imagine you have a table with columns: Table, Record ID, Update Time. This table contains the history of all tables and records that are required for your business. Each time, you update/create/delete the record, you have to maintain a corresponding record in this table.
Each time, you make the GET request with the delta token, you check this table first, and then return updated records only. Well... actually, that is why SAP provides SMP
Kind regards,
Vlad
Hello Krishna & Vlad,
I am not able to find ET_SERVICE_MODEL_INFOS in the signature, how to use this.
data lo_delta_context type /IWBEP/IF_MGW_REQ_ENTITYSTDLTA
* first get the delta token
lo_delta_context =? io_tech_request_context.
lv_delta_token = lo_delta_context->get_deltatoken( ). "converts it automatically into a datetime
loop at ET_SERVICE_MODEL_INFOS REFERENCE INTO lr_svc_mdl_info.
TRY .
if lr_svc_mdl_info->*-last_modified le lv_delta_token.
* then add it to the return table
delete ET_SERVICE_MODEL_INFOS index sy-tabix.
endif.
* catch as much as possible
CATCH cx_root INTO lx_exception.
* service does not exist anymore or is not compileable --> put it to the deleted entries
lr_svc_mdl_info->*-deleted = abap_true.
ENDTRY.
endloop.
Regards
Manish
Hi Manish,
I have not implemented deltatoken. Form the experience I can suggest the following.
Gateway does not automatically filterout data based on the delta token. In the data provider the logic needs to be handled carefully. If you have created new records even after timestamp specified in the deltatoken(20130927) and you are not getting the expected result back, then this means the the filtering logic implemented in the DPC needs to be re checked. Please check if youare returning the currect result(the filtered resultset) back via export parameter 'ER_ENTITYSET' of /IWBEP/IF_MGW_APPL_RUNTIME~GET_ENTITYSET() of your DPC ?
Please refer to the sample code mentioned in the documentation(SP6) provided.
This is a sample code and ET_SERVICE_MODEL_INFOS REFERENCE contains the list of all the records. Now you need to remove all the records from ET_SERVICE_MODEL_INFOS REFERENCE for which creation date/time is less than deltatoken(20130927). Once removed you will only have the result set which is created after the specified delta token.
loop at ET_SERVICE_MODEL_INFOS REFERENCE INTO lr_svc_mdl_info.
TRY .
if lr_svc_mdl_info->*-last_modified le lv_delta_token.
* then add it to the return table
delete ET_SERVICE_MODEL_INFOS index sy-tabix.
endif.
* catch as much as possible
CATCH cx_root INTO lx_exception.
* service does not exist anymore or is not compileable --> put it to the deleted entries
lr_svc_mdl_info->*-deleted = abap_true.
ENDTRY.
endloop.
For Deltatoken implementation following things must be considered.
Hope this helps.
Regards,
Atanu
Hello Manish, The parameter ES_RESPONSE_CONTEXT is available in the GET_ENTITYSET. Exactly this parameter you should change to supply a delta token. Kind regards, Vlad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.