What Is Parallel Cursor Concept

Parallel cursor is the technique to increase the performance of the program, when there are nested loops. 
For example if we use nested select in our program instead of For all entries addition, then definitely performance going down. In the same way the if we use nested loops in the program it will also leads to down the performance.

For example:

if the code contains this type of logic:

loop at itab into wa.

loop at itab1 into wa1.
endloop.

endloop.

In the above logic, for one record of the itab, again the table itab1 loops many times. If itab contains many records and also at the same time if itab1 contains double the records, then this would result into performance issue.  You can modify it as:

loop at itab into wa.

read table itab1 into wa1 with key field1 = wa-field1.
v_tabix = sy-tabix.
if sy-subrc eq 0.
loop at itab1 into wa1 from v_tabix. "It will loop from that index
endloop.
endif.
endloop.

---------

Parallel Cursor helps in performance tuning.

Reasons for using Parallel Cursor:
Nested Loops is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.

Program (Nested Loop using Parallel Cursor):

REPORT zparallel_cursor2.

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.

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.