sy
sy('<SAP_variable>')
varchar(255): The value of the SAP system variable. You may need to recast the return value to the actual data type of the system variable in SAP.
<SAP_variable>: A string value containing the name of the SAP system variable. This value is not case sensitive. Enclose the name in single quotation marks (').
When the sy function is executed, the software generates the appropriate function call in the ABAP for the ABAP data flow (appends SY- to the <SAP_variable > that you specify) and returns the result of the function call at run time.
The table SYST in SAP lists the available system variable, their data types, and descriptions.
If the given <SAP_variable > does not exist in SAP, a run-time error will be returned:
ABAP program <Generated ABAP Program> syntax error: <The data object "SY" has no component called "ABC">.
No value is returned when this error occurs.
Example:
Function |
Results |
---|---|
sy('SUBRC') |
0 if the subroutine call returned successfully |
sy('mandt') |
The client ID number of the current SAP application client |
sy('UNAME') |
The login name of the user |
sy('DATUM') |
The current date from the SAP application server |
sy('UZEIT') |
The current time from the SAP application server |
sy('TCODE') |
The current transaction code |
* Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of example code unless damages have been caused by SAP's gross negligence or willful misconduct.