ABAP程序系统字段中英文详解
系統字段由ABAP運行時環境填寫,并且可以用來在ABAP程序中查詢系統狀態。除了一個例外(sy-repid),系統字段都是變量,但是它們都是只讀的。此外,更多程序執行的重要信息通常都被丟棄。ABAP程序中的系統字段只在極少需要控制系統行為的時候才能被重寫。
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.
?
| 名稱 Name | 類型 Type | 說明 Content |
| 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. |
| sy-binpt | c(1) | 在批處理輸入會話中設置為“X”,在ABAP程序中調用using?CALL TRANSACTION USING。否則就是初始值。 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. |
| sy-colno | i | 在清單緩沖區中創建清單過程中的當前位置。從1開始計算。在非Unicode系統中,這個位置也符合顯示清單中的列。在Unicode系統中,由于清單緩沖區中的一個字符可能占多列,這只保證每個輸出的最低和最高的輸出能力。 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. |
| sy-cprog | c(40) | 在外部程序調用中,調用程序的名字,否則就是當前程序的名字。如果一個程序包含多級程序調用,sy-cprog包含框架程序的名字,而不是設置為程序調用序列中的框架程序名字。 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. |
| sy-dbnam | c(20) | 在執行程序中,表示連接的邏輯數據庫。 In executable programs, the linked?logical database. |
| sy-dbsys | c(10) | 使用的數據庫系統,例如ORACEL, INFORMIX。 Central database system, for example, ORACLE, INFORMIX. |
| sy-dyngr | c(4) | 當前屏幕的屏幕組。在屏幕畫筆中,幾個屏幕可以指定給一個公共屏幕組,例如,可以用來一次修改同一個屏幕組中的全部屏幕。 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. |
| sy-dynnr | c(4) | 當前的屏幕號。在選擇屏幕處理過程中,這指定了當前被選中的屏幕。在列表處理過程中,說明了子屏幕容器的數量。在子屏幕屏幕過程中(包括選項卡),說明了屏幕數量。 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 intabstrips), this screen number. |
| sy-fdayw | b | 工廠日歷的周日,Monday為1,…,Friday為5。 Factory calendar weekday, Monday = 1, ..., Friday = 5. |
| sy-fdpos | i | 在字符類型數據對象操作時查找定位。 Found location in operations with character-type data objects. |
| sy-host | c(8) | 應用服務器的名字,例如,KSAP0001,HS01234。 Name of the?application server, for example, KSAP0001, HS01234. |
| sy-index | i | 循環索引。在DO和WHILE循環中,指包含了本次循環的循環次數。 Loop index. In?DO?and?WHILE?loops, contains the number of the loop passes including the current pass. |
| sy-langu | c(1) | 單字符的語言鍵,例如,D,E,F,給當前的文本環境使用。通過依照當前用戶的登錄語言,或使用SET LOCALE語句設定。 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 statement?SET 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. |
| sy-linct | i | 在當前清單創建時的頁長。sy-linct在一個任意長度的標準清單中的值為0,而在定義了頁長的清單中不為0。 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. |
| sy-lisel | c(255) | 當一個清單事件被觸發時,光標所在行在清單緩沖區中的行內容。(限制為最前面的255行(疑誤,應為字符))。 Content of the list line in the list buffer, on which the cursor was positioned while a list event was triggered (restricted to the first 255 lines). |
| sy-listi | i | 當清單事件被觸發時,清單等級。 List level of the list for which a list event was triggered. |
| sy-loopc | i | 在一個表控制中當前顯示的行號。 Number of lines currently displayed in a?table control. |
| sy-lsind | i | 正在被創建清單的清單級別(基本清單:0,明細清單:大于0)。對每個交互式清單事件,sy-lsind自動以1遞增。sy-lsind只能在ABAP程序中在清單列表的導航中更改。 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. |
| sy-modno | c(1) | 外部會話的索引。在第一個會話中設置為0。在使用Create Session函數創建或由在工具欄輸入字段中帶/o參數的事務調用新事務時,這個值以1遞增。 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 a?transaction?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. |
| sy-repid | c(40) | 當前ABAP程序的名字。對外部調用的程序,是指程序的框架程序的名字。在6.10版以前,當sy-repid向一個外部程序傳遞實際參數時,形式參數沒有被設置為調用者的名字,而是程序的名字。在6.10版之后,sy-repid可以被傳遞給程序而無需參考字段。 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 the?page header. |
| sy-stepl | i | 在表控制中當前行的索引。在每個循環過程中設置。 Index of the current line in a table control. This is set for every loop pass. |
| sy-subrc | i | 返回被ABAP語句設置的值。通常,0表示程序執行沒有錯誤。當發生錯誤時,根據語句的使用方法來設置sy-subrc,可以從不同的值來判斷發生的錯誤。 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. |
| sy-tcode | c(20) | 當前事務碼的名稱。 Name of the current transaction code. |
| sy-tfill | i | 在DESCRIBE TABLE,LOOP AT和READ TABLE語句中,sy-tfill設置為被定位的那表的行數。 In the statements?DESCRIBE TABLE,?LOOP AT, and?READ TABLE,?sy-tfill?is filled with the number of lines in the internal table that has been addressed. |
| sy-timlo | t | 用戶的本地時間,例如152557。可以用GET TIME來設置。 Local time of the user, for example 152557. Can be set by?GET TIME. |
| sy-title | c(70) | 當前屏幕標題欄顯示的文字。 Text that appears in the title bar of the screen. |
| sy-tleng | i | 在DESCRIBE TABLE,LOOP AT和READ TABLE語句中,sy-tleng設置為被定位的那表的行大小。 In the statements?DESCRIBE TABLE,?LOOP AT, and?READ TABLE,?sy-tleng?is filled with the line size of the internal table that is being addressed. |
| sy-tvar0 ... sy-tvar9 | c(20) | 程序中可以指定值的系統字段。在事件TOP-OF-PAGE中,sy-tvar0到sy-tvar9替換程序里清單和列標題中占位符的文本。 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.
總結
以上是生活随笔為你收集整理的ABAP程序系统字段中英文详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MRP清单的动态和静态ABAP的取法
- 下一篇: 使用SLIN事务码进行ABAP程序扩展语