Application Development and Automation 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: 
Read only

Different beween these 2 sql

Former Member
0 Likes
379

SELECT vbeln posnr etenr edatu wadat FROM vbep INTO CORRESPONDING FIELDS OF TABLE it_vbep FOR ALL ENTRIES IN it_output

WHERE vbeln = it_output-vbeln

AND posnr = it_output-posnr

AND etenr = ( SELECT MAX( etenr ) FROM vbep WHERE vbeln = it_output-vbeln AND posnr = it_output-posnr ).

SORT it_vbep BY vbeln posnr etenr DESCENDING.

LOOP AT it_output INTO wa_output.

READ TABLE it_vbep WITH KEY vbeln = wa_output-vbeln

posnr = wa_output-posnr.

IF sy-subrc EQ 0.

wa_output-zedatu = it_vbep-edatu.

wa_output-zwadat = it_vbep-wadat.

ENDIF.

Modify it_output from wa_output.

Endloop.

Option B :

SELECT vbeln posnr etenr edatu wadat FROM vbep INTO CORRESPONDING FIELDS OF TABLE it_output FOR ALL ENTRIES IN it_output

WHERE vbeln = it_output-vbeln

AND posnr = it_output-posnr

AND etenr = ( SELECT MAX( etenr ) FROM vbep WHERE vbeln = it_output-vbeln AND posnr = it_output-posnr ).

May I know is there any different between these 2 options?

2 REPLIES 2
Read only

Former Member
0 Likes
359

Hi,

Option A is correct.

in Option B, there is no point in comparing the entries in it_output with the same entries in it_output.

<b>Reward for helpful answers</b>

Satish

Read only

Former Member
0 Likes
359

hi,

you have used same queries in both the options ,so there is no difference in their output,but in the first option you have used sort ,loop and read statements to change the update the your internal table.

Siva