2008 Mar 06 5:34 AM
Hi all,
I have 2 itabs, itab1 & itab2.
now i want to delete records from itab1 which are not available on itab2.
i dont want to use any LOOP statement because of performance issue.
tell me is there any single DELETE statement.
Hi,
Could you specify the structure of itab1 and itab2.
Regards.
2008 Mar 06 5:37 AM
Hi,
DELETE for Database Table Entries
Deletes entries from database tables.
Syntax
DELETE FROM <dbtab> WHERE <cond>.
All of the lines in the database table that satisfy the conditions in the WHERE clause are deleted.
Syntax
DELETE <dbtab> FROM <wa>.
DELETE <dbtab> FROM TABLE <itab>.
This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length as the work area of the database table.
Regards,
Priya.
2008 Mar 06 5:37 AM
2008 Mar 06 5:44 AM
Hi,
You can use the READ for this, which won't be performance issue for u.
create one more internal table(itab3), which contains success records.
Sort itab1 with key-field.
Read table itab1 into workarea1 with key field = itab2-key.
binary search.
if sy-subrc =0.
Append itab3 with work area1.
else.
delete itab1 from workarea1.
endif.
Please reawrd points, if its helpful.
Regards,
Abhishek
2008 Mar 06 5:45 AM
Hi,
Could you specify the structure of itab1 and itab2.
Regards.
2008 Mar 06 5:46 AM
Hi..
u can try this..
while fetching data from 2 table, mention the selection criteria of the first itab in where condition....
ex :
consider that ur itab1 is filled with two fields f1 & f2.
now..
if itab1[] is not initial.
select * from db_table
into itab2
for all entries in itab1
where
db_f1 = itab1-f1.
endif.reply back..
With Rgds,
S.Barani
2008 Mar 06 5:58 AM
hi
hope it will help you.
Reward if help.
&----
*& Report ZTESTTT
*&
&----
*&
*&
&----
REPORT ZTESTTT.
tables : ekko, ekpo.
types : begin of i_ekko,
ebeln type ekko-ebeln,
end of i_ekko.
data : itab_ekko type table of i_ekko with header line,
itab_ekpo type table of i_ekko with header line.
select ebeln from ekko into table itab_ekko.
select ebeln from ekpo into table itab_ekpo.
delete itab_ekko where ebeln = itab_ekpo-ebeln.
write : itab_ekko-ebeln.
2008 Mar 06 6:23 AM
sort itab2 by <field>
Loop at itab1 into wa1.
read table itab2 into wa2 with <key> binary search.
if sy-subrc NE 0.
delete itab1.
endif.
endloop.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |