F Parallel Cursor in SAP | CodeTheta

Parallel Cursor in SAP

June 07, 2024

Parallel Cursor is an optimized method to increase the performance of the SAP ABAP program when there are nested loops for a particular condition.

Algorithm for Parallel Cursor
STEP 1: Table1 and Table2 must be sorted.
STEP 2: Loop at Table1 and within the loop and read the Table2 with matching key of Table1 and Table2.
STEP 3: If read successfully then take the sy-tabix into a variable.
STEP 4: After that loop at Table2 with that sy-tabix variable.
STEP 5: Then within the loop if Table1 and Table2 primary keys are not matched then exit from the program.

Sample Code:
SORT: table1, table2.
LOOP AT table1 INTO wa_table1.
READ TABLE table2 INTO wa_table2 WITH KEY eid = wa_table1-eid BINARY SEARCH.
IF SY-SUBRC = 0.
DATA(lv_index) = SY-TABIX.
LOOP AT table2 INTO wa_table2 FROM lv_index.
IF wa_table1-eid <> wa_table2-eid.
EXIT.
ENDIF.
Write: wa_table1-eid, wa_table2-month, wa_table2-amount.
ENDLOOP.
ENDLOOP.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Post a Comment