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

Loop inside a Loop

Former Member
0 Likes
455

Hi All ,

Wat could be the Best way of resolving a Loop inside a loop????

wat are the possible ways of resolving it..???

Thanks in advnce.

Regards

Aslam.

3 REPLIES 3
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
422

You can use Parallel Cursors.

link:[http://help-abap.blogspot.com/2009/12/parallel-cursor-to-speed-up-performance.html]

Read only

Former Member
0 Likes
422

I discuss this point extensively ... in a German test book

http://www.dpunkt.de/buch/3096.html

There are three possiblities for nested processing of internal tables:


loop at itab1
   read table itab2
...

1:1 relation between records of the 2 tables. You must take care that the inner processing is faster than a sequential read,

i.e. use binary search (automatically with sorted tables) or direct access (index or hashed tables).


loop at itab1
   loop at itab2  where

1:C relation like header and position etc. This also automatically solved with sorted and hashed tables. With standard tables there is a bit more complicated work-around possible (see Measurements on internal tables: Reads and Loops:

/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables).


loop at itab1
   loop at itab2 

No relation between the records of the two tables.

+ Either one of the two tables is small, then there is no problem.

+ Or there is relation where each record of the inner table is related to each record of the other, this is only the case with

complicated optimization problems, and usually never with business tasks.

Nested loops can alsop be constructed with READs and some logic on the indexes, can be nested over several modularization layer etc etc. They can look very different, but they are all the same!

Of course the same hold for MODIFY, INSERT and DELETE. The whole discussion needs 20 pages.

I personally do not recommend the parallel cursor, because it is much to complicated in the general case (both tables have extra records!

Siegfried

Read only

Former Member
0 Likes
422

Moderator message - Please search before asking - post locked

Rob