Skip to Content
author's profile photo Former Member
Former Member

about sy-subrc

Hi friends,

i have my code like this...

if filed1 is initial.

if sy-subrc Eq 0.

do something...

endif.

endif.

after if condition (i.e if filed1 is initial),is it possible to check sy-sybrc.please tell me

but in above code if field1 is initial,i am not getting sy-subrc 0.

please tell me

Thanks,

kishore.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 07:47 AM

    hi,

    Checking for sy-subrc is not required ... you can remove that ...

    if filed1 is initial.
    *if sy-subrc Eq 0.
    do something...
    *endif.
    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 22, 2008 at 07:48 AM

    hi,

    sy-subrc returns 0 if a preceding statement was executed successfully.

    in your case, the if statement for field1 is true that is why subrc returns 0.

    regards,

    Peter

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 07:49 AM

    with If condition sy-subrc is not req.

    Sy-subrc have the value of last condition.

    Edited by: shilpi agarwal on Jul 22, 2008 9:49 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 07:49 AM

    hi ,

    here the sy-subrc check is not required.

    you can just check the conditiond

    if field1 is initial

    do something.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 07:50 AM

    Hi Kishore,

    If your field1 is a Table field which is fetched from a table then u need to check the sy-subrc otherwise it is not required. Usually it holds the return value for ABAP Statements.

    Regards,

    Sai

    Edited by: Sai Krishna Kowluri on Jul 22, 2008 9:50 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 08:27 AM

    hi,

    You can very well check the other conditions that you wanted to check for without the sy-subrc ... as the sy-subrc has no significance ...

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 08:54 AM

    Kishor,

    Try to use

    if filed1 = space.

    if sy-subrc = 0.

    do something...

    endif.

    endif.

    Check out all possible scenarios....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 22, 2008 at 09:17 AM

    Sy-subrc should be written immediately after the concerned statement Eg. Read statement, select statement.

    for eg:

    read table tab1 into wa1 with key f1 = 'a'.

    -->

    if sy-subrc eq 0. (or if wa1 is not initial)

    do something.

    endif..

    if you write some command statement which has a sy-subrc return code in between read and if statement.

    for eg you are doing a select statement in between then the system variable Sy-subrc would give you the result of the select statement not the read

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 08:04 AM

    solved

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.