cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Cursor vs LOOP AT WHERE, which is faster?

sh4il3sh
Participant
0 Kudos

Hello Experts, I want my code to look short and also perform fast and I need some expert to confirm which is the right way from below two.
PARALLEL CURSOR CODE:
Sadly we cant shorten this with new syntaxes. (maybe line_index can help?)

sh4il3sh_2-1710832111546.png

LOOP AT WHERE CODE:
This is shorter to code, but I am sure its not faster.

sh4il3sh_3-1710832251924.png

Maybe parallel cursor can be written with line_index since it is similar to READ TABLE TRANSPORTING NO FIELDS. Is it advisable?

sh4il3sh_0-1710834920006.png

 


Thank You!

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
0 Kudos

The two nested LOOP AT is the same speed as "parallel cursor" provided that pt_pf_cm is declared as TYPE SORTED TABLE (with either primary key or secondary key).

So that your question makes sense, the SORT statement or TYPE SORTED TABLE declaration should be clearly mentioned.

Note that your "parallel cursor" code might be slightly faster if all the lines of pt_pf_cm are used, by removing the READ TABLE and starting from position 1.

NB: please don't post code as image, just use text with formatting option (buttons "..." and "</>") e.g.

LOOP AT lt_sales_cm ASSIGNING <ls_log>.
  READ TABLE pt_pf_cm ...
  ...
ENDLOOP.

 

sh4il3sh
Participant
0 Kudos

Thanks Sandra, what do you think about line_index variant in case pt_pf_cm is not declared at SORTED?
I wanted to post code with formatting like I always have in the past but I was unable to do so (it was getting messy).

PS: I miss old answers.sap.com

Sandra_Rossi
Active Contributor
0 Kudos
lv_index = line_index( itab[ ... ] ) is exactly the same as READ TABLE itab TRANSPORTING NO FIELDS ... + lv_index = SY-TABIX.

Answers (0)