Use System Variables

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Use system variables in a program

Frequently Used System Variables

System Variables

System VariableDescription
SY-DATUMCurrent date
SY-UZEITCurrent time
SY-UNAMEUser ID of current user

So far, you have declared all variables that you work with in your ABAP programs. However, the system contains special system variables (or system fields) that you can use in your source code without explicitly declaring them. The ABAP runtime system manages these system variables, and they are available to any ABAP program that wants to use them.

Note
You can recognize a system variable by its name. All system variable names begin with (SY-).

System variables provide information about the actual system status. The ABAP runtime system populates and changes the values of the system fields when necessary.

For example, the system variable SY-DATUM is always filled with the current date, and SY-UZEIT is filled with the current time.

For a complete list of system variables, see the ABAP keyword documentation for System Fields.

Note
System variables are intended for read access only.

Handling Empty Results Using a System Field

In this code example, the SELECT statement reads the data from a database table using the SELECT statement. If the system finds a suitable record, the system variable SY-SUBRC returns with the value 0. If this occurs, the program may output the data that was retrieved or use the data in a follow on statement.

Save progress to your learning plan by logging in or creating an account