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

Delete Sourcepackage where code is in another internal table

Former Member
0 Likes
5,689

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!!!

5 REPLIES 5
Read only

Former Member
0 Likes
2,012

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.

Read only

0 Likes
2,012

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

Read only

0 Likes
2,012

where are you assigning the field symbol <SOURCE_FIELDS> ???

Read only

0 Likes
2,012

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!

Read only

0 Likes
2,012

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.