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

former_member384574
Active Participant
0 Likes
1,064

Hi everybody!

Can I make a loop specifying in which line I want this loop start?

Thanks

Regards,

Rebeca

1 ACCEPTED SOLUTION
Read only

0 Likes
1,034

Loop at itab from n1 to n2.

Luck.

7 REPLIES 7
Read only

0 Likes
1,035

Loop at itab from n1 to n2.

Luck.

Read only

Former Member
0 Likes
1,034

Hi Rebeca,

Yes offcourse you can do the loop at the index number.



Loop at it_final from 1 to 10.
   write: it_final-text.
Endloop.

&*********Reward Point if helpful*********&

You are repeatedly breaking the rules of engagement

Edited by: Durairaj Athavan Raja on Jul 1, 2008 1:08 PM

Read only

Former Member
0 Likes
1,034

Hi,

If you press the F1 key on your keyboard and read the on-line help for LOOP AT you will see you can add FROM into the command...

Read only

Former Member
0 Likes
1,034
Read only

Former Member
0 Likes
1,034

Hi,

For that you have to use Conditional loop statement-

To terminate a single loop pass conditionally, use the CHECK <condition> statement in the statement block of the loop.

If the condition is not true, any remaining statements in the current statement block after the CHECK statement are ignored, and the next loop pass starts. <condition> can be any logical expression.

DO 4 TIMES.

CHECK SY-INDEX BETWEEN 2 and 3.

WRITE SY-INDEX.

ENDDO.

The output is:

2 3

The first and fourth loop passes are terminated without the WRITE statement being processed, because SY-INDEX is not between 2 and 3.

2.

DO 4 TIMES.

IF SY-INDEX = 2.

CONTINUE.

ENDIF.

WRITE SY-INDEX.

ENDDO.

The output is:

1 3 4

The second loop pass is terminated without the WRITE statement being processed.

Revert back if any confusion.

Regards,

Sujit

Read only

0 Likes
1,034

Thanks and regards! I've done now!

Read only

Subhankar
Active Contributor
0 Likes
1,034

Hi

Please check it.

DATA : i_mara TYPE STANDARD TABLE OF mara,

wa_mara TYPE mara.

SELECT * FROM mara

UP TO 10 ROWS

INTO TABLE i_mara.

LOOP at i_mara INTO wa_mara FROM 8.

WRITE: / wa_mara-matnr.

ENDLOOP.