Skip to Content

The logic of how customizing data download avoids duplication

In crm, there's a table CRMC_INIT_HELP. For a successful download, the table CRMC_INIT_HELP will be cleared.

Take load of DNL_CUST_PRICE for example, the coding is as follows:

In mapping FM CRMC_OUTPUT_PRICING_MAP_SAVE,

    SELECT SINGLE * FROM crmc_init_help
                    INTO ls_init_help
                    WHERE tab_name = 'T052'.
    IF sy-subrc eq 0.

       IF ls_init_help-ref_id eq i_bapicrmdh2-ref_id.
*       ok

      ELSE.
*        there is an old entry in CRMC_INIT_HELP for this ta
        DELETE FROM crmc_init_help WHERE tab_name = 'T052'.
        DELETE FROM crmc_pmnttrms  CLIENT SPECIFIED
                                   WHERE client = sy-mandt.
        ls_init_help-client   = sy-mandt.
        ls_init_help-tab_name = 'T052'.
        ls_init_help-ref_id   = i_bapicrmdh2-ref_id.
        INSERT INTO crmc_init_help CLIENT SPECIFIED VALUES ls_init_help.
      ENDIF.
    ELSE.
*     entry does not exist so far

      DELETE FROM crmc_pmnttrms  CLIENT SPECIFIED
                                 WHERE client = sy-mandt.
      ls_init_help-client   = sy-mandt.
      ls_init_help-tab_name = 'T052'.

      ls_init_help-ref_id   = i_bapicrmdh2-ref_id.

      INSERT INTO crmc_init_help CLIENT SPECIFIED VALUES ls_init_help.

    ENDIF.

line 836

IF not i_bapicrmdh2-lastblock is initial.

    DELETE FROM crmc_init_help CLIENT SPECIFIED

           WHERE ref_id = i_bapicrmdh2-ref_id.

When R3 sends customizing data to CRM, the block will contain a ref_id(guid). For every successful processing of a LUW, the R3 table name associated with this LUW will be stored into CRMC_INIT_HELP, together with the ref_id from R3.

In CRM, when processing the incoming R3 table data, it will firstly check if there's an entry in CRMC_INIT_HELP for this R3 table. If so, it will compare the ref_id in CRMC_INIT_HELP with the ref_id from R3 data, if same, it means there're already previous LUWs that have been processed for the same R3 table, so the download of the same R3 table should continue, then it will not delete the CRM table. If CRMC_INIT_HELP-ref_id is not the same as r3 ref_id, it means the CRM customizing table contains stale data, so it will delete CRM customizing table firstly, then insert r3 table data.

If there's no entry in CRMC_INIT_HELP for this R3 table, it means the R3 table has yet to be downloaded this time(last time it was successfully downloaded so the CRM customizing table has the old data) then it will firstly delete the CRM customizing table and also update CRMC_INIT_HELP with the table name and R3 ref_id.

Tags:
Former Member