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: 

Parallel Cursor with ABAP 7.4

satadas30
Explorer
0 Kudos
22,763

Generally we use the below logic for implementing Parallel Cursor

LOOP AT it_vbak ASSIGNING <lfs_vbak>.
LOOP AT it_vbap FROM lv_tabix ASSIGNING <lfs_vbap>.
* Save index & Exit the loop, if the keys are not same
IF <lfs_vbak>-vbeln <> <lfs_vbap>-vbeln.
lv_tabix = sy-tabix.
EXIT.
ENDIF.
* Rest of the logic would go from here...
ENDLOOP.
ENDLOOP.

I figured out that the same can be implemented using the ABAP 7.4 syntaxes as below:

DATA(lt_final) = VALUE ty_t_final( FOR ls_vbap IN it_vbap
FOR ls_vbak IN it_vbak FROM line_index( it_vbak[ vbeln = ls_vbap-vbeln ] )
WHERE ( vbeln = ls_vbap-vbeln )
LET ls_final = VALUE ty_final(
vbeln = ls_vbak-vbeln )
IN ( CORRESPONDING #( BASE ( ls_final ) ls_vbap ) ) ).

But when I compare the performance for both of these, the previous one is quite quicker than the one implemented with ABAP 7.4 syntax. Can someone let me know if I am missing anything?

2 REPLIES 2

Sandra_Rossi
Active Contributor
10,160

It seems obvious that if you try to implement it the same way, a table iteration is less performing because you can't exit a FOR loop, you need to loop till the end of the internal table!

If it_vbak and it_vbap are standard tables, the table expression will be very slow.

Conclusion: constructor expressions are sometimes "bad"....

alopezv74
Participant
0 Kudos
10,160

I think that both codes are not equivalents.

I mean, in the cursor one, the outside LOOP is for VBAK and then do the LOOP for the VBAP.
In the 7.4 version, the outside LOOP is for VBAP and the inside LOOP is for VBAK, maybe if you do in this order the performance could be more equlas??

The 7.4 version, I think that should be like this, isn't it?

 DATA(it_final) = VALUE ty_t_final( FOR ls_vbak IN it_vbak 
          FOR ls_vbap IN it_vbak FROM line_index( it_vbak[ vbeln = ls_vbap-vbeln ] ) WHERE ( vbeln = ls_vbak-vbeln ) LET ls_final = VALUE ty_final( vbeln = ls_vbak-vbeln ) IN ( CORRESPONDING #( BASE ( ls_final ) ls_vbap ) ) ).