调用API修改标准订单或一揽子发放行或发运行的单价、数量、需求日期和承诺日期等等,实例参考如下:
一、修改发运行API实例:
DECLARE
Lt_Errors Po_Api_Errors_Rec_Type;
Lt_Chg Po_Changes_Rec_Type;
Lv_Return_Status VARCHAR2(30);
Lv_Launch_Approvals_Flag VARCHAR2(30) := 'T';
Ln_Org_Id NUMBER := 131;
Ln_Po_Header_Id NUMBER := NULL; --
Ln_Po_Release_Id NUMBER := 1393066; --一揽子发放标识
Ln_Po_Line_Location_Id NUMBER := 7577456; --发运行标识
Ln_New_Quantity NUMBER := 1000; --修改数量
Ld_New_Promised_Date DATE := NULL; --承诺日期
Ln_New_Price NUMBER := NULL; --单价
Ld_New_Need_By_Date DATE := To_Date('2009-01-29', 'yyyy-mm-dd'); --修改需求日期
Lv_Msg_Data VARCHAR2(20000);
BEGIN
--Init
Mo_Global.Init('PO');
Mo_Global.Set_Policy_Context('S', Ln_Org_Id);
Lt_Chg := Po_Changes_Rec_Type.Create_Object(p_Po_Header_Id => Ln_Po_Header_Id
,p_Po_Release_Id => Ln_Po_Release_Id);
--Call Api
Lt_Chg.Shipment_Changes.Add_Change(p_Po_Line_Location_Id => Ln_Po_Line_Location_Id
,p_Quantity => Ln_New_Quantity
,p_Promised_Date => Ld_New_Promised_Date
,p_Price_Override => Ln_New_Price
,p_Need_By_Date => Ld_New_Need_By_Date);
Po_Document_Update_Grp.Update_Document(p_Api_Version => 1.0 -- pass this as 1.0
,p_Init_Msg_List => Fnd_Api.g_True -- pass this as TRUE
,x_Return_Status => Lv_Return_Status -- returns the result of execution
,p_Changes => Lt_Chg -- changes obPr_Lines_Tbl(J). contains all changes intended to be made on document
,p_Run_Submission_Checks => Fnd_Api.g_False -- set to TRUE if want to perform submission check
,p_Launch_Approvals_Flag => Lv_Launch_Approvals_Flag -- set to TRUE if want to launch approval work flow after making the changes
,p_Buyer_Id => NULL -- buyer id
,p_Update_Source => NULL -- name of a source who is calling this API. In case of manual call can be passed as NULL
,p_Override_Date => NULL
,x_Api_Errors => Lt_Errors -- list of errors if any occurred in execution
,p_Mass_Update_Releases => NULL);
Dbms_Output.Put_Line('Lv_Return_Status :' || Lv_Return_Status);
IF Lt_Errors IS NOT NULL THEN
FOR i IN 1 .. Lt_Errors.Message_Text.Count LOOP
Lv_Msg_Data := Lt_Errors.Message_Text(i) || ' - ' ||
Lt_Errors.Message_Name(i) || '; ' || Lv_Msg_Data;
END LOOP;
Dbms_Output.Put_Line('Lv_Msg_Data:' || Lv_Msg_Data);
END IF;
END;
二、添加或拆分发运行API实例:
DECLARE
Lt_Errors Po_Api_Errors_Rec_Type;
Lt_Chg Po_Changes_Rec_Type;
Lt_Shipment_Changes Po_Shipments_Rec_Type;
Lv_Return_Status VARCHAR2(30);
Lv_Launch_Approvals_Flag VARCHAR2(30) := 'F';
--Blanket header
Ln_Po_Header_Id NUMBER := 9041;
--Blanket Release
Ln_Po_Release_Id NUMBER := 5989;
--父(参照)发运行
Ln_Parent_Line_Location_Id NUMBER := 47386;
--新发运行
Ln_Po_Line_Location_Id Po_Tbl_Number := Po_Tbl_Number();
--发运数量
Ln_Quantity Po_Tbl_Number := Po_Tbl_Number();
--单价
Ln_Price_Override Po_Tbl_Number := Po_Tbl_Number();
--承诺日期
Ln_Promised_Date Po_Tbl_Date := Po_Tbl_Date();
--需求日期
Ln_Need_By_Date Po_Tbl_Date := Po_Tbl_Date();
Ln_Org_Id NUMBER := 101;
--发运行
Ln_Split_Shipment_Num NUMBER;
Lv_Msg_Data VARCHAR2(20000);
BEGIN
--to set org context in a R12 env
Mo_Global.Init('PO');
Mo_Global.Set_Policy_Context('S', Ln_Org_Id);
Fnd_Global.Apps_Initialize(User_Id => 110, Resp_Id => 96502, Resp_Appl_Id => 20003);
SELECT MAX(Pll.Shipment_Num) + 1
INTO Ln_Split_Shipment_Num
FROM Po_Line_Locations_All Pll
WHERE Pll.Po_Header_Id = Ln_Po_Header_Id;
Ln_Po_Line_Location_Id := Po_Tbl_Number(NULL);
Ln_Quantity := Po_Tbl_Number(20000);
Ln_Price_Override := Po_Tbl_Number(NULL);
Ln_Promised_Date := Po_Tbl_Date(NULL);
Ln_Need_By_Date := Po_Tbl_Date(To_Date('2009-01-29', 'yyyy-mm-dd'));
-- Create an Object for Shipment Changes
-- For Creating New Shipment Line pass p_po_line_location_id as Null
Lt_Shipment_Changes := Po_Shipments_Rec_Type.Create_Object(p_Po_Line_Location_Id => Ln_Po_Line_Location_Id
,p_Quantity => Ln_Quantity
,p_Promised_Date => Ln_Promised_Date
,p_Price_Override => Ln_Price_Override
,p_Parent_Line_Location_Id => Po_Tbl_Number(Ln_Parent_Line_Location_Id)
,p_Split_Shipment_Num => Po_Tbl_Number(Ln_Split_Shipment_Num)
,p_Need_By_Date => Ln_Need_By_Date);
-- Create an Object for Changes
-- po_changes_rec_type constructor takes either po_header_id OR po_release_id to construct the object.
-- For release order pass po_release_id only.
Lt_Chg := Po_Changes_Rec_Type.Create_Object(p_Po_Header_Id => NULL
,p_Po_Release_Id => Ln_Po_Release_Id
,p_Shipment_Changes => Lt_Shipment_Changes);
-- Now call the change api to execute the above changes
Po_Document_Update_Grp.Update_Document(p_Api_Version => 1.0 -- pass this as 1.0
,p_Init_Msg_List => Fnd_Api.g_True -- pass this as TRUE
,x_Return_Status => Lv_Return_Status -- returns the result of execution
,p_Changes => Lt_Chg -- changes obPr_Lines_Tbl(J). contains all changes intended to be made on document
,p_Run_Submission_Checks => Fnd_Api.g_False -- set to TRUE if want to perform submission check
,p_Launch_Approvals_Flag => Lv_Launch_Approvals_Flag -- set to TRUE if want to launch approval work flow after making the changes
,p_Buyer_Id => NULL -- buyer id
,p_Update_Source => NULL -- name of a source who is calling this API. In case of manual call can be passed as NULL
,p_Override_Date => NULL
,x_Api_Errors => Lt_Errors -- list of errors if any occurred in execution
,p_Mass_Update_Releases => NULL);
--S表示成功,
Dbms_Output.Put_Line('Lv_Return_Status :' || Lv_Return_Status);
--Error Output
IF Lt_Errors IS NOT NULL THEN
FOR i IN 1 .. Lt_Errors.Message_Text.Count LOOP
Lv_Msg_Data := Lt_Errors.Message_Text(i) || ' - ' || Lt_Errors.Message_Name(i) || '; ' ||
Lv_Msg_Data;
END LOOP;
Dbms_Output.Put_Line('Lv_Msg_Data:' || Lv_Msg_Data);
END IF;
END;