‎2007 Oct 19 1:07 PM
Hi.
I incorporated a DO loop in a subroutine, but it doesn't seem to be working.
**********************************************************************
FORM VALIDATE_FILEPATH.
DO 10 TIMES.
SELECT AREA_A_FILE_MAND INTO MAND_CHECK FROM ZSCSDM_OF
WHERE OBJECT_ID = 'STUD' AND FILE_NUMBER = SY-INDEX.
ENDSELECT.
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
ENDDO.
ENDFORM.
**********************************************************************
The message will always return 1 (i.e. SY-INDEX is always = 1)
Thanks
‎2007 Oct 19 1:09 PM
Hi,
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
this is stopping the process of do loop
put in a condition atleast..
like
DO 10 TIMES.
SELECT AREA_A_FILE_MAND INTO MAND_CHECK FROM ZSCSDM_OF
WHERE OBJECT_ID = 'STUD' AND FILE_NUMBER = SY-INDEX.
<b>so when ever it is failed this will give the message</b>
<b>if sy-subrc ne 0.
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
endif.</b>
ENDSELECT.
ENDDO.
regards,
Venkatesh
‎2007 Oct 19 1:09 PM
Hi,
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
this is stopping the process of do loop
put in a condition atleast..
like
DO 10 TIMES.
SELECT AREA_A_FILE_MAND INTO MAND_CHECK FROM ZSCSDM_OF
WHERE OBJECT_ID = 'STUD' AND FILE_NUMBER = SY-INDEX.
<b>so when ever it is failed this will give the message</b>
<b>if sy-subrc ne 0.
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
endif.</b>
ENDSELECT.
ENDDO.
regards,
Venkatesh
‎2007 Oct 19 1:11 PM
HI,
you are making the message for each loop.
for the first time it will go insdide...
then it will give error message
then it will come out of the do loop.
if you want the message every time and to continue the loop
you can make it success message ...
regards,
Venkatesh
‎2007 Oct 19 1:13 PM
Hi,
do like this
SELECT AREA_A_FILE_MAND INTO table MAND_CHECK FROM ZSCSDM_OF
WHERE OBJECT_ID = 'STUD'.
loop at mand_check.
if sy-index > 10.
exit.
else.
MESSAGE E002(ZMSGGARY) WITH SY-INDEX.
endif.
endloop.<b>Reward for helpful answers</b>
Satish
‎2007 Oct 19 1:15 PM
Hi,
change message type to S
MESSAGE S002(ZMSGGARY) WITH SY-INDEX.
‎2007 Oct 19 3:59 PM
for looping through itab, we should use sy-tabix instead of sy-index. if i use sy-index, somehow it returns 0 instead of 1, 2....
loop at mand_check.
if sy-index > 10. ==> NO.
IF SY-TABIX > 10 ==> YES.