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 Problem

Former Member
0 Likes
934

hi,

i have 4 records in internal table and using a loop.

If on record 4, field 1 EQ 0 then want to rerun the loop FROM START.

Please can anyone guide me how to do this << Removed >>

Thanks

Moderator message - Please don not use words like "urjent"

Edited by: Rob Burbank on Nov 3, 2009 10:33 AM

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
907

Wrap it inside a WHILE / ENDWHILE, but beware of endless loops

Thomas

6 REPLIES 6
Read only

ThomasZloch
Active Contributor
0 Likes
908

Wrap it inside a WHILE / ENDWHILE, but beware of endless loops

Thomas

Read only

0 Likes
907

how to do it, please give me a snippet.

It is LOOP AT statement not WHILE.

Read only

0 Likes
907

wrap the loop inside a while endwhile...

Read only

0 Likes
907

please write a sample code using LOOP at statement and demonstrate.

Read only

0 Likes
907

You're going to have to give some more information. Thge logic you have given will simply produce an infinite loop.

Rob

Read only

0 Likes
907

Hi Merc,

See below code.

DATA: BEGIN OF itab OCCURS 0,

data TYPE i,

END OF itab,

wa LIKE itab.

wa-data = '1'.

APPEND wa TO itab.

wa-data = '2'.

APPEND wa TO itab.

wa-data = '3'.

APPEND wa TO itab.

wa-data = '0'.

APPEND wa TO itab.

READ TABLE itab INTO wa INDEX 4. " Initially read 4th record

WHILE wa-data = 0. " Loop while 4th record is Zero

LOOP AT itab INTO wa.

" Start your code

IF wa-data = 0.

wa-data = 1.

MODIFY itab FROM wa INDEX 4 TRANSPORTING data. " Modified 4th record to avoid infinite loop

ENDIF.

ENDLOOP.

" End your code

READ TABLE itab INTO wa INDEX 4. " Before going to check while condition read 4th record

ENDWHILE.

Thanks,

Edited by: Sap Fan on Nov 3, 2009 4:53 PM

Edited by: Sap Fan on Nov 3, 2009 4:55 PM