销售订单BOM组件分配(CP_BD_DIRECT_INPUT_PLAN_EXT)
转自:http://www.baidusap.com/abap/function/520
1, 销售订单BOM组件分配前台操作
Tcode:CA02,输入物料,工厂,销售订单以及行项目,回车进入下一屏幕
点击组件分配按钮
选中要分配的行,点击 new assignment按钮,输入operation
保存。
2, CP_BD_DIRECT_INPUT_PLAN_EXT参数介绍
可以通过调用函数CP_BD_DIRECT_INPUT_PLAN_EXT实现销售订单BOM的组件分配,函数参数如下:
1, 输入参数
RC271_EX_IMP:
下图 routing head details中可以找到group和group counter
RC27M_EX:
SAVE_DI_IMP:
2, 组件分配相关tables参数
注意:BOMAT字段-->当bom header material(截图中编号18处)是phantom件(截图中编号19处勾上),需要向父层上找,一直找到不是phantom件的父层物料为止,
3, 例子程序
给销售订单BOM 940602-01的10行组件57432049分配0030的operation
程序如下:
REPORT ztest_component_allocate. DATA:l_rc271_ex_imp TYPE rc271_ex, l_rc27m_ex_imp TYPE rc27m_ex, l_save_di_imp TYPE save_di, lit_err TYPE STANDARD TABLE OF cmfmsg, lwa_err TYPE cmfmsg, lit_err_di TYPE STANDARD TABLE OF error_di, lwa_err_di TYPE error_di, lit_plmz TYPE STANDARD TABLE OF plmz_di_ex, lwa_plmz TYPE plmz_di_ex, lit_rcuob2 TYPE STANDARD TABLE OF rcuob2, lit_rcuob1_ex TYPE STANDARD TABLE OF rcuob1_ex, lit_plko TYPE STANDARD TABLE OF plko_di_ex, lit_mapl TYPE STANDARD TABLE OF mapl_di_ex, lit_plpo TYPE STANDARD TABLE OF plpo_di_ex, lit_plfl TYPE STANDARD TABLE OF plfl_di_ex, lit_plfh TYPE STANDARD TABLE OF plfh_di_ex, lit_text TYPE STANDARD TABLE OF txt_obj_ex, lit_text_di_tab TYPE STANDARD TABLE OF tline, lit_obj_null_field TYPE STANDARD TABLE OF obj_nfield. * 相关notes:Notes 1944995 l_rc271_ex_imp-tcode = 'CA02'. CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL' EXPORTING date_internal = sy-datum IMPORTING date_external = l_rc271_ex_imp-sttag EXCEPTIONS date_internal_is_invalid = 1 OTHERS = 2. l_rc271_ex_imp-werks = '8800'. l_rc271_ex_imp-plnnr = '50001594'. l_rc271_ex_imp-plnal = '01'. l_rc271_ex_imp-vbeln = '0690000006'. l_rc271_ex_imp-posnr = '000100'. l_rc27m_ex_imp-werks = '8800'. CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = '940602-01' IMPORTING output = l_rc27m_ex_imp-matnr EXCEPTIONS length_error = 1 OTHERS = 2. l_save_di_imp-save_error = 'X'. l_save_di_imp-syn_save = 'X'. REFRESH:lit_plmz. CLEAR:lwa_plmz. lwa_plmz-acttyp = 'H'. "create lwa_plmz-plnal = '01'. "Group Counter lwa_plmz-plnfl = '000000'. "Sequence lwa_plmz-plnkn = '00000000'. "Node number (batch input) lwa_plmz-vornr = '0030'. "Operation/Activity Number lwa_plmz-stlty = 'K'. "BOM category:order bom lwa_plmz-stlnr = '00001094'. "Bill of material lwa_plmz-stlal = '01'. "Alternative BOM lwa_plmz-stlkn = '00000001'. "Node number (batch input) lwa_plmz-posnr = '0010'. "BOM Item Number * "Material Number components CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = '57432049' IMPORTING output = lwa_plmz-matnr EXCEPTIONS length_error = 1 OTHERS = 2. lwa_plmz-werks = '8800'. "plant lwa_plmz-stlst = '1'. "Order level lwa_plmz-stlwg = '1'. "Order path CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = '940602-01' IMPORTING output = lwa_plmz-bomat EXCEPTIONS length_error = 1 OTHERS = 2. * stlnr_w stlal_w stlty_w是上层物料BOM和Alternative BOM, * 如果上层物料是Phantom件,接着向上找,一直找到非Phantom件 lwa_plmz-stlnr_w = '00001093'. " lwa_plmz-stlal_w = '01'. " lwa_plmz-stlty_w = 'K'. " lwa_plmz-stlan = '1'. "BOM Usage APPEND lwa_plmz TO lit_plmz. REFRESH:lit_err, lit_obj_null_field. CALL FUNCTION 'CP_BD_DIRECT_INPUT_PLAN_EXT' EXPORTING rc271_ex_imp = l_rc271_ex_imp rc27m_ex_imp = l_rc27m_ex_imp save_di_imp = l_save_di_imp TABLES "MAPL_DI_EX_TAB plko_di_ex_tab = lit_plko[] mapl_di_ex_tab = lit_mapl[] plpo_di_ex_tab = lit_plpo[] plfl_di_ex_tab = lit_plfl[] plfh_di_ex_tab = lit_plfh[] text_obj_di_ex_tab = lit_text[] text_di_tab = lit_text_di_tab[] knowl_alloc_di_ex_tab = lit_rcuob2[] knowl_alloc_obj_di_ex_tab = lit_rcuob1_ex[] plmz_di_ex_tab = lit_plmz[] obj_null_field_tab = lit_obj_null_field[] error_plan_di_tab = lit_err_di[] error_plan_tab = lit_err[]. LOOP AT lit_err INTO lwa_err. "error handling ENDLOOP.
程序运行结果,30的operation分配成功
以上。
本人常年接收SAP运维和远程项目,ECC,S/4HANA,CRM,WDA.
远程人天可谈,终身售后,有活请联系V信:18925782767(问问题免费,欢迎交流!)
!!请关注本人技术分享公众号:SAP翔子(可扫头像二维码)
每天分享新知识,博客文章也会陆续整理并迁移至公众号,与您一起共同学习