REPORT zhello.
DATA:outtab001 TYPE TABLE OF zsfms_getpctx WITH HEADER LINE,
it_matnr TYPE TABLE OF ccvx_matnr WITH HEADER LINE,
it_atnam TYPE TABLE OF tctrw WITH HEADER LINE.
it_matnr-matnr = 'E0201203832'.
APPEND it_matnr.
SORT it_matnr BY matnr.
REFRESH:outtab001,it_atnam.
PERFORM get001 TABLES it_matnr.
SORT outtab001 BY matnr atnam.
BREAK-POINT.
FORM get001 TABLES t_matnr STRUCTURE ccvx_matnr.
DATA:BEGIN OF it_objek OCCURS 0,
objek TYPE kssk-objek,
END OF it_objek.
CLEAR:it_objek[],outtab001[].
DELETE t_matnr WHERE matnr IS INITIAL.
CHECK t_matnr[] IS NOT INITIAL.
SORT t_matnr BY matnr.
LOOP AT t_matnr.
CLEAR:it_objek.
it_objek-objek = t_matnr-matnr.
COLLECT it_objek.
ENDLOOP.
*取001的特征
SELECT ksml~clint,
ksml~posnr,
ksml~adzhl,
ksml~klart,
ksml~imerk AS atinn,
cabn~atnam ,
cabn~atfor ,
cabn~anzst ,
cabn~anzdz ,
kssk~objek AS matnr
INTO TABLE @DATA(it_ksml)
FROM ksml INNER JOIN cabn ON ksml~imerk = cabn~atinn
INNER JOIN kssk ON ksml~clint = kssk~clint
AND kssk~klart = '001'
FOR ALL ENTRIES IN @it_objek
WHERE kssk~objek = @it_objek-objek.
IF sy-subrc EQ 0.
SORT it_ksml BY klart matnr atinn.
SELECT *
INTO TABLE @DATA(lt_ausp)
FROM ausp
FOR ALL ENTRIES IN @it_ksml
WHERE klart = @it_ksml-klart
AND objek = @it_ksml-matnr
AND atinn = @it_ksml-atinn.
SORT it_ksml BY matnr atinn.
LOOP AT lt_ausp INTO DATA(lw_ausp).
CLEAR:outtab001,it_atnam.
IF lw_ausp-atwrt IS INITIAL.
CONTINUE.
ENDIF.
outtab001-matnr = lw_ausp-objek.
READ TABLE it_ksml INTO DATA(wa_ksml) WITH KEY matnr = lw_ausp-objek
atinn = lw_ausp-atinn
BINARY SEARCH.
IF sy-subrc EQ 0.
outtab001-atnam = wa_ksml-atnam.
outtab001-atwrt = lw_ausp-atwrt.
APPEND outtab001.
it_atnam-atnam = outtab001-atnam."汇总,后续取描述
COLLECT it_atnam.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM.
网友评论