SAP ABAP常用系统变量 (SY-)及SY-SUBRC

SAP ABAP常用系统变量 (SY-)及SY-SUBRC

abap系统变量在syst结构里面可以找到

 

SY-SUBRC: 系统执行某指令后,表示执行成功与否的变量,0表示成功

SY-DBLNT: 被处理过的记录的笔数

SY-UNAME: 当前使用者登入SAP的USERNAME

SY-DATUM: 当前系统日期

SY-UZEIT: 当前系统时间

SY-TCODE: 当前执行程序的Transaction code

SY-REPID: 当前程序名称

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: 当前行

SY-SUBRC:语句执行后的返回值,0表示成功

SY-DATUM:当前服务器日期

SY-UZEIT:当前服务器时间

SY-ULINE:255长度的水平线

SY-VLINE:垂直线

SY-INDEX:循环说执行的次数

SY-TABIX:内表循环的次数

SY-DYNNR:当前Screen号

SY-MANDT:当前登录的Client号

SY-STEPL:返回当前操作的屏幕行号(Table Control)

SY-LOOPC:当前表格控件在屏幕中的总行数(Table Control)

SY-UCOMM:PAI所出发的功能代码

SY-DYNNR:当前屏幕号

SY-MSGID:Message Class

SY-MSGNR:Message Number

SY-MSGTY:Message Type

SY-MSGV1~4:Message Variant

SY-LINCT:REPROT语句中设定的LINE-COUNT

SY-LINSZ:REPROT语句中设定的LINE-SIZE

SY-SROWS:当前窗口的列表行数

SY-SCOLS:当前窗口的列表栏目数

SY-PAGNO:当前页的页码

SY-LINNO:当前选定行的行号

SY-COLNO:当前选定列的列号

SY-LSIND:当前列表索引,第一级列表为1

SY-LILLI:选择某行时光标行位置

SY-CUROW:选择某行时光标列位置

SY-ABCDE 常量,A-Z字母表

SY-BATCH 后台的程序运行

SY-COLNO:当前选定列的列号

SY-CPAGE 列表的当前显示页

SY-CUCOL 屏幕,PAI 的水平光标位置

SY-CUROW:选择某行时光标列位置

sy-datar:在PAI中,如果屏幕上至少有一个输入字段的值被用户或其他数据传输所更改,则为“X”,否则为初始值。

sy-datlo:用户的当前日期

SY-DATUM 服务器日期

SY-DYNNR 当前屏幕的编号

SY-INDEX 循环的次数(DO While)

SY-LANGU 当前登录语言

SY-LILLI:选择某行时光标行位置

SY-LINCT 当前报表长度 (REPROT语句中设定的LINE-COUNT)

SY-LINNO 当前选定行的行号

SY-LINSZ 当前报表宽度(REPROT语句中设定的LINE-SIZE)

SY-LISEL 选择行的内容,长度为255

SY-LISTI 上一个列表的索引

SY-LOOPC:当前表格控件在屏幕中的总行数(Table Control)

SY-LSIND:当前列表索引,第一级列表为1

SY-MSGID 消息, 消息类

SY-MSGTY 消息,消息类型

SY-MSGNO 消息, 消息编号

SY-MSGV1 消息,消息变量1

SY-MSGV2 消息,消息变量2

SY-MSGV3 消息,消息变量3

SY-MSGV4 消息,消息变量4

SY-PAGNO 当前页号

SY-SCOLS:当前窗口的列表栏目数

SY-SLSET 选择屏幕的变式名称

SY-SROWS:当前窗口的列表行数

SY-STARO 真实行号

SY-STEPL:返回当前操作的屏幕行号(Table Control)

SY-SUBRC 执行状态

SY-TABIX 当前处理的内表的Index

SY-TCODE 当前的事务代码

SY-UCOMM:PAI所出发的功能代码

SY-ULINE 水平线

SY-UNAME 用户名

SY-UZEIT 服务器时间

SY-VLINE 垂直线

原文链接:https://blog.csdn.net/sapliumeng/article/details/18653139

 2.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: 没有找到符合条件的记录,也没有更新。

 

Values of SY-SUBRC on different ABAP statements

'sy-subrc' is a return code, set by the following ABAP statements.
As a rule, if SY-SUBRC = 0, the statement was executed successfully.

