标签:des style color os io strong for 数据 ar
Code listing for: ZPPR001
Description: 三层BOM显示报表
*======================================================================* * T-Code: ZPPR001 * * Program Name ZPPR001 * * DESCRIPTION: 三层BOM显示报表 * * * * TYPE: Report * * APPLICATION AREA: PP * *----------------------------------------------------------------------* * FUNCTION: 显示三层BOM显示报表,方便导入新bom * * * *----------------------------------------------------------------------* * MODIFICATION LOG: * * VER DD/MM/YY Author DESCRIPTION CHANGE REQUEST * * --- -------- ------------- ---------------------- ---------------* * 000 25/07/13 libo Initial release DEVK906922 * *----------------------------------------------------------------------* REPORT zppr001 NO STANDARD PAGE HEADING. TABLES:mast, mara. DATA:BEGIN OF gt_output OCCURS 0, werks LIKE mast-werks, "工厂 matnr LIKE mast-matnr, "物料号 maktx1 LIKE makt-maktx, "物料描述 stlan LIKE mast-stlan, "BOM用途 stlal LIKE mast-stlal, "可选的BOM stktx LIKE stko-stktx, "可选BOM文本 bmeng(18), "BOM基本数量 bmein LIKE stpox-mmein, "BOM基本数量单位 MMEIN posnr LIKE stpo-posnr, "BOM 项目号 idnrk LIKE stpo-idnrk, "组件 maktx LIKE makt-maktx, "描述 mnglg LIKE stpox-mnglg, "组件数量 meins LIKE stpox-meins, "组件数量单位 lgort LIKE stpox-lgort, "生产仓储地点 brgew LIKE mara-brgew, "毛重 ntgew LIKE mara-ntgew, "净重 level TYPE char1,"层级 END OF gt_output. DATA:gt_data LIKE STANDARD TABLE OF gt_output WITH HEADER LINE. DATA:gt_stb LIKE STANDARD TABLE OF stpox WITH HEADER LINE. include zincalv. DATA: BEGIN OF gt_stpo OCCURS 0, werks LIKE mast-werks, matnr LIKE mast-matnr, maktx1 LIKE makt-maktx, bmeng LIKE stko-bmeng, "BOM基本数量 bmein LIKE stko-bmein, "BOM基本数量单位 stlan LIKE mast-stlan, "BOM用途 stlnr LIKE mast-stlnr, "物料单 stlty LIKE stpo-stlty, stlkn LIKE stpo-stlkn, stpoz LIKE stpo-stpoz, stlal LIKE mast-stlal, "可选的BOM stktx LIKE stko-stktx, "可选文字 002 add posnr LIKE stpo-posnr, "BOM 项目号 postp LIKE stpo-postp, "项目类别(物料单) oidnrk LIKE stpo-idnrk, "old组件 omaktx LIKE makt-maktx, "old描述 omenge LIKE stpo-menge, "old组件数量 omeins LIKE stpo-meins, "old组件数量单位 olgort LIKE stpo-lgort, "old生产仓储地点 idnrk LIKE stpo-idnrk, "组件 maktx LIKE makt-maktx, "描述 menge LIKE stpo-menge, "组件数量 meins LIKE stpo-meins, "组件数量单位 lgort LIKE stpo-lgort, "生产仓储地点 END OF gt_stpo. DATA:gt_makt LIKE STANDARD TABLE OF makt WITH HEADER LINE. DATA:BEGIN OF gt_mtnrv OCCURS 0, matnr LIKE mara-matnr, matkl LIKE mara-matkl, END OF gt_mtnrv. DATA:gt_mtnrv_lt LIKE STANDARD TABLE OF gt_mtnrv WITH HEADER LINE, gt_mtnrv_tp LIKE STANDARD TABLE OF gt_mtnrv WITH HEADER LINE, gt_mtnrv_zlj LIKE STANDARD TABLE OF gt_mtnrv WITH HEADER LINE. DATA:BEGIN OF gt_mara OCCURS 0, matkl LIKE mara-matkl, matnr LIKE mara-matnr, lvorm LIKE mara-lvorm, brgew LIKE mara-brgew, ntgew LIKE mara-ntgew, meins LIKE mara-meins, END OF gt_mara. DATA:BEGIN OF gt_matnr OCCURS 0, matnr LIKE mara-matnr, level TYPE char1,"层级 matkl LIKE mara-matkl, idnrk LIKE mara-matnr, posnr(4) TYPE n, END OF gt_matnr. DATA:BEGIN OF gt_mast OCCURS 0, matnr LIKE mast-matnr, werks LIKE mast-werks, stlan LIKE mast-stlan, stlnr LIKE mast-stlnr, stlal LIKE mast-stlal, stktx LIKE stko-stktx, bmeng LIKE stko-bmeng, bmein LIKE stko-bmein, END OF gt_mast. RANGES:r_lt FOR mara-matnr,"轮胎 r_tp FOR mara-matnr,"胎胚 r_gs FOR mara-matnr,"钢丝 r_zlj FOR mara-matnr,"终炼胶 r_ycl FOR mara-matnr."原材料 CONSTANTS:c_zlj LIKE mara-matkl VALUE ‘113‘, c_m TYPE char1 VALUE ‘M‘, c_char_x TYPE char1 VALUE ‘X‘. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. PARAMETERS: p_werks LIKE mkal-werks OBLIGATORY. "工厂 SELECT-OPTIONS:s_matnr FOR mara-matnr. "物料号 SELECT-OPTIONS:s_lvorm FOR mara-lvorm, "删除标记 s_stlal FOR mast-stlal."可选bom PARAMETERS:p_datuv LIKE stas-datuv DEFAULT sy-datum."BOM起始有效期 SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION. PERFORM frm_init_range. PERFORM frm_get_data. PERFORM frm_process_data. PERFORM frm_disp_data. *&---------------------------------------------------------------------* *& Form frm_get_bom *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM frm_get_data. write_screen text-i01. DATA:l_tabix LIKE sy-tabix. SELECT matnr matkl INTO CORRESPONDING FIELDS OF TABLE gt_mtnrv FROM mara WHERE matnr IN s_matnr AND ( matkl IN r_lt OR matkl IN r_tp OR matkl IN r_zlj ) AND lvorm IN s_lvorm. gt_mtnrv_zlj[] = gt_mtnrv[]. gt_mtnrv_tp[] = gt_mtnrv[]. gt_mtnrv_lt[] = gt_mtnrv[]. DELETE gt_mtnrv_lt WHERE matkl NOT IN r_lt. DELETE gt_mtnrv_tp WHERE matkl NOT IN r_tp. DELETE gt_mtnrv_zlj WHERE matkl NOT IN r_zlj. IF gt_mtnrv[] IS NOT INITIAL. SELECT mast~matnr mast~werks mast~stlan mast~stlnr mast~stlal stko~stktx stko~bmeng stko~bmein INTO CORRESPONDING FIELDS OF TABLE gt_mast FROM mast INNER JOIN mara ON mast~matnr = mara~matnr INNER JOIN stko ON mast~stlnr = stko~stlnr AND mast~stlal = stko~stlal AND stko~lkenz = ‘‘ AND stko~stlty = c_m FOR ALL entries IN gt_mtnrv WHERE mast~matnr = gt_mtnrv-matnr AND mast~werks = p_werks AND mast~stlal IN s_stlal AND mast~stlan = ‘1‘. ENDIF. DATA:lt_stb LIKE STANDARD TABLE OF stpox WITH HEADER LINE, lt_mast LIKE STANDARD TABLE OF mast WITH HEADER LINE, lt_mat LIKE STANDARD TABLE OF cscmat WITH HEADER LINE. REFRESH:gt_stb,gt_data. LOOP AT gt_mtnrv_lt. REFRESH:lt_stb,lt_mat. LOOP AT gt_mast WHERE matnr = gt_mtnrv_lt-matnr. PERFORM sub_get_bom TABLES lt_stb"lt_mat USING ‘‘ gt_mast-matnr gt_mast-stlal gt_mast-stlan gt_mast-werks gt_mast-stktx gt_mast-bmeng gt_mast-bmein ‘LT‘. APPEND LINES OF lt_stb TO gt_stb. ENDLOOP. ENDLOOP. LOOP AT gt_mtnrv_tp. LOOP AT gt_mast WHERE matnr = gt_mtnrv_tp-matnr. PERFORM sub_get_bom TABLES lt_stb "lt_mat USING c_char_x gt_mast-matnr gt_mast-stlal gt_mast-stlan gt_mast-werks gt_mast-stktx gt_mast-bmeng gt_mast-bmein ‘TP‘. APPEND LINES OF lt_stb TO gt_stb. ENDLOOP. ENDLOOP. LOOP AT gt_mtnrv_zlj. LOOP AT gt_mast WHERE matnr = gt_mtnrv_zlj-matnr. PERFORM sub_get_bom TABLES lt_stb" lt_mat USING c_char_x gt_mast-matnr gt_mast-stlal gt_mast-stlan gt_mast-werks gt_mast-stktx gt_mast-bmeng gt_mast-bmein ‘ZLJ‘. APPEND LINES OF lt_stb TO gt_stb. ENDLOOP. ENDLOOP. IF gt_mast[] IS NOT INITIAL. SELECT matnr maktx APPENDING CORRESPONDING FIELDS OF TABLE gt_makt FROM makt FOR ALL ENTRIES IN gt_mast WHERE matnr = gt_mast-matnr AND spras = sy-langu. SELECT matkl matnr lvorm brgew ntgew meins APPENDING TABLE gt_mara FROM mara FOR ALL ENTRIES IN gt_mast WHERE matnr = gt_mast-matnr. ENDIF. IF gt_data[] IS NOT INITIAL. SELECT matnr maktx APPENDING CORRESPONDING FIELDS OF TABLE gt_makt FROM makt FOR ALL ENTRIES IN gt_data WHERE matnr = gt_data-idnrk AND spras = sy-langu. SELECT matkl matnr lvorm brgew ntgew meins APPENDING TABLE gt_mara FROM mara FOR ALL ENTRIES IN gt_data WHERE matnr = gt_data-idnrk. ENDIF. ENDFORM. "frm_get_bom *&---------------------------------------------------------------------* *& Form FRM_INIT_RANGE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_init_range . REFRESH:r_lt,r_tp,r_gs,r_zlj,r_ycl. "轮胎 insert_range r_lt ‘I‘ ‘EQ‘ ‘31‘ ‘‘. insert_range:r_lt ‘I‘ ‘EQ‘ ‘32‘ ‘‘. insert_range:r_lt ‘I‘ ‘EQ‘ ‘34‘ ‘‘. "胎胚 insert_range:r_tp ‘I‘ ‘EQ‘ ‘204‘ ‘‘. "钢丝 insert_range:r_gs ‘I‘ ‘BT‘ ‘114‘ ‘117‘. "终炼胶 insert_range:r_zlj ‘I‘ ‘EQ‘ ‘223‘ ‘‘. "原材料 insert_range:r_ycl ‘I‘ ‘BT‘ ‘100‘ ‘113‘. ENDFORM. " FRM_INIT_RANGE *&---------------------------------------------------------------------* *& Form FRM_PROCESS_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_process_data . DATA:l_posnr(4) TYPE n, l_tabix LIKE sy-tabix. * DATA:lt_data LIKE STANDARD TABLE OF gt_data WITH HEADER LINE. REFRESH:gt_matnr. write_screen text-i02. *先的到所有数据 LOOP AT gt_data. l_tabix = sy-tabix. CLEAR:gt_matnr. gt_matnr-matnr = gt_data-matnr. gt_matnr-idnrk = gt_data-idnrk. READ TABLE gt_mara WITH KEY matnr = gt_data-idnrk. IF sy-subrc = 0. gt_matnr-matkl = gt_mara-matkl. ENDIF. READ TABLE gt_mara WITH KEY matnr = gt_data-matnr. IF sy-subrc = 0. gt_data-ntgew = gt_mara-ntgew. gt_data-brgew = gt_mara-brgew. ENDIF. IF gt_matnr-matkl IN r_lt. gt_matnr-level = ‘1‘. ENDIF. IF gt_matnr-matkl IN r_tp. gt_matnr-level = ‘2‘. ENDIF. IF gt_matnr-matkl IN r_gs OR gt_matnr-matkl IN r_zlj. gt_matnr-level = ‘3‘. ENDIF. IF gt_matnr-matkl IN r_ycl. gt_matnr-level = ‘4‘. ENDIF. IF gt_matnr-matkl IN r_zlj. gt_matnr-matkl = c_zlj. ENDIF. COLLECT gt_matnr. gt_data-level = gt_matnr-level. READ TABLE gt_makt WITH KEY matnr = gt_data-matnr. IF sy-subrc = 0. gt_data-maktx1 = gt_makt-maktx. ENDIF. READ TABLE gt_makt WITH KEY matnr = gt_data-idnrk. IF sy-subrc = 0. gt_data-maktx = gt_makt-maktx. ENDIF. MODIFY gt_data INDEX l_tabix TRANSPORTING maktx1 maktx ntgew brgew. ENDLOOP. SORT gt_matnr BY matnr level matkl idnrk. LOOP AT gt_matnr. l_tabix = sy-tabix. AT NEW level. CLEAR:l_posnr. ENDAT. l_posnr = l_posnr + 10. IF gt_matnr-matkl = c_zlj. gt_matnr-matkl = ‘223‘. ENDIF. gt_matnr-posnr = l_posnr. MODIFY gt_matnr INDEX l_tabix TRANSPORTING posnr matkl. ENDLOOP. *赋值项目号 LOOP AT gt_data. l_tabix = sy-tabix. READ TABLE gt_matnr WITH KEY matnr = gt_data-matnr idnrk = gt_data-idnrk. IF sy-subrc = 0. gt_data-posnr = gt_matnr-posnr. MODIFY gt_data INDEX l_tabix TRANSPORTING posnr. ENDIF. ENDLOOP. SORT gt_data BY matnr stlal level posnr idnrk. gt_output[] = gt_data[]. ENDFORM. " FRM_PROCESS_DATA *&---------------------------------------------------------------------* *& Form FRM_DISP_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_disp_data . PERFORM sub_init_layout USING text-i04 ‘‘. PERFORM sub_insert_fields. PERFORM sub_disp_data_new. ENDFORM. " FRM_DISP_DATA *&---------------------------------------------------------------------* *& Form SUB_INSERT_FIELDS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM sub_insert_fields . alv_head ‘WERKS‘ text-t01 space c_char_x space ‘04‘ ."工厂 alv_head ‘MATNR‘ text-t02 c_char_x c_char_x space ‘18‘ ."物料号 alv_head ‘MAKTX1‘ text-t03 space space space ‘40‘ ."物料描述 alv_head ‘STLAN‘ text-t04 space space space ‘01‘ ."BOM用途 alv_head ‘STLAL‘ text-t05 c_char_x space space ‘02‘ ."可选的BOM alv_head ‘STKTX‘ text-t06 space space space ‘40‘ ."可选BOM文本 alv_head ‘BMENG‘ text-t07 space space space ‘18‘ ."BOM基本数量 alv_head ‘BMEIN‘ text-t08 space space space ‘03‘ ."BOM基本单位 alv_head ‘POSNR‘ text-t09 space space space ‘04‘ ."BOM 项目号 alv_head ‘IDNRK‘ text-t10 c_char_x space space ‘18‘ ."组件 alv_head ‘MAKTX‘ text-t11 space space space ‘40‘ ."描述 alv_head ‘MNGLG‘ text-t12 space space space ‘18‘ ."组件数量 alv_head ‘MEINS‘ text-t13 space space space ‘03‘ ."组件数量单位 alv_head ‘LGORT‘ text-t14 space space space ‘04‘ ."生产仓储地点 alv_head ‘BRGEW‘ text-t15 space space space ‘18‘ ."毛重 alv_head ‘NTGEW‘ text-t16 space space space ‘18‘ ."净重 ENDFORM. " SUB_INSERT_FIELDS *&---------------------------------------------------------------------* *& Form SUB_DISP_DATA_NEW *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM sub_disp_data_new. write_screen text-i03. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC‘ EXPORTING i_interface_check = ‘‘ i_callback_program = sy-cprog i_callback_pf_status_set = ‘SET_PF_STATUS‘ i_grid_title = text-i04 is_layout_lvc = gs_layout it_fieldcat_lvc = gt_fieldcat i_save = ‘A‘ i_default = c_char_x TABLES t_outtab = gt_output[] EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM. " SUB_DISP_DATA_NEW *&---------------------------------------------------------------------* *& Form set_pf_status_r1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->RT_EXTAB text *----------------------------------------------------------------------* FORM set_pf_status USING rt_extab TYPE slis_t_extab. SET PF-STATUS ‘PF_STATUS‘. ENDFORM. "set-pf-status *&---------------------------------------------------------------------* *& Form SUB_GET_BOM *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_L_MEHRS text * -->P_L_MTNRV text * -->P_L_STLAL text * -->P_L_STLAN text * -->P_L_WERKS text * -->P_LT_STB text * -->P_LT_MAT text *----------------------------------------------------------------------* FORM sub_get_bom TABLES lt_stb STRUCTURE stpox * lt_mat STRUCTURE cscmat USING l_mehrs l_mtnrv l_stlal l_stlan l_werks l_stktx l_emeng l_bmein l_type. REFRESH:lt_stb. CALL FUNCTION ‘CS_BOM_EXPL_MAT_V2‘ EXPORTING capid = ‘PP01‘ datuv = p_datuv mdmps = space mehrs = l_mehrs mtnrv = l_mtnrv stlal = l_stlal stlan = l_stlan emeng = l_emeng werks = l_werks TABLES stb = lt_stb[] * matcat = lt_mat[] 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_stb. CLEAR:gt_data. CASE l_type. WHEN ‘LT‘. CHECK lt_stb-matkl IN r_tp. WHEN ‘TP‘. CHECK lt_stb-matkl IN r_zlj OR lt_stb-matkl IN r_gs. WHEN ‘ZLJ‘. CHECK lt_stb-matkl IN r_ycl. WHEN OTHERS. ENDCASE. gt_data-werks = l_werks. gt_data-matnr = l_mtnrv. gt_data-stlan = l_stlan. "BOM用途 gt_data-stlal = l_stlal. "可选的BOM gt_data-stktx = l_stktx. WRITE l_emeng TO gt_data-bmeng. CONDENSE gt_data-bmeng. gt_data-bmein = l_bmein. gt_data-idnrk = lt_stb-idnrk. "组件 gt_data-mnglg = lt_stb-mnglg. "组件数量 gt_data-meins = lt_stb-meins. "组件数量单位 gt_data-lgort = lt_stb-lgort. "生产仓储地点 COLLECT gt_data. ENDLOOP. ENDFORM. " SUB_GET_BOM *Text elements *---------------------------------------------------------- * 001 选项 * I01 取数据... * I02 处理数据... * I03 显示数据... * I04 三层BOM显示报表 * T01 工厂 * T02 物料号 * T03 物料描述 * T04 BOM用途 * T05 可选的BOM * T06 可选BOM文本 * T07 BOM基本数量 * T08 BOM基本数量单位 * T09 BOM#项目号 * T10 组件 * T11 描述 * T12 组件数量 * T13 组件数量单位 * T14 生产仓储地点 * T15 毛重 * T16 净重 *Selection texts *---------------------------------------------------------- * P_DATUV 有效起始日期 * P_WERKS 工厂 * S_LVORM 物料删除标记 * S_MATNR 物料 * S_STLAL 可选BOM
Extracted by Direct Download Enterprise version 1.3 - E.G.Mellodew. 1998-2004 UK. Sap Release 700
标签:des style color os io strong for 数据 ar
原文地址:http://www.cnblogs.com/eric0701/p/3934210.html