report z. * Explode assembly (including phantom assemblies up to last level) parameters: p_werks like t001w-werks obligatory, p_matnr like mara-matnr obligatory. constants c_x value 'X'. data: begin of it_comp occurs 0, idnrk like stpox-idnrk, ojtxp like stpox-ojtxp, menge like stpox-menge, meins like stpox-meins, matkl like stpox-matmk, end of it_comp. data: w_topmat like cstmat, ******************* start-of-selection. ******************* perform explode_assembly. ***************** end-of-selection. ***************** perform write_report. ************ top-of-page. ************ perform print_header. *&---------------------------------------------------------------------* form print_header. write: /(18) 'Component'(h00), (40) 'Description'(h01), 'Mat.Group'(h02), (18) 'Quantity'(h03). uline. endform. *&---------------------------------------------------------------------* form write_report. write: / w_topmat-matnr under text-h00 color col_heading, w_topmat-maktx under text-h01 color col_heading. loop at it_comp. write: / it_comp-idnrk under text-h00, it_comp-ojtxp under text-h01, it_comp-matkl under text-h02, it_comp-menge unit it_comp-meins under text-h03, it_comp-meins. endloop. uline. endform. *&---------------------------------------------------------------------* form explode_assembly. data: it_stb like stpox occurs 0 with header line, it_stb2 like stpox occurs 0 with header line, it_stb3 like stpox occurs 0 with header line, w_msg(255) type c. * Explode highest level: call function 'CS_BOM_EXPL_MAT_V2' exporting capid = 'PP01' cuols = c_x datuv = sy-datum knfba = c_x ksbvo = c_x mbwls = c_x mdmps = c_x mtnrv = p_matnr werks = p_werks importing topmat = w_topmat tables stb = it_stb 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 <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into w_msg. write: / w_msg. exit. endif. * Don't process documents delete it_stb where idnrk is initial. * Don't process valid from furure: delete it_stb where datuv >= sy-datum. * Explode phantom assemblies up to last level do. it_stb2[] = it_stb[]. delete it_stb2 where dumps is initial. if it_stb2[] is initial. exit. endif. delete it_stb where not dumps is initial. loop at it_stb2. call function 'CS_BOM_EXPL_MAT_V2' exporting capid = 'PP01' cuols = c_x datuv = sy-datum knfba = c_x ksbvo = c_x mbwls = c_x mdmps = c_x mtnrv = it_stb2-idnrk werks = p_werks tables stb = it_stb3 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 <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into w_msg. write: / w_msg. else. delete it_stb3 where idnrk is initial. loop at it_stb3. multiply it_stb3-menge by it_stb2-menge. modify it_stb3 transporting menge. endloop. append lines of it_stb3 to it_stb. endif. endloop. enddo. * Build table of components collecting the same components from * all levels loop at it_stb. it_comp-matkl = it_stb-matmk. it_comp-idnrk = it_stb-idnrk. it_comp-ojtxp = it_stb-ojtxp. it_comp-menge = it_stb-menge. it_comp-meins = it_stb-meins. collect it_comp. clear it_comp. endloop. endform.