ASSIGN sets SY-SUBRC to 0 if the field symbol assignment was possible, otherwise to 4.
AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the required authorization, otherwise to 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause of the authorization failure.
CALL DIALOG with USING sets SY-SUBRC to 0 if the processing is successful, otherwise to a value other than 0.
CALL FUNCTION sets SY-SUBRC in accordance with the defined exception handling.
CALL METHOD sets SY-SUBRC in accordance with the defined exception handling.
CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chooses Enter or Execute, and 4 if the user chooses Cancel.
CALL TRANSACTION with USING sets SY-SUBRC to 0 if the processing is successful, otherwise to a value other than 0.
CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC after the ENDCATCH statement if a system exception occurs. The value is set in the program.
COMMIT WORK sets SY-SUBRC to 0. COMMIT WORK AND WAIT sets SY-SUBRC to 0 if the update is successful, otherwise to a value other than 0.
COMMUNICATION INIT DESTINATION ... RETURNCODE sets SY-SUBRC as specified.
CONCATENATE sets SY-SUBRC to 0 if the result fits into the target variable, otherwise to 4.
CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled in the program.
CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object could be created, otherwise to 1, 2, or 3, depending on the cause.
DELETE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or another value other than 0, depending on the cause.
DEMAND ... MESSAGES INTO sets SY-SUBRC to 0 if the message table is empty, otherwise to a value other than 0.
DESCRIBE LIST sets SY-SUBRC to 0 if the line or list exists, otherwise to 4 or 8.
EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in nearly all cases. It does, however, set SYSUBRC to 4 if no entry is read in a FETCH statement.
FETCH sets SY-SUBRC to 0 if at least one line was read, otherwise to 4.
GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if the generation was successful, otherwise to 8.
GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise to 4.
GET PARAMETER sets SY-SUBRC to 0 if a corresponding value exists in SAP memory, otherwise to 4.
IMPORT sets SY-SUBRC to 0 if the import is successful, otherwise to 4.
INSERT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.
LOAD REPORT sets SY-SUBRC to 0 if the operation is successful, otherwise to 4 or 8 depending on the cause of the error.
LOOP sets SY-SUBRC to 0 if there is at least one pass through the extract. Otherwise, it is set to a value other than 0.
LOOP AT sets SY-SUBRC to 0 if there is at least one loop pass through the internal table, otherwise to 4.
MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.
MODIFY LINE sets SY-SUBRC to 0 if a line in the list was changed, otherwise it sets it to a value other than 0.
MODIFY sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.
OLE2 Automation, executed successfully, otherwise 1, 2, 3, or 4, depending on the cause of the error.
OPEN DATASET sets SY-SUBRC to 0 if the file could be opened, otherwise to 8.
Open SQL statements set SY-SUBRC to 0 if the operation is successful, otherwise to a value other than 0.
OVERLAY sets SY-SUBRC to 0 if at least one character is overlaid, otherwise to 4.
READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise to 4 or 8, depending on the cause of the error.
READ LINE sets SY-SUBRC to 0 if a list line exists, otherwise to a value other than 0.
READ TABLE sets SY-SUBRC to 0 if table lines are found, otherwise to 2, 4, or 8, depending on the context and cause of the error.
REPLACE sets SY-SUBRC to 0 if the search string was replaced, otherwise to a value other than 0.
SCROLL sets SY-SUBRC to 0 if the scrolling within the list was successful, otherwise to 4 or 8, depending on the cause.
SEARCH sets SY-SUBRC to 0 if the search string was found, otherwise to 4.
SELECT sets SY-SUBRC to 0 if at least one line was read, otherwise to 4, or possibly 8 in SELECT SINGLE FOR UPDATE.
SET COUNTRY sets SY-SUBRC if the country code exists in table T005X, otherwise to 4.
SET BIT sets SY-SUBRC to 0 if the bit could be set, otherwise to a value other than 0.
SET TITLEBAR sets SY-SUBRC to 0 if the title exists, otherwise to 4.
SHIFT ... UP TO sets SY-SUBRC to 0 if the position could be found within the string, otherwise to 4.
SPLIT sets SY-SUBRC to 0 if the sizes of the target fields are adequate, otherwise to 4.
UPDATE sets SY-SUBRC to 0 if the operation is successful, otherwise to 4.
WRITE ... TO sets SY-SUBRC to 0 if the assignment is successful, otherwise to 4.

作者: 轻烟随风
当前文章地址: https://www.zyxpp.com/abapsy/
来源: 轻烟随风的博客
文章版权归作者所有,欢迎转载
THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录