Skip to Content
avatar image
Former Member

Question about SY-SUBRC

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..

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

11 Answers

  • avatar image
    Former Member
    Sep 15, 2008 at 05: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.??

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05:41 AM

    search SCN

    it works 😊

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05:43 AM

    hi,

    Yes it works.

    Regards,

    Tarun

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05:44 AM

    Hi,

    Sy-subrc will work in loop also

    thanks

    Gowri Sankar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05:45 AM

    hi,

    Please check this link for all queries on SY-SUBRC

    https://www.sdn.sap.com/irj/sdn/wiki

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 15, 2008 at 05:58 AM

    Hi,

    Can you please show us your code so that we can analyse where the problem is .

    Regards,

    Nitin.

    Add comment
    10|10000 characters needed characters exceeded