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

Performance issue

abdulazeez12
Active Contributor
0 Likes
728

Hii all,

I have two internal tables itab1 and itab2, both having huge data. I want to compare if itab1 and itab2 have same records in them. If so, I need to delete records from itab1. So, I put like this in code:

loop at itab1.

loop at itab2.

if < conditions>

delete itab1.

endif.

endloop.

endloop.

But this is giving me serious performance issues. Can anyone help in this regard. Whats the best statement that can be used to increase the performance?

Urgent help needed.

Thanx in advance.

shakir

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

sort itab1 by field1 field2.

sort itab2 by field1 field2.

loop at itab1.

lv_index = sy-tabix.

read table itab2 with key field1 = itab1-field1

field2 = itab1-field2 binary search.

if sy-subrc = 0.

delete itab1 index lv_index.

endif.

endloop.

Regards,

Ravi

6 REPLIES 6
Read only

Former Member
0 Likes
697

sort itab1 by field1 field2.

sort itab2 by field1 field2.

loop at itab1.

lv_index = sy-tabix.

read table itab2 with key field1 = itab1-field1

field2 = itab1-field2 binary search.

if sy-subrc = 0.

delete itab1 index lv_index.

endif.

endloop.

Regards,

Ravi

Read only

Former Member
0 Likes
696

Hi shakir,

1. suppose u want to delete from itab1.

2. then (using matching key)

3. LOOP AT ITAB2.

<b> READ TABLE ITAB1 WITH KEY FIELD1 = ITAB2-FIELD1

FIELD2 = ITAB2-FIELD2.

IF SY-SUBRC = 0.

DELETE ITAB1.

ENDIF.</b>

ENDLOOP.

regards,

amit m.

Read only

Former Member
0 Likes
696

HI,

sort itab2 by <fieldname>

Loop at itab1.

read table itab2 with

key <fieldname = itab1-fieldname>

binary search.

if sy-subrc = 0.

delete itab1.

endif.

endloop.

regards

Subbu

Read only

Former Member
0 Likes
696

sort itab2 by <field>.

loop at itab1

read table itab2 with key <cond>

binary search.

if sy-subrc = 0.

delete itab1.

endif.

endloop.

Read only

Former Member
0 Likes
696

Hi,

Add one more column called 'MARK' in itab1.

1. Don't delete a table entry while looping it.

2. Don't use loop inside loop ( Not advisable )

Loop at itab1 <WA1>.

read table itab2 into <WA2> with key

aa = <WA1>-aa.

if sy-subrc EQ 0.

<WA1>-mark = 'X'.

modify itab1 from <WA1> transporting MARK.

endif.

endloop.

delete itab1 where MARK = 'X'.

Regs,

Venkat Ramanan N

Read only

Former Member
0 Likes
696

Hi,

just try this.

loop at itab2.

read table itab1 index sy-index.

delete table itab1 with table key

fieldname = itab2-fieldname1 fname2 = itab2-fname2.

endloop.

i hope this works well, please reward if it is helpful

Regards,

Sowjanya