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

Skip loop step

Former Member
0 Likes
719

Hi,

Is there an instruction to skip a loop step??

My code looks like that:


LOOP AT it_matnr.

 IF it_matnr <> matnr.
   CHECK 1 = 0.  
 ELSE.
* Do something....
 ENDIF.
ENDLOOP.

The instruction CHECK 1 = 0 works but It isn't "elegant"... is there another option?

  • Don't say me that the SKIP step with CHECK 1 = 0 is useless, because that's only a sample code to explain the situation...

Edited by: Marshal Oliveras on Jun 2, 2008 4:23 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
659

Hi,

You have a few options...

You could use LOOP AT WHERE...

Or use the CONTINUE command within your loop.

Check the F1 help for both of these to see if they are suitable.

Gareth.

5 REPLIES 5
Read only

Former Member
0 Likes
659

Why do you not use:

LOOP AT it_matnr.

IF NOT it_matnr = matnr

  • do something

ENDIF.

ENDLOOP.

Kind regards,

Lieselot

Read only

Former Member
0 Likes
660

Hi,

You have a few options...

You could use LOOP AT WHERE...

Or use the CONTINUE command within your loop.

Check the F1 help for both of these to see if they are suitable.

Gareth.

Read only

Former Member
0 Likes
659

use continue.

LOOP AT it_matnr.

IF it_matnr matnr.

continue..

ELSE.

  • Do something....

ENDIF.

ENDLOOP.

Thanks,

Rajinikanth G.

Read only

Former Member
0 Likes
659

Thank you.

CONTINUE is what I was looking for. The other solutions don't solve my problem because my code is much more complicated than the sample that I posted

Read only

0 Likes
659

To be honest, I tend to use CONTINUE instead of LOOP AT WHERE 99% of the time as I find it makes the code easier to read and helps when debugging...

Just my preference really.

Gareth.