今天我们来学习生产订单下达的标准BAPI函数BAPI_PRODORD_RELEASE,希望您喜欢。
一首打油诗,提醒自己是个有罪的胆怯的人。
前有丰县铁链女,今有唐山霸王龙。
事不关己人一多,到头终是一场空!
BAPI_PRODORD_RELEASE对应的前台操作tcode是CO02,Functions==>Release.
函数的组成参数为:
参数名称 | 关联类型 | 缺省值 | 可选的 | 值传递 | 说明 |
RELEASE_CONTROL | BAPI_ORDER_FUNC_CNTRL-RELEASE_CNTRL | ‘1’ | 否 | 是 | Release control order. 批准控制订单
BAPI_ORDER_FUNC_CNTRL: 执行订单函数的输入参数 (关联表见下文) |
WORK_PROCESS_GROUP | BAPI_ORDER_CNTRL_PARAM-WORK_PROC_GROUP | ‘COWORK_BAPI’ | 是 | 是 | Logon/Server Group Name。
登录/服务器组名称 BAPI_ORDER_CNTRL_PARAM:并行处理的订单控制结构 (关联表见下文) |
WORK_PROCESS_MAX | BAPI_ORDER_CNTRL_PARAM-WORK_PROC_MAX | 99 | 是 | 是 | Maximum number of work processes that can be used。
可以使用的最大工作进程数 BAPI_ORDER_CNTRL_PARAM:并行处理的订单控制结构 (关联表见下文) |
执行订单函数的输入参数BAPI_ORDER_FUNC_CNTRL
字段 | 数据元素 | 数据类型 | 长度 | 小数位 | 短文本 |
STATUS_PROFILE | CO_STSMA_HDR | CHAR | 8 | 0 | 指定到订单抬头的状态参数文件 |
STATUS | P_TXT04 | CHAR | 4 | 0 | 对象状态 |
RELEASE_CNTRL | CO_RELEASE_C | CHAR | 1 | 0 | 批准控制订单 |
RESET_AVAIL_DATA | AV_CLEAR | CHAR | 1 | 0 | 重置有效数据 |
SCOPE_AVAIL | COWB_AVAIL_C | CHAR | 1 | 0 | 执行可用性检查(会话) |
FIX_PLANNED_ORDERS | AV_FIX_PL | CHAR | 1 | 0 | 固定订单计划 |
SCOPE_COMPL_TECH | CO_TECO_EXPL | CHAR | 1 | 0 | 技术性完成:订单网络展开 |
SCHED_TYPE | TERMKZ | CHAR | 1 | 0 | 计划类型 |
FWD_DLV_ORIGIN | CO_SCHED_ORI | CHAR | 1 | 0 | 计划日期来源 |
FWD_DLV_DATE | CO_GLTRP | DATS | 8 | 0 | 基本完成日期 |
FWD_DLV_TIME | CO_GLUZP | TIMS | 6 | 0 | 基本完成(时间) |
FWD_DLV_OFFSET | CO_OFFSET | QUAN | 5 | 0 | 日期变更 |
FWD_DLV_UNIT | MAIZE | UNIT | 3 | 0 | 时间单位 |
FWD_BEG_ORIGIN | CO_SCHED_ORI | CHAR | 1 | 0 | 计划日期来源 |
FWD_BEG_DATE | CO_GSTRP | DATS | 8 | 0 | 基本开始日期 |
FWD_BEG_TIME | CO_GSUZP | TIMS | 6 | 0 | 基本开始(时间) |
FWD_BEG_OFFSET | CO_OFFSET | QUAN | 5 | 0 | 日期变更 |
FWD_BEG_UNIT | MAIZE | UNIT | 3 | 0 | 时间单位 |
BCK_DLV_ORIGIN | CO_SCHED_ORI | CHAR | 1 | 0 | 计划日期来源 |
BCK_DLV_DATE | CO_GLTRP | DATS | 8 | 0 | 基本完成日期 |
BCK_DLV_TIME | CO_GLUZP | TIMS | 6 | 0 | 基本完成(时间) |
BCK_DLV_OFFSET | CO_OFFSET | QUAN | 5 | 0 | 日期变更 |
BCK_DLV_UNIT | MAIZE | UNIT | 3 | 0 | 时间单位 |
BCK_BEG_ORIGIN | CO_SCHED_ORI | CHAR | 1 | 0 | 计划日期来源 |
BCK_BEG_DATE | CO_GSTRP | DATS | 8 | 0 | 基本开始日期 |
BCK_BEG_TIME | CO_GSUZP | TIMS | 6 | 0 | 基本开始(时间) |
BCK_BEG_OFFSET | CO_OFFSET | QUAN | 5 | 0 | 日期变更 |
BCK_BEG_UNIT | MAIZE | UNIT | 3 | 0 | 时间单位 |
COLLECTIVE_ORDER | FLG_MSTUF | CHAR | 1 | 0 | 显示整个汇总订单 |
RELEASE_CNTRL_PI | CO_RELEASE_C | CHAR | 1 | 0 | 批准控制:订单 – 流程订单 |
RELEASE_CNTRL_OPER | CO_RELEASE_C | CHAR | 1 | 0 | 批准控制工序 |
RELEASE_CNTRL_OPER_PI | CO_RELEASE_C | CHAR | 1 | 0 | 批准控制:工序 – 流程订单 |
Return 返回的参数:
参数名称 | 关联类型 | 可选的 | 说明 |
ORDERS | BAPI_ORDER_KEY | 否 | Order Numbers
BAPI_ORDER_KEY:订单编号 (关联表见下文) |
DETAIL_RETURN | BAPI_ORDER_RETURN | 是 | Return Structure for Order BAPIs
BAPI_ORDER_RETURN:订单 BAPI 的退货结构 (关联表见下文) |
APPLICATION_LOG | BAPI_ORDER_APPLICATION_LOG | 是 | ApplicationLog Handle
BAPI_ORDER_APPLICATION_LOG:订单 BAPI 的应用日志处理 (关联表见下文) |
Situation场景:
创建生产订单BAPI_PRODORD_CREATE并下达BAPI_PRODORD_RELEASE
注意事项:生产部门反应创建工单非常慢,是因为SAP创建生产订单时会检查物料,会花费大量时间,
其次创建生产订单一次只能根据销售订单一个行项目创建,所以完成一个销售订单的排产就需要更长的时间。
封装好的函数FUNCTION Module代码:
FUNCTION zppfm007.
*”———————————————————————-
*”*”本地接口:
*” IMPORTING
*” VALUE(I_HEADER) TYPE ZPPS001 OPTIONAL
*” EXPORTING
*” VALUE(E_MESSAGE) TYPE ZOTS001
*” VALUE(E_AUFNR) TYPE AUFNR
*” TABLES
*” T_ITEM STRUCTURE ZPPS003
*”———————————————————————-
DATA:ls_afpo TYPE afpo.
DATA:ls_message TYPE zots001.
DATA:ls_return TYPE bapiret2.
DATA:ls_orderdata TYPE bapi_pp_order_create.
DATA:lv_objnr TYPE jsto-objnr.
DATA:lv_bsark_e TYPE vbkd-bsark_e.
DATA:lv_order_number TYPE aufnr.
DATA:lt_status TYPE TABLE OF jstat WITH HEADER LINE,
lt_orders TYPE TABLE OF bapi_order_key WITH HEADER LINE,
lt_detail_return TYPE TABLE OF bapi_order_return WITH HEADER LINE.
FIELD-SYMBOLS:<fs_item> TYPE zpps003.
PERFORM frm_inputsap_matnr CHANGING i_header-matnr.
PERFORM frm_inputsap_vbeln CHANGING i_header-sales_order.
SELECT SINGLE bsark_e INTO lv_bsark_e FROM vbkd WHERE vbeln = i_header-sales_order.
CASE lv_bsark_e.
WHEN ‘A001’.
i_header-order_type = ‘SG01’.
WHEN ‘A005’.
i_header-order_type = ‘SG03’.
WHEN ‘A002’.
i_header-order_type = ‘SG05’.
WHEN ‘A007’.
i_header-order_type = ‘SG07’.
WHEN ‘A006’.
i_header-order_type = ‘SG09’.
WHEN ‘A012’.
i_header-order_type = ‘SG11’.
WHEN ‘A009’.
i_header-order_type = ‘SG13’.
WHEN ‘A011’.
i_header-order_type = ‘SG15’.
WHEN ‘A010’.
i_header-order_type = ‘SG17’.
WHEN ‘A013’.
i_header-order_type = ‘SG19’.
WHEN ‘A003’.
i_header-order_type = ‘SG21’.
WHEN ‘A004’.
i_header-order_type = ‘SG23’.
ENDCASE.
ls_orderdata-material = i_header-matnr.
ls_orderdata-order_type = i_header-order_type.
ls_orderdata-plant = i_header-plant.
ls_orderdata-planning_plant = i_header-plant.
IF i_header-basic_start_date IS NOT INITIAL .
CONCATENATE i_header-basic_start_date+0(4) i_header-basic_start_date+5(2) i_header-basic_start_date+8(2) INTO ls_orderdata-basic_start_date.
ELSE .
ls_orderdata-basic_start_date = sy-datum.
ENDIF.
IF i_header-basic_end_date IS NOT INITIAL .
CONCATENATE i_header-basic_end_date+0(4) i_header-basic_end_date+5(2) i_header-basic_end_date+8(2) INTO ls_orderdata-basic_end_date.
ELSE .
ls_orderdata-basic_end_date = sy-datum .
ENDIF .
ls_orderdata-quantity = i_header-quantity.
ls_orderdata-sales_order = i_header-sales_order.
ls_orderdata-sales_order_item = i_header-sales_order_item.
ls_orderdata-storage_location = i_header-storage_location.
ls_orderdata-unloading_point = i_header-unloading_point.
*–>生产订单创建Create Production Order.
CALL FUNCTION ‘BAPI_PRODORD_CREATE’
EXPORTING
orderdata = ls_orderdata
IMPORTING
return = ls_return
order_number = lv_order_number.
IF lv_order_number IS INITIAL.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’ .
e_message-type = ‘E’.
e_message-message = ls_return-message.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
*–>修改生产订单组建
IF t_item[] IS NOT INITIAL.
LOOP AT t_item ASSIGNING <fs_item>.
PERFORM frm_inputsap_matnr CHANGING <fs_item>-matnr.
ENDLOOP.
WAIT UP TO 1 SECONDS.
CALL FUNCTION ‘ZPPFM010’
EXPORTING
i_aufnr = lv_order_number
IMPORTING
e_message = ls_message
TABLES
t_item = t_item[].
IF e_message-type = ‘E’.
MOVE-CORRESPONDING ls_message TO e_message.
e_aufnr = lv_order_number.
EXIT.
ENDIF.
ENDIF.
*–>生产订单下达Realease Production.
WAIT UP TO 1 SECONDS.
CLEAR:lt_orders.
lt_orders-order_number = lv_order_number.
APPEND lt_orders .
CALL FUNCTION ‘BAPI_PRODORD_RELEASE’
TABLES
detail_return = lt_detail_return
orders = lt_orders[].
LOOP AT lt_detail_return WHERE type CA ‘AEX’.
IF e_message-message IS INITIAL.
e_message-message = lt_detail_return-message.
ELSE.
e_message-message = e_message-message && ‘/’ && lt_detail_return-message.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’ .
e_message-type = ‘E’.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
e_message-type = ‘S’.
e_message-message = ‘生产订单创建并下达成功’.
e_aufnr = lv_order_number.
ENDIF.
ENDIF.
ENDFUNCTION.
FORM frm_inputsap_matnr CHANGING pc_matnr TYPE char18.
CALL FUNCTION ‘CONVERSION_EXIT_MATN1_INPUT’
EXPORTING
input = pc_matnr
IMPORTING
output = pc_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
ENDFORM.
FORM frm_inputsap_vbeln CHANGING pc_vbeln TYPE char10.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input = pc_vbeln
IMPORTING
output = pc_vbeln.
ENDFORM.
相关联配置点:
TCODE事务代码OBJK关闭物料检查,在物料可用性中,勾选【没检查】checkbox
TCODE事务代码OPKP创建生产订单并一步执行,在自动操作中,勾选【下达】checkbox
我的微信公众号【 hot583 】 或者在这个链接联系我
本文链接 : http://www.hot583.com/2022/06/18/bapi_prodord_release/
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
微信原文《全文完》