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: 

Sy-subrc values

Former Member
0 Kudos

Hi All,

Can any one let me know the values of Sy-subrc and its meaning.

Thanks & Regards.

Jareer.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

SY-SUBRC

Return code, set by the following ABAP statements. As a rule, if SY-SUBRC = 0, the statement

was executed successfully.

ASSIGN sets SY-SUBRC to 0 if the field symbol assignment was possible, otherwise to 4.

AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the required authorization,

otherwise to 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause of the authorization

failure.

CALL DIALOG with USING sets SY-SUBRC to 0 if the processing is successful, otherwise to

a value other than 0.

CALL FUNCTION sets SY-SUBRC in accordance with the defined exception handling.

CALL METHOD sets SY-SUBRC in accordance with the defined exception handling.

CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chooses Enter or Execute, and

4 if the user chooses Cancel.

CALL TRANSACTION with USING sets SY-SUBRC to 0 if the processing is successful,

otherwise to a value other than 0.

CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC after the ENDCATCH statement if a

system exception occurs. The value is set in the program.

COMMIT WORK sets SY-SUBRC to 0.

COMMIT WORK AND WAIT sets SY-SUBRC to 0 if the update is successful, otherwise to a

value other than 0.

COMMUNICATION INIT DESTINATION … RETURNCODE sets SY-SUBRC as specified.

CONCATENATE sets SY-SUBRC to 0 if the result fits into the target variable, otherwise to 4.

CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled

in the program.

CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object could be created,

otherwise to 1, 2, or 3, depending on the cause.

DELETE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or another value

other than 0, depending on the cause.

DEMAND … MESSAGES INTO sets SY-SUBRC to 0 if the message table is empty,

otherwise to a value other than 0.

DESCRIBE LIST sets SY-SUBRC to 0 if the line or list exists, otherwise to 4 or 8.

EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in nearly all cases. It does, however, set SYSUBRC

to 4 if no entry is read in a FETCH statement.

FETCH sets SY-SUBRC to 0 if at least one line was read, otherwise to 4.

GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if the generation was successful,

otherwise to 8.

GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise to 4.

GET PARAMETER sets SY-SUBRC to 0 if a corresponding value exists in SAP memory,

otherwise to 4.

IMPORT sets SY-SUBRC to 0 if the import is successful, otherwise to 4.

INSERT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

LOAD REPORT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or 8

depending on the cause of the error.

LOOP sets SY-SUBRC to 0 if there is at least one pass through the extract. Otherwise, it is

set to a value other than 0.

LOOP AT sets SY-SUBRC to 0 if there is at least one loop pass through the internal table,

otherwise to 4.

MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

MODIFY LINE sets SY-SUBRC to 0 if a line in the list was changed, otherwise it sets it to a

value other than 0.

MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

OLE2 Automation: Bundled commands set SY-SUBRC to 0 if all commands could be

executed successfully, otherwise 1, 2, 3, or 4, depending on the cause of the error.

OPEN DATASET sets SY-SUBRC to 0 if the file could be opened, otherwise to 8.

Open SQL statements set SY-SUBRC to 0 if the operation is successful, otherwise to a value

other than 0.

OVERLAY sets SY-SUBRC to 0 if at least one character is overlaid, otherwise to 4.

READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise to 4

or 8, depending on the cause of the error.

READ LINE sets SY-SUBRC to 0 if a list line exists, otherwise to a value other than 0.

READ TABLE sets SY-SUBRC to 0 if table lines are found, otherwise to 2, 4, or 8, depending

on the context and cause of the error.

REPLACE sets SY-SUBRC to 0 if the search string was replaced, otherwise to a value other

than 0.

SCROLL sets SY-SUBRC to 0 if the scrolling within the list was successful, otherwise to 4 or

8, depending on the cause.

SEARCH sets SY-SUBRC to 0 if the search string was found, otherwise to 4.

SELECT sets SY-SUBRC to 0 if at least one line was read, otherwise to 4, or possibly 8 in

SELECT SINGLE FOR UPDATE.

SET COUNTRY sets SY-SUBRC if the country code exists in table T005X, otherwise to 4.

SET BIT sets SY-SUBRC to 0 if the bit could be set, otherwise to a value other than 0.

SET TITLEBAR sets SY-SUBRC to 0 if the title exists, otherwise to 4.

SHIFT … UP TO sets SY-SUBRC to 0 if the position could be found within the string,

otherwise to 4.

SPLIT sets SY-SUBRC to 0 if the sizes of the target fields are adequate, otherwise to 4.

UPDATE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

WRITE … TO sets SY-SUBRC to 0 if the assignment is successful, otherwise to 4.

Regards,

Bhaskar

6 REPLIES 6

Former Member
0 Kudos

hi,

Field:SY-SUBRC

Definition

Return value of many ABAP statements. In general, the content 0 means that the statement was executed without problem. Depending on with which statement sy-subrc was set, the error cause can be derived from the respective value.

Former Member
0 Kudos

hi,

Sy-subrc gives the return code of the previous statement.

sy-subrc = 0 means its true and its executed correctly.

sy-subrc = 4 means there is an error.

Former Member
0 Kudos

Hi ,

One important thing is that when SY-SUBRC = 0, then the previous statement is successful, when it is not 0, then the previous statement was not successful.

For examples:

sy-subrc = 0 -


Success

sy-subrc = 4 -


Failure(known reason)

sy-subrc = 8 -


Internal error(Unknown reason).

sy-subrc = 1001 -


Failure error in BDC

Hope this resolves your query.

Reward all the helpful answers.

Former Member
0 Kudos

Hi.

The subrc variable is used to indicate if a function module or another command in ABAP was successful.

