工艺路线建立——BAPI_ROUTING_CREATE
运行效果:
代码:
DATA: lv_plnnr TYPE plnnr. DATA: lt_plko TYPE TABLE OF bapi1012_tsk_c, lt_mapl TYPE TABLE OF bapi1012_mtk_c, lt_plpo TYPE TABLE OF bapi1012_opr_c, lt_subplpo TYPE TABLE OF bapi1012_sub_opr_c, lt_bom TYPE TABLE OF bapi1012_com_c, lt_msg TYPE TABLE OF bapiret2, ls_plko TYPE bapi1012_tsk_c, ls_mapl TYPE bapi1012_mtk_c, ls_plpo TYPE bapi1012_opr_c, ls_subplpo TYPE bapi1012_sub_opr_c, ls_bom TYPE bapi1012_com_c, ls_msg TYPE bapiret2. ***表头*** ls_plko-valid_from = sy-datum. "生效日期 ls_plko-valid_to_date = '99991231'. "有效期限 ls_plko-plant = '2000'. "工厂 ls_plko-task_list_usage = '1'. "用途 ls_plko-task_list_status = '4'. "状态 ls_plko-task_measure_unit = 'PCS'. "单位 ls_plko-lot_size_from = 0. "批量下限 ls_plko-lot_size_to = 99999999. "批量上限 APPEND ls_plko TO lt_plko. CLEAR ls_plko. ***物料分配*** ls_mapl-material_long = 'CTCZ0185-S2V-3'. ls_mapl-plant = '2000'. ls_mapl-valid_from = sy-datum. ls_mapl-valid_to_date = '99991231'. APPEND ls_mapl TO lt_mapl. CLEAR ls_mapl. ***工艺*** ls_plpo-activity = '0010'. ls_plpo-denominator = 1. "分母 ls_plpo-nominator = 1. "分子 ls_plpo-work_cntr = '23001'. "工作中心 ls_plpo-control_key = 'ZP10'. "控制码 ls_plpo-standard_text_key = '1050'. "标准内文码 ls_plpo-base_quantity = 1. "基础数量 ls_plpo-operation_measure_unit = 'PCS'. "单位 ls_plpo-std_value_01 = 60. "标准值1 ls_plpo-std_value_02 = '77.140'. "标准值2 ls_plpo-std_value_03 = 0. "标准值3 ls_plpo-std_value_04 = 10. "制程时间 ls_plpo-std_unit_04 = '10'. "天数单位 ls_plpo-scrap_factor = 0. "废品系数 ls_plpo-valid_from = sy-datum. "有效起始日期 ls_plpo-valid_to_date = '99991231'. "有效截止日期 ls_plpo-cost_relevant = 'X'. "与成本核算相关标志 APPEND ls_plpo TO lt_plpo. CLEAR ls_plpo. ls_plpo-activity = '0020'. ls_plpo-denominator = 1. "分母 ls_plpo-nominator = 1. "分子 ls_plpo-work_cntr = 'DP2031'. "工作中心 ls_plpo-control_key = 'ZP02'. "控制码 ls_plpo-standard_text_key = 'M231'. "标准内文码 ls_plpo-base_quantity = 600. "基础数量 ls_plpo-operation_measure_unit = 'PCS'. "单位 ls_plpo-std_value_01 = 1. "标准值1 ls_plpo-std_value_02 = 0. "标准值2 ls_plpo-std_value_03 = 1. "标准值3 ls_plpo-std_value_04 = 0. "制程时间 ls_plpo-scrap_factor = '0.5'. "废品系数 ls_plpo-valid_from = sy-datum. "有效起始日期 ls_plpo-valid_to_date = '99991231'. "有效截止日期 ls_plpo-cost_relevant = 'X'. "与成本核算相关标志 APPEND ls_plpo TO lt_plpo. CLEAR ls_plpo. ***子工艺*** ls_plpo-activity = '0011'. ls_subplpo-activity = '0010'. ls_plpo-denominator = 1. "分母 ls_plpo-nominator = 1. "分子 ls_plpo-work_cntr = '31001'. "工作中心 ls_plpo-control_key = 'ZP10'. "控制码 ls_plpo-standard_text_key = '1061'. "标准内文码 ls_plpo-base_quantity = 20. "基础数量 ls_plpo-operation_measure_unit = 'PCS'. "单位 ls_plpo-std_value_01 = 35. "标准值1 ls_plpo-std_value_02 = 35. "标准值2 ls_plpo-std_value_03 = 0. "标准值3 ls_plpo-std_value_04 = 0. "制程时间 ls_plpo-scrap_factor = 0. "废品系数 ls_plpo-valid_from = sy-datum. "有效起始日期 ls_plpo-valid_to_date = '99991231'. "有效截止日期 ls_plpo-cost_relevant = 'X'. "与成本核算相关标志 APPEND ls_plpo TO lt_plpo. CLEAR ls_plpo. ***组件分配*** ls_bom-valid_from = sy-datum. "有效起始日期 ls_bom-valid_to_date = '99991231'. "有效截止日期 ls_bom-bom_type = ls_bom-bom_type_root = 'M'. "物料BOM STKO-STLTY ls_bom-activity = '0010'. "工艺路线工序号 ls_bom-item_id = '00000001'. "物料BOM项目 STPO-STLKN ls_bom-bom_no = ls_bom-bom_no_root = '00007871'. "物料BOM STKO-STLNR ls_bom-alternative_bom = ls_bom-alternative_bom_root = '01'. "可选BOM STKO-STLAL ls_bom-item_no = '0010'. "物料BOM项目 STPO-POSNR ls_bom-plant = '2000'. "工厂 APPEND ls_bom TO lt_bom. CLEAR ls_bom. ls_bom-valid_from = sy-datum. "有效起始日期 ls_bom-valid_to_date = '99991231'. "有效截止日期 ls_bom-bom_type = ls_bom-bom_type_root = 'M'. "物料BOM STKO-STLTY ls_bom-activity = '0010'. "工艺路线工序号 ls_bom-item_id = '00000002'. "物料BOM项目 STPO-STLKN ls_bom-bom_no = ls_bom-bom_no_root = '00007871'. "物料BOM STKO-STLNR ls_bom-alternative_bom = ls_bom-alternative_bom_root = '01'. "可选BOM STKO-STLAL ls_bom-item_no = '0020'. "物料BOM项目 STPO-POSNR ls_bom-plant = '2000'. "工厂 APPEND ls_bom TO lt_bom. CLEAR ls_bom. ls_bom-valid_from = sy-datum. "有效起始日期 ls_bom-valid_to_date = '99991231'. "有效截止日期 ls_bom-bom_type = ls_bom-bom_type_root = 'M'. "物料BOM STKO-STLTY ls_bom-activity = '0020'. "工艺路线工序号 ls_bom-item_id = '00000003'. "物料BOM项目 STPO-STLKN ls_bom-bom_no = ls_bom-bom_no_root = '00007871'. "物料BOM STKO-STLNR ls_bom-alternative_bom = ls_bom-alternative_bom_root = '01'. "可选BOM STKO-STLAL ls_bom-item_no = '0030'. "物料BOM项目 STPO-POSNR ls_bom-plant = '2000'. "工厂 ls_bom-order_lvl = '01'. "虚拟件使用 ls_bom-order_path = '01'. "虚拟件使用 ls_bom-path = '000001'. "虚拟件使用 APPEND ls_bom TO lt_bom. CLEAR ls_bom. CALL FUNCTION 'BAPI_ROUTING_CREATE' IMPORTING group = lv_plnnr TABLES task = lt_plko materialtaskallocation = lt_mapl operation = lt_plpo suboperation = lt_subplpo componentallocation = lt_bom return = lt_msg. READ TABLE lt_msg INTO ls_msg WITH KEY type = 'E'. IF sy-subrc = 0. ROLLBACK WORK. ELSE. COMMIT WORK. ENDIF. cl_demo_output=>write( lv_plnnr ). cl_demo_output=>write( lt_msg ). cl_demo_output=>display( ).
落霞与孤鹜齐飞,秋水共长天一色