展开BOM的时候,半成品组件的数量,不会跟着变,或许有其它方法
这里每次展开1层,写了个循环调用。直接调用接口就好了。
CALL FUNCTION 'Z_RFC_PP_BOM_EXPL'
EXPORTING
p_aufsw = 'X'
p_capid = 'PP01'
p_datuv = sy-datum
p_matnr = gs_output-matnr
p_stlan = gs_output-stlan
p_stlal = gs_output-stlal
p_bmeng = gs_output-bmeng
p_werks = gs_output-werks
* p_histu = p_histu3 "stufe
* IMPORTING
* ls_cstmat = ls_cstmat
* p_histu2 = p_histu4
TABLES
it_stpox = gt_stpox.
*"---------------------------------------------------------------------- *"*"本地接口: *" IMPORTING *" VALUE(P_AUFSW) TYPE CSDATA-XFELD DEFAULT 'X' *" VALUE(P_CAPID) TYPE TC04-CAPID DEFAULT 'PP01' *" VALUE(P_DATUV) TYPE STKO-DATUV DEFAULT SY-DATUM *" VALUE(P_MATNR) TYPE MARA-MATNR OPTIONAL *" VALUE(P_STLAN) TYPE STZU-STLAN OPTIONAL *" VALUE(P_STLAL) TYPE STKO-STLAL OPTIONAL *" VALUE(P_BMENG) TYPE STKO-BMENG OPTIONAL *" VALUE(P_WERKS) TYPE MARC-WERKS OPTIONAL *" VALUE(P_HISTU) TYPE HISTU DEFAULT '1' *" EXPORTING *" VALUE(LS_CSTMAT) TYPE CSTMAT *" VALUE(P_HISTU2) TYPE HISTU *" TABLES *" IT_STPOX STRUCTURE STPOX OPTIONAL *" IT_CSCMAT STRUCTURE CSCMAT OPTIONAL *"---------------------------------------------------------------------- DATA: lt_stpox LIKE TABLE OF stpox, lt_stpox2 LIKE TABLE OF stpox, ls_stpox LIKE stpox, ls_stpox2 LIKE stpox, p_histu3 TYPE histu, p_histu4 TYPE histu. * ADD 1 TO p_histu. p_histu2 = p_histu + 1. CALL FUNCTION 'CS_BOM_EXPL_MAT_V2' "展开BOM EXPORTING aufsw = p_aufsw "'X' capid = p_capid "'PP01' "checkb "BOM应用 datuv = p_datuv "sy-datum "有效起始日 mtnrv = p_matnr "gs_output-matnr "展开物料号 postp = ' ' "项目类别(物料单) stlan = p_stlan "BOM用途 stlal = p_stlal "可选的BOM werks = p_werks "工厂 emeng = p_bmeng "数量 gsmng计划订单总数量 bdmng需求量 mehrs = '' "X为多层展开 IMPORTING topmat = ls_cstmat * DSTST = TABLES stb = lt_stpox matcat = it_cscmat 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. IF sy-subrc EQ 0. LOOP AT lt_stpox INTO ls_stpox. CLEAR:lt_stpox2[]. ls_stpox-stufe = p_histu2. APPEND ls_stpox TO it_stpox[]. IF ls_stpox-xtlty NE ''. p_histu3 = p_histu2. CALL FUNCTION 'Z_RFC_PP_BOM_EXPL' EXPORTING p_aufsw = 'X' p_capid = 'PP01' p_datuv = sy-datum p_matnr = ls_stpox-idnrk p_stlan = ls_stpox-stlan p_stlal = ls_stpox-stlal p_bmeng = ls_stpox-mngko p_werks = ls_stpox-werks p_histu = p_histu3 "stufe IMPORTING ls_cstmat = ls_cstmat p_histu2 = p_histu4 TABLES it_stpox = lt_stpox2. LOOP AT lt_stpox2 INTO ls_stpox2. ls_stpox2-stufe = p_histu4. APPEND ls_stpox2 TO it_stpox[]. CLEAR: ls_stpox2. ENDLOOP. ENDIF. CLEAR ls_stpox. ENDLOOP. ENDIF.View Code