‎2007 Oct 19 10:38 AM
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?
‎2007 Oct 19 10:44 AM
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
‎2007 Oct 19 10:54 AM
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