SAP系统变量⽤法----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.
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 , 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 .
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 , 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 , this is the current selection screen. During list processing, the number of the
subscreen container. During processing of a (including in ), this screen number.
⼯⼚⽇历的周⽇,Monday 为1,…,Friday 为5。
Factory calendar weekday, Monday = 1, ..., Friday = 5.
在字符类型数据对象操作时查定位。
Found location in operations with character-type data objects.
应⽤服务器的名字,例如,KSAP0001,HS01234。
Name of the , for example, KSAP0001, HS01234.
循环索引。在DO 和WHILE 循环中,指包含了本次循环的循环次数。
Loop index. In DO and WHILE loops, contains the number of the loop passes including the current pass.
单字符的语⾔键,例如,D ,E ,F ,给当前的⽂本环境使⽤。通过依照当前⽤户的登录语⾔,或使⽤SET LOCALE 语句设定。Single-character language key, for example, D, E, F, for the current . Set according to the logon language of the user or
by using the statement SET LOCALE.
在可执⾏程序中,指定了连接的逻辑数据库的数据库程序。
In executable programs, the of the linked logical database.
当清单事件被触发时的清单⾏数,从1开始计算并包含页抬头。
List line for which a list event was triggered. Counting begins at 1 and includes the .
在当前清单创建时的页长。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.
当清单建⽴时的当前清单⾏。从1开始并包含了页抬头。
Current list line during list creation. Counting begins at 1 and includes the page header.
当清单建⽴时,在清单缓冲区中的⾏长度。
Line width of the current list in the list buffer during list creation.
当⼀个清单事件被触发时,光标所在⾏在清单缓冲区中的⾏内容。(限制为最前⾯的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).
当清单事件被触发时,清单等级。
List level of the list for which a list event was triggered.
在⼀个表控制中当前显⽰的⾏号。
Number of lines currently displayed in a .
正在被创建清单的清单级别(基本清单: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.
当打印清单时,包含了左边距的列数。
When printing lists, contains the number of columns on the left edge.
当前⽤户登录的客户端号,例如:401,800。
with which the user has logged on, for example, 401, 800.
在打印清单时,包含了顶端空⽩的⾏数。
When printing lists, contains the number of lines on the top margin.
外部会话的索引。在第⼀个会话中设置为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 with /o in the input field of the toolbar, this value is increased by 1.exists的用法
在MESSAGE语句后,包含了消息类。
After the statement MESSAGE, contains the message class.
在MESSAGE语句后,包含了消息号。
After the statement MESSAGE, contains the message number.
在MESSAGE语句后,包含了消息类型。
After the statement MESSAGE, contains the message type.
在MESSAGE语句后,包含了要替换掉消息中参数字段的内容。
After the statement MESSAGE, contain the contents of the fields that are used as placeholders in the .
应⽤服务器的操作系统,例如,SOLARIS,HP-UX。
Operating system of the , for example, SOLARIS, HP-UX.
在清单创建时的当前页。
Current page in list creation.
当前屏幕的GUI状态。
GUI status of the current .
当打印清单时,包含了脱机⽂件的名字。
When printing lists, contains the name of the spool file.
当前ABAP程序的名字。对外部调⽤的程序,是指程序的框架程序的名字。在6.10版以前,当sy-repid向⼀个外部程序传递实际参数时,形式参数没有被设置为调⽤者的名字,⽽是程序的名字。在6.10版之后,sy-repid可以被传递给程序⽽⽆需参考字段。
Name of the current ABAP program. For procedures called externally, name of the of the . 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.
SAP系统的发⾏版本,例如46D,610。
Release status of the SAP system, for example, 46D, 610.
当前屏幕的列数。
Number of columns of the current .
⽤来填充⼀个选择屏幕的变量。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。