SAP System Variables

ABAP has given some predefined types of variables that are used to query system statuses; these variables are called SAP System Variables. Also, to check whether a given command worked properly or not, we use these variables. These are filled during runtime. They can store numeric, char, integer, date or time values. There is a field SY-SUBRC which is always zero ‘0’ in case of correct program run.

There is a table/structure in ABAP Dictionary (SE11) where you can find all the list of these variables with description.  They can be accessed using Keyword “SYST-” or “SY-”.

Following are some of the SAP System Variables:

NAME TYPE LENGTH DESCRIPTION
SY-SUBRC i Returns value 0 in case of no error of above statement
SY-DATUM d System Date
SY-UZEIT t System Time
SY-INDEX i Loop Index : Contains previous loop passes with the current one
SY-TABIX i Row number in the table index of Internal Table
SY-UCOMM c 70 Function Code that has raised the event PAI

Programming Guidelines to use System Variables:

  1. It is recommended not to define a local variable starting with “SYST-” or “SY-” ( although not forbidden).
  2. Do not use obsolete system Fields. Here is a list of Obsolete ABAP System Fields.
  3. Use System Fields at right position. It means using a SY-SUBRC check after a mathematical expression will never change its value.

Following are some of the Implementation of System Variables:

WRITE: / “ABAP SYSTEM VARIABLES”.
WRITE: / ‘DATE:’ SY-DATUM.
WRITE: / ‘TIME:’ SY-UZEIT.

The output for above codes is:

ABAP SYSTEM VARIALBES
27-06-2018
11:34:00

To view the complete list of ABAP System Variables, visit here.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Translate »