[Home] [Help]
PACKAGE BODY: APPS.GMI_SUMM_INV_PVT
Source
1 PACKAGE BODY GMI_SUMM_INV_PVT AS
2 /* $Header: GMIVBUSB.pls 115.5 2000/11/28 08:57:56 pkm ship $ */
3 /* +=========================================================================+
4 | Copyright (c) 2000 Oracle Corporation |
5 | TVP, Reading, England |
6 | All rights reserved |
7 +=========================================================================+
8 | FILENAME |
9 | GMIVBUSB.pls |
10 | |
11 | DESCRIPTION |
12 | This package contains private definitions For Business Layer |
13 | Logic For IC_SUMM_INV |
14 | |
15 | HISTORY |
16 | 12-JAN-2000 H.Verdding |
17 +=========================================================================+
18 API Name : GMI_SUMM_INV_PVT
19 Type : Public
20 Function : This package contains private procedures used to create
21 IC_SUMM_INV transactions
22 Pre-reqs : N/A
23 Parameters: Per function
24
25 Current Vers : 1.0
26
27 Previous Vers : 1.0
28
29 Initial Vers : 1.0
30 Notes
31
32
33 Body end of comments
34 */
35
36 /* Global variables */
37 G_PKG_NAME CONSTANT VARCHAR2(30):='GMI_SUMM_INV_PVT';
38
39 PROCEDURE PENDING
40 (
41 p_tran_rec IN GMI_TRANS_ENGINE_PUB.ictran_rec,
42 x_return_status OUT VARCHAR2
43 )
44 IS
45 err_num NUMBER;
46 err_msg VARCHAR2(200);
47 l_summ_inv IC_SUMM_INV%ROWTYPE;
48
49 BEGIN
50
51 /* Initialize return status to sucess */
52 x_return_status := FND_API.G_RET_STS_SUCCESS;
53
54 /* Assign All default Values To Record Type */
55
56 l_summ_inv.onhand_qty :=0;
57 l_summ_inv.onhand_qty2 :=NULL;
58 l_summ_inv.onhand_prod_qty :=0;
59 l_summ_inv.onhand_prod_qty2 :=NULL;
60 l_summ_inv.onhand_order_qty :=0;
61 l_summ_inv.onhand_order_qty2 :=NULL;
62 l_summ_inv.onhand_ship_qty :=0;
63 l_summ_inv.onhand_ship_qty2 :=NULL;
64 l_summ_inv.committedprod_qty :=0;
65 l_summ_inv.committedprod_qty2 :=NULL;
66 l_summ_inv.onprod_qty :=0;
67 l_summ_inv.onprod_qty2 :=NULL;
68 l_summ_inv.committedsales_qty :=0;
69 l_summ_inv.committedsales_qty2 :=NULL;
70 l_summ_inv.onpurch_qty :=0;
71 l_summ_inv.onpurch_qty2 :=NULL;
72 l_summ_inv.intransit_qty :=0;
73 l_summ_inv.intransit_qty2 :=NULL;
74
75
76 /* Copy required Fields From Ic_tran_rec record Type. */
77
78 l_summ_inv.item_id := p_tran_rec.item_id;
79 l_summ_inv.whse_code := p_tran_rec.whse_code;
80 l_summ_inv.qc_grade := p_tran_rec.qc_grade;
81 l_summ_inv.last_updated_by := p_tran_rec.user_id;
82 l_summ_inv.created_by := p_tran_rec.user_id;
83 l_summ_inv.last_update_date := SYSDATE;
84 l_summ_inv.creation_date := SYSDATE;
85
86
87 /* Firm Planned Orders */
88
89 IF p_tran_rec.doc_type='FPO' THEN
90 RETURN; /* No Update Needed For Firm Planned Orders */
91 END IF;
92
93 /* Production Batches */
94
95 IF p_tran_rec.doc_type='PROD' THEN
96 /* If Ingredient Lines */
97 IF p_tran_rec.line_type = -1 THEN
98 l_summ_inv.committedprod_qty := p_tran_rec.trans_qty * -1;
99 l_summ_inv.committedprod_qty2 := p_tran_rec.trans_qty2 * -1;
100 ELSE
101 /* Products And By Products
102 Increase Expected Production quantity */
103
104 l_summ_inv.onprod_qty := p_tran_rec.trans_qty;
105 l_summ_inv.onprod_qty2 := p_tran_rec.trans_qty2;
106 END IF;
107 END IF;
108
109 /* Sales Orders And Shipments */
110
111 IF ( p_tran_rec.doc_type='OMSO') OR ( p_tran_rec.doc_type ='OPSO') THEN
112 /* increase committed sales Quantity */
113 l_summ_inv.committedsales_qty := p_tran_rec.trans_qty *-1;
114 l_summ_inv.committedsales_qty2 := p_tran_rec.trans_qty2 *-1;
115 END IF;
116
117 /* Purchase Orders And Receipts */
118
119 IF ( p_tran_rec.doc_type='PORD') OR (p_tran_rec.doc_type = 'RECV') THEN
120 /* increase expected purchase Quantity */
121 l_summ_inv.onpurch_qty := p_tran_rec.trans_qty;
122 l_summ_inv.onpurch_qty2 := p_tran_rec.trans_qty2;
123 END IF;
124
125 /* Transfers */
126
127 IF p_tran_rec.doc_type = 'XFER' THEN
128 l_summ_inv.intransit_qty := p_tran_rec.trans_qty ;
129 l_summ_inv.intransit_qty2:= p_tran_rec.trans_qty2;
130 END IF;
131
132 /* Update Inventory Summary Table -- */
133
134 IF NOT GMI_SUMM_INV_DB_PVT.UPDATE_IC_SUMM_INV( p_summ_inv => l_summ_inv)
135 THEN
136 IF NOT GMI_SUMM_INV_DB_PVT.INSERT_IC_SUMM_INV( p_summ_inv => l_summ_inv)
137 THEN
138 FND_MESSAGE.SET_NAME('GMI','GMI_IC_SUMM_INV_INSERT');
139 FND_MSG_PUB.ADD;
140 RAISE FND_API.G_EXC_ERROR;
141 END IF;
142 END IF;
143
144 EXCEPTION
145 WHEN FND_API.G_EXC_ERROR THEN
146
147 x_return_status := FND_API.G_RET_STS_ERROR;
148
149 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
150 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
151
152 WHEN OTHERS THEN
153 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
154
155 FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME
156 , 'PENDING');
157
158
159
160 END PENDING;
161
162 PROCEDURE COMPLETED
163 (
164 p_tran_rec IN GMI_TRANS_ENGINE_PUB.ictran_rec,
165 x_return_status OUT VARCHAR2
166 )
167 IS
168 err_num NUMBER;
169 err_msg VARCHAR2(200);
170
171 l_summ_inv IC_SUMM_INV%ROWTYPE;
172 l_lots_sts IC_LOTS_STS%ROWTYPE;
173 BEGIN
174
175 /* Initialize return status to sucess */
176 x_return_status := FND_API.G_RET_STS_SUCCESS;
177
178 /* Assign All default Values To Record Type */
179
180 l_summ_inv.onhand_qty :=0;
181 l_summ_inv.onhand_qty2 :=NULL;
182 l_summ_inv.onhand_prod_qty :=0;
183 l_summ_inv.onhand_prod_qty2 :=NULL;
184 l_summ_inv.onhand_order_qty :=0;
185 l_summ_inv.onhand_order_qty2 :=NULL;
186 l_summ_inv.onhand_ship_qty :=0;
187 l_summ_inv.onhand_ship_qty2 :=NULL;
188 l_summ_inv.committedprod_qty :=0;
189 l_summ_inv.committedprod_qty2 :=NULL;
190 l_summ_inv.onprod_qty :=0;
191 l_summ_inv.onprod_qty2 :=NULL;
192 l_summ_inv.committedsales_qty :=0;
193 l_summ_inv.committedsales_qty2 :=NULL;
194 l_summ_inv.onpurch_qty :=0;
195 l_summ_inv.onpurch_qty2 :=NULL;
196 l_summ_inv.intransit_qty :=0;
197 l_summ_inv.intransit_qty2 :=NULL;
198
199
200 /* Copy required Fields From Ic_tran_row Type. */
201
202 l_summ_inv.item_id := p_tran_rec.item_id;
203 l_summ_inv.whse_code := p_tran_rec.whse_code;
204 l_summ_inv.qc_grade := p_tran_rec.qc_grade;
205 l_summ_inv.last_updated_by := p_tran_rec.user_id;
206 l_summ_inv.created_by := p_tran_rec.user_id;
207 l_summ_inv.last_update_date := SYSDATE;
208 l_summ_inv.creation_date := SYSDATE;
209
210 IF p_tran_rec.lot_status IS NULL THEN
211 l_lots_sts.nettable_ind :=1;
212 l_lots_sts.order_proc_ind :=1;
213 l_lots_sts.prod_ind :=1;
214 l_lots_sts.shipping_ind :=1;
215 l_lots_sts.rejected_ind :=1;
216 ELSE
217 /* Get Specific Values for Passed In status. */
218
219 IF NOT ( GMI_SUMM_INV_DB_PVT.GET_LOT_ATTRIBUTES
220 (
221 p_lot_status => p_tran_rec.lot_status,
222 x_lots_sts => l_lots_sts
223 )
224 )
225 THEN
226
227 FND_MESSAGE.SET_NAME('GMI','IC_INVALID_LOT_STATUS');
228 FND_MESSAGE.SET_TOKEN('LOT_STATUS', p_tran_rec.lot_status);
229 FND_MSG_PUB.Add;
230 RAISE FND_API.G_EXC_ERROR;
231 END IF;
232
233 END IF;
234
235 /* Nettable Lots */
236
237 IF l_lots_sts.nettable_ind =1 THEN
238 l_summ_inv.onhand_qty := p_tran_rec.trans_qty;
239 l_summ_inv.onhand_qty2 := p_tran_rec.trans_qty2;
240 END IF;
241
242 /* Available For Production */
243
244 IF l_lots_sts.prod_ind =1 THEN
245 l_summ_inv.onhand_prod_qty := p_tran_rec.trans_qty;
246 l_summ_inv.onhand_prod_qty2 := p_tran_rec.trans_qty2;
247 END IF;
248
249 /* Available For Sales */
250
251 IF l_lots_sts.order_proc_ind =1 THEN
252 l_summ_inv.onhand_order_qty := p_tran_rec.trans_qty;
253 l_summ_inv.onhand_order_qty2 := p_tran_rec.trans_qty2;
254 END IF;
255
256 /* Available For Shipping */
257
258 IF l_lots_sts.shipping_ind =1 THEN
259 l_summ_inv.onhand_ship_qty := p_tran_rec.trans_qty;
260 l_summ_inv.onhand_ship_qty2 := p_tran_rec.trans_qty2;
261 END IF;
262
263 /* Update Inventory Summary Table -- */
264
265 IF NOT GMI_SUMM_INV_DB_PVT.UPDATE_IC_SUMM_INV( p_summ_inv => l_summ_inv)
266 THEN
267
268 IF NOT GMI_SUMM_INV_DB_PVT.INSERT_IC_SUMM_INV( p_summ_inv => l_summ_inv)
269 THEN
270 FND_MESSAGE.SET_NAME('GMI','GMI_IC_SUMM_INV_INSERT');
271 FND_MSG_PUB.ADD;
272 RAISE FND_API.G_EXC_ERROR;
273 END IF;
274 END IF;
275
276 EXCEPTION
277
278 WHEN FND_API.G_EXC_ERROR THEN
279
280 x_return_status := FND_API.G_RET_STS_ERROR;
281
282 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
283 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
284
285 WHEN OTHERS THEN
286 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
287
288 FND_MSG_PUB.Add_Exc_Msg ( G_PKG_NAME
289 , 'COMPLETED');
290
291 END COMPLETED;
292
293 END GMI_SUMM_INV_PVT;