KEMBAR78
Parallel Cursor&Processing | PDF | Cursor (User Interface) | Parallel Computing
0% found this document useful (0 votes)
5 views3 pages

Parallel Cursor&Processing

Uploaded by

ameesha.sh20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Parallel Cursor&Processing

Uploaded by

ameesha.sh20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Parallel Cursor and Parallel Processing in ABAP

This document explains the concepts of Parallel Cursor and Parallel Processing in ABAP with examples.

1. Parallel Cursor

🔹 Concept

The parallel cursor technique is used to improve performance when looping through two internal tables
with a relationship (like parent-child). Instead of nested loops (which are costly in performance), you move
pointers (cursors) in parallel.

🔹 Example: Fetching Sales Orders and Items

Without Parallel Cursor (Nested Loop):

LOOP AT lt_vbak INTO ls_vbak. " Header Table


LOOP AT lt_vbap INTO ls_vbap " Item Table
WHERE vbeln = ls_vbak-vbeln.
WRITE: / ls_vbak-vbeln, ls_vbap-posnr.
ENDLOOP.
ENDLOOP.

⚠️ Performance issue: If lt_vbak has 10,000 rows and lt_vbap has 50,000 rows, nested loops are expensive.

With Parallel Cursor:

SORT lt_vbap BY vbeln.

LOOP AT lt_vbak INTO ls_vbak. " Header Table


READ TABLE lt_vbap INTO ls_vbap WITH KEY vbeln = ls_vbak-vbeln
BINARY SEARCH.

IF sy-subrc = 0.
lv_index = sy-tabix.
LOOP AT lt_vbap INTO ls_vbap FROM lv_index.
IF ls_vbap-vbeln <> ls_vbak-vbeln.
EXIT.
ENDIF.
WRITE: / ls_vbak-vbeln, ls_vbap-posnr.

1
ENDLOOP.
ENDIF.
ENDLOOP.

✅ Much faster because item table is scanned only once per header instead of repeatedly.

2. Parallel Processing

🔹 Concept

Parallel processing in ABAP distributes workload across multiple work processes to speed up execution.
This is useful for long-running jobs like mass data updates.

It is achieved using Asynchronous RFC (aRFC).

🔹 Steps for Parallel Processing

1. Split data into packages (chunks).


2. Call a function module in parallel tasks ( CALL FUNCTION ... STARTING NEW TASK ).
3. Collect results using callback routine.

🔹 Example: Parallel Processing with aRFC

DATA: lt_data TYPE TABLE OF mara,


lt_sub TYPE TABLE OF mara,
lv_lines TYPE i,
lv_pack TYPE i VALUE 1000,
lv_from TYPE i VALUE 1,
lv_to TYPE i.

SELECT * FROM mara INTO TABLE lt_data.

lv_lines = lines( lt_data ).

WHILE lv_from <= lv_lines.


lv_to = lv_from + lv_pack - 1.

APPEND LINES OF lt_data FROM lv_from TO lv_to TO lt_sub.

CALL FUNCTION 'Z_PROCESS_DATA' STARTING NEW TASK lv_from


PERFORMING callback_form ON END OF TASK
EXPORTING it_data = lt_sub.

2
CLEAR lt_sub.
lv_from = lv_to + 1.
ENDWHILE.

WAIT UNTIL gv_tasks = 0.

FORM callback_form USING taskname.


gv_tasks = gv_tasks - 1.
ENDFORM.

🔹 Function Module Z_PROCESS_DATA

This function module should be RFC-enabled.

FUNCTION z_process_data.
TABLES it_data STRUCTURE mara.

LOOP AT it_data INTO DATA(ls_data).


" Processing logic for each row
ENDLOOP.

ENDFUNCTION.

✅ This way, processing is distributed among multiple tasks instead of one sequential loop.

🔑 Key Differences

Concept Usage Benefit

Optimizes nested loops within a single Improves performance in joins/


Parallel Cursor
internal table processing parent-child relationships

Parallel Executes processing in multiple dialog/ Reduces runtime for large data
Processing background work processes volumes

📌 Summary
• Use Parallel Cursor for optimizing nested loops.
• Use Parallel Processing (aRFC) for splitting and processing large data sets across multiple work
processes.
• Both techniques are performance boosters but used in different scenarios.

You might also like