1. 程式人生 > 其它 >ABAP程式系統欄位中英文詳解

ABAP程式系統欄位中英文詳解

SY-SUBRC: 系統執行某指令後,表示執行成功與否的變數,’0’ 表示成功
SY-DBLNT: 被處理過的記錄的筆數 
SY-UNAME: 當前使用者登入SAP的USERNAME;
SY-DATUM: 當前系統日期;
SY-UZEIT: 當前系統時間;
SY-TCODE: 當前執行程式的Transaction code
SY-INDEX : 當前LOOP迴圈過的次數
SY-TABIX: 當前處理的是internal table 的第幾筆
SY-TMAXL: Internal table的總筆數
SY-SROWS: 螢幕總行數;
SY-SCOLS: 螢幕總列數;
SY-MANDT: 當前系統編號(CLIENT NUMBER)
SY-VLINE: 畫豎線
SY-ULINE: 畫橫線
SY-PAGNO: 當前頁號
SY-LINSZ: 當前報表寬度
SY-LINCT: 當前報表長度
SPACE: 空字串
SY-LSIND: 列表索引頁
SY-LISTI: 上一個列表的索引
SY-LILLI: 絕對列表中選定行的行號
SY-CUROW: 螢幕上的行
SY-CUCOL: 游標列
SY-CPAGE: 列表的當前顯示頁
SY-STARO:真實行號
SY-LISEL: 選擇行的內容,長度為255
SY-LINNO: 當前行

系統內部有一個專門存放系統變數的結構SYST,其中最常用的系統變數有:
SY-SUBRC: 系統執行某指令後,表示執行成功與否的變數,’0’ 表示成功
SY-UNAME: 當前使用者登入SAP的USERNAME;
SY-DATUM: 當前系統日期;
SY-UZEIT: 當前系統時間;
SY-TCODE: 當前執行程式的Transaction code
SY-REPID: ABAP 程式名,目前的主程式
SY-CPROG: ABAP 程式名
SY-SYSID: R/3 系統,R/3 系統名稱
SY-UCOMM:  畫面,PAI 驅動的功能程式碼,一般用來參照定義變數
SY-INDEX : 當前LOOP迴圈過的次數   READ TABLE it_po INDEX 1  此時變數值1
SY-TABIX: 當前處理的是internal table 的第幾筆
下面說下sy-index 和 sy-tabix的區別

sy-index和sy-tabix都是系統欄位,用來記錄迴圈的次數。

sy-index 在DO....ENDDO迴圈裡有效,而sy-tabix在loop at ......endloop裡有效。

執行下面的例子能更好的理解:
DATA: BEGIN OF line,
    col1 TYPE i,
    col2 TYPE i,
    END OF line.
DATA itab LIKE TABLE OF line WITH HEADER LINE.
DO 30 TIMES.
  line-col1 = sy-index.
  line-col2 = sy-index * sy-index.
  APPEND line TO itab.
ENDDO.
LOOP AT itab .
  DO 2 TIMES.
    WRITE: / 'sy-tabix:',sy-tabix,itab-col1,
     'sy-index:',sy-index,itab-col2.
  ENDDO.
ENDLOOP.
sy-dbcnt:Sy-dbcnt代表有多少條記錄被處理了
例如:當我們查詢記錄放入內表,判斷內表中是否有資料就可以用 if sy-dbcnt = 0  MESSAGE s000.
      STOP. ENDIF.
sy-tfill:返回當前內表(Internal Table)內的記錄數。
但是要小心,那些欄位隨各自的內表(Internal Table)改變。例:如果你迴圈(Loop at)(讀取)itab,sy-tfill返回itab的記錄數。
如 果你在迴圈(Loop at)(讀取)內表(Internal Table)itab的內部巢狀迴圈(Loop at)(讀取)內表(Internal Table)jtab,sy-tfill返回的不再是itab的記錄數,而是jtab的!所以如果你需要使用itab的記錄數,請先把sy-tfill的 值傳遞給其它變數。
無論如何,sy-tfill永遠儲存當前的記錄數。
例如記錄內表記錄條數:DESCRIBE TABLE itab LINES sy-tfill.
SY-TMAXL: Internal table的總筆數
SY-SROWS: 螢幕總行數;
SY-SCOLS: 螢幕總列數;
SY-MANDT: 當前系統編號(CLIENT NUMBER)
SY-VLINE: 畫豎線
SY-ULINE: 畫橫線

sy-pagno   當前頁號
sy-lsind      列表索引頁
sy-listi        上一個列表的索引
sy-linsz      當前報表寬度
sy-lilli          絕對列表中選定的行號
sy-linct       當前報表長度
sy-curow    螢幕上的行
space         空字元
sy-cucol     游標列
sy-cpage    列表的當前顯示頁
sy-staro     真實行號
sy-lisel       選擇行的內容,長度為255
sy-linno      當前行

SY-MANDT: 當前系統編號(CLIENT NUMBER)
SY-SLSET:  

 SY-SUBRC 的含義

================= FUNCTION MODULE (或RFC中) SY-SUBRC 的含義 ================ 
使用SELECT語句選擇查詢: 
SY-SUBRC = 0: 至少有一行資料,當ENDSELECT語句執行完,SY-DBCNT中儲存著記錄的個數。 
SY-SUBRC = 4: 沒有資料。 
SY-SUBRC = 8: 只有使用“SELECT SINGLE FOR UPDATE”時才會有, 
              表示: WHERE條件指定的記錄不止一行,結果是沒有記錄被選中。 
  
使用INSERT語句,向表中插入一行,必須注意INSERT的順序與表中欄位的順序一致: 
SY-SUBRC = 0: 插入成功,SY-DBCNT包含了插入的行數,0或1。 
SY-SUBRC = 4: 由於有相同的KEY存在,所以插入失敗。 
  
使用LOOP語句來遍歷一個內表: 
SY-SUBRC = 0: 迴圈至少被執行一次。 
SY-SUBRC = 4: 迴圈沒有被執行,可能是沒有資料,也可能是沒有符合條件的記錄。 
  
使用DELETE語句來刪除一條記錄: 
SY-SUBRC = 0: 找到一行並刪除之,如果該表有不唯一主鍵,也就是有多條重複的記錄,則只刪除第一條記錄。 
SY-SUBRC = 4: 沒有找到符合條件的記錄,也沒有刪除。 
  
使用UPDATE語句來更新一條記錄: 
SY-SUBRC = 0: 找到記錄並更新,(如果有多條記錄呢?) 
SY-SUBRC = 4: 沒有找到符合條件的記錄,也沒有更新。 
 

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 usingLEAVE 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 in tabstrips), 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 thepage 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 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.

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 theframework 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.

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 ifhashed 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 cand 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.