EBS OM 新增订单API--Oe_Order_Pub.Process_Order

DECLARE
l_Header_Rec Oe_Order_Pub.Header_Rec_Type;
l_Line_Tbl Oe_Order_Pub.Line_Tbl_Type;
--l_header_adj_tbl OE_ORDER_PUB.Header_Adj_Tbl_Type;
--l_line_adj_tbl OE_ORDER_PUB.line_adj_tbl_Type;
--l_header_scredit_tbl OE_ORDER_PUB.Header_Scredit_Tbl_Type;
--l_line_scredit_tbl OE_ORDER_PUB.Line_Scredit_Tbl_Type;
l_Action_Request_Tbl Oe_Order_Pub.Request_Tbl_Type;

l_Return_Status VARCHAR2(1);
l_Msg_Count NUMBER;
l_Msg_Data 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;

x_Debug_File VARCHAR2(100);
l_Line_Tbl_Index NUMBER;
l_Msg_Index_Out NUMBER(10);

BEGIN
Dbms_Output.Enable(1000000);
Fnd_Global.Apps_Initialize(2241
,51729
,660); -- pass in user_id,responsibility_id, and application_id
Oe_Msg_Pub.Initialize; --初始化
Oe_Debug_Pub.Initialize; --Debug初始化,清除debug cache
x_Debug_File := Oe_Debug_Pub.Set_Debug_Mode('FILE');
Oe_Debug_Pub.Setdebuglevel(5); -- Use 5 for the most debuging output, I warn you its a lot of data 设置Debug级别
--DBMS_APPLICATION_INFO.set_client_info(122);--org_id
Dbms_Output.Put_Line('START OF NEW DEBUG');

/* The header record is initialized to missing as there would be no header_id exists for the record.
Once the header_id is generated by the API, the l_header_rec will take the value of the header_id */
l_Header_Rec := Oe_Order_Pub.g_Miss_Header_Rec;
-- Header Attributes
l_Header_Rec.Order_Type_Id := 1204; --10-标准订单
l_Header_Rec.Sold_To_Org_Id := 155205; --关联客户编号
--l_header_rec.ship_to_org_id := 23128;--关联收货地点
l_header_rec.cust_po_number := '1901SP6432107007ZYA001';
--l_header_rec.transactional_curr_code := 'CNY';
-- The statement indicates to the process order API that a new header has to be created.
l_Header_Rec.Operation := Oe_Globals.g_Opr_Create;

-- Setting index as 1 to indicate that these belong to 1st line record
l_Line_Tbl_Index := 1;
-- Initializing the line record to missing
l_Line_Tbl(l_Line_Tbl_Index) := Oe_Order_Pub.g_Miss_Line_Rec;
-- Line Attributes
l_Line_Tbl(l_Line_Tbl_Index).Inventory_Item_Id := 64881; --关联物料编号
l_Line_Tbl(l_Line_Tbl_Index).Ordered_Quantity := 10; --订单数量
l_Line_Tbl(l_Line_Tbl_Index).Unit_Selling_Price := 0.1; --订单单价
--l_line_tbl(l_line_tbl_index).SHIP_FROM_ORG_ID := 130;--发运仓库ID
--l_line_tbl(l_line_tbl_index).calculate_price_flag := 'Y';--标识价目表是否要输入
l_Line_Tbl(l_Line_Tbl_Index).Line_Type_Id := 1182; --行类型
-- Indicates that this is a create operation for the line record.
l_Line_Tbl(l_Line_Tbl_Index).Operation := Oe_Globals.g_Opr_Create;

-- action request订单登记
/*
l_action_request_tbl(l_line_tbl_index) := oe_order_pub.g_miss_request_rec;
l_action_request_tbl(l_line_tbl_index).request_type := oe_globals.g_book_order;
l_action_request_tbl(l_line_tbl_index).entity_code := oe_globals.g_entity_header;
l_action_request_tbl(l_line_tbl_index).entity_id := l_header_rec.header_id;
*/
Oe_Order_Pub.Process_Order(p_Api_Version_Number => 1.0
, --API版本初始化
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
,
-- OUT PARAMETERS
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_Tbl
,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('OM Debug file: ' || Oe_Debug_Pub.g_Dir || '/' ||
Oe_Debug_Pub.g_File);
FOR i IN 1 .. l_Msg_Count LOOP
Oe_Msg_Pub.Get(p_Msg_Index => i
,p_Encoded => Fnd_Api.g_False
,p_Data => l_Msg_Data
,p_Msg_Index_Out => l_Msg_Index_Out);
Dbms_Output.Put_Line('message is: ' || l_Msg_Data);
Dbms_Output.Put_Line('message index is: ' || l_Msg_Index_Out);
END LOOP;
-- Check the return status
IF l_Return_Status = Fnd_Api.g_Ret_Sts_Success THEN
Dbms_Output.Put_Line('^_^Process Order Success!');
COMMIT;
ELSE
Dbms_Output.Put_Line('~_~Process Order Failed!');
ROLLBACK;
END IF;
-- debug output
Dbms_Output.Put_Line('Debug Output');
FOR i IN 1 .. Oe_Debug_Pub.g_Debug_Count LOOP
Dbms_Output.Put_Line(Oe_Debug_Pub.g_Debug_Tbl(i));
END LOOP;
END;

posted @ 2021-08-02 16:27  蓝莓DD  阅读(377)  评论(0)    收藏  举报