DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_INV_INTEGRATION_GRP

Source


1 PACKAGE BODY PO_INV_INTEGRATION_GRP AS
2 /* $Header: PO_INV_INTEGRATION_GRP.plb 120.1 2005/08/19 16:26:06 dreddy noship $ */
3 
4 G_PKG_NAME             CONSTANT VARCHAR2(30) := 'PO_INV_INTEGRATION_GRP';
5 
6 -------------------------------------------------------------------------------
7 --Start of Comments
8 --Name: inv_um_convert
9 --Pre-reqs:
10 --  none
11 --Modifies:
12 --  None.
13 --Locks:
14 --  None.
15 --Function:
16 --  Converts the given quantity from one uom to the other
17 --Parameters:
18 --IN:
19 --p_api_version
20 --  Initial API version : Expected value is 1.0
21 --p_item_id
22 -- Inventory Item Id for whxih the conversion is defined
23 --p_from_quantity
24 -- Quantity to be converted
25 --p_from_unit_of_measure
26 --  The unit of measure to be converted from
27 --p_to_unit_of_measure
28 --  The unit of measure to be converted to
29 --OUT:
30 --x_to_quantity
31 --  Qty converted from from_uom to the to_uom
32 --x_ret_status
33 --  (a) FND_API.G_RET_STS_SUCCESS - 'S' if successful
34 --  (b) FND_API.G_RET_STS_ERROR - 'E' if known error occurs
35 --  (c) FND_API.G_RET_STS_UNEXP_ERROR - 'U' if unexpected error occurs
36 --Testing:
37 --  None.
38 --End of Comments
39 -------------------------------------------------------------------------------
40 PROCEDURE get_converted_qty(p_api_version    IN NUMBER,
41                          p_item_id   IN number,
42                          p_from_quantity        IN NUMBER,
43                          p_from_unit_of_measure IN VARCHAR2,
44                          p_to_unit_of_measure   IN VARCHAR2 ,
45                          x_to_quantity    OUT NOCOPY NUMBER,
46                          x_return_status  OUT NOCOPY VARCHAR2 ) IS
47 
48 l_api_name              CONSTANT VARCHAR2(30) := 'get_converted_qty';
49 l_api_version           CONSTANT NUMBER := 1.0;
50 
51 l_to_quantity           NUMBER := null;
52 
53 BEGIN
54  -- Initialise the return status
55  x_return_status := FND_API.G_RET_STS_SUCCESS;
56 
57  -- check for API version
58  IF ( NOT FND_API.compatible_api_call(l_api_version,p_api_version,l_api_name,G_PKG_NAME) )
59  THEN
60    x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
61    return;
62  END IF;
63 
64  -- Call the Inv API to get the qty
65  l_to_quantity := INV_CONVERT.inv_um_convert (
66          item_id        => p_item_id,
67          precision      => 5,
68          from_quantity  => p_from_quantity,
69          from_unit      => null,
70          to_unit        => null,
71          from_name	=> p_from_unit_of_measure,
72          to_name	=> p_to_unit_of_measure );
73 
74  IF l_to_quantity < 0 THEN
75    x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
76    FND_MESSAGE.SET_NAME('INV','INV_INVALID_UOM_CONV');
77    FND_MESSAGE.SET_TOKEN ('VALUE1',p_from_unit_of_measure);
78    FND_MESSAGE.SET_TOKEN ('VALUE2',p_to_unit_of_measure);
79    FND_MSG_PUB.ADD;
80  ELSE
81    x_to_quantity := l_to_quantity;
82  END IF;
83 
84 EXCEPTION
85 When Others then
86      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
87 END;
88 
89 -------------------------------------------------------------------------------
90 --Start of Comments
91 --Name: within_deviation
92 --Pre-reqs:
93 --  none
94 --Modifies:
95 --  None.
96 --Locks:
97 --  None.
98 --Function:
99 --  Checks if the given primary and secondary quantities are within the allowed
100 --  deviation for the primary and secondary UOM's
101 --Parameters:
102 --IN:
103 --p_api_version
104 --  Initial API version : Expected value is 1.0
105 --p_organization_id
106 -- Inventory Organization id to validate the item in
107 --p_item_id
108 -- Inventory Item Id for which the deviation is defined
109 --p_pri_quantity
110 -- Primary Quantity
111 --p_sec_quantity
112 --  Secondary Quantity
113 --p_pri_unit_of_measure
114 --  The unit of measure corresponding to primary qty
115 --p_sec_unit_of_measure
116 --  The unit of measure corresponding to secondary qty
117 --OUT:
118 --x_ret_status
119 --  (a) FND_API.G_RET_STS_SUCCESS - 'S' if successful
120 --  (b) FND_API.G_RET_STS_ERROR - 'E' if known error occurs
121 --  (c) FND_API.G_RET_STS_UNEXP_ERROR - 'U' if unexpected error occurs
122 --Testing:
123 --  None.
124 --End of Comments
125 -------------------------------------------------------------------------------
126 PROCEDURE within_deviation(p_api_version    IN NUMBER,
127                            p_organization_id     IN NUMBER,
128                            p_item_id             IN NUMBER,
129                            p_pri_quantity        IN NUMBER,
130                            p_sec_quantity        IN NUMBER,
131                            p_pri_unit_of_measure IN VARCHAR2,
132                            p_sec_unit_of_measure IN VARCHAR2,
133                            x_return_status  OUT NOCOPY VARCHAR2,
134                            x_msg_data       OUT NOCOPY VARCHAR2) IS
135 
136 l_api_name              CONSTANT VARCHAR2(30) := 'within_deviation';
137 l_api_version           CONSTANT NUMBER := 1.0;
138 
139 l_return_code           NUMBER;
140 
141 BEGIN
142  -- Initialise the return status
143  x_return_status := FND_API.G_RET_STS_SUCCESS;
144 
145  -- check for API version
146  IF ( NOT FND_API.compatible_api_call(l_api_version,p_api_version,l_api_name,G_PKG_NAME) )
147  THEN
148    x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
149    return;
150  END IF;
151 
152  -- call the inv API to check deviation
153  l_return_code := INV_CONVERT.within_deviation(
154       p_organization_id     => p_organization_id,
155       p_inventory_item_id   => p_item_id,
156       p_lot_number          => null,
157       p_precision           => 5,
158       p_quantity            => p_pri_quantity,
159       p_uom_code1           => null,
160       p_quantity2           => p_sec_quantity,
161       p_uom_code2           => null,
162       p_unit_of_measure1    => p_pri_unit_of_measure,
163       p_unit_of_measure2    => p_sec_unit_of_measure);
164 
165  IF l_return_code = 0 THEN
166     x_return_status := FND_API.G_RET_STS_ERROR;
167     x_msg_data := FND_MESSAGE.get_encoded;
168  END IF;
169 
170 
171 EXCEPTION
172 When Others then
173      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
174 END;
175 
176 END PO_INV_INTEGRATION_GRP;