include:
INCLUDE:
XXXXXXX
XXXXXXX
给代码分块儿存放,一种组织形式。可以挂在多个程序里面。
------------------------------------------------
PRAMETERS:
PARAMETERS P_XXX TYPE MARA-XXX.
只查询一个值,变量如果不指定TYPE型,则默认定义为基本CHAR1类型。和DATA一样定值。
----------------------------------------------------------
BREAK-POINT.
BREAK-POINT.
断点。
------------------------------------------------
X_XXX 【】:【】代表内表。
BT:指定区间。
EQ:等于
I:包括
E:排除
------------------------------------------------
SELECT-OPTIONS:
在程序里是一个内表,有四 个字段
SIGN/OPTION/LOW/HIGH
在程序内可以通过两个方式得到同样的内表
1:
DATA LV_MATNR TYPE MARA-matnr.
TYPES: BEGIN OF ty_mat,
sign TYPE char01,
option TYPE char02,
high TYPE mara-matnr,
high TYPE mara-matnr,
END OF ty_mat.
DATA lt_mat TYPE TABLE OF ty_mat.
2:
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.
DATA lt_mate TYPE RANGE OF mara-matnr.
LT_MATE[] = S_MATNR[].
------------------------------------------------
DEFAULT:
选择画面设置初始值。
PARAMETERS:
P_XX TYPE TAB-XX DEFAULT 'XX'.
------------------------------------------------
MATCHCODE OBJECT:
手动创建搜索帮助
PARAMETERS:
P_XXX TYPE XXX-XXX MATCHCODE OBJECT TBA.
------------------------------------------------
OBLIGATORY:
必须输入值
SELECT-OPTIONS S_XXX FOR TAB-XXX OBLIGATORY.
------------------------------------------------
AS CHECKBOX
定义一个チェックボックス
------------------------------------------------
DO 10 TIMES.
write: /, 'times', sy-index.
ENDDO.
自定义循环多少次。sy-index:当前循环的次数
DO 10 TIMES.
ENDDO.
------------------------------------------------
sy-tabix:循环多少次,可以带出循环的行数,每循环一次+1.
LOOP AT lt_xxx into ls_xxx.
write: / sy-tabix , ls_xxx-xxx.
endloop.
------------------------------------------------
READ TABLE
单拿某一行
READ TABLE LT_XXX INTO LS_XXX WITH KEY XX(字段) = ' xx '
READ TABLE LT_XXX INTO LS_XXX INDEX 1(可写变量). 拿第x行
------------------------------------------------
sy-subrc = 0
作为判断,上一条语句的执行结果,如果成功=0,如果失败≠0
等于0成功,不等于失败。
READ TABLE LT_XXX INTO LS_XXX WITH KEY MATNR = 'XX'
IF SY-subrc = 0.
write:/xxx
ELSE.
WRITE: /'NOTFOUND'.
endif.
------------------------------------------------
sy-uname : 当前登录用户名称
sy-datum : 当前服务器日期
sy-uzeit : 当前系统时间点
sy-langu : 当前系统语言
sy-subrc : 作为判断,上一条语句的执行结果,如果成功=0,如果失败≠0
sy-index : 当前循环的次数
sy-tabix : 循环多少次,可以带出循环的行数,每循环一次+1.
------------------------------------------------
lines:查看当前内表行数,看内表里是否有数据
DATA LV_XXX ROWS TYPE INT4.
LV_XXX = LINES( LT_XXX ).
WRITE: /, LVROWS.
DATA LV_XXX ROWS TYPE INT4.
DESCRIBE TABLE LT_XXX LINES LV_XXX.
WRITE: /, LV_XXX.
或者写一个LOOP sy-tabix
IS INITIAL :初始值
IF LT_XXX IS INITIAL.
WRITE: XXX
ENDIF.
------------------------------------------------
COLLECT:做统计,按照key值把里面的数值累加,尽量少字段。
COLLECT LS_XXX INTO LT_XXX.
CLEAR :清空行
CLEAR LS_XXX.
------------------------------------------------
DECIMALS X
几位小数
DATA LV_XXX TYPE P DECIMALS 2. p类型两位小数
------------------------------------------------
加法
lv_xxx = a + b .
lv_xxx = add a to b.
减法
lv_xx = a-b.
lv_xx = subtract b from a.
------------------------------------------------
SORT : 按照xxx排序(默认从小到大)
ascending:升序
descending:降序
SORT LT_XXX BY XXX(字段).
SORT LT_XXX BY XXX DESCENDING. 降序
SORT LT_XXX BY XXX ASCENDING. 升序
------------------------------------------------
APPEND:在内表增加一行
CLEAR IS_XXX.
LS_XXX-XXX = 'XX'.
LS_XXX-XXX = “XX'.
APPEND LS_XXXTO LT_XXX.
------------------------------------------------
DELETE:删除表数据
DELETE LT_XXX WHERE XX > 100. 删除内表LT_XXX中字段XX>100的数据
DELETE LT_XXX INDEX 1. 删除第一行
CLEAR LS_XXX. = DELETE LS_XXX.
------------------------------------------------
LS_XXX-XXX = LS_XXX-XXX + 20.
LS_XXX-XXX += 20.
------------------------------------------------
MODIFY:修改内表数据
TRANSPORTING:只改,,
LOOP AT LT_XXX INTO LS_XXX
LS_XXX-XXX += 20
MODIFY LT_XXX FROM LS_XXX INDEX SY-TABIX TRANSPORTING XXX. 只改xxx
ENDLOOP.
******
MODIFY LT_xx FROM LS_xx INDEX 1.
------------------------------------------------
增:APPEND
删:DELETE
读:READ
改:MODIFY
循环:LOOP,DO