Developer

Redefining the GET_ENTITYSET_DELTA Method

Redefine the GET_ENTITYSET_DELTA method to retrieve the entity set delta by comparing the current hash values to the hash values of the prior call.

Procedure

  1. Redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET_DELTA .
  2. Retrieve all relevant entries for this entity set (as for GET_ENTITYSET).
  3. Get the data provider facade:
    * get the data provider facade
    TRY.
      lo_dp_facade = /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
    CATCH /iwbep/cx_mgw_tech_exception.
      RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
    ENDTRY.
  4. Call the /IWBEP/CL_QUERY_RESULT_LOG-> CREATE_UPDATE_LOG_ENTRY_HASH method for the delta query functionality by passing local table ET_ENTITYSET containing the business partner entries. Take over the changed objects and store them in local table LT_BUSINESSPARTNER. Similarly, take over the deleted objects and store them in local table LT_DELETED_BUSINESSPARTNER:
    * call the delta token functionality
    TRY.
      CALL METHOD /iwbep/cl_query_result_log=>create_update_log_entry_hash
        EXPORTING
          io_tech_request_context = io_tech_request_context
          io_dp_facade = lo_dp_facade
          ir_service_document_name = mr_service_document_name
          ir_service_version = mr_service_version
          it_entityset = lt_businesspartner
        IMPORTING
          et_deleted_entityset = lt_deleted_businesspartner
          et_entityset = lt_businesspartner
        CHANGING
          ev_delta_token = lv_delta_token.
      CATCH /iwbep/cx_qrl_locked.
        RAISE EXCEPTION TYPE /iwbep/cx_qrl_locked.
      CATCH /iwbep/cx_qrl_delta_unavailabl.
        RAISE EXCEPTION TYPE /iwbep/cx_qrl_delta_unavailabl.
    ENDTRY.
  5. Export the delta token which was calculated by the method in step 4:
    es_response_context-deltatoken = lv_delta_token.
  6. Export the deleted entity set - add deleted records from the table LT_DELETED_BUSINESSPARTNER to the deleted entries list ER_DELETED_ENTITYSET:
    * export the deleted entity set
    copy_data_to_ref( EXPORTING
        is_data = lt_deleted_businesspartner
      CHANGING
        cr_data = er_deleted_entityset ).
  7. Export the changed entity set - add changed records from the table LT_BUSINESSPARTNER to the changed entries list ER_ENTITYSET:
    * export the changed entity set
    copy_data_to_ref( EXPORTING
        is_data = lt_businesspartner
      CHANGING
        cr_data = er_entityset ).

Results

The /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET_DELTA method and complete code should look similar to:
DATA:
  lt_return TYPE TABLE OF bapiret2,
  lv_entity_set_name TYPE string,
  lt_businesspartner TYPE zcl_z_epm_rkt_mpc=>tt_businesspartner,
  ls_businesspartner TYPE zcl_z_epm_rkt_mpc=>ts_businesspartner,
  lt_deleted_businesspartner TYPE zcl_z_epm_rkt_mpc=>tt_businesspartner,
  ls_deleted_businesspartner TYPE zcl_z_epm_rkt_mpc=>ts_businesspartner,
  lv_delta_token TYPE string,
  lo_dp_facade TYPE REF TO /iwbep/if_mgw_dp_facade.

FIELD-SYMBOLS:
  <lt_businesspartner> TYPE zcl_z_epm_rkt_mpc=>tt_businesspartner,
  <lt_deleted_businesspartner> TYPE zcl_z_epm_rkt_mpc=>tt_businesspartner.
  lv_entity_set_name = io_tech_request_context->get_entity_set_name( ).
  IF lv_entity_set_name = 'BusinessPartners'.

* retrieve all relevant entries for this entityset
CALL FUNCTION 'BAPI_EPM_BP_GET_LIST'
  TABLES
    headerdata = lt_businesspartner
    return = lt_return.

* get the data provider facade
TRY.
  lo_dp_facade = /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
CATCH /iwbep/cx_mgw_tech_exception.
  RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
ENDTRY.

* call the delta token functionality
TRY.
  CALL METHOD /iwbep/cl_query_result_log=>create_update_log_entry_hash
    EXPORTING
      io_tech_request_context = io_tech_request_context
      io_dp_facade = lo_dp_facade
      ir_service_document_name = mr_service_document_name
      ir_service_version = mr_service_version
      it_entityset = lt_businesspartner
    IMPORTING
      et_deleted_entityset = lt_deleted_businesspartner
      et_entityset = lt_businesspartner
    CHANGING
      ev_delta_token = lv_delta_token.
CATCH /iwbep/cx_qrl_locked.
  RAISE EXCEPTION TYPE /iwbep/cx_qrl_locked.
CATCH /iwbep/cx_qrl_delta_unavailabl.
  RAISE EXCEPTION TYPE /iwbep/cx_qrl_delta_unavailabl.
ENDTRY.

* export the delta token
  es_response_context-deltatoken = lv_delta_token.

* export the deleted entity set
    copy_data_to_ref( EXPORTING
      is_data = lt_deleted_businesspartner
    CHANGING
      cr_data = er_deleted_entityset ).

* export the changed entity set
    copy_data_to_ref( EXPORTING
      is_data = lt_businesspartner
    CHANGING
      cr_data = er_entityset ).
ENDIF.