‎2009 Aug 27 9:23 AM
Hi all,
I want to loop on required records only in Item table (i_vbap). My code as follows
LOOP AT i_vbak
READ TABLE i_vbap WITH KEY vbeln = i_vbak-vbeln.
IF sy-subrc = 0.
LOOP AT i_vbap.
IF i_vbap-vbeln = i_vbak-vbeln.
MOVE i_vbap TO i_vbap1.
APPEND i_vbap1.
ENDIF.
ENDLOOP.
ENDLOOP.
in 2nd loop, it is looping all records in i_vbap. but i want to loop only when vbeln = i_vbak-vbeln (as in read statement ).
Plz help me on this. Thanks in advance.
Regards.
‎2009 Aug 27 9:25 AM
Hi,
do like this
LOOP AT i_vbak
READ TABLE i_vbap WITH KEY vbeln = i_vbak-vbeln.
IF sy-subrc = 0.
LOOP AT i_vbap where vbeln = i_vbak-vbeln .
IF i_vbap-vbeln = i_vbak-vbeln.
MOVE i_vbap TO i_vbap1.
APPEND i_vbap1.
ENDIF.
ENDLOOP.
ENDLOOP.
Regards,
Prashant
‎2009 Aug 27 9:25 AM
Hi,
do like this
LOOP AT i_vbak
READ TABLE i_vbap WITH KEY vbeln = i_vbak-vbeln.
IF sy-subrc = 0.
LOOP AT i_vbap where vbeln = i_vbak-vbeln .
IF i_vbap-vbeln = i_vbak-vbeln.
MOVE i_vbap TO i_vbap1.
APPEND i_vbap1.
ENDIF.
ENDLOOP.
ENDLOOP.
Regards,
Prashant
‎2009 Aug 27 9:26 AM
use like this.
LOOP AT i_vbak
READ TABLE i_vbap WITH KEY vbeln = i_vbak-vbeln.
IF sy-subrc = 0.
LOOP AT i_vbap where vbeln = i_vbak-vbeln..
MOVE i_vbap TO i_vbap1.
APPEND i_vbap1.
ENDLOOP.
ENDLOOP.
‎2009 Aug 27 9:27 AM
Hi,
Try like this,
LOOP AT i_vbak
LOOP AT i_vbap where vbeln = i_vbak-vbeln. "------> Remove the read statement and add the condition in loop itself
IF i_vbap-vbeln = i_vbak-vbeln.
MOVE i_vbap TO i_vbap1.
APPEND i_vbap1.
ENDLOOP.
ENDLOOP.
Regards,
Vikranth
‎2009 Aug 27 9:35 AM
you can use where conditon with loop statement ...press F1 on loop to get more details regarding where clause..