SAP ABAP: SY-SUBRC meaning

SY-SUBRC is SAP ABAP system field and contains a return code of ABAP statements.

System fields are active in all ABAP programs and they get their value by the run-time environment.

In almost every ABAP program the system field SUBRC is used, because it’s meaning is connected with the successful execution of a statement. It contains return value, set by ABAP statements. It is an integer value like 0, 4, 8 or other. This value is used to determine the status of the execution of an ABAP statement. If SY-SUBRC is 0, the ABAP statement has been executed successfully. If the value is different from 0, than the statement has raised an error or warning. Usually 4 means error and 8 means warning, but this is not obligatory. It depends on the statement.

‘SUBRC’ and all other system fields can be found in the structure ‘SYST’. To address them in an ABAP program, You should use the following form: SY-<fieldname>.

abap

Here are some examples of the values of SY-SUBRC on different ABAP statements:

  •  ‘CALL FUNCTION’ in function modules sets the value based on the exceptions declared. The same is valid for ‘CALL METHOD’.
  • Statement ‘SELECT’ sets the return code to 0 if at least one line was retrieved. If no line was selected, the return code is 4 or 8.
  • DELETE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or another value other than 0, depending on the cause.
  • GET PARAMETER sets SY-SUBRC to 0 if a corresponding value exists in SAP memory, otherwise to 4.
  • 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.
  • LOAD REPORT sets it to 0 if the operation is successful, otherwise the code is 4 or 8 depending on the error.

A non-zero value of the return code doesn’t necessarily mean that an operation failed. It just gives You some information about the results of an operation.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × five =