赞
踩
- CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
- CALL FUNCTION 'CARO_ROUTING_READ'
- EXPORTING
- date_from = sy-datum
- date_to = '99991231'
- plnty = 'N' "任务清单类型
- plnnr = gs_gylx-plnnr "任务清单组键值
- plnal = gs_gylx-plnal "组计数器
- matnr = gs_gylx-matnr "物料
- TABLES
- tsk_tab = lt_tsk_tab
- seq_tab = lt_seq_tab
- opr_tab = lt_opr_tab
- * com_tab = lt_com_tab
- EXCEPTIONS
- not_found = 1
- ref_not_exp = 2
- not_valid = 3
- OTHERS = 4.
- CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
- SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
- FROM mast
- INNER JOIN stko
- ON mast~stlnr = stko~stlnr
- AND mast~stlal = stko~stlal
- WHERE mast~matnr = gs_gylx-matnr
- AND mast~werks = gs_gylx-werks
- AND mast~stlal = gs_gylx-stlal
- AND stko~stlty = 'M'.
- CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
- EXPORTING
- aufsw = 'X' "确定订单层次与路径(工艺路线虚拟组件分配的时候需要根据这个标识获取订单层次与路径)
- capid = 'PP01'
- datuv = sy-datum
- emeng = 1
- mdnot = 'X'
- mdmps = 'X' "展开虚拟件
- mehrs = 'X' "展开多层
- mtnrv = lt_mast-matnr
- stlal = lt_mast-stlal
- stlan = lt_mast-stlan
- werks = lt_mast-werks
- IMPORTING
- topmat = ls_topmat
- TABLES
- stb = lt_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.
- DATA: lt_stpox TYPE TABLE OF stpox,
- ls_stpox TYPE stpox.
- CLEAR: lt_stpox, ls_stpox.
-
- APPEND LINES OF lt_stb[] TO lt_stpox.
-
- CALL FUNCTION 'CS_X4_NODE_DETERMINATION'
- EXPORTING
- i_stlty_w = ls_topmat-stlty "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
- i_stlnr_w = ls_topmat-stlnr "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
- i_stlal_w = ls_topmat-stlal "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
- i_flg_create_nodes = 'X'
- i_flg_node_for_class = 'X'
- i_flg_check_node = 'X'
- i_flg_special_class = 'X'
- i_flg_node_for_assem = 'X'
- i_flg_calc_path2 = 'X'
- i_flg_calc_path4 = 'X'
- TABLES
- stb = lt_stpox "根据上一步函数CS_BOM_EXPL_MAT_V2得到BOM列表信息传入赋值进来
- EXCEPTIONS
- wrong_initialization = 1
- foreign_lock = 2
- system_failure = 3
- stb_inconsistent = 4
- stvkn_not_initialized = 5
- OTHERS = 6.
- IF sy-subrc <> 0.
- * Implement suitable error handling here
- ENDIF.
备注:该函数必须要由上一步读取BOM信息函数CS_BOM_EXPL_MAT_V2之后使用,需要使用上一步跑出来的BOM信息作为传入参数,然后计算出工艺路线的组件分配的层次与路径
- LOOP AT lt_fpwlv INTO ls_fpwlv.
- READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
- posnr = ls_fpwlv-posnr.
- IF sy-subrc = 0.
- CHECK lt_stb-loekz IS INITIAL.
- CLEAR: ls_components, ls_components_x, ls_com_tab, ls_opr_tab.
- READ TABLE lt_com_tab INTO ls_com_tab
- WITH KEY stlty = 'M'
- stlnr = lt_stb-stlnr
- stlal = lt_stb-stlal
- stlkn = lt_stb-stvkn.
- IF sy-subrc = 0.
- READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
- CHECK ls_fpwlv-vornr <> ls_opr_tab-vornr.
- ls_components-maintain_mode = 'M'. "修改
- ELSE.
- ls_components-maintain_mode = 'C'. "创建
- ENDIF.
- lv_pointer = lv_pointer + 1.
- ls_components-flag_bar_pointer = lv_pointer.
- ls_components-sequence_no = '000000'.
- ls_components-activity = ls_fpwlv-vornr. "工序号
- ls_components-activity_old = ls_opr_tab-vornr.
- ls_components-bom_type = 'M' . "BOM 类别
- ls_components-bom_no = lt_stb-stlnr. "物料单
- ls_components-alternative_bom = gs_gylx-stlal."可选的 BOM
- ls_components-item_id = lt_stb-stvkn. "项目 ID
- ls_components-item_no = lt_stb-posnr. "BOM 项目号
- ls_components-plant = gs_gylx-werks. "工厂
- * ls_component-material = ls_fpwl-matnr. "物料号
- ls_component-material = ''.
- ls_components-backflush = lt_stb-rgekz.
-
- * 以下三行代码必须得传输,不然在生产订单上根据工艺路线带入的时候会有问题
- ls_components-bom_type_root = 'M'.
- ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
- ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
-
- "虚拟件分配,填入level和path
- IF lt_stb-dumps IS NOT INITIAL.
- * CLEAR ls_phantom.
- ** ls_components-material = gs_gylx-matnr.
- * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
- * wegxx = lt_stb-wegxx.
- * ls_components-order_lvl = ls_phantom-level.
- * ls_components-order_path = ls_phantom-path.
- ls_components-order_lvl = lt_stb-aufst. "根据BOM展开函数获取的订单层次
- ls_components-order_path = lt_stb-aufwg. "根据BOM展开函数获取的订单路径
- READ TABLE lt_stpox INTO ls_stpox WITH KEY stufe = lt_stb-stufe
- wegxx = lt_stb-wegxx.
- IF sy-subrc = 0.
- ls_components-path = ls_stpox-nlink. "根据CS_X4_NODE_DETERMINATION获取的BOM的路径
- ENDIF.
- * ls_components-path = lt_stb-aufwg.
-
- ELSE.
- IF lt_stb-stufe > 1.
- ls_components-material = gs_gylx-matnr.
- READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
- wegxx = lt_stb-vwegx.
- IF sy-subrc = 0.
- ls_components-order_lvl = ls_phantom-level.
- ls_components-order_path = ls_phantom-path.
- * READ TABLE lt_stb WITH KEY stufe = 1
- * wegxx = lt_stb-vwegx.
- * IF sy-subrc = 0.
- ls_components-bom_type_root = 'M'.
- ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
- ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
- * ENDIF.
- ENDIF.
- ENDIF.
- ENDIF.
- APPEND ls_components TO lt_components.
-
- ls_components_x-activity = 'X'. "操作/活动编号
- IF ls_components-maintain_mode = 'C'.
- ls_components_x-sequence_no = 'X'.
- ls_components_x-plant = 'X'. "工厂
- * ls_components_x-material = 'X'. "物料号
- ls_components_x-material = 'X'.
- ls_components_x-backflush = 'X'.
- ls_components_x-order_lvl = 'X'.
- ls_components_x-order_path = 'X'.
- ls_components_x-path = 'X'.
- ls_components_x-bom_type_root = 'X'.
- ls_components_x-bom_no_root = 'X'.
- ls_components_x-alternative_bom_root = 'X'.
- ENDIF.
- APPEND ls_components_x TO lt_components_x.
- ENDIF.
- ENDLOOP.
- CALL FUNCTION 'ROUTING_MAINTAIN'
- EXPORTING
- change_no = lv_changeno
- key_date = sy-datum
- task_list_group = wa_mapl-plnnr "组
- * group_counter = wa_mapl-plnal "组计数器
- * material = wa_mapl-matnr "物料编号
- * plant = wa_mapl-werks "工厂
- group_counter = gs_gylx-plnal "组计数器
- material = gs_gylx-matnr "物料编号
- plant = gs_gylx-werks "工厂
- task = ls_h_task
- task_x = ls_h_task_x
- application = 'PP01'
- bom_usage = lt_mast-stlan
- TABLES
- material_task_allocations = lt_materials
- material_task_allocations_x = lt_materials_x
- * SEQUENCES = SEQUENCES
- * SEQUENCES_X = SEQUENCES_X
- operations = lt_operations
- operations_x = lt_operations_x
- component_allocations = lt_components
- component_allocations_x = lt_components_x
- return = lt_return.
完整代码:
- FUNCTION zjkplm006.
- *"----------------------------------------------------------------------
- *"*"本地接口:
- *" EXPORTING
- *" VALUE(RETURN) TYPE ZSPLM_RETURN
- *" TABLES
- *" ET_GYLX STRUCTURE ZJKPLM006
- *"----------------------------------------------------------------------
- "假定:接口参数中物料MATNR和工厂WERKS是同一组
- *MATNR 1 类型 MATNR CHAR 18 0 物料号
- *WERKS 1 类型 WERKS_D CHAR 4 0 工厂
- "工艺路线-子项目*VERWE 1 类型 PLN_VERWE CHAR 3 0 任务清单使用
- "工艺路线-子项目*PLNAL 1 类型 PLNAL CHAR 2 0 组计数器
- "工艺路线-子项目*KTEXT 1 类型 PLANTEXT CHAR 40 0 任务清单描述
- "工艺路线-子项目 工序-子项目*VORNR 1 类型 VORNR CHAR 4 0 操作/活动编号
- "工艺路线-子项目 工序-子项目*ARBPL 1 类型 ARBPL CHAR 8 0 工作中心
- "工艺路线-子项目 工序-子项目*STEUS 1 类型 STEUS CHAR 4 0 控制码
- "工艺路线-子项目 工序-子项目*KTSCH 1 类型 KTSCH CHAR 7 0 标准文本码
- "工艺路线-子项目 工序-子项目*TXT 1 类型 VLSCH_TXT CHAR 40 0 标准文本码描述
- "工艺路线-子项目 工序-子项目*UMREZ 1 类型 CP_UMREZ DEC 5 0 用于转换任务清单和工序计量单位的计数器
- "工艺路线-子项目 工序-子项目*UMREN 1 类型 CP_UMREN DEC 5 0 用于转换工艺路线和工序单位的分母
- "工艺路线-子项目 工序-子项目*BMSCH 1 类型 BMSCH QUAN 13 3 基本数量
- "工艺路线-子项目 工序-子项目*VGW01 1 类型 VGWRT QUAN 9 3 标准值
- "工艺路线-子项目 工序-子项目*VGE01 1 类型 VGWRTEH UNIT 3 0 标准值计量单位
- "工艺路线-子项目 工序-子项目 组件分配*FPWL 1 类型 CHAR 255 0 分配物料
- *MESS 1 类型 CHAR 255 0 消息
- TABLES:t435,t435t.
- TYPES:BEGIN OF ty_out,
- matnr TYPE mapl-matnr, " 物料
- werks TYPE mapl-werks, " 物料工厂
- verwe TYPE plko-verwe, " 用途
- plnal TYPE mapl-plnal, "组计数器
- ktext TYPE plko-ktext, "工艺路线描述
- vornr TYPE plpo-vornr, " 工序号
- arbpl TYPE crhd-arbpl, " 工作中心
- steus TYPE plpo-steus, " 控制码
- ktsch TYPE plpo-ktsch, "工序标准文本码
- txt TYPE vlsch_txt, "工序标准文本码描述
- umrez TYPE plpo-umrez, "工艺路线抬头数量
- umren TYPE plpo-umren, "工序数量
- bmsch TYPE plpo-bmsch, "基本数量
- vgw01 TYPE plpo-vgw01, "工时
- vge01 TYPE plpo-vge01, "单位
- * vgw02 TYPE plpo-vgw02, "固定
- * vge02 TYPE plpo-vge02, "单位
- * vgw03 TYPE plpo-vgw03, "变动
- * vge03 TYPE plpo-vge03, "单位
- * vgw04 TYPE plpo-vgw04, "营运
- * vge04 TYPE plpo-vge04, "单位
- fpwl TYPE char2048, "分配物料
- meins TYPE mara-meins, "单位
- plnnr TYPE plpo-plnnr,
- flg TYPE c, "X正确
- mess TYPE string , "返回消息
- END OF ty_out.
- DATA:gt_out TYPE TABLE OF ty_out,
- gs_out TYPE ty_out,
- gs_gylx TYPE zjkplm006,
- gs_gylx_tmp TYPE zjkplm006.
-
- TYPES:BEGIN OF ty_vornr,
- matnr TYPE mapl-matnr, " 物料
- werks TYPE mapl-werks, " 物料工厂
- plnal TYPE mapl-plnal, "组计数器
- plnnr TYPE mapl-plnnr, " 任务清单组码
- vornr TYPE plpo-vornr, "工序
- END OF ty_vornr.
- TYPES: BEGIN OF ty_crhd,
- arbpl TYPE crhd-arbpl, "工作中心
- werks TYPE crhd-werks, "工厂
- lvorm TYPE crhd-lvorm, "工作中心删除标志
- END OF ty_crhd.
-
- TYPES: BEGIN OF ty_marc,
- matnr TYPE marc-matnr,
- werks TYPE marc-werks,
- meins TYPE mara-meins,
- END OF ty_marc.
-
- TYPES: BEGIN OF ty_fpwl,
- * matnr TYPE marc-matnr,
- line(255),
- END OF ty_fpwl.
-
- TYPES: BEGIN OF ty_fpwlv,
- posnr TYPE stpo-posnr,
- matnr TYPE marc-matnr,
- plnal TYPE mapl-plnal, "组计数器
- vornr TYPE plpo-vornr, "工序
- END OF ty_fpwlv.
- DATA:lt_gylx TYPE STANDARD TABLE OF zjkplm006,
- lt_gylx_temp TYPE STANDARD TABLE OF zjkplm006.
- FIELD-SYMBOLS:<fs_gylx> TYPE zjkplm006.
-
- "组件分配 component allocation
- DATA:lt_mast TYPE TABLE OF mast WITH HEADER LINE,
- ls_topmat TYPE cstmat,
- lt_stb TYPE TABLE OF stpox WITH HEADER LINE.
- DATA:lt_fpwl TYPE TABLE OF ty_fpwl,
- lt_fpwlv TYPE TABLE OF ty_fpwlv,
- ls_fpwl TYPE ty_fpwl,
- ls_fpwlv TYPE ty_fpwlv.
- DATA:lt_phantom TYPE TABLE OF ty_phantom,
- ls_phantom TYPE ty_phantom.
- "读取工艺路线
- DATA:
- lt_mapl TYPE STANDARD TABLE OF mapl, wa_mapl TYPE mapl, wa_mapl_temp TYPE mapl,
- lt_tsk_tab TYPE STANDARD TABLE OF capp_tsk, ls_tsk_tab TYPE capp_tsk,
- lt_seq_tab TYPE STANDARD TABLE OF capp_seq, ls_seq_tab TYPE capp_seq,
- lt_opr_tab TYPE STANDARD TABLE OF capp_opr, ls_opr_tab TYPE capp_opr,
- lt_com_tab TYPE STANDARD TABLE OF capp_com, ls_com_tab TYPE capp_com.
- "标准文本码
- DATA: ls_header TYPE thead,
- lt_lines TYPE TABLE OF tline WITH HEADER LINE.
- "物料计量单位
- DATA:ls_marc TYPE ty_marc.
-
- DATA: lv_create TYPE c, "创建
- lv_modify TYPE c, "更改
- lv_tabix TYPE i,
- lv_changeno TYPE aennr,
- lv_message TYPE string.
-
- "创建工艺路线
- DATA:lt_task TYPE TABLE OF bapi1012_tsk_c,
- ls_task TYPE bapi1012_tsk_c,
- lt_material TYPE TABLE OF bapi1012_mtk_c,
- ls_material TYPE bapi1012_mtk_c,
- lt_sequence TYPE TABLE OF bapi1012_seq_c,
- ls_sequence TYPE bapi1012_seq_c,
- lt_operation TYPE TABLE OF bapi1012_opr_c,
- ls_operation TYPE bapi1012_opr_c,
- lt_component TYPE TABLE OF bapi1012_com_c,
- ls_component TYPE bapi1012_com_c,
- lv_group TYPE bapi1012_tsk_c-task_list_group,
- lt_return TYPE bapiret2_t,
- ls_return TYPE bapiret2.
- "更改工艺路线
- DATA:ls_h_task TYPE cps_task_list_maint_tsk,
- ls_h_task_x TYPE cps_task_list_maint_tsk_x,
- lt_materials TYPE TABLE OF cps_task_list_maint_mtk,
- ls_materials TYPE cps_task_list_maint_mtk,
- lt_materials_x TYPE TABLE OF cps_task_list_maint_mtk_x,
- ls_materials_x TYPE cps_task_list_maint_mtk_x,
- lt_sequences TYPE TABLE OF cps_task_list_maint_seq,
- ls_sequences TYPE cps_task_list_maint_seq,
- lt_sequences_x TYPE TABLE OF cps_task_list_maint_seq_x,
- ls_sequences_x TYPE cps_task_list_maint_seq_x,
- lt_operations TYPE STANDARD TABLE OF cps_task_list_maint_opr,
- lt_operations_del TYPE STANDARD TABLE OF cps_task_list_maint_opr,
- ls_operations TYPE cps_task_list_maint_opr,
- lt_operations_x TYPE STANDARD TABLE OF cps_task_list_maint_opr_x,
- ls_operations_x TYPE cps_task_list_maint_opr_x,
- lt_components TYPE TABLE OF cps_task_list_maint_com,
- ls_components TYPE cps_task_list_maint_com,
- lt_components_x TYPE TABLE OF cps_task_list_maint_com_x,
- ls_components_x TYPE cps_task_list_maint_com_x.
- DATA :ls_zmest401 TYPE zmest401,
- ls_routing TYPE ztplm_routing.
- DATA:ls_gylx_zmes TYPE zjkplm006.
- DATA:lv_vornr TYPE vornr,
- lv_pointer TYPE cp_task_list_maint_pointer.
- "CC01
- DATA:lt_bdc TYPE STANDARD TABLE OF bdcdata,
- ls_msg TYPE bdcmsgcoll,
- lt_msg TYPE STANDARD TABLE OF bdcmsgcoll.
- DATA:ls_params TYPE ctu_params.
- lt_gylx[] = et_gylx[].
- READ TABLE lt_gylx ASSIGNING <fs_gylx> INDEX 1.
- SELECT COUNT(*) FROM zmest001
- WHERE werks = <fs_gylx>-werks.
- IF sy-subrc = 0.
- "3200工厂不做修改
- LOOP AT lt_gylx ASSIGNING <fs_gylx>.
- "物料号补充前导0
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = <fs_gylx>-matnr
- IMPORTING
- output = <fs_gylx>-matnr.
- CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
- EXPORTING
- input = <fs_gylx>-plnal
- IMPORTING
- output = <fs_gylx>-plnal.
- ***检查标准文本码是否存在,如果不存在,创建
- SELECT SINGLE * FROM t435 WHERE vlsch = <fs_gylx>-ktsch.
- IF sy-subrc <> 0.
- CLEAR: ls_header, lt_lines, lt_lines[].
- ls_header-tdobject = 'WORKST'.
- ls_header-tdid = 'SUBM'.
- ls_header-tdspras = sy-langu.
- ls_header-tdname = <fs_gylx>-ktsch.
- ls_header-tdform = 'SYSTEM'.
- lt_lines-tdformat = '*' .
- lt_lines-tdline = <fs_gylx>-txt.
- APPEND lt_lines.
- CALL FUNCTION 'SAVE_TEXT'
- EXPORTING
- client = sy-mandt
- header = ls_header
- savemode_direct = 'X'
- TABLES
- lines = lt_lines
- EXCEPTIONS
- id = 1
- language = 2
- name = 3
- object = 4
- OTHERS = 5.
- *BEGIN OF COPY FROM FUNCTION 'SUBMISSION_PROCESSING'
- CLEAR: t435,t435t.
- t435-vlsch = <fs_gylx>-ktsch.
- INSERT INTO t435 VALUES t435.
- t435t-vlsch = <fs_gylx>-ktsch.
- t435t-spras = sy-langu.
- t435t-txt = <fs_gylx>-txt.
- INSERT INTO t435t VALUES t435t.
- CALL FUNCTION 'COMMIT_TEXT'.
- COMMIT WORK.
- *END OF COPY
- ELSE.
- " ***检查标准文本码描述,如果不同,修改
- "3200工厂的不修改 -------------
- IF <fs_gylx>-werks <> '3200'.
- SELECT SINGLE * FROM t435t WHERE spras = sy-langu
- AND vlsch = <fs_gylx>-ktsch.
- IF t435t-txt <> <fs_gylx>-txt.
- ls_header-tdobject = 'WORKST'.
- ls_header-tdid = 'SUBM'.
- ls_header-tdspras = sy-langu.
- ls_header-tdname = <fs_gylx>-ktsch.
- ls_header-tdform = 'SYSTEM'.
- lt_lines-tdformat = '*' .
- lt_lines-tdline = <fs_gylx>-txt.
- APPEND lt_lines.
- CALL FUNCTION 'SAVE_TEXT'
- EXPORTING
- client = sy-mandt
- header = ls_header
- savemode_direct = 'X'
- TABLES
- lines = lt_lines
- EXCEPTIONS
- id = 1
- language = 2
- name = 3
- object = 4
- OTHERS = 5.
- CLEAR: t435t.
- t435t-vlsch = <fs_gylx>-ktsch.
- t435t-spras = sy-langu.
- t435t-txt = <fs_gylx>-txt.
- MODIFY t435t FROM t435t.
- CALL FUNCTION 'COMMIT_TEXT'.
- COMMIT WORK.
- ENDIF.
- ENDIF.
- ENDIF.
- IF <fs_gylx>-umrez IS INITIAL .
- <fs_gylx>-umrez = 1.
- ENDIF.
- IF <fs_gylx>-umren IS INITIAL .
- <fs_gylx>-umren = 1.
- ENDIF.
- ENDLOOP.
- "创建工艺路线
- CLEAR:lt_task,lt_material,lt_sequence,lt_operation,lt_return.
- "更改工艺路线
- CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
- lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
- "读取工艺路线
- CLEAR: lt_mapl,lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
- CLEAR: lv_create,lv_modify.
-
- IF lt_gylx IS NOT INITIAL.
- "根据物料编码+工厂+组计数器 获取已经存在的工艺路线
- SELECT *
- FROM mapl
- INTO TABLE lt_mapl
- FOR ALL ENTRIES IN lt_gylx
- WHERE mapl~matnr = lt_gylx-matnr
- AND mapl~werks = lt_gylx-werks
- AND mapl~plnty = 'N' "任务清单类型
- AND mapl~loekz = ''.
- SORT lt_mapl BY matnr werks plnal.
- ENDIF.
-
- SORT lt_gylx BY matnr
- werks
- plnal "工艺路线-子项目 组计数器
- verwe "工艺路线-子项目 用途
- vornr."工艺路线-子项目 工序-子项目 工序号
- "判断该记录是否存在
- IF lt_mapl IS INITIAL.
- lv_create = 'X'.
- ELSE.
- lv_modify = 'X'.
- ENDIF.
-
- READ TABLE lt_gylx INTO gs_gylx INDEX 1.
- IF sy-subrc = 0.
- CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
- SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
- FROM mast
- INNER JOIN stko
- ON mast~stlnr = stko~stlnr
- AND mast~stlal = stko~stlal
- WHERE mast~matnr = gs_gylx-matnr
- AND mast~werks = gs_gylx-werks
- AND stko~stlty = 'M'.
- CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
- EXPORTING
- capid = 'PP01'
- datuv = sy-datum
- emeng = 1
- mehrs = ''
- mtnrv = lt_mast-matnr
- stlal = lt_mast-stlal
- stlan = lt_mast-stlan
- werks = lt_mast-werks
- IMPORTING
- topmat = ls_topmat
- TABLES
- stb = lt_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.
-
- "根据物料 工厂 获取MARC记录
- SELECT SINGLE
- marc~matnr
- marc~werks
- mara~meins
- INTO CORRESPONDING FIELDS OF ls_marc
- FROM marc INNER JOIN mara
- ON mara~matnr = marc~matnr
- WHERE marc~matnr = gs_gylx-matnr
- AND marc~werks = gs_gylx-werks.
- ENDIF.
- LOOP AT lt_gylx INTO gs_gylx.
- "组件分配
- CLEAR:lt_fpwl.
- SPLIT gs_gylx-fpwl AT ';' INTO TABLE lt_fpwl.
- * LOOP AT lt_fpwl INTO ls_fpwl.
- * ls_fpwlv-matnr = ls_fpwl-matnr.
- * ls_fpwlv-vornr = gs_gylx-vornr.
- * APPEND ls_fpwlv TO lt_fpwlv.
- * ENDLOOP.
- LOOP AT lt_fpwl INTO ls_fpwl.
- SPLIT ls_fpwl-line AT '&' INTO ls_fpwlv-posnr ls_fpwlv-matnr.
- CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
- EXPORTING
- input = ls_fpwlv-posnr
- IMPORTING
- output = ls_fpwlv-posnr.
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = ls_fpwlv-matnr
- IMPORTING
- output = ls_fpwlv-matnr
- EXCEPTIONS
- length_error = 1
- OTHERS = 2.
-
- ls_fpwlv-vornr = gs_gylx-vornr.
- APPEND ls_fpwlv TO lt_fpwlv.
- ENDLOOP.
- ENDLOOP.
-
- IF lv_create = 'X'.
- LOOP AT lt_gylx INTO gs_gylx.
- * IF gs_gylx-steus = 'SOP'. "控制码转换
- * gs_gylx-steus = 'MP01'.
- * ELSE.
- * gs_gylx-steus = 'MP06'.
- * ENDIF.
- IF sy-tabix = 1.
- CLEAR ls_material.
- ls_material-material = gs_gylx-matnr."物料编号
- ls_material-plant = gs_gylx-werks."工厂
- ls_material-valid_from = sy-datum."有效起始日期
- ls_material-valid_to_date = '99991231'."有效截止日期
- APPEND ls_material TO lt_material.
- CLEAR ls_sequence.
- ls_sequence-sequence_no = '000000'."序列
- ls_sequence-valid_from = sy-datum. "有效起始日期
- ls_sequence-valid_to_date = '99991231'."有效截止日期
- ls_sequence-sequence_category = '0'."顺序类别
- ls_sequence-alignment_key_for_scheduling = '2'."计划校准码
- APPEND ls_sequence TO lt_sequence.
-
- CLEAR ls_task.
- * ls_task-task_list_group = gs_gylx-plnnr."组
- ls_task-group_counter = gs_gylx-plnal."组计数器
- ls_task-valid_from = sy-datum. "有效起始日期
- ls_task-valid_to_date = '99991231'."有效截止日期
- ls_task-task_list_usage = '1'. "任务清单使用
- ls_task-plant = gs_gylx-werks."工厂
- ls_task-task_list_status = '4'."状态
- ls_task-task_measure_unit = ls_marc-meins."任务清单计量单位
- ls_task-description = gs_gylx-ktext."任务清单描述
- APPEND ls_task TO lt_task.
- ENDIF.
- "工序
- CLEAR ls_operation.
- ls_operation-group_counter = gs_gylx-plnal."组计数器
- ls_operation-sequence_no = '000000'.
- ls_operation-valid_from = sy-datum. "有效起始日期
- ls_operation-valid_to_date = '99991231'. "有效截止日期
- ls_operation-activity = gs_gylx-vornr. "操作/活动编号
- ls_operation-control_key = gs_gylx-steus. "控制码
- ls_operation-standard_text_key = gs_gylx-ktsch. "工序标准文本码
- ls_operation-work_cntr = gs_gylx-arbpl. "工作中心
- ls_operation-denominator = '1'."用于转换工艺路线和工序单位的分母
- ls_operation-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
- ls_operation-base_quantity = gs_gylx-bmsch."基本数量
- ls_operation-operation_measure_unit = ls_marc-meins."单位
- ls_operation-description = gs_gylx-txt."标准文本
-
- IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
- ls_operation-acttype_01 = 'ZJ01'.
- ls_operation-std_value_01 = gs_gylx-vgw01."工时
- ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
- ELSE.
- ls_operation-std_value_01 = gs_gylx-vgw01."工时
- ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
- ls_operation-std_value_02 = gs_gylx-vgw01."固定
- ls_operation-std_unit_02 = gs_gylx-vge01."工时计量单位
- ls_operation-std_value_03 = gs_gylx-vgw01."变动
- ls_operation-std_unit_03 = gs_gylx-vge01."工时计量单位
- ls_operation-std_value_04 = gs_gylx-vgw01."营运
- ls_operation-std_unit_04 = gs_gylx-vge01."工时计量单位
- ENDIF.
- ls_operation-cost_relevant = 'X'."打上成本核算先关标识
-
- APPEND ls_operation TO lt_operation.
-
- "组件分配 component allocation -->工序
- LOOP AT lt_fpwlv INTO ls_fpwlv WHERE vornr = gs_gylx-vornr.
- READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr.
- IF sy-subrc = 0.
- CHECK lt_stb-loekz IS INITIAL.
- CLEAR ls_component.
- ls_component-valid_from = sy-datum. "有效起始日期
- ls_component-activity = ls_fpwlv-vornr. "工序号
- ls_component-bom_type = 'M' . "BOM 类别
- ls_component-bom_no = lt_stb-stlnr. "物料单
- ls_component-alternative_bom = lt_mast-stlal."可选的 BOM
- ls_component-item_id = lt_stb-stvkn. "项目 ID
- ls_component-item_no = lt_stb-posnr. "BOM 项目号
- ls_component-plant = gs_gylx-werks. "工厂
- * ls_component-material = ls_fpwl-matnr. "物料号
- APPEND ls_component TO lt_component.
- ENDIF.
- ENDLOOP.
- ENDLOOP.
-
- SORT lt_component.
- DELETE ADJACENT DUPLICATES FROM lt_component COMPARING ALL FIELDS.
- CALL FUNCTION 'BAPI_ROUTING_CREATE'
- IMPORTING
- group = lv_group
- TABLES
- task = lt_task
- materialtaskallocation = lt_material
- sequence = lt_sequence
- operation = lt_operation
- componentallocation = lt_component
- return = lt_return.
- READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
- IF sy-subrc = 0.
- return-type = 'E'.
- LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
- return-id = ls_return-id.
- return-type = ls_return-type.
- return-number = ls_return-number.
- MESSAGE ID ls_return-id
- TYPE ls_return-type
- NUMBER ls_return-number
- WITH ls_return-message_v1
- ls_return-message_v2
- ls_return-message_v3
- ls_return-message_v4
- INTO return-message.
- ENDLOOP.
- ROLLBACK WORK.
- ELSE.
- return-type = 'S'.
- return-message = '系统处理成功!'.
- "ls_out-flg = 'X'.
- CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
- EXPORTING
- wait = 'X'.
- "保存版本,供ME使用----------------------------
- "MES 所需内容 FROM--------------------20200422-----------
- READ TABLE et_gylx INTO gs_gylx INDEX 1.
- IF gs_gylx-version IS NOT INITIAL.
- SELECT COUNT(*) FROM zmest001
- WHERE werks = gs_gylx-werks.
- IF sy-subrc = 0 .
- CLEAR:ls_zmest401.
- CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_zmest401-matnr.
- ls_zmest401-werks = gs_gylx-werks.
- ls_zmest401-ztype = 'R'.
- ls_zmest401-datum = sy-datum.
- ls_zmest401-zgybb = gs_gylx-version.
- ls_zmest401-zgybh = gs_gylx-plnnr_alt.
- MODIFY zmest401 FROM ls_zmest401.
- COMMIT WORK AND WAIT.
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_routing-matnr.
- ls_routing-werks = gs_gylx-werks.
- ls_routing-stlal = gs_gylx-stlal.
- ls_routing-ztype = 'R'.
- ls_routing-datum = sy-datum.
- ls_routing-zgybb = gs_gylx-version.
- ls_routing-zgybh = gs_gylx-plnnr_alt.
- MODIFY ztplm_routing FROM ls_routing.
- COMMIT WORK AND WAIT.
- ENDIF.
- ENDIF.
- "MES 所需内容 END --------------------20200422-----------
- ENDIF.
-
- ENDIF.
-
- IF lv_modify = 'X'.
- "cc01 生成 CHANGE NO号
- READ TABLE lt_mapl INTO wa_mapl INDEX 1.
- PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0100'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '/00'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RAD_BUT_ECNTYP-NORM' 'X'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RAD_AEFUN-OHFR' 'X'.
- PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0010'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '/00'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AETXT' wa_mapl-matnr.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-DATUV' sy-datum.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AENST' '01'.
- PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0020'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '=ENT1'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_CURSOR' 'RC29A-AEERL(02)'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AEERL(02)' 'X'.
- PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0020'.
- PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '=FCBU'.
- ls_params-dismode = 'N'.
- ls_params-updmode = 'S'.
- ls_params-defsize = 'X'.
- CALL TRANSACTION 'CC01' USING lt_bdc
- OPTIONS FROM ls_params
- MESSAGES INTO lt_msg.
- READ TABLE lt_msg INTO ls_msg WITH KEY msgtyp = 'S'.
- IF sy-subrc = 0.
- CLEAR:lv_changeno.
- lv_changeno = ls_msg-msgv1.
- ENDIF.
- IF lv_changeno IS INITIAL .
- return-type = 'E'.
- return-message = 'ECN号获取失败'.
- ELSE.
- "工艺路线-子项目 修改
- LOOP AT lt_mapl INTO wa_mapl.
- CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
- CALL FUNCTION 'CARO_ROUTING_READ'
- EXPORTING
- date_from = sy-datum
- date_to = '99991231'
- plnty = wa_mapl-plnty
- plnnr = wa_mapl-plnnr
- plnal = wa_mapl-plnal
- TABLES
- tsk_tab = lt_tsk_tab
- seq_tab = lt_seq_tab
- opr_tab = lt_opr_tab
- com_tab = lt_com_tab
- EXCEPTIONS
- not_found = 1
- ref_not_exp = 2
- not_valid = 3
- OTHERS = 4.
-
- lt_gylx_temp = lt_gylx.
- DELETE lt_gylx_temp WHERE plnal <> wa_mapl-plnal.
- SORT lt_gylx_temp BY matnr
- werks
- plnal "工艺路线-子项目 组计数器
- verwe "工艺路线-子项目 用途
- vornr."工艺路线-子项目 工序-子项目 工序号
- ***创建和修改
- CLEAR:lv_vornr.
- LOOP AT lt_gylx_temp INTO gs_gylx.
- * IF gs_gylx-steus = 'SOP'. "控制码转换
- * gs_gylx-steus = 'MP01'.
- * ELSE.
- * gs_gylx-steus = 'MP06'.
- * ENDIF.
- IF sy-tabix = 1.
- * TASK 组
- CLEAR ls_h_task.
- ls_h_task-plant = gs_gylx-werks."工厂
- ls_h_task-task_list_usage = '1'. "任务清单使用
- ls_h_task-task_list_status = '4'."状态
- ls_h_task-description = gs_gylx-ktext."任务清单描述
- ls_h_task-task_measure_unit = ls_marc-meins.
- ls_h_task_x-description = 'X'.
- ENDIF.
-
- CLEAR:ls_operations,ls_operations_x.
- READ TABLE lt_opr_tab INTO ls_opr_tab
- WITH KEY vornr = gs_gylx-vornr.
- IF sy-subrc = 0.
- "工序修改
- ls_operations-maintain_mode = 'M'. "修改
- ELSE.
- "工序新建
- ls_operations-maintain_mode = 'C'. "创建
- ENDIF.
- "------------------修改于20200803--------------FROM----------
- IF lv_vornr IS INITIAL .
- lv_vornr = 1.
- ELSE.
- lv_vornr = lv_vornr + 1.
- ENDIF.
- ls_operations-flag_bar_pointer = lv_vornr.
- " ls_operations-flag_bar_pointer = gs_gylx-vornr / 10.
- "------------------修改于20200803--------------END-----------
- ls_operations-sequence_no = '000000'.
- ls_operations-activity = gs_gylx-vornr. "操作/活动编号
- ls_operations-control_key = gs_gylx-steus. "控制码
- ls_operations-standard_text_key = gs_gylx-ktsch. "工序标准文本码
- ls_operations-description = gs_gylx-txt. "工序标准文本码
- ls_operations-work_cntr = gs_gylx-arbpl. "工作中心
- ls_operations-plant = gs_gylx-werks. "工作中心
- ls_operations-denominator = '1'."用于转换工艺路线和工序单位的分母
- ls_operations-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
- ls_operations-base_quantity = gs_gylx-bmsch."基本数量
- ls_operations-operation_measure_unit = ls_marc-meins."单位
- IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
- ls_operation-acttype_01 = 'ZJ01'.
- ls_operations-std_value_01 = gs_gylx-vgw01."工时
- ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
- ELSE.
- ls_operations-std_value_01 = gs_gylx-vgw01."工时
- ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
- ls_operations-std_value_02 = gs_gylx-vgw01."固定
- ls_operations-std_unit_02 = gs_gylx-vge01."工时计量单位
- ls_operations-std_value_03 = gs_gylx-vgw01."变动
- ls_operations-std_unit_03 = gs_gylx-vge01."工时计量单位
- ls_operations-std_value_04 = gs_gylx-vgw01."营运
- ls_operations-std_unit_04 = gs_gylx-vge01."工时计量单位
- ENDIF.
-
- ls_operations-cost_relevant = 'X'.
- APPEND ls_operations TO lt_operations.
-
- IF ls_operations-maintain_mode = 'C'. "创建
- ls_operations_x-activity = 'X'. "操作/活动编号
- ENDIF.
- ls_operations_x-control_key = 'X'. "控制码
- ls_operations_x-standard_text_key = 'X'. "工序标准文本码
- ls_operations_x-description = 'X'. "工序标准文本码描述
- ls_operations_x-work_cntr = 'X'. "工作中心
- ls_operations_x-plant = 'X'. "工厂
- ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
- ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
- ls_operations_x-base_quantity = 'X'."基本数量
- ls_operations_x-operation_measure_unit = 'X'."单位
- IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
- ls_operations_x-acttype_01 = 'X'.
- ls_operations_x-std_value_01 = 'X'."工时
- ls_operations_x-std_unit_01 = 'X'."工时计量单位
- ELSE.
- ls_operations_x-std_value_01 = 'X'."工时
- ls_operations_x-std_unit_01 = 'X'."工时计量单位
- ls_operations_x-std_value_02 = 'X'."固定
- ls_operations_x-std_unit_02 = 'X'."工时计量单位
- ls_operations_x-std_value_03 = 'X'."变动
- ls_operations_x-std_unit_03 = 'X'."工时计量单位
- ls_operations_x-std_value_04 = 'X'."营运
- ls_operations_x-std_unit_04 = 'X'."工时计量单位
- ENDIF.
-
- ls_operations_x-cost_relevant = 'X'."成本核算表示
- APPEND ls_operations_x TO lt_operations_x.
- ENDLOOP.
- ***删除
- CLEAR:lv_vornr.
- LOOP AT lt_opr_tab INTO ls_opr_tab.
- READ TABLE lt_gylx_temp INTO gs_gylx WITH KEY vornr = ls_opr_tab-vornr.
- IF sy-subrc <> 0.
- CLEAR:ls_operations,ls_operations_x.
- ls_operations-maintain_mode = 'D'. "删除
- "------------------修改于20200803--------------FROM----------
- IF lv_vornr IS INITIAL .
- lv_vornr = 1.
- ELSE.
- lv_vornr = lv_vornr + 1.
- ENDIF.
- ls_operations-flag_bar_pointer = lv_vornr.
- " ls_operations-flag_bar_pointer = ls_opr_tab-vornr / 10.
- "------------------修改于20200803--------------END-----------
- ls_operations-sequence_no = '000000'.
- ls_operations-activity = ls_opr_tab-vornr. "操作/活动编号
-
- APPEND ls_operations TO lt_operations.
- ls_operations_x-control_key = 'X'. "控制码
- ls_operations_x-standard_text_key = 'X'. "工序标准文本码
- ls_operations_x-description = 'X'. "工序标准文本码描述
- ls_operations_x-work_cntr = 'X'. "工作中心
- ls_operations_x-plant = 'X'. "工厂
- ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
- ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
- ls_operations_x-base_quantity = 'X'."基本数量
- ls_operations_x-operation_measure_unit = 'X'."单位
- IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型.
- ls_operations_x-acttype_01 = 'X'.
- ls_operations_x-std_value_01 = 'X'."工时
- ls_operations_x-std_unit_01 = 'X'."工时计量单位
- ELSE.
- ls_operations_x-std_value_01 = 'X'."工时
- ls_operations_x-std_unit_01 = 'X'."工时计量单位
- ls_operations_x-std_value_02 = 'X'."固定
- ls_operations_x-std_unit_02 = 'X'."工时计量单位
- ls_operations_x-std_value_03 = 'X'."变动
- ls_operations_x-std_unit_03 = 'X'."工时计量单位
- ls_operations_x-std_value_04 = 'X'."营运
- ls_operations_x-std_unit_04 = 'X'."工时计量单位
- ENDIF.
-
- APPEND ls_operations_x TO lt_operations_x.
- ENDIF.
- ENDLOOP.
- SORT lt_operations BY activity.
-
- CALL FUNCTION 'ROUTING_MAINTAIN'
- EXPORTING
- change_no = lv_changeno
- key_date = sy-datum
- task_list_group = wa_mapl-plnnr "组
- group_counter = wa_mapl-plnal "组计数器
- material = wa_mapl-matnr "物料编号
- plant = wa_mapl-werks "工厂
- task = ls_h_task
- task_x = ls_h_task_x
- * APPLICATION =
- bom_usage = lt_mast-stlan
- TABLES
- * MATERIAL_TASK_ALLOCATIONS = MATERIAL_TASK_ALLOCATIONS
- * MATERIAL_TASK_ALLOCATIONS_X = MATERIAL_TASK_ALLOCATIONS_X
- * SEQUENCES = SEQUENCES
- * SEQUENCES_X = SEQUENCES_X
- operations = lt_operations
- operations_x = lt_operations_x
- component_allocations = lt_components
- component_allocations_x = lt_components_x
- return = lt_return.
- READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
- IF sy-subrc = 0.
- return-type = 'E'.
- LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
- return-id = ls_return-id.
- return-type = ls_return-type.
- return-number = ls_return-number.
- MESSAGE ID ls_return-id
- TYPE ls_return-type
- NUMBER ls_return-number
- WITH ls_return-message_v1
- ls_return-message_v2
- ls_return-message_v3
- ls_return-message_v4
- INTO return-message.
- ENDLOOP.
- ROLLBACK WORK.
- ELSE.
- return-type = 'S'.
- return-message = '系统处理成功!'.
- "ls_out-flg = 'X'.
- CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
- EXPORTING
- wait = 'X'.
- "保存版本,供ME使用----------------------------
- "MES 所需内容 FROM--------------------20200422-----------
- READ TABLE et_gylx INTO gs_gylx INDEX 1.
- IF gs_gylx-version IS NOT INITIAL.
- SELECT COUNT(*) FROM zmest001
- WHERE werks = gs_gylx-werks.
- IF sy-subrc = 0 .
- CLEAR:ls_zmest401.
- CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_zmest401-matnr.
- ls_zmest401-werks = gs_gylx-werks.
- ls_zmest401-ztype = 'R'.
- ls_zmest401-datum = sy-datum.
- ls_zmest401-zgybb = gs_gylx-version.
- ls_zmest401-zgybh = gs_gylx-plnnr_alt.
- MODIFY zmest401 FROM ls_zmest401.
- COMMIT WORK AND WAIT.
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_routing-matnr.
- ls_routing-werks = gs_gylx-werks.
- ls_routing-stlal = gs_gylx-stlal.
- ls_routing-ztype = 'R'.
- ls_routing-datum = sy-datum.
- ls_routing-zgybb = gs_gylx-version.
- ls_routing-zgybh = gs_gylx-plnnr_alt.
- MODIFY ztplm_routing FROM ls_routing.
- COMMIT WORK AND WAIT.
- ENDIF.
- ENDIF.
- ENDIF.
- "更改工艺路线
- CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
- lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
-
- ENDLOOP.
- ENDIF.
- * "工艺路线-子项目 创建
- * READ TABLE lt_mapl INTO wa_mapl_temp INDEX 1.
- * LOOP AT lt_gylx INTO gs_gylx.
- * READ TABLE lt_mapl INTO wa_mapl
- * WITH KEY plnal = gs_gylx-plnal.
- * IF sy-subrc <> 0.
- *
- ** CALL FUNCTION 'BAPI_ROUTING_CREATE'
- **需要指定每个参数表中的
- **TASK_LIST_GROUP 1 类型 PLNNR CHAR 8 0 任务清单组码
- **GROUP_COUNTER 1 类型 PLNAL CHAR 2 0 组计数器
- * ENDIF.
- * ENDLOOP.
- ENDIF.
- ELSE.
- "不做ECN,直接修改;组件分配
- LOOP AT lt_gylx ASSIGNING <fs_gylx>.
- "物料号补充前导0
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = <fs_gylx>-matnr
- IMPORTING
- output = <fs_gylx>-matnr.
- CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
- EXPORTING
- input = <fs_gylx>-plnal
- IMPORTING
- output = <fs_gylx>-plnal.
- CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
- EXPORTING
- input = <fs_gylx>-infnr
- IMPORTING
- output = <fs_gylx>-infnr.
- ***检查标准文本码是否存在,如果不存在,创建
- SELECT SINGLE * FROM t435 WHERE vlsch = <fs_gylx>-ktsch.
- IF sy-subrc <> 0.
- CLEAR: ls_header, lt_lines, lt_lines[].
- ls_header-tdobject = 'WORKST'.
- ls_header-tdid = 'SUBM'.
- ls_header-tdspras = sy-langu.
- ls_header-tdname = <fs_gylx>-ktsch.
- ls_header-tdform = 'SYSTEM'.
- lt_lines-tdformat = '*' .
- lt_lines-tdline = <fs_gylx>-txt.
- APPEND lt_lines.
- CALL FUNCTION 'SAVE_TEXT'
- EXPORTING
- client = sy-mandt
- header = ls_header
- savemode_direct = 'X'
- TABLES
- lines = lt_lines
- EXCEPTIONS
- id = 1
- language = 2
- name = 3
- object = 4
- OTHERS = 5.
- *BEGIN OF COPY FROM FUNCTION 'SUBMISSION_PROCESSING'
- CLEAR: t435,t435t.
- t435-vlsch = <fs_gylx>-ktsch.
- INSERT INTO t435 VALUES t435.
- t435t-vlsch = <fs_gylx>-ktsch.
- t435t-spras = sy-langu.
- t435t-txt = <fs_gylx>-txt.
- INSERT INTO t435t VALUES t435t.
- CALL FUNCTION 'COMMIT_TEXT'.
- COMMIT WORK.
- *END OF COPY
- ELSE.
- " ***检查标准文本码描述,如果不同,修改
- SELECT SINGLE * FROM t435t WHERE spras = sy-langu
- AND vlsch = <fs_gylx>-ktsch.
- IF t435t-txt <> <fs_gylx>-txt.
- ls_header-tdobject = 'WORKST'.
- ls_header-tdid = 'SUBM'.
- ls_header-tdspras = sy-langu.
- ls_header-tdname = <fs_gylx>-ktsch.
- ls_header-tdform = 'SYSTEM'.
-
- lt_lines-tdformat = '*' .
- lt_lines-tdline = <fs_gylx>-txt.
- APPEND lt_lines.
- CALL FUNCTION 'SAVE_TEXT'
- EXPORTING
- client = sy-mandt
- header = ls_header
- savemode_direct = 'X'
- TABLES
- lines = lt_lines
- EXCEPTIONS
- id = 1
- language = 2
- name = 3
- object = 4
- OTHERS = 5.
- CLEAR: t435t.
- t435t-vlsch = <fs_gylx>-ktsch.
- t435t-spras = sy-langu.
- t435t-txt = <fs_gylx>-txt.
- MODIFY t435t FROM t435t.
- CALL FUNCTION 'COMMIT_TEXT'.
- COMMIT WORK.
- ENDIF.
- ENDIF.
- IF <fs_gylx>-umrez IS INITIAL .
- <fs_gylx>-umrez = 1.
- ENDIF.
- IF <fs_gylx>-umren IS INITIAL .
- <fs_gylx>-umren = 1.
- ENDIF.
- ENDLOOP.
-
- "创建工艺路线
- CLEAR:lt_task,lt_material,lt_sequence,lt_operation,lt_return.
- "更改工艺路线
- CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
- lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
- "读取工艺路线
- CLEAR: lt_mapl,lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
- CLEAR: lv_create,lv_modify.
- IF lt_gylx IS NOT INITIAL.
- "根据PLM的工艺路线号查找SAP对应的工艺路线组号
- READ TABLE lt_gylx INTO gs_gylx INDEX 1.
- IF gs_gylx-plnnr_alt IS INITIAL.
- return-type = 'E'.
- return-message = 'PLM工艺路线号不能为空'.
- RETURN.
- ENDIF.
- SELECT SINGLE plnnr
- INTO lv_group
- FROM plko
- WHERE plnty = 'N'
- AND loekz = '' "过滤删除的工艺路线
- AND plnnr_alt = gs_gylx-plnnr_alt.
- "根据物料编码+工厂+组号 获取已经存在的工艺路线
- SELECT *
- FROM mapl
- INTO CORRESPONDING FIELDS OF TABLE lt_mapl
- * FOR ALL ENTRIES IN lt_gylx
- * WHERE mapl~matnr = lt_gylx-matnr
- * AND mapl~werks = lt_gylx-werks
- * AND mapl~plnnr = lv_group
- WHERE mapl~plnnr = lv_group
- AND mapl~plnty = 'N'. "任务清单类型
- * AND mapl~loekz = ''. "这个标识只是删除物料分配,物料还是可以分配回来
- SORT lt_mapl BY matnr werks plnal.
- ENDIF.
-
- SORT lt_gylx BY matnr
- werks
- plnal "工艺路线-子项目 组计数器
- verwe "工艺路线-子项目 用途
- vornr."工艺路线-子项目 工序-子项目 工序号
- "判断该记录是否存在,判断依据PLNNR+PLNAL,PLNNR根据PLM号获取,PLNAL由PLM指定
- READ TABLE lt_gylx INTO gs_gylx INDEX 1.
- READ TABLE lt_mapl INTO wa_mapl WITH KEY plnal = gs_gylx-plnal.
- * IF lt_mapl IS INITIAL.
- IF sy-subrc <> 0.
- lv_create = 'X'.
- ELSE.
- lv_modify = 'X'.
- *******************************************************************************************
- * 删除组件分配
- * DATA: ctumode TYPE ctu_params-dismode VALUE 'N',
- * cupdate TYPE ctu_params-updmode VALUE 'A'.
- * REFRESH: bdcdata, messtab.
- * CLEAR: bdcdata, messtab.
- *
- * PERFORM bdc_dynpro USING 'SAPLCPDI' '1010'.
- * PERFORM bdc_field USING 'BDC_CURSOR'
- * 'RC27M-MATNR'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '/00'.
- * PERFORM bdc_field USING 'RC27M-MATNR'
- * gs_gylx-matnr.
- * PERFORM bdc_field USING 'RC27M-WERKS'
- * gs_gylx-werks.
- * PERFORM bdc_field USING 'RC271-STTAG'
- * sy-datum.
- * PERFORM bdc_dynpro USING 'SAPLCPDI' '1400'.
- * PERFORM bdc_field USING 'BDC_CURSOR'
- * 'PLPOD-VORNR(01)'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '=MATA'.
- * PERFORM bdc_field USING 'RC27X-ENTRY_ACT'
- * '1'.
- * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
- * PERFORM bdc_field USING 'BDC_CURSOR'
- * 'RCM01-MATNR'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '=MARA'.
- * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
- * PERFORM bdc_field USING 'BDC_CURSOR'
- * 'RCM01-MATNR'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '=DEL'.
- * PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '=YES'.
- * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
- * PERFORM bdc_field USING 'BDC_CURSOR'
- * 'RCM01-MATNR'.
- * PERFORM bdc_field USING 'BDC_OKCODE'
- * '=BU'.
- * CALL TRANSACTION 'CA02' USING bdcdata
- * MODE ctumode
- * UPDATE cupdate
- * MESSAGES INTO messtab.
- * REFRESH: bdcdata, messtab.
- * CLEAR: bdcdata, messtab.
- *****************************************************************************************
-
- CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
- CALL FUNCTION 'CARO_ROUTING_READ'
- EXPORTING
- date_from = sy-datum
- date_to = '99991231'
- plnty = 'N'
- plnnr = lv_group
- plnal = gs_gylx-plnal
- matnr = gs_gylx-matnr
- TABLES
- tsk_tab = lt_tsk_tab
- seq_tab = lt_seq_tab
- opr_tab = lt_opr_tab
- * com_tab = lt_com_tab
- EXCEPTIONS
- not_found = 1
- ref_not_exp = 2
- not_valid = 3
- OTHERS = 4.
- "CARO_ROUTING_READ读取组件不准确,改用逻辑数据库,参考CA51
- DATA: lt_plmzd TYPE TABLE OF plmzd,
- ls_plmzd TYPE plmzd.
- RANGES: lr_matnr FOR plmzd-matnr,
- lr_werks FOR plmzd-werks,
- lr_plnnr FOR plmzd-plnnr,
- lr_plnal FOR plmzd-plnal.
- lr_matnr-sign = 'I'.
- lr_matnr-option = 'EQ'.
- lr_matnr-low = gs_gylx-matnr.
- APPEND lr_matnr.
- lr_werks-sign = 'I'.
- lr_werks-option = 'EQ'.
- lr_werks-low = gs_gylx-werks.
- APPEND lr_werks.
- lr_plnnr-sign = 'I'.
- lr_plnnr-option = 'EQ'.
- lr_plnnr-low = lv_group.
- APPEND lr_plnnr.
- lr_plnal-sign = 'I'.
- lr_plnal-option = 'EQ'.
- lr_plnal-low = gs_gylx-plnal.
- APPEND lr_plnal.
- REFRESH lt_plmzd.
- "参照CA51
- SUBMIT zjkmes006_read_component WITH pn_plnty = 'N'
- WITH pn_matnr IN lr_matnr
- WITH pn_werks IN lr_werks
- WITH pn_plnnr IN lr_plnnr
- WITH pn_plnal IN lr_plnal
- WITH pn_datuv = sy-datum
- WITH pn_capid = 'PP01'
- WITH mat = 'X'
- WITH pn_mehrs = 'X'
- AND RETURN.
-
- IMPORT lt = lt_plmzd[] FROM MEMORY ID 'ZCOMPONENT'.
- MOVE-CORRESPONDING lt_plmzd[] TO lt_com_tab[].
-
- ENDIF.
-
- READ TABLE lt_gylx INTO gs_gylx INDEX 1.
- IF sy-subrc = 0.
- CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
- SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
- FROM mast
- INNER JOIN stko
- ON mast~stlnr = stko~stlnr
- AND mast~stlal = stko~stlal
- WHERE mast~matnr = gs_gylx-matnr
- AND mast~werks = gs_gylx-werks
- AND mast~stlal = gs_gylx-stlal
- AND stko~stlty = 'M'.
- CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
- EXPORTING
- aufsw = 'X'
- capid = 'PP01'
- datuv = sy-datum
- emeng = 1
- mdnot = 'X'
- mdmps = 'X'
- mehrs = 'X'
- mtnrv = lt_mast-matnr
- stlal = lt_mast-stlal
- stlan = lt_mast-stlan
- werks = lt_mast-werks
- IMPORTING
- topmat = ls_topmat
- TABLES
- stb = lt_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.
-
- DATA: lt_stpox TYPE TABLE OF stpox,
- ls_stpox TYPE stpox.
- CLEAR: lt_stpox, ls_stpox.
-
- APPEND LINES OF lt_stb[] TO lt_stpox.
-
- CALL FUNCTION 'CS_X4_NODE_DETERMINATION'
- EXPORTING
- i_stlty_w = ls_topmat-stlty
- i_stlnr_w = ls_topmat-stlnr
- i_stlal_w = ls_topmat-stlal
- i_flg_create_nodes = 'X'
- i_flg_node_for_class = 'X'
- i_flg_check_node = 'X'
- i_flg_special_class = 'X'
- i_flg_node_for_assem = 'X'
- i_flg_calc_path2 = 'X'
- i_flg_calc_path4 = 'X'
- TABLES
- stb = lt_stpox
- EXCEPTIONS
- wrong_initialization = 1
- foreign_lock = 2
- system_failure = 3
- stb_inconsistent = 4
- stvkn_not_initialized = 5
- OTHERS = 6.
- IF sy-subrc <> 0.
- * Implement suitable error handling here
- ENDIF.
-
- DELETE lt_stb WHERE loekz IS NOT INITIAL.
- PERFORM frm_get_phantom TABLES lt_stb
- lt_com_tab
- lt_phantom.
-
- "根据物料 工厂 获取MARC记录
- SELECT SINGLE
- marc~matnr
- marc~werks
- mara~meins
- INTO CORRESPONDING FIELDS OF ls_marc
- FROM marc INNER JOIN mara
- ON mara~matnr = marc~matnr
- WHERE marc~matnr = gs_gylx-matnr
- AND marc~werks = gs_gylx-werks.
- ENDIF.
- LOOP AT lt_gylx INTO gs_gylx.
- "组件分配
- CLEAR:lt_fpwl.
- SPLIT gs_gylx-fpwl AT ';' INTO TABLE lt_fpwl.
- LOOP AT lt_fpwl INTO ls_fpwl.
- SPLIT ls_fpwl-line AT '&' INTO ls_fpwlv-posnr ls_fpwlv-matnr.
- CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
- EXPORTING
- input = ls_fpwlv-posnr
- IMPORTING
- output = ls_fpwlv-posnr.
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = ls_fpwlv-matnr
- IMPORTING
- output = ls_fpwlv-matnr
- EXCEPTIONS
- length_error = 1
- OTHERS = 2.
-
- ls_fpwlv-vornr = gs_gylx-vornr.
- APPEND ls_fpwlv TO lt_fpwlv.
- ENDLOOP.
- ENDLOOP.
-
- IF lv_create = 'X'.
- LOOP AT lt_gylx INTO gs_gylx.
- * IF gs_gylx-steus = 'SOP'. "控制码转换
- * gs_gylx-steus = 'MP01'.
- * ELSE.
- * gs_gylx-steus = 'MP06'.
- * ENDIF.
- IF sy-tabix = 1.
- CLEAR ls_material.
- ls_material-task_list_group = lv_group."组
- ls_material-material = gs_gylx-matnr."物料编号
- ls_material-plant = gs_gylx-werks."工厂
- ls_material-valid_from = sy-datum."有效起始日期
- ls_material-valid_to_date = '99991231'."有效截止日期
- APPEND ls_material TO lt_material.
-
- CLEAR ls_sequence.
- ls_sequence-task_list_group = lv_group."组
- ls_sequence-sequence_no = '000000'."序列
- ls_sequence-valid_from = sy-datum. "有效起始日期
- ls_sequence-valid_to_date = '99991231'."有效截止日期
- ls_sequence-sequence_category = '0'."顺序类别
- ls_sequence-alignment_key_for_scheduling = '2'."计划校准码
- APPEND ls_sequence TO lt_sequence.
-
- CLEAR ls_task.
- ls_task-task_list_group = lv_group."组
- ls_task-group_counter = gs_gylx-plnal."组计数器
- ls_task-valid_from = sy-datum. "有效起始日期
- ls_task-valid_to_date = '99991231'."有效截止日期
- ls_task-task_list_usage = '1'. "任务清单使用
- ls_task-plant = gs_gylx-werks."工厂
- ls_task-task_list_status = '4'."状态
- ls_task-task_measure_unit = ls_marc-meins."任务清单计量单位
- ls_task-description = gs_gylx-ktext."任务清单描述
- ls_task-old_number_of_task_list = gs_gylx-plnnr_alt."PLM工艺流程编号
- APPEND ls_task TO lt_task.
- ENDIF.
-
- "工序
- CLEAR ls_operation.
- ls_operation-task_list_group = lv_group."组
- * ls_operation-group_counter = gs_gylx-plnal."组计数器
- ls_operation-sequence_no = '000000'.
- ls_operation-valid_from = sy-datum. "有效起始日期
- ls_operation-valid_to_date = '99991231'. "有效截止日期
- ls_operation-activity = gs_gylx-vornr. "操作/活动编号
- ls_operation-control_key = gs_gylx-steus. "控制码
- ls_operation-standard_text_key = gs_gylx-ktsch. "工序标准文本码
- ls_operation-work_cntr = gs_gylx-arbpl. "工作中心
- * ls_operation-denominator = '1'."用于转换工艺路线和工序单位的分母
- * ls_operation-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
- ls_operation-base_quantity = gs_gylx-bmsch."基本数量
- ls_operation-operation_measure_unit = ls_marc-meins."单位
- ls_operation-description = gs_gylx-txt."标准文本
- ls_operation-nominator = gs_gylx-umrez.
- ls_operation-denominator = gs_gylx-umren.
- PERFORM frm_get_op_plant USING gs_gylx-werks gs_gylx-arbpl CHANGING ls_operation-plant.
- ls_operation-info_rec = gs_gylx-infnr."采购信息记录
- ls_operation-purch_org = gs_gylx-ekorg."采购组织
- PERFORM ftm_get_cost_elem USING ls_operation-plant
- ls_operation-info_rec
- ls_operation-purch_org
- CHANGING ls_operation-cost_elem."成本要素
- * ls_operation-std_value_01 = gs_gylx-vgw01."工时
- * ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
- * ls_operation-std_value_02 = gs_gylx-vgw01."固定
- * ls_operation-std_unit_02 = gs_gylx-vge01."工时计量单位
- * ls_operation-std_value_03 = gs_gylx-vgw01."变动
- * ls_operation-std_unit_03 = gs_gylx-vge01."工时计量单位
- * ls_operation-std_value_04 = gs_gylx-vgw01."营运
- * ls_operation-std_unit_04 = gs_gylx-vge01."工时计量单位
- PERFORM frm_set_std_value USING ls_operation-plant
- gs_gylx-arbpl
- gs_gylx-vgw01
- gs_gylx-vge01
- CHANGING ls_operation-std_value_01
- ls_operation-std_unit_01
- ls_operation-std_value_02
- ls_operation-std_unit_02
- ls_operation-std_value_03
- ls_operation-std_unit_03
- ls_operation-std_value_04
- ls_operation-std_unit_04
- ls_operation-std_value_05
- ls_operation-std_unit_05
- ls_operation-std_value_06
- ls_operation-std_unit_06
- ls_operations-acttype_01
- ls_operations-acttype_02
- ls_operations-acttype_03
- ls_operations-acttype_04
- ls_operations-acttype_05
- ls_operations-acttype_06.
- * IF gs_gylx-steus = 'MQ01'.
- * ls_operations-acttype_01 = 'ZJ01'.
- * ENDIF.
- ls_operation-cost_relevant = 'X'."于成本核算先关表示
-
- APPEND ls_operation TO lt_operation.
-
- "组件分配 component allocation -->工序
- LOOP AT lt_fpwlv INTO ls_fpwlv WHERE vornr = gs_gylx-vornr.
- READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
- posnr = ls_fpwlv-posnr.
- IF sy-subrc = 0.
- CHECK lt_stb-loekz IS INITIAL.
- CLEAR ls_component.
- ls_component-task_list_group = lv_group."组
- ls_component-sequence_no = '000000'.
- ls_component-valid_from = sy-datum. "有效起始日期
- ls_component-valid_to_date = '99991231'."有效截止日期
- ls_component-activity = ls_fpwlv-vornr. "工序号
- ls_component-bom_type = 'M' . "BOM 类别
- ls_component-bom_no = lt_stb-stlnr. "物料单
- ls_component-alternative_bom = lt_mast-stlal."可选的 BOM
- ls_component-item_id = lt_stb-stvkn. "项目 ID
- ls_component-item_no = lt_stb-posnr. "BOM 项目号
- ls_component-plant = gs_gylx-werks. "工厂
- * ls_component-material = ls_fpwl-matnr. "物料号
- ls_component-material = ''.
- ls_component-backflush = lt_stb-rgekz.
-
- "虚拟件分配,填入level和path
- IF lt_stb-dumps IS NOT INITIAL.
- * CLEAR ls_phantom.
- ** ls_component-material = gs_gylx-matnr.
- * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
- * wegxx = lt_stb-wegxx.
- * ls_component-order_lvl = ls_phantom-level.
- * ls_component-order_path = ls_phantom-path.
- ELSE.
- IF lt_stb-stufe > 1.
- ls_component-material = gs_gylx-matnr.
- READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
- wegxx = lt_stb-vwegx.
- IF sy-subrc = 0.
- ls_component-order_lvl = ls_phantom-level.
- ls_component-order_path = ls_phantom-path.
- * READ TABLE lt_stb WITH KEY stufe = 1
- * wegxx = lt_stb-vwegx.
- * IF sy-subrc = 0.
- ls_component-bom_type_root = 'M'.
- ls_component-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
- ls_component-alternative_bom_root = lt_mast-stlal."lt_stb-stlal.
- * ENDIF.
- ENDIF.
- ENDIF.
- ENDIF.
- APPEND ls_component TO lt_component.
- ENDIF.
- ENDLOOP.
- ENDLOOP.
- * SORT lt_component.
- DELETE ADJACENT DUPLICATES FROM lt_component COMPARING ALL FIELDS.
- CALL FUNCTION 'BAPI_ROUTING_CREATE'
- EXPORTING
- application = 'PP01'
- IMPORTING
- group = lv_group
- TABLES
- task = lt_task
- materialtaskallocation = lt_material
- sequence = lt_sequence
- operation = lt_operation
- componentallocation = lt_component
- return = lt_return.
- READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
- IF sy-subrc = 0.
- return-type = 'E'.
- LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
- return-id = ls_return-id.
- return-type = ls_return-type.
- return-number = ls_return-number.
- MESSAGE ID ls_return-id
- TYPE ls_return-type
- NUMBER ls_return-number
- WITH ls_return-message_v1
- ls_return-message_v2
- ls_return-message_v3
- ls_return-message_v4
- INTO lv_message.
- CONCATENATE return-message lv_message INTO return-message.
- ENDLOOP.
- ROLLBACK WORK.
- ELSE.
- return-type = 'S'.
- return-message = '系统处理成功!'.
- "ls_out-flg = 'X'.
- CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
- EXPORTING
- wait = 'X'.
-
- "保存版本,供ME使用----------------------------
- "MES 所需内容 FROM--------------------20200422-----------
- READ TABLE et_gylx INTO gs_gylx INDEX 1.
-
- IF gs_gylx-version IS NOT INITIAL.
-
- CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_routing-matnr.
- ls_routing-werks = gs_gylx-werks.
- ls_routing-stlal = gs_gylx-stlal.
- ls_routing-ztype = 'R'.
- ls_routing-datum = sy-datum.
- ls_routing-zgybb = gs_gylx-version.
- ls_routing-zgybh = gs_gylx-plnnr_alt.
- MODIFY ztplm_routing FROM ls_routing.
- COMMIT WORK AND WAIT.
- ENDIF.
- "MES 所需内容 END --------------------20200422-----------
- ENDIF.
- ENDIF.
- IF lv_modify = 'X'.
- "工艺路线-子项目 修改
- READ TABLE lt_gylx INTO gs_gylx INDEX 1.
- READ TABLE lt_mapl INTO wa_mapl WITH KEY matnr = gs_gylx-matnr
- werks = gs_gylx-werks
- plnal = gs_gylx-plnal
- loekz = ''.
- IF sy-subrc <> 0.
- "物料分配,此工艺路线+
- ls_materials-maintain_mode = 'C'.
- ls_materials-material = gs_gylx-matnr.
- ls_materials-plant = gs_gylx-werks.
- APPEND ls_materials TO lt_materials.
- ENDIF.
- * LOOP AT lt_mapl INTO wa_mapl.
- READ TABLE lt_mapl INTO wa_mapl INDEX 1.
- * DELETE lt_com_tab WHERE stlal_w <> gs_gylx-stlal.
- LOOP AT lt_com_tab INTO ls_com_tab.
- IF ls_com_tab-stlnr <> lt_mast-stlnr AND ls_com_tab-stlnr_w <> lt_mast-stlnr.
- DELETE lt_com_tab.
- CONTINUE.
- ENDIF.
- IF ls_com_tab-stlal_w IS INITIAL.
- IF ls_com_tab-stlal <> gs_gylx-stlal.
- DELETE lt_com_tab.
- CONTINUE.
- ENDIF.
- ELSE.
- IF ls_com_tab-stlal_w <> gs_gylx-stlal.
- DELETE lt_com_tab.
- CONTINUE.
- ENDIF.
- ENDIF.
- ENDLOOP.
- lt_gylx_temp = lt_gylx.
- * DELETE lt_gylx_temp WHERE plnal <> wa_mapl-plnal.
- SORT lt_gylx_temp BY matnr
- werks
- plnal "工艺路线-子项目 组计数器
- verwe "工艺路线-子项目 用途
- vornr."工艺路线-子项目 工序-子项目 工序号
- ***创建和修改
- CLEAR:lv_vornr.
- LOOP AT lt_gylx_temp INTO gs_gylx.
- IF sy-tabix = 1.
- * TASK 组
- CLEAR ls_h_task.
- * ls_h_task-group_counter = gs_gylx-plnal."组计数器
- ls_h_task-plant = gs_gylx-werks."工厂
- ls_h_task-task_list_usage = '1'. "任务清单使用
- ls_h_task-task_list_status = '4'."状态
- ls_h_task-description = gs_gylx-ktext."任务清单描述
- ls_h_task-task_measure_unit = ls_marc-meins.
- ls_h_task-old_number_of_task_list = gs_gylx-plnnr_alt.
- ls_h_task_x-description = 'X'.
- ENDIF.
- CLEAR:ls_operations,ls_operations_x.
- READ TABLE lt_opr_tab INTO ls_opr_tab
- WITH KEY vornr = gs_gylx-vornr.
- IF sy-subrc = 0.
- "工序修改
- ls_operations-maintain_mode = 'M'. "修改
- ELSE.
- "工序新建
- ls_operations-maintain_mode = 'C'. "创建
- ENDIF.
- "------------------修改于20200803--------------FROM----------
- IF lv_vornr IS INITIAL .
- lv_vornr = 1.
- ELSE.
- lv_vornr = lv_vornr + 1.
- ENDIF.
- ls_operations-flag_bar_pointer = lv_vornr.
- " ls_operations-flag_bar_pointer = gs_gylx-vornr / 10.
- "------------------修改于20200803--------------END-----------
- ls_operations-sequence_no = '000000'.
- ls_operations-activity = gs_gylx-vornr. "操作/活动编号
- ls_operations-control_key = gs_gylx-steus. "控制码
- ls_operations-standard_text_key = gs_gylx-ktsch. "工序标准文本码
- ls_operations-description = gs_gylx-txt. "工序标准文本码
- ls_operations-work_cntr = gs_gylx-arbpl. "工作中心
- * ls_operations-plant = gs_gylx-werks. "工作中心
- * ls_operations-denominator = '1'."用于转换工艺路线和工序单位的分母
- * ls_operations-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
- ls_operations-nominator = gs_gylx-umrez.
- ls_operations-denominator = gs_gylx-umren.
- ls_operations-base_quantity = gs_gylx-bmsch."基本数量
- ls_operations-operation_measure_unit = ls_marc-meins."单位
- PERFORM frm_get_op_plant USING gs_gylx-werks gs_gylx-arbpl CHANGING ls_operations-plant.
-
- ls_operations-info_rec = gs_gylx-infnr."采购信息记录
- ls_operations-purch_org = gs_gylx-ekorg."采购组织
- PERFORM ftm_get_cost_elem USING ls_operations-plant
- ls_operations-info_rec
- ls_operations-purch_org
- CHANGING ls_operations-cost_elem."成本要素
- * ls_operations-std_value_01 = gs_gylx-vgw01."工时
- * ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
- * ls_operations-std_value_02 = gs_gylx-vgw01."固定
- * ls_operations-std_unit_02 = gs_gylx-vge01."工时计量单位
- * ls_operations-std_value_03 = gs_gylx-vgw01."变动
- * ls_operations-std_unit_03 = gs_gylx-vge01."工时计量单位
- * ls_operations-std_value_04 = gs_gylx-vgw01."营运
- * ls_operations-std_unit_04 = gs_gylx-vge01."工时计量单位
- PERFORM frm_set_std_value USING ls_operations-plant
- gs_gylx-arbpl
- gs_gylx-vgw01
- gs_gylx-vge01
- CHANGING ls_operations-std_value_01
- ls_operations-std_unit_01
- ls_operations-std_value_02
- ls_operations-std_unit_02
- ls_operations-std_value_03
- ls_operations-std_unit_03
- ls_operations-std_value_04
- ls_operations-std_unit_04
- ls_operations-std_value_05
- ls_operations-std_unit_05
- ls_operations-std_value_06
- ls_operations-std_unit_06
- ls_operations-acttype_01
- ls_operations-acttype_02
- ls_operations-acttype_03
- ls_operations-acttype_04
- ls_operations-acttype_05
- ls_operations-acttype_06.
- * IF gs_gylx-steus = 'MQ01'.
- * ls_operations-acttype_01 = 'ZJ01'.
- * ENDIF.
- ls_operations-cost_relevant = 'X'.
- APPEND ls_operations TO lt_operations.
- IF ls_operations-maintain_mode = 'C'. "创建
- ls_operations_x-activity = 'X'. "操作/活动编号
- ENDIF.
- ls_operations_x-control_key = 'X'. "控制码
- ls_operations_x-standard_text_key = 'X'. "工序标准文本码
- ls_operations_x-description = 'X'. "工序标准文本码描述
- ls_operations_x-work_cntr = 'X'. "工作中心
- ls_operations_x-plant = 'X'. "工厂
- ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
- ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
- ls_operations_x-base_quantity = 'X'."基本数量
- ls_operations_x-operation_measure_unit = 'X'."单位
-
- ls_operations_x-std_value_01 = 'X'."工时
- ls_operations_x-std_unit_01 = 'X'."工时计量单位
- ls_operations_x-std_value_02 = 'X'."固定
- ls_operations_x-std_unit_02 = 'X'."工时计量单位
- ls_operations_x-std_value_03 = 'X'."变动
- ls_operations_x-std_unit_03 = 'X'."工时计量单位
- ls_operations_x-std_value_04 = 'X'."营运
- ls_operations_x-std_unit_04 = 'X'."工时计量单位
- ls_operations_x-std_value_05 = 'X'."外协
- ls_operations_x-std_unit_05 = 'X'."工时计量单位
- ls_operations_x-std_value_06 = 'X'."质检
- ls_operations_x-std_unit_06 = 'X'."工时计量单位
- ls_operations_x-cost_relevant = 'X'."成本核算表示
- ls_operations_x-info_rec = 'X'. "采购信息记录
- ls_operations_x-purch_org = 'X'. "采购组织
- ls_operations_x-cost_elem = 'X'."成本要素
- ls_operations_x-acttype_01 = 'X'.
- ls_operations_x-acttype_02 = 'X'.
- ls_operations_x-acttype_03 = 'X'.
- ls_operations_x-acttype_04 = 'X'.
- ls_operations_x-acttype_05 = 'X'.
- ls_operations_x-acttype_06 = 'X'.
- APPEND ls_operations_x TO lt_operations_x.
- ENDLOOP.
-
- "组件分配 component allocation -->工序
- IF lt_materials[] IS NOT INITIAL.
- REFRESH lt_com_tab[].
- ENDIF.
- LOOP AT lt_fpwlv INTO ls_fpwlv.
- READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
- posnr = ls_fpwlv-posnr.
- IF sy-subrc = 0.
- CHECK lt_stb-loekz IS INITIAL.
- CLEAR: ls_components, ls_components_x, ls_com_tab, ls_opr_tab.
- READ TABLE lt_com_tab INTO ls_com_tab
- WITH KEY stlty = 'M'
- stlnr = lt_stb-stlnr
- stlal = lt_stb-stlal
- stlkn = lt_stb-stvkn.
- IF sy-subrc = 0.
- READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
- CHECK ls_fpwlv-vornr <> ls_opr_tab-vornr.
- ls_components-maintain_mode = 'M'. "修改
- ELSE.
- ls_components-maintain_mode = 'C'. "创建
- ENDIF.
- lv_pointer = lv_pointer + 1.
- ls_components-flag_bar_pointer = lv_pointer.
- ls_components-sequence_no = '000000'.
- ls_components-activity = ls_fpwlv-vornr. "工序号
- ls_components-activity_old = ls_opr_tab-vornr.
- ls_components-bom_type = 'M' . "BOM 类别
- ls_components-bom_no = lt_stb-stlnr. "物料单
- ls_components-alternative_bom = gs_gylx-stlal."可选的 BOM
- ls_components-item_id = lt_stb-stvkn. "项目 ID
- ls_components-item_no = lt_stb-posnr. "BOM 项目号
- ls_components-plant = gs_gylx-werks. "工厂
- * ls_component-material = ls_fpwl-matnr. "物料号
- ls_component-material = ''.
- ls_components-backflush = lt_stb-rgekz.
- ls_components-bom_type_root = 'M'.
- ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
- ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
- "虚拟件分配,填入level和path
- IF lt_stb-dumps IS NOT INITIAL.
- * CLEAR ls_phantom.
- ** ls_components-material = gs_gylx-matnr.
- * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
- * wegxx = lt_stb-wegxx.
- * ls_components-order_lvl = ls_phantom-level.
- * ls_components-order_path = ls_phantom-path.
- ls_components-order_lvl = lt_stb-aufst.
- ls_components-order_path = lt_stb-aufwg.
-
- READ TABLE lt_stpox INTO ls_stpox WITH KEY stufe = lt_stb-stufe
- wegxx = lt_stb-wegxx.
- IF sy-subrc = 0.
- ls_components-path = ls_stpox-nlink.
- ENDIF.
- * ls_components-path = lt_stb-aufwg.
-
- ELSE.
- IF lt_stb-stufe > 1.
- ls_components-material = gs_gylx-matnr.
- READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
- wegxx = lt_stb-vwegx.
- IF sy-subrc = 0.
- ls_components-order_lvl = ls_phantom-level.
- ls_components-order_path = ls_phantom-path.
- * READ TABLE lt_stb WITH KEY stufe = 1
- * wegxx = lt_stb-vwegx.
- * IF sy-subrc = 0.
- ls_components-bom_type_root = 'M'.
- ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
- ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
- * ENDIF.
- ENDIF.
- ENDIF.
- ENDIF.
- APPEND ls_components TO lt_components.
-
- ls_components_x-activity = 'X'. "操作/活动编号
- IF ls_components-maintain_mode = 'C'.
- ls_components_x-sequence_no = 'X'.
- ls_components_x-plant = 'X'. "工厂
- * ls_components_x-material = 'X'. "物料号
- ls_components_x-material = 'X'.
- ls_components_x-backflush = 'X'.
- ls_components_x-order_lvl = 'X'.
- ls_components_x-order_path = 'X'.
- ls_components_x-path = 'X'.
- ls_components_x-bom_type_root = 'X'.
- ls_components_x-bom_no_root = 'X'.
- ls_components_x-alternative_bom_root = 'X'.
- ENDIF.
- APPEND ls_components_x TO lt_components_x.
- ENDIF.
- ENDLOOP.
- **删除
- *工序删除无法处理组件分配自动删除,单独BDC处理
- CLEAR:lv_pointer.
- LOOP AT lt_operations INTO ls_operations.
- lv_pointer = ls_operations-flag_bar_pointer.
- ENDLOOP.
- LOOP AT lt_opr_tab INTO ls_opr_tab.
- READ TABLE lt_gylx_temp INTO gs_gylx WITH KEY vornr = ls_opr_tab-vornr.
- IF sy-subrc <> 0.
- CLEAR:ls_operations,ls_operations_x.
- ls_operations-maintain_mode = 'D'. "删除
- "------------------修改于20200803--------------FROM----------
- IF lv_pointer IS INITIAL .
- lv_pointer = 1.
- ELSE.
- lv_pointer = lv_pointer + 1.
- ENDIF.
- ls_operations-flag_bar_pointer = lv_pointer.
- " ls_operations-flag_bar_pointer = ls_opr_tab-vornr / 10.
- "------------------修改于20200803--------------END-----------
- ls_operations-sequence_no = '000000'.
- ls_operations-activity = ls_opr_tab-vornr. "操作/活动编号
-
- APPEND ls_operations TO lt_operations_del.
- * ls_operations_x-control_key = 'X'. "控制码
- * ls_operations_x-standard_text_key = 'X'. "工序标准文本码
- * ls_operations_x-description = 'X'. "工序标准文本码描述
- * ls_operations_x-work_cntr = 'X'. "工作中心
- * ls_operations_x-plant = 'X'. "工厂
- * ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
- * ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
- * ls_operations_x-base_quantity = 'X'."基本数量
- * ls_operations_x-operation_measure_unit = 'X'."单位
- * ls_operations_x-std_value_01 = 'X'."工时
- * ls_operations_x-std_unit_01 = 'X'."工时计量单位
- * ls_operations_x-std_value_02 = 'X'."固定
- * ls_operations_x-std_unit_02 = 'X'."工时计量单位
- * ls_operations_x-std_value_03 = 'X'."变动
- * ls_operations_x-std_unit_03 = 'X'."工时计量单位
- * ls_operations_x-std_value_04 = 'X'."营运
- * ls_operations_x-std_unit_04 = 'X'."工时计量单位
- * ls_operations_x-std_value_05 = 'X'."外协
- * ls_operations_x-std_unit_05 = 'X'."工时计量单位
- * ls_operations_x-std_value_06 = 'X'."质检
- * ls_operations_x-std_unit_06 = 'X'."工时计量单位
- *
- * APPEND ls_operations_x TO lt_operations_x.
- ENDIF.
- ENDLOOP.
- * SORT lt_operations BY activity.
- CLEAR:lv_pointer.
- LOOP AT lt_components INTO ls_components.
- lv_pointer = ls_components-flag_bar_pointer.
- ENDLOOP.
- LOOP AT lt_com_tab INTO ls_com_tab.
- CLEAR: lt_stb, ls_opr_tab, ls_fpwlv.
- READ TABLE lt_stb WITH KEY stlty = ls_com_tab-stlty
- stlnr = ls_com_tab-stlnr
- stlal = ls_com_tab-stlal
- stvkn = ls_com_tab-stlkn.
- CHECK sy-subrc = 0.
- READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
- READ TABLE lt_fpwlv INTO ls_fpwlv WITH KEY posnr = lt_stb-posnr
- matnr = lt_stb-idnrk.
- * vornr = ls_opr_tab-vornr.
- CHECK sy-subrc <> 0.
- CLEAR: ls_components, ls_components_x.
- ls_components-maintain_mode = 'D'. "删除
- IF lv_pointer IS INITIAL.
- lv_pointer = 1.
- ELSE.
- lv_pointer = lv_pointer + 1.
- ENDIF.
- ls_components-flag_bar_pointer = lv_pointer.
- ls_components-sequence_no = ls_com_tab-plnfl.
- ls_components-activity = ls_opr_tab-vornr. "工序号
- ls_components-bom_type = 'M' . "BOM 类别
- ls_components-bom_no = ls_com_tab-stlnr. "物料单
- ls_components-alternative_bom = ls_com_tab-stlal."可选的 BOM
- ls_components-item_id = lt_stb-stvkn. "项目 ID
- ls_components-item_no = lt_stb-posnr. "BOM 项目号
- ls_components-plant = ls_com_tab-werk_stl. "工厂
- * ls_component-material = ls_fpwl-matnr. "物料号
- ls_component-material = ''.
- IF ls_com_tab-stlst IS NOT INITIAL AND lt_stb-dumps IS INITIAL.
- ls_components-material = gs_gylx-matnr.
- ENDIF.
- ls_components-backflush = ls_com_tab-rgekz.
- ls_components-order_lvl = ls_com_tab-stlst.
- ls_components-order_path = ls_com_tab-stlwg.
- ls_components-bom_type_root = ls_com_tab-stlty_w.
- ls_components-bom_no_root = ls_com_tab-stlnr_w.
- ls_components-alternative_bom_root = ls_com_tab-stlal_w.
- ls_components-path = ls_com_tab-kante.
- APPEND ls_components TO lt_components.
-
- ls_components_x-sequence_no = 'X'.
- ls_components_x-activity = 'X'. "工序号
- ls_components_x-plant = 'X'. "工厂
- ls_components_x-material = 'X'. "物料号
- ls_components_x-backflush = 'X'.
- ls_components_x-order_lvl = 'X'.
- ls_components_x-order_path = 'X'.
- ls_components_x-bom_type_root = 'X'.
- ls_components_x-bom_no_root = 'X'.
- ls_components_x-alternative_bom_root = 'X'.
- ls_components_x-path = 'X'.
- APPEND ls_components_x TO lt_components_x.
- ENDLOOP.
- * SORT lt_components.SORT lt_components_x.
- CALL FUNCTION 'ROUTING_MAINTAIN'
- EXPORTING
- change_no = lv_changeno
- key_date = sy-datum
- task_list_group = wa_mapl-plnnr "组
- * group_counter = wa_mapl-plnal "组计数器
- * material = wa_mapl-matnr "物料编号
- * plant = wa_mapl-werks "工厂
- group_counter = gs_gylx-plnal "组计数器
- material = gs_gylx-matnr "物料编号
- plant = gs_gylx-werks "工厂
- task = ls_h_task
- task_x = ls_h_task_x
- application = 'PP01'
- bom_usage = lt_mast-stlan
- TABLES
- material_task_allocations = lt_materials
- material_task_allocations_x = lt_materials_x
- * SEQUENCES = SEQUENCES
- * SEQUENCES_X = SEQUENCES_X
- operations = lt_operations
- operations_x = lt_operations_x
- component_allocations = lt_components
- component_allocations_x = lt_components_x
- return = lt_return.
- * READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
- LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
- ENDLOOP.
- IF sy-subrc = 0.
- return-type = 'E'.
- LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
- return-id = ls_return-id.
- * return-type = ls_return-type.
- return-number = ls_return-number.
- MESSAGE ID ls_return-id
- TYPE ls_return-type
- NUMBER ls_return-number
- WITH ls_return-message_v1
- ls_return-message_v2
- ls_return-message_v3
- ls_return-message_v4
- INTO lv_message.
- CONCATENATE return-message lv_message INTO return-message.
- ENDLOOP.
- ROLLBACK WORK.
- ELSE.
- "ls_out-flg = 'X'.
- CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
- EXPORTING
- wait = 'X'.
- IF lt_operations_del[] IS NOT INITIAL.
- WAIT UP TO 1 SECONDS.
- PERFORM frm_delete_operation TABLES lt_operations_del
- USING lv_group gs_gylx-matnr gs_gylx-werks
- CHANGING return.
- ENDIF.
- IF return-type <> 'E'.
- return-type = 'S'.
- return-message = '系统处理成功!'.
- "保存版本,供ME使用----------------------------
- "MES 所需内容 FROM--------------------20200422-----------
- READ TABLE et_gylx INTO gs_gylx INDEX 1.
- IF gs_gylx-version IS NOT INITIAL.
- CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
- EXPORTING
- input = gs_gylx-matnr
- IMPORTING
- output = ls_routing-matnr.
- ls_routing-werks = gs_gylx-werks.
- ls_routing-stlal = gs_gylx-stlal.
- ls_routing-ztype = 'R'.
- ls_routing-datum = sy-datum.
- ls_routing-zgybb = gs_gylx-version.
- ls_routing-zgybh = gs_gylx-plnnr_alt.
- MODIFY ztplm_routing FROM ls_routing.
- COMMIT WORK AND WAIT.
- ENDIF.
- ENDIF.
- ENDIF.
- "更改工艺路线
- CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
- lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
-
- * ENDLOOP.
- ENDIF.
-
- "发送安达发MES
- IF return-type = 'S' AND ls_routing IS NOT INITIAL.
- CALL FUNCTION 'ZJKPLM006_TO_MES' IN BACKGROUND TASK
- EXPORTING
- matnr = ls_routing-matnr
- werks = ls_routing-werks
- stlal = ls_routing-stlal
- datum = ls_routing-datum
- zgybh = ls_routing-zgybh
- zgybb = ls_routing-zgybb.
- COMMIT WORK.
- ENDIF.
- ENDIF.
- ENDFUNCTION.
- *&---------------------------------------------------------------------*
- *& Form FRM_BDC_DYNPRO
- *&---------------------------------------------------------------------*
- * -->PT_BDCDATA text
- * -->PV_PROGRAM text
- * -->PV_DYNPRO text
- *----------------------------------------------------------------------*
- FORM frm_bdc_dynpro TABLES pt_bdcdata STRUCTURE bdcdata
- USING pv_program
- pv_dynpro.
- DATA: ls_bdcdata TYPE bdcdata.
- WRITE pv_program TO ls_bdcdata-program.
- WRITE pv_dynpro TO ls_bdcdata-dynpro.
- WRITE 'X' TO ls_bdcdata-dynbegin.
- APPEND ls_bdcdata TO pt_bdcdata.
- CLEAR ls_bdcdata.
- ENDFORM. " BDC_DYNPRO
- *&---------------------------------------------------------------------*
- *& Form FRM_BDC_FIELD
- *&---------------------------------------------------------------------*
- * -->PT_BDCDATA text
- * -->PV_FNAM text
- * -->PV_FVAL text
- *----------------------------------------------------------------------*
- FORM frm_bdc_field TABLES pt_bdcdata STRUCTURE bdcdata
- USING pv_fnam
- pv_fval.
- DATA:ls_bdcdata TYPE bdcdata.
- DATA:lv_type TYPE c.
-
- DESCRIBE FIELD pv_fval TYPE lv_type.
-
- WRITE pv_fnam TO ls_bdcdata-fnam.
- IF lv_type = 'D'.
- WRITE pv_fval TO ls_bdcdata-fval DD/MM/YYYY.
- ELSEIF lv_type = 'C' OR lv_type = 'N'.
- ls_bdcdata-fval = pv_fval.
- ELSE.
- WRITE pv_fval TO ls_bdcdata-fval LEFT-JUSTIFIED.
- ENDIF.
- APPEND ls_bdcdata TO pt_bdcdata.
- CLEAR ls_bdcdata.
- ENDFORM. " BDC_FIELD
- *&---------------------------------------------------------------------*
- *& Form FRM_GET_PHANTOM
- *&---------------------------------------------------------------------*
- * -->PT_STB TEXT
- * -->PT_PHANTOM TEXT
- *----------------------------------------------------------------------*
- FORM frm_get_phantom TABLES pt_stb STRUCTURE stpox
- pt_com STRUCTURE capp_com
- pt_phantom LIKE gt_phantom.
- TYPES: BEGIN OF ty_mast,
- matnr TYPE mast-matnr,
- werks TYPE mast-werks,
- stlan TYPE mast-stlan,
- stlnr TYPE mast-stlnr,
- stlal TYPE mast-stlal,
- END OF ty_mast.
- TYPES: BEGIN OF ty_path,
- level TYPE aufst,
- path TYPE aufwg,
- END OF ty_path.
- DATA: ls_mast TYPE ty_mast.
- DATA: ls_com TYPE capp_com.
- DATA: lt_path TYPE TABLE OF ty_path,
- ls_path TYPE ty_path.
- DATA: ls_stb TYPE stpox,
- ls_phantom TYPE ty_phantom.
- DATA: lv_index TYPE sy-tabix.
- DATA: lv_flg_ftrel TYPE xfeld.
- LOOP AT pt_com INTO ls_com.
- ls_path-level = ls_com-stlst.
- ls_path-path = ls_com-stlwg.
- APPEND ls_path TO lt_path.
- ENDLOOP.
- SORT lt_path.
- DELETE ADJACENT DUPLICATES FROM lt_path COMPARING ALL FIELDS.
- REFRESH pt_phantom.
- * CALL FUNCTION 'CM_DI_GET_FTREL_FLAG'
- * IMPORTING
- * e_flg_ftrel = lv_flg_ftrel.
- LOOP AT pt_stb INTO ls_stb WHERE dumps IS NOT INITIAL AND idnrk IS NOT INITIAL.
- SELECT SINGLE matnr werks stlan stlnr stlal
- INTO ls_mast
- FROM mast
- WHERE matnr = ls_stb-idnrk
- AND werks = ls_stb-werks
- AND stlal = ls_stb-stlal
- AND stlan = ls_stb-stlan.
- "虚拟件的level/path
- CLEAR ls_phantom.
- ls_phantom-stufe = ls_stb-stufe.
- ls_phantom-wegxx = ls_stb-wegxx.
- ls_phantom-level = ls_stb-stufe.
- READ TABLE pt_com INTO ls_com WITH KEY stlnr = ls_mast-stlnr.
- IF sy-subrc = 0.
- ls_phantom-path = ls_com-stlwg.
- ELSE.
- READ TABLE lt_path INTO ls_path WITH KEY level = ls_phantom-level.
- IF sy-subrc = 0.
- lv_index = sy-tabix.
- ls_path-path = ls_path-path + 1.
- MODIFY lt_path FROM ls_path INDEX lv_index.
- ls_phantom-path = ls_path-path.
- ELSE.
- ls_path-level = ls_phantom-level.
- ls_path-path = 1.
- APPEND ls_path TO lt_path.
- ls_phantom-path = ls_path-path.
- ENDIF.
- ENDIF.
- APPEND ls_phantom TO pt_phantom.
- ENDLOOP.
-
- ENDFORM.
- *&---------------------------------------------------------------------*
- *& Form FRM_SET_STD_VALUE
- *&---------------------------------------------------------------------*
- * -->PT_STB TEXT
- * -->PT_PHANTOM TEXT
- *----------------------------------------------------------------------*
- FORM frm_set_std_value USING pv_werks TYPE werks_d
- pv_arbpl TYPE arbpl
- pv_std_value TYPE vgwrt
- pv_std_unit TYPE vgwrteh
- CHANGING pv_std_value_01 TYPE vgwrt
- pv_std_unit_01 TYPE vgwrteh
- pv_std_value_02 TYPE vgwrt
- pv_std_unit_02 TYPE vgwrteh
- pv_std_value_03 TYPE vgwrt
- pv_std_unit_03 TYPE vgwrteh
- pv_std_value_04 TYPE vgwrt
- pv_std_unit_04 TYPE vgwrteh
- pv_std_value_05 TYPE vgwrt
- pv_std_unit_05 TYPE vgwrteh
- pv_std_value_06 TYPE vgwrt
- pv_std_unit_06 TYPE vgwrteh
- pv_acttype_01 TYPE lstar
- pv_acttype_02 TYPE lstar
- pv_acttype_03 TYPE lstar
- pv_acttype_04 TYPE lstar
- pv_acttype_05 TYPE lstar
- pv_acttype_06 TYPE lstar.
- DATA: ls_crhd TYPE crhd,
- ls_crco TYPE crco,
- lt_crco TYPE TABLE OF crco.
-
- CLEAR: pv_std_value_01,
- pv_std_unit_01,
- pv_std_value_02,
- pv_std_unit_02,
- pv_std_value_03,
- pv_std_unit_03,
- pv_std_value_04,
- pv_std_unit_04,
- pv_std_value_05,
- pv_std_unit_05,
- pv_std_value_06,
- pv_std_unit_06,
- pv_acttype_01,
- pv_acttype_02,
- pv_acttype_03,
- pv_acttype_04,
- pv_acttype_05,
- pv_acttype_06
- .
- SELECT SINGLE * INTO ls_crhd
- FROM crhd
- WHERE objty = 'A'
- AND werks = pv_werks
- AND arbpl = pv_arbpl
- AND begda <= sy-datum
- AND endda >= sy-datum.
- CHECK sy-subrc = 0.
- SELECT * INTO TABLE lt_crco
- FROM crco
- WHERE objty = 'A'
- AND objid = ls_crhd-objid
- AND begda <= sy-datum
- AND endda >= sy-datum.
- LOOP AT lt_crco INTO ls_crco.
- CASE ls_crco-lanum.
- WHEN 1.
- pv_std_value_01 = pv_std_value.
- pv_std_unit_01 = pv_std_unit.
- pv_acttype_01 = ls_crco-lstar.
- WHEN 2.
- pv_std_value_02 = pv_std_value.
- pv_std_unit_02 = pv_std_unit.
- pv_acttype_02 = ls_crco-lstar.
- WHEN 3.
- pv_std_value_03 = pv_std_value.
- pv_std_unit_03 = pv_std_unit.
- pv_acttype_03 = ls_crco-lstar.
- WHEN 4.
- pv_std_value_04 = pv_std_value.
- pv_std_unit_04 = pv_std_unit.
- pv_acttype_04 = ls_crco-lstar.
- WHEN 5.
- pv_std_value_05 = pv_std_value.
- pv_std_unit_05 = pv_std_unit.
- pv_acttype_05 = ls_crco-lstar.
- WHEN 6.
- pv_std_value_06 = pv_std_value.
- pv_std_unit_06 = pv_std_unit.
- pv_acttype_06 = ls_crco-lstar.
- WHEN OTHERS.
- ENDCASE.
- ENDLOOP.
-
- ENDFORM.
- "确定工序工厂
- "根据工作中心判定,只找到一个工厂则能够确定;找到多个工厂/找不到,无法确定,则取工艺路线工厂
- FORM frm_get_op_plant USING pv_werks_in TYPE werks_d
- pv_arbpl TYPE arbpl
- CHANGING pv_werks_o TYPE werks_d.
- DATA: lt_crhd TYPE TABLE OF crhd WITH HEADER LINE.
-
- CLEAR pv_werks_o.
- SELECT * INTO TABLE lt_crhd
- FROM crhd
- WHERE objty = 'A'
- AND arbpl = pv_arbpl
- AND begda <= sy-datum
- AND endda >= sy-datum.
- IF lines( lt_crhd ) = 1.
- READ TABLE lt_crhd INDEX 1.
- pv_werks_o = lt_crhd-werks.
- ELSE.
- pv_werks_o = pv_werks_in.
- ENDIF.
- ENDFORM.
-
- FORM frm_delete_operation TABLES pt_operations_del STRUCTURE cps_task_list_maint_opr
- USING pv_group TYPE bapi1012_tsk_c-task_list_group
- pv_matnr TYPE matnr
- pv_werks TYPE werks_d
- CHANGING ps_return TYPE zsplm_return.
- DATA: ls_operations_del TYPE cps_task_list_maint_opr.
- DATA: ls_params TYPE ctu_params,
- ls_msg TYPE bdcmsgcoll.
-
- LOOP AT pt_operations_del INTO ls_operations_del.
- REFRESH: bdcdata, messtab.
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1010'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=VOUE'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'RC27M-MATNR' pv_matnr.
- PERFORM frm_bdc_field TABLES bdcdata USING 'RC27M-WERKS' pv_werks.
- PERFORM frm_bdc_field TABLES bdcdata USING 'RC271-PLNNR' pv_group.
-
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=OSEA'.
-
- * LOOP AT pt_operations_del INTO ls_operations_del.
-
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCP02' '1010'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=ENT1'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'RC27H-VORNR' ls_operations_del-activity.
-
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=LOE'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'RC27X-FLG_SEL(01)' 'X'.
-
- * PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLSPO1' '0100'.
- * PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=YES'.
- *ENDLOOP.
-
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLSPO1' '0100'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=YES'.
-
- PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
- PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=BU'.
- ls_params-dismode = 'N'.
- ls_params-updmode = 'S'.
- ls_params-defsize = 'X'.
- CALL TRANSACTION 'CA02' USING bdcdata
- OPTIONS FROM ls_params
- MESSAGES INTO messtab.
- READ TABLE messtab INTO ls_msg WITH KEY msgtyp = 'E'.
- IF sy-subrc = 0.
- ps_return-type = 'E'.
- ps_return-id = ls_msg-msgid.
- ps_return-number = ls_msg-msgnr.
- MESSAGE ID ls_msg-msgid TYPE ls_msg-msgtyp NUMBER ls_msg-msgnr
- WITH ls_msg-msgv1
- ls_msg-msgv2
- ls_msg-msgv3
- ls_msg-msgv4
- INTO ps_return-message.
- ENDIF.
-
- ENDLOOP.
-
- ENDFORM.
- FORM ftm_get_cost_elem USING pv_werks TYPE werks_d
- pv_infnr TYPE infnr
- pv_ekorg TYPE ekorg
- CHANGING pv_kstar TYPE kstar.
- DATA: lv_matkl TYPE matkl.
-
- CLEAR pv_kstar.
-
- CHECK pv_infnr IS NOT INITIAL.
- SELECT SINGLE matkl INTO lv_matkl
- FROM eina
- WHERE infnr = pv_infnr.
- CHECK sy-subrc = 0.
- CALL FUNCTION 'CO_ZF_ACCOUNT_FIND'
- EXPORTING
- matnr_imp = space
- knttp_imp = 'F'
- shkzg_imp = 'H'
- werks_imp = pv_werks
- matkl_imp = lv_matkl
- IMPORTING
- saknr_exp = pv_kstar.
-
- ENDFORM.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。