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: 

concept of parallel cursor

Former Member
0 Kudos

Hi

If i want to use parallel cursor fro these loops,how do i do it?

the first internal table it_rel_acc has 84,000 thousand entries

the second internal table it_rel_acc_itm has 1 lakh entries

LOOP AT it_rel_acc INTO wa_rel_acc WHERE claim = wa_output-claim.

LOOP AT it_rel_acc_itm INTO wa_rel_acc_itm

WHERE claim = wa_rel_acc-claim

AND vbtyp = wa_rel_acc-vbtyp

AND vbeln = wa_rel_acc-vbeln

AND gjahr = wa_rel_acc-gjahr.

Please advise as to how do i combat with this problem

6 REPLIES 6

former_member156446
Active Contributor
0 Kudos

Parallel processing is not preferred, it will pull almost every resource of the system towards it and will make system very slow... unless there is no other go dont go for parallel processing.

looks like your scenario parallel processing is not suitable.

Former Member
0 Kudos

Moved to the correct forum.

Please see [Performance of Nested Loops|/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops]

Rob

Former Member
0 Kudos

Hi ,

Refer to the Performance examples given in the T.code SE80 Environment--->Examples

The exmaple there looks like this :


* Both tables sorted by key K
data i type i.
I = 1.
LOOP AT ITAB1 INTO WA1.
  LOOP AT ITAB2 INTO WA2 FROM I.
    IF WA2-K <> WA1-K.
      I = SY-TABIX.
      EXIT.
    ENDIF.
    " ...
  ENDLOOP.
ENDLOOP.

the most importatnt thing you need to make sure that both the itabs are sorted by its key.

regards,

Advait

Former Member
0 Kudos

hi u can use this code for parallel processing

data : index type i.

loop at ktab.

read table itab with key value = ktab-value.

if sy-subrc eq 0.

index = sy-tabix.

else.

exit.

endif.

clear itab.

do .

read table itab index index1.

if itab-value = ktab-value.

index = sy-tabix + 1.

write : / itab-value.

clear itab.

else.

exit.

endif.

enddo.

endloop.

the condition is that both tables itab and ktab should be shorted by field value

endloop.

former_member194613
Active Contributor
0 Kudos

Please use a standard solution,


LOOP AT itab ASSIGNING <fs>.
   READ TABLE itab2 WITH KEY ....

Try to use a sorted table for itab2 or a hashed table, if there is a 1:1. relation and the read can use the

complete table key.

If you need a LOOP with WHERE condition they you need a sorted table for itab2.

If only standard tables are possible then BINARY SEARCH is necessary!!! And loop is completicated,

see there

Measurements on internal tables: Reads and Loops:

/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables

Be careful with the SORTS!!!

Only the itab2 must be sorted, itab can have any order.

In parallel cursor you need to sort both tables .... and that costs you nearly thewhole advantage of

the parallel cursor.

I can not recommend parallel cursor, in the general case when both tables can have entries which are not in the other, then it is ver y cumbersome. Maybe it is a bit faster, but with a higher risk of errors and

much higher requirements. Also future changes are difficult, nobody will understand the coding.

Try the hash table if it fits, but also sorted is acceptable or binary search, they are all fast enough.

Without optimization it will be 100.000 slower !!!!!

Siegfried

Former Member
0 Kudos
l_tabix type sy-tabix.
  sort itab1 by <key field>
  sort itab2 by <key field>
  loop at itab1.
    loop at itab2 index l_tabix.
      if (your condition).
      l_tabix = sy-tabix.
        * your code here for the conditon.
      else.
      exit.
    endif.
  endloop.
endloop.

The concept of parallel cursor is to reduce the execution time of the second loop.

This is achieved by starting the second loop from the index for which the last condition is satisfied.

The prerequisite for this is that the tables should be sorted in same order.

Also the condition should be set proper in the loop so that all data is populated.

* Close your question once answered.

Regards,

Lalit Mohan Gupta.