Summary -

In this topic, we described about the below sections -

ABAP System variables are predefined by the SAP system. These variables can accessed by all the programs in SAP environment. These variables always filled by the SAP runtime environment.

The system variables contain the values that describes about the current state of the system at any point of time (i.e. runtime). The complete list of system variable found in SYST table.

Individual fields of the SYST table can be accessed either using "SYST-" or "ST-". Below are the list of system variables available for usage -

NameTypeLengthContent
sy-abcdec26Contains the Latin alphabet. Used to access individual letters directly by specifying the offset/length.
sy-batchc1Contains "X" in an ABAP program running in the background; otherwise initial.
sy-binptc1Contains "X" when processing batch input sessions in ABAP programs called by CALL TRANSACTION USING; otherwise initial. These defaults can overridden using the addition OPTIONS FROM of the statement CALL TRANSACTION ... USING.
sy-calldc1Contains blank in the first program of a call sequence; otherwise "X". Set to "X" after calls using CALL TRANSACTION, CALL DIALOG, or SUBMIT ... AND RETURN. Empty if the program was started using LEAVE TO TRANSACTION or by a transaction code entered on the screen. A call using SUBMIT (without AND RETURN) takes the value of the calling program.
sy-callrc8Contains a value that indicates where spooling was started when spooling lists.
sy-colnoi Contains current position when a list is created in the list buffer; set whenever an output statement is used. Counting begins at 1. This position corresponding to the column in the displayed list and list is only guaranteed for the lower and upper output limits.
sy-cpagei Contains page number of the top page in the list display where a list event was raised. Counting begins at 1.
sy-cprogc40Contains the name of the calling program in externally called procedures; otherwise, the name of the current program. If an externally called procedure calls another external procedure, it contains the name of the master program, and is not set to the name of the master program of the subsequent calling program.
sy-cucoli Contains horizontal cursor position on the dynpro screen. Counting begins at column 2. Set after the event PAI.
sy-curowi Contains vertical cursor position on the dynpro screen. Counting begins at row 1. Set after the event PAI.
sy-datarc1Contains "X" for PAI, if at least one input field of a screen was changed by a user or some other data being passed.
sy-datlod Contains user date in the format "YYYYMMDD".
sy-datumd Contains system date.
sy-daystc1Contains "X" in summer time in the system time zone; otherwise initial.
sy-dbcnti Contains number of table rows processed. SQL statements set the content of sy-dbcnt to the number of table rows processed.
sy-dbnamc20Contains name of associated logical database for executable programs.
sy-dbsysc10Contains name of central database system.
sy-dyngrc4Contains name of screen group of the current dynpro. In Screen Painter, multiple dynpros can be assigned to the same screen group.
sy-dynnrc4Contains number of the current dynpro. In selection screen processing, the current selection screen. In list processing, the number of the subscreen dynpro. When processing a subscreen dynpro (including in tabstrips), the number of this dynpro.
sy-fdaywb Contains factory calendar weekday in the system time zone; Monday = 1, ..., Friday = 5.
sy-fdposi Contains occurrence after certain operations on character-like or byte-like data objects.
sy-hostc32Contains network name of the computer on which the current application server is instantiated.
sy-indexi Contains loop index. In DO and WHILE loops, contains the number of previous loop passes, including the current pass.
sy-languc1Contains single-character language key. Set by the logon language of the user or by the statement SET LOCALE.
sy-ldbpgc40Contains the database program of the associated logical database in executable programs.
sy-lillii Contains list line on which a list event was raised. Counting begins at 1 and includes the page header.
sy-lincti Contains page length of the current list when the list is created. sy-linct is 0 for a standard list of any length and has a value not equal to 0 for lists with fixed page lengths. Set by the introductory program statement or by SUBMIT.
sy-linnoi Contains current list line when the list is created. Counting begins at 1 and includes the page header. Set by output statements.
sy-linszi Contains row width of the current list in the list buffer when the list is created. By default, the value is set as follows - If sy-scols is greater than or equal to 84, sy-linsz is equal to sy-scols; otherwise sy-linsz has the value 84. This can be overridden by the introductory program statement or by SUBMIT.
sy-liselc255Contains content of the list line in the list buffer where the cursor was placed in the displayed list when a list event was raised (limited to the first 255 characters).
sy-listii Contains list level of the list in which a list event was raised.
sy-loopci Contains number of currently displayed rows in a table control. Set after the event PAI.
sy-lsindi Contains list level of the list that is currently being created (basic list: 0, details lists: greater than 0). For every interactive list event, sy-lsind is automatically increased by an increment of 1. sy-lsind can be changed in ABAP programs when navigating between details lists. Any changes made to sy-lsind are ignored until the end of a list event.
sy-macoli Contains number of columns on the left margin when spooling lists. Set by the statement SET MARGIN.
sy-mandtc3Contains client ID used by the current user to log on.
sy-marowi Contains number of rows on the top margin when spooling lists. Set by the statement SET MARGIN.
sy-modnoi Contains indexing of the ABAP sessions. Contains the value 0 in the first session. In new sessions that are opened using the Create Session function or by calling a transaction with /o in the command field of the standard toolbar, this value is increased by 1. If previous sessions were deleted, only the free numbers are allocated again. Sessions opened with CALL FUNCTION ... STARTING NEW TASK start at 0 again.
sy-msgidc20Contains the message class after the statement MESSAGE. Also set in the calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgnon3Contains the message number after the statement MESSAGE. Also set in the calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgtyc1Contains the message type after the statement MESSAGE. Also set in the calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4c50Contain the field content used for the placeholders of the message after the statement MESSAGE. Also set in the calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions). If a database lock is requested using an ENQUEUE function module, sym-sgv1 contains the name of the user holding the lock after the exception FOREIGN_LOCK.
sy-opsysc10Contains operating system of the current application server.
sy-pagnoi Contains current page when the list is created. Set by output statements.
sy-pfkeyc20Contains GUI status of the current dynpro.
sy-repidc40Contains name of the current ABAP program In procedures called externally, the name of the master program of the procedure. If sy-repid is passed to an external procedure as an actual parameter, the formal parameter is set to the name of the caller.
sy-saprlc4Contains ABAP release.
sy-scolsi Contains number of columns in the current screen layout. Set after the event PAI.
sy-slsetc14Contains variant used to fill a selection screen. The associated program name can be seen in sy-cprog.
sy-sponon10Contains the name of the spool number when spooling lists.
sy-srowsi Contains number of rows in the current screen layout. Set after the event PAI.
sy-stacoi Contains number of the first displayed column of the list in which a list event was raised. Counting begins at 1.
sy-staroi Contains number of the top displayed list line of the top displayed page of the list where a list event was raised. Counting begins at 1 and does not include the page header.
sy-stepli Contains index of the current row in a table control. This is set for every loop pass. Outside of a loop, for example after the event POV or POH for a table row, the content of sy-stepl is undefined.
sy-subrci Contains return code set by many ABAP statements. In general, the value 0 means that the statement was executed with no problems. Depending on which statement set sy-subrc, the cause of an error can be derived from this value. sy-subrc keeps its previous value or its content is undefined after statements where the setting of sy-subrc is not documented explicitly.
sy-sysidc8Contains name of AS ABAP.
sy-tabixi Contains row number in the table index of an internal table. Contains the last row accessed using a primary or secondary table index. Is set to 0 when accessed using a hash algorithm.
sy-tcodec20Contains name of the current transaction code. Initial in background processing, unless a transaction was called during background processing.
sy-tfilli sy-tfill is given the number of rows of the accessed internal table in the statements DESCRIBE TABLE, LOOP AT, and READ TABLE.
sy-timlot Contains user time.
sy-titlec70Contains text that appears in the title bar of the dynpro.
sy-tlengi sy-tleng is given the row size of the accessed internal table in the statements DESCRIBE TABLE, LOOP AT, and READ TABLE.
sy-tvar0, sy-tvar1, sy-tvar2, sy-tvar3, sy-tvar4, sy-tvar5, sy-tvar6, sy-tvar7, sy-tvar8, sy-tvar9c20Contains values can be assigned to these system fields in the program. In the event TOP-OF-PAGE, the content of sy-tvar0 through sy-tvar9 replaces the placeholders "&0" through "&9" in the list headers and column headers of the text elements of the program.
sy-tzonei Contains time difference of the system time to the UTC reference time in seconds.
sy-ucommc70Contains function code that raised the event PAI. This function code is usually has a unique association with a function. Only Enter can pass assorted function codes to sy-ucomm in accordance with the following hierarchy: Content of the command field in the system toolbar, then associated function code; the content is not affected.
sy-ulinec255Contains 255 "-" characters for displaying lines in lists. In the case of displaying sy-uline with the statement WRITE, the same applies as for the statement ULINE. In other words, every "-" character is replaced by a line element.
sy-unamec12Contains logon name of the user.
sy-uzeitt Contains system time.
sy-vlinec1Contains a vertical bar (|) for displays in lists.
sy-wtitlc1Set to "N" in the statements REPORT, PROGRAM, and FUNCTION-POOL, if the addition NO STANDARD PAGE HEADING is used; otherwise initial. The statement NEW-PAGE does not set sy-wtitl.
sy-zonloc6Contains user time zone.

Example -

Write a simple program to display some of the system variables.


Code -

*&---------------------------------------------------------------------*
*& Report  Z_SYSTEM_VARIABLE
*&---------------------------------------------------------------------*
*& Program Written by TUTORIALSCAMPUS
*&---------------------------------------------------------------------*

REPORT  Z_SYSTEM_VARIABLE.

* Displaying some of the system variables
WRITE:/'SY-ABCDE', SY-ABCDE,
      /'SY-DATUM', SY-DATUM,
      /'SY-DBSYS', SY-DBSYS,
      /'SY-LANGU', SY-LANGU,
      /'SY-MANDT', SY-MANDT,
      /'SY-OPSYS', SY-OPSYS,
      /'SY-SAPRL', SY-SAPRL,
      /'SY-TCODE', SY-TCODE.

Output -

system variables example output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear picture of example code.

SY-ABCDE displays the Latin alphabets. SY-DATUM displays the system date (i.e program run date). SY-DBSYS displays the system central database name. SY-LANGU displays the system language. SY-MANDT displays the current client ID used to logon. SY-OPSYS displays the operating system of the current application server. SY-SAPRL displays the running ABAP release. SY-TCODE displays the current running transaction code of ABAP editor.