OE_Order_PUB.Process_Order
问题:数据库中因为有OU屏蔽,所以更新、导入失败
解决方法:
--设置OU,显示OU屏蔽的数据
通过mo_global.set_policy_context('S',81); 设置单OU,推荐使用这种方式(没有任何前提,直接将当前环境初始化为ORG_ID=81的环境)。
通过 mo_global.init('ONT'); 将OM应用能访问的组织都初始化访问列表中(前提是使用的应用已经注册了多组织访问)
declare
l_header_rec oe_order_pub.header_rec_type;
l_line_tbl oe_order_pub.line_tbl_type;
l_line_tb2 oe_order_pub.line_tbl_type;
l_action_request_tbl oe_order_pub.request_tbl_type;
l_return_status varchar2(1000);
l_msg_count number;
l_msg_data varchar2(1000);
v_line_number varchar2(1000);
l_index varchar2(1000);
x_header_val_rec oe_order_pub.header_val_rec_type;
x_header_adj_tbl oe_order_pub.header_adj_tbl_type;
x_header_adj_val_tbl oe_order_pub.header_adj_val_tbl_type;
x_header_price_att_tbl oe_order_pub.header_price_att_tbl_type;
x_header_adj_att_tbl oe_order_pub.header_adj_att_tbl_type;
x_header_adj_assoc_tbl oe_order_pub.header_adj_assoc_tbl_type;
x_header_scredit_tbl oe_order_pub.header_scredit_tbl_type;
x_header_scredit_val_tbl oe_order_pub.header_scredit_val_tbl_type;
x_line_val_tbl oe_order_pub.line_val_tbl_type;
x_line_adj_tbl oe_order_pub.line_adj_tbl_type;
x_line_adj_val_tbl oe_order_pub.line_adj_val_tbl_type;
x_line_price_att_tbl oe_order_pub.line_price_att_tbl_type;
x_line_adj_att_tbl oe_order_pub.line_adj_att_tbl_type;
x_line_adj_assoc_tbl oe_order_pub.line_adj_assoc_tbl_type;
x_line_scredit_tbl oe_order_pub.line_scredit_tbl_type;
x_line_scredit_val_tbl oe_order_pub.line_scredit_val_tbl_type;
x_lot_serial_tbl oe_order_pub.lot_serial_tbl_type;
x_lot_serial_val_tbl oe_order_pub.lot_serial_val_tbl_type;
l_cust_po_number VARCHAR2(50);
l_promise_date DATE;
l_shipping_instructions VARCHAR2(240);
l_ship_to_org_id NUMBER;
v_line_id NUMBER;
begin
BEGIN
SELECT ool.line_id,ool.cust_po_number,ool.promise_date,ool.shipping_instructions,ool.ship_to_org_id
INTO v_line_id,l_cust_po_number,l_promise_date,l_shipping_instructions,l_ship_to_org_id
FROM OE_ORDER_HEADERS_all OOH,
OE_ORDER_LINES_all ool
WHERE ooh.header_id = ool.header_id
and ooh.order_number = trim('168102')
and ool.line_number = substr(trim('1.1'), 1, instr(trim('1.1'),'.',1) - 1)
and ool.shipment_number = substr(trim('1.1'), instr(trim('1.1'),'.',1) + 1) ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
raise_application_error(-20000, '订单行不存在!请检查订单编号和行号');
END;
fnd_global.apps_initialize(user_id => 1334 --FND_GLOBAL.USER_ID -- User name:hz00100
,
resp_id => 21623--FND_GLOBAL.RESP_ID-- Order Management Super User, Vision UK
,
resp_appl_id => 660--FND_GLOBAL.RESP_APPL_ID --Order Management , ONT
);
mo_global.init('ONT'); --important 数据库中执行必须init OU,若是前台调用就不用加这一句
oe_msg_pub.initialize;
oe_debug_pub.initialize;
oe_debug_pub.debug_on;
oe_debug_pub.setdebuglevel(5);
--mo_global.set_policy_context('S', 81);
-- l_header_rec := oe_order_pub.g_miss_header_rec;
--l_header_rec.header_id := 370752; --in_header_rec.header_id;
--l_header_rec.operation := oe_globals.g_opr_update;
l_line_tbl(1) := oe_order_pub.g_miss_line_rec;
l_line_tbl(1).line_id := 925743; --1136;--in_line_tbl(i).line_id;
l_line_tbl(1).operation := oe_globals.g_opr_update;
l_line_tbl (1).cust_po_number := '123456';
-- l_line_tbl(1).promise_date := to_date('2014-04-26','yyyy-mm-dd');
-- l_line_tbl(1).shipping_instructions := '';
--l_line_tbl(1).ship_to_org_id := 1908;
dbms_output.put_line('l_line_tbl:' || l_line_tbl(1).open_flag);
oe_order_pub.process_order(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_false,
p_return_values => fnd_api.g_false,
p_action_commit => fnd_api.g_false,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_header_rec => l_header_rec,
p_line_tbl => l_line_tbl,
p_action_request_tbl => l_action_request_tbl,
x_header_rec => l_header_rec,
x_header_val_rec => x_header_val_rec,
x_header_adj_tbl => x_header_adj_tbl,
x_header_adj_val_tbl => x_header_adj_val_tbl,
x_header_price_att_tbl => x_header_price_att_tbl,
x_header_adj_att_tbl => x_header_adj_att_tbl,
x_header_adj_assoc_tbl => x_header_adj_assoc_tbl,
x_header_scredit_tbl => x_header_scredit_tbl,
x_header_scredit_val_tbl => x_header_scredit_val_tbl,
x_line_tbl => l_line_tb2,
x_line_val_tbl => x_line_val_tbl,
x_line_adj_tbl => x_line_adj_tbl,
x_line_adj_val_tbl => x_line_adj_val_tbl,
x_line_price_att_tbl => x_line_price_att_tbl,
x_line_adj_att_tbl => x_line_adj_att_tbl,
x_line_adj_assoc_tbl => x_line_adj_assoc_tbl,
x_line_scredit_tbl => x_line_scredit_tbl,
x_line_scredit_val_tbl => x_line_scredit_val_tbl,
x_lot_serial_tbl => x_lot_serial_tbl,
x_lot_serial_val_tbl => x_lot_serial_val_tbl,
x_action_request_tbl => l_action_request_tbl);
dbms_output.put_line('l_index:' || l_index || 'l_msg_data1:' ||
l_msg_data);
if l_msg_count > 0 then
for l_index in 1 .. l_msg_count
loop
l_msg_data := oe_msg_pub.get(p_msg_index => l_index,
p_encoded => 'F');
end loop;
end if;
dbms_output.put_line('l_index:' || l_index || 'l_msg_data:' ||
l_msg_data);
if l_return_status = fnd_api.g_ret_sts_success then
dbms_output.put_line('OK');
commit;
else
dbms_output.put_line('Failed');
rollback;
end if;
commit;
end;