‎2008 Jun 09 10:16 AM
Hi,
I have 2 internal tables.
ITAB1 has 100 records.
ITAB 2 has 10 records.
I want to delete the records from ITAB1 which are present in the ITAB2.
Is htere any way without using the LOOP?
Thanks in advance.
‎2008 Jun 09 10:19 AM
do.
read itab2 into wa index sy-index.
if sy-sbrc ne 0.
exit.
endif.
read itab1 where itab1 eq wa.
if sy-subrc eq 0.
delete itab1.
modify itab1.
endif.
enddo.
‎2008 Jun 09 10:21 AM
hi there....
do as follows
loop at itab1.
loop at itab2.
if itab1-field1 eq itab2-field1 and itab1-field2 eq itab2-field2.....
clear itab2.
update itab2.
endif.
endloop.
endloop.
i hope it helps...
do reward if helpful.
‎2008 Jun 09 10:22 AM
Hi ,
combined two internal table into final_itab and use
DELETE ADJACENT DUPLICATES final_itab COMPARING VALUES.
Regards,
Vishvesh.
‎2008 Jun 09 10:24 AM
Hi,
LOOP AT ITAB1 into wa_itab1
READ TABLE ITAB2 WITH VAR = wa_itab1-VAR1.
DELETE TAble ITAB1 from wa_itab1
ENDLOOP.
‎2008 Jun 09 11:46 AM
Not possible without some sort of loop. My general approach would be:
- LOOP AT the smaller table using ASSIGNING (not INTO)
- READ the corresponding entry in the larger table (table should be of type SORTED, use full table key for access) using TRANSPORTING NO FIELDS
- if found, DELETE that entry from the larger table using INDEX
Thomas
‎2008 Jun 09 11:55 AM
hi,
If same fields are there in both internal tables then you can combine data in one internal table and just use DELETE ADJACENT DUPLICATES ..
& if different fields are there then use
LOOP AT it_prd.
READ TABLE it_chs WITH KEY
spras = 'E'
msehi = it_prd-msehi.
IF sy-subrc NE 0.
WRITE:/ w_tmp.
APPEND it_prd TO it_s.
incs = incs + 1.
ENDIF.
if sy-subrc EQ 0.
clear it_chs.
endif.
ENDLOOP.
reward points if useful.
thx,
twinkal
‎2008 Jun 09 11:58 AM
may be you dont want looping because of performance
in delete statement you provide values in where condition which are in itab2
‎2008 Jun 09 12:01 PM
Hi,
To reduce time taken,
Loop at itab2.
delete itab1 where key1 = itab1-key1.
endloop.
In all, you will loop only 10 times.
Shruthi
‎2008 Jun 09 12:37 PM
Hello Pranu,
if you are looking for a sinle code line whic can delete one internal table rows from another similar internal table... then I am sorry there is no such way as of now. You have to use some form logic with loop process as described by SDN members.
However "DELETE ADJACENT DUPLICATES FROM... " may not meet the requirement as one set of value still remains in the table and only the duplicate entry is removed.
Regards,
Mahidhar
‎2008 Jun 09 12:49 PM
Hi,
Please refer the code below:
loop at itab1.
read table itab2 with key f1 = itab1-f1. "Use all necessary key fields.
if sy-subrc eq 0.
delete itab1.
clear itab1.
endif.
endloop.
Thanks,
Sriram Ponna.
‎2008 Jun 09 12:51 PM
hi ,
pls try this .
loop at itab1 .
read table itab2 with key matnr = itab1-matnr .
if sy-subrc = 0.
delete itab1 index sy-tabix .
endif .
clear itab1 .
endloop .