The value of sy-subrc depends on the place where it occurs.

For example a command like SELECT is giving a sy-subrc = 4 if no entry was found in the database.

Another example is that function module can raise exceptions. If the caller of the function is catching the exceptions, a number is assigned to the exceptions. Whenever the function module is raising the particular exception the sy-subrc in the calling programm is set to this number.

Normally the sy-subrc should be 0 if everything is ok. But for sure there are some exceptions in the ABAP world.

Regards,

Timo.

Former Member
0 Kudos

hi,

sy-subrc is a system variable which holds the value of execution of previous statement.

when an statement is executed it has two values.

i.e the statement is executed or not. that value is maintained by sy-subrc.

sy-subrc eq 0 // statement executed successfully.

sy-subrc ne 0 // statement not executed.

depending on the statement sy-subrc has many values as 0, 2, 4, 8 ,............

ex:

select * from mara into table itab where matnr in p_matnr.

if sy-subrc eq 0. // if records available with given condition.

...............

else. // no records found with given condition in database table.

.................

endif.

if useful reward so9me points.

with regards,

Suresh.A

Former Member
0 Kudos

Hi,

SY-SUBRC

Return code, set by the following ABAP statements. As a rule, if SY-SUBRC = 0, the statement

was executed successfully.

ASSIGN sets SY-SUBRC to 0 if the field symbol assignment was possible, otherwise to 4.

AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the required authorization,

otherwise to 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause of the authorization

failure.

CALL DIALOG with USING sets SY-SUBRC to 0 if the processing is successful, otherwise to

a value other than 0.

CALL FUNCTION sets SY-SUBRC in accordance with the defined exception handling.

CALL METHOD sets SY-SUBRC in accordance with the defined exception handling.

CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chooses Enter or Execute, and

4 if the user chooses Cancel.

CALL TRANSACTION with USING sets SY-SUBRC to 0 if the processing is successful,

otherwise to a value other than 0.

CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC after the ENDCATCH statement if a

system exception occurs. The value is set in the program.

COMMIT WORK sets SY-SUBRC to 0.

COMMIT WORK AND WAIT sets SY-SUBRC to 0 if the update is successful, otherwise to a

value other than 0.

COMMUNICATION INIT DESTINATION … RETURNCODE sets SY-SUBRC as specified.

CONCATENATE sets SY-SUBRC to 0 if the result fits into the target variable, otherwise to 4.

CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled

in the program.

CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object could be created,

otherwise to 1, 2, or 3, depending on the cause.

DELETE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or another value

other than 0, depending on the cause.

DEMAND … MESSAGES INTO sets SY-SUBRC to 0 if the message table is empty,

otherwise to a value other than 0.

DESCRIBE LIST sets SY-SUBRC to 0 if the line or list exists, otherwise to 4 or 8.

EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in nearly all cases. It does, however, set SYSUBRC

to 4 if no entry is read in a FETCH statement.

FETCH sets SY-SUBRC to 0 if at least one line was read, otherwise to 4.

GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if the generation was successful,

otherwise to 8.

GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise to 4.

GET PARAMETER sets SY-SUBRC to 0 if a corresponding value exists in SAP memory,

otherwise to 4.

IMPORT sets SY-SUBRC to 0 if the import is successful, otherwise to 4.

INSERT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

LOAD REPORT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or 8

depending on the cause of the error.

LOOP sets SY-SUBRC to 0 if there is at least one pass through the extract. Otherwise, it is

set to a value other than 0.

LOOP AT sets SY-SUBRC to 0 if there is at least one loop pass through the internal table,

otherwise to 4.

MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

MODIFY LINE sets SY-SUBRC to 0 if a line in the list was changed, otherwise it sets it to a

value other than 0.

MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

OLE2 Automation: Bundled commands set SY-SUBRC to 0 if all commands could be

executed successfully, otherwise 1, 2, 3, or 4, depending on the cause of the error.

OPEN DATASET sets SY-SUBRC to 0 if the file could be opened, otherwise to 8.

Open SQL statements set SY-SUBRC to 0 if the operation is successful, otherwise to a value

other than 0.

OVERLAY sets SY-SUBRC to 0 if at least one character is overlaid, otherwise to 4.

READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise to 4

or 8, depending on the cause of the error.

READ LINE sets SY-SUBRC to 0 if a list line exists, otherwise to a value other than 0.

READ TABLE sets SY-SUBRC to 0 if table lines are found, otherwise to 2, 4, or 8, depending

on the context and cause of the error.

REPLACE sets SY-SUBRC to 0 if the search string was replaced, otherwise to a value other

than 0.

SCROLL sets SY-SUBRC to 0 if the scrolling within the list was successful, otherwise to 4 or

8, depending on the cause.

SEARCH sets SY-SUBRC to 0 if the search string was found, otherwise to 4.

SELECT sets SY-SUBRC to 0 if at least one line was read, otherwise to 4, or possibly 8 in

SELECT SINGLE FOR UPDATE.

SET COUNTRY sets SY-SUBRC if the country code exists in table T005X, otherwise to 4.

SET BIT sets SY-SUBRC to 0 if the bit could be set, otherwise to a value other than 0.

SET TITLEBAR sets SY-SUBRC to 0 if the title exists, otherwise to 4.

SHIFT … UP TO sets SY-SUBRC to 0 if the position could be found within the string,

otherwise to 4.

SPLIT sets SY-SUBRC to 0 if the sizes of the target fields are adequate, otherwise to 4.

UPDATE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.

WRITE … TO sets SY-SUBRC to 0 if the assignment is successful, otherwise to 4.

Regards,

Bhaskar