REPORT ZPPR012. *&---------------------------------------------------------------------* *& Report ZPPR_ECN001 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* TABLES:stpo,stko,stpu,mast,stas. *&------------------------------------------------------------------* *& INTERNAL TABLES *&------------------------------------------------------------------* TYPE-POOLS:slis. *ALV控件构造时需要的参数 DATA: g_alv_fieldcat TYPE slis_t_fieldcat_alv, g_alv_fieldcat_line LIKE LINE OF g_alv_fieldcat, g_alv_head TYPE slis_t_listheader, g_alv_event TYPE slis_t_event. *ALV控件输出的表头 DATA: g_alv_listheader TYPE slis_t_listheader. *指定ALV控件触发TOP_OF_PAGE事件时调用的子程序 DATA: g_alv_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'. *指定ALV控件的显示特征 DATA : g_alv_layout TYPE slis_layout_alv. DATA: BEGIN OF itab OCCURS 0, frbom LIKE mara-matnr, "上阶成品号码 aennr LIKE stpo-aennr, "变更号码 * sdnrk like stpo-idnrk, "更改前组件 idnrk LIKE stpo-idnrk, "更改后组件 stlnr LIKE stpo-stlnr, "BOM物料单 stlkn LIKE stpo-stlkn, "BOM项目节点号 lin TYPE i, stlkn1 LIKE stpo-stlkn, stpoz LIKE stpo-stpoz, "记数器 lkenz LIKE stas-lkenz, "删除(修改)标记 stvkn LIKE stas-stvkn, "BOM 项目的继承节点号 ebort LIKE stpu-ebort, "安装地点 ebort1 LIKE stpu-ebort, ebort2 LIKE stpu-ebort, * oenge like stpo-menge, "更改前数量 menge LIKE stpo-menge, "更改后数量 menge1 LIKE stpo-menge, meins LIKE stpo-meins, posnr LIKE stpo-posnr, "项目 aedat LIKE stpo-aedat, "修改日期 vgknt LIKE stpo-vgknt, "前一节点 vgpzl LIKE stpo-vgpzl, datuv LIKE stas-datuv, "有效期始于 potx1(40),potx2(40), potx3(40),potx4(40), potx5(40),potx6(40), potx7(40),potx8(40), potx9(40),potx10(40), maktx(75), maktx1(75), name LIKE thead-tdname, END OF itab. DATA:BEGIN OF i_parent OCCURS 0 , frbom LIKE mara-matnr, "上阶成品号码 END OF i_parent. DATA:BEGIN OF circuit OCCURS 0, loc LIKE itab-ebort, END OF circuit. DATA:BEGIN OF model OCCURS 0, aennr LIKE stas-aennr, parent LIKE mara-matnr, modle LIKE mara-matnr, matnr LIKE mara-matnr, END OF model. DATA:BEGIN OF i_stas OCCURS 0, stlnr LIKE stas-stlnr, "物料单 stlkn LIKE stas-stlkn, "BOM 项目节点号 aennr LIKE stas-aennr, "更改号 lkenz LIKE stas-lkenz, "删除标识 stvkn LIKE stas-stvkn, "BOM 项目的继承节点号 datuv LIKE stas-datuv, "有效期始于 END OF i_stas. DATA:BEGIN OF i_stpo OCCURS 0, stlnr LIKE stas-stlnr, " 物料单 stlkn LIKE stas-stlkn, "BOM 项目节点号 stpoz LIKE stpo-stpoz, "计数器 aennr LIKE stas-aennr, "更改号 lkenz LIKE stas-lkenz, "删除标识 stvkn LIKE stas-stvkn, "BOM 项目 idnrk LIKE stpo-idnrk, "BOM 组件 posnr LIKE stpo-posnr, "BOM 项目号 menge LIKE stpo-menge, "组件数量 meins LIKE stpo-meins, "组件数量 vgknt LIKE stpo-vgknt, "前述节点 ebort LIKE stpu-ebort, "存放地点 datuv LIKE stas-datuv, "有效期始于 potx1 LIKE stpo-potx1, potx2 LIKE stpo-potx2, vgpzl LIKE stpo-vgpzl, END OF i_stpo. DATA:BEGIN OF it_stko OCCURS 0, matnr LIKE mast-matnr, stlnr LIKE stko-stlnr, aennr LIKE stko-aennr, labor LIKE stko-labor, bmeng LIKE stko-bmeng, datuv LIKE stas-datuv, vgkzl LIKE stko-vgkzl, END OF it_stko. DATA:BEGIN OF it_stko_all OCCURS 0, matnr LIKE mast-matnr, stlnr LIKE stko-stlnr, aennr LIKE stko-aennr, labor LIKE stko-labor, bmeng LIKE stko-bmeng, stkoz LIKE stko-stkoz, "ADD BY LY 20160112 vgkzl LIKE stko-vgkzl, "ADD BY LY 20160112 datuv LIKE stas-datuv, datuv1 LIKE stas-datuv, datuv2 LIKE stas-datuv, END OF it_stko_all . DATA:BEGIN OF it_stko_end OCCURS 0, matnr LIKE mast-matnr, stlnr LIKE stko-stlnr, aennr LIKE stko-aennr, labor LIKE stko-labor, bmeng LIKE stko-bmeng, datuv LIKE stas-datuv, datuv1 LIKE stas-datuv, END OF it_stko_end . DATA:BEGIN OF it_matnr OCCURS 0, stlnr LIKE mast-stlnr, END OF it_matnr . DATA:t_stpo LIKE i_stpo OCCURS 0 WITH HEADER LINE, v_stpo LIKE i_stpo OCCURS 0 WITH HEADER LINE, s_stpo LIKE i_stpo OCCURS 0 WITH HEADER LINE, y_stpo LIKE i_stpo OCCURS 0 WITH HEADER LINE, b_stpo LIKE i_stpo OCCURS 0 WITH HEADER LINE. DATA:i_model LIKE model OCCURS 0 WITH HEADER LINE. DATA: i_itab LIKE itab OCCURS 0 WITH HEADER LINE, y_itab LIKE itab OCCURS 0 WITH HEADER LINE, v_itab LIKE itab OCCURS 0 WITH HEADER LINE, t_itab LIKE itab OCCURS 0 WITH HEADER LINE, s_itab LIKE itab OCCURS 0 WITH HEADER LINE, z_itab LIKE itab OCCURS 0 WITH HEADER LINE, w_itab LIKE itab OCCURS 0 WITH HEADER LINE, x_itab LIKE itab OCCURS 0 WITH HEADER LINE, k_itab LIKE itab OCCURS 0 WITH HEADER LINE. DATA: lines LIKE tline OCCURS 0 WITH HEADER LINE. DATA:flag1 TYPE c,flag2 TYPE c,a TYPE i, del_flag LIKE i_itab-idnrk. DATA:point(4),C(3),b TYPE i. DATA:flag3 LIKE t_itab-frbom, flag4 LIKE t_itab-frbom. DATA:parent1 LIKE i_model-parent. DATA:idnrk1 LIKE s_itab-idnrk, stlnr1 LIKE s_itab-stlnr. DATA:aennr2 LIKE stpo-aennr, aennr4 LIKE t_itab-aennr, idnrk2 LIKE stpo-idnrk, stlnr2 LIKE i_itab-stlnr, stlkn2 LIKE i_itab-stlkn, frbom1 LIKE i_itab-frbom. DATA:i_aenr LIKE aenr OCCURS 0 WITH HEADER LINE. DATA:i_stko LIKE stko OCCURS 0 WITH HEADER LINE. DATA:BEGIN OF i_mast OCCURS 0, matnr LIKE mast-matnr, werks LIKE mast-werks, stlnr LIKE mast-stlnr, END OF i_mast. DATA:BEGIN OF i_mast1 OCCURS 0, matnr LIKE mast-matnr, werks LIKE mast-werks, stlnr LIKE mast-stlnr, END OF i_mast1. DATA:BEGIN OF i_change OCCURS 0, aennr LIKE aenr-aennr, stlnr LIKE stas-stlnr, END OF i_change. DATA:BEGIN OF t_stas OCCURS 0, aennr LIKE stas-aennr, stlnr LIKE stas-stlnr, stlkn LIKE stas-stlkn, stvkn LIKE stas-stvkn, datuv LIKE stas-datuv, lkenz LIKE stas-lkenz, END OF t_stas. DATA: BEGIN OF itab_alv OCCURS 0, aennr LIKE aenr-aennr, datuv LIKE aenr-datuv, aetxt LIKE aenr-aetxt, matnr LIKE mast-matnr, stlnr LIKE stas-stlnr, "20111115 Add maktx LIKE makt-maktx, cflag(20) TYPE c, indnr1 LIKE mast-matnr, maktx1 LIKE makt-maktx, indnr2 LIKE mast-matnr, maktx2 LIKE makt-maktx, menge1 LIKE stpo-menge, ebort1(400) TYPE c, menge2 LIKE stpo-menge, meins LIKE stpo-meins, ebort2(400) TYPE c, etext1(40) TYPE c, etext2(40) TYPE c, labor LIKE stko-labor, "add by ly 20160111 annam TYPE stpo-annam, "创建人 aenam TYPE stpo-aenam, "最后修人 labst TYPE mard-labst, "仓存量 针对子件的话,更改,删除的组件才有 labzt TYPE mdps-mng01, "在途数量 labzz TYPE mdps-mng01, "在制数量 labdy TYPE mdps-mng01, "库存待用量 netpr TYPE ekpo-netpr, "最近一次采购单价 labcg TYPE mdps-mng01, "采购在途数量 netcg TYPE ekpo-netpr, "新物料采购单价 meinc TYPE stpo-meins, "新料单位 mengx TYPE mseg-menge, "旧料实际消化数量 labox LIKE stko-labor, "更改后BOM版本 vgkzl LIKE stko-vgkzl, "前一项目计数器 END OF itab_alv. DATA:BEGIN OF itab_mard OCCURS 0,"add by ly 20160111 matnr TYPE mard-matnr, labst TYPE mard-labst, insme TYPE mard-insme, END OF itab_mard,"add by ly 20160111 BEGIN OF it_ekpo OCCURS 0, matnr TYPE ekpo-matnr, aedat TYPE ekpo-aedat, netpr TYPE ekpo-netpr, END OF it_ekpo. TYPES:BEGIN OF ty_mdps,"add by ly 20160111 matnr TYPE mard-matnr, mng01 TYPE mdps-mng01, END OF ty_mdps."add by ly 20160111 TYPES: BEGIN OF ty_tab, stlty LIKE stpo-stlty, "BOM类别 stlnr LIKE stpo-stlnr, "BOM号 matnr LIKE mara-matnr, "父料号 maktxf LIKE makt-maktx, "父料号描述 stlkn LIKE stpo-stlkn, " BOM项目节点号 stpoz LIKE stpo-stpoz, "内部计数器 datuv LIKE stpo-datuv, "有效起始时间 aennr LIKE stpo-aennr, "更改编号 vgknt LIKE stpo-vgknt, " 前一项目节点 vgpzl LIKE stpo-vgpzl, "前一项目计数器 idnrk LIKE stpo-idnrk, "项目组件号 maktx LIKE makt-maktx, "组件描述 postp LIKE stpo-postp, "项目类别 posnr LIKE stpo-posnr, "组件项目号 meins LIKE stpo-meins, "组件单位 menge LIKE stpo-menge, "组件数量 matnr1 LIKE mara-matnr, "更改前料号 maktx1 LIKE makt-maktx, "更改前料号描述 meins1 LIKE stpo-meins, "更改前组件单位 menge1 LIKE stpo-menge, "更改前组件数量 andat LIKE aenr-andat, "日期记录创建于 annam LIKE aenr-annam, "创建记录的用户 aetxt LIKE aenr-aetxt, "更改编号描述 aegru LIKE aenr-aegru, "更改原因 labor LIKE stko-labor, labox LIKE stko-labor, text(10) TYPE c, flag TYPE c, flag1 TYPE c, aenam LIKE aenr-aenam, "add by ly 20160111 labst TYPE mard-labst, "仓存量 针对子件的话,更改,删除的组件才有 labzt TYPE mdps-mng01, "在途数量 labzz TYPE mdps-mng01, "在制数量 labdy TYPE mdps-mng01, "库存待用量 netpr TYPE ekpo-netpr, "最近一次采购单价 labcg TYPE mdps-mng01, "采购在途数量 netcg TYPE ekpo-netpr, "新物料采购单价 meinc TYPE stpo-meins, "新料单位 mengx TYPE mseg-menge, "旧料实际消化数量 END OF ty_tab. DATA: tab1 TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE, tab2 TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE, tab3 TYPE STANDARD TABLE OF ty_tab WITH HEADER LINE. DATA:mdps_zz TYPE TABLE OF ty_mdps WITH HEADER LINE, mdps_zt TYPE TABLE OF ty_mdps WITH HEADER LINE. DATA:lt_mseg TYPE TABLE OF ty_mdps WITH HEADER LINE. DATA: BEGIN OF tmast OCCURS 0, matnr LIKE mast-matnr, werks LIKE mast-werks, stlnr LIKE mast-stlnr, stlal LIKE mast-stlal, END OF tmast. DEFINE rt_tab. CLEAR:&1. &1-LOW = &2. &1-HIGH = &3. &1-OPTION = &4. &1-SIGN = &5. APPEND &1. END-OF-DEFINITION. *&------------------------------------------------------------------* *& SELECT-OPTIONS *&------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001. *select-options:s_aennr for stpo-aennr obligatory. PARAMETERS:p_werks LIKE mast-werks OBLIGATORY DEFAULT '1010'. SELECT-OPTIONS:p_aennr FOR stpo-aennr . SELECT-OPTIONS:p_matnr FOR mast-matnr . SELECT-OPTIONS:s_matnr FOR mast-matnr . SELECT-OPTIONS:s_datuv FOR mast-aedat . PARAMETERS:p_bom TYPE c AS CHECKBOX USER-COMMAND bo. SELECTION-SCREEN END OF BLOCK block1. *&------------------------------------------------------------------* * TOP-OF-PAGE *&------------------------------------------------------------------* TOP-OF-PAGE. * PERFORM WRITE_TITLE. * PERFORM TOP_PAGE. *&------------------------------------------------------------------* * END-OF-PAGE *&------------------------------------------------------------------* END-OF-PAGE. *perform end_page. *&------------------------------------------------------------------* * START OF SELECTION *&------------------------------------------------------------------* START-OF-SELECTION. *&=====hmw 增加于2015-11-19===== IF s_matnr IS NOT INITIAL. PERFORM getroh. PERFORM fillfield USING g_alv_fieldcat[]. PERFORM build_eventtab USING g_alv_event[]. PERFORM build_comment USING g_alv_head[]. PERFORM build_layout USING g_alv_layout. PERFORM writeout. ELSE. PERFORM main. PERFORM initialize_fieldcat USING g_alv_fieldcat[]. PERFORM build_eventtab USING g_alv_event[]. PERFORM build_comment USING g_alv_head[]. PERFORM build_layout USING g_alv_layout. PERFORM writeoutput. ENDIF. *&------------------------------------------------------------------* *& Form MAIN *&------------------------------------------------------------------* * text *-------------------------------------------------------------------* * --> p1 text * <-- p2 text *-------------------------------------------------------------------* FORM main. PERFORM get-data. PERFORM output-data. ENDFORM. " MAIN *&------------------------------------------------------------------* *& Form get-data *&------------------------------------------------------------------* * text *-------------------------------------------------------------------* * --> p1 text * <-- p2 text *-------------------------------------------------------------------* FORM get-data. DATA:flag TYPE c. " IF p_matnr-low <> space. SELECT * FROM mast INTO CORRESPONDING FIELDS OF TABLE i_mast WHERE werks = p_werks AND matnr IN p_matnr. " ENDIF. IF NOT i_mast[] IS INITIAL. SELECT * FROM stas INTO CORRESPONDING FIELDS OF TABLE i_stas FOR ALL ENTRIES IN i_mast WHERE stlty = 'M' AND stlnr = i_mast-stlnr AND aennr IN p_aennr * AND AENNR <> SPACE AND lkenz <> 'X'. SELECT * FROM stko INTO CORRESPONDING FIELDS OF TABLE it_stko FOR ALL ENTRIES IN i_mast WHERE stlty = 'M' AND stlnr = i_mast-stlnr AND aennr IN p_aennr * AND AENNR <> SPACE AND lkenz <> 'X'. ELSE. SELECT * FROM stas INTO CORRESPONDING FIELDS OF TABLE i_stas WHERE stlty = 'M' AND aennr IN p_aennr AND lkenz <> 'X'. SELECT * FROM stko INTO CORRESPONDING FIELDS OF TABLE it_stko WHERE stlty = 'M' AND aennr IN p_aennr AND lkenz <> 'X'. ENDIF. LOOP AT it_stko. SELECT SINGLE matnr FROM mast INTO it_stko-matnr WHERE stlnr = it_stko-stlnr AND stlal = '01'. MODIFY it_stko.CLEAR it_stko. ENDLOOP. LOOP AT i_stas. SELECT SINGLE * FROM stpo WHERE stlnr = i_stas-stlnr AND stlkn = i_stas-stlkn AND aennr = i_stas-aennr. IF sy-subrc EQ 0. MOVE stpo-idnrk TO i_stpo-idnrk."BOM 组件 MOVE stpo-stlnr TO i_stpo-stlnr."物料单 MOVE stpo-stlkn TO i_stpo-stlkn."项目结点 MOVE stpo-stpoz TO i_stpo-stpoz."记数器 MOVE stpo-aennr TO i_stpo-aennr."更改号 MOVE stpo-menge TO i_stpo-menge."数量 MOVE stpo-meins TO i_stpo-meins."数量 MOVE stpo-posnr TO i_stpo-posnr."BOM 项目号 MOVE stpo-vgknt TO i_stpo-vgknt."前述节点 MOVE stpo-vgpzl TO i_stpo-vgpzl. APPEND i_stpo.CLEAR i_stpo. ENDIF. ENDLOOP. LOOP AT i_stpo WHERE vgknt = ' '. "新增BOM(y_stpo) MOVE: i_stpo-idnrk TO y_stpo-idnrk, i_stpo-stlnr TO y_stpo-stlnr, i_stpo-stlkn TO y_stpo-stlkn, i_stpo-stpoz TO y_stpo-stpoz, i_stpo-menge TO y_stpo-menge, i_stpo-meins TO y_stpo-meins, i_stpo-aennr TO y_stpo-aennr. APPEND y_stpo.CLEAR y_stpo. ENDLOOP. LOOP AT i_stpo WHERE vgknt <> ' '. "更改后bom(s_stpo) MOVE: i_stpo-idnrk TO s_stpo-idnrk, i_stpo-stlnr TO s_stpo-stlnr, i_stpo-stlkn TO s_stpo-stlkn, i_stpo-stpoz TO s_stpo-stpoz, i_stpo-menge TO s_stpo-menge, i_stpo-meins TO s_stpo-meins, i_stpo-posnr TO s_stpo-posnr, i_stpo-vgknt TO s_stpo-vgknt,"前述节点 i_stpo-vgpzl TO s_stpo-vgpzl, i_stpo-aennr TO s_stpo-aennr. APPEND s_stpo.CLEAR s_stpo. ENDLOOP. CLEAR stas.CLEAR stpo. REFRESH i_stpo.CLEAR i_stpo. IF NOT i_mast[] IS INITIAL. SELECT * FROM stas INTO CORRESPONDING FIELDS OF TABLE i_stpo "删除bom(v_stpo) FOR ALL ENTRIES IN i_mast WHERE aennr IN p_aennr AND stlnr = i_mast-stlnr AND lkenz = 'X'. ELSE. SELECT * FROM stas INTO CORRESPONDING FIELDS OF TABLE i_stpo "删除bom(v_stpo) WHERE aennr IN p_aennr AND lkenz = 'X'. ENDIF. SORT i_stpo BY stlnr. LOOP AT i_stpo. CLEAR stpo. SELECT SINGLE * FROM stpo WHERE stlnr = i_stpo-stlnr AND stlkn = i_stpo-stlkn. IF sy-subrc EQ 0. SELECT * FROM stpo WHERE stlnr = stpo-stlnr AND posnr = stpo-posnr. MOVE:stpo-stlnr TO b_stpo-stlnr, stpo-stlkn TO b_stpo-stlkn, stpo-posnr TO b_stpo-posnr. APPEND b_stpo.CLEAR b_stpo. ENDSELECT. ENDIF. IF sy-dbcnt = 1. MOVE-CORRESPONDING i_stpo TO v_stpo. MOVE stpo-idnrk TO v_stpo-idnrk. MOVE stpo-posnr TO v_stpo-posnr. MOVE stpo-menge TO v_stpo-menge. MOVE stpo-meins TO v_stpo-meins. MOVE stpo-stlnr TO v_stpo-stlnr. MOVE stpo-stlkn TO v_stpo-stlkn. MOVE stpo-stpoz TO v_stpo-stpoz. MOVE stpo-vgknt TO v_stpo-vgknt."前述节点 MOVE stpo-vgpzl TO v_stpo-vgpzl. APPEND v_stpo.CLEAR v_stpo. CLEAR b_stpo.REFRESH b_stpo. ENDIF. IF sy-dbcnt > 1. LOOP AT b_stpo. CLEAR stpo. SELECT SINGLE * FROM stpo WHERE stlnr = b_stpo-stlnr AND stlkn = b_stpo-stlkn AND posnr = b_stpo-posnr AND aennr NOT IN p_aennr. CHECK stpo-stlkn = i_stpo-stlkn. IF sy-subrc EQ 0. MOVE-CORRESPONDING i_stpo TO v_stpo. MOVE stpo-idnrk TO v_stpo-idnrk. MOVE stpo-posnr TO v_stpo-posnr. MOVE stpo-menge TO v_stpo-menge. MOVE stpo-meins TO v_stpo-meins. MOVE stpo-stlnr TO v_stpo-stlnr. MOVE stpo-stlkn TO v_stpo-stlkn. MOVE stpo-stpoz TO v_stpo-stpoz. MOVE stpo-vgknt TO i_stpo-vgknt."前述节点 MOVE stpo-vgpzl TO i_stpo-vgpzl. APPEND v_stpo.CLEAR v_stpo. ENDIF. ENDLOOP. CLEAR b_stpo.REFRESH b_stpo. ENDIF. ENDLOOP. **-------** LOOP AT v_stpo. CLEAR stpo. SELECT SINGLE * FROM stpo WHERE stlnr = v_stpo-stlnr AND vgknt = v_stpo-stlkn. IF sy-subrc EQ 0. DELETE v_stpo. ENDIF. ENDLOOP. **-------** *****存放地点************************************ LOOP AT y_stpo. PERFORM get_new-site TABLES y_stpo. "新增BOM(y_stpo) PERFORM prm_get_new USING y_stpo-idnrk. ENDLOOP. LOOP AT s_stpo. PERFORM get_changing-site TABLES s_stpo. "更改后bom(s_stpo) PERFORM prm_get_new USING s_stpo-idnrk. ENDLOOP. LOOP AT t_stpo. PERFORM get_changed-site TABLES t_stpo. "被更改bom(t_stpo) PERFORM prm_get_mard USING t_stpo-idnrk. PERFORM prm_get_mseg USING t_stpo-idnrk t_stpo-datuv. ENDLOOP. LOOP AT v_stpo. PERFORM get_delete-site TABLES v_stpo. "删除bom(v_stpo) PERFORM prm_get_mard USING v_stpo-idnrk. PERFORM prm_get_mseg USING v_stpo-idnrk v_stpo-datuv. ENDLOOP. ENDFORM. "get-data *&---------------------------------------------------------------------* *& Form output-data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM output-data. DATA:j TYPE i,i TYPE i, idnrk1 LIKE t_itab-idnrk, idnrk2 LIKE t_itab-idnrk, flag1 TYPE c,flag2 TYPE c. SORT t_itab BY aennr idnrk ebort. "新增记录 SORT i_itab BY aennr idnrk ebort. "更改后BOM SORT v_itab BY aennr idnrk ebort. "前一节点 SORT s_itab BY aennr idnrk ebort. "删除记录 SORT it_ekpo BY matnr ASCENDING aedat DESCENDING. DELETE ADJACENT DUPLICATES FROM it_ekpo COMPARING matnr aedat. **获取其他数据 PERFORM get_other-data. ************ 输 出 ************ SORT model BY aennr parent. DELETE ADJACENT DUPLICATES FROM model COMPARING aennr parent. LOOP AT model. **----- 新增bom ----** CLEAR idnrk1. SORT t_itab BY stlnr stlkn. DELETE ADJACENT DUPLICATES FROM t_itab COMPARING stlnr stlkn. LOOP AT t_itab WHERE frbom = model-parent AND aennr = model-aennr. itab_alv-aennr = t_itab-aennr. itab_alv-matnr = t_itab-frbom. itab_alv-stlnr = t_itab-stlnr. CHECK t_itab-idnrk <> idnrk1. idnrk1 = t_itab-idnrk. itab_alv-indnr2 = t_itab-idnrk. itab_alv-cflag = '增加物料'. itab_alv-menge2 = t_itab-menge. itab_alv-meinc = t_itab-meins. PERFORM output_new-add-bom-site CHANGING itab_alv-ebort2 itab_alv-ebort1. PERFORM output_new-add-bom-text CHANGING itab_alv-etext2. PERFORM prm_set_new USING t_itab-idnrk CHANGING itab_alv-labcg itab_alv-netcg. APPEND itab_alv.CLEAR itab_alv. ENDLOOP. ***------ 删除BOM -----** CLEAR idnrk1. SORT s_itab BY stlnr stlkn. DELETE ADJACENT DUPLICATES FROM s_itab COMPARING stlnr stlkn. LOOP AT s_itab WHERE frbom = model-parent AND aennr = model-aennr. itab_alv-aennr = s_itab-aennr. itab_alv-matnr = s_itab-frbom. itab_alv-stlnr = s_itab-stlnr. CHECK s_itab-idnrk <> idnrk1. idnrk1 = s_itab-idnrk. itab_alv-indnr1 = s_itab-idnrk. itab_alv-cflag = '删除物料'. itab_alv-menge1 = s_itab-menge. itab_alv-meins = s_itab-meins. PERFORM output_delete-bom-ebort CHANGING itab_alv-ebort1 itab_alv-ebort2. PERFORM output_delete-bom-text CHANGING itab_alv-etext1. PERFORM prm_set_mard USING itab_alv-indnr1 CHANGING itab_alv-labst itab_alv-labzt itab_alv-labzz itab_alv-labdy itab_alv-netpr. PERFORM prm_set_mseg USING itab_alv-indnr1 CHANGING itab_alv-mengx. APPEND itab_alv.CLEAR itab_alv. ENDLOOP. **---- 更改后bom ----** CLEAR idnrk1. SORT i_itab BY stlnr stlkn. DELETE ADJACENT DUPLICATES FROM i_itab COMPARING stlnr stlkn vgknt. LOOP AT i_itab WHERE frbom = model-parent AND aennr = model-aennr. itab_alv-aennr = i_itab-aennr. itab_alv-matnr = i_itab-frbom. itab_alv-stlnr = i_itab-stlnr. CHECK i_itab-idnrk <> idnrk1. idnrk1 = i_itab-idnrk. * read table t_stpo with key vgknt = i_itab-STLKN. SELECT SINGLE * FROM stpo WHERE stlnr = i_itab-stlnr AND stlkn = i_itab-vgknt AND stlty = 'M'. IF stpo-idnrk <> i_itab-idnrk. itab_alv-cflag = '更改物料'. itab_alv-indnr2 = i_itab-idnrk. itab_alv-indnr1 = stpo-idnrk. itab_alv-menge2 = stpo-menge. itab_alv-meinc = i_itab-meins. itab_alv-meins = stpo-meins. itab_alv-menge1 = i_itab-menge. ENDIF. IF stpo-menge <> i_itab-menge. itab_alv-cflag = '更改数量'. itab_alv-menge2 = i_itab-menge. itab_alv-menge1 = stpo-menge. itab_alv-indnr2 = i_itab-idnrk. itab_alv-indnr1 = stpo-idnrk. itab_alv-meinc = i_itab-meins. itab_alv-meins = stpo-meins. ELSE. IF stpo-idnrk = i_itab-idnrk. itab_alv-cflag = '更改位号或组件文本'. itab_alv-indnr2 = i_itab-idnrk. itab_alv-indnr1 = stpo-idnrk. itab_alv-meinc = i_itab-meins. itab_alv-meins = stpo-meins. itab_alv-menge2 = stpo-menge. itab_alv-menge1 = i_itab-menge. ENDIF. ENDIF. PERFORM output_changed-bom-site CHANGING itab_alv-ebort2 itab_alv-ebort1. PERFORM output_changed-bom-text CHANGING itab_alv-etext2 itab_alv-etext1. PERFORM prm_set_mard USING itab_alv-indnr1 CHANGING itab_alv-labst itab_alv-labzt itab_alv-labzz itab_alv-labdy itab_alv-netpr. PERFORM prm_set_new USING itab_alv-indnr2 CHANGING itab_alv-labcg itab_alv-netcg. PERFORM prm_set_mseg USING itab_alv-indnr1 CHANGING itab_alv-mengx. APPEND itab_alv.CLEAR itab_alv. ENDLOOP. ENDLOOP. IF p_bom IS NOT INITIAL. LOOP AT it_stko. itab_alv-matnr = it_stko-matnr. itab_alv-aennr = it_stko-aennr. itab_alv-stlnr = it_stko-stlnr. itab_alv-labor = it_stko-labor. itab_alv-vgkzl = it_stko-vgkzl. "前一项目计数器 itab_alv-cflag = '更改BOM版本'. APPEND itab_alv.CLEAR itab_alv. ENDLOOP. ENDIF. LOOP AT itab_alv. SELECT SINGLE maktx INTO itab_alv-maktx1 FROM makt WHERE matnr = itab_alv-indnr1. SELECT SINGLE maktx INTO itab_alv-maktx2 FROM makt WHERE matnr = itab_alv-indnr2. SELECT SINGLE maktx INTO itab_alv-maktx FROM makt WHERE matnr = itab_alv-matnr. SELECT SINGLE datuv aegru aenam annam INTO (itab_alv-datuv , itab_alv-aetxt , itab_alv-aenam , itab_alv-annam) FROM aenr WHERE aennr = itab_alv-aennr AND datuv IN s_datuv. IF sy-subrc = 0. MODIFY itab_alv. ELSE. DELETE itab_alv. ENDIF. CLEAR itab_alv. ENDLOOP. SORT itab_alv BY aennr matnr. SELECT * FROM mast INTO CORRESPONDING FIELDS OF TABLE i_mast1 FOR ALL ENTRIES IN itab_alv WHERE werks = p_werks AND matnr = itab_alv-matnr. IF NOT i_mast1[] IS INITIAL. SELECT * FROM stko INTO CORRESPONDING FIELDS OF TABLE it_stko_all FOR ALL ENTRIES IN i_mast1 WHERE stlty = 'M' AND stlnr = i_mast1-stlnr AND lkenz <> 'X'. * LOOP AT it_stko_all. * READ TABLE i_mast1 WITH KEY stlnr = it_stko_all-stlnr. * IF sy-subrc = 0. * it_stko_all-matnr = i_mast1-matnr. * MODIFY it_stko_all.CLEAR it_stko_all. * ENDIF. * ENDLOOP. * * * LOOP AT it_stko_all. * MOVE-CORRESPONDING it_stko_all TO it_matnr. * COLLECT it_matnr.CLEAR it_matnr. * ENDLOOP. * * LOOP AT it_stko_all. * MOVE-CORRESPONDING it_stko_all TO it_stko_end. * APPEND it_stko_end.CLEAR it_stko_end. * ENDLOOP. * * * LOOP AT it_matnr. * i = 1. * LOOP AT it_stko_end WHERE stlnr = it_matnr-stlnr. * it_stko_end-datuv1 = '99999999'. * i = i + 1. * j = 0. * LOOP AT it_stko_all WHERE stlnr = it_matnr-stlnr. * j = j + 1. * IF j = i. * it_stko_end-datuv1 = it_stko_all-datuv. * ENDIF. * ENDLOOP. * MODIFY it_stko_end. * ENDLOOP. * CLEAR it_stko_end. * ENDLOOP. LOOP AT itab_alv. * itab_alv-labox = itab_alv-labor."版本变更 * LOOP AT it_stko_end WHERE stlnr = itab_alv-stlnr. "STLNR Replace Matnr * IF itab_alv-datuv >= it_stko_end-datuv AND itab_alv-datuv < it_stko_end-datuv1. * itab_alv-labor = it_stko_end-labor. * MODIFY itab_alv. * CLEAR itab_alv. * ENDIF. * ENDLOOP. READ TABLE it_stko_all WITH KEY stlnr = itab_alv-stlnr stkoz = itab_alv-vgkzl. IF sy-subrc = 0. itab_alv-labox = it_stko_all-labor. MODIFY itab_alv. CLEAR itab_alv. ENDIF. ENDLOOP. ENDIF. ENDFORM. "output-data *&---------------------------------------------------------------------* *& Form get_other-data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_other-data. **-------select Parent bom -----** **更改/删除/新增BOM描述/长项目文本 PERFORM get_parent-bom. **--------- 存放地点 -----------** PERFORM get_set-place. **--------- 安装地点长度 -------** PERFORM get_length. ENDFORM. " get_other-data *&---------------------------------------------------------------------* *& Form get_Parent-bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_parent-bom. LOOP AT t_itab. ** 父件及其描述 CLEAR t_itab-name. PERFORM change_bom USING t_itab-stlnr CHANGING t_itab-frbom. MODIFY t_itab. ** other usage MOVE t_itab-frbom TO model-parent. MOVE t_itab-aennr TO model-aennr. APPEND model.CLEAR model. ENDLOOP. LOOP AT i_itab. ** 父件及其描述 CLEAR i_itab-name. PERFORM change_bom USING i_itab-stlnr CHANGING i_itab-frbom. MODIFY i_itab. ** other usage. MOVE i_itab-frbom TO model-parent. MOVE i_itab-aennr TO model-aennr. APPEND model.CLEAR model. ENDLOOP. LOOP AT v_itab. ** 父件及其描述 CLEAR v_itab-name. PERFORM change_bom USING v_itab-stlnr CHANGING v_itab-frbom. MODIFY v_itab. ** other usage. MOVE v_itab-frbom TO model-parent. MOVE v_itab-aennr TO model-aennr. APPEND model.CLEAR model. ENDLOOP. LOOP AT s_itab. ** 父件及其描述 CLEAR s_itab-name. PERFORM change_bom USING s_itab-stlnr CHANGING s_itab-frbom. MODIFY s_itab. MOVE s_itab-frbom TO model-parent. MOVE s_itab-aennr TO model-aennr. APPEND model.CLEAR model. ENDLOOP. SORT model BY parent. DELETE ADJACENT DUPLICATES FROM model COMPARING aennr parent. ENDFORM. " get_Parent-bom *&---------------------------------------------------------------------* *& Form change_bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_T_ITAB_STLNR text * <--P_T_ITAB_FRBOM text * <--P_T_ITAB_MAKTX1 text *----------------------------------------------------------------------* FORM change_bom USING v_stlnr CHANGING v_frbom. DATA:v_name LIKE thead-tdname. SELECT SINGLE * FROM mast WHERE stlnr = v_stlnr AND stlal = '01'. IF sy-subrc EQ 0. MOVE mast-matnr TO v_frbom. ENDIF. CLEAR mast. MOVE v_frbom TO v_name. CLEAR v_name. ENDFORM. " change_bom *&---------------------------------------------------------------------* *& Form get_set-place *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_set-place. **------ 更改后BOM存放地点 -----** PERFORM set_i_itab. **------ 删除BOM存放地点 -------** PERFORM set_delete-bom. **------ 新增BOM存放地点 -------** PERFORM set_new-bom. **------ 被更改BOM存放地点 -----** PERFORM set_changed-bom. ENDFORM. " get_set-place *&---------------------------------------------------------------------* *& Form get_length *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_length. DATA:lin TYPE i. LOOP AT y_itab. CONDENSE y_itab-ebort NO-GAPS. lin = strlen( y_itab-ebort ). MOVE lin TO y_itab-lin. IF lin > 10. MOVE 'X' TO y_itab-ebort1. ENDIF. MODIFY y_itab. CLEAR lin. ENDLOOP. LOOP AT w_itab. CONDENSE w_itab-ebort NO-GAPS. lin = strlen( w_itab-ebort ). MOVE lin TO w_itab-lin. IF lin > 10. MOVE 'X' TO w_itab-ebort1. ENDIF. MODIFY w_itab. CLEAR lin. ENDLOOP. LOOP AT x_itab. CONDENSE x_itab-ebort NO-GAPS. lin = strlen( x_itab-ebort ). MOVE lin TO x_itab-lin. IF lin > 10. MOVE 'X' TO x_itab-ebort1. ENDIF. MODIFY x_itab. CLEAR lin. ENDLOOP. SORT y_itab BY idnrk lin ebort. SORT w_itab BY idnrk lin ebort. SORT x_itab BY idnrk lin ebort. ENDFORM. " get_length *&---------------------------------------------------------------------* *& Form get_new-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_Y_STPO text *----------------------------------------------------------------------* FORM get_new-site TABLES p_stpo LIKE y_stpo[]. DATA:flag TYPE c. CLEAR flag.CLEAR stpu. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO t_itab. MOVE stpu-ebort TO t_itab-ebort. flag = 'X'. APPEND t_itab.CLEAR t_itab. ENDSELECT. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO t_itab. MOVE stpu-ebort TO t_itab-ebort2. flag = 'X'. APPEND t_itab.CLEAR t_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO t_itab. MOVE stpo-potx1 TO t_itab-potx1. flag = 'X'. APPEND t_itab.CLEAR t_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO t_itab. MOVE stpo-potx1 TO t_itab-potx2. flag = 'X'. APPEND t_itab.CLEAR t_itab. ENDSELECT. IF flag <> 'X'. MOVE-CORRESPONDING p_stpo TO t_itab. APPEND t_itab.CLEAR t_itab. ENDIF. ENDFORM. " get_new-site *&---------------------------------------------------------------------* *& Form get_changing-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_S_STPO text *----------------------------------------------------------------------* FORM get_changing-site TABLES p_stpo LIKE s_stpo[]. DATA:flag TYPE c. CLEAR flag.CLEAR stpu. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO i_itab. MOVE stpu-ebort TO i_itab-ebort. flag = 'X'. APPEND i_itab.CLEAR i_itab. ENDSELECT. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO i_itab. MOVE stpu-ebort TO i_itab-ebort2. flag = 'X'. APPEND i_itab.CLEAR i_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO i_itab. MOVE stpo-potx1 TO i_itab-potx1. flag = 'X'. APPEND i_itab.CLEAR i_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO i_itab. MOVE stpo-potx1 TO i_itab-potx2. flag = 'X'. APPEND i_itab.CLEAR i_itab. ENDSELECT. IF flag <> 'X'. MOVE-CORRESPONDING p_stpo TO i_itab. APPEND i_itab.CLEAR i_itab. ENDIF. ENDFORM. " get_changing-site *&---------------------------------------------------------------------* *& Form get_changed-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_T_STPO text *----------------------------------------------------------------------* FORM get_changed-site TABLES p_stpo LIKE t_stpo[]. DATA:flag TYPE c. CLEAR flag.CLEAR stpu. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO v_itab. MOVE stpu-ebort TO v_itab-ebort. flag = 'X'. APPEND v_itab.CLEAR v_itab. ENDSELECT. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO v_itab. MOVE stpu-ebort TO v_itab-ebort2. flag = 'X'. APPEND v_itab.CLEAR v_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO v_itab. MOVE stpo-potx1 TO v_itab-potx1. flag = 'X'. APPEND v_itab.CLEAR v_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO v_itab. MOVE stpo-potx1 TO v_itab-potx2. flag = 'X'. APPEND v_itab.CLEAR v_itab. ENDSELECT. IF flag <> 'X'. MOVE-CORRESPONDING p_stpo TO v_itab. APPEND v_itab.CLEAR v_itab. ENDIF. "ADD BY LY 20160111 * IF p_stpo-idnrk IS NOT INITIAL. * SELECT labst insme * INTO ( itab_mard-labst,itab_mard-insme ) * FROM mard * WHERE matnr = p_stpo-idnrk * AND werks = p_werks. * COLLECT itab_mard. * ENDSELECT. * ENDIF. "ADD BY LY 20160111 ENDFORM. " get_changed-site *&---------------------------------------------------------------------* *& Form get_delete-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_V_STPO text *----------------------------------------------------------------------* FORM get_delete-site TABLES p_stpo LIKE v_stpo[]. DATA:flag TYPE c. CLEAR flag.CLEAR stpu. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO s_itab. MOVE stpu-ebort TO s_itab-ebort. flag = 'X'. APPEND s_itab.CLEAR s_itab. ENDSELECT. SELECT * FROM stpu WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO s_itab. MOVE stpu-ebort TO s_itab-ebort2. flag = 'X'. APPEND s_itab.CLEAR s_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-stlkn. MOVE-CORRESPONDING p_stpo TO s_itab. MOVE stpo-potx1 TO s_itab-potx1. flag = 'X'. APPEND s_itab.CLEAR s_itab. ENDSELECT. SELECT * FROM stpo WHERE stlnr = p_stpo-stlnr AND stlkn = p_stpo-vgknt. MOVE-CORRESPONDING p_stpo TO s_itab. MOVE stpo-potx1 TO s_itab-potx2. flag = 'X'. APPEND s_itab.CLEAR s_itab. ENDSELECT. IF flag <> 'X'. MOVE-CORRESPONDING p_stpo TO s_itab. APPEND s_itab.CLEAR s_itab. ENDIF. "ADD BY LY 20160111 * IF p_stpo-idnrk IS NOT INITIAL. * SELECT matnr labst insme * INTO itab_mard * FROM mard * WHERE matnr = p_stpo-idnrk * AND werks = p_werks. * COLLECT itab_mard. * ENDSELECT. * ENDIF. "ADD BY LY 20160111 ENDFORM. " get_delete-site *&---------------------------------------------------------------------* *& Form set_i_itab *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM set_i_itab. REFRESH y_itab.CLEAR y_itab. LOOP AT i_itab. IF i_itab-ebort <> '' OR i_itab-ebort2 <> ''. MOVE: i_itab-aennr TO y_itab-aennr, i_itab-idnrk TO y_itab-idnrk, i_itab-stlkn TO y_itab-stlkn, i_itab-stlnr TO y_itab-stlnr, i_itab-ebort TO y_itab-ebort, i_itab-vgknt TO y_itab-vgknt, i_itab-ebort2 TO y_itab-ebort2, i_itab-potx1 TO y_itab-potx1, i_itab-potx2 TO y_itab-potx2. APPEND y_itab.CLEAR y_itab. ENDIF. ENDLOOP. LOOP AT i_itab. IF i_itab-potx1 <> '' OR i_itab-potx2 <> ''. MOVE: i_itab-aennr TO y_itab-aennr, i_itab-idnrk TO y_itab-idnrk, i_itab-stlkn TO y_itab-stlkn, i_itab-stlnr TO y_itab-stlnr, i_itab-ebort TO y_itab-ebort, i_itab-vgknt TO y_itab-vgknt, i_itab-ebort2 TO y_itab-ebort2, i_itab-potx1 TO y_itab-potx1, i_itab-potx2 TO y_itab-potx2. APPEND y_itab.CLEAR y_itab. ENDIF. ENDLOOP. ENDFORM. " set_i_itab *&---------------------------------------------------------------------* *& Form set_delete-bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM set_delete-bom. LOOP AT s_itab. MOVE-CORRESPONDING s_itab TO x_itab. APPEND x_itab.CLEAR x_itab. ENDLOOP. ENDFORM. " set_delete-bom *&---------------------------------------------------------------------* *& Form set_new-bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM set_new-bom. LOOP AT t_itab. MOVE-CORRESPONDING t_itab TO w_itab. APPEND w_itab.CLEAR w_itab. ENDLOOP. ENDFORM. " set_new-bom *&---------------------------------------------------------------------* *& Form output_new-add-bom-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM output_new-add-bom-site CHANGING p_ebort p_ebort1. DATA:sing5 TYPE c. CLEAR: a,b. LOOP AT w_itab WHERE idnrk = t_itab-idnrk AND stlnr = t_itab-stlnr AND stlkn = t_itab-stlkn. IF w_itab-ebort <> ''. CONCATENATE p_ebort w_itab-ebort ',' INTO p_ebort. ENDIF. ENDLOOP. LOOP AT w_itab WHERE idnrk = t_itab-idnrk AND stlnr = t_itab-stlnr AND vgknt = t_itab-vgknt. IF w_itab-ebort2 <> ''. CONCATENATE p_ebort1 w_itab-ebort2 ',' INTO p_ebort1. ENDIF. ENDLOOP. *** 长项目文本 * PERFORM SHOW_POTX1-POTX10 * USING W_ITAB-EBORT * W_ITAB-POTX1 W_ITAB-POTX2 * W_ITAB-POTX3 W_ITAB-POTX4 * W_ITAB-POTX5 W_ITAB-POTX6 * W_ITAB-POTX7 W_ITAB-POTX8 * W_ITAB-POTX9 W_ITAB-POTX10. ENDFORM. " output_new-add-bom-site *&---------------------------------------------------------------------* *& Form output_delete-bom-ebort *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM output_delete-bom-ebort CHANGING p_ebort p_ebort1. DATA:sing4 TYPE c. CLEAR:a ,b. LOOP AT x_itab WHERE idnrk = s_itab-idnrk AND stlnr = s_itab-stlnr AND stlkn = s_itab-stlkn. IF x_itab-ebort <> ''. CONCATENATE p_ebort x_itab-ebort ',' INTO p_ebort. ENDIF. ENDLOOP. LOOP AT x_itab WHERE idnrk = s_itab-idnrk AND stlnr = s_itab-stlnr AND vgknt = s_itab-vgknt. IF x_itab-ebort2 <> ''. CONCATENATE p_ebort1 x_itab-ebort2 ',' INTO p_ebort1. ENDIF. ENDLOOP. ENDFORM. " output_delete-bom-ebort *&---------------------------------------------------------------------* *& Form output_changed-bom-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM output_changed-bom-site CHANGING p_ebort p_ebort1. DATA:sing TYPE c. CLEAR:a,b. LOOP AT y_itab WHERE aennr = i_itab-aennr AND idnrk = i_itab-idnrk AND stlkn = i_itab-stlkn AND stlnr = i_itab-stlnr. IF y_itab-ebort <> ''. CONCATENATE p_ebort y_itab-ebort ',' INTO p_ebort. ENDIF. ENDLOOP. LOOP AT y_itab WHERE aennr = i_itab-aennr AND idnrk = i_itab-idnrk AND stlnr = i_itab-stlnr AND vgknt = i_itab-vgknt. IF y_itab-ebort2 <> ''. CONCATENATE p_ebort1 y_itab-ebort2 ',' INTO p_ebort1. ENDIF. ENDLOOP. *****长项目文本****** * PERFORM SHOW_POTX1-POTX10 * USING I_ITAB-EBORT * I_ITAB-POTX1 I_ITAB-POTX2 * I_ITAB-POTX3 I_ITAB-POTX4 * I_ITAB-POTX5 I_ITAB-POTX6 * I_ITAB-POTX7 I_ITAB-POTX8 * I_ITAB-POTX9 I_ITAB-POTX10. ENDFORM. " output_changed-bom-site *&---------------------------------------------------------------------* *& Form output_changing-bom-site *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM output_changing-bom-site CHANGING p_ebort p_ebort1. DATA:sing TYPE c. CLEAR:a,b,sing. LOOP AT k_itab WHERE idnrk = v_itab-idnrk AND stlnr = v_itab-stlnr AND stlkn = v_itab-stlkn. CONCATENATE p_ebort k_itab-ebort ',' INTO p_ebort. ****长项目存放地点** * PERFORM SHOW_POTX1-POTX10 * USING S_ITAB-EBORT * S_ITAB-POTX1 S_ITAB-POTX2 * S_ITAB-POTX3 S_ITAB-POTX4 * S_ITAB-POTX5 S_ITAB-POTX6 * S_ITAB-POTX7 S_ITAB-POTX8 * S_ITAB-POTX9 S_ITAB-POTX10. ENDLOOP. LOOP AT k_itab WHERE idnrk = v_itab-idnrk AND stlnr = v_itab-stlnr AND vgknt = v_itab-vgknt. IF k_itab-ebort2 <> ''. CONCATENATE p_ebort1 k_itab-ebort2 ',' INTO p_ebort1. ENDIF. ENDLOOP. ENDFORM. " output_changing-bom-site *&---------------------------------------------------------------------* *& Form set_changed-bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM set_changed-bom. LOOP AT v_itab. MOVE-CORRESPONDING v_itab TO k_itab. APPEND k_itab.CLEAR k_itab. ENDLOOP. ENDFORM. " set_changed-bom *&---------------------------------------------------------------------* *& Form BUILD_EVENTTAB *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_EVENTS text *----------------------------------------------------------------------* FORM build_eventtab USING p_events TYPE slis_t_event. DATA: ls_event TYPE slis_alv_event. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING i_list_type = 0 IMPORTING et_events = p_events. READ TABLE p_events WITH KEY name = slis_ev_top_of_page INTO ls_event. IF sy-subrc = 0. MOVE g_alv_formname_top_of_page TO ls_event-form. APPEND ls_event TO p_events. ENDIF. ENDFORM. "BUILD_EVENTTAB *&---------------------------------------------------------------------* *& Form BUILD_COMMENT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_HEADING text *----------------------------------------------------------------------* FORM build_comment USING p_heading TYPE slis_t_listheader. DATA: hline TYPE slis_listheader, text(60) TYPE c, sep(20) TYPE c. CLEAR: hline, text. hline-typ = 'S'. WRITE: '列表人:' TO text, sy-uname TO text+8, '列表时间:' TO text+22, sy-datum TO text+32, '-' TO text+42, sy-uzeit TO text+43. hline-info = text. APPEND hline TO p_heading. WRITE: '制表人:' TO text, '标准化审核:' TO text+30. hline-info = text. APPEND hline TO p_heading. WRITE: '认证审核:' TO text, '批准:' TO text+20, '报表编号:' TO text+40. hline-info = text. APPEND hline TO p_heading. ENDFORM. "BUILD_COMMENT *&---------------------------------------------------------------------* *& Form BUILD_LAYOUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LAYOUT text *----------------------------------------------------------------------* FORM build_layout USING p_layout TYPE slis_layout_alv. p_layout-get_selinfos = 'X'. p_layout-detail_popup = 'X'. p_layout-no_keyfix = 'X'. p_layout-colwidth_optimize = 'X'. ENDFORM. "BUILD_LAYOUT *&---------------------------------------------------------------------* *& Form WRITEOUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM writeoutput. * delete ITAB_ALV where AENNR is INITIAL. LOOP AT itab_alv. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = itab_alv-matnr IMPORTING output = itab_alv-matnr. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = itab_alv-indnr1 IMPORTING output = itab_alv-indnr1. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = itab_alv-indnr2 IMPORTING output = itab_alv-indnr2. MODIFY itab_alv. ENDLOOP. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_BUFFER_ACTIVE = 'X' i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND' is_layout = g_alv_layout it_fieldcat = g_alv_fieldcat i_save = 'A' " I_STRUCTURE_NAME = 'ITAB1' i_grid_title = 'BOM工程更改记录报表' "NEED MODIFY TABLES t_outtab = itab_alv EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. "WRITEOUTPUT FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. * CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' * IMPORTING * E_GRID = L_GRID. * CALL METHOD L_GRID->CHECK_CHANGED_DATA. * RS_SELFIELD-REFRESH = 'X'. CASE r_ucomm. WHEN '&IC1'. READ TABLE itab_alv INDEX rs_selfield-tabindex. SET PARAMETER ID 'AEN' FIELD itab_alv-aennr. CALL TRANSACTION 'CC03' AND SKIP FIRST SCREEN. ENDCASE. * CALL METHOD L_GRID->REFRESH_TABLE_DISPLAY. ENDFORM. "USER_COMMAND *&---------------------------------------------------------------------* *& Form INITIALIZE_FIELDCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_FIELDTAB text *----------------------------------------------------------------------* FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv. DATA: l_fieldcat TYPE slis_fieldcat_alv. DATA : col_pos TYPE i VALUE 0. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'AENNR'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'ECN号码'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-ref_tabname = 'ITAB_ALV'. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'DATUV'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-no_zero = 'X'. l_fieldcat-seltext_l = 'ECN日期'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'AETXT'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '更改原因'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-ref_tabname = 'ITAB_ALV'. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABOR'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'BOM版本'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABOX'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '更改后BOM版本'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MATNR'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '父件料号'. APPEND l_fieldcat TO p_fieldtab. CLEAR l_fieldcat. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MAKTX'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '父件描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'CFLAG'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改类型'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'INDNR1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前子件料号'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MAKTX1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的物料描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'INDNR2'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的子件编码'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MAKTX2'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的物料描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MENGE1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MEINS'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '单位'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MENGX'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '旧料实际消化数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'EBORT1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的位号'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MENGE2'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABST'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '仓存量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABZT'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '在途数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABZZ'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '在制数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABDY'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '库存待用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'NETPR'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '单价'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABCG'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '新料采购在途量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'NETCG'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '新料单价'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MEINC'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '新料单位'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'EBORT2'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的位号'. APPEND l_fieldcat TO p_fieldtab. CLEAR l_fieldcat. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'ETEXT1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的组件文本备注'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'ETEXT2'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的组件文本备注'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'ANNAM'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '记录创建人'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'AENAM'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '记录修改人'. APPEND l_fieldcat TO p_fieldtab. ENDFORM. "INITIALIZE_FIELDCAT *&---------------------------------------------------------------------* *& Form OUTPUT_CHANGED-BOM-TEXT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_ITAB_ALV_ETEXT2 text * <--P_ITAB_ALV_ETEXT1 text *----------------------------------------------------------------------* FORM output_changed-bom-text CHANGING p_itab_alv_etext2 p_itab_alv_etext1. DATA:sing TYPE c. CLEAR:a,b. LOOP AT y_itab WHERE aennr = i_itab-aennr AND idnrk = i_itab-idnrk AND stlkn = i_itab-stlkn AND stlnr = i_itab-stlnr AND potx1 <> ''. p_itab_alv_etext2 = y_itab-potx1. ENDLOOP. LOOP AT y_itab WHERE aennr = i_itab-aennr AND idnrk = i_itab-idnrk AND stlkn = i_itab-stlkn AND vgknt = i_itab-vgknt AND potx2 <> ''. p_itab_alv_etext1 = y_itab-potx2. ENDLOOP. ENDFORM. " OUTPUT_CHANGED-BOM-TEXT *&---------------------------------------------------------------------* *& Form OUTPUT_DELETE-BOM-TEXT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_ITAB_ALV_ETEXT1 text *----------------------------------------------------------------------* FORM output_delete-bom-text CHANGING p_itab_alv_etext1. DATA:sing4 TYPE c. CLEAR:a ,b. LOOP AT x_itab WHERE idnrk = s_itab-idnrk AND stlnr = s_itab-stlnr AND vgknt = s_itab-vgknt. p_itab_alv_etext1 = s_itab-potx2. ENDLOOP. ENDFORM. " OUTPUT_DELETE-BOM-TEXT *&---------------------------------------------------------------------* *& Form OUTPUT_NEW-ADD-BOM-TEXT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_ITAB_ALV_ETEXT2 text *----------------------------------------------------------------------* FORM output_new-add-bom-text CHANGING p_itab_alv_etext2. DATA:sing5 TYPE c. CLEAR: a,b. LOOP AT w_itab WHERE idnrk = t_itab-idnrk AND stlnr = t_itab-stlnr AND stlkn = t_itab-stlkn. p_itab_alv_etext2 = t_itab-potx2. ENDLOOP. ENDFORM. " OUTPUT_NEW-ADD-BOM-TEXT *Text elements *---------------------------------------------------------- * 001 输入查询条件 *Selection texts *---------------------------------------------------------- * P_AENNR ECN变更号码 * P_ANDAT 变更日期 * P_MATNR 产品编码 * P_WERKS 工厂 *&---------------------------------------------------------------------* *& Form GETROH *&---------------------------------------------------------------------* FORM getroh . CLEAR: tab1,tab2. REFRESH:tab1,tab2. SELECT stlty stlnr stlkn stpoz datuv aennr vgknt vgpzl idnrk postp posnr meins menge "当前组件状态 FROM stpo INTO CORRESPONDING FIELDS OF TABLE tab1 WHERE aennr IN p_aennr AND idnrk IN s_matnr AND lkenz = '' AND aennr NE '' "更改号不能为空 . IF tab1[] IS INITIAL. MESSAGE '没有适合条件的数据,核对数据输入是否正确!' TYPE 'E'. ENDIF. LOOP AT tab1. IF tab1-vgknt = '00000000'. tab1-flag = 'X'. tab1-text = '组件新增'. ELSE. tab1-text = '组件变更'. ENDIF. MODIFY tab1. CLEAR tab1. ENDLOOP. " if p_matnr is not initial. "只取指定成品的修改记录 IF tab1[] IS NOT INITIAL. SELECT matnr werks stlnr stlal FROM mast INTO CORRESPONDING FIELDS OF TABLE tmast FOR ALL ENTRIES IN tab1 WHERE werks = p_werks AND matnr IN p_matnr AND stlan = '1' AND stlnr = tab1-stlnr . ENDIF. IF tmast[] IS NOT INITIAL. SORT tmast BY matnr werks stlal. DELETE ADJACENT DUPLICATES FROM tmast COMPARING matnr werks stlal. LOOP AT tab1. READ TABLE tmast WITH KEY stlnr = tab1-stlnr. IF sy-subrc NE 0. tab1-flag1 = 'X'. ENDIF. MODIFY tab1. CLEAR tab1. ENDLOOP. DELETE tab1 WHERE flag1 = 'X'. ENDIF. " endif. IF tab1[] IS NOT INITIAL. SELECT stlty stlnr stlkn stpoz datuv aennr vgknt vgpzl idnrk postp posnr meins menge "更改前组件状态 FROM stpo INTO CORRESPONDING FIELDS OF TABLE tab2 FOR ALL ENTRIES IN tab1 WHERE stlty = tab1-stlty "BPM类别 AND stlnr = tab1-stlnr "BOM号 AND stlkn = tab1-vgknt "前一节点 AND stpoz = tab1-vgpzl "前一节点计数器 AND aennr NE tab1-aennr "更改号不等于当前更改号 AND posnr = tab1-posnr "组件项目号 . ENDIF. LOOP AT tab1. "把修改前的数据放到输出表 READ TABLE tab2 WITH KEY stlty = tab1-stlty stlnr = tab1-stlnr stlkn = tab1-vgknt stpoz = tab1-vgpzl posnr = tab1-posnr. IF sy-subrc = 0. tab1-matnr1 = tab2-idnrk. tab1-meins1 = tab2-meins. tab1-menge1 = tab2-menge. PERFORM prm_get_mard USING tab1-matnr1. PERFORM prm_get_mseg USING tab1-matnr1 tab1-datuv. ENDIF. PERFORM prm_get_new USING tab1-idnrk. MODIFY tab1. CLEAR tab1. ENDLOOP. LOOP AT tab1. SELECT SINGLE matnr INTO tab1-matnr FROM mast WHERE werks = p_werks AND stlan = '1' AND stlnr = tab1-stlnr. IF sy-subrc = 0. SELECT SINGLE maktx INTO tab1-maktxf FROM makt WHERE spras = '1' AND matnr = tab1-matnr. ENDIF. SELECT SINGLE maktx INTO tab1-maktx FROM makt WHERE spras = '1' AND matnr = tab1-idnrk. SELECT SINGLE maktx INTO tab1-maktx1 FROM makt WHERE spras = '1' AND matnr = tab1-matnr1. SELECT SINGLE andat annam aenam aetxt aegru INTO (tab1-andat,tab1-annam,tab1-aenam,tab1-aetxt,tab1-aegru) FROM aenr WHERE aennr = tab1-aennr AND andat IN s_datuv. IF sy-subrc = 0. MODIFY tab1. ELSE. DELETE tab1. ENDIF. CLEAR tab1. ENDLOOP. LOOP AT tab1. PERFORM prm_set_new USING tab1-idnrk CHANGING tab1-labcg tab1-netcg. PERFORM prm_set_mard USING tab1-matnr1 CHANGING tab1-labst tab1-labzt tab1-labzz tab1-labdy tab1-netpr. PERFORM prm_set_mseg USING tab1-matnr1 CHANGING tab1-mengx. PERFORM frm_del_zero CHANGING tab1-matnr. PERFORM frm_del_zero CHANGING tab1-matnr1. PERFORM frm_del_zero CHANGING tab1-idnrk. MODIFY tab1. CLEAR tab1. ENDLOOP. ENDFORM. " GETROH *&---------------------------------------------------------------------* *& Form FILLFIELD *&---------------------------------------------------------------------* FORM fillfield USING p_fieldtab TYPE slis_t_fieldcat_alv.. DATA: l_fieldcat TYPE slis_fieldcat_alv. DATA : col_pos TYPE i VALUE 0. ADD 1 TO col_pos. l_fieldcat-fieldname = 'AENNR'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'ECN号码'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'DATUV'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'ECN有效日期'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'ANDAT'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'ECN创建日期'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'ANNAM'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = 'ECN创建人'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'AETXT'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '更改描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'AEGRU'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '更改原因'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MATNR'. l_fieldcat-col_pos = col_pos. l_fieldcat-fix_column = 'X'. l_fieldcat-seltext_l = '父件料号'. APPEND l_fieldcat TO p_fieldtab. CLEAR l_fieldcat. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MAKTXF'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '父件描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MATNR1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前子件料号'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MAKTX1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的物料描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MEINS'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '单位'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'IDNRK'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的子件编码'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MAKTX'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的物料描述'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MEINS1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '单位'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MENGE1'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改前的用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'MENGE'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '更改后的用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'MENGX'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '旧料实际消化数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABST'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '仓存量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABZT'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '在途数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABZZ'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '在制数量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABDY'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '库存待用量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'NETPR'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '单价'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'LABCG'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '新料采购在途量'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-tabname = 'ITAB_ALV'. l_fieldcat-fieldname = 'NETCG'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_l = '新料单价'. APPEND l_fieldcat TO p_fieldtab. ADD 1 TO col_pos. l_fieldcat-fieldname = 'TEXT'. l_fieldcat-col_pos = col_pos. l_fieldcat-seltext_m = '更改状态'. APPEND l_fieldcat TO p_fieldtab. CLEAR l_fieldcat. ENDFORM. " FILLFIELD *&---------------------------------------------------------------------* *& Form WRITEOUT *&---------------------------------------------------------------------* FORM writeout . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_BUFFER_ACTIVE = 'X' i_callback_program = sy-repid i_callback_user_command = 'USER_COMMAND' is_layout = g_alv_layout it_fieldcat = g_alv_fieldcat i_save = 'A' " I_STRUCTURE_NAME = 'ITAB1' i_grid_title = 'BOM工程更改记录报表' "NEED MODIFY TABLES t_outtab = tab1 EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. " WRITEOUT FORM frm_del_zero CHANGING x. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = x IMPORTING output = x. ENDFORM. " frm_del_zero *&---------------------------------------------------------------------* *& Form PRM_GET_MARD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_V_STPO_IDNRK text *----------------------------------------------------------------------* FORM prm_get_mard USING p_idnrk. DATA:lt_mdps TYPE TABLE OF mdps. DATA:ls_mdps LIKE LINE OF lt_mdps. DATA:gv_flag TYPE c VALUE '0'. IF p_idnrk IS NOT INITIAL. SELECT matnr labst insme INTO itab_mard FROM mard WHERE matnr = p_idnrk AND werks = p_werks. COLLECT itab_mard. ENDSELECT. READ TABLE mdps_zt WITH KEY matnr = p_idnrk. IF sy-subrc = 0. gv_flag = '1'. ENDIF. READ TABLE mdps_zz WITH KEY matnr = p_idnrk. IF sy-subrc = 0. gv_flag = '1'. ENDIF. IF gv_flag <> '1'. CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API' EXPORTING matnr = p_idnrk werks = p_werks TABLES mdpsx = lt_mdps * MDEZX = * MDSUX = EXCEPTIONS material_plant_not_found = 1 plant_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. ENDIF. LOOP AT lt_mdps INTO ls_mdps WHERE plaab = '02'."在途库存和在制库存 IF ls_mdps-delkz = 'BE'. mdps_zt-matnr = p_idnrk. mdps_zt-mng01 = ls_mdps-mng01. COLLECT mdps_zt. ENDIF. IF ls_mdps-delkz = 'FE'. mdps_zt-matnr = p_idnrk. mdps_zt-mng01 = ls_mdps-mng01. COLLECT mdps_zz. ENDIF. ENDLOOP. ENDIF. READ TABLE it_ekpo WITH KEY matnr = p_idnrk. IF sy-subrc = 0. ELSE. SELECT matnr aedat netpr INTO CORRESPONDING FIELDS OF TABLE it_ekpo FROM ekpo WHERE matnr = p_idnrk. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_SET_MARD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_S_ITAB_IDNRK text * <--P_I_ITAB_ALV_LABST text *----------------------------------------------------------------------* FORM prm_set_mard USING p_idnrk CHANGING p_labst p_labzt p_labzz p_labdy p_netpr. IF p_idnrk IS NOT INITIAL. READ TABLE itab_mard WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_labst = itab_mard-labst + itab_mard-insme. ENDIF. READ TABLE mdps_zt WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_labzt = mdps_zt-mng01. ENDIF. READ TABLE mdps_zz WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_labzz = mdps_zz-mng01. ENDIF. p_labdy = p_labst + p_labzt + p_labzz. READ TABLE it_ekpo WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_netpr = it_ekpo-netpr. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_GET_NEW *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_Y_STPO_IDNRK text *----------------------------------------------------------------------* FORM prm_get_new USING p_idnrk."新料采购在途中&&新物料采购单价 DATA:lt_mdps TYPE TABLE OF mdps. DATA:ls_mdps LIKE LINE OF lt_mdps. DATA:gv_flag TYPE c VALUE '0'. READ TABLE mdps_zt WITH KEY matnr = p_idnrk. IF sy-subrc = 0. gv_flag = '1'. ENDIF. IF gv_flag <> '1'. CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API' EXPORTING matnr = p_idnrk werks = p_werks TABLES mdpsx = lt_mdps * MDEZX = * MDSUX = EXCEPTIONS material_plant_not_found = 1 plant_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. ENDIF. LOOP AT lt_mdps INTO ls_mdps WHERE plaab = '02'."在途库存 IF ls_mdps-delkz = 'BE'. mdps_zt-matnr = p_idnrk. mdps_zt-mng01 = ls_mdps-mng01. COLLECT mdps_zt. ENDIF. ENDLOOP. ENDIF. READ TABLE it_ekpo WITH KEY matnr = p_idnrk."新物料采购单价 IF sy-subrc = 0. ELSE. SELECT matnr aedat netpr INTO CORRESPONDING FIELDS OF TABLE it_ekpo FROM ekpo WHERE matnr = p_idnrk. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_SET_NEW *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_T_ITAB_IDNRK text * <--P_ITAB_ALV_LABCG text * <--P_ITAB_ALV_NETCG text *----------------------------------------------------------------------* FORM prm_set_new USING p_idnrk CHANGING p_labcg p_netcg. IF p_idnrk IS NOT INITIAL. READ TABLE mdps_zt WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_labcg = mdps_zt-mng01. ENDIF. READ TABLE it_ekpo WITH KEY matnr = p_idnrk. IF sy-subrc = 0. p_netcg = it_ekpo-netpr. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_GET_MSEG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_Y_STPO_IDNRK text *----------------------------------------------------------------------* FORM prm_get_mseg USING p_idnrk p_datuv. DATA:rt_date TYPE RANGE OF mseg-budat_mkpf WITH HEADER LINE. DATA:rt_bwart TYPE RANGE OF mseg-bwart WITH HEADER LINE. DATA:rt_bwars TYPE RANGE OF mseg-bwart WITH HEADER LINE. DATA:rt_mseg TYPE TABLE OF ty_mdps WITH HEADER LINE. DATA:rt_mses TYPE TABLE OF ty_mdps WITH HEADER LINE. rt_tab:rt_date p_datuv sy-datum 'BT' 'I', rt_bwart '101' '' 'EQ' 'I', rt_bwars '202' '' 'EQ' 'I', rt_bwart '261' '' 'EQ' 'I', rt_bwars '262' '' 'EQ' 'I', rt_bwart '601' '' 'EQ' 'I', rt_bwars '602' '' 'EQ' 'I', rt_bwart 'Z21' '' 'EQ' 'I', rt_bwars 'Z22' '' 'EQ' 'I', rt_bwart 'Z11' '' 'EQ' 'I', rt_bwars 'Z12' '' 'EQ' 'I'. READ TABLE lt_mseg WITH KEY matnr = p_idnrk. IF sy-subrc <> 0. SELECT matnr menge AS mng01 INTO TABLE rt_mseg FROM mseg WHERE matnr = p_idnrk AND werks = p_werks AND budat_mkpf IN rt_date AND bwart IN rt_bwart. SELECT matnr menge AS mng01 INTO TABLE rt_mses FROM mseg WHERE matnr = p_idnrk AND werks = p_werks AND budat_mkpf IN rt_date AND bwart IN rt_bwars. LOOP AT rt_mseg. COLLECT rt_mseg INTO lt_mseg. ENDLOOP. LOOP AT rt_mses. rt_mseg-mng01 = rt_mseg-mng01 * -1. COLLECT rt_mses INTO lt_mseg. ENDLOOP. ENDIF. "SELECT ENDFORM. *&---------------------------------------------------------------------* *& Form PRM_SET_MSEG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_ITAB_ALV_INDNR1 text * <--P_ITAB_ALV_MENGX text *----------------------------------------------------------------------* FORM prm_set_mseg USING p_indnr1 CHANGING p_mengx. IF p_indnr1 IS NOT INITIAL. READ TABLE lt_mseg WITH KEY matnr = p_indnr1. IF sy-subrc = 0. p_mengx = lt_mseg-mng01. ENDIF. ENDIF. ENDFORM.
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18628.html