System fields are filled by the ABAP runtime environment and can be used in an ABAP program to query system statuses. With one exception (sy-repid), system fields are variables, but they should only be accessed on a read-only basis. Otherwise, important information for further program execution often gets lost. System fields in ABAP programs can only be overwritten in a few cases to control system behavior.
With the exception of sy-repid, the data types of the system fields are defined in the ABAP Dictionary in the structure SYST (as of release 6.10), and are instantiated in ABAP programs as components of the predefined structure sy, which can also be addressed using SYST. The structure sy exists only once in an internal session and is used by all programs of an internal session at the same time. The following table shows the system fields that can be used in ABAP programs. All other components of the structure sy are either intended for internal use by the ABAP runtime environment or are obsolete.
名称
类型
说明
sy-abcde
c(26)
包含了字母表。可以用来通过指定偏移/长度直接访问独立的字母,而无需考虑代码页。
Contains the alphabet. Can be used to access individual letters directly by specifying the offset/length, regardless of the code page.
sy-batch
c(1)
在一个后台运行的ABAP程序中设置为“X”,否则就是初始值。
Set to "X" in an ABAP program that runs in the background, otherwise initial.
Set to "X" during processing of batch input sessions, and in ABAP programs called using CALL TRANSACTION USING. Otherwise initial.
sy-calld
c(1)
在一个调用序列中的第一个程序里为空字符串,否则为值“X”。在调用using CALL TRANSACTION,CALL Dialog或者SUBMIT ... AND RETURN后变为“X”。如果程序以LEAVE TO TRANSACTION或者从一个屏幕事务开始的话,则为空。使用SUBMIT(没有AND RETURN)时设定为调用它的程序的值。
Contains a blank character in the first program in a call sequence , otherwise contains the value "X". Is 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 a transaction from the screen. A call using SUBMIT(without AND RETURN) assumes the value of the calling program.
sy-callr
c(8)
当打印清单时,显示打印从何处开始的值,例如NEW-PAGE为程序控制的打印,或者RSDBRUNT为从一个选择屏幕打印。When printing lists, contains a value that displays where the printing was started, for example, NEW-PAGE for program-controlled printing, or RSDBRUNT for printing from the selection screen.
Current position during creation of a list in the list buffer. Counting begins at 1. In non-Unicode systems, this position also corresponds to the column in the displayed list. In Unicode systems, this is only guaranteed for the lower and upper output limits applicable to each output, as one character may take up more columns in the list than positions in the list buffer.
sy-cpage
i
当清单事件被触发时,显示在清单顶端的页码。从1开始。
Page number of the page displayed at the top of the list for which a list event was triggered. Counting begins at 1.
In procedures called externally, the name of the calling program, Otherwise the name of the current program. If a procedure called externally calls another external procedure, sy-cprog contains the name of the framework program, and is not set to the name of the framework program of the subsequent calling program.
sy-cucol
i
在屏幕上显示的横向指针的位置。从第2列开始。
Horizontal cursor position in the display on a screen. Counting begins at column 2.
sy-curow
i
在屏幕上显示的纵向指针的位置。从第1行开始。
Vertical cursor position on the screen display of a screen. Counting begins at line 1.
sy-datar
c(1)
在PAI中,如果屏幕上至少有一个输入字段的值被用户或其他数据传输所更改,则为“X”,否则为初始值。
At PAI, contains "X" if at least one input field of a screen has been changed by a user or by further data transfer, otherwise initial.
sy-datlo
d
用户的当前日期,例如:19990723,20000422。可以用GET TIME来设置。
Local date of the user, for example 19990723, 20000422. Can be set using GET TIME.
sy-datum
d
SAP系统的本地日期。可以用GET TIME来设置。
Local date of the SAP system. Can be set using GET TIME.
sy-dayst
c(1)
在夏令时中设置为“X”,否则为初始值。
"X" during summertime, otherwise initial.
sy-dbcnt
i
SQL语句把sy-dbcnt的内容设置为处理过的表行数。
SQL statements set the content of sy-dbcnt to the number of processed table lines.
Screen group of the current screen. In the Screen Painter, several screens can be assigned to a common screen group, which can be used, for example, for making modifications to all screens in the group at once.
Number of the current screen. During selection screen processing, this is the current selection screen. During list processing, the number of the subscreen container. During processing of a subscreen screen (including in tabstrips), this screen number.
Single-character language key, for example, D, E, F, for the current text environment. Set according to the logon language of the user or by using the statementSET LOCALE.
sy-ldbpg
c(40)
在可执行程序中,指定了连接的逻辑数据库的数据库程序。
In executable programs, the database program of the linked logical database.
sy-lilli
i
当清单事件被触发时的清单行数,从1开始计算并包含页抬头。
List line for which a list event was triggered. Counting begins at 1 and includes the page header.
Page length of the current list during list creation. sy-linct is 0 for a standard list of any length, and has a value that is not 0 for lists with a defined page length.
sy-linno
i
当清单建立时的当前清单行。从1开始并包含了页抬头。
Current list line during list creation. Counting begins at 1 and includes the page header.
sy-linsz
i
当清单建立时,在清单缓冲区中的行长度。
Line width of the current list in the list buffer during list creation.
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 only be changed in ABAP programs for navigating between details lists.
sy-macol
i
当打印清单时,包含了左边距的列数。
When printing lists, contains the number of columns on the left edge.
sy-mandt
c(3)
当前用户登录的客户端号,例如:401,800。
client identifier with which the user has logged on, for example, 401, 800.
sy-marow
i
在打印清单时,包含了顶端空白的行数。
When printing lists, contains the number of lines on the top margin.
Indexing of external 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 input field of the toolbar, this value is increased by 1.
sy-msgid
c(20)
在MESSAGE语句后,包含了消息类。
After the statement MESSAGE, contains the message class.
sy-msgno
n(3)
在MESSAGE语句后,包含了消息号。
After the statement MESSAGE, contains the message number.
sy-msgty
c(1)
在MESSAGE语句后,包含了消息类型。
After the statement MESSAGE, contains the message type.
sy-msgv1 ... sy-msgv4
c(50)
在MESSAGE语句后,包含了要替换掉消息中参数字段的内容。
After the statement MESSAGE, contain the contents of the fields that are used as placeholders in the message.
sy-opsys
c(10)
应用服务器的操作系统,例如,SOLARIS,HP-UX。
Operating system of the application server, for example, SOLARIS, HP-UX.
sy-pagno
i
在清单创建时的当前页。
Current page in list creation.
sy-pfkey
c(20)
当前屏幕的GUI状态。
GUI status of the current screen.
sy-prdsn
c(6)
当打印清单时,包含了脱机文件的名字。
When printing lists, contains the name of the spool file.
Name of the current ABAP program. For procedures called externally, name of the framework program of the procedure. sy-repid when transferring actual parameters to an external procedure, before release 6.10, the formal parameter was not set to the name of the caller, but to the name of the procedure instead. As of release 6.10, sy-repid can be transferred to procedures without help fields.
sy-saprl
c(4)
SAP系统的发行版本,例如46D,610。
Release status of the SAP system, for example, 46D, 610.
sy-scols
i
当前屏幕的列数。
Number of columns of the current screen.
sy-slset
c(14)
用来填充一个选择屏幕的变量。
Variant that was used for filling a selection screen.
sy-spono
n(10)
当打印清单时,包含了缓冲池的数量。
When printing lists, contains the name of the spool number.
sy-srows
i
当前屏幕的行数。
Number of lines of the current screen.
sy-staco
i
当清单事件被触发时,清单显示的第一列的数量,从1开始。
Number of the first column displayed in the list for which a list event has been triggered. Counting begins at 1.
sy-staro
i
当清单事件被触发时,在清单页顶端显示的页顶端的列表行数。从1开始计数并且不包括在页抬头中。
Number of the list line displayed at the top of the page at the top of the list, for which a list event was triggered. Counting begins at 1 and does not include thepage header.
sy-stepl
i
在表控制中当前行的索引。在每个循环过程中设置。
Index of the current line in a table control. This is set for every loop pass.
Return value that is set by many ABAP statements. In general, the value 0 means that the statement was executed with no problems. Depending on which statement was used to set sy-subrc, if errors occur, the cause of the error can be derived from the corresponding value.
sy-sysid
c(8)
SAP系统的名字,例如,S01,K99。
Name of the SAP system, for example, S01, K99.
sy-tabix
i
表索引。标准表或者排序表的最后被定位的行(表循环中当前所在行)。如果访问哈希表,则设置为0。
Table index. Last addressed line of a standard table or sorted table. Is set to 0 if hashed table is accessed.
These system fields can be assigned values in the program. At the event TOP-OF-PAGE, the content of sy-tvar0 to sy-tvar0 replaces the placeholders in the list and column headers of the text elements of the program.
sy-tzone
i
与UTC参考事件的事件差异,以秒为单位,例如,3600,10800。
Time difference to the UTC reference time in seconds, for example, 3600, 10800.
sy-ucomm
c(70)
触发事件PAI的功能码。
Function code that triggered the event PAI.
sy-uline
c(255)
在清单中显示的包含最多255个字符的横线。
Contains a horizontal line of length 255 for displaying in lists.
sy-uname
c(12)
用户的登录名,例如,KELLERH。
User's logon name, for example, KELLERH.
sy-uzeit
t
SAP系统的本地时间,可以用GET TIME来设置。
Local time of the SAP system. Can be set using GET TIME.
sy-vline
c(1)
在清单中显示的一个竖线(|)。
Contains a vertical line (|) for displaying in lists.
sy-wtitl
c(1)
在REPORT,PROGRAM和FUNCTION-POOL语句中,如果使用了NO STANDARD PAGE HEADING附加属性,则设置为“N”,否则用初始值。
In the statements REPORT, PROGRAM, and FUNCTION-POOL, set to "N" if the addition NO STANDARD PAGE HEADING is used, otherwise initial.
sy-zonlo
c(6)
用户时区,例如CET,PST。
Time zone of the user, for example, CET, PST.
系统字段的数据类型和长度都在第二列描述,格式为类型(长度)。
The data type and length of the system fields are specified in the second column in the notation type(length).
在6.10版之后,sy-repid系统字段不再是SYST或者sy结构的一部分了。作为替代,每个程序都包含了预定义常数sy-repid和syst-repid,都包含了相关程序的名字。这也是两个预定义类型——sy-repid和syst-repid——的名字,都是长度为40的字符。
As of release 6.10, 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.
注意Notes:
如果可能的话,一个系统字段应该在设置它的语句后立即使用,以避免其他语句修改它的值。如果必要的话,把系统字段的值存储在一个辅助的变量中。
If possible, a system field should be evaluated directly following the statement that set it, so that it is not overwritten by other statements. If necessary, store the values of system fields in auxiliary variables.
如果语句不设置一个系统字段的值,则它只能作为一个读取位置的操作数来使用。否则,系统将出现异常表现。
A system field should only be used as an operand at a read position if its content is not set by the same statement. Otherwise, the system may behave unexpectedly.
System fields are filled by the ABAP runtime environment and can be used in an ABAP program to query system statuses. With one exception (sy-repid), system fields are variables, but they should only be accessed on a read-only basis. Otherwise, important information for further program execution often gets lost. System fields in ABAP programs can only be overwritten in a few cases to control system behavior.
对于例外的sy-repid,这个系统字段的数据类型在ABAP字典的SYST结构(6.10版以后)中定义,作为sy结构(也可以用SYST来定位)的组件在ABAP程序中有示例。sy结构在一个内部会话期间内只存在一次,并且在这个内部会话期间内被所有程序使用。下表列出了在ABAP程序中可以使用的系统字段。所有sy结构的其他组件则或者在ABAP运行时环境内部使用或者已经废弃。
With the exception of sy-repid, the data types of the system fields are defined in the ABAP Dictionary in the structure SYST (as of release 6.10), and are instantiated in ABAP programs as components of the predefined structure sy, which can also be addressed using SYST. The structure sy exists only once in an internal session and is used by all programs of an internal session at the same time. The following table shows the system fields that can be used in ABAP programs. All other components of the structure sy are either intended for internal use by the ABAP runtime environment or are obsolete.
系统字段的数据类型和长度都在第二列描述,格式为类型(长度)。
The data type and length of the system fields are specified in the second column in the notation type(length).
在6.10版之后,sy-repid系统字段不再是SYST或者sy结构的一部分了。作为替代,每个程序都包含了预定义常数sy-repid和syst-repid,都包含了相关程序的名字。这也是两个预定义类型——sy-repid和syst-repid——的名字,都是长度为40的字符。
As of release 6.10, 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.
注意Notes:
If possible, a system field should be evaluated directly following the statement that set it, so that it is not overwritten by other statements. If necessary, store the values of system fields in auxiliary variables.
A system field should only be used as an operand at a read position if its content is not set by the same statement. Otherwise, the system may behave unexpectedly.