EBS 销售订单行单条一次或多次发运确认API(wsh_new_delivery_actions.confirm_delivery)详解
以下是销售订单发运确认的代码,主要解释API接口:
/*==================================================
Procedure Name :
ship_confirm
Description:
销售订单发运确认
Argument:
History:
1.00 2021-02-25 chenyang Creation
==================================================*/
PROCEDURE ship_confirm(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false
,p_commit IN VARCHAR2 DEFAULT fnd_api.g_false
,p_header_id IN NUMBER
,p_bill_date IN DATE
,p_item_move_order_num IN VARCHAR2
,p_item_code IN VARCHAR2
,x_return_status OUT NOCOPY VARCHAR2
,x_msg_count OUT NOCOPY NUMBER
,x_msg_data OUT NOCOPY VARCHAR2) IS
l_api_name CONSTANT VARCHAR2(30) := 'order_pick';
l_savepoint_name CONSTANT VARCHAR2(30) := '';
l_request_id NUMBER;
l_del_rows wsh_util_core.id_tab_type;
l_item_move_order_num VARCHAR2(80) DEFAULT p_item_move_order_num;
l_count NUMBER DEFAULT 0;
BEGIN
x_return_status := cux_api.start_activity(p_pkg_name => g_pkg_name
,p_api_name => l_api_name
,p_savepoint_name => l_savepoint_name
,p_init_msg_list => p_init_msg_list);
raise_exception(x_return_status);
--判断是否已经发放过,如果发放过,p_item_move_order_num会为空
IF l_item_move_order_num IS NULL THEN
BEGIN
SELECT MAX(mth.REQUEST_NUMBER)
INTO l_item_move_order_num
FROM MTL_TXN_REQUEST_HEADERS mth,
MTL_TXN_REQUEST_LINES mtl,
oe_order_lines_all ool
WHERE 1=1
AND mth.HEADER_ID = mtl.HEADER_ID
AND mtl.TXN_SOURCE_LINE_ID = ool.LINE_ID
AND mtl.LINE_STATUS = 5--已关闭
AND mth.MOVE_ORDER_TYPE = 3 --挑库通知
AND ool.ORDERED_ITEM = p_item_code
AND ool.HEADER_ID = p_header_id;
EXCEPTION
WHEN OTHERS THEN
l_item_move_order_num := NULL;
END;
END IF;
SELECT wda.delivery_id
INTO l_del_rows(1)
FROM wsh_delivery_details wdd
,wsh_delivery_assignments wda
,mtl_system_items_b msi
WHERE 1=1
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wdd.INVENTORY_ITEM_ID = msi.INVENTORY_ITEM_ID
AND wdd.ORGANIZATION_ID = msi.ORGANIZATION_ID
AND wdd.source_header_id = p_header_id
AND wdd.BATCH_ID = l_item_move_order_num
AND msi.SEGMENT1 = p_item_code
AND wdd.RELEASED_STATUS = 'Y'
AND rownum = 1;
wsh_new_delivery_actions.confirm_delivery(p_del_rows => l_del_rows
,p_action_flag => 'S'
,p_intransit_flag => 'Y'
,p_close_flag => 'Y'
,p_stage_del_flag => NULL
,p_report_set_id => NULL
,p_ship_method => NULL
,p_actual_dep_date => p_bill_date
,p_bol_flag => NULL
,p_mc_bol_flag => 'N'
,p_defer_interface_flag => 'Y'
,x_return_status => x_return_status);
raise_exception(x_return_status);
--连接行程停靠站 - SRS
/*l_request_id := fnd_request.submit_request('WSH'
,'WSHINTERFACES'
,''
,to_char(SYSDATE
,'YYYY/MM/DD HH24:MI:SS')
,FALSE
,'ALL'
,NULL
,l_del_rows(1)
,0
,chr(0));*/
l_request_id := fnd_request.submit_request('WSH'
,'WSHINTERFACES'
,''
,to_char(SYSDATE
,'YYYY/MM/DD HH24:MI:SS')
,FALSE
,'ALL'
,NULL
,NULL
,0
,NULL
,NULL
,NULL
,1
,1);
IF l_request_id = 0 THEN
x_return_status := fnd_api.g_ret_sts_error;
raise_exception(x_return_status);
END IF;
x_return_status := cux_api.end_activity(p_pkg_name => g_pkg_name
,p_api_name => l_api_name
,p_commit => p_commit
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data);
raise_exception(x_return_status);
EXCEPTION
WHEN fnd_api.g_exc_error THEN
x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name
,p_api_name => l_api_name
,p_savepoint_name => l_savepoint_name
,p_exc_name => cux_api.g_exc_name_error
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data);
WHEN fnd_api.g_exc_unexpected_error THEN
x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name
,p_api_name => l_api_name
,p_savepoint_name => l_savepoint_name
,p_exc_name => cux_api.g_exc_name_unexp
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data);
WHEN OTHERS THEN
x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name
,p_api_name => l_api_name
,p_savepoint_name => l_savepoint_name
,p_exc_name => cux_api.g_exc_name_others
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data);
END ship_confirm;
以下是解释:
wsh_new_delivery_actions.confirm_delivery(p_del_rows => l_del_rows
,p_action_flag => ‘S’
–S Ship Entered Quantities, Ship Unspecified
–B Ship Entered Quantities, Backorder Unspecified
–T Ship Entered Quantities, Stage Unspecified
–A Ship All
–C Completely Backordered
,p_intransit_flag => ‘Y’ --‘Y’ for autocreate_trip closes first stop
,p_close_flag => ‘Y’ --‘Y’ closes autocreated trip and stops
,p_stage_del_flag => NULL --‘Y’ creates a new delivery for the staged lines
,p_report_set_id => NULL ----report set for delivery
,p_ship_method => NULL ----ship method for autocreated trip
,p_actual_dep_date => p_bill_date ----actual departure date for pickup stop on autocreated trip
,p_bol_flag => NULL
,p_mc_bol_flag => ‘N’
,p_defer_interface_flag => ‘Y’—‘Y’ skip concurrent program submission,bug 1578251
,x_return_status => x_return_status);