2005 Oct 13 7:56 AM
Dear all,
The structure of my code is as follows :-
LOOP AT ITAB. (1)
.....
....
DO. (2)
....
....
DO. (3)
....
....
IF I > 2.
....GOT TO NEXT LOOP PASS (1).
ENDIF.
ENDDO.
ENDDO.
ENDLOOP.
Which statement can I use to get out of the two DO loops and go to the next Loop pass of LOOP (1).
Please suggest.
Thanks in advance,
Archana
2005 Oct 13 8:02 AM
Hi Archana!
Easiest way: make a flag for this:
data next_loop type xflag.
loop at itab.
clear next_loop.
do.
do.
if ...
next_loop = 'X'.
exit. (3)
endif.
enddo.
if next_loop = 'X'.
exit. (2)
endif.
enddo.
if next_loop = 'X'.
continue. (1)
endif.
... (optional coding)
endloop.
Regards,
Christian
Hi Archana!
Easiest way: make a flag for this:
data next_loop type xflag.
loop at itab.
clear next_loop.
do.
do.
if ...
next_loop = 'X'.
exit. (3)
endif.
enddo.
if next_loop = 'X'.
exit. (2)
endif.
enddo.
if next_loop = 'X'.
continue. (1)
endif.
... (optional coding)
endloop.
Regards,
Christian
2005 Oct 13 8:02 AM
Hi Archana!
Easiest way: make a flag for this:
data next_loop type xflag.
loop at itab.
clear next_loop.
do.
do.
if ...
next_loop = 'X'.
exit. (3)
endif.
enddo.
if next_loop = 'X'.
exit. (2)
endif.
enddo.
if next_loop = 'X'.
continue. (1)
endif.
... (optional coding)
endloop.
Regards,
Christian
2005 Oct 13 9:02 AM
Hi Christian,
Thanx so much....
Ur solution has solved my problem...
have rewarded u the points as well...
2005 Oct 13 8:03 AM
Hi Archana,
There is not one statement to get out of the innermost DO-loop and the outermost DO-loop at once.
You will have to program 2 consecutive EXITs (one for each DO-ENDDO) to accomplish this.
Regards,
John.
2005 Oct 13 8:03 AM
Hi Archana,
You can use CONTINUE to come out of the current loop.
see below example i hope it may help you.
DO 100 TIMES.
IF SY-INDEX >= 10 AND SY-INDEX <= 20.
CONTINUE.
ENDIF.
...
ENDDO.
if solution is helpful kindly reward the points
2005 Oct 13 8:03 AM
Hi,
U can use EXIT or STOP Statement.
Simple example of a DO loop:
DO.
WRITE SY-INDEX.
IF SY-INDEX = 3.
EXIT.
ENDIF.
ENDDO.
The output is:
1 2 3
Check this link,
<u>http://help.sap.com/saphelp_erp2004/helpdata/en/fc/eb3564358411d1829f0000e829fbfe/frameset.htm</u>
Thanks&Regards,
Ruthra
2005 Oct 13 8:03 AM
There is no single staemant you can use - you can EXIT to extr to DO-LOOP. But to go to the next LOOP you have to use CONTINUE.
Define a help-variable ex. l_exit and set this to TRUE if you want to exit and check for this.
2005 Oct 13 8:04 AM
Hi!
The idea is the following - place DO(2) and DO(3) loops inside separate FORMS and handle return parameters from them bottom-up.
Regards,
Maxim.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |