查询物料保留并释放(可查看具体错误信息)
--查询物料保留并释放
DECLARE
l_Rsv_Rec Inv_Reservation_Global.Mtl_Reservation_Rec_Type;
l_Serial_Number Inv_Reservation_Global.Serial_Number_Tbl_Type;
l_Api_Version NUMBER := 1.0;
l_Init_Msg_List VARCHAR2(2) := Fnd_Api.g_True;
l_Primary_Relieved_Quantity NUMBER;
x_Return_Status VARCHAR2(2);
x_Err_Msg VARCHAR2(4000);
x_Status VARCHAR2(2);
x_Msg_Count NUMBER := 0;
x_Msg_Data VARCHAR2(255);
x_Error_Code NUMBER := 0;
x_Mtl_Reservation_Tbl Inv_Reservation_Global.Mtl_Reservation_Tbl_Type;
x_Mtl_Reservation_Tbl_Count NUMBER := 0;
x_Primary_Relieved_Qty NUMBER := 0;
x_Primary_Remain_Qty NUMBER := 0;
x_Qty NUMBER := 0;
BEGIN
l_Rsv_Rec.Organization_Id := '92';
l_Rsv_Rec.Inventory_Item_Id := 111;
l_Rsv_Rec.Primary_Reservation_Quantity := p_Qty;
l_Rsv_Rec.Demand_Source_Name := 'xxxxxxxxx';
l_Rsv_Rec.Demand_Source_Type_Id := 13;
l_Rsv_Rec.Subinventory_Code := 'xxxx';
l_Rsv_Rec.Reservation_Id := 11111;
Inv_Reservation_Pub.Query_Reservation(p_Api_Version_Number => l_Api_Version
,p_Init_Msg_Lst => l_Init_Msg_List
,x_Return_Status => x_Status
,x_Msg_Count => x_Msg_Count
,x_Msg_Data => x_Msg_Data
,p_Query_Input => l_Rsv_Rec
,p_Lock_Records => Fnd_Api.g_False
,p_Sort_By_Req_Date => Inv_Reservation_Global.g_Query_No_Sort
,p_Cancel_Order_Mode => Inv_Reservation_Global.g_Cancel_Order_No
,x_Mtl_Reservation_Tbl => x_Mtl_Reservation_Tbl
,x_Mtl_Reservation_Tbl_Count => x_Mtl_Reservation_Tbl_Count
,x_Error_Code => x_Error_Code);
Dbms_Output.Put_Line(x_Status);
Dbms_Output.Put_Line(x_Error_Code);
Dbms_Output.Put_Line('x_Mtl_Reservation_Tbl_Count:' ||
x_Mtl_Reservation_Tbl_Count);
IF (x_Status = Fnd_Api.g_Ret_Sts_Success AND
x_Mtl_Reservation_Tbl_Count > 0) THEN
x_Qty := 0;
FOR i IN 1 .. x_Mtl_Reservation_Tbl_Count LOOP
x_Qty := x_Qty + x_Mtl_Reservation_Tbl(i)
.Primary_Reservation_Quantity;
Dbms_Output.Put_Line('保留idreservation_id: ' ||
To_Char(x_Mtl_Reservation_Tbl(i).Reservation_Id));
END LOOP;
Dbms_Output.Put_Line('保留数量x_Qty:' || x_Qty);
END IF;
Inv_Reservation_Pub.Relieve_Reservation(p_Api_Version_Number => l_Api_Version
,p_Init_Msg_Lst => l_Init_Msg_List
,x_Return_Status => x_Status
,x_Msg_Count => x_Msg_Count
,x_Msg_Data => x_Msg_Data
,p_Rsv_Rec => x_Mtl_Reservation_Tbl(1)
,p_Primary_Relieved_Quantity => l_Primary_Relieved_Quantity
,p_Relieve_All => Fnd_Api.g_False
,p_Original_Serial_Number => l_Serial_Number
,p_Validation_Flag => Fnd_Api.g_True
,x_Primary_Relieved_Quantity => x_Primary_Relieved_Qty
,x_Primary_Remain_Quantity => x_Primary_Remain_Qty);
IF (x_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
Dbms_Output.Put_Line('释放物料保留调用API出错:' || x_Msg_Data);
Fnd_Msg_Pub.Count_And_Get(p_Encoded => Fnd_Api.g_False
,p_Count => x_Msg_Count
,p_Data => x_Msg_Data);
IF x_Msg_Count > 1 THEN
x_Msg_Data := Fnd_Msg_Pub.Get_Detail(p_Msg_Index => Fnd_Msg_Pub.g_First
,p_Encoded => Fnd_Api.g_False);
END IF;
Dbms_Output.Put_Line(x_Msg_Data);
END IF;
END;