In ABAP, system fields are predefined fields provided by the SAP runtime environment. They hold important contextual information about the program’s current state — like the current date, time, user, or return codes of statements.
These fields start with SY- and are always available globally in any ABAP program.
They are read-only for most cases (with a few exceptions) and help developers write more intelligent and context-aware programs.
Why Use System Fields?
You can use system fields to:
- · Check return codes after statements (SY-SUBRC)
- · Get current user (SY-UNAME)
- · Get current date/time (SY-DATUM, SY-UZEIT)
- · Control logic flow depending on system response
- · Debug or log useful runtime info
List of Commonly Used System Fields
System Field | Description |
SY-DATUM | Current date |
SY-UZEIT | Current time |
SY-UNAME | Current user ID |
SY-SUBRC | Return code of the last ABAP statement |
SY-TCODE | Current transaction code |
SY-CPROG | Name of the calling program |
SY-REPID | Current ABAP report or program name |
SY-TABIX | Index of current row in internal table loop |
SY-LANGU | Logon language of the user |
SY-MANDT | Client number |
SY-INDEX | Loop index |
SY-DBCNT | Number of rows affected by last DB operation |
SY-MSGID | Message class of last message |
SY-MSGNO | Message number of last messages |
SY-MSGTY | Message type (E, I, W, etc.) |
SY-MSGV1 to SY-MSGV4 | Variables used in messages |
SY-BATCH | Flag: is this a background (batch) job? |
SY-SLSET | Selection screen variant used |
SY-STEPL | Step number (mainly in background processing) |
SY-LILLI | Current line number in the program |
SY-ROWNO | Row number of ALV grid event |
SY-FDPOS | Position of the first character that differs in a comparison |
SY-CUCOL / SY-CUROW | Current cursor column/row position |
SY-SYSID | System ID (e.g., DEV, PRD) |