Sap Loop Improvment
Sap Loop Improvment
During our development, there are cases which we need to perform a nested loop. Nested loop
is simply a loop within a loop. This cannot be avoided since there are tables in the data
dictionary wherein we loop a header and carry out some processing for each of the lines in the
corresponding item level. Doing so have a great impact on the performance of the program
specially when deployed on the production system where data is about millions of lines. An
example of these tables are EKKO (Purchasing Document Header) and EKPO (Purchasing
Document Item) tables. Consider this sample code below showing a Nested Loop.
As seen from the code above, a LOOP is within a LOOP. This way of code will greatly affect
the performance of your program. In this situation, what you need to implement is a Parallel
Cursor technique.
Having this code implemented with parallel cursor, the inner loop will execute four times and
statement inside the loop will execute three times. This will result in a major performance
improvement over the nested loop code.
Again, thank you so much for reading this article. If you find it useful and helpful, please
consider sharing it to your friends. Remember always, SHARING is CARING . Until next
tutorial.