2010 Dec 16 4:42 PM
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!
2010 Dec 16 9:51 PM
>
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.
>
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.
2010 Dec 16 9:51 PM
>
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.
2010 Dec 17 10:41 AM
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!!!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |