通常情况下,一般在处理物料搬运单界面要做2个操作:1分配物料搬运单行[Allocate;2处理物料搬运单行[Tansact]。
图17
本节以下内容介绍如何使用API处理物料搬运单。
Step 1 : 分配物料搬运单行;
Step 2 : 处理物料搬运单行;
假如物料搬运单行的Request数量为20,但是订单只保留了19个,可以修改物料搬运单行的Request数量为19吗?答案是肯定的。
图18
在plsql Developer 中执行脚本Process_Move_Order_Line.sql:
DECLARE
p_api_version NUMBER;
p_init_msg_list VARCHAR2(15);
x_return_status VARCHAR2(1);
p_commit VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
v_Trolin_Tbl_Type INV_Move_Order_PUB.Trolin_Tbl_Type;
v_Trolin_Tbl_Type1 INV_Move_Order_PUB.Trolin_Tbl_Type;
v_Trolin_Tbl_Type2 INV_Move_Order_PUB.Trolin_Tbl_Type;
BEGIN
fnd_global.APPS_Initialize(3334, 50671, 20003);
v_Trolin_Tbl_Type := INV_TROLIN_UTIL.Query_Rows(p_line_id => 4252170); --Move Order Line ID
v_trolin_tbl_type(1).db_flag := FND_API.G_TRUE;
-- 下面可以把要UPDATE的项列出来
v_trolin_tbl_type(1).operation := 'UPDATE';
v_trolin_tbl_type(1).quantity := 19;
v_trolin_tbl_type(1).primary_quantity := 19;
INV_Move_Order_PUB.Process_Move_Order_Line(p_api_version_number => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_return_values => FND_API.G_TRUE,
p_commit => FND_API.G_TRUE,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_trolin_tbl => v_Trolin_Tbl_Type,
p_trolin_old_tbl => v_Trolin_Tbl_Type1,
x_trolin_tbl => v_Trolin_Tbl_Type2);
IF x_return_status NOT IN (fnd_api.g_ret_sts_success, 'W') THEN
if (nvl(x_msg_count, 0) = 0) then
dbms_output.put_line('no message return');
else
FOR i IN 1 .. x_msg_count LOOP
dbms_output.put_line(FND_MSG_PUB.get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
end if;
END IF;
END;
图19
此处API效果等同于点击图17’Allocate’按钮,进入物料分配界面操作。
在plsql Developer 中执行脚本Pick_Release.sql:
DECLARE
p_api_version NUMBER;
p_init_msg_list VARCHAR2(15);
x_return_status VARCHAR2(1);
p_commit VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
v_mo_line_tbl INV_Move_Order_PUB.TROLIN_TBL_TYPE;
v_pick_release_status INV_Pick_Release_PUB.INV_Release_Status_Tbl_Type;
BEGIN
fnd_global.APPS_Initialize(3334, 50671, 20003);
v_mo_line_tbl := INV_TROLIN_UTIL.query_rows(p_line_id => 4252170); --Move Order Line ID
INV_Pick_Release_PUB.Pick_Release(p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_mo_line_tbl => v_mo_line_tbl,
p_auto_pick_confirm => 2, --1 (yes) or 2 (no) ,
p_grouping_rule_id => NULL,
p_allow_partial_pick => fnd_api.g_true,
x_pick_release_status => v_pick_release_status,
p_plan_tasks => FALSE);
dbms_output.put_line(x_return_status);
IF x_return_status NOT IN (fnd_api.g_ret_sts_success, 'W') THEN
IF (nvl(x_msg_count, 0) = 0) THEN
dbms_output.put_line('no message return');
ELSE
FOR i IN 1 .. x_msg_count LOOP
dbms_output.put_line(oe_msg_pub.get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
END IF;
END IF;
END;
图20
可以看到物料搬运单行已作Allocate,下一步可以做Tansact处理,在此界面可查看分配的详细情况,如图23所是,分配的物料正是前面保留的物料:
图21
此处API效果等同于点击图20’Transact’按钮。
在plsql Developer 中执行脚本Update_Reservation.sql:
DECLARE
v_mmtt_tbl INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
v_mold_tbl INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type ;
out_trolin_tbl INV_Move_Order_PUB.Trolin_Tbl_Type;
v_trolin_tbl INV_Move_Order_PUB.TROLIN_TBL_TYPE ;
v_return_status VARCHAR2(10);
v_msg_count NUMBER;
v_msg_data VARCHAR2(2000);
BEGIN
fnd_global.APPS_Initialize(3334, 50671, 20003);
v_trolin_tbl := INV_TROLIN_UTIL.query_rows(p_line_id => 4252170); --Move Order Line ID
/* TRANSACTION_MODE 1 Online processing 2 Concurrent processing 3 Background processing */
INV_Pick_Wave_Pick_Confirm_PUB.Pick_Confirm(
p_api_version_number => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_FALSE,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
p_move_order_type => 3,
p_transaction_mode => 1,
p_trolin_tbl => v_trolin_tbl,
p_mold_tbl => v_mold_tbl,
x_mmtt_tbl => v_mmtt_tbl,
x_trolin_tbl => out_trolin_tbl);
dbms_output.put_line('Return status=' || SUBSTR(v_return_status, 1, 255));
dbms_output.put_line('count =' || TO_CHAR(v_msg_count));
dbms_output.put_line('Msg Data =' || SUBSTR(v_msg_data, 1, 255));
IF v_msg_count > 1 THEN
FOR I IN 1 .. v_msg_count LOOP
dbms_output.put_line(
'I.' || SUBSTR(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),
1, 255));
END LOOP;
END IF;
IF v_return_status != APPS.FND_API.G_RET_STS_SUCCESS then
dbms_output.put_line('failed. printing error msg...');
dbms_output.put_line(APPS.FND_MSG_PUB.Get(p_msg_index => APPS.FND_MSG_PUB.G_LAST,
p_encoded => APPS.FND_API.G_FALSE));
ELSE
COMMIT;
END IF;
END;
在处理物料搬运单界面查找Move Order 1873937,发现已经找不到了,因为该Move Order所有的行(本例只有1行)已被全部处理了。
图22
查看此时的订单行状态已经变成部分挑库(挑库数量为19):
图23
本章主要介绍了利用API模拟各种在处理物料搬运单界面的操作。
注意:各个API的P_COMMIT参数,请根据业务的需要在恰当的时机提交。