关于ABAP ALV的一个问题,
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/08/24 07:22:52
关于ABAP ALV的一个问题,
一个物料存在于好几个库位,例:
物料号 库位
10000000 101
10000000 102
10000000 103
怎么在程序里写成按照下面的显示呢
物料号 库位 库位 库位
10000000 101 102 103
一个物料存在于好几个库位,例:
物料号 库位
10000000 101
10000000 102
10000000 103
怎么在程序里写成按照下面的显示呢
物料号 库位 库位 库位
10000000 101 102 103
假设你的源物料内表结构为:
MATNR
SLOC
内表为:IT_MAT.
目标表的结构为:
MATNR
SLOC1
SLOC2
SLOC3
SLOC4
SLOC5
内表为:IT_MATD
DATA:WA_MAT LIKE LINE OF IT_MAT,
IT_TEM LIKE IT_MAT,
WA_TEM LIKE LINE OF IT_MAT,
LV_NUM TYPE N,
WA_MATD LIKE LINE OF IT_MATD,
LV_FIELD TYPE STRING.
FIELD-SYMBOLS:TYPE ANY.
SORT IT_MAT BY MATNR ASCENDING
SLOC ASCENDING.
LV_NUMBER = 1.
LOOP AT IT_MAT INTO WA_MAT.
AT NEW MATNR.
LOOP AT IT_TEM INTO WA_TEM.
WA_MATD-MATNR = WA_TEM-MATNR.
CONCATENATE 'WA_MATD-SLOC'
LV_NUMBER
INTO LV_FIELD.
ASSIGN COMPONENT LV_FIELD OF STRUCTURE WA_MATD TO .
IF SY-SUBRC = 0 .
= WA_TEM-SLOC.
ENDIF.
LV_NUMBER = LV_NUMBER + 1.
ENDLOOP.
IF WA_MATD-MATNR IS NOT INITIAL.
APPEND WA_MATD TO IT_MATD.
ENDIF.
CLEAR:IT_TEM,
WA_TEM,
WA_MATD.
ENDAT.
APPEND WA_MAT TO IT_TEM.
AT LAST.
LOOP AT IT_TEM INTO WA_TEM.
WA_MATD-MATNR = WA_TEM-MATNR.
CONCATENATE 'WA_MATD-SLOC'
LV_NUMBER
INTO LV_FIELD.
ASSIGN COMPONENT LV_FIELD OF STRUCTURE WA_MATD TO .
IF SY-SUBRC = 0 .
= WA_TEM-SLOC.
ENDIF.
ENDLOOP.
CLEAR:IT_TEM.
APPEND WA_MATD TO IT_MATD.
ENDAT.
ENDLOOP.
看看你能不能理解,不能理解再问我.
MATNR
SLOC
内表为:IT_MAT.
目标表的结构为:
MATNR
SLOC1
SLOC2
SLOC3
SLOC4
SLOC5
内表为:IT_MATD
DATA:WA_MAT LIKE LINE OF IT_MAT,
IT_TEM LIKE IT_MAT,
WA_TEM LIKE LINE OF IT_MAT,
LV_NUM TYPE N,
WA_MATD LIKE LINE OF IT_MATD,
LV_FIELD TYPE STRING.
FIELD-SYMBOLS:TYPE ANY.
SORT IT_MAT BY MATNR ASCENDING
SLOC ASCENDING.
LV_NUMBER = 1.
LOOP AT IT_MAT INTO WA_MAT.
AT NEW MATNR.
LOOP AT IT_TEM INTO WA_TEM.
WA_MATD-MATNR = WA_TEM-MATNR.
CONCATENATE 'WA_MATD-SLOC'
LV_NUMBER
INTO LV_FIELD.
ASSIGN COMPONENT LV_FIELD OF STRUCTURE WA_MATD TO .
IF SY-SUBRC = 0 .
= WA_TEM-SLOC.
ENDIF.
LV_NUMBER = LV_NUMBER + 1.
ENDLOOP.
IF WA_MATD-MATNR IS NOT INITIAL.
APPEND WA_MATD TO IT_MATD.
ENDIF.
CLEAR:IT_TEM,
WA_TEM,
WA_MATD.
ENDAT.
APPEND WA_MAT TO IT_TEM.
AT LAST.
LOOP AT IT_TEM INTO WA_TEM.
WA_MATD-MATNR = WA_TEM-MATNR.
CONCATENATE 'WA_MATD-SLOC'
LV_NUMBER
INTO LV_FIELD.
ASSIGN COMPONENT LV_FIELD OF STRUCTURE WA_MATD TO .
IF SY-SUBRC = 0 .
= WA_TEM-SLOC.
ENDIF.
ENDLOOP.
CLEAR:IT_TEM.
APPEND WA_MATD TO IT_MATD.
ENDAT.
ENDLOOP.
看看你能不能理解,不能理解再问我.