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

Parallel cursor technique

Former Member
0 Likes
896

Hi all,

What is Parallel cursor technique, could anybody please explain this? and also how this can be used to avoid nesting loops ?

thanks and regards

--Deepti

3 REPLIES 3
Read only

Former Member
Read only

Former Member
0 Likes
495

Go to transaction se30 ->utilities -> trips and tricks

->internal tables ->simple algorithms

You will find the sample code and some documentation. This should be helpful for you

Read only

Former Member
0 Likes
495

Hi Deepti,

I guess you are referring to the SE30 Tipps&Tricks

to avoid nested loops:

nestedLoop:

  • Entries: 100 (ITAB1), 1000 (ITAB2)

  • Line width: 100

  • Both tables sorted by key K

LOOP AT ITAB1 INTO WA1.

LOOP AT ITAB2 INTO WA2

WHERE K = WA1-K.

" ...

ENDLOOP.

ENDLOOP.

parallel cursors:

  • Entries: 100 (ITAB1), 1000 (ITAB2)

  • Line width: 100

  • Both tables sorted by key K

I = 1.

LOOP AT ITAB1 INTO WA1.

LOOP AT ITAB2 INTO WA2 FROM I.

IF WA2-K <> WA1-K.

I = SY-TABIX.

EXIT.

ENDIF.

" ...

ENDLOOP.

ENDLOOP.

Thats what the text says:

If ITAB1 has n1 entries and ITAB2 has n2 entries, the time needed for the nested loop with the straightforward algorithm is O(n1 * n2),whereas the parallel cursor approach takes only O(n1 + n2) time.

The above parallel cursor algorithm assumes that ITAB2 contains only entries also contained in ITAB1.If this assumption does not hold, the parallel cursor algorithm gets slightly more complicated, but its performance characteristics remain the same.

Also go through this link,

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/frameset.htm

Regards,

Abhy