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 from Internal table.....

Former Member
0 Likes
944

Hi All,

I have two internal tables with same structure like: IT_REC_LIST and IT_REC_LIST_DEL.

I have 10 records in this internal table: IT_REC_LIST and same 5 records in this internal table: IT_REC_LIST_DEL. I don’t have any key fields.

So I want to delete those 5 records from IT_REC_LIST. Could you please let me know hw to write the code, when I write like below its going for dump.

DELETE IT_REC_LIST [] FROM IT_REC_LIST_DEL [].

Akhitha.

Hi All,

I have two internal tables with same structure like: IT_REC_LIST and IT_REC_LIST_DEL.

I have 10 records in this internal table: IT_REC_LIST and same 5 records in this internal table: IT_REC_LIST_DEL. I don’t have any key fields.

So I want to delete those 5 records from IT_REC_LIST. Could you please let me know hw to write the code, when I write like below its going for dump.

DELETE IT_REC_LIST [] FROM IT_REC_LIST_DEL [].

Akhitha.

9 REPLIES 9
Read only

Former Member
0 Likes
923

loop at IT_REC_LIST_DEL.
  DELETE IT_REC_LIST FROM IT_REC_LIST_DEL .
endloop.
Read only

Former Member
0 Likes
923

Hello,

You can do like :


loop at IT_REC_LIST .
read table IT_REC_LIST_del with key field1 = IT_REC_LIST-field1.
if sy-subrc eq 0.
delete IT_REC_LIST. 
endif.
endloop.

<REMOVED BY MODERATOR>

Vasanth

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 5:28 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
923

there must be a field similar in two itabs..

without that based on what u r deleting..it makes no sense.

Read only

0 Likes
923

Ya, i got it,

all are same fields in both internal tbales, but its not key fields..

Read only

0 Likes
923

data:wa1 like itab1.

data:wa2 like itab2.

Loop at it1 into wa1.

read table it2 into wa2 with key <field1> = <wa1-field1>

<field2> = <wa1-field2>

<field3> = <wa1-field3>

<field4> = <wa1-field4>

<field5> = <wa1-field5>.

if sy-subrc = 0.

delete it1 from wa1.

endif.

endloop.

Read only

0 Likes
923

hi,

lets have itab with 10 fields.

itab1 with 5 fields.

then

loop at itab.

delete itab1 where col2 = itab-col1.

endloop.

loop at itab1.

write : itab1-col2.

endloop.

try this.

Read only

0 Likes
923

hw u r saying that, what is col2 and what is col1, i dont think that will work.....

Akshitha.

Read only

0 Likes
923

did u try my post

Read only

0 Likes
923

Im sure, that will work, but its not that much lengthy code, it should come for only one or two lines as they are expecting, thats why im thinking.....! any other alternate.

Akshitha.