Application Development 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: 

using parallel cursor

Former Member
0 Kudos

Hi Experts,

In my program using nested loop. I want avoid that using parallel cursor. But In two nested loops, using

I done, but where has three nested loops how ? plz tell me or send code?

Ex: my Requirment is like this

Loop at i_tab1 into wa_tab1.

loop at s_tab into wa_tab2.

end loop.

loop at k_tab into wa_tab3

end loop.

end loop.

plz send code using parallel cursor, if u get more points.

thanx

srinu

5 REPLIES 5

Former Member
0 Kudos

HI,

Check this Code .....

REPORT zparallel_cursor.

TABLES:

likp,

lips.

DATA:

t_likp TYPE TABLE OF likp,

t_lips TYPE TABLE OF lips.

DATA:

w_runtime1 TYPE i,

w_runtime2 TYPE i,

w_index LIKE sy-index.

START-OF-SELECTION.

SELECT *

FROM likp

INTO TABLE t_likp.

SELECT *

FROM lips

INTO TABLE t_lips.

GET RUN TIME FIELD w_runtime1.

SORT t_likp BY vbeln.

SORT t_lips BY vbeln.

LOOP AT t_likp INTO likp.

LOOP AT t_lips INTO lips FROM w_index.

IF likp-vbeln NE lips-vbeln.

w_index = sy-tabix.

EXIT.

ENDIF.

ENDLOOP.

ENDLOOP.

GET RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.

WRITE w_runtime2.

Either you can use the above code ..or ucan replace the inside loops with read statement of lopp with where clause depending on requirement

Edited by: avinash kodarapu on Nov 30, 2008 4:04 PM

0 Kudos

Hey,

small correcction, this is not the parallel processing way to code:(Since parallel processin needs the index to loop from, You need the read statment to code it..)

SORT t_likp BY vbeln.

SORT t_lips BY vbeln.

LOOP AT t_likp INTO likp.

Read table t_lips into lips with key vbeln = likp-vbelnLOOP AT t_lips INTO lips FROM w_index.

if sy-subrc EQ 0.

LOOP AT t_lips INTO lips FROM w_index.

-


do processing----

AT END OF <Key field> (here it is VBELN)

EXIT. " Exit of the inner loop pn t_likp or else it will go into infinite loops

ENDAT.

ENDLOOP.

ENDIF.

ENDLOOP.

Regards

Shiva

0 Kudos

SORT t_likp BY vbeln.

SORT t_lips BY vbeln.

LOOP AT t_likp INTO likp.

Read table t_lips into lips with key vbeln = likp-vbeln

if sy-subrc EQ 0.

LOOP AT t_lips INTO lips FROM sy-tabix.

...........do processing----

AT END OF <Key field> (here it is VBELN)

EXIT. " Exit of the inner loop pn t_likp or else it will go into infinite loops

ENDAT.

ENDLOOP.

ENDIF.

ENDLOOP.

Former Member
0 Kudos

Hi

When nested loop beceomes necessary than parallel cursor is really helpful in improving the performance.

It will help us to avoid complete looping of the internal table .

You can see the advantages if their are two-three internal tables inside the loop.

Check this link for an example of parallel cursor"

http://www.sap-img.com/abap/what-is-parallel-cursor-concept.htm

http://www.articlesbase.com/programming-articles/sap-performance-tuning-using-parallel-cursor-324225...

Regards

Neha

raymond_giuseppi
Active Contributor
0 Kudos

Look in the Code Gallery for [ABAP Code for Parallel Cursor - Loop Processing |https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPCodeforParallelCursor-Loop+Processing]. (or directly [Avoiding Nested Loops Using Parallel Cursors |http://karsap.blogspot.com/2007/06/avoiding-nested-loops-using-parallel_19.html] and [Improved version of Parallel Cursor |http://karsap.blogspot.com/2007/06/improved-version-of-parallel-cursor.html])

Regards