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

Delay within internal loops - nested loops

Former Member
0 Likes
951

Hi all,

I have generated report using nested loops.if i give some 200 hits ,it generates the report within 90 seconds.but if the hit limit increases above 500,the loop becomes infinite.i have checked the datas as well as select Queries,everything is fine.why it happens.please help me if u know the solution.

thanks in advance,

raj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
845

Check this <a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">blog.</a>Rob

7 REPLIES 7
Read only

Former Member
0 Likes
845

Hi,

1). Try to avoide nested loops.

2). Try using READ WITH BINARY SEARCH

3). Use a SORTED TABLE the access is fast

Post urt code to let u know where u can fine tune the program.

Cheers

VJ

Read only

0 Likes
845

Hi vijay & anirban,

I have implemented the solutins whatever u have given.i have cross verified with my colleagues also.but this situation behaves very strange.i ll post my code .just go through that code and let me know where ia have to fine tune

thanks

raj

Read only

0 Likes
845

Wheres ur code?

VJ

Read only

Former Member
0 Likes
845

There should be no reason why the program goes into an infinite loop pass with a larger number of records, unless there is some problem with one of the records it is trying to access.

It seems to me that one of the records in the 500 has some problem, and that is why the system behaves strangely in that case. You can do some trouble shooting, for eg, have the system download a file with the loop pass number, so that you know at which loop pass it went into an infinite loop, and analyze the same.

Hope this helps.

Sudha

Read only

0 Likes
845

Hi sudha,

I tried first 200 records,then 200 records like this i have checked upto 1000 records.the system produes the results within short time.but when i have checked above 500 ,it creates infinite loop.but sometimes the report comes after an 1 hour for 500 records.

thanks

raj

Read only

former_member480923
Active Contributor
0 Likes
845

hi

There are couple of solutions to this

a) try defining a sarted internal table for the inside table with the keys that you define in the where clause of your inside loop.

b) You can try the below code

loop at itab1.
read table itab2 with key .......
l_tabix = sy-tabix.
loop at itab2 from l_tabix.
<check the validity condition>
endloop.

this could kill about 3/4 of the time before

Hope this Helps

Anirban

Read only

Former Member
0 Likes
846

Check this <a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">blog.</a>Rob