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

exit from loop

Former Member
0 Likes
739

Hi, can You please tell me how to exit loop for one record , eg. IF condition is not OK leave this record and continue loop.

EXIT command dont help me, is there any other?

LOOP AT lt_s941 INTO ls_s941.

if ( ls_s941-bwart = '101' And ls_s941-lgort = '' ) or

( ls_s941-bwart = '101' And ls_s941-lgort = '0001' And

ls_s941-wzubb = 0 ).

  • ??? -here how to exit loop-???

MOVE-CORRESPONDING ls_s941 TO wa_outtab.

SELECT SINGLE matnr mtart FROM mara INTO (lv_matnr, lv_mtart)

WHERE matnr = ls_s941-matnr.

MOVE: lv_mtart TO wa_outtab-mtart.

select single maktx from makt into wa_outtab-maktx

where matnr = ls_s941-matnr and spras = 'd'.

select single bklas from mbew into wa_outtab-bklas

where matnr = ls_s941-matnr and bwkey = ls_s941-werks.

IF ls_s941-spmon < p_datum-low.

wa_outtab-kolps = ls_s941-ntgew.

if ls_s941-wzubb < 0.

wa_outtab-vredps = ls_s941-wzubb * -1.

endif.

if ls_s941-wzubb > 0.

wa_outtab-vredps = ls_s941-wzubb.

endif.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
653

Hi,

Use check or continue commands as like follows.

loop at itab.

check < condition >.

endloop.

or

loop at itab.

if <condition>.

continue.

endif.

endloop.

Regards,

Sankar.

4 REPLIES 4
Read only

Former Member
0 Likes
653

put CONTINUE instead of EXIT ...

Read only

0 Likes
653

Hi!

Use the CHECK command.

Read only

Former Member
0 Likes
653

Hi,

You can do as below :



LOOP AT lt_s941 INTO ls_s941. 

if ( ls_s941-bwart = '101' And ls_s941-lgort = '' ) or 
( ls_s941-bwart = '101' And ls_s941-lgort = '0001' And 
ls_s941-wzubb = 0 ). 


continue.   "Use collect statement

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
654

Hi,

Use check or continue commands as like follows.

loop at itab.

check < condition >.

endloop.

or

loop at itab.

if <condition>.

continue.

endif.

endloop.

Regards,

Sankar.