BOM展开
DATA: LT_STPOX LIKE TABLE OF STPOX WITH HEADER LINE.
DATA: LT_J_3ABOMD LIKE TABLE OF J_3ABOMD WITH HEADER LINE.
DATA: LT_STPO LIKE TABLE OF ZSTPO WITH HEADER LINE.
LOOP AT LW_GT_IT.
CLEAR: LT_STPOX[],GT_T[].
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
DATUV = SY-DATUM
EHNDL = '1'
MTNRV = LW_GT_IT-MATNR
MEHRS = 'X'
MMORY = '1'
EMENG = '10'
STLAL = '1'
STLAN = LW_GT_IT-STLAN
WERKS = LW_GT_IT-WERKS
TABLES
STB = LT_STPOX[]
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
CONVERSION_ERROR = 8
OTHERS = 9.
LOOP AT LT_STPOX WHERE DUMPS EQ ''.
READ TABLE LT_J_3ABOMD WITH KEY STLNR = LT_STPOX-STLNR.
IF SY-SUBRC NE 0.
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE LT_J_3ABOMD
FROM J_3ABOMD
WHERE STLNR EQ LT_STPOX-STLNR.
ENDIF.
ENDLOOP.
LOOP AT LT_STPOX WHERE DUMPS EQ ''.
MOVE-CORRESPONDING LT_STPOX TO LT_STPO.
SELECT SINGLE * FROM STKO WHERE STLTY EQ LT_STPOX-STLTY
AND STLNR EQ LT_STPOX-STLNR.
* AND stlal EQ '01'.
SELECT SINGLE * FROM MARA WHERE MATNR EQ LT_STPOX-IDNRK.
MOVE MARA-NORMT TO GT_T-NORMT.
GT_T-BMENG = LW_GT_IT-BMENG.
GT_T-AVOAU = LW_GT_IT-AVOAU.
GT_T-MATNR = LW_GT_IT-MATNR.
GT_T-MAKTX = LW_GT_IT-MAKTX.
GT_T-WERKS = LW_GT_IT-WERKS.
GT_T-STLAN = LW_GT_IT-STLAN.
GT_T-EKGRP = LW_GT_IT-EKGRP.
GT_T-LBTXT = LW_GT_IT-LBTXT.
GT_T-ANNAM = LW_GT_IT-ANNAM.
GT_T-ANDAT = LW_GT_IT-ANDAT.
GT_T-AENAM = LW_GT_IT-AENAM.
GT_T-AEDAT = LW_GT_IT-AEDAT.
GT_T-FORMT = LW_GT_IT-FORMT.
* GT_T-XZ = LW_GT_IT-XZ.
* GT_T-PRDAT = LW_GT_IT-PRDAT.
GT_T-BLATT = LW_GT_IT-BLATT.
GT_T-IDNRK = LT_STPOX-IDNRK.
GT_T-SORTF = LT_STPOX-SORTF.
GT_T-POSNR = LT_STPOX-POSNR.
* GT_T-KTEXT = LT_STPOX-KTEXT.
GT_T-POTX1 = LT_STPOX-POTX1.
GT_T-POTX2 = LT_STPOX-POTX2.
SELECT SINGLE INFNR INTO GT_T-INFNR FROM EINA WHERE MATNR = GT_T-IDNRK.
SELECT SINGLE MAX( PRDAT ) INTO GT_T-PRDAT FROM EINE WHERE INFNR = GT_T-INFNR.
SELECT SINGLE NETPR INTO GT_T-NETPR FROM EINE WHERE INFNR = GT_T-INFNR AND PRDAT = GT_T-PRDAT.
IF GT_T-NETPR > 0 .
GT_T-XZ = '√'.
else.
GT_T-XZ = ''.
ENDIF .
SELECT SINGLE MAKTX INTO GT_T-MAKTX1 "物料描述
FROM MAKT
WHERE MATNR = GT_T-IDNRK.
SELECT SINGLE GROES INTO GT_T-GROES "物料描述
FROM MARA
WHERE MATNR = GT_T-IDNRK.
IF MARA-J_3APGNR EQ 'ZZZZ'.
READ TABLE LT_J_3ABOMD WITH KEY STLTY = LT_STPOX-STLTY
STLNR = LT_STPOX-STLNR
STLKN = LT_STPOX-STLKN
STPOZ = LT_STPOX-STPOZ.
MOVE LT_J_3ABOMD-J_3APGNR TO GT_T-J_3APGNR.
MOVE LT_J_3ABOMD-J_3AKORDX TO GT_T-J_3AKORDX.
MOVE LT_J_3ABOMD-J_3AKORDXL TO GT_T-J_3AKORDXL.
MOVE LT_J_3ABOMD-MEINS TO GT_T-J_3AMEINS.
MOVE LT_J_3ABOMD-MENGE TO GT_T-J_3AMENGE.
GT_T-J_3AMENGE = GT_T-J_3AMENGE / STKO-BMENG.
SPLIT GT_T-J_3AKORDXL AT ' ' INTO GT_T-SIZE GT_T-COLOR. "数量
CONDENSE: GT_T-SIZE,GT_T-COLOR.
SELECT SINGLE MSEHT INTO GT_T-J_3AMEINST "单位中文
FROM T006A
WHERE SPRAS EQ SY-LANGU
AND MSEHI EQ GT_T-J_3AMEINS.
APPEND GT_T.
ELSE.
LOOP AT LT_J_3ABOMD WHERE STLTY EQ LT_STPOX-STLTY
AND STLNR EQ LT_STPOX-STLNR
AND STLKN EQ LT_STPOX-STLKN
AND STPOZ EQ LT_STPOX-STPOZ.
MOVE LT_J_3ABOMD-J_3APGNR TO GT_T-J_3APGNR.
MOVE LT_J_3ABOMD-J_3AKORDX TO GT_T-J_3AKORDX.
MOVE LT_J_3ABOMD-J_3AKORDXL TO GT_T-J_3AKORDXL.
MOVE LT_J_3ABOMD-MEINS TO GT_T-J_3AMEINS.
MOVE LT_J_3ABOMD-MENGE TO GT_T-J_3AMENGE.
GT_T-J_3AMENGE = GT_T-J_3AMENGE / STKO-BMENG.
SPLIT GT_T-J_3AKORDXL AT ' ' INTO GT_T-SIZE GT_T-COLOR.
CONDENSE: GT_T-SIZE,GT_T-COLOR.
SELECT SINGLE MSEHT INTO GT_T-J_3AMEINST "单位中文
FROM T006A
WHERE SPRAS EQ SY-LANGU
AND MSEHI EQ GT_T-J_3AMEINS.
APPEND GT_T.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. "get_date