*--------------------------------内表-------------------------------------
MATNR TYPE LIPS-MATNR,
LFIMG TYPE LIPS-LFIMG,
COL TYPE I ,
VBELN TYPE LIPS-VBELN,
ARKTX TYPE LIPS-ARKTX,
KDMAT TYPE LIPS-KDMAT,
ZREMARK(30),
END OF TY_TAB.```
*-----------------------------取值和保存值的表和工作区----------------------------------------
``` DATA: GT_TAB1 TYPE TABLE OF TY_TAB ,
GS_TAB1 TYPE TY_TAB.```
*-----------------------------取值----------------------------------------
SELECT
LIPS~MATNR
LIPS~ARKTX
LIPS~KDMAT
LIPS~LFIMG
INTO CORRESPONDING FIELDS OF TABLE GT_TAB1
FROM LIPS
WHERE LIPS~LFIMG <> 0
and LIPS~VBELN IN S_VBELN.
SORT GT_TAB1 BY MATNR.```
*---------------------------------汇总-------------------------------------
LOOP AT GT_TAB1 INTO Gs_TAB1.
AT new MATNR.
LFIMG1 = 0.
ENDAT.
LFIMG1 = LFIMG1 + Gs_TAB1-LFIMG.
Gs_TAB1-LFIMG = LFIMG1 .
MODIFY Gt_TAB1 from Gs_TAB1.
ENDLOOP.
SORT GT_TAB1 DESCENDING by MATNR LFIMG. "降序
delete ADJACENT DUPLICATES FROM Gt_TAB1 COMPARING MATNR.
使用 AT NEW F、AT END OF F时需注意:
1.F 是内表第一个字段
2.内表不进入at new 、at end of
AT NEW : “ 当读取内表第一行是触发
AT END OF : '当读取内表的最后一行是触发