*&---------------------------------------------------------------------* *& Report ZBOM_UP *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* report zbom_up. types: begin of typ_marc, matnr type marc-matnr,"物料编码 werks type marc-werks,"工厂 bstrf type marc-bstrf,"采购订单数量的舍入值 lgfsb type marc-lgfsb,"外部采购的缺省仓储位置 kordb type marc-kordb,"标识: 源清单要求 beskz type marc-beskz,"采购类型 dispo type marc-dispo,"MRP 控制者(物料计划人) matkl type mara-matkl,"物料组 prdha type mara-prdha,"产品层次 bstme type mara-bstme,"采购订单的计量单位 meins type mara-meins,"计量单位 maktx type makt-maktx,"物料描述 end of typ_marc. types:begin of typ_output, matnr type marc-matnr, "物料 werks type marc-werks, "工厂 maktx type makt-maktx, "物料描述 prdha type prodh_d, vtext type ztpps001-vtext1,"产品层次 dispo type marc-dispo,"MEP控制者 dsnam type ztpps001-dsnam1,"MEP控制者描述 lifnr type lfa1-lifnr,"供应商 sortl type lfa1-sortl,"供应商描述 erfme type pbed-meins,"单位 m01 type pbed-plnmg, m02 type pbed-plnmg, m03 type pbed-plnmg, m04 type pbed-plnmg, m05 type pbed-plnmg, m06 type pbed-plnmg, m07 type pbed-plnmg, m08 type pbed-plnmg, m09 type pbed-plnmg, m10 type pbed-plnmg, m11 type pbed-plnmg, m12 type pbed-plnmg, price type ztpps001-price,"单价 konwa type konp-konwa ,"单位 idnrk type stpox-idnrk ,"物料 pswrk type stpox-pswrk ,"工厂 beskz type marc-beskz ,"采购类型 gjahr type gjahr ,"年度 box type c ,"复选框 mess type char100 ,"消息 led type icon-id ,"指示灯 * celltab TYPE lvc_t_styl , "STYLE end of typ_output. data: gt_marc type standard table of typ_marc, gw_marc type typ_marc. data: lt_wultb_a type table of stpov, lt_wultb type table of stpov, lw_wultb type stpov. data: l_mess type char100. data gt_output type standard table of typ_output. clear gw_marc. gw_marc-matnr = '000000005000000002'. gw_marc-werks = '7810'."工厂 append gw_marc to gt_marc. *输入一个物料 展开全部上阶物料 loop at gt_marc into gw_marc. "根据下阶物料查找上阶物料 refresh: lt_wultb. lw_wultb-matnr = gw_marc-matnr."上阶物料 lw_wultb-werks = gw_marc-werks."上阶物料工厂 lw_wultb-idnrk = gw_marc-matnr."下阶物料 lw_wultb-pswrk = gw_marc-werks."下阶物料工厂 append lw_wultb to lt_wultb. "查找物料在哪个BOM使用,一直查找到最上一阶 perform frm_cs_where_used_mat tables lt_wultb lt_wultb_a using gw_marc-matnr gw_marc-werks changing l_mess. "结果汇总 append lines of lt_wultb to lt_wultb_a. endloop. break-point. *&---------------------------------------------------------------------* *& Form FRM_CS_WHERE_USED_MAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LT_BOM text * -->P_GW_MARC_MATNR text * -->P_GW_MARC_WERKS text * <--P_L_MESS text *----------------------------------------------------------------------* form frm_cs_where_used_mat tables pt_wultb structure stpov pt_wultb_a structure stpov using pv_matnr pv_werks changing pv_mess. data: lt_wultb type table of stpov, lw_wultb type stpov, lt_equicat type table of cscequi, lt_kndcat type table of cscknd, lt_matcat type table of cscmat, lt_stdcat type table of cscstd, lt_tplcat type table of csctpl. data: l_datub type rc29l-datub , l_datuv type rc29l-datuv , l_matnr type rc29l-matnr, l_postp type rc29l-postp, l_stlan type rc29l-stlan value '1', l_werks type rc29l-werks, lw_topmat type mc29s. data: l_tabix type i. loop at pt_wultb. l_datub = sy-datum. l_datuv = sy-datum. l_matnr = pt_wultb-matnr."物料 l_werks = pt_wultb-werks."工厂 clear lw_topmat. refresh: lt_wultb, lt_equicat, lt_kndcat, lt_matcat, lt_stdcat, lt_tplcat. call function 'CS_WHERE_USED_MAT' exporting datub = l_datub datuv = l_datuv matnr = l_matnr * POSTP = l_postp * RETCODE_ONLY = ' ' stlan = l_stlan werks = l_werks * MCLMT = ' ' * MNSTL = ' ' * MXSTL = ' ' * STLTP = ' ' * NEWSI = ' ' importing topmat = lw_topmat tables wultb = lt_wultb equicat = lt_equicat kndcat = lt_kndcat matcat = lt_matcat stdcat = lt_stdcat tplcat = lt_tplcat * PRJCAT = exceptions call_invalid = 1 material_not_found = 2 no_where_used_rec_found = 3 no_where_used_rec_selected = 4 no_where_used_rec_valid = 5 others = 6. if sy-subrc <> 0. * Implement suitable error handling here "若不存在上阶物料,则为成品物料 if pt_wultb-matnr = pv_matnr and pt_wultb-werks = pv_werks. delete pt_wultb. endif. else. loop at lt_wultb into lw_wultb. "成品已经存在,不要此条目 * READ TABLE gt_output TRANSPORTING NO FIELDS * WITH KEY matnr = lw_wultb-matnr * werks = lw_wultb-werks. ** idnrk = pt_wultb-idnrk. * IF sy-subrc = 0. * CONTINUE. * ENDIF. * "存在同一成品,不要此条目 * READ TABLE pt_wultb TRANSPORTING NO FIELDS * WITH KEY matnr = lw_wultb-matnr * werks = lw_wultb-werks. * IF sy-subrc = 0. * CONTINUE. * ENDIF. * "与别的物料存在同一成品, 不要此条目 * READ TABLE pt_wultb_a TRANSPORTING NO FIELDS * WITH KEY matnr = lw_wultb-matnr * werks = lw_wultb-werks. * IF sy-subrc = 0. * CONTINUE. * ENDIF. "记录下阶物料和工厂 lw_wultb-idnrk = pv_matnr. lw_wultb-pswrk = pv_werks. append lw_wultb to pt_wultb. endloop. "若存在上阶物料,则删除本阶物料 delete pt_wultb. endif. endloop. endform. " FRM_CS_WHERE_USED_MAT
标签:物料,werks,matnr,wultb,marc,BOM,向上,type,展开 From: https://www.cnblogs.com/Anyohh233/p/17980135