‎2009 Nov 03 3:30 PM
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
‎2009 Nov 03 3:35 PM
Wrap it inside a WHILE / ENDWHILE, but beware of endless loops
Thomas
‎2009 Nov 03 3:35 PM
Wrap it inside a WHILE / ENDWHILE, but beware of endless loops
Thomas
‎2009 Nov 03 3:36 PM
how to do it, please give me a snippet.
It is LOOP AT statement not WHILE.
‎2009 Nov 03 3:38 PM
‎2009 Nov 03 3:39 PM
please write a sample code using LOOP at statement and demonstrate.
‎2009 Nov 03 3:40 PM
You're going to have to give some more information. Thge logic you have given will simply produce an infinite loop.
Rob
‎2009 Nov 03 3:53 PM
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