delete adjacent duplicates from lt_xxx comparing course. 删除多余的行
只保留最上面一行
delete adjacent duplicates from lt_xxx comparing course. 删除多余的行
只保留最上面一行
parameters p_date type sydatum.
data lv_data like p_date.
lv_date = p_date.
lv_date = lv_date +35.
lv_date+6(2) = '01'.
lv_date = lv_date -1.
write: / lv_date.
20180118
Event Blocks:报表事件,
-----------------------------------------------
INITIALIZATION:初始化,所有事件中最早执行的一个事件
----------------------------------------------
选择屏幕创建下拉列表:AS LISTBOX VISIBLE LENGTH XX.
函数'VRM_SET_VALUES'
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'P_XXX' 选择屏幕定义的名字
VALUES = LT_XXX 需要输出的内容
EXCEPTIONS
id_illegal_name = 1
OTHERS
------------------------------------------------
所有输出内容变小写:
TTRANSLATE LS_XXX TO LOWER CASE.
-----------------------------------------------
AT SELECTION-SCREEN. 检查选择屏幕 ,必须输入值。
IF P_XX IS INITIAL.
MESSAGE 'XXXX' TYPE 'W'
ENDIF
pbo:看到屏幕之前
pai:看到屏幕之后
------------------------------------------------
START-OF-SELECTION. 运行程序
给程序分块儿:
PERFORM XX_XX
FORM
ENDFORM
可以定义FORM里面自己的变量,其他FORM里不可以调用
----------------------------------------------
FIELD-SYMBOLS<XXX> TYPE TY_XXX.
没听懂
LOOP AT XX_XX ASSIGNING <>.
没懂
------------------------------------------------
二分查找 Binary Search
SROT LT_XXX BY XX(字段) 先排序
READ TABLE LT_XXX INTO LS_XXX WITH KEY XX(字段)= 'XXXX'
BINARY SEARCH.
IF SY-SUBRC = 0.
WRITE: / 'the locatin is ',sy-tabix.
ELSE.
WRITE: / 'not found'.
endif.
-----------------------------------------------
AT SELECTION-SCREEN.
检查,把不合理的挡住
PARAMETERS P_XXX TYPE XXX.
SELECTION-SCREEN.
IF NOT ( P_XXX CP 'XXX' OR P_XXX CP 'XXX' ).
message 'xxxxxxx' type ‘ W(E)'.
ENDIF.
----------------------------------------------
在本地读取exl文件到客户端
ZWEEK4_READ_LPCAL_EXCEL
G_REPID = SY-REPID. 永远不变
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
PARAMATERS