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

Loop Statement

Former Member
0 Likes
719

Is there any way i can make the loop statement skip some passes.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
693

If it is conditional you can write where condition as below:

Loop at itab where matnr = p_matnr.

.

.

.

Endloop.

Or you can write If condition in the loop as:

Loop at itab.

If itab-matnr ne p_matnr.

continue.

endif.

.

.

Endloop.

Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
693

LOOP AT ... WHERE ...

Rob

Read only

Former Member
0 Likes
693

Hello,

You can do like this if my understanding is correct.

LOOP AT ITAB WHERE F! NE 'X'.
ENDLOOP.

Vasanth

Read only

Former Member
0 Likes
694

If it is conditional you can write where condition as below:

Loop at itab where matnr = p_matnr.

.

.

.

Endloop.

Or you can write If condition in the loop as:

Loop at itab.

If itab-matnr ne p_matnr.

continue.

endif.

.

.

Endloop.

Thanks

Read only

0 Likes
693

continue works and also if you want to skip the first few lines you can do it as loop at...from index 5.

Read only

Former Member
0 Likes
693

Hi Deepthi,

Use CONTINUE in the LOOP...ENDLOOP statement to skip for that iteration.

Check this code.

DATA:

BEGIN OF ITAB OCCURS 0,

MATERIAL TYPE MARA-MATNR,

END OF ITAB.

START-OF-SELECTION.

SELECT MATNR

FROM MARA

INTO TABLE ITAB

UP TO 10 ROWS.

END-OF-SELECTION.

LOOP AT ITAB.

IF SY-TABIX >= '3' AND SY-TABIX <='7'.

<b>CONTINUE.</b>

ENDIF.

WRITE:/ SY-TABIX, ITAB.

ENDLOOP.

Thanks,

Vinay