Application Development 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: 

delete lines from internal table.

Former Member
0 Kudos

hi all.

i have two internal tables ITAB and ITAB1. ITAB having records which exists in ITAB1 also. now i want to delete that records from ITAB which are in ITAB1.

how can i do this?

thanks.

null

5 REPLIES 5

Former Member
0 Kudos

loop at itab1.

read table itab with key f1 = itab1-f1.

if sy-subrc = 0.

delete itab index sy-tabix.

endif.

endloop.

regards

shiba dutta

amit_khare
Active Contributor
0 Kudos

Hi,

Deleting is a tedious process instead use a third internal table and read all distinct values into it.

I think that will be easy.

Regards,

Amit

0 Kudos

loop at p_sub.

read table intab with key locno eq p_sub-locno.

if sy-subrc eq 0.

delete intab.

ENDIF.

endloop.

kishan negi

Former Member
0 Kudos

try this code ,change table name accordingly but main thing is tht u shud have primary key common in both the table -

data: begin of itab occurs 0.

include structure zgill_main.

data end of itab.

data itab1 like itab occurs 0 with header line.

data wa_itab like itab.

data:i1 type i value 0.

select * from zgill_main into table itab.

select * from zgill_main into table itab1 where pernr = '11111111'.

loop at itab into wa_itab.

i1 = i1 + 1.

read table itab1 with key pernr = wa_itab-pernr.

if sy-subrc = 0.

delete itab index i1.

endif.

endloop.

Former Member
0 Kudos

hi,

execute the following code .

data:begin of itab occurs 0,

f1(3) type c,

f2(3) type c,

end of itab.

data:begin of itab1 occurs 0,

f1(3) type c,

f2(3) type c,

end of itab1.

itab-f1 = 'ABC'.itab-f2 = '123'.append itab.clear itab.

itab-f1 = 'ZXC'.itab-f2 = '678'.append itab.clear itab.

itab-f1 = 'HGD'.itab-f2 = '658'.append itab.clear itab.

itab-f1 = 'KDJ'.itab-f2 = '645'.append itab.clear itab.

itab1-f1 = 'ZXC'.itab1-f2 = '678'.append itab1.clear itab1.

itab1-f1 = 'KDJ'.itab1-f2 = '645'.append itab1.clear itab1.

loop at itab.

read table itab1 with key f1 = itab-f1.

if sy-subrc = 0.

delete itab.

endif.

endloop.

loop at itab.

write:/ itab-f1, itab-f2.

endloop.

if it helpful reward me.