‎2007 Jun 23 8:30 AM
what is the effect of sy-subrc in the programme
how it works
regards basavaraj
‎2007 Jun 23 9:20 AM
Hi ,
Sy-subrc is a system variable. It will be indicate whether a particular ABAP is executed succussfully or failed. Depending on its value of sy-subrc , even we can tell what is the reason of failure.
For example
read table itab with key a = 'K'.
after this statment sy-subrc will be checked to know whether read statement worked properly or not.
If sy-subrc eq 0 , then read statement is succuss data has been fetched from table and if is not equal to 0 , then no data has been from internal table
‎2007 Jun 23 9:47 AM
Hi Basavraj,
Sy-subrc is used to check if the particular statement, ABAP or SQL was successful or not.
For eg, we check sy-subc after SELECT, if it is 0 that means the SELECT was successful and we got the data from DB table
Also let say we check sy-subrc after READ statement , here if value is 0 that means we found entry in the internal table.
Reward points if useful.
Regards,
Atish
‎2007 Jun 23 3:26 PM
hi
u can put a check using sy-subrc if some condition fails. suppose
select * from ztable into table itab.
if sy-subrc eq 0. " it means data fetched successfully
else
the value of sy-subrc will be 4.
<b>u can check the value of sy-subrc using debugger</b>
hope it may help u.
regards
ravish
<b>plz dont forget to reward points if helpful</b>
‎2007 Jun 24 8:47 AM
Hi,
The Variable sy-subrc is a field of a structure SYST available in SY during runtime of SAP.
It is initialised for every internal or external session,
when a program is executed the status of the sy-subrc indiacates the status of the execution of the staement. if the value is zero then the previous statement execution is succesful, if the execution have some error number then the error is determined by the value of sy-subrc. (which is always greater than zero).
When you call a function module you have see some exceptions, is any exception occurs numbers are placed in sy-subrc field, with that number in your main program you can decide whether an error occured or not and you can decide how to handle the error.
Please reward if it is helpful.
‎2007 Jun 25 8:10 AM
Hi,
<i><b>SY-SUBRC</b></i> is a<i><b> system variable</b></i>. System variable meaning the value in this field will be directly placed by system as the program executes. It is part of <i><b>SYST</b></i> structure. SYST structure contains many more system variables.
In ABAP program, SY-SUBRC plays important role. The value is placed as <i><b>"0" (Zero) </b></i> if the execution of the current statement in the program is<i><b> successful</b></i>.
And if any <i><b>error</b></i> occurs than <i><b>nonzero value</b></i> is placed in SY-SUBRC.
The value of SY-SUBRC can be viewed in the ABAP Debugger at runtime for each last executed statement.
Depending on the value of the SY-SUBRC the flow of the program can be controlled. Like if the SELECT query gives successful results with SY-SUBRC as 0 then only execute the next statement. This can be done by checking the value of SY-SUBRC using IF statement. So verifying the value of SY-SUBRC in the program has lots of effects in flow of the program at runtime.
Hope this helps.
PS If the answer solves your query, plz reward each reply and close the thread by marking it Solved.
Regards
‎2007 Jun 25 8:55 AM
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if subrc = 0
then data is exsist and correct ...
if subrc = 4
then data doesnot exsist in the database , internal table etc ..
sy-subrc is used outside the select statements .
reward points if it is usefull ...
Girish