‎2007 Apr 10 1:30 PM
Hi Friends,
I need to change the coding because of taking more times when in nested loopsand below is the sample code
loop at itab.
loop at itab1
loop at itab2.
..........
endloop.
endloop.
loop at itab3.
loop at itab4.
...................
endloop.
endloop.
loop at itab5.
loop at itab6.
...................
endloop.
endloop.
endloop.
Here before this loop it took only 5 seconds in compared with total 941 seconds.after that loop it took almost of time is spend on this big nested loop statement.so how to solve this this issue and what are the possible ways to reduce the time by changing the coding.pls help me to come out this issue.
Thanks,
Regards,
Rajendra Kumar.
‎2007 Apr 10 1:36 PM
Hi,
try to read the internal tables. check the commality in different loops and try to merge the loop.
if wud be better if u can post the code here.
pls go through the below links:
/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/improvingPerformanceinNestedLoopsforInternal+Tables&
**reward if helpful
Regards,
Madhu
‎2007 Apr 10 1:36 PM
Hi,
try to read the internal tables. check the commality in different loops and try to merge the loop.
if wud be better if u can post the code here.
pls go through the below links:
/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/improvingPerformanceinNestedLoopsforInternal+Tables&
**reward if helpful
Regards,
Madhu
‎2007 Apr 10 1:38 PM
Hi..,
You can use READ TABLE statement instead of the nested LOOP ENDLOOP..
regards,
sai ramesh
‎2007 Apr 10 11:34 PM
Hi Kumar,
I think if possible try joining tables during selection from the database tables to
avoid so many internal tables.
Then as mentioned above, try using read with binary search option to make it faster.
Thanks,
Babu
‎2007 Apr 12 1:20 PM
Without knowing how you are using the data in these loops we cannot give you the best reply.
MattG.
‎2007 Apr 13 4:55 PM
HI Kumar,
T best way to avoid the Nested Loop and EndLoop.try to read the tables in place of the Loop.
Thanks & Regards,
Nelson
‎2007 Apr 18 9:30 AM
What is the purpose of so many Loops. It would be better to explain the scenario with small piece of coding.
Just writing 10 loop and endloop would not help.
What are the tables used, can there be joins possible. And lot more need to be analysed.
‎2007 Apr 21 3:14 PM
I am sending u some of the performence issues that to be kept in mind when coding.
1.Use appropriate Tabletype according to the requirement i.e. standerd ,hashed,sorted.
2.Avoid using Nested loops. Instead of Nested loops use READ TABLE.......WITH KEY ..........BINARY SEARCH for SINGLE RECORD access.
HASHED table has higher performance for single record access.
3.When ever using nested loops try to provide as many KEYS as possible in the where clause.
4.Always use TRANPORTING addition in READ/MODIFY statements.
5. Avoid using Control Break statements cantaining where/from/to clauses.
6.Always loop the table cantaining more records to get correct output.
7.APPEND LINES/INSERT LINES has higher performance than APPEND/INSERT
STATEMENT.