Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

about sy-subrc

Former Member
0 Kudos

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.

11 REPLIES 11

Former Member
0 Kudos

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.

0 Kudos

Remove sy-subrc check ...

Raghav

peter_ruiz2
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

hi ,

here the sy-subrc check is not required.

you can just check the conditiond

if field1 is initial

do something.

endif.

Former Member
0 Kudos

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

0 Kudos

Hi,

Thanks for all u r answers...

but with the value of sy-subrc ,i want to check another condition with in same if and endif.

That's why i checking the value of sy-subrc

Thanks,

kishore.

Former Member
0 Kudos

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

Former Member
0 Kudos

Kishor,

Try to use

if filed1 = space.

if sy-subrc = 0.

do something...

endif.

endif.

Check out all possible scenarios....

Former Member
0 Kudos

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

Former Member
0 Kudos

solved