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

Enhancing performance for loop inside loop processing..........

Former Member
0 Likes
2,425

Hi ,

my current program has the following code

Loop at itab1.

..................

loop at itab2

where f1 = itab1-f1.

endloop.

..............

endloop.

in itab1 there 20,000. and itab2 there are 10,000 records

The above code is causing a great bottle neck .is their any way to enhance the performance.

please help .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
848

Use the Parallel Cursor technique.

data: v_tabix type sy-tabix.
Loop at itab1.

..................
Read table itab2 into wa_tab2 with key .........
if sy-subrc eq 0.
v_tabix = sy-tabix.
loop at itab2 into wa_tab2 from v_tabix.
if wa_tab2 ne field1.
exit.
endif.

endloop.
endif.

..............

endloop.

Regards

Kannaiah

5 REPLIES 5
Read only

Former Member
0 Likes
849

Use the Parallel Cursor technique.

data: v_tabix type sy-tabix.
Loop at itab1.

..................
Read table itab2 into wa_tab2 with key .........
if sy-subrc eq 0.
v_tabix = sy-tabix.
loop at itab2 into wa_tab2 from v_tabix.
if wa_tab2 ne field1.
exit.
endif.

endloop.
endif.

..............

endloop.

Regards

Kannaiah

Read only

Former Member
0 Likes
848

Hi,

~ if you have any duplicates in itab1, just process the loop for 1st pass.

~ you can use [parallel cursor method|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2bcode%2bfor%2bparallel%2bcursor%2b-%2bloop%2bprocessing]

regards,

madhu

Read only

Former Member
0 Likes
848

From the ABAP editor go to the menu path Environment->Examples->Performance Examples and look at the Parallel Cursor technique under internal tables->simple algorithms->nested loops.

Gareth.

Read only

Former Member
0 Likes
848

Write the nested loop logic as shown below. This will reduce the execution time to maximum.

SORT itab1 BY f1.

SORT itab2 BY f1.

LOOP AT itab1.

LOOP AT itab2 FROM w_index.

IF itab1-f1 NE itab2-f1.

w_index = sy-tabix.

EXIT.

ENDIF.

ENDLOOP.

ENDLOOP.

****Reward points if useful

Regards,

Kiran Bobbala

Read only

Former Member
0 Likes
848

Thnkx Madhu