2007 Mar 02 5:38 AM
if in a loop iam checkin a condition n if the condition satisfies then which is the best way to exit the loop.
Hi,
Use EXIT Statment inside loop, you are exiting from the loop.
If hleps plz reward points.
Regards
Bhupal Reddy
2007 Mar 02 5:42 AM
Hi
USE EXIT within the loop thats the best way to exit out of the loop.
Cheers
VJ
2007 Mar 02 5:42 AM
2007 Mar 02 5:43 AM
Hi,
Use EXIT for the same
if sy-subrc = 0.
exit.
endif.
Regards,
Satyendra
2007 Mar 02 5:53 AM
Hi Sushant,
Use EXIT in the LOOP after the condition .If u use STOP it will exit from the Program.
Try this example creating a Program by uncommending EXIT and STOP.
DATA: t_mara TYPE STANDARD TABLE OF mara.
DATA: w_mara TYPE mara,
sum TYPE i.
SELECT matnr mtart FROM mara INTO CORRESPONDING FIELDS OF TABLE t_mara
WHERE mtart EQ 'KMAT' OR mtart EQ 'FERT' OR mtart EQ 'LGUT'.
sum = 0.
IF sy-subrc EQ 0.
SORT t_mara BY mtart.
LOOP AT t_mara INTO w_mara.
IF w_mara-mtart EQ 'LGUT'.
sum = sum + 1.
EXIT.
*STOP.
ENDIF.
ENDLOOP.
ENDIF.
WRITE : sum.
Reward Points if useful.
Regards
Avi...
2007 Mar 02 6:04 AM
Hi,
Use EXIT Statment inside loop, you are exiting from the loop.
If hleps plz reward points.
Regards
Bhupal Reddy
2007 Mar 02 6:08 AM
Hi
Use EXIT Statment within the loop, this can takes the control out of the loop if the condition satisfies.
Regards,
kumar
2007 Mar 02 7:13 AM
Hi ,,
Exit is the best option , because if you use STOP control then goes to End-of-selection .
Thanks .
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |