当前位置:   article > 正文

SAP FM: ROUTING_MAINTAIN - 工艺路线组件分配(含虚拟件)

routing_maintain
  •  读取工艺路线
  1. CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
  2. CALL FUNCTION 'CARO_ROUTING_READ'
  3. EXPORTING
  4. date_from = sy-datum
  5. date_to = '99991231'
  6. plnty = 'N' "任务清单类型
  7. plnnr = gs_gylx-plnnr "任务清单组键值
  8. plnal = gs_gylx-plnal "组计数器
  9. matnr = gs_gylx-matnr "物料
  10. TABLES
  11. tsk_tab = lt_tsk_tab
  12. seq_tab = lt_seq_tab
  13. opr_tab = lt_opr_tab
  14. * com_tab = lt_com_tab
  15. EXCEPTIONS
  16. not_found = 1
  17. ref_not_exp = 2
  18. not_valid = 3
  19. OTHERS = 4.

  • 读取BOM信息: CS_BOM_EXPL_MAT_V2
  1. CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
  2. SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
  3. FROM mast
  4. INNER JOIN stko
  5. ON mast~stlnr = stko~stlnr
  6. AND mast~stlal = stko~stlal
  7. WHERE mast~matnr = gs_gylx-matnr
  8. AND mast~werks = gs_gylx-werks
  9. AND mast~stlal = gs_gylx-stlal
  10. AND stko~stlty = 'M'.
  11. CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
  12. EXPORTING
  13. aufsw = 'X' "确定订单层次与路径(工艺路线虚拟组件分配的时候需要根据这个标识获取订单层次与路径)
  14. capid = 'PP01'
  15. datuv = sy-datum
  16. emeng = 1
  17. mdnot = 'X'
  18. mdmps = 'X' "展开虚拟件
  19. mehrs = 'X' "展开多层
  20. mtnrv = lt_mast-matnr
  21. stlal = lt_mast-stlal
  22. stlan = lt_mast-stlan
  23. werks = lt_mast-werks
  24. IMPORTING
  25. topmat = ls_topmat
  26. TABLES
  27. stb = lt_stb
  28. EXCEPTIONS
  29. alt_not_found = 1
  30. call_invalid = 2
  31. material_not_found = 3
  32. missing_authorization = 4
  33. no_bom_found = 5
  34. no_plant_data = 6
  35. no_suitable_bom_found = 7
  36. conversion_error = 8
  37. OTHERS = 9.
  • 确定工艺路线组件分配的层次和路径: CS_X4_NODE_DETERMINATION
  1. DATA: lt_stpox TYPE TABLE OF stpox,
  2. ls_stpox TYPE stpox.
  3. CLEAR: lt_stpox, ls_stpox.
  4. APPEND LINES OF lt_stb[] TO lt_stpox.
  5. CALL FUNCTION 'CS_X4_NODE_DETERMINATION'
  6. EXPORTING
  7. i_stlty_w = ls_topmat-stlty "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
  8. i_stlnr_w = ls_topmat-stlnr "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
  9. i_stlal_w = ls_topmat-stlal "根据上一步CS_BOM_EXPL_MAT_V2获取的值传入进来
  10. i_flg_create_nodes = 'X'
  11. i_flg_node_for_class = 'X'
  12. i_flg_check_node = 'X'
  13. i_flg_special_class = 'X'
  14. i_flg_node_for_assem = 'X'
  15. i_flg_calc_path2 = 'X'
  16. i_flg_calc_path4 = 'X'
  17. TABLES
  18. stb = lt_stpox "根据上一步函数CS_BOM_EXPL_MAT_V2得到BOM列表信息传入赋值进来
  19. EXCEPTIONS
  20. wrong_initialization = 1
  21. foreign_lock = 2
  22. system_failure = 3
  23. stb_inconsistent = 4
  24. stvkn_not_initialized = 5
  25. OTHERS = 6.
  26. IF sy-subrc <> 0.
  27. * Implement suitable error handling here
  28. ENDIF.

备注:该函数必须要由上一步读取BOM信息函数CS_BOM_EXPL_MAT_V2之后使用,需要使用上一步跑出来的BOM信息作为传入参数,然后计算出工艺路线的组件分配的层次与路径

  • 组件分配 component allocation -->工序
  1. LOOP AT lt_fpwlv INTO ls_fpwlv.
  2. READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
  3. posnr = ls_fpwlv-posnr.
  4. IF sy-subrc = 0.
  5. CHECK lt_stb-loekz IS INITIAL.
  6. CLEAR: ls_components, ls_components_x, ls_com_tab, ls_opr_tab.
  7. READ TABLE lt_com_tab INTO ls_com_tab
  8. WITH KEY stlty = 'M'
  9. stlnr = lt_stb-stlnr
  10. stlal = lt_stb-stlal
  11. stlkn = lt_stb-stvkn.
  12. IF sy-subrc = 0.
  13. READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
  14. CHECK ls_fpwlv-vornr <> ls_opr_tab-vornr.
  15. ls_components-maintain_mode = 'M'. "修改
  16. ELSE.
  17. ls_components-maintain_mode = 'C'. "创建
  18. ENDIF.
  19. lv_pointer = lv_pointer + 1.
  20. ls_components-flag_bar_pointer = lv_pointer.
  21. ls_components-sequence_no = '000000'.
  22. ls_components-activity = ls_fpwlv-vornr. "工序号
  23. ls_components-activity_old = ls_opr_tab-vornr.
  24. ls_components-bom_type = 'M' . "BOM 类别
  25. ls_components-bom_no = lt_stb-stlnr. "物料单
  26. ls_components-alternative_bom = gs_gylx-stlal."可选的 BOM
  27. ls_components-item_id = lt_stb-stvkn. "项目 ID
  28. ls_components-item_no = lt_stb-posnr. "BOM 项目号
  29. ls_components-plant = gs_gylx-werks. "工厂
  30. * ls_component-material = ls_fpwl-matnr. "物料号
  31. ls_component-material = ''.
  32. ls_components-backflush = lt_stb-rgekz.
  33. * 以下三行代码必须得传输,不然在生产订单上根据工艺路线带入的时候会有问题
  34. ls_components-bom_type_root = 'M'.
  35. ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
  36. ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
  37. "虚拟件分配,填入level和path
  38. IF lt_stb-dumps IS NOT INITIAL.
  39. * CLEAR ls_phantom.
  40. ** ls_components-material = gs_gylx-matnr.
  41. * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
  42. * wegxx = lt_stb-wegxx.
  43. * ls_components-order_lvl = ls_phantom-level.
  44. * ls_components-order_path = ls_phantom-path.
  45. ls_components-order_lvl = lt_stb-aufst. "根据BOM展开函数获取的订单层次
  46. ls_components-order_path = lt_stb-aufwg. "根据BOM展开函数获取的订单路径
  47. READ TABLE lt_stpox INTO ls_stpox WITH KEY stufe = lt_stb-stufe
  48. wegxx = lt_stb-wegxx.
  49. IF sy-subrc = 0.
  50. ls_components-path = ls_stpox-nlink. "根据CS_X4_NODE_DETERMINATION获取的BOM的路径
  51. ENDIF.
  52. * ls_components-path = lt_stb-aufwg.
  53. ELSE.
  54. IF lt_stb-stufe > 1.
  55. ls_components-material = gs_gylx-matnr.
  56. READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
  57. wegxx = lt_stb-vwegx.
  58. IF sy-subrc = 0.
  59. ls_components-order_lvl = ls_phantom-level.
  60. ls_components-order_path = ls_phantom-path.
  61. * READ TABLE lt_stb WITH KEY stufe = 1
  62. * wegxx = lt_stb-vwegx.
  63. * IF sy-subrc = 0.
  64. ls_components-bom_type_root = 'M'.
  65. ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
  66. ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
  67. * ENDIF.
  68. ENDIF.
  69. ENDIF.
  70. ENDIF.
  71. APPEND ls_components TO lt_components.
  72. ls_components_x-activity = 'X'. "操作/活动编号
  73. IF ls_components-maintain_mode = 'C'.
  74. ls_components_x-sequence_no = 'X'.
  75. ls_components_x-plant = 'X'. "工厂
  76. * ls_components_x-material = 'X'. "物料号
  77. ls_components_x-material = 'X'.
  78. ls_components_x-backflush = 'X'.
  79. ls_components_x-order_lvl = 'X'.
  80. ls_components_x-order_path = 'X'.
  81. ls_components_x-path = 'X'.
  82. ls_components_x-bom_type_root = 'X'.
  83. ls_components_x-bom_no_root = 'X'.
  84. ls_components_x-alternative_bom_root = 'X'.
  85. ENDIF.
  86. APPEND ls_components_x TO lt_components_x.
  87. ENDIF.
  88. ENDLOOP.

  • 工艺路线修改处理: ROUTING_MAINTAIN

 

  1. CALL FUNCTION 'ROUTING_MAINTAIN'
  2. EXPORTING
  3. change_no = lv_changeno
  4. key_date = sy-datum
  5. task_list_group = wa_mapl-plnnr "组
  6. * group_counter = wa_mapl-plnal "组计数器
  7. * material = wa_mapl-matnr "物料编号
  8. * plant = wa_mapl-werks "工厂
  9. group_counter = gs_gylx-plnal "组计数器
  10. material = gs_gylx-matnr "物料编号
  11. plant = gs_gylx-werks "工厂
  12. task = ls_h_task
  13. task_x = ls_h_task_x
  14. application = 'PP01'
  15. bom_usage = lt_mast-stlan
  16. TABLES
  17. material_task_allocations = lt_materials
  18. material_task_allocations_x = lt_materials_x
  19. * SEQUENCES = SEQUENCES
  20. * SEQUENCES_X = SEQUENCES_X
  21. operations = lt_operations
  22. operations_x = lt_operations_x
  23. component_allocations = lt_components
  24. component_allocations_x = lt_components_x
  25. return = lt_return.

完整代码:

  1. FUNCTION zjkplm006.
  2. *"----------------------------------------------------------------------
  3. *"*"本地接口:
  4. *" EXPORTING
  5. *" VALUE(RETURN) TYPE ZSPLM_RETURN
  6. *" TABLES
  7. *" ET_GYLX STRUCTURE ZJKPLM006
  8. *"----------------------------------------------------------------------
  9. "假定:接口参数中物料MATNR和工厂WERKS是同一组
  10. *MATNR 1 类型 MATNR CHAR 18 0 物料号
  11. *WERKS 1 类型 WERKS_D CHAR 4 0 工厂
  12. "工艺路线-子项目*VERWE 1 类型 PLN_VERWE CHAR 3 0 任务清单使用
  13. "工艺路线-子项目*PLNAL 1 类型 PLNAL CHAR 2 0 组计数器
  14. "工艺路线-子项目*KTEXT 1 类型 PLANTEXT CHAR 40 0 任务清单描述
  15. "工艺路线-子项目 工序-子项目*VORNR 1 类型 VORNR CHAR 4 0 操作/活动编号
  16. "工艺路线-子项目 工序-子项目*ARBPL 1 类型 ARBPL CHAR 8 0 工作中心
  17. "工艺路线-子项目 工序-子项目*STEUS 1 类型 STEUS CHAR 4 0 控制码
  18. "工艺路线-子项目 工序-子项目*KTSCH 1 类型 KTSCH CHAR 7 0 标准文本码
  19. "工艺路线-子项目 工序-子项目*TXT 1 类型 VLSCH_TXT CHAR 40 0 标准文本码描述
  20. "工艺路线-子项目 工序-子项目*UMREZ 1 类型 CP_UMREZ DEC 5 0 用于转换任务清单和工序计量单位的计数器
  21. "工艺路线-子项目 工序-子项目*UMREN 1 类型 CP_UMREN DEC 5 0 用于转换工艺路线和工序单位的分母
  22. "工艺路线-子项目 工序-子项目*BMSCH 1 类型 BMSCH QUAN 13 3 基本数量
  23. "工艺路线-子项目 工序-子项目*VGW01 1 类型 VGWRT QUAN 9 3 标准值
  24. "工艺路线-子项目 工序-子项目*VGE01 1 类型 VGWRTEH UNIT 3 0 标准值计量单位
  25. "工艺路线-子项目 工序-子项目 组件分配*FPWL 1 类型 CHAR 255 0 分配物料
  26. *MESS 1 类型 CHAR 255 0 消息
  27. TABLES:t435,t435t.
  28. TYPES:BEGIN OF ty_out,
  29. matnr TYPE mapl-matnr, " 物料
  30. werks TYPE mapl-werks, " 物料工厂
  31. verwe TYPE plko-verwe, " 用途
  32. plnal TYPE mapl-plnal, "组计数器
  33. ktext TYPE plko-ktext, "工艺路线描述
  34. vornr TYPE plpo-vornr, " 工序号
  35. arbpl TYPE crhd-arbpl, " 工作中心
  36. steus TYPE plpo-steus, " 控制码
  37. ktsch TYPE plpo-ktsch, "工序标准文本码
  38. txt TYPE vlsch_txt, "工序标准文本码描述
  39. umrez TYPE plpo-umrez, "工艺路线抬头数量
  40. umren TYPE plpo-umren, "工序数量
  41. bmsch TYPE plpo-bmsch, "基本数量
  42. vgw01 TYPE plpo-vgw01, "工时
  43. vge01 TYPE plpo-vge01, "单位
  44. * vgw02 TYPE plpo-vgw02, "固定
  45. * vge02 TYPE plpo-vge02, "单位
  46. * vgw03 TYPE plpo-vgw03, "变动
  47. * vge03 TYPE plpo-vge03, "单位
  48. * vgw04 TYPE plpo-vgw04, "营运
  49. * vge04 TYPE plpo-vge04, "单位
  50. fpwl TYPE char2048, "分配物料
  51. meins TYPE mara-meins, "单位
  52. plnnr TYPE plpo-plnnr,
  53. flg TYPE c, "X正确
  54. mess TYPE string , "返回消息
  55. END OF ty_out.
  56. DATA:gt_out TYPE TABLE OF ty_out,
  57. gs_out TYPE ty_out,
  58. gs_gylx TYPE zjkplm006,
  59. gs_gylx_tmp TYPE zjkplm006.
  60. TYPES:BEGIN OF ty_vornr,
  61. matnr TYPE mapl-matnr, " 物料
  62. werks TYPE mapl-werks, " 物料工厂
  63. plnal TYPE mapl-plnal, "组计数器
  64. plnnr TYPE mapl-plnnr, " 任务清单组码
  65. vornr TYPE plpo-vornr, "工序
  66. END OF ty_vornr.
  67. TYPES: BEGIN OF ty_crhd,
  68. arbpl TYPE crhd-arbpl, "工作中心
  69. werks TYPE crhd-werks, "工厂
  70. lvorm TYPE crhd-lvorm, "工作中心删除标志
  71. END OF ty_crhd.
  72. TYPES: BEGIN OF ty_marc,
  73. matnr TYPE marc-matnr,
  74. werks TYPE marc-werks,
  75. meins TYPE mara-meins,
  76. END OF ty_marc.
  77. TYPES: BEGIN OF ty_fpwl,
  78. * matnr TYPE marc-matnr,
  79. line(255),
  80. END OF ty_fpwl.
  81. TYPES: BEGIN OF ty_fpwlv,
  82. posnr TYPE stpo-posnr,
  83. matnr TYPE marc-matnr,
  84. plnal TYPE mapl-plnal, "组计数器
  85. vornr TYPE plpo-vornr, "工序
  86. END OF ty_fpwlv.
  87. DATA:lt_gylx TYPE STANDARD TABLE OF zjkplm006,
  88. lt_gylx_temp TYPE STANDARD TABLE OF zjkplm006.
  89. FIELD-SYMBOLS:<fs_gylx> TYPE zjkplm006.
  90. "组件分配 component allocation
  91. DATA:lt_mast TYPE TABLE OF mast WITH HEADER LINE,
  92. ls_topmat TYPE cstmat,
  93. lt_stb TYPE TABLE OF stpox WITH HEADER LINE.
  94. DATA:lt_fpwl TYPE TABLE OF ty_fpwl,
  95. lt_fpwlv TYPE TABLE OF ty_fpwlv,
  96. ls_fpwl TYPE ty_fpwl,
  97. ls_fpwlv TYPE ty_fpwlv.
  98. DATA:lt_phantom TYPE TABLE OF ty_phantom,
  99. ls_phantom TYPE ty_phantom.
  100. "读取工艺路线
  101. DATA:
  102. lt_mapl TYPE STANDARD TABLE OF mapl, wa_mapl TYPE mapl, wa_mapl_temp TYPE mapl,
  103. lt_tsk_tab TYPE STANDARD TABLE OF capp_tsk, ls_tsk_tab TYPE capp_tsk,
  104. lt_seq_tab TYPE STANDARD TABLE OF capp_seq, ls_seq_tab TYPE capp_seq,
  105. lt_opr_tab TYPE STANDARD TABLE OF capp_opr, ls_opr_tab TYPE capp_opr,
  106. lt_com_tab TYPE STANDARD TABLE OF capp_com, ls_com_tab TYPE capp_com.
  107. "标准文本码
  108. DATA: ls_header TYPE thead,
  109. lt_lines TYPE TABLE OF tline WITH HEADER LINE.
  110. "物料计量单位
  111. DATA:ls_marc TYPE ty_marc.
  112. DATA: lv_create TYPE c, "创建
  113. lv_modify TYPE c, "更改
  114. lv_tabix TYPE i,
  115. lv_changeno TYPE aennr,
  116. lv_message TYPE string.
  117. "创建工艺路线
  118. DATA:lt_task TYPE TABLE OF bapi1012_tsk_c,
  119. ls_task TYPE bapi1012_tsk_c,
  120. lt_material TYPE TABLE OF bapi1012_mtk_c,
  121. ls_material TYPE bapi1012_mtk_c,
  122. lt_sequence TYPE TABLE OF bapi1012_seq_c,
  123. ls_sequence TYPE bapi1012_seq_c,
  124. lt_operation TYPE TABLE OF bapi1012_opr_c,
  125. ls_operation TYPE bapi1012_opr_c,
  126. lt_component TYPE TABLE OF bapi1012_com_c,
  127. ls_component TYPE bapi1012_com_c,
  128. lv_group TYPE bapi1012_tsk_c-task_list_group,
  129. lt_return TYPE bapiret2_t,
  130. ls_return TYPE bapiret2.
  131. "更改工艺路线
  132. DATA:ls_h_task TYPE cps_task_list_maint_tsk,
  133. ls_h_task_x TYPE cps_task_list_maint_tsk_x,
  134. lt_materials TYPE TABLE OF cps_task_list_maint_mtk,
  135. ls_materials TYPE cps_task_list_maint_mtk,
  136. lt_materials_x TYPE TABLE OF cps_task_list_maint_mtk_x,
  137. ls_materials_x TYPE cps_task_list_maint_mtk_x,
  138. lt_sequences TYPE TABLE OF cps_task_list_maint_seq,
  139. ls_sequences TYPE cps_task_list_maint_seq,
  140. lt_sequences_x TYPE TABLE OF cps_task_list_maint_seq_x,
  141. ls_sequences_x TYPE cps_task_list_maint_seq_x,
  142. lt_operations TYPE STANDARD TABLE OF cps_task_list_maint_opr,
  143. lt_operations_del TYPE STANDARD TABLE OF cps_task_list_maint_opr,
  144. ls_operations TYPE cps_task_list_maint_opr,
  145. lt_operations_x TYPE STANDARD TABLE OF cps_task_list_maint_opr_x,
  146. ls_operations_x TYPE cps_task_list_maint_opr_x,
  147. lt_components TYPE TABLE OF cps_task_list_maint_com,
  148. ls_components TYPE cps_task_list_maint_com,
  149. lt_components_x TYPE TABLE OF cps_task_list_maint_com_x,
  150. ls_components_x TYPE cps_task_list_maint_com_x.
  151. DATA :ls_zmest401 TYPE zmest401,
  152. ls_routing TYPE ztplm_routing.
  153. DATA:ls_gylx_zmes TYPE zjkplm006.
  154. DATA:lv_vornr TYPE vornr,
  155. lv_pointer TYPE cp_task_list_maint_pointer.
  156. "CC01
  157. DATA:lt_bdc TYPE STANDARD TABLE OF bdcdata,
  158. ls_msg TYPE bdcmsgcoll,
  159. lt_msg TYPE STANDARD TABLE OF bdcmsgcoll.
  160. DATA:ls_params TYPE ctu_params.
  161. lt_gylx[] = et_gylx[].
  162. READ TABLE lt_gylx ASSIGNING <fs_gylx> INDEX 1.
  163. SELECT COUNT(*) FROM zmest001
  164. WHERE werks = <fs_gylx>-werks.
  165. IF sy-subrc = 0.
  166. "3200工厂不做修改
  167. LOOP AT lt_gylx ASSIGNING <fs_gylx>.
  168. "物料号补充前导0
  169. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  170. EXPORTING
  171. input = <fs_gylx>-matnr
  172. IMPORTING
  173. output = <fs_gylx>-matnr.
  174. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  175. EXPORTING
  176. input = <fs_gylx>-plnal
  177. IMPORTING
  178. output = <fs_gylx>-plnal.
  179. ***检查标准文本码是否存在,如果不存在,创建
  180. SELECT SINGLE * FROM t435 WHERE vlsch = <fs_gylx>-ktsch.
  181. IF sy-subrc <> 0.
  182. CLEAR: ls_header, lt_lines, lt_lines[].
  183. ls_header-tdobject = 'WORKST'.
  184. ls_header-tdid = 'SUBM'.
  185. ls_header-tdspras = sy-langu.
  186. ls_header-tdname = <fs_gylx>-ktsch.
  187. ls_header-tdform = 'SYSTEM'.
  188. lt_lines-tdformat = '*' .
  189. lt_lines-tdline = <fs_gylx>-txt.
  190. APPEND lt_lines.
  191. CALL FUNCTION 'SAVE_TEXT'
  192. EXPORTING
  193. client = sy-mandt
  194. header = ls_header
  195. savemode_direct = 'X'
  196. TABLES
  197. lines = lt_lines
  198. EXCEPTIONS
  199. id = 1
  200. language = 2
  201. name = 3
  202. object = 4
  203. OTHERS = 5.
  204. *BEGIN OF COPY FROM FUNCTION 'SUBMISSION_PROCESSING'
  205. CLEAR: t435,t435t.
  206. t435-vlsch = <fs_gylx>-ktsch.
  207. INSERT INTO t435 VALUES t435.
  208. t435t-vlsch = <fs_gylx>-ktsch.
  209. t435t-spras = sy-langu.
  210. t435t-txt = <fs_gylx>-txt.
  211. INSERT INTO t435t VALUES t435t.
  212. CALL FUNCTION 'COMMIT_TEXT'.
  213. COMMIT WORK.
  214. *END OF COPY
  215. ELSE.
  216. " ***检查标准文本码描述,如果不同,修改
  217. "3200工厂的不修改 -------------
  218. IF <fs_gylx>-werks <> '3200'.
  219. SELECT SINGLE * FROM t435t WHERE spras = sy-langu
  220. AND vlsch = <fs_gylx>-ktsch.
  221. IF t435t-txt <> <fs_gylx>-txt.
  222. ls_header-tdobject = 'WORKST'.
  223. ls_header-tdid = 'SUBM'.
  224. ls_header-tdspras = sy-langu.
  225. ls_header-tdname = <fs_gylx>-ktsch.
  226. ls_header-tdform = 'SYSTEM'.
  227. lt_lines-tdformat = '*' .
  228. lt_lines-tdline = <fs_gylx>-txt.
  229. APPEND lt_lines.
  230. CALL FUNCTION 'SAVE_TEXT'
  231. EXPORTING
  232. client = sy-mandt
  233. header = ls_header
  234. savemode_direct = 'X'
  235. TABLES
  236. lines = lt_lines
  237. EXCEPTIONS
  238. id = 1
  239. language = 2
  240. name = 3
  241. object = 4
  242. OTHERS = 5.
  243. CLEAR: t435t.
  244. t435t-vlsch = <fs_gylx>-ktsch.
  245. t435t-spras = sy-langu.
  246. t435t-txt = <fs_gylx>-txt.
  247. MODIFY t435t FROM t435t.
  248. CALL FUNCTION 'COMMIT_TEXT'.
  249. COMMIT WORK.
  250. ENDIF.
  251. ENDIF.
  252. ENDIF.
  253. IF <fs_gylx>-umrez IS INITIAL .
  254. <fs_gylx>-umrez = 1.
  255. ENDIF.
  256. IF <fs_gylx>-umren IS INITIAL .
  257. <fs_gylx>-umren = 1.
  258. ENDIF.
  259. ENDLOOP.
  260. "创建工艺路线
  261. CLEAR:lt_task,lt_material,lt_sequence,lt_operation,lt_return.
  262. "更改工艺路线
  263. CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
  264. lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
  265. "读取工艺路线
  266. CLEAR: lt_mapl,lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
  267. CLEAR: lv_create,lv_modify.
  268. IF lt_gylx IS NOT INITIAL.
  269. "根据物料编码+工厂+组计数器 获取已经存在的工艺路线
  270. SELECT *
  271. FROM mapl
  272. INTO TABLE lt_mapl
  273. FOR ALL ENTRIES IN lt_gylx
  274. WHERE mapl~matnr = lt_gylx-matnr
  275. AND mapl~werks = lt_gylx-werks
  276. AND mapl~plnty = 'N' "任务清单类型
  277. AND mapl~loekz = ''.
  278. SORT lt_mapl BY matnr werks plnal.
  279. ENDIF.
  280. SORT lt_gylx BY matnr
  281. werks
  282. plnal "工艺路线-子项目 组计数器
  283. verwe "工艺路线-子项目 用途
  284. vornr."工艺路线-子项目 工序-子项目 工序号
  285. "判断该记录是否存在
  286. IF lt_mapl IS INITIAL.
  287. lv_create = 'X'.
  288. ELSE.
  289. lv_modify = 'X'.
  290. ENDIF.
  291. READ TABLE lt_gylx INTO gs_gylx INDEX 1.
  292. IF sy-subrc = 0.
  293. CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
  294. SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
  295. FROM mast
  296. INNER JOIN stko
  297. ON mast~stlnr = stko~stlnr
  298. AND mast~stlal = stko~stlal
  299. WHERE mast~matnr = gs_gylx-matnr
  300. AND mast~werks = gs_gylx-werks
  301. AND stko~stlty = 'M'.
  302. CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
  303. EXPORTING
  304. capid = 'PP01'
  305. datuv = sy-datum
  306. emeng = 1
  307. mehrs = ''
  308. mtnrv = lt_mast-matnr
  309. stlal = lt_mast-stlal
  310. stlan = lt_mast-stlan
  311. werks = lt_mast-werks
  312. IMPORTING
  313. topmat = ls_topmat
  314. TABLES
  315. stb = lt_stb
  316. EXCEPTIONS
  317. alt_not_found = 1
  318. call_invalid = 2
  319. material_not_found = 3
  320. missing_authorization = 4
  321. no_bom_found = 5
  322. no_plant_data = 6
  323. no_suitable_bom_found = 7
  324. conversion_error = 8
  325. OTHERS = 9.
  326. "根据物料 工厂 获取MARC记录
  327. SELECT SINGLE
  328. marc~matnr
  329. marc~werks
  330. mara~meins
  331. INTO CORRESPONDING FIELDS OF ls_marc
  332. FROM marc INNER JOIN mara
  333. ON mara~matnr = marc~matnr
  334. WHERE marc~matnr = gs_gylx-matnr
  335. AND marc~werks = gs_gylx-werks.
  336. ENDIF.
  337. LOOP AT lt_gylx INTO gs_gylx.
  338. "组件分配
  339. CLEAR:lt_fpwl.
  340. SPLIT gs_gylx-fpwl AT ';' INTO TABLE lt_fpwl.
  341. * LOOP AT lt_fpwl INTO ls_fpwl.
  342. * ls_fpwlv-matnr = ls_fpwl-matnr.
  343. * ls_fpwlv-vornr = gs_gylx-vornr.
  344. * APPEND ls_fpwlv TO lt_fpwlv.
  345. * ENDLOOP.
  346. LOOP AT lt_fpwl INTO ls_fpwl.
  347. SPLIT ls_fpwl-line AT '&' INTO ls_fpwlv-posnr ls_fpwlv-matnr.
  348. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  349. EXPORTING
  350. input = ls_fpwlv-posnr
  351. IMPORTING
  352. output = ls_fpwlv-posnr.
  353. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  354. EXPORTING
  355. input = ls_fpwlv-matnr
  356. IMPORTING
  357. output = ls_fpwlv-matnr
  358. EXCEPTIONS
  359. length_error = 1
  360. OTHERS = 2.
  361. ls_fpwlv-vornr = gs_gylx-vornr.
  362. APPEND ls_fpwlv TO lt_fpwlv.
  363. ENDLOOP.
  364. ENDLOOP.
  365. IF lv_create = 'X'.
  366. LOOP AT lt_gylx INTO gs_gylx.
  367. * IF gs_gylx-steus = 'SOP'. "控制码转换
  368. * gs_gylx-steus = 'MP01'.
  369. * ELSE.
  370. * gs_gylx-steus = 'MP06'.
  371. * ENDIF.
  372. IF sy-tabix = 1.
  373. CLEAR ls_material.
  374. ls_material-material = gs_gylx-matnr."物料编号
  375. ls_material-plant = gs_gylx-werks."工厂
  376. ls_material-valid_from = sy-datum."有效起始日期
  377. ls_material-valid_to_date = '99991231'."有效截止日期
  378. APPEND ls_material TO lt_material.
  379. CLEAR ls_sequence.
  380. ls_sequence-sequence_no = '000000'."序列
  381. ls_sequence-valid_from = sy-datum. "有效起始日期
  382. ls_sequence-valid_to_date = '99991231'."有效截止日期
  383. ls_sequence-sequence_category = '0'."顺序类别
  384. ls_sequence-alignment_key_for_scheduling = '2'."计划校准码
  385. APPEND ls_sequence TO lt_sequence.
  386. CLEAR ls_task.
  387. * ls_task-task_list_group = gs_gylx-plnnr."组
  388. ls_task-group_counter = gs_gylx-plnal."组计数器
  389. ls_task-valid_from = sy-datum. "有效起始日期
  390. ls_task-valid_to_date = '99991231'."有效截止日期
  391. ls_task-task_list_usage = '1'. "任务清单使用
  392. ls_task-plant = gs_gylx-werks."工厂
  393. ls_task-task_list_status = '4'."状态
  394. ls_task-task_measure_unit = ls_marc-meins."任务清单计量单位
  395. ls_task-description = gs_gylx-ktext."任务清单描述
  396. APPEND ls_task TO lt_task.
  397. ENDIF.
  398. "工序
  399. CLEAR ls_operation.
  400. ls_operation-group_counter = gs_gylx-plnal."组计数器
  401. ls_operation-sequence_no = '000000'.
  402. ls_operation-valid_from = sy-datum. "有效起始日期
  403. ls_operation-valid_to_date = '99991231'. "有效截止日期
  404. ls_operation-activity = gs_gylx-vornr. "操作/活动编号
  405. ls_operation-control_key = gs_gylx-steus. "控制码
  406. ls_operation-standard_text_key = gs_gylx-ktsch. "工序标准文本码
  407. ls_operation-work_cntr = gs_gylx-arbpl. "工作中心
  408. ls_operation-denominator = '1'."用于转换工艺路线和工序单位的分母
  409. ls_operation-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
  410. ls_operation-base_quantity = gs_gylx-bmsch."基本数量
  411. ls_operation-operation_measure_unit = ls_marc-meins."单位
  412. ls_operation-description = gs_gylx-txt."标准文本
  413. IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
  414. ls_operation-acttype_01 = 'ZJ01'.
  415. ls_operation-std_value_01 = gs_gylx-vgw01."工时
  416. ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
  417. ELSE.
  418. ls_operation-std_value_01 = gs_gylx-vgw01."工时
  419. ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
  420. ls_operation-std_value_02 = gs_gylx-vgw01."固定
  421. ls_operation-std_unit_02 = gs_gylx-vge01."工时计量单位
  422. ls_operation-std_value_03 = gs_gylx-vgw01."变动
  423. ls_operation-std_unit_03 = gs_gylx-vge01."工时计量单位
  424. ls_operation-std_value_04 = gs_gylx-vgw01."营运
  425. ls_operation-std_unit_04 = gs_gylx-vge01."工时计量单位
  426. ENDIF.
  427. ls_operation-cost_relevant = 'X'."打上成本核算先关标识
  428. APPEND ls_operation TO lt_operation.
  429. "组件分配 component allocation -->工序
  430. LOOP AT lt_fpwlv INTO ls_fpwlv WHERE vornr = gs_gylx-vornr.
  431. READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr.
  432. IF sy-subrc = 0.
  433. CHECK lt_stb-loekz IS INITIAL.
  434. CLEAR ls_component.
  435. ls_component-valid_from = sy-datum. "有效起始日期
  436. ls_component-activity = ls_fpwlv-vornr. "工序号
  437. ls_component-bom_type = 'M' . "BOM 类别
  438. ls_component-bom_no = lt_stb-stlnr. "物料单
  439. ls_component-alternative_bom = lt_mast-stlal."可选的 BOM
  440. ls_component-item_id = lt_stb-stvkn. "项目 ID
  441. ls_component-item_no = lt_stb-posnr. "BOM 项目号
  442. ls_component-plant = gs_gylx-werks. "工厂
  443. * ls_component-material = ls_fpwl-matnr. "物料号
  444. APPEND ls_component TO lt_component.
  445. ENDIF.
  446. ENDLOOP.
  447. ENDLOOP.
  448. SORT lt_component.
  449. DELETE ADJACENT DUPLICATES FROM lt_component COMPARING ALL FIELDS.
  450. CALL FUNCTION 'BAPI_ROUTING_CREATE'
  451. IMPORTING
  452. group = lv_group
  453. TABLES
  454. task = lt_task
  455. materialtaskallocation = lt_material
  456. sequence = lt_sequence
  457. operation = lt_operation
  458. componentallocation = lt_component
  459. return = lt_return.
  460. READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
  461. IF sy-subrc = 0.
  462. return-type = 'E'.
  463. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  464. return-id = ls_return-id.
  465. return-type = ls_return-type.
  466. return-number = ls_return-number.
  467. MESSAGE ID ls_return-id
  468. TYPE ls_return-type
  469. NUMBER ls_return-number
  470. WITH ls_return-message_v1
  471. ls_return-message_v2
  472. ls_return-message_v3
  473. ls_return-message_v4
  474. INTO return-message.
  475. ENDLOOP.
  476. ROLLBACK WORK.
  477. ELSE.
  478. return-type = 'S'.
  479. return-message = '系统处理成功!'.
  480. "ls_out-flg = 'X'.
  481. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
  482. EXPORTING
  483. wait = 'X'.
  484. "保存版本,供ME使用----------------------------
  485. "MES 所需内容 FROM--------------------20200422-----------
  486. READ TABLE et_gylx INTO gs_gylx INDEX 1.
  487. IF gs_gylx-version IS NOT INITIAL.
  488. SELECT COUNT(*) FROM zmest001
  489. WHERE werks = gs_gylx-werks.
  490. IF sy-subrc = 0 .
  491. CLEAR:ls_zmest401.
  492. CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
  493. EXPORTING
  494. input = gs_gylx-matnr
  495. IMPORTING
  496. output = ls_zmest401-matnr.
  497. ls_zmest401-werks = gs_gylx-werks.
  498. ls_zmest401-ztype = 'R'.
  499. ls_zmest401-datum = sy-datum.
  500. ls_zmest401-zgybb = gs_gylx-version.
  501. ls_zmest401-zgybh = gs_gylx-plnnr_alt.
  502. MODIFY zmest401 FROM ls_zmest401.
  503. COMMIT WORK AND WAIT.
  504. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  505. EXPORTING
  506. input = gs_gylx-matnr
  507. IMPORTING
  508. output = ls_routing-matnr.
  509. ls_routing-werks = gs_gylx-werks.
  510. ls_routing-stlal = gs_gylx-stlal.
  511. ls_routing-ztype = 'R'.
  512. ls_routing-datum = sy-datum.
  513. ls_routing-zgybb = gs_gylx-version.
  514. ls_routing-zgybh = gs_gylx-plnnr_alt.
  515. MODIFY ztplm_routing FROM ls_routing.
  516. COMMIT WORK AND WAIT.
  517. ENDIF.
  518. ENDIF.
  519. "MES 所需内容 END --------------------20200422-----------
  520. ENDIF.
  521. ENDIF.
  522. IF lv_modify = 'X'.
  523. "cc01 生成 CHANGE NO号
  524. READ TABLE lt_mapl INTO wa_mapl INDEX 1.
  525. PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0100'.
  526. PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '/00'.
  527. PERFORM frm_bdc_field TABLES lt_bdc USING 'RAD_BUT_ECNTYP-NORM' 'X'.
  528. PERFORM frm_bdc_field TABLES lt_bdc USING 'RAD_AEFUN-OHFR' 'X'.
  529. PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0010'.
  530. PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '/00'.
  531. PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AETXT' wa_mapl-matnr.
  532. PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-DATUV' sy-datum.
  533. PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AENST' '01'.
  534. PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0020'.
  535. PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '=ENT1'.
  536. PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_CURSOR' 'RC29A-AEERL(02)'.
  537. PERFORM frm_bdc_field TABLES lt_bdc USING 'RC29A-AEERL(02)' 'X'.
  538. PERFORM frm_bdc_dynpro TABLES lt_bdc USING 'SAPMC29C' '0020'.
  539. PERFORM frm_bdc_field TABLES lt_bdc USING 'BDC_OKCODE' '=FCBU'.
  540. ls_params-dismode = 'N'.
  541. ls_params-updmode = 'S'.
  542. ls_params-defsize = 'X'.
  543. CALL TRANSACTION 'CC01' USING lt_bdc
  544. OPTIONS FROM ls_params
  545. MESSAGES INTO lt_msg.
  546. READ TABLE lt_msg INTO ls_msg WITH KEY msgtyp = 'S'.
  547. IF sy-subrc = 0.
  548. CLEAR:lv_changeno.
  549. lv_changeno = ls_msg-msgv1.
  550. ENDIF.
  551. IF lv_changeno IS INITIAL .
  552. return-type = 'E'.
  553. return-message = 'ECN号获取失败'.
  554. ELSE.
  555. "工艺路线-子项目 修改
  556. LOOP AT lt_mapl INTO wa_mapl.
  557. CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
  558. CALL FUNCTION 'CARO_ROUTING_READ'
  559. EXPORTING
  560. date_from = sy-datum
  561. date_to = '99991231'
  562. plnty = wa_mapl-plnty
  563. plnnr = wa_mapl-plnnr
  564. plnal = wa_mapl-plnal
  565. TABLES
  566. tsk_tab = lt_tsk_tab
  567. seq_tab = lt_seq_tab
  568. opr_tab = lt_opr_tab
  569. com_tab = lt_com_tab
  570. EXCEPTIONS
  571. not_found = 1
  572. ref_not_exp = 2
  573. not_valid = 3
  574. OTHERS = 4.
  575. lt_gylx_temp = lt_gylx.
  576. DELETE lt_gylx_temp WHERE plnal <> wa_mapl-plnal.
  577. SORT lt_gylx_temp BY matnr
  578. werks
  579. plnal "工艺路线-子项目 组计数器
  580. verwe "工艺路线-子项目 用途
  581. vornr."工艺路线-子项目 工序-子项目 工序号
  582. ***创建和修改
  583. CLEAR:lv_vornr.
  584. LOOP AT lt_gylx_temp INTO gs_gylx.
  585. * IF gs_gylx-steus = 'SOP'. "控制码转换
  586. * gs_gylx-steus = 'MP01'.
  587. * ELSE.
  588. * gs_gylx-steus = 'MP06'.
  589. * ENDIF.
  590. IF sy-tabix = 1.
  591. * TASK 组
  592. CLEAR ls_h_task.
  593. ls_h_task-plant = gs_gylx-werks."工厂
  594. ls_h_task-task_list_usage = '1'. "任务清单使用
  595. ls_h_task-task_list_status = '4'."状态
  596. ls_h_task-description = gs_gylx-ktext."任务清单描述
  597. ls_h_task-task_measure_unit = ls_marc-meins.
  598. ls_h_task_x-description = 'X'.
  599. ENDIF.
  600. CLEAR:ls_operations,ls_operations_x.
  601. READ TABLE lt_opr_tab INTO ls_opr_tab
  602. WITH KEY vornr = gs_gylx-vornr.
  603. IF sy-subrc = 0.
  604. "工序修改
  605. ls_operations-maintain_mode = 'M'. "修改
  606. ELSE.
  607. "工序新建
  608. ls_operations-maintain_mode = 'C'. "创建
  609. ENDIF.
  610. "------------------修改于20200803--------------FROM----------
  611. IF lv_vornr IS INITIAL .
  612. lv_vornr = 1.
  613. ELSE.
  614. lv_vornr = lv_vornr + 1.
  615. ENDIF.
  616. ls_operations-flag_bar_pointer = lv_vornr.
  617. " ls_operations-flag_bar_pointer = gs_gylx-vornr / 10.
  618. "------------------修改于20200803--------------END-----------
  619. ls_operations-sequence_no = '000000'.
  620. ls_operations-activity = gs_gylx-vornr. "操作/活动编号
  621. ls_operations-control_key = gs_gylx-steus. "控制码
  622. ls_operations-standard_text_key = gs_gylx-ktsch. "工序标准文本码
  623. ls_operations-description = gs_gylx-txt. "工序标准文本码
  624. ls_operations-work_cntr = gs_gylx-arbpl. "工作中心
  625. ls_operations-plant = gs_gylx-werks. "工作中心
  626. ls_operations-denominator = '1'."用于转换工艺路线和工序单位的分母
  627. ls_operations-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
  628. ls_operations-base_quantity = gs_gylx-bmsch."基本数量
  629. ls_operations-operation_measure_unit = ls_marc-meins."单位
  630. IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
  631. ls_operation-acttype_01 = 'ZJ01'.
  632. ls_operations-std_value_01 = gs_gylx-vgw01."工时
  633. ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
  634. ELSE.
  635. ls_operations-std_value_01 = gs_gylx-vgw01."工时
  636. ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
  637. ls_operations-std_value_02 = gs_gylx-vgw01."固定
  638. ls_operations-std_unit_02 = gs_gylx-vge01."工时计量单位
  639. ls_operations-std_value_03 = gs_gylx-vgw01."变动
  640. ls_operations-std_unit_03 = gs_gylx-vge01."工时计量单位
  641. ls_operations-std_value_04 = gs_gylx-vgw01."营运
  642. ls_operations-std_unit_04 = gs_gylx-vge01."工时计量单位
  643. ENDIF.
  644. ls_operations-cost_relevant = 'X'.
  645. APPEND ls_operations TO lt_operations.
  646. IF ls_operations-maintain_mode = 'C'. "创建
  647. ls_operations_x-activity = 'X'. "操作/活动编号
  648. ENDIF.
  649. ls_operations_x-control_key = 'X'. "控制码
  650. ls_operations_x-standard_text_key = 'X'. "工序标准文本码
  651. ls_operations_x-description = 'X'. "工序标准文本码描述
  652. ls_operations_x-work_cntr = 'X'. "工作中心
  653. ls_operations_x-plant = 'X'. "工厂
  654. ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
  655. ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
  656. ls_operations_x-base_quantity = 'X'."基本数量
  657. ls_operations_x-operation_measure_unit = 'X'."单位
  658. IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型
  659. ls_operations_x-acttype_01 = 'X'.
  660. ls_operations_x-std_value_01 = 'X'."工时
  661. ls_operations_x-std_unit_01 = 'X'."工时计量单位
  662. ELSE.
  663. ls_operations_x-std_value_01 = 'X'."工时
  664. ls_operations_x-std_unit_01 = 'X'."工时计量单位
  665. ls_operations_x-std_value_02 = 'X'."固定
  666. ls_operations_x-std_unit_02 = 'X'."工时计量单位
  667. ls_operations_x-std_value_03 = 'X'."变动
  668. ls_operations_x-std_unit_03 = 'X'."工时计量单位
  669. ls_operations_x-std_value_04 = 'X'."营运
  670. ls_operations_x-std_unit_04 = 'X'."工时计量单位
  671. ENDIF.
  672. ls_operations_x-cost_relevant = 'X'."成本核算表示
  673. APPEND ls_operations_x TO lt_operations_x.
  674. ENDLOOP.
  675. ***删除
  676. CLEAR:lv_vornr.
  677. LOOP AT lt_opr_tab INTO ls_opr_tab.
  678. READ TABLE lt_gylx_temp INTO gs_gylx WITH KEY vornr = ls_opr_tab-vornr.
  679. IF sy-subrc <> 0.
  680. CLEAR:ls_operations,ls_operations_x.
  681. ls_operations-maintain_mode = 'D'. "删除
  682. "------------------修改于20200803--------------FROM----------
  683. IF lv_vornr IS INITIAL .
  684. lv_vornr = 1.
  685. ELSE.
  686. lv_vornr = lv_vornr + 1.
  687. ENDIF.
  688. ls_operations-flag_bar_pointer = lv_vornr.
  689. " ls_operations-flag_bar_pointer = ls_opr_tab-vornr / 10.
  690. "------------------修改于20200803--------------END-----------
  691. ls_operations-sequence_no = '000000'.
  692. ls_operations-activity = ls_opr_tab-vornr. "操作/活动编号
  693. APPEND ls_operations TO lt_operations.
  694. ls_operations_x-control_key = 'X'. "控制码
  695. ls_operations_x-standard_text_key = 'X'. "工序标准文本码
  696. ls_operations_x-description = 'X'. "工序标准文本码描述
  697. ls_operations_x-work_cntr = 'X'. "工作中心
  698. ls_operations_x-plant = 'X'. "工厂
  699. ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
  700. ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
  701. ls_operations_x-base_quantity = 'X'."基本数量
  702. ls_operations_x-operation_measure_unit = 'X'."单位
  703. IF gs_gylx-steus = 'MQ01'. "当控制码为质检类型的时候,只维护第一个作业类型.
  704. ls_operations_x-acttype_01 = 'X'.
  705. ls_operations_x-std_value_01 = 'X'."工时
  706. ls_operations_x-std_unit_01 = 'X'."工时计量单位
  707. ELSE.
  708. ls_operations_x-std_value_01 = 'X'."工时
  709. ls_operations_x-std_unit_01 = 'X'."工时计量单位
  710. ls_operations_x-std_value_02 = 'X'."固定
  711. ls_operations_x-std_unit_02 = 'X'."工时计量单位
  712. ls_operations_x-std_value_03 = 'X'."变动
  713. ls_operations_x-std_unit_03 = 'X'."工时计量单位
  714. ls_operations_x-std_value_04 = 'X'."营运
  715. ls_operations_x-std_unit_04 = 'X'."工时计量单位
  716. ENDIF.
  717. APPEND ls_operations_x TO lt_operations_x.
  718. ENDIF.
  719. ENDLOOP.
  720. SORT lt_operations BY activity.
  721. CALL FUNCTION 'ROUTING_MAINTAIN'
  722. EXPORTING
  723. change_no = lv_changeno
  724. key_date = sy-datum
  725. task_list_group = wa_mapl-plnnr "组
  726. group_counter = wa_mapl-plnal "组计数器
  727. material = wa_mapl-matnr "物料编号
  728. plant = wa_mapl-werks "工厂
  729. task = ls_h_task
  730. task_x = ls_h_task_x
  731. * APPLICATION =
  732. bom_usage = lt_mast-stlan
  733. TABLES
  734. * MATERIAL_TASK_ALLOCATIONS = MATERIAL_TASK_ALLOCATIONS
  735. * MATERIAL_TASK_ALLOCATIONS_X = MATERIAL_TASK_ALLOCATIONS_X
  736. * SEQUENCES = SEQUENCES
  737. * SEQUENCES_X = SEQUENCES_X
  738. operations = lt_operations
  739. operations_x = lt_operations_x
  740. component_allocations = lt_components
  741. component_allocations_x = lt_components_x
  742. return = lt_return.
  743. READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
  744. IF sy-subrc = 0.
  745. return-type = 'E'.
  746. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  747. return-id = ls_return-id.
  748. return-type = ls_return-type.
  749. return-number = ls_return-number.
  750. MESSAGE ID ls_return-id
  751. TYPE ls_return-type
  752. NUMBER ls_return-number
  753. WITH ls_return-message_v1
  754. ls_return-message_v2
  755. ls_return-message_v3
  756. ls_return-message_v4
  757. INTO return-message.
  758. ENDLOOP.
  759. ROLLBACK WORK.
  760. ELSE.
  761. return-type = 'S'.
  762. return-message = '系统处理成功!'.
  763. "ls_out-flg = 'X'.
  764. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
  765. EXPORTING
  766. wait = 'X'.
  767. "保存版本,供ME使用----------------------------
  768. "MES 所需内容 FROM--------------------20200422-----------
  769. READ TABLE et_gylx INTO gs_gylx INDEX 1.
  770. IF gs_gylx-version IS NOT INITIAL.
  771. SELECT COUNT(*) FROM zmest001
  772. WHERE werks = gs_gylx-werks.
  773. IF sy-subrc = 0 .
  774. CLEAR:ls_zmest401.
  775. CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
  776. EXPORTING
  777. input = gs_gylx-matnr
  778. IMPORTING
  779. output = ls_zmest401-matnr.
  780. ls_zmest401-werks = gs_gylx-werks.
  781. ls_zmest401-ztype = 'R'.
  782. ls_zmest401-datum = sy-datum.
  783. ls_zmest401-zgybb = gs_gylx-version.
  784. ls_zmest401-zgybh = gs_gylx-plnnr_alt.
  785. MODIFY zmest401 FROM ls_zmest401.
  786. COMMIT WORK AND WAIT.
  787. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  788. EXPORTING
  789. input = gs_gylx-matnr
  790. IMPORTING
  791. output = ls_routing-matnr.
  792. ls_routing-werks = gs_gylx-werks.
  793. ls_routing-stlal = gs_gylx-stlal.
  794. ls_routing-ztype = 'R'.
  795. ls_routing-datum = sy-datum.
  796. ls_routing-zgybb = gs_gylx-version.
  797. ls_routing-zgybh = gs_gylx-plnnr_alt.
  798. MODIFY ztplm_routing FROM ls_routing.
  799. COMMIT WORK AND WAIT.
  800. ENDIF.
  801. ENDIF.
  802. ENDIF.
  803. "更改工艺路线
  804. CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
  805. lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
  806. ENDLOOP.
  807. ENDIF.
  808. * "工艺路线-子项目 创建
  809. * READ TABLE lt_mapl INTO wa_mapl_temp INDEX 1.
  810. * LOOP AT lt_gylx INTO gs_gylx.
  811. * READ TABLE lt_mapl INTO wa_mapl
  812. * WITH KEY plnal = gs_gylx-plnal.
  813. * IF sy-subrc <> 0.
  814. *
  815. ** CALL FUNCTION 'BAPI_ROUTING_CREATE'
  816. **需要指定每个参数表中的
  817. **TASK_LIST_GROUP 1 类型 PLNNR CHAR 8 0 任务清单组码
  818. **GROUP_COUNTER 1 类型 PLNAL CHAR 2 0 组计数器
  819. * ENDIF.
  820. * ENDLOOP.
  821. ENDIF.
  822. ELSE.
  823. "不做ECN,直接修改;组件分配
  824. LOOP AT lt_gylx ASSIGNING <fs_gylx>.
  825. "物料号补充前导0
  826. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  827. EXPORTING
  828. input = <fs_gylx>-matnr
  829. IMPORTING
  830. output = <fs_gylx>-matnr.
  831. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  832. EXPORTING
  833. input = <fs_gylx>-plnal
  834. IMPORTING
  835. output = <fs_gylx>-plnal.
  836. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  837. EXPORTING
  838. input = <fs_gylx>-infnr
  839. IMPORTING
  840. output = <fs_gylx>-infnr.
  841. ***检查标准文本码是否存在,如果不存在,创建
  842. SELECT SINGLE * FROM t435 WHERE vlsch = <fs_gylx>-ktsch.
  843. IF sy-subrc <> 0.
  844. CLEAR: ls_header, lt_lines, lt_lines[].
  845. ls_header-tdobject = 'WORKST'.
  846. ls_header-tdid = 'SUBM'.
  847. ls_header-tdspras = sy-langu.
  848. ls_header-tdname = <fs_gylx>-ktsch.
  849. ls_header-tdform = 'SYSTEM'.
  850. lt_lines-tdformat = '*' .
  851. lt_lines-tdline = <fs_gylx>-txt.
  852. APPEND lt_lines.
  853. CALL FUNCTION 'SAVE_TEXT'
  854. EXPORTING
  855. client = sy-mandt
  856. header = ls_header
  857. savemode_direct = 'X'
  858. TABLES
  859. lines = lt_lines
  860. EXCEPTIONS
  861. id = 1
  862. language = 2
  863. name = 3
  864. object = 4
  865. OTHERS = 5.
  866. *BEGIN OF COPY FROM FUNCTION 'SUBMISSION_PROCESSING'
  867. CLEAR: t435,t435t.
  868. t435-vlsch = <fs_gylx>-ktsch.
  869. INSERT INTO t435 VALUES t435.
  870. t435t-vlsch = <fs_gylx>-ktsch.
  871. t435t-spras = sy-langu.
  872. t435t-txt = <fs_gylx>-txt.
  873. INSERT INTO t435t VALUES t435t.
  874. CALL FUNCTION 'COMMIT_TEXT'.
  875. COMMIT WORK.
  876. *END OF COPY
  877. ELSE.
  878. " ***检查标准文本码描述,如果不同,修改
  879. SELECT SINGLE * FROM t435t WHERE spras = sy-langu
  880. AND vlsch = <fs_gylx>-ktsch.
  881. IF t435t-txt <> <fs_gylx>-txt.
  882. ls_header-tdobject = 'WORKST'.
  883. ls_header-tdid = 'SUBM'.
  884. ls_header-tdspras = sy-langu.
  885. ls_header-tdname = <fs_gylx>-ktsch.
  886. ls_header-tdform = 'SYSTEM'.
  887. lt_lines-tdformat = '*' .
  888. lt_lines-tdline = <fs_gylx>-txt.
  889. APPEND lt_lines.
  890. CALL FUNCTION 'SAVE_TEXT'
  891. EXPORTING
  892. client = sy-mandt
  893. header = ls_header
  894. savemode_direct = 'X'
  895. TABLES
  896. lines = lt_lines
  897. EXCEPTIONS
  898. id = 1
  899. language = 2
  900. name = 3
  901. object = 4
  902. OTHERS = 5.
  903. CLEAR: t435t.
  904. t435t-vlsch = <fs_gylx>-ktsch.
  905. t435t-spras = sy-langu.
  906. t435t-txt = <fs_gylx>-txt.
  907. MODIFY t435t FROM t435t.
  908. CALL FUNCTION 'COMMIT_TEXT'.
  909. COMMIT WORK.
  910. ENDIF.
  911. ENDIF.
  912. IF <fs_gylx>-umrez IS INITIAL .
  913. <fs_gylx>-umrez = 1.
  914. ENDIF.
  915. IF <fs_gylx>-umren IS INITIAL .
  916. <fs_gylx>-umren = 1.
  917. ENDIF.
  918. ENDLOOP.
  919. "创建工艺路线
  920. CLEAR:lt_task,lt_material,lt_sequence,lt_operation,lt_return.
  921. "更改工艺路线
  922. CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
  923. lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
  924. "读取工艺路线
  925. CLEAR: lt_mapl,lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
  926. CLEAR: lv_create,lv_modify.
  927. IF lt_gylx IS NOT INITIAL.
  928. "根据PLM的工艺路线号查找SAP对应的工艺路线组号
  929. READ TABLE lt_gylx INTO gs_gylx INDEX 1.
  930. IF gs_gylx-plnnr_alt IS INITIAL.
  931. return-type = 'E'.
  932. return-message = 'PLM工艺路线号不能为空'.
  933. RETURN.
  934. ENDIF.
  935. SELECT SINGLE plnnr
  936. INTO lv_group
  937. FROM plko
  938. WHERE plnty = 'N'
  939. AND loekz = '' "过滤删除的工艺路线
  940. AND plnnr_alt = gs_gylx-plnnr_alt.
  941. "根据物料编码+工厂+组号 获取已经存在的工艺路线
  942. SELECT *
  943. FROM mapl
  944. INTO CORRESPONDING FIELDS OF TABLE lt_mapl
  945. * FOR ALL ENTRIES IN lt_gylx
  946. * WHERE mapl~matnr = lt_gylx-matnr
  947. * AND mapl~werks = lt_gylx-werks
  948. * AND mapl~plnnr = lv_group
  949. WHERE mapl~plnnr = lv_group
  950. AND mapl~plnty = 'N'. "任务清单类型
  951. * AND mapl~loekz = ''. "这个标识只是删除物料分配,物料还是可以分配回来
  952. SORT lt_mapl BY matnr werks plnal.
  953. ENDIF.
  954. SORT lt_gylx BY matnr
  955. werks
  956. plnal "工艺路线-子项目 组计数器
  957. verwe "工艺路线-子项目 用途
  958. vornr."工艺路线-子项目 工序-子项目 工序号
  959. "判断该记录是否存在,判断依据PLNNR+PLNAL,PLNNR根据PLM号获取,PLNAL由PLM指定
  960. READ TABLE lt_gylx INTO gs_gylx INDEX 1.
  961. READ TABLE lt_mapl INTO wa_mapl WITH KEY plnal = gs_gylx-plnal.
  962. * IF lt_mapl IS INITIAL.
  963. IF sy-subrc <> 0.
  964. lv_create = 'X'.
  965. ELSE.
  966. lv_modify = 'X'.
  967. *******************************************************************************************
  968. * 删除组件分配
  969. * DATA: ctumode TYPE ctu_params-dismode VALUE 'N',
  970. * cupdate TYPE ctu_params-updmode VALUE 'A'.
  971. * REFRESH: bdcdata, messtab.
  972. * CLEAR: bdcdata, messtab.
  973. *
  974. * PERFORM bdc_dynpro USING 'SAPLCPDI' '1010'.
  975. * PERFORM bdc_field USING 'BDC_CURSOR'
  976. * 'RC27M-MATNR'.
  977. * PERFORM bdc_field USING 'BDC_OKCODE'
  978. * '/00'.
  979. * PERFORM bdc_field USING 'RC27M-MATNR'
  980. * gs_gylx-matnr.
  981. * PERFORM bdc_field USING 'RC27M-WERKS'
  982. * gs_gylx-werks.
  983. * PERFORM bdc_field USING 'RC271-STTAG'
  984. * sy-datum.
  985. * PERFORM bdc_dynpro USING 'SAPLCPDI' '1400'.
  986. * PERFORM bdc_field USING 'BDC_CURSOR'
  987. * 'PLPOD-VORNR(01)'.
  988. * PERFORM bdc_field USING 'BDC_OKCODE'
  989. * '=MATA'.
  990. * PERFORM bdc_field USING 'RC27X-ENTRY_ACT'
  991. * '1'.
  992. * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
  993. * PERFORM bdc_field USING 'BDC_CURSOR'
  994. * 'RCM01-MATNR'.
  995. * PERFORM bdc_field USING 'BDC_OKCODE'
  996. * '=MARA'.
  997. * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
  998. * PERFORM bdc_field USING 'BDC_CURSOR'
  999. * 'RCM01-MATNR'.
  1000. * PERFORM bdc_field USING 'BDC_OKCODE'
  1001. * '=DEL'.
  1002. * PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.
  1003. * PERFORM bdc_field USING 'BDC_OKCODE'
  1004. * '=YES'.
  1005. * PERFORM bdc_dynpro USING 'SAPLCMDI' '1000'.
  1006. * PERFORM bdc_field USING 'BDC_CURSOR'
  1007. * 'RCM01-MATNR'.
  1008. * PERFORM bdc_field USING 'BDC_OKCODE'
  1009. * '=BU'.
  1010. * CALL TRANSACTION 'CA02' USING bdcdata
  1011. * MODE ctumode
  1012. * UPDATE cupdate
  1013. * MESSAGES INTO messtab.
  1014. * REFRESH: bdcdata, messtab.
  1015. * CLEAR: bdcdata, messtab.
  1016. *****************************************************************************************
  1017. CLEAR:lt_tsk_tab,lt_seq_tab,lt_opr_tab,lt_com_tab.
  1018. CALL FUNCTION 'CARO_ROUTING_READ'
  1019. EXPORTING
  1020. date_from = sy-datum
  1021. date_to = '99991231'
  1022. plnty = 'N'
  1023. plnnr = lv_group
  1024. plnal = gs_gylx-plnal
  1025. matnr = gs_gylx-matnr
  1026. TABLES
  1027. tsk_tab = lt_tsk_tab
  1028. seq_tab = lt_seq_tab
  1029. opr_tab = lt_opr_tab
  1030. * com_tab = lt_com_tab
  1031. EXCEPTIONS
  1032. not_found = 1
  1033. ref_not_exp = 2
  1034. not_valid = 3
  1035. OTHERS = 4.
  1036. "CARO_ROUTING_READ读取组件不准确,改用逻辑数据库,参考CA51
  1037. DATA: lt_plmzd TYPE TABLE OF plmzd,
  1038. ls_plmzd TYPE plmzd.
  1039. RANGES: lr_matnr FOR plmzd-matnr,
  1040. lr_werks FOR plmzd-werks,
  1041. lr_plnnr FOR plmzd-plnnr,
  1042. lr_plnal FOR plmzd-plnal.
  1043. lr_matnr-sign = 'I'.
  1044. lr_matnr-option = 'EQ'.
  1045. lr_matnr-low = gs_gylx-matnr.
  1046. APPEND lr_matnr.
  1047. lr_werks-sign = 'I'.
  1048. lr_werks-option = 'EQ'.
  1049. lr_werks-low = gs_gylx-werks.
  1050. APPEND lr_werks.
  1051. lr_plnnr-sign = 'I'.
  1052. lr_plnnr-option = 'EQ'.
  1053. lr_plnnr-low = lv_group.
  1054. APPEND lr_plnnr.
  1055. lr_plnal-sign = 'I'.
  1056. lr_plnal-option = 'EQ'.
  1057. lr_plnal-low = gs_gylx-plnal.
  1058. APPEND lr_plnal.
  1059. REFRESH lt_plmzd.
  1060. "参照CA51
  1061. SUBMIT zjkmes006_read_component WITH pn_plnty = 'N'
  1062. WITH pn_matnr IN lr_matnr
  1063. WITH pn_werks IN lr_werks
  1064. WITH pn_plnnr IN lr_plnnr
  1065. WITH pn_plnal IN lr_plnal
  1066. WITH pn_datuv = sy-datum
  1067. WITH pn_capid = 'PP01'
  1068. WITH mat = 'X'
  1069. WITH pn_mehrs = 'X'
  1070. AND RETURN.
  1071. IMPORT lt = lt_plmzd[] FROM MEMORY ID 'ZCOMPONENT'.
  1072. MOVE-CORRESPONDING lt_plmzd[] TO lt_com_tab[].
  1073. ENDIF.
  1074. READ TABLE lt_gylx INTO gs_gylx INDEX 1.
  1075. IF sy-subrc = 0.
  1076. CLEAR: lt_mast,ls_topmat,lt_stb,lt_stb[].
  1077. SELECT SINGLE * INTO CORRESPONDING FIELDS OF lt_mast
  1078. FROM mast
  1079. INNER JOIN stko
  1080. ON mast~stlnr = stko~stlnr
  1081. AND mast~stlal = stko~stlal
  1082. WHERE mast~matnr = gs_gylx-matnr
  1083. AND mast~werks = gs_gylx-werks
  1084. AND mast~stlal = gs_gylx-stlal
  1085. AND stko~stlty = 'M'.
  1086. CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
  1087. EXPORTING
  1088. aufsw = 'X'
  1089. capid = 'PP01'
  1090. datuv = sy-datum
  1091. emeng = 1
  1092. mdnot = 'X'
  1093. mdmps = 'X'
  1094. mehrs = 'X'
  1095. mtnrv = lt_mast-matnr
  1096. stlal = lt_mast-stlal
  1097. stlan = lt_mast-stlan
  1098. werks = lt_mast-werks
  1099. IMPORTING
  1100. topmat = ls_topmat
  1101. TABLES
  1102. stb = lt_stb
  1103. EXCEPTIONS
  1104. alt_not_found = 1
  1105. call_invalid = 2
  1106. material_not_found = 3
  1107. missing_authorization = 4
  1108. no_bom_found = 5
  1109. no_plant_data = 6
  1110. no_suitable_bom_found = 7
  1111. conversion_error = 8
  1112. OTHERS = 9.
  1113. DATA: lt_stpox TYPE TABLE OF stpox,
  1114. ls_stpox TYPE stpox.
  1115. CLEAR: lt_stpox, ls_stpox.
  1116. APPEND LINES OF lt_stb[] TO lt_stpox.
  1117. CALL FUNCTION 'CS_X4_NODE_DETERMINATION'
  1118. EXPORTING
  1119. i_stlty_w = ls_topmat-stlty
  1120. i_stlnr_w = ls_topmat-stlnr
  1121. i_stlal_w = ls_topmat-stlal
  1122. i_flg_create_nodes = 'X'
  1123. i_flg_node_for_class = 'X'
  1124. i_flg_check_node = 'X'
  1125. i_flg_special_class = 'X'
  1126. i_flg_node_for_assem = 'X'
  1127. i_flg_calc_path2 = 'X'
  1128. i_flg_calc_path4 = 'X'
  1129. TABLES
  1130. stb = lt_stpox
  1131. EXCEPTIONS
  1132. wrong_initialization = 1
  1133. foreign_lock = 2
  1134. system_failure = 3
  1135. stb_inconsistent = 4
  1136. stvkn_not_initialized = 5
  1137. OTHERS = 6.
  1138. IF sy-subrc <> 0.
  1139. * Implement suitable error handling here
  1140. ENDIF.
  1141. DELETE lt_stb WHERE loekz IS NOT INITIAL.
  1142. PERFORM frm_get_phantom TABLES lt_stb
  1143. lt_com_tab
  1144. lt_phantom.
  1145. "根据物料 工厂 获取MARC记录
  1146. SELECT SINGLE
  1147. marc~matnr
  1148. marc~werks
  1149. mara~meins
  1150. INTO CORRESPONDING FIELDS OF ls_marc
  1151. FROM marc INNER JOIN mara
  1152. ON mara~matnr = marc~matnr
  1153. WHERE marc~matnr = gs_gylx-matnr
  1154. AND marc~werks = gs_gylx-werks.
  1155. ENDIF.
  1156. LOOP AT lt_gylx INTO gs_gylx.
  1157. "组件分配
  1158. CLEAR:lt_fpwl.
  1159. SPLIT gs_gylx-fpwl AT ';' INTO TABLE lt_fpwl.
  1160. LOOP AT lt_fpwl INTO ls_fpwl.
  1161. SPLIT ls_fpwl-line AT '&' INTO ls_fpwlv-posnr ls_fpwlv-matnr.
  1162. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  1163. EXPORTING
  1164. input = ls_fpwlv-posnr
  1165. IMPORTING
  1166. output = ls_fpwlv-posnr.
  1167. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  1168. EXPORTING
  1169. input = ls_fpwlv-matnr
  1170. IMPORTING
  1171. output = ls_fpwlv-matnr
  1172. EXCEPTIONS
  1173. length_error = 1
  1174. OTHERS = 2.
  1175. ls_fpwlv-vornr = gs_gylx-vornr.
  1176. APPEND ls_fpwlv TO lt_fpwlv.
  1177. ENDLOOP.
  1178. ENDLOOP.
  1179. IF lv_create = 'X'.
  1180. LOOP AT lt_gylx INTO gs_gylx.
  1181. * IF gs_gylx-steus = 'SOP'. "控制码转换
  1182. * gs_gylx-steus = 'MP01'.
  1183. * ELSE.
  1184. * gs_gylx-steus = 'MP06'.
  1185. * ENDIF.
  1186. IF sy-tabix = 1.
  1187. CLEAR ls_material.
  1188. ls_material-task_list_group = lv_group."
  1189. ls_material-material = gs_gylx-matnr."物料编号
  1190. ls_material-plant = gs_gylx-werks."工厂
  1191. ls_material-valid_from = sy-datum."有效起始日期
  1192. ls_material-valid_to_date = '99991231'."有效截止日期
  1193. APPEND ls_material TO lt_material.
  1194. CLEAR ls_sequence.
  1195. ls_sequence-task_list_group = lv_group."组
  1196. ls_sequence-sequence_no = '000000'."序列
  1197. ls_sequence-valid_from = sy-datum. "有效起始日期
  1198. ls_sequence-valid_to_date = '99991231'."有效截止日期
  1199. ls_sequence-sequence_category = '0'."顺序类别
  1200. ls_sequence-alignment_key_for_scheduling = '2'."计划校准码
  1201. APPEND ls_sequence TO lt_sequence.
  1202. CLEAR ls_task.
  1203. ls_task-task_list_group = lv_group."组
  1204. ls_task-group_counter = gs_gylx-plnal."组计数器
  1205. ls_task-valid_from = sy-datum. "有效起始日期
  1206. ls_task-valid_to_date = '99991231'."有效截止日期
  1207. ls_task-task_list_usage = '1'. "任务清单使用
  1208. ls_task-plant = gs_gylx-werks."工厂
  1209. ls_task-task_list_status = '4'."状态
  1210. ls_task-task_measure_unit = ls_marc-meins."任务清单计量单位
  1211. ls_task-description = gs_gylx-ktext."任务清单描述
  1212. ls_task-old_number_of_task_list = gs_gylx-plnnr_alt."PLM工艺流程编号
  1213. APPEND ls_task TO lt_task.
  1214. ENDIF.
  1215. "工序
  1216. CLEAR ls_operation.
  1217. ls_operation-task_list_group = lv_group."
  1218. * ls_operation-group_counter = gs_gylx-plnal."组计数器
  1219. ls_operation-sequence_no = '000000'.
  1220. ls_operation-valid_from = sy-datum. "有效起始日期
  1221. ls_operation-valid_to_date = '99991231'. "有效截止日期
  1222. ls_operation-activity = gs_gylx-vornr. "操作/活动编号
  1223. ls_operation-control_key = gs_gylx-steus. "控制码
  1224. ls_operation-standard_text_key = gs_gylx-ktsch. "工序标准文本码
  1225. ls_operation-work_cntr = gs_gylx-arbpl. "工作中心
  1226. * ls_operation-denominator = '1'."用于转换工艺路线和工序单位的分母
  1227. * ls_operation-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
  1228. ls_operation-base_quantity = gs_gylx-bmsch."基本数量
  1229. ls_operation-operation_measure_unit = ls_marc-meins."单位
  1230. ls_operation-description = gs_gylx-txt."标准文本
  1231. ls_operation-nominator = gs_gylx-umrez.
  1232. ls_operation-denominator = gs_gylx-umren.
  1233. PERFORM frm_get_op_plant USING gs_gylx-werks gs_gylx-arbpl CHANGING ls_operation-plant.
  1234. ls_operation-info_rec = gs_gylx-infnr."采购信息记录
  1235. ls_operation-purch_org = gs_gylx-ekorg."采购组织
  1236. PERFORM ftm_get_cost_elem USING ls_operation-plant
  1237. ls_operation-info_rec
  1238. ls_operation-purch_org
  1239. CHANGING ls_operation-cost_elem."成本要素
  1240. * ls_operation-std_value_01 = gs_gylx-vgw01."工时
  1241. * ls_operation-std_unit_01 = gs_gylx-vge01."工时计量单位
  1242. * ls_operation-std_value_02 = gs_gylx-vgw01."固定
  1243. * ls_operation-std_unit_02 = gs_gylx-vge01."工时计量单位
  1244. * ls_operation-std_value_03 = gs_gylx-vgw01."变动
  1245. * ls_operation-std_unit_03 = gs_gylx-vge01."工时计量单位
  1246. * ls_operation-std_value_04 = gs_gylx-vgw01."营运
  1247. * ls_operation-std_unit_04 = gs_gylx-vge01."工时计量单位
  1248. PERFORM frm_set_std_value USING ls_operation-plant
  1249. gs_gylx-arbpl
  1250. gs_gylx-vgw01
  1251. gs_gylx-vge01
  1252. CHANGING ls_operation-std_value_01
  1253. ls_operation-std_unit_01
  1254. ls_operation-std_value_02
  1255. ls_operation-std_unit_02
  1256. ls_operation-std_value_03
  1257. ls_operation-std_unit_03
  1258. ls_operation-std_value_04
  1259. ls_operation-std_unit_04
  1260. ls_operation-std_value_05
  1261. ls_operation-std_unit_05
  1262. ls_operation-std_value_06
  1263. ls_operation-std_unit_06
  1264. ls_operations-acttype_01
  1265. ls_operations-acttype_02
  1266. ls_operations-acttype_03
  1267. ls_operations-acttype_04
  1268. ls_operations-acttype_05
  1269. ls_operations-acttype_06.
  1270. * IF gs_gylx-steus = 'MQ01'.
  1271. * ls_operations-acttype_01 = 'ZJ01'.
  1272. * ENDIF.
  1273. ls_operation-cost_relevant = 'X'."于成本核算先关表示
  1274. APPEND ls_operation TO lt_operation.
  1275. "组件分配 component allocation -->工序
  1276. LOOP AT lt_fpwlv INTO ls_fpwlv WHERE vornr = gs_gylx-vornr.
  1277. READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
  1278. posnr = ls_fpwlv-posnr.
  1279. IF sy-subrc = 0.
  1280. CHECK lt_stb-loekz IS INITIAL.
  1281. CLEAR ls_component.
  1282. ls_component-task_list_group = lv_group."
  1283. ls_component-sequence_no = '000000'.
  1284. ls_component-valid_from = sy-datum. "有效起始日期
  1285. ls_component-valid_to_date = '99991231'."有效截止日期
  1286. ls_component-activity = ls_fpwlv-vornr. "工序号
  1287. ls_component-bom_type = 'M' . "BOM 类别
  1288. ls_component-bom_no = lt_stb-stlnr. "物料单
  1289. ls_component-alternative_bom = lt_mast-stlal."可选的 BOM
  1290. ls_component-item_id = lt_stb-stvkn. "项目 ID
  1291. ls_component-item_no = lt_stb-posnr. "BOM 项目号
  1292. ls_component-plant = gs_gylx-werks. "工厂
  1293. * ls_component-material = ls_fpwl-matnr. "物料号
  1294. ls_component-material = ''.
  1295. ls_component-backflush = lt_stb-rgekz.
  1296. "虚拟件分配,填入level和path
  1297. IF lt_stb-dumps IS NOT INITIAL.
  1298. * CLEAR ls_phantom.
  1299. ** ls_component-material = gs_gylx-matnr.
  1300. * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
  1301. * wegxx = lt_stb-wegxx.
  1302. * ls_component-order_lvl = ls_phantom-level.
  1303. * ls_component-order_path = ls_phantom-path.
  1304. ELSE.
  1305. IF lt_stb-stufe > 1.
  1306. ls_component-material = gs_gylx-matnr.
  1307. READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
  1308. wegxx = lt_stb-vwegx.
  1309. IF sy-subrc = 0.
  1310. ls_component-order_lvl = ls_phantom-level.
  1311. ls_component-order_path = ls_phantom-path.
  1312. * READ TABLE lt_stb WITH KEY stufe = 1
  1313. * wegxx = lt_stb-vwegx.
  1314. * IF sy-subrc = 0.
  1315. ls_component-bom_type_root = 'M'.
  1316. ls_component-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
  1317. ls_component-alternative_bom_root = lt_mast-stlal."lt_stb-stlal.
  1318. * ENDIF.
  1319. ENDIF.
  1320. ENDIF.
  1321. ENDIF.
  1322. APPEND ls_component TO lt_component.
  1323. ENDIF.
  1324. ENDLOOP.
  1325. ENDLOOP.
  1326. * SORT lt_component.
  1327. DELETE ADJACENT DUPLICATES FROM lt_component COMPARING ALL FIELDS.
  1328. CALL FUNCTION 'BAPI_ROUTING_CREATE'
  1329. EXPORTING
  1330. application = 'PP01'
  1331. IMPORTING
  1332. group = lv_group
  1333. TABLES
  1334. task = lt_task
  1335. materialtaskallocation = lt_material
  1336. sequence = lt_sequence
  1337. operation = lt_operation
  1338. componentallocation = lt_component
  1339. return = lt_return.
  1340. READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
  1341. IF sy-subrc = 0.
  1342. return-type = 'E'.
  1343. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  1344. return-id = ls_return-id.
  1345. return-type = ls_return-type.
  1346. return-number = ls_return-number.
  1347. MESSAGE ID ls_return-id
  1348. TYPE ls_return-type
  1349. NUMBER ls_return-number
  1350. WITH ls_return-message_v1
  1351. ls_return-message_v2
  1352. ls_return-message_v3
  1353. ls_return-message_v4
  1354. INTO lv_message.
  1355. CONCATENATE return-message lv_message INTO return-message.
  1356. ENDLOOP.
  1357. ROLLBACK WORK.
  1358. ELSE.
  1359. return-type = 'S'.
  1360. return-message = '系统处理成功!'.
  1361. "ls_out-flg = 'X'.
  1362. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
  1363. EXPORTING
  1364. wait = 'X'.
  1365. "保存版本,供ME使用----------------------------
  1366. "MES 所需内容 FROM--------------------20200422-----------
  1367. READ TABLE et_gylx INTO gs_gylx INDEX 1.
  1368. IF gs_gylx-version IS NOT INITIAL.
  1369. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  1370. EXPORTING
  1371. input = gs_gylx-matnr
  1372. IMPORTING
  1373. output = ls_routing-matnr.
  1374. ls_routing-werks = gs_gylx-werks.
  1375. ls_routing-stlal = gs_gylx-stlal.
  1376. ls_routing-ztype = 'R'.
  1377. ls_routing-datum = sy-datum.
  1378. ls_routing-zgybb = gs_gylx-version.
  1379. ls_routing-zgybh = gs_gylx-plnnr_alt.
  1380. MODIFY ztplm_routing FROM ls_routing.
  1381. COMMIT WORK AND WAIT.
  1382. ENDIF.
  1383. "MES 所需内容 END --------------------20200422-----------
  1384. ENDIF.
  1385. ENDIF.
  1386. IF lv_modify = 'X'.
  1387. "工艺路线-子项目 修改
  1388. READ TABLE lt_gylx INTO gs_gylx INDEX 1.
  1389. READ TABLE lt_mapl INTO wa_mapl WITH KEY matnr = gs_gylx-matnr
  1390. werks = gs_gylx-werks
  1391. plnal = gs_gylx-plnal
  1392. loekz = ''.
  1393. IF sy-subrc <> 0.
  1394. "物料分配,此工艺路线+
  1395. ls_materials-maintain_mode = 'C'.
  1396. ls_materials-material = gs_gylx-matnr.
  1397. ls_materials-plant = gs_gylx-werks.
  1398. APPEND ls_materials TO lt_materials.
  1399. ENDIF.
  1400. * LOOP AT lt_mapl INTO wa_mapl.
  1401. READ TABLE lt_mapl INTO wa_mapl INDEX 1.
  1402. * DELETE lt_com_tab WHERE stlal_w <> gs_gylx-stlal.
  1403. LOOP AT lt_com_tab INTO ls_com_tab.
  1404. IF ls_com_tab-stlnr <> lt_mast-stlnr AND ls_com_tab-stlnr_w <> lt_mast-stlnr.
  1405. DELETE lt_com_tab.
  1406. CONTINUE.
  1407. ENDIF.
  1408. IF ls_com_tab-stlal_w IS INITIAL.
  1409. IF ls_com_tab-stlal <> gs_gylx-stlal.
  1410. DELETE lt_com_tab.
  1411. CONTINUE.
  1412. ENDIF.
  1413. ELSE.
  1414. IF ls_com_tab-stlal_w <> gs_gylx-stlal.
  1415. DELETE lt_com_tab.
  1416. CONTINUE.
  1417. ENDIF.
  1418. ENDIF.
  1419. ENDLOOP.
  1420. lt_gylx_temp = lt_gylx.
  1421. * DELETE lt_gylx_temp WHERE plnal <> wa_mapl-plnal.
  1422. SORT lt_gylx_temp BY matnr
  1423. werks
  1424. plnal "工艺路线-子项目 组计数器
  1425. verwe "工艺路线-子项目 用途
  1426. vornr."工艺路线-子项目 工序-子项目 工序号
  1427. ***创建和修改
  1428. CLEAR:lv_vornr.
  1429. LOOP AT lt_gylx_temp INTO gs_gylx.
  1430. IF sy-tabix = 1.
  1431. * TASK 组
  1432. CLEAR ls_h_task.
  1433. * ls_h_task-group_counter = gs_gylx-plnal."组计数器
  1434. ls_h_task-plant = gs_gylx-werks."工厂
  1435. ls_h_task-task_list_usage = '1'. "任务清单使用
  1436. ls_h_task-task_list_status = '4'."状态
  1437. ls_h_task-description = gs_gylx-ktext."任务清单描述
  1438. ls_h_task-task_measure_unit = ls_marc-meins.
  1439. ls_h_task-old_number_of_task_list = gs_gylx-plnnr_alt.
  1440. ls_h_task_x-description = 'X'.
  1441. ENDIF.
  1442. CLEAR:ls_operations,ls_operations_x.
  1443. READ TABLE lt_opr_tab INTO ls_opr_tab
  1444. WITH KEY vornr = gs_gylx-vornr.
  1445. IF sy-subrc = 0.
  1446. "工序修改
  1447. ls_operations-maintain_mode = 'M'. "修改
  1448. ELSE.
  1449. "工序新建
  1450. ls_operations-maintain_mode = 'C'. "创建
  1451. ENDIF.
  1452. "------------------修改于20200803--------------FROM----------
  1453. IF lv_vornr IS INITIAL .
  1454. lv_vornr = 1.
  1455. ELSE.
  1456. lv_vornr = lv_vornr + 1.
  1457. ENDIF.
  1458. ls_operations-flag_bar_pointer = lv_vornr.
  1459. " ls_operations-flag_bar_pointer = gs_gylx-vornr / 10.
  1460. "------------------修改于20200803--------------END-----------
  1461. ls_operations-sequence_no = '000000'.
  1462. ls_operations-activity = gs_gylx-vornr. "操作/活动编号
  1463. ls_operations-control_key = gs_gylx-steus. "控制码
  1464. ls_operations-standard_text_key = gs_gylx-ktsch. "工序标准文本码
  1465. ls_operations-description = gs_gylx-txt. "工序标准文本码
  1466. ls_operations-work_cntr = gs_gylx-arbpl. "工作中心
  1467. * ls_operations-plant = gs_gylx-werks. "工作中心
  1468. * ls_operations-denominator = '1'."用于转换工艺路线和工序单位的分母
  1469. * ls_operations-nominator = '1'. "用于转换任务清单和工序计量单位的计数器
  1470. ls_operations-nominator = gs_gylx-umrez.
  1471. ls_operations-denominator = gs_gylx-umren.
  1472. ls_operations-base_quantity = gs_gylx-bmsch."基本数量
  1473. ls_operations-operation_measure_unit = ls_marc-meins."单位
  1474. PERFORM frm_get_op_plant USING gs_gylx-werks gs_gylx-arbpl CHANGING ls_operations-plant.
  1475. ls_operations-info_rec = gs_gylx-infnr."采购信息记录
  1476. ls_operations-purch_org = gs_gylx-ekorg."采购组织
  1477. PERFORM ftm_get_cost_elem USING ls_operations-plant
  1478. ls_operations-info_rec
  1479. ls_operations-purch_org
  1480. CHANGING ls_operations-cost_elem."成本要素
  1481. * ls_operations-std_value_01 = gs_gylx-vgw01."工时
  1482. * ls_operations-std_unit_01 = gs_gylx-vge01."工时计量单位
  1483. * ls_operations-std_value_02 = gs_gylx-vgw01."固定
  1484. * ls_operations-std_unit_02 = gs_gylx-vge01."工时计量单位
  1485. * ls_operations-std_value_03 = gs_gylx-vgw01."变动
  1486. * ls_operations-std_unit_03 = gs_gylx-vge01."工时计量单位
  1487. * ls_operations-std_value_04 = gs_gylx-vgw01."营运
  1488. * ls_operations-std_unit_04 = gs_gylx-vge01."工时计量单位
  1489. PERFORM frm_set_std_value USING ls_operations-plant
  1490. gs_gylx-arbpl
  1491. gs_gylx-vgw01
  1492. gs_gylx-vge01
  1493. CHANGING ls_operations-std_value_01
  1494. ls_operations-std_unit_01
  1495. ls_operations-std_value_02
  1496. ls_operations-std_unit_02
  1497. ls_operations-std_value_03
  1498. ls_operations-std_unit_03
  1499. ls_operations-std_value_04
  1500. ls_operations-std_unit_04
  1501. ls_operations-std_value_05
  1502. ls_operations-std_unit_05
  1503. ls_operations-std_value_06
  1504. ls_operations-std_unit_06
  1505. ls_operations-acttype_01
  1506. ls_operations-acttype_02
  1507. ls_operations-acttype_03
  1508. ls_operations-acttype_04
  1509. ls_operations-acttype_05
  1510. ls_operations-acttype_06.
  1511. * IF gs_gylx-steus = 'MQ01'.
  1512. * ls_operations-acttype_01 = 'ZJ01'.
  1513. * ENDIF.
  1514. ls_operations-cost_relevant = 'X'.
  1515. APPEND ls_operations TO lt_operations.
  1516. IF ls_operations-maintain_mode = 'C'. "创建
  1517. ls_operations_x-activity = 'X'. "操作/活动编号
  1518. ENDIF.
  1519. ls_operations_x-control_key = 'X'. "控制码
  1520. ls_operations_x-standard_text_key = 'X'. "工序标准文本码
  1521. ls_operations_x-description = 'X'. "工序标准文本码描述
  1522. ls_operations_x-work_cntr = 'X'. "工作中心
  1523. ls_operations_x-plant = 'X'. "工厂
  1524. ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
  1525. ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
  1526. ls_operations_x-base_quantity = 'X'."基本数量
  1527. ls_operations_x-operation_measure_unit = 'X'."单位
  1528. ls_operations_x-std_value_01 = 'X'."工时
  1529. ls_operations_x-std_unit_01 = 'X'."工时计量单位
  1530. ls_operations_x-std_value_02 = 'X'."固定
  1531. ls_operations_x-std_unit_02 = 'X'."工时计量单位
  1532. ls_operations_x-std_value_03 = 'X'."变动
  1533. ls_operations_x-std_unit_03 = 'X'."工时计量单位
  1534. ls_operations_x-std_value_04 = 'X'."营运
  1535. ls_operations_x-std_unit_04 = 'X'."工时计量单位
  1536. ls_operations_x-std_value_05 = 'X'."外协
  1537. ls_operations_x-std_unit_05 = 'X'."工时计量单位
  1538. ls_operations_x-std_value_06 = 'X'."质检
  1539. ls_operations_x-std_unit_06 = 'X'."工时计量单位
  1540. ls_operations_x-cost_relevant = 'X'."成本核算表示
  1541. ls_operations_x-info_rec = 'X'. "采购信息记录
  1542. ls_operations_x-purch_org = 'X'. "采购组织
  1543. ls_operations_x-cost_elem = 'X'."成本要素
  1544. ls_operations_x-acttype_01 = 'X'.
  1545. ls_operations_x-acttype_02 = 'X'.
  1546. ls_operations_x-acttype_03 = 'X'.
  1547. ls_operations_x-acttype_04 = 'X'.
  1548. ls_operations_x-acttype_05 = 'X'.
  1549. ls_operations_x-acttype_06 = 'X'.
  1550. APPEND ls_operations_x TO lt_operations_x.
  1551. ENDLOOP.
  1552. "组件分配 component allocation -->工序
  1553. IF lt_materials[] IS NOT INITIAL.
  1554. REFRESH lt_com_tab[].
  1555. ENDIF.
  1556. LOOP AT lt_fpwlv INTO ls_fpwlv.
  1557. READ TABLE lt_stb WITH KEY idnrk = ls_fpwlv-matnr
  1558. posnr = ls_fpwlv-posnr.
  1559. IF sy-subrc = 0.
  1560. CHECK lt_stb-loekz IS INITIAL.
  1561. CLEAR: ls_components, ls_components_x, ls_com_tab, ls_opr_tab.
  1562. READ TABLE lt_com_tab INTO ls_com_tab
  1563. WITH KEY stlty = 'M'
  1564. stlnr = lt_stb-stlnr
  1565. stlal = lt_stb-stlal
  1566. stlkn = lt_stb-stvkn.
  1567. IF sy-subrc = 0.
  1568. READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
  1569. CHECK ls_fpwlv-vornr <> ls_opr_tab-vornr.
  1570. ls_components-maintain_mode = 'M'. "修改
  1571. ELSE.
  1572. ls_components-maintain_mode = 'C'. "创建
  1573. ENDIF.
  1574. lv_pointer = lv_pointer + 1.
  1575. ls_components-flag_bar_pointer = lv_pointer.
  1576. ls_components-sequence_no = '000000'.
  1577. ls_components-activity = ls_fpwlv-vornr. "工序号
  1578. ls_components-activity_old = ls_opr_tab-vornr.
  1579. ls_components-bom_type = 'M' . "BOM 类别
  1580. ls_components-bom_no = lt_stb-stlnr. "物料单
  1581. ls_components-alternative_bom = gs_gylx-stlal."可选的 BOM
  1582. ls_components-item_id = lt_stb-stvkn. "项目 ID
  1583. ls_components-item_no = lt_stb-posnr. "BOM 项目号
  1584. ls_components-plant = gs_gylx-werks. "工厂
  1585. * ls_component-material = ls_fpwl-matnr. "物料号
  1586. ls_component-material = ''.
  1587. ls_components-backflush = lt_stb-rgekz.
  1588. ls_components-bom_type_root = 'M'.
  1589. ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
  1590. ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
  1591. "虚拟件分配,填入level和path
  1592. IF lt_stb-dumps IS NOT INITIAL.
  1593. * CLEAR ls_phantom.
  1594. ** ls_components-material = gs_gylx-matnr.
  1595. * READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = lt_stb-stufe
  1596. * wegxx = lt_stb-wegxx.
  1597. * ls_components-order_lvl = ls_phantom-level.
  1598. * ls_components-order_path = ls_phantom-path.
  1599. ls_components-order_lvl = lt_stb-aufst.
  1600. ls_components-order_path = lt_stb-aufwg.
  1601. READ TABLE lt_stpox INTO ls_stpox WITH KEY stufe = lt_stb-stufe
  1602. wegxx = lt_stb-wegxx.
  1603. IF sy-subrc = 0.
  1604. ls_components-path = ls_stpox-nlink.
  1605. ENDIF.
  1606. * ls_components-path = lt_stb-aufwg.
  1607. ELSE.
  1608. IF lt_stb-stufe > 1.
  1609. ls_components-material = gs_gylx-matnr.
  1610. READ TABLE lt_phantom INTO ls_phantom WITH KEY stufe = 1
  1611. wegxx = lt_stb-vwegx.
  1612. IF sy-subrc = 0.
  1613. ls_components-order_lvl = ls_phantom-level.
  1614. ls_components-order_path = ls_phantom-path.
  1615. * READ TABLE lt_stb WITH KEY stufe = 1
  1616. * wegxx = lt_stb-vwegx.
  1617. * IF sy-subrc = 0.
  1618. ls_components-bom_type_root = 'M'.
  1619. ls_components-bom_no_root = lt_mast-stlnr. "lt_stb-stlnr.
  1620. ls_components-alternative_bom_root = lt_mast-stlal. "lt_stb-stlal.
  1621. * ENDIF.
  1622. ENDIF.
  1623. ENDIF.
  1624. ENDIF.
  1625. APPEND ls_components TO lt_components.
  1626. ls_components_x-activity = 'X'. "操作/活动编号
  1627. IF ls_components-maintain_mode = 'C'.
  1628. ls_components_x-sequence_no = 'X'.
  1629. ls_components_x-plant = 'X'. "工厂
  1630. * ls_components_x-material = 'X'. "物料号
  1631. ls_components_x-material = 'X'.
  1632. ls_components_x-backflush = 'X'.
  1633. ls_components_x-order_lvl = 'X'.
  1634. ls_components_x-order_path = 'X'.
  1635. ls_components_x-path = 'X'.
  1636. ls_components_x-bom_type_root = 'X'.
  1637. ls_components_x-bom_no_root = 'X'.
  1638. ls_components_x-alternative_bom_root = 'X'.
  1639. ENDIF.
  1640. APPEND ls_components_x TO lt_components_x.
  1641. ENDIF.
  1642. ENDLOOP.
  1643. **删除
  1644. *工序删除无法处理组件分配自动删除,单独BDC处理
  1645. CLEAR:lv_pointer.
  1646. LOOP AT lt_operations INTO ls_operations.
  1647. lv_pointer = ls_operations-flag_bar_pointer.
  1648. ENDLOOP.
  1649. LOOP AT lt_opr_tab INTO ls_opr_tab.
  1650. READ TABLE lt_gylx_temp INTO gs_gylx WITH KEY vornr = ls_opr_tab-vornr.
  1651. IF sy-subrc <> 0.
  1652. CLEAR:ls_operations,ls_operations_x.
  1653. ls_operations-maintain_mode = 'D'. "删除
  1654. "------------------修改于20200803--------------FROM----------
  1655. IF lv_pointer IS INITIAL .
  1656. lv_pointer = 1.
  1657. ELSE.
  1658. lv_pointer = lv_pointer + 1.
  1659. ENDIF.
  1660. ls_operations-flag_bar_pointer = lv_pointer.
  1661. " ls_operations-flag_bar_pointer = ls_opr_tab-vornr / 10.
  1662. "------------------修改于20200803--------------END-----------
  1663. ls_operations-sequence_no = '000000'.
  1664. ls_operations-activity = ls_opr_tab-vornr. "操作/活动编号
  1665. APPEND ls_operations TO lt_operations_del.
  1666. * ls_operations_x-control_key = 'X'. "控制码
  1667. * ls_operations_x-standard_text_key = 'X'. "工序标准文本码
  1668. * ls_operations_x-description = 'X'. "工序标准文本码描述
  1669. * ls_operations_x-work_cntr = 'X'. "工作中心
  1670. * ls_operations_x-plant = 'X'. "工厂
  1671. * ls_operations_x-denominator = 'X'."用于转换工艺路线和工序单位的分母
  1672. * ls_operations_x-nominator = 'X'. "用于转换任务清单和工序计量单位的计数器
  1673. * ls_operations_x-base_quantity = 'X'."基本数量
  1674. * ls_operations_x-operation_measure_unit = 'X'."单位
  1675. * ls_operations_x-std_value_01 = 'X'."工时
  1676. * ls_operations_x-std_unit_01 = 'X'."工时计量单位
  1677. * ls_operations_x-std_value_02 = 'X'."固定
  1678. * ls_operations_x-std_unit_02 = 'X'."工时计量单位
  1679. * ls_operations_x-std_value_03 = 'X'."变动
  1680. * ls_operations_x-std_unit_03 = 'X'."工时计量单位
  1681. * ls_operations_x-std_value_04 = 'X'."营运
  1682. * ls_operations_x-std_unit_04 = 'X'."工时计量单位
  1683. * ls_operations_x-std_value_05 = 'X'."外协
  1684. * ls_operations_x-std_unit_05 = 'X'."工时计量单位
  1685. * ls_operations_x-std_value_06 = 'X'."质检
  1686. * ls_operations_x-std_unit_06 = 'X'."工时计量单位
  1687. *
  1688. * APPEND ls_operations_x TO lt_operations_x.
  1689. ENDIF.
  1690. ENDLOOP.
  1691. * SORT lt_operations BY activity.
  1692. CLEAR:lv_pointer.
  1693. LOOP AT lt_components INTO ls_components.
  1694. lv_pointer = ls_components-flag_bar_pointer.
  1695. ENDLOOP.
  1696. LOOP AT lt_com_tab INTO ls_com_tab.
  1697. CLEAR: lt_stb, ls_opr_tab, ls_fpwlv.
  1698. READ TABLE lt_stb WITH KEY stlty = ls_com_tab-stlty
  1699. stlnr = ls_com_tab-stlnr
  1700. stlal = ls_com_tab-stlal
  1701. stvkn = ls_com_tab-stlkn.
  1702. CHECK sy-subrc = 0.
  1703. READ TABLE lt_opr_tab INTO ls_opr_tab WITH KEY plnkn = ls_com_tab-plnkn.
  1704. READ TABLE lt_fpwlv INTO ls_fpwlv WITH KEY posnr = lt_stb-posnr
  1705. matnr = lt_stb-idnrk.
  1706. * vornr = ls_opr_tab-vornr.
  1707. CHECK sy-subrc <> 0.
  1708. CLEAR: ls_components, ls_components_x.
  1709. ls_components-maintain_mode = 'D'. "删除
  1710. IF lv_pointer IS INITIAL.
  1711. lv_pointer = 1.
  1712. ELSE.
  1713. lv_pointer = lv_pointer + 1.
  1714. ENDIF.
  1715. ls_components-flag_bar_pointer = lv_pointer.
  1716. ls_components-sequence_no = ls_com_tab-plnfl.
  1717. ls_components-activity = ls_opr_tab-vornr. "工序号
  1718. ls_components-bom_type = 'M' . "BOM 类别
  1719. ls_components-bom_no = ls_com_tab-stlnr. "物料单
  1720. ls_components-alternative_bom = ls_com_tab-stlal."可选的 BOM
  1721. ls_components-item_id = lt_stb-stvkn. "项目 ID
  1722. ls_components-item_no = lt_stb-posnr. "BOM 项目号
  1723. ls_components-plant = ls_com_tab-werk_stl. "工厂
  1724. * ls_component-material = ls_fpwl-matnr. "物料号
  1725. ls_component-material = ''.
  1726. IF ls_com_tab-stlst IS NOT INITIAL AND lt_stb-dumps IS INITIAL.
  1727. ls_components-material = gs_gylx-matnr.
  1728. ENDIF.
  1729. ls_components-backflush = ls_com_tab-rgekz.
  1730. ls_components-order_lvl = ls_com_tab-stlst.
  1731. ls_components-order_path = ls_com_tab-stlwg.
  1732. ls_components-bom_type_root = ls_com_tab-stlty_w.
  1733. ls_components-bom_no_root = ls_com_tab-stlnr_w.
  1734. ls_components-alternative_bom_root = ls_com_tab-stlal_w.
  1735. ls_components-path = ls_com_tab-kante.
  1736. APPEND ls_components TO lt_components.
  1737. ls_components_x-sequence_no = 'X'.
  1738. ls_components_x-activity = 'X'. "工序号
  1739. ls_components_x-plant = 'X'. "工厂
  1740. ls_components_x-material = 'X'. "物料号
  1741. ls_components_x-backflush = 'X'.
  1742. ls_components_x-order_lvl = 'X'.
  1743. ls_components_x-order_path = 'X'.
  1744. ls_components_x-bom_type_root = 'X'.
  1745. ls_components_x-bom_no_root = 'X'.
  1746. ls_components_x-alternative_bom_root = 'X'.
  1747. ls_components_x-path = 'X'.
  1748. APPEND ls_components_x TO lt_components_x.
  1749. ENDLOOP.
  1750. * SORT lt_components.SORT lt_components_x.
  1751. CALL FUNCTION 'ROUTING_MAINTAIN'
  1752. EXPORTING
  1753. change_no = lv_changeno
  1754. key_date = sy-datum
  1755. task_list_group = wa_mapl-plnnr "
  1756. * group_counter = wa_mapl-plnal "组计数器
  1757. * material = wa_mapl-matnr "物料编号
  1758. * plant = wa_mapl-werks "工厂
  1759. group_counter = gs_gylx-plnal "组计数器
  1760. material = gs_gylx-matnr "物料编号
  1761. plant = gs_gylx-werks "工厂
  1762. task = ls_h_task
  1763. task_x = ls_h_task_x
  1764. application = 'PP01'
  1765. bom_usage = lt_mast-stlan
  1766. TABLES
  1767. material_task_allocations = lt_materials
  1768. material_task_allocations_x = lt_materials_x
  1769. * SEQUENCES = SEQUENCES
  1770. * SEQUENCES_X = SEQUENCES_X
  1771. operations = lt_operations
  1772. operations_x = lt_operations_x
  1773. component_allocations = lt_components
  1774. component_allocations_x = lt_components_x
  1775. return = lt_return.
  1776. * READ TABLE lt_return INTO ls_return TRANSPORTING NO FIELDS WITH KEY type = 'E'. "存放导入工艺路线时的错误提示信息
  1777. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  1778. ENDLOOP.
  1779. IF sy-subrc = 0.
  1780. return-type = 'E'.
  1781. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
  1782. return-id = ls_return-id.
  1783. * return-type = ls_return-type.
  1784. return-number = ls_return-number.
  1785. MESSAGE ID ls_return-id
  1786. TYPE ls_return-type
  1787. NUMBER ls_return-number
  1788. WITH ls_return-message_v1
  1789. ls_return-message_v2
  1790. ls_return-message_v3
  1791. ls_return-message_v4
  1792. INTO lv_message.
  1793. CONCATENATE return-message lv_message INTO return-message.
  1794. ENDLOOP.
  1795. ROLLBACK WORK.
  1796. ELSE.
  1797. "ls_out-flg = 'X'.
  1798. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "导入成功
  1799. EXPORTING
  1800. wait = 'X'.
  1801. IF lt_operations_del[] IS NOT INITIAL.
  1802. WAIT UP TO 1 SECONDS.
  1803. PERFORM frm_delete_operation TABLES lt_operations_del
  1804. USING lv_group gs_gylx-matnr gs_gylx-werks
  1805. CHANGING return.
  1806. ENDIF.
  1807. IF return-type <> 'E'.
  1808. return-type = 'S'.
  1809. return-message = '系统处理成功!'.
  1810. "保存版本,供ME使用----------------------------
  1811. "MES 所需内容 FROM--------------------20200422-----------
  1812. READ TABLE et_gylx INTO gs_gylx INDEX 1.
  1813. IF gs_gylx-version IS NOT INITIAL.
  1814. CALL FUNCTION 'CONVERSION_EXIT_EAN11_INPUT'
  1815. EXPORTING
  1816. input = gs_gylx-matnr
  1817. IMPORTING
  1818. output = ls_routing-matnr.
  1819. ls_routing-werks = gs_gylx-werks.
  1820. ls_routing-stlal = gs_gylx-stlal.
  1821. ls_routing-ztype = 'R'.
  1822. ls_routing-datum = sy-datum.
  1823. ls_routing-zgybb = gs_gylx-version.
  1824. ls_routing-zgybh = gs_gylx-plnnr_alt.
  1825. MODIFY ztplm_routing FROM ls_routing.
  1826. COMMIT WORK AND WAIT.
  1827. ENDIF.
  1828. ENDIF.
  1829. ENDIF.
  1830. "更改工艺路线
  1831. CLEAR:ls_h_task, ls_h_task_x, lt_materials,lt_materials_x,
  1832. lt_sequences,lt_sequences_x,lt_operations,lt_operations_x,lt_components,lt_components_x.
  1833. * ENDLOOP.
  1834. ENDIF.
  1835. "发送安达发MES
  1836. IF return-type = 'S' AND ls_routing IS NOT INITIAL.
  1837. CALL FUNCTION 'ZJKPLM006_TO_MES' IN BACKGROUND TASK
  1838. EXPORTING
  1839. matnr = ls_routing-matnr
  1840. werks = ls_routing-werks
  1841. stlal = ls_routing-stlal
  1842. datum = ls_routing-datum
  1843. zgybh = ls_routing-zgybh
  1844. zgybb = ls_routing-zgybb.
  1845. COMMIT WORK.
  1846. ENDIF.
  1847. ENDIF.
  1848. ENDFUNCTION.
  1849. *&---------------------------------------------------------------------*
  1850. *& Form FRM_BDC_DYNPRO
  1851. *&---------------------------------------------------------------------*
  1852. * -->PT_BDCDATA text
  1853. * -->PV_PROGRAM text
  1854. * -->PV_DYNPRO text
  1855. *----------------------------------------------------------------------*
  1856. FORM frm_bdc_dynpro TABLES pt_bdcdata STRUCTURE bdcdata
  1857. USING pv_program
  1858. pv_dynpro.
  1859. DATA: ls_bdcdata TYPE bdcdata.
  1860. WRITE pv_program TO ls_bdcdata-program.
  1861. WRITE pv_dynpro TO ls_bdcdata-dynpro.
  1862. WRITE 'X' TO ls_bdcdata-dynbegin.
  1863. APPEND ls_bdcdata TO pt_bdcdata.
  1864. CLEAR ls_bdcdata.
  1865. ENDFORM. " BDC_DYNPRO
  1866. *&---------------------------------------------------------------------*
  1867. *& Form FRM_BDC_FIELD
  1868. *&---------------------------------------------------------------------*
  1869. * -->PT_BDCDATA text
  1870. * -->PV_FNAM text
  1871. * -->PV_FVAL text
  1872. *----------------------------------------------------------------------*
  1873. FORM frm_bdc_field TABLES pt_bdcdata STRUCTURE bdcdata
  1874. USING pv_fnam
  1875. pv_fval.
  1876. DATA:ls_bdcdata TYPE bdcdata.
  1877. DATA:lv_type TYPE c.
  1878. DESCRIBE FIELD pv_fval TYPE lv_type.
  1879. WRITE pv_fnam TO ls_bdcdata-fnam.
  1880. IF lv_type = 'D'.
  1881. WRITE pv_fval TO ls_bdcdata-fval DD/MM/YYYY.
  1882. ELSEIF lv_type = 'C' OR lv_type = 'N'.
  1883. ls_bdcdata-fval = pv_fval.
  1884. ELSE.
  1885. WRITE pv_fval TO ls_bdcdata-fval LEFT-JUSTIFIED.
  1886. ENDIF.
  1887. APPEND ls_bdcdata TO pt_bdcdata.
  1888. CLEAR ls_bdcdata.
  1889. ENDFORM. " BDC_FIELD
  1890. *&---------------------------------------------------------------------*
  1891. *& Form FRM_GET_PHANTOM
  1892. *&---------------------------------------------------------------------*
  1893. * -->PT_STB TEXT
  1894. * -->PT_PHANTOM TEXT
  1895. *----------------------------------------------------------------------*
  1896. FORM frm_get_phantom TABLES pt_stb STRUCTURE stpox
  1897. pt_com STRUCTURE capp_com
  1898. pt_phantom LIKE gt_phantom.
  1899. TYPES: BEGIN OF ty_mast,
  1900. matnr TYPE mast-matnr,
  1901. werks TYPE mast-werks,
  1902. stlan TYPE mast-stlan,
  1903. stlnr TYPE mast-stlnr,
  1904. stlal TYPE mast-stlal,
  1905. END OF ty_mast.
  1906. TYPES: BEGIN OF ty_path,
  1907. level TYPE aufst,
  1908. path TYPE aufwg,
  1909. END OF ty_path.
  1910. DATA: ls_mast TYPE ty_mast.
  1911. DATA: ls_com TYPE capp_com.
  1912. DATA: lt_path TYPE TABLE OF ty_path,
  1913. ls_path TYPE ty_path.
  1914. DATA: ls_stb TYPE stpox,
  1915. ls_phantom TYPE ty_phantom.
  1916. DATA: lv_index TYPE sy-tabix.
  1917. DATA: lv_flg_ftrel TYPE xfeld.
  1918. LOOP AT pt_com INTO ls_com.
  1919. ls_path-level = ls_com-stlst.
  1920. ls_path-path = ls_com-stlwg.
  1921. APPEND ls_path TO lt_path.
  1922. ENDLOOP.
  1923. SORT lt_path.
  1924. DELETE ADJACENT DUPLICATES FROM lt_path COMPARING ALL FIELDS.
  1925. REFRESH pt_phantom.
  1926. * CALL FUNCTION 'CM_DI_GET_FTREL_FLAG'
  1927. * IMPORTING
  1928. * e_flg_ftrel = lv_flg_ftrel.
  1929. LOOP AT pt_stb INTO ls_stb WHERE dumps IS NOT INITIAL AND idnrk IS NOT INITIAL.
  1930. SELECT SINGLE matnr werks stlan stlnr stlal
  1931. INTO ls_mast
  1932. FROM mast
  1933. WHERE matnr = ls_stb-idnrk
  1934. AND werks = ls_stb-werks
  1935. AND stlal = ls_stb-stlal
  1936. AND stlan = ls_stb-stlan.
  1937. "虚拟件的level/path
  1938. CLEAR ls_phantom.
  1939. ls_phantom-stufe = ls_stb-stufe.
  1940. ls_phantom-wegxx = ls_stb-wegxx.
  1941. ls_phantom-level = ls_stb-stufe.
  1942. READ TABLE pt_com INTO ls_com WITH KEY stlnr = ls_mast-stlnr.
  1943. IF sy-subrc = 0.
  1944. ls_phantom-path = ls_com-stlwg.
  1945. ELSE.
  1946. READ TABLE lt_path INTO ls_path WITH KEY level = ls_phantom-level.
  1947. IF sy-subrc = 0.
  1948. lv_index = sy-tabix.
  1949. ls_path-path = ls_path-path + 1.
  1950. MODIFY lt_path FROM ls_path INDEX lv_index.
  1951. ls_phantom-path = ls_path-path.
  1952. ELSE.
  1953. ls_path-level = ls_phantom-level.
  1954. ls_path-path = 1.
  1955. APPEND ls_path TO lt_path.
  1956. ls_phantom-path = ls_path-path.
  1957. ENDIF.
  1958. ENDIF.
  1959. APPEND ls_phantom TO pt_phantom.
  1960. ENDLOOP.
  1961. ENDFORM.
  1962. *&---------------------------------------------------------------------*
  1963. *& Form FRM_SET_STD_VALUE
  1964. *&---------------------------------------------------------------------*
  1965. * -->PT_STB TEXT
  1966. * -->PT_PHANTOM TEXT
  1967. *----------------------------------------------------------------------*
  1968. FORM frm_set_std_value USING pv_werks TYPE werks_d
  1969. pv_arbpl TYPE arbpl
  1970. pv_std_value TYPE vgwrt
  1971. pv_std_unit TYPE vgwrteh
  1972. CHANGING pv_std_value_01 TYPE vgwrt
  1973. pv_std_unit_01 TYPE vgwrteh
  1974. pv_std_value_02 TYPE vgwrt
  1975. pv_std_unit_02 TYPE vgwrteh
  1976. pv_std_value_03 TYPE vgwrt
  1977. pv_std_unit_03 TYPE vgwrteh
  1978. pv_std_value_04 TYPE vgwrt
  1979. pv_std_unit_04 TYPE vgwrteh
  1980. pv_std_value_05 TYPE vgwrt
  1981. pv_std_unit_05 TYPE vgwrteh
  1982. pv_std_value_06 TYPE vgwrt
  1983. pv_std_unit_06 TYPE vgwrteh
  1984. pv_acttype_01 TYPE lstar
  1985. pv_acttype_02 TYPE lstar
  1986. pv_acttype_03 TYPE lstar
  1987. pv_acttype_04 TYPE lstar
  1988. pv_acttype_05 TYPE lstar
  1989. pv_acttype_06 TYPE lstar.
  1990. DATA: ls_crhd TYPE crhd,
  1991. ls_crco TYPE crco,
  1992. lt_crco TYPE TABLE OF crco.
  1993. CLEAR: pv_std_value_01,
  1994. pv_std_unit_01,
  1995. pv_std_value_02,
  1996. pv_std_unit_02,
  1997. pv_std_value_03,
  1998. pv_std_unit_03,
  1999. pv_std_value_04,
  2000. pv_std_unit_04,
  2001. pv_std_value_05,
  2002. pv_std_unit_05,
  2003. pv_std_value_06,
  2004. pv_std_unit_06,
  2005. pv_acttype_01,
  2006. pv_acttype_02,
  2007. pv_acttype_03,
  2008. pv_acttype_04,
  2009. pv_acttype_05,
  2010. pv_acttype_06
  2011. .
  2012. SELECT SINGLE * INTO ls_crhd
  2013. FROM crhd
  2014. WHERE objty = 'A'
  2015. AND werks = pv_werks
  2016. AND arbpl = pv_arbpl
  2017. AND begda <= sy-datum
  2018. AND endda >= sy-datum.
  2019. CHECK sy-subrc = 0.
  2020. SELECT * INTO TABLE lt_crco
  2021. FROM crco
  2022. WHERE objty = 'A'
  2023. AND objid = ls_crhd-objid
  2024. AND begda <= sy-datum
  2025. AND endda >= sy-datum.
  2026. LOOP AT lt_crco INTO ls_crco.
  2027. CASE ls_crco-lanum.
  2028. WHEN 1.
  2029. pv_std_value_01 = pv_std_value.
  2030. pv_std_unit_01 = pv_std_unit.
  2031. pv_acttype_01 = ls_crco-lstar.
  2032. WHEN 2.
  2033. pv_std_value_02 = pv_std_value.
  2034. pv_std_unit_02 = pv_std_unit.
  2035. pv_acttype_02 = ls_crco-lstar.
  2036. WHEN 3.
  2037. pv_std_value_03 = pv_std_value.
  2038. pv_std_unit_03 = pv_std_unit.
  2039. pv_acttype_03 = ls_crco-lstar.
  2040. WHEN 4.
  2041. pv_std_value_04 = pv_std_value.
  2042. pv_std_unit_04 = pv_std_unit.
  2043. pv_acttype_04 = ls_crco-lstar.
  2044. WHEN 5.
  2045. pv_std_value_05 = pv_std_value.
  2046. pv_std_unit_05 = pv_std_unit.
  2047. pv_acttype_05 = ls_crco-lstar.
  2048. WHEN 6.
  2049. pv_std_value_06 = pv_std_value.
  2050. pv_std_unit_06 = pv_std_unit.
  2051. pv_acttype_06 = ls_crco-lstar.
  2052. WHEN OTHERS.
  2053. ENDCASE.
  2054. ENDLOOP.
  2055. ENDFORM.
  2056. "确定工序工厂
  2057. "根据工作中心判定,只找到一个工厂则能够确定;找到多个工厂/找不到,无法确定,则取工艺路线工厂
  2058. FORM frm_get_op_plant USING pv_werks_in TYPE werks_d
  2059. pv_arbpl TYPE arbpl
  2060. CHANGING pv_werks_o TYPE werks_d.
  2061. DATA: lt_crhd TYPE TABLE OF crhd WITH HEADER LINE.
  2062. CLEAR pv_werks_o.
  2063. SELECT * INTO TABLE lt_crhd
  2064. FROM crhd
  2065. WHERE objty = 'A'
  2066. AND arbpl = pv_arbpl
  2067. AND begda <= sy-datum
  2068. AND endda >= sy-datum.
  2069. IF lines( lt_crhd ) = 1.
  2070. READ TABLE lt_crhd INDEX 1.
  2071. pv_werks_o = lt_crhd-werks.
  2072. ELSE.
  2073. pv_werks_o = pv_werks_in.
  2074. ENDIF.
  2075. ENDFORM.
  2076. FORM frm_delete_operation TABLES pt_operations_del STRUCTURE cps_task_list_maint_opr
  2077. USING pv_group TYPE bapi1012_tsk_c-task_list_group
  2078. pv_matnr TYPE matnr
  2079. pv_werks TYPE werks_d
  2080. CHANGING ps_return TYPE zsplm_return.
  2081. DATA: ls_operations_del TYPE cps_task_list_maint_opr.
  2082. DATA: ls_params TYPE ctu_params,
  2083. ls_msg TYPE bdcmsgcoll.
  2084. LOOP AT pt_operations_del INTO ls_operations_del.
  2085. REFRESH: bdcdata, messtab.
  2086. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1010'.
  2087. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=VOUE'.
  2088. PERFORM frm_bdc_field TABLES bdcdata USING 'RC27M-MATNR' pv_matnr.
  2089. PERFORM frm_bdc_field TABLES bdcdata USING 'RC27M-WERKS' pv_werks.
  2090. PERFORM frm_bdc_field TABLES bdcdata USING 'RC271-PLNNR' pv_group.
  2091. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
  2092. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=OSEA'.
  2093. * LOOP AT pt_operations_del INTO ls_operations_del.
  2094. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCP02' '1010'.
  2095. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=ENT1'.
  2096. PERFORM frm_bdc_field TABLES bdcdata USING 'RC27H-VORNR' ls_operations_del-activity.
  2097. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
  2098. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=LOE'.
  2099. PERFORM frm_bdc_field TABLES bdcdata USING 'RC27X-FLG_SEL(01)' 'X'.
  2100. * PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLSPO1' '0100'.
  2101. * PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=YES'.
  2102. *ENDLOOP.
  2103. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLSPO1' '0100'.
  2104. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=YES'.
  2105. PERFORM frm_bdc_dynpro TABLES bdcdata USING 'SAPLCPDI' '1400'.
  2106. PERFORM frm_bdc_field TABLES bdcdata USING 'BDC_OKCODE' '=BU'.
  2107. ls_params-dismode = 'N'.
  2108. ls_params-updmode = 'S'.
  2109. ls_params-defsize = 'X'.
  2110. CALL TRANSACTION 'CA02' USING bdcdata
  2111. OPTIONS FROM ls_params
  2112. MESSAGES INTO messtab.
  2113. READ TABLE messtab INTO ls_msg WITH KEY msgtyp = 'E'.
  2114. IF sy-subrc = 0.
  2115. ps_return-type = 'E'.
  2116. ps_return-id = ls_msg-msgid.
  2117. ps_return-number = ls_msg-msgnr.
  2118. MESSAGE ID ls_msg-msgid TYPE ls_msg-msgtyp NUMBER ls_msg-msgnr
  2119. WITH ls_msg-msgv1
  2120. ls_msg-msgv2
  2121. ls_msg-msgv3
  2122. ls_msg-msgv4
  2123. INTO ps_return-message.
  2124. ENDIF.
  2125. ENDLOOP.
  2126. ENDFORM.
  2127. FORM ftm_get_cost_elem USING pv_werks TYPE werks_d
  2128. pv_infnr TYPE infnr
  2129. pv_ekorg TYPE ekorg
  2130. CHANGING pv_kstar TYPE kstar.
  2131. DATA: lv_matkl TYPE matkl.
  2132. CLEAR pv_kstar.
  2133. CHECK pv_infnr IS NOT INITIAL.
  2134. SELECT SINGLE matkl INTO lv_matkl
  2135. FROM eina
  2136. WHERE infnr = pv_infnr.
  2137. CHECK sy-subrc = 0.
  2138. CALL FUNCTION 'CO_ZF_ACCOUNT_FIND'
  2139. EXPORTING
  2140. matnr_imp = space
  2141. knttp_imp = 'F'
  2142. shkzg_imp = 'H'
  2143. werks_imp = pv_werks
  2144. matkl_imp = lv_matkl
  2145. IMPORTING
  2146. saknr_exp = pv_kstar.
  2147. ENDFORM.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/486443
推荐阅读
相关标签
  

闽ICP备14008679号