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 records from internal table using another internal table

Former Member
0 Likes
17,072

HI,

I have two internal tables itab1 and itab2 which have same records initially.Later some records of itab2 are deleted .Then i want to delete those records from itab1 also ie,those records not found in itab2 .Is there any method other than looping.

So that itab1 again becomes equal to itab2.

Thanks in advance.

Sowmya.

5 REPLIES 5
Read only

Former Member
0 Likes
4,150

try this

itab1 = itab2.

Read only

Former Member
0 Likes
4,150

Hi Sowmya,

The two way outs:

1) if you have make itab1 = itab2 then you can simply move itab2 to itab1 this will overwrite the records in itab1 with the records of itab2..

2) whereever you are deleting the record ffrom itab2 there delete the same record from itab1 also so that no extra loop ia requied to make these tables equal.

reward points if useful...

Read only

Former Member
0 Likes
4,150

Hi Sowmya,

The two way outs:

1) if you have make itab1 = itab2 then you can simply move itab2 to itab1 this will overwrite the records in itab1 with the records of itab2..

2) whereever you are deleting the record ffrom itab2 there delete the same record from itab1 also so that no extra loop ia requied to make these tables equal.

reward points if useful...

Read only

Former Member
0 Likes
4,150

YOU HAVE TO USE - DELETE TABLE itab [FROM wa].

you need to loop at in your itab2 into your work area , and then delete the corresponding entry from your itab1.

reward if useful

Varun Mathur

Edited by: Varun Mathur on Feb 18, 2008 6:55 AM

Read only

Former Member
0 Likes
4,150

Soumya,

Itab1 , Itab2 .

Before deleting the records from itab2 move those records to one more internal table itab3.

Now you have deleted records of itab2 in itab3.

SORT ITAB3,ITAB1 by your main key field.

LOOP AT itab3.

READ TABLE ITAB1 WITH KEY key field = itab3-

keyfield.

IF sy-subrc EQ 0.

DELETE itab1 where keyfield eq itab3-keyfield.

ENDIF.

ENDLOOP.