Skip to Content
avatar image
Former Member

using parallel cursor

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Nov 30, 2008 at 10:34 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Nov 30, 2008 at 01:35 PM

    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.html

    Regards

    Neha

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 30, 2008 at 01:54 PM

    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

    Add comment
    10|10000 characters needed characters exceeded