Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Predefined Types, Data Objects, Functions, and Constructors →  Predefined Data Objects 

ABAP System Fields

System fields are filled by the ABAP runtime environment and can be used in an ABAP program to query system statuses. Except for one field (sy-repid), the system fields are variables, but nevertheless they should be used only for read access; otherwise, important information for the execution of subsequent programs may be lost. System fields in ABAP programs can be overwritten in rare cases only, to control system behavior.

With the exception of sy-repid, the data types of the system fields are defined in the structure SYST in ABAP Dictionary, and are instantiated in ABAP programs as components of the predefined structure sy. The structure sy exists only once in an internal session and is shared by all programs in this internal session.

The structure sy can also be addressed using syst. There is also a predefined data type sy, which can be used instead of the data type SYST of ABAP Dictionary.

The table below shows the system fields which can be used in ABAP programs. All other components of the structure sy are either intended only for internal use by the ABAP runtime environment or are obsolete.

Name Type Length Content
sy-abcde c 26 Contains the Latin alphabet. Can be used to access individual letters directly by specifying the offset/length, regardless of thecode page.
sy-batch c 1 "X" in an ABAP program running in the background; otherwise initial.
sy-binpt c 1 "X" when processingbatch input sessionsand in ABAP programs called by CALLTRANSACTION USING; otherwise initial. These defaults can be overridden using the addition OPTIONS FROM of the statement CALL TRANSACTION ... USING.
sy-calld c 1 A 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 thescreen. A call using SUBMIT (without AND RETURN) takes the value of the calling program.
sy-callr c 8 When spooling lists, contains a value that indicates where spooling was started, for example NEW-PAGE for program-driven spooling or RSDBRUNT for spooling from theselection screen.
sy-colno i - Current position when a list is created in the list buffer; set whenever an output statement is used. Counting begins at 1. In non-Unicode systems, thisposition also corresponds to the column in the displayed list. In Unicode systems this is only guaranteedfor the lower and upper output limits, since a single character may occupy more columns in the list than positions in the list buffer. See alsoLists - System Fields.
sy-cpage i - Page number of the top page in the list display where a list event was triggered. Counting begins at 1. See also Lists - System Fields.
sy-cprog c 40 In externally called procedures,the name of the calling program; otherwise the name of the current program. If an externally called procedure calls another external procedure, sy-cprog contains the name of themaster program, and is not set to the name of the master program of the subsequent calling program.
sy-cucol i - Horizontal cursor position on the screen of a dynpro. Counting begins at column 2. Set after the event PAI.
sy-curow i - Vertical cursor position on the screen of a dynpro. Counting begins at row 1. Set after the event PAI.
sy-datar c 1 "X" for PAI, if at least one input field of a screen was changed by a user or some other data being passed.
sy-datlo d - User date, such as "19990723". See System Fields for Date and Time.
sy-datum d - System date. See System Fields for Date and Time.
sy-dayst c 1 "X" in summer time in the system time zone; otherwise initial. See System Fields for Date and Time.
sy-dbcnt i - SQL statements set the content of sy-dbcnt to the number of table rows processed.
sy-dbnam c 20 For executable programs, the associated logical database.
sy-dbsys c 10 Central database system, for example "HDB" or "ADABAS". See also CL_DB_SYS.
sy-dyngr c 4 Screen group of the current dynpro. In Screen Painter, multiple dynpros can be assigned to the same screen group, which can be used, for example, to make modifications to all screens in the group at once.
sy-dynnr c 4 Number of the current dynpro. In selection screen processing, the current selection screen. In list processing, the number of the subscreen dynpro. When processing asubscreen dynpro (including intabstrips), the number of this dynpro.
sy-fdayw b - Factory calendar weekday in the system time zone; Monday = 1, ..., Friday = 5. See System Fields for Date and Time.
sy-fdpos i - Occurrence after certain operations on character-like or byte-like data objects (for example FIND orcomparisons).
sy-host c 32 Network name of the computer on which the currentapplication serveris instantiated, for example "KSAP0001" or "HS01234".
sy-index i - Loop index. In DO and WHILE loops, contains the number of previous loop passes, including the current pass.
sy-langu c 1 Single-character language key, for example "E", "D", "F", for the currenttext environment. Set by the logon language of the user or by the statement SET LOCALE.
sy-ldbpg c 40 In executable programs, the database program of the associated logical database.
sy-lilli i - List row on which a list event was triggered. Counting begins at 1 and includes thepage header. See also Lists - System Fields.
sy-linct i - Page length of the current list when the list is created. sy-linct is0 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. See alsoLists - System Fields.
sy-linno i - Current list row when the list is created. Counting begins at 1 and includes the page header. Set by output statements. See also Lists - System Fields.
sy-linsz i - Row width of the current list in the list buffer when the list is created. By default, the valueis set as follows: If sy-scols is greater than or equal to 84, sy-linszis equal to sy-scols; otherwise sy-linsz has the value 84. This can be overridden by the introductory program statement or by SUBMIT. See alsoLists - System Fields.
sy-lisel c 255 Content of the list row in the list buffer where the cursor was in the displayed list when a list event was triggered (limited to the first 255 characters). See alsoLists - System Fields.
sy-listi i - List level of the list in which a list event was triggered.
sy-loopc i - Number of currently displayed rows in a table control. Set after the event PAI.
sy-lsind i - List level of the list that is currently being created (basic list: 0, details lists: greater than0). For every interactive list event, sy-lsind is automatically increasedby 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. See alsoLists - System Fields.
sy-macol i - Number of columns on the left margin when spooling lists. Set by the statement SET MARGIN.
sy-mandt c 3 Client ID used by the current user to log on, for example "401" or "800".
sy-marow i - Number of rows on the top margin when spooling lists. Set by the statement SET MARGIN.
sy-modno i - 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 atransaction with /o in the command field of thestandard toolbar,this value is increased by 1. If previous sessions were deleted, only the free numbers are allocatedagain. Sessions opened with CALL FUNCTION ... STARTING NEW TASK start at 0 again.
sy-msgid c 20 After the statement MESSAGE, contains the message class. Also set inthe calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgno n 3 After the statement MESSAGE, contains the message number. Also set inthe calling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgty c 1 After the statement MESSAGE, contains the message type. Also set in thecalling program after MESSAGE ... RAISING, if it handles the exception (the same applies to RFC exceptions).
sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4 c 50 After the statement MESSAGE, contain the field content used for the placeholders of themessage. Also set in the callingprogram after MESSAGE ... RAISING, if it handles the exception (the sameapplies 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-opsys c 10 Operating system of the current application server, for example "SOLARIS" or "HP-UX".
sy-pagno i - Current page when the list is created. Set by output statements. See also Lists - System Fields.
sy-pfkey c 20 GUI status of the current dynpro. Set after the event PAI.
sy-repid c 40 Name of the current ABAP program In procedures called externally, the name of themaster program of theprocedure. If sy-repidis passed to an external procedure as an actual parameter, then the formal parameter is set to the name of the caller.
sy-saprl c 4 AS ABAP release, for example "702" or "740".
sy-scols i - Number of columns in the current screen layout. Set after the event PAI.
sy-slset c 14 Variant used to fill a selection screen. The associated program name can be seen in sy-cprog.
sy-spono n 10 Contains the name of the spool number when spooling lists.
sy-srows i - Number of rows in the current screen layout. Set after the event PAI.
sy-staco i - Number of the first displayed column of the list in which a list event was triggered. Counting begins at 1. See also Lists - System Fields.
sy-staro i - Number of the top displayed list row of the top displayed page of the list where a list event was triggered. Counting begins at 1 and does not include thepage header. See also Lists - System Fields.
sy-stepl i - 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-subrc i - Return code set by many ABAP statements. In general, the value 0 means that the statement was executedwith no problems. Depending on which statement set sy-subrc, the cause ofan error can be derived from this value. sy-subrc keeps its previous valueor its content is undefined after statements where sy-subrc's setting is not documented explicitly.
sy-sysid c 8 Name of AS ABAP, for example "S01" or "K99".
sy-tabix i - Row number in the table index of an internal table. Contains the last row accessed using aprimary orsecondary table index. Is set to 0 when accessed using ahash algorithm.
sy-tcode c 20 Name of the current transaction code. Initial inbackground processing, unless a transaction was called during background processing.
sy-tfill i - In the statements DESCRIBE TABLE, LOOP AT,and READ TABLE, sy-tfill is given the number of rows of the accessed internal table.
sy-timlo t - User time, such as "152557". See System Fields for Date and Time.
sy-title c 70 Text that appears in the title bar of the dynpro.
sy-tleng i - In the statements DESCRIBE TABLE, LOOP AT,and READ TABLE, sy-tleng is given the row size of the accessed internal table.
sy-tvar0, sy-tvar1, sy-tvar2,sy-tvar3, sy-tvar4, sy-tvar5,sy-tvar6, sy-tvar7, sy-tvar8, sy-tvar9 c 20 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 replacesthe placeholders "&0" through "&9" in the list headers and column headers of the text elements of the program.
sy-tzone i - Time difference of the system time to theUTC reference time in seconds, for example "3600" or "10800". SeeSystem Fields for Date and Time.
sy-ucomm c 70 Function code that triggered the event PAI. This function code is usually has a unique association with a function. Only Entercan pass assorted function codes to sy-ucomm in accordance with the followinghierarchy: Content of the command field in the system toolbar, then associated function code; the content is not affected.
sy-uline c 255 Contains 255 "-" characters for displaying lines in lists. In the case of displaying sy-ulinewith the statement WRITE, the sameapplies as for the statement ULINE. In other words, every "-" character is replaced by aline element.
sy-uname c 12 Logon name of the user, for example "KELLERH". See also User-Specific Program Flow.
sy-uzeit t - System time. See System Fields for Date and Time.
sy-vline c 1 Contains a vertical line (
sy-wtitl c 1 Set to "N" in the statements REPORT, PROGRAM, and FUNCTION-POOL, if the addition NOSTANDARD PAGE HEADING is used; otherwise initial. The statement NEW-PAGE does not set sy-wtitl.
sy-zonlo c 6 User time zone, for example "CET" or "PST". SeeSystem Fields for Date and Time.

The system field sy-repid is no longer a part of the structures syst or sy. Instead, each program contains the predefined constants sy-repid and syst-repid, which both contain the name of the relevant program. There are also two predefined types with the same names, sy-repid and syst-repid, of type c and length 40.

Other versions: 7.31 | 7.40 | 7.54

Programming Guidelines


Notes

  • The content of system fields is defined only as stated in the table above, or as described in individual ABAP statements. In any other contexts, the content of system fields is not reliable. In particular those statements whose effect on system fields is undocumented can influence the content of certain system fields in undefined ways, for example sy-subrc. This applies especially to statements that call ABAP code implicitly or explicitly when executed.

  • If possible, a system field should be evaluated directly after the statement that set it, to prevent it from being overwritten by other statements. If necessary, the values of system fields should be saved in auxiliary variables.

  • A system field should only be used as an operand in a reader position if its content is not set by the same statement. Otherwise, the system may behave unexpectedly.

  • System fields and the associated structure SYST have an entirely program-internal function. No dynpro fields should be created with reference to system fields, since the associated field helps are not intended for end users.

  • Although it is not forbidden, it is recommended that user-defined data objects or types in a program that are named sy or syst are not used, since they can obscure predefined data objects and types.

  • Internal system fields are intended entirely for internal use in the ABAP runtime environment and in the ABAP kernel. Never overwrite them from within an ABAP program and do not even process them in read-only mode.

  • Most of the obsolete system fields were kept during the transition from R/2 to R/3 and are no longer filled. These system fields can no longer be used.

  • The static methods of the system class CL_ABAP_SYST also provide important system states. The use of these methods can replace the evaluation of the associated system fields in cases where it is important that a system field has not been incorrectly overwritten in the program. In the case of sy-dbsys, it is recommended that the class CL_DB_SYS is used.

Continue

Internal System Fields