‎2010 Dec 10 11:40 AM
I'm working on a Transformation and have a requirement to delete out certain records from the source_package where a code in that source_package is NOT in one of my infoobjects (this is likely to change so I want the ability to modify the list of codes without transporting any code changes). I have loaded my infoobject into an internal table called w_cutcodes containing only the 4 cutcodes I want to keep. This is the code I have so far (throws up syntax errors).
LOOP AT SOURCE_PACKAGE.
READ TABLE w_cutcodes
WHERE /BIC/Z_CUTCODE = w_cutcodes/BIC/ZCUTCDINC.
IF SY-SUBRC <> 0.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDLOOP.
I just get the "E:At "LOOP AT itab", one of the additions "INTO", "ASSIGNING", or "TRANSPORTING NO FIELDS" is required. in the OO context" syntax error.
Any ideas how to delete all records out of the source package where the cutcode is not in the list of cutcodes in my itab? Any help is much appreciated as this is driving me nuts!!!
‎2010 Dec 10 11:43 AM
Hi,
Declare a work area (WA_SOURCE_PACKAGE) and write as :
LOOP AT SOURCE_PACKAGE into WA_SOURCE_PACKAGE.
READ TABLE w_cutcodes
WHERE /BIC/Z_CUTCODE = w_cutcodes/BIC/ZCUTCDINC.
IF SY-SUBRC 0.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDLOOP.
Regards,
Srini.
‎2010 Dec 10 2:15 PM
Many thanks for your quick response. Your answer seems to have got me a lot closer to a solution. THis is what I current'y have:
DATA WA_SOURCE_PACKAGE TYPE tys_SC_1.
LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
READ TABLE w_cutcodes
WITH KEY /BIC/ZCUTCDINC = <SOURCE_FIELDS>-/BIC/Z_CUTCODE
TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDLOOP.
In contains no syntax errors, but when I run this I recieve the following runtime error:
GETWA_NOT_ASSIGNED
Any ideas anyone? Many thanks in advance
‎2010 Dec 10 2:32 PM
where are you assigning the field symbol <SOURCE_FIELDS> ???
‎2010 Dec 10 2:52 PM
I haven't assigned it myself, I was trying to refer to the cut code in the source package and found <SOURCE_FIELDS> in some other code. Apologies, I'm pretty new to ABAP so that might've been a school boy error!
‎2010 Dec 10 3:44 PM
RESOLVED!!! It was the <source-fields> bit that was causing the error. This needed to be the same as my work area (WA_SOURCE_PACKAGE). Thanks for all your help guys. Here's the code in case anyone else is trying to do something similar:
DATA WA_SOURCE_PACKAGE TYPE _ty_s_SC_1.
LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
READ TABLE w_cutcodes
WITH TABLE KEY /BIC/ZCUTCDINC = WA_SOURCE_PACKAGE-/BIC/Z_CUTCODE
TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDLOOP.