Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Deleting Source Package based on Data in Work Area

Former Member
0 Likes
2,760

I'm working on a transformation that needs to look at the Target DSO, and only load records where in the target the records matching the criteria have 0 as its quantity. So far I have the following

I've created my work area containing the required fields for comparison:

TYPES: begin of ty_zos_lo49,
             DOC_NUMBER           type  /BI0/OIDOC_NUMBER,
             DELIV_NUMB             type  /BI0/OIDELIV_NUMB,
             DELIV_ITEM               type  /BI0/OIDELIV_ITEM,
             MATERIAL                 type  /BI0/OIMATERIAL,
             /BIC/ZDISC_MRG       type  /BIC/OIZDISC_MRG,
             /BIC/Z_DISCQTY(2)   type  n,
             end of ty_zos_lo49.
    DATA:
            w_zos_lo49      TYPE STANDARD TABLE OF ty_zos_lo49,

and I've filled this work area for records in my source package that are also in the target with 0 records:

IF w_zos_lo49 is INITIAL.
   SELECT DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG
    FROM /BIC/AZOS_LO4900
     INTO CORRESPONDING FIELDS OF TABLE w_zos_lo49
      FOR ALL ENTRIES IN SOURCE_PACKAGE
      WHERE DOC_NUMBER      = SOURCE_PACKAGE-DOC_NUMBER     AND
            DELIV_NUMB      = SOURCE_PACKAGE-DELIV_NUMB     AND
            DELIV_ITEM      = SOURCE_PACKAGE-DELIV_ITEM     AND
            /BIC/ZDISC_MRG  = SOURCE_PACKAGE-/BIC/Z_CUTCODE AND
            /BIC/Z_DISCQTY  = 0.
ENDIF.

Now I want to keep only therecords from my source package that are in my work area (w_zos_lo49 ) and this is where I am having problems. I've tried the following but recieve an error (about the declaration for DELIV_NUMB being incomplete).

DATA: WA_SOURCE_PACKAGE2  TYPE _ty_s_SC_1.

   LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE2.
      READ TABLE w_zos_lo49
        WITH TABLE KEY DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER
        TRANSPORTING NO FIELDS.
    IF SY-SUBRC <> 0.
       DELETE SOURCE_PACKAGE.
    ENDIF.
    ENDLOOP.

I also want to read the table where DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG are in both, not just DOC NUMBER.

Please can someone advise me as to how I can complete this final step? Am I on the right lines?

Many Thanks in advance!

1 ACCEPTED SOLUTION
Read only

former_member191735
Active Contributor
0 Likes
905

>

DATA: WA_SOURCE_PACKAGE2  TYPE _ty_s_SC_1.
> 
>    LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE2.
>       READ TABLE w_zos_lo49
>         WITH TABLE KEY DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER
>         TRANSPORTING NO FIELDS.
>     IF SY-SUBRC <> 0.
>        DELETE SOURCE_PACKAGE.
>     ENDIF.
>     ENDLOOP.

>

> I also want to read the table where DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG are in both, not just DOC NUMBER.

Define the following way.... You have used with table key where as no key defined in decleration of internal table W_ZOS_LO49.

Do the following

READ TABLE w_zos_lo49 with key

DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER

Deliv_numb = wa_xxx-delivnumb

material = wa_xxx-material

TRANSPORTING NO FIELDS.

I'm working on a transformation that needs to look at the Target DSO, and only load records where in the target the records matching the criteria have 0 as its quantity. So far I have the following

I've created my work area containing the required fields for comparison:

TYPES: begin of ty_zos_lo49,
             DOC_NUMBER           type  /BI0/OIDOC_NUMBER,
             DELIV_NUMB             type  /BI0/OIDELIV_NUMB,
             DELIV_ITEM               type  /BI0/OIDELIV_ITEM,
             MATERIAL                 type  /BI0/OIMATERIAL,
             /BIC/ZDISC_MRG       type  /BIC/OIZDISC_MRG,
             /BIC/Z_DISCQTY(2)   type  n,
             end of ty_zos_lo49.
    DATA:
            w_zos_lo49      TYPE STANDARD TABLE OF ty_zos_lo49,

and I've filled this work area for records in my source package that are also in the target with 0 records:

IF w_zos_lo49 is INITIAL.
   SELECT DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG
    FROM /BIC/AZOS_LO4900
     INTO CORRESPONDING FIELDS OF TABLE w_zos_lo49
      FOR ALL ENTRIES IN SOURCE_PACKAGE
      WHERE DOC_NUMBER      = SOURCE_PACKAGE-DOC_NUMBER     AND
            DELIV_NUMB      = SOURCE_PACKAGE-DELIV_NUMB     AND
            DELIV_ITEM      = SOURCE_PACKAGE-DELIV_ITEM     AND
            /BIC/ZDISC_MRG  = SOURCE_PACKAGE-/BIC/Z_CUTCODE AND
            /BIC/Z_DISCQTY  = 0.
ENDIF.

Now I want to keep only therecords from my source package that are in my work area (w_zos_lo49 ) and this is where I am having problems. I've tried the following but recieve an error (about the declaration for DELIV_NUMB being incomplete).

DATA: WA_SOURCE_PACKAGE2  TYPE _ty_s_SC_1.

   LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE2.
      READ TABLE w_zos_lo49
        WITH TABLE KEY DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER
        TRANSPORTING NO FIELDS.
    IF SY-SUBRC <> 0.
       DELETE SOURCE_PACKAGE.
    ENDIF.
    ENDLOOP.

I also want to read the table where DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG are in both, not just DOC NUMBER.

Please can someone advise me as to how I can complete this final step? Am I on the right lines?

Many Thanks in advance!

2 REPLIES 2
Read only

former_member191735
Active Contributor
0 Likes
906

>

DATA: WA_SOURCE_PACKAGE2  TYPE _ty_s_SC_1.
> 
>    LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE2.
>       READ TABLE w_zos_lo49
>         WITH TABLE KEY DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER
>         TRANSPORTING NO FIELDS.
>     IF SY-SUBRC <> 0.
>        DELETE SOURCE_PACKAGE.
>     ENDIF.
>     ENDLOOP.

>

> I also want to read the table where DOC_NUMBER DELIV_NUMB DELIV_ITEM MATERIAL /BIC/ZDISC_MRG are in both, not just DOC NUMBER.

Define the following way.... You have used with table key where as no key defined in decleration of internal table W_ZOS_LO49.

Do the following

READ TABLE w_zos_lo49 with key

DOC_NUMBER = WA_SOURCE_PACKAGE2-DOC_NUMBER

Deliv_numb = wa_xxx-delivnumb

material = wa_xxx-material

TRANSPORTING NO FIELDS.

Read only

0 Likes
905

Brilliant! Thanks so much.

I used the following code and it works perfectly:

DATA: WA_SOURCE_PACKAGE2  TYPE _ty_s_SC_1.

    LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE2.
        READ TABLE w_zos_lo49 with key
                DOC_NUMBER     = WA_SOURCE_PACKAGE2-DOC_NUMBER
                DELIV_NUMB     = WA_SOURCE_PACKAGE2-DELIV_NUMB
                DELIV_ITEM     = WA_SOURCE_PACKAGE2-DELIV_ITEM
                MATERIAL       = WA_SOURCE_PACKAGE2-MATERIAL
                /BIC/ZDISC_MRG = WA_SOURCE_PACKAGE2-/BIC/Z_CUTCODE
              TRANSPORTING NO FIELDS.
          IF SY-SUBRC <> 0.
              DELETE SOURCE_PACKAGE.
          ENDIF.
    ENDLOOP.

POINTS ASSIGNED!!!