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

Internal Tables

Former Member
0 Likes
683

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.

7 REPLIES 7
Read only

Former Member
0 Likes
657

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.

Read only

Former Member
0 Likes
657

Hi

its not possible at least you need to loop at itab1.

Aditya

Read only

Former Member
0 Likes
657

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

Read only

Former Member
0 Likes
657

Hi,

Could you specify the structure of itab1 and itab2.

Regards.

Read only

Former Member
0 Likes
657

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

Read only

Former Member
0 Likes
657

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.

Read only

Former Member
0 Likes
657

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.