Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CMOD User Exit Variable ABAP Logic

Hi,

I am in process of writing a User Exit Variable in CMOD,With help from SDN I wrote the below code which is working as expected.
But need a minor change, As my ABAP knowledge is limited need help.

After every read, If successfull I am appending the output to results (INSERT L_S_RANGE INTO TABLE E_T_RANGE) and passing value to variable.


Change I am looking is without changing the below logic …before passing into variable how can I sort all the WA_IT_TPCTR-COMP_CODE from reads and delete duplicate and then finally pass it to variable.

Please help.


    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    LOOP AT  IT_TPCTR INTO WA_IT_TPCTR.
*Read at Segment (Level 1 )
      READ TABLE IT_STORES INTO WA_IT_STORES
         WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSEGMT.
      IF SY-SUBRC = 0.
        L_S_RANGE-LOW = WA_IT_TPCTR-COMP_CODE.
        INSERT L_S_RANGE INTO TABLE E_T_RANGE.
      ELSE.
*Read at Subsegment (Level 2 )
        READ TABLE IT_STORES INTO WA_IT_STORES
          WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSUBSG.
        IF SY-SUBRC = 0.
          L_S_RANGE-LOW = WA_IT_TPCTR-COMP_CODE.
          INSERT L_S_RANGE INTO TABLE E_T_RANGE.
        ELSE.
*Read at Business Area (Level 3 )
          READ TABLE IT_STORES INTO WA_IT_STORES
            WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXBUSA.
          IF SY-SUBRC = 0.
            L_S_RANGE-LOW = WA_IT_TPCTR-COMP_CODE.
            INSERT L_S_RANGE INTO TABLE E_T_RANGE.
          ELSE.
*Read at Contract (Level 4 )
            READ TABLE IT_STORES INTO WA_IT_STORES
               WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXCTRCT.
            IF SY-SUBRC = 0.
              L_S_RANGE-LOW = WA_IT_TPCTR-COMP_CODE.
              INSERT L_S_RANGE INTO TABLE E_T_RANGE.
            ELSE.
*Read at Business Site  (Level 5 )
              READ TABLE IT_STORES INTO WA_IT_STORES
                WITH KEY /BIC/ZSDXSEGMT = WA_IT_TPCTR-/BIC/ZSDXSITE.
              IF SY-SUBRC = 0.
                L_S_RANGE-LOW = WA_IT_TPCTR-COMP_CODE.
                INSERT L_S_RANGE INTO TABLE E_T_RANGE.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDIF.

Former Member
Not what you were looking for? View more on this topic or Ask a question