09-15-2008 6:38 AM
Hi Experts,
Can anyone clear my doubt that is SY-SUBRC works inside the Nested loop or loop statement or not? If not Why?
Thanks a lot in advance..
09-15-2008 6:41 AM
09-15-2008 6:43 AM
09-15-2008 6:44 AM
09-15-2008 6:45 AM
09-15-2008 6:46 AM
Hi Moni,
Yes, It works inside the loop also.
Sy-subrc check whether an ABAP statement is succesful or not.
Executing a loop itself means that we are processing the correct and valid records. Then where is the issue of checking sy-subrc value, It will always be equal to 0 (zero).
Regards,
Nitin.
09-15-2008 6:46 AM
But in my code it is not working.. I have placed a nested loop and was counting if SY-SUBRC = 0 then it should do something. But its not checking the value if it is equal to 0 but giving me the value of sy-subrc as 4.??
09-15-2008 6:47 AM
09-15-2008 6:53 AM
but my condition is matching with the criteria but inspite of this sy-subrc = 4. I was checking it in debugging, sy-subrc should be = 0 with my records. But it is not
09-15-2008 6:59 AM
Hi Moni,
Can you copy the part of code in your case?
starting from LOOP AT.... to ENDLOOP. ?
Then we can help better
Cheers,
Kothand
09-15-2008 6:46 AM
Hi Moni,
SY-SUBRC cannot be used for Counting.
For that you need to declare separate variable and then
ADD 1 TO counter.
Cheers,
Kothand
09-15-2008 6:47 AM
hii
sy-subrc can also check whether an ABAP statement is succesful or not..you can use it with READ statament.
regards
twinkal
09-15-2008 6:49 AM
Hi Moni,
If it is showing you value 4 for sy-subrc in nested loop,
It means there is no record satisfying your WHERE condition for that loop.
Thats why it must be showing 4.
Regards,
Nitin.
09-15-2008 6:58 AM
Hi,
Can you please show us your code so that we can analyse where the problem is .
Regards,
Nitin.
09-15-2008 6:59 AM
Hi,
Its works in loop or outside loop alos
WHEN SELECT QUERY EXECUTE THAN VALUE OF SY-SUBARC = 0 OTHER WISE ITS 4
WITH EXAMPLE
DATA : ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA INTO TABLE ITAB.
IF SY-SUBRC = 0.
WRITE : 'EXECUTE'.
ENDIF.
LOOP AT ITAB.
IF SY-SUBRC = 0.
WRITE 😕 ITAB-MATNR.
ENDIF.
ENDLOOP.