SAP System Variables

by | Mar 8, 2018 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » SAP System Variables

Preface – This post is part of the ABAP Beginner series.

SAP System Variables

ABAP has given some predefined types of variables used to query system statuses. These variables are called SAP system variables. We use these variables to check whether a given command works properly. 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 the correct program run.

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

Following are some of the SAP System Variables:

NAMETYPELENGTHDESCRIPTION
SY-SUBRCiReturns value 0 in case of no error of above statement
SY-DATUMdSystem Date
SY-UZEITtSystem Time
SY-INDEXiLoop Index: Contains previous loop passes with the current one
SY-TABIXiRow number in the table index of Internal Table
SY-UCOMMc70Function Code that has raised the event PAI

Programming Guidelines:

  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 the right position. It means using an SY-SUBRC check after a mathematical expression will never change its value.

Implementation of System Variables:

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

The output for the above code is:

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

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

Author

0 Comments

Submit 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.

Author