Oracle EBS Interface/API(19)-PO修改行或發運行的單價、數量、需求日期和承諾日期等等

調用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;







 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章