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: 

what is meant by parallel cursor

Former Member

hi

what is meant by parallel cursor

7 REPLIES 7

Former Member

Parallel Cursor is a technique to increase the performance of the program when there are nested loops.

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.

Regards

Kannaiah

0 Kudos

Hi, Kannaiah

I looked at Parallel Cursor technique and I have a question.

In your example you first of all take a line wa_01 from itab_01 and after that call read table itab_02 into wa_02 according to key-field from wa_01. And only if such line was found you remember a line index where you stopped in itab_02 when you found the desired line and begin to pass over this table from the index to the end.

Could you, please, clarify, why call READ TABLE for the first occurrence in table and LOOP for the rest of the lines in the table is more cheaper than pass the whole table with regular LOOP? Or in other words, why exactly READ TABLE is more cheaper, than LOOP?

Thanks.

Former Member

Hi,

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

I will give you one example like take billing document header details in one table and item details in other table let say the header table have 1000 records and the item table have 1 lakh records. If you want to make an output then you need to put nested loops first loop at header table then next loop at item table. For each entry of header record the item table loops 1 lakh times. calculate the total. so instead of we develop parallel cursor technique,, see the belwo code..

Loop at header.

read table item with key number = header-number.

if sy-subrc = 0.

loop at item from sy-tabix.

if item-number <> header-number.

exit.

else.

do some process here.

endif.

endloop.

endif.

endloop.

First the item table is read using the read table statement for getting the exact index number where the document number reside. if found then loop through the item table from that index upto item- number <> header-number.

Rgds,

Bujji

Edited by: Bujji on Jun 26, 2008 12:48 PM

Former Member
0 Kudos

Hi,

Parallel Cursor is a technique to increase the performance of the program when there are nested loops.

Code for Parallel Cursor:

SORT: bkpf_tab BY bukrs belnr gjahr,

bseg_tab BY bukrs belnr gjahr.

bseg_index = 1.

LOOP AT bkpf_tab INTO bkpf_lin.

bkpf_reads = bkpf_reads + 1.

LOOP AT bseg_tab INTO bseg_lin FROM bseg_index.

IF bseg_lin-bukrs <> bkpf_lin-bukrs OR

bseg_lin-belnr <> bkpf_lin-belnr OR

bseg_lin-gjahr <> bkpf_lin-gjahr.

bseg_index = sy-tabix.

EXIT.

ELSE.

bseg_reads = bseg_reads + 1.

ENDIF.

ENDLOOP.

ENDLOOP.

0 Kudos

If you are using nested loop it will decrease performance. If you want increase performance then paralel cursor is the solution.

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 see the below code using parallel cursor. Here we are reading inner itab1 using binary search

loop at itab into wa.

read table itab1 into wa1 with key field1 = wa-field1 binary search.

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.

former_member1716
Active Contributor

sbhillar,This is 10 years old Thread, i dont think there will be any response.Recommend you to check the thread before posting.

matt
Active Contributor

Probably spam, trying to promote a web site. And reported as such. Certainly useless. Especially since parallel cursor technique is thoroughly obsolete.