Correction of Unique Record Identifier


Case: URI, Unique Records Identifier is basically used to distinguish each record identical. Usually, it is a concatenation of Date, Time, DatapackID, Record number.


Scenario: In my Standard DSO, URI got duplicated for more than one record. Somehow, datapackid is blank for both the records. Like below:

Duplicated URI
Record 1
0000201808311156260000000000001226
Record 2
0000201808311156260000000000001226


Steps to correct duplicated URI records in G* Layer DSO:
1. Create a copy the Original DSO.
2.  Load the selected URI records from main DSO Layer to copy DSO and update with a new URI with below logic in Start Routine.

    DATA: WA_SOURCE_PACKAGE TYPE _ty_s_SC_1,
          lv_pre_uri        TYPE /BIC/OIXXXXX0002,
          lv_uri            TYPE /BIC/OIXXXXX0002,
          lv_start          TYPE c LENGTH 18,
          lv_mid(6)         TYPE N VALUE '000000',
          lv_end            TYPE c LENGTH 10.

    SORT SOURCE_PACKAGE BY /BIC/XXXXX0002 DOC_NUMBER S_ORD_ITEM
    ASCENDING.
    CLEAR: lv_pre_uri.

    LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
      lv_uri = WA_SOURCE_PACKAGE-/BIC/XXXXX0002.
      lv_start = lv_uri+0(18).
      lv_end = lv_uri+24(10).

      IF lv_pre_uri <> lv_uri.
        lv_mid = '000001'.
        lv_pre_uri = lv_uri.
      ELSEIF lv_pre_uri = lv_uri.
        lv_mid = lv_mid + 1.
      ENDIF.

      CONCATENATE lv_start lv_mid lv_end INTO
      WA_SOURCE_PACKAGE-/BIC/XXXXX0002.
      MODIFY SOURCE_PACKAGE FROM WA_SOURCE_PACKAGE TRANSPORTING
      /BIC/XXXXX0002.

    ENDLOOP.

The above logic will only replace/modify the datapackid part in the URI and rest part of the URI will be the same. for example:

Duplicated URI
Modified URI
Record 1
0000201808311156260000000000001226
0000201808311156260000010000001226
Record 2
0000201808311156260000000000001226
0000201808311156260000020000001226


3.  Now delete the selected URI from the main DSO.
4.  Load the corrected URI records from copy DSO to main DSO.

Comments

Popular posts from this blog

Simple Program to Check Active Requests in ODSOs / ADSOs

Simplification List for SAP BW/4HANA (SAP Release 18th June’ 2018)

Unforeseen Issue during SAP BW Data Flow Migration