Skip to Content

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

Start routine Need to take only correct record in Dso and erroneous record in error DTP

This is CSV scenario no ECC involved. I have written these code in Start routine.

I have 3 DSO. I want to load data in dso 3 while loading data i want to check the dso1 and dso2 for source package that these entries are in presents in  dso 1 and dso2. If entry is represent then load the record  if not  then send record to error stack. I have written the code but due to standard functionality of error stack code if the there is erroneous  record in the packet it take the whole packet in error stack. My requirement is to take only erroneous record which are not their in dso1 and dso2 while data in dso3. is their a way i can achieved this .

    TYPES: BEGIN OF TY_SA,

            /BIC/ZCUSTOMER TYPE /BIC/AZSA00-/BIC/ZCUSTOMER,

            /BIC/ZP_ORG    TYPE /BIC/AZSA00-/BIC/ZP_ORG,

            /BIC/ZDOC_TYPE TYPE /BIC/AZSA00-/BIC/ZDOC_TYPE,

            /BIC/ZPUR_ORDR TYPE /BIC/AZSA00-/BIC/ZPUR_ORDR,

             OI_EBELP      TYPE /BIC/AZSA00-OI_EBELP,

          END OF TY_SA.

    DATA: ITAB_SA1 TYPE STANDARD TABLE OF TY_SA.

    FIELD-SYMBOLS <WA_SA1> TYPE TY_SA.

    TYPES: BEGIN OF TY_QUOT,

            /BIC/ZCUSTOMER TYPE /BIC/AZBID_DSO00-/BIC/ZCUSTOMER,

            /BIC/ZP_ORG    TYPE /BIC/AZBID_DSO00-/BIC/ZP_ORG,

            /BIC/ZDOC_TYPE TYPE /BIC/AZBID_DSO00-/BIC/ZDOC_TYPE,

            /BIC/ZPUR_ORDR  TYPE /BIC/AZBID_DSO00-/BIC/ZPUR_ORDR,

            OI_EBELP      TYPE /BIC/AZBID_DSO00-OI_EBELP,

          END OF TY_QUOT.

    DATA: ITAB_QUOT1 TYPE STANDARD TABLE OF TY_QUOT.

    FIELD-SYMBOLS <WA_QUOT1> TYPE TY_QUOT.

    IF SOURCE_PACKAGE IS NOT INITIAL.

*dso1 Structure

      SELECT /BIC/ZCUSTOMER /BIC/ZP_ORG /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR

        OI_EBELP

        FROM /BIC/AZSA00 INTO TABLE ITAB_SA1

        FOR ALL ENTRIES IN SOURCE_PACKAGE

        WHERE /BIC/ZCUSTOMER = SOURCE_PACKAGE-/BIC/ZCUSTOMER

        AND   /BIC/ZP_ORG    = SOURCE_PACKAGE-/BIC/ZP_ORG

        AND   /BIC/ZDOC_TYPE = SOURCE_PACKAGE-/BIC/ZDOC_TYPE

        AND   /BIC/ZPUR_ORDR = SOURCE_PACKAGE-/BIC/ZPUR_ORDR

        AND      OI_EBELP    = SOURCE_PACKAGE-OI_EBELP.

      IF ITAB_SA1 IS NOT INITIAL.

        SORT ITAB_SA1 BY /BIC/ZCUSTOMER /BIC/ZP_ORG

                        /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR OI_EBELP.

      ENDIF.

*dso2 Structure

      SELECT /BIC/ZCUSTOMER /BIC/ZP_ORG /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR

      OI_EBELP

        FROM /BIC/AZBID_DSO00 INTO TABLE ITAB_QUOT1

        FOR ALL ENTRIES IN SOURCE_PACKAGE

        WHERE /BIC/ZCUSTOMER = SOURCE_PACKAGE-/BIC/ZCUSTOMER

        AND   /BIC/ZP_ORG    = SOURCE_PACKAGE-/BIC/ZP_ORG

        AND   /BIC/ZDOC_TYPE = SOURCE_PACKAGE-/BIC/ZDOC_TYPE

        AND   /BIC/ZPUR_ORDR  = SOURCE_PACKAGE-/BIC/ZPUR_ORDR

        AND      OI_EBELP    = SOURCE_PACKAGE-OI_EBELP.

*        AND   /BIC/ZDOC_TYPE = 'QUT'.

      IF ITAB_QUOT1 IS NOT INITIAL.

        SORT ITAB_QUOT1 BY /BIC/ZCUSTOMER /BIC/ZP_ORG

                          /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR OI_EBELP.

      ENDIF.

    ENDIF.

    LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_FIELDS>.

      IF <SOURCE_FIELDS>-/BIC/ZDOC_TYPE = 'QUT'.

        READ TABLE ITAB_QUOT1 ASSIGNING <WA_QUOT1>

        WITH KEY /BIC/ZCUSTOMER = <SOURCE_FIELDS>-/BIC/ZCUSTOMER

                 /BIC/ZP_ORG    = <SOURCE_FIELDS>-/BIC/ZP_ORG

                 /BIC/ZDOC_TYPE = <SOURCE_FIELDS>-/BIC/ZDOC_TYPE

                 /BIC/ZPUR_ORDR  = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR

                   OI_EBELP    = <SOURCE_FIELDS>-OI_EBELP

                 BINARY SEARCH.

        IF SY-SUBRC NE 0.

    CLEAR MONITOR_REC.

          MONITOR_REC-msgid   = 'ZMESSAGE'.

          MONITOR_REC-msgty   = 'E'.

          MONITOR_REC-msgno   = '101'.

          MONITOR_REC-msgv1   =

          'This Transactional does not exist in Reference DSO.'.

          MONITOR_REC-msgv2   = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR.

          MONITOR_REC-recno   = <SOURCE_FIELDS>-RECORD.

          MONITOR_REC-skipped = 'X'.

          APPEND MONITOR_REC TO MONITOR.

*          RAISE EXCEPTION TYPE CX_RSROUT_ABORT.

          CONTINUE.

        ENDIF.

        ELSE.

*IF <SOURCE_FIELDS>-/BIC/ZDOC_TYPE IS NOT INITIAL.

IF <SOURCE_FIELDS>-/BIC/ZDOC_TYPE NE 'QUT'.

        READ TABLE ITAB_SA1 ASSIGNING <WA_SA1>

        WITH KEY /BIC/ZCUSTOMER = <SOURCE_FIELDS>-/BIC/ZCUSTOMER

                 /BIC/ZP_ORG    = <SOURCE_FIELDS>-/BIC/ZP_ORG

                 /BIC/ZDOC_TYPE = <SOURCE_FIELDS>-/BIC/ZDOC_TYPE

                 /BIC/ZPUR_ORDR = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR

                  OI_EBELP    = <SOURCE_FIELDS>-OI_EBELP

                 BINARY SEARCH.

        IF SY-SUBRC NE 0.

          MONITOR_REC-msgid   = 'ZMESSAGE'.

          MONITOR_REC-msgty   = 'E'.

          MONITOR_REC-msgno   = '101'.

          MONITOR_REC-msgv1   =

          'This Transactional does not exist in Reference DSO.'.

          MONITOR_REC-msgv2   = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR.

          MONITOR_REC-recno   = <SOURCE_FIELDS>-RECORD.

          MONITOR_REC-skipped = 'X'.

          APPEND MONITOR_REC TO MONITOR.

          DELETE TABLE SOURCE_PACKAGE FROM <SOURCE_FIELDS>.

*          RAISE EXCEPTION TYPE CX_RSROUT_ABORT.

          CONTINUE.

        ENDIF.

      ENDIF.

ENDIF.

ENDLOOP.

Thanks in advance.

Rashid S

replied

Issue is resolve by the changing the code .

IF SOURCE_PACKAGE IS NOT INITIAL.

       SELECT /BIC/ZCUSTOMER /BIC/ZP_ORG /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR

         FROM /BIC/AZSA00 INTO TABLE ITAB_SA

         FOR ALL ENTRIES IN SOURCE_PACKAGE

         WHERE /BIC/ZCUSTOMER = SOURCE_PACKAGE-/BIC/ZCUSTOMER

         AND   /BIC/ZP_ORG    = SOURCE_PACKAGE-/BIC/ZP_ORG

         AND   /BIC/ZDOC_TYPE = SOURCE_PACKAGE-/BIC/ZDOC_TYPE

         AND   /BIC/ZPUR_ORDR = SOURCE_PACKAGE-/BIC/ZPUR_ORDR.

       IF ITAB_SA IS NOT INITIAL.

         SORT ITAB_SA BY /BIC/ZCUSTOMER /BIC/ZP_ORG

                         /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR.

       ENDIF.

       SELECT /BIC/ZCUSTOMER /BIC/ZP_ORG /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR

         FROM /BIC/AZBID_DSO00 INTO TABLE ITAB_QUOT

         FOR ALL ENTRIES IN SOURCE_PACKAGE

         WHERE /BIC/ZCUSTOMER = SOURCE_PACKAGE-/BIC/ZCUSTOMER

         AND   /BIC/ZP_ORG    = SOURCE_PACKAGE-/BIC/ZP_ORG

         AND   /BIC/ZDOC_TYPE = SOURCE_PACKAGE-/BIC/ZDOC_TYPE

         AND   /BIC/ZPUR_ORDR  = SOURCE_PACKAGE-/BIC/ZPUR_ORDR

         AND   /BIC/ZDOC_TYPE = 'QUT'.

       IF ITAB_QUOT IS NOT INITIAL.

         SORT ITAB_QUOT BY /BIC/ZCUSTOMER /BIC/ZP_ORG

                           /BIC/ZDOC_TYPE /BIC/ZPUR_ORDR.

       ENDIF.

     ENDIF.

     LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_FIELDS>.

       LV_FLAG = 0.

       IF <SOURCE_FIELDS>-/BIC/ZDOC_TYPE = 'QUT'.

         READ TABLE ITAB_QUOT ASSIGNING <WA_QUOT>

         WITH KEY /BIC/ZCUSTOMER = <SOURCE_FIELDS>-/BIC/ZCUSTOMER

                  /BIC/ZP_ORG    = <SOURCE_FIELDS>-/BIC/ZP_ORG

                  /BIC/ZDOC_TYPE = <SOURCE_FIELDS>-/BIC/ZDOC_TYPE

                  /BIC/ZPUR_ORDR  = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR

                  BINARY SEARCH.

         IF SY-SUBRC NE 0.

           LV_FLAG = 1.

         ENDIF.

       ELSE. "'SA'

         READ TABLE ITAB_SA ASSIGNING <WA_SA>

         WITH KEY /BIC/ZCUSTOMER = <SOURCE_FIELDS>-/BIC/ZCUSTOMER

                  /BIC/ZP_ORG    = <SOURCE_FIELDS>-/BIC/ZP_ORG

                  /BIC/ZDOC_TYPE = <SOURCE_FIELDS>-/BIC/ZDOC_TYPE

                  /BIC/ZPUR_ORDR = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR

                  BINARY SEARCH.

         IF SY-SUBRC NE 0.

           LV_FLAG = 1.

         ENDIF.

       ENDIF.

       IF LV_FLAG = 1.

           MONITOR_REC-msgid   = 'ZMESSAGE'.

           MONITOR_REC-msgty   = 'E'.

           MONITOR_REC-msgno   = '101'.

           MONITOR_REC-msgv1   =

           'This Transactional does not exist in Reference DSO.'.

           MONITOR_REC-msgv2   = <SOURCE_FIELDS>-/BIC/ZPUR_ORDR.

           MONITOR_REC-recno   = <SOURCE_FIELDS>-RECORD.

           MONITOR_REC-skipped = 'X'.

           APPEND MONITOR_REC TO MONITOR.

           DELETE TABLE SOURCE_PACKAGE FROM <SOURCE_FIELDS>.

*

*          RAISE EXCEPTION TYPE CX_RSROUT_ABORT.

           CONTINUE.

         ENDIF.

ENDLOOP.

1 View this answer in context

Helpful Answer

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