Developer

Retrieving Entity Set Deltas

Redefine the GET_ENTITYSET_DELTA method in the runtime data provider class to return only new or changed entities from the change pointer table, based on the timestamp in the delta token.

Context

This example implements functionality for the BusinessPartner entity type, and uses this information:
  • ZEPM_MOBILE_APPLICATION – the mobile application that you configured in Creating Exchange Objects in Syclo.
  • ZEPM_BUSINESSPARTNER_EXCHANGE_OBJECT – ID of the exchange object that you configured in Creating Exchange Objects in Syclo.
  • Delta token timestamp in UTC – used to calculate the list of delta-object keys for Syclo Exchange Framework.
  • EREF_OBJKEY_LIST_RANGE – output list of delta-object keys returned by Exchange Framework. SAP recommends that you use the /IWBEP/T_COD_SELECT_OPTION structure.

Procedure

  1. In the /IWBEP/IF_MGW_APPL_SRV_RUNTIME~ runtime provider class, add this code to the GET_ENTITYSET_DELTA method:
    DATA: lt_objkey_list TYPE /iwbep/t_cod_select_options.
    DATA: lo_delta_context TYPE REF TO /iwbep/if_mgw_req_entitystdlta.
    DATA: lref_objkey_list TYPE REF TO /iwbep/t_cod_select_options.
    
    CONSTANTS:
      lc_odata_mobile_app TYPE /syclo/core_mobile_app_dte
                          
    VALUE ' ZEPM_MOBILE_APPLICATION',
      lc_exobj_businesspartner TYPE /syclo/core_exchobj_dte
                               VALUE ' ZEPM_BUSINESSPARTNER_EXCHANGE_OBJECT'.
    
    * get timestamp from delta token 
    
      lv_delta_token = io_tech_request_context->get_deltatoken( ). 
      lv_timestamp = lv_delta_token. 
    
    * retrieve created and changed entities 
      GET REFERENCE OF lt_objkey_list INTO lref_objkey_list.
       /smfnd/cl_core_exobj_tools=>determine_delta_objkeys(
         EXPORTING iv_mobile_app = lc_odata_mobile_app
                   iv_exchobj = lc_exobj_businesspartner
                   iv_time_token = lv_ts
         IMPORTING eref_objkey_list_range = lref_objkey_list ). 
    
    * conversion from lref_objkey_list type to lt_selparambpid type
    * will be needed here, this is left open for now 
    
      lt_selparambpid = _convert_somehow(lref_objkey_list).
    
    * retrieve all relevant entries for this entityset 
      CALL FUNCTION ' BAPI_EPM_BP_GET_LIST' 
        TABLES 
           selparambpid = lt_selparambpid 
           bpheaderdata = et_entityset. 
    
        LOOP AT lt_businesspartners INTO ls_businesspartner. 
          MOVE-CORRESPONDING ls_businesspartner TO ls_entityset. 
          APPEND ls_entityset TO et_entityset. 
        ENDLOOP.
    * return the time stamp as a delta token 
      GET TIME STAMP FIELD lv_delta_token. 
    
    * export the delta token in the es_response_context parameter 
      es_response_context-deltatoken = lv_delta_token.
    
  2. Save and activate your changes.