7:
8:
9: PROCEDURE complete_batch
10: (p_batch_header_rec IN gme_batch_header%ROWTYPE
11: ,x_exception_material_tbl IN OUT NOCOPY gme_common_pvt.exceptions_tab
12: ,x_batch_header_rec OUT NOCOPY gme_batch_header%ROWTYPE
13: ,x_return_status OUT NOCOPY VARCHAR2) IS
14:
15:
24: CURSOR Cur_get_step_to_complete(v_batch_id NUMBER) IS
25: SELECT *
26: FROM gme_batch_steps
27: WHERE batch_id = v_batch_id
28: AND step_status NOT IN (gme_common_pvt.g_step_completed, gme_common_pvt.g_step_closed);
29:
30: CURSOR Cur_get_phantom_batch(v_batch_id NUMBER) IS
31: SELECT hdr.*
32: FROM gme_material_details dtl, gme_batch_header hdr
30: CURSOR Cur_get_phantom_batch(v_batch_id NUMBER) IS
31: SELECT hdr.*
32: FROM gme_material_details dtl, gme_batch_header hdr
33: WHERE dtl.batch_id = v_batch_id
34: AND dtl.line_type = gme_common_pvt.g_line_type_ing
35: AND dtl.phantom_id IS NOT NULL
36: AND hdr.batch_id = dtl.phantom_id
37: AND hdr.batch_status NOT IN (gme_common_pvt.g_batch_completed, gme_common_pvt.g_batch_closed);
38:
33: WHERE dtl.batch_id = v_batch_id
34: AND dtl.line_type = gme_common_pvt.g_line_type_ing
35: AND dtl.phantom_id IS NOT NULL
36: AND hdr.batch_id = dtl.phantom_id
37: AND hdr.batch_status NOT IN (gme_common_pvt.g_batch_completed, gme_common_pvt.g_batch_closed);
38:
39: CURSOR cur_lock_batch_ingredients (v_batch_id NUMBER) IS
40: SELECT *
41: FROM gme_material_details
39: CURSOR cur_lock_batch_ingredients (v_batch_id NUMBER) IS
40: SELECT *
41: FROM gme_material_details
42: WHERE batch_id = v_batch_id
43: AND (line_type = gme_common_pvt.g_line_type_ing OR
44: (line_type = gme_common_pvt.g_line_type_prod AND phantom_line_id IS NOT NULL))
45: FOR UPDATE OF actual_qty NOWAIT;
46:
47: CURSOR Cur_lock_batch_products(v_batch_id NUMBER) IS
40: SELECT *
41: FROM gme_material_details
42: WHERE batch_id = v_batch_id
43: AND (line_type = gme_common_pvt.g_line_type_ing OR
44: (line_type = gme_common_pvt.g_line_type_prod AND phantom_line_id IS NOT NULL))
45: FOR UPDATE OF actual_qty NOWAIT;
46:
47: CURSOR Cur_lock_batch_products(v_batch_id NUMBER) IS
48: SELECT *
47: CURSOR Cur_lock_batch_products(v_batch_id NUMBER) IS
48: SELECT *
49: FROM gme_material_details
50: WHERE batch_id = v_batch_id
51: AND line_type IN (gme_common_pvt.g_line_type_prod,gme_common_pvt.g_line_type_byprod)
52: AND phantom_line_id IS NULL -- no phantom products
53: FOR UPDATE OF actual_qty NOWAIT;
54:
55: l_api_name CONSTANT VARCHAR2 (30) := 'COMPLETE_BATCH';
55: l_api_name CONSTANT VARCHAR2 (30) := 'COMPLETE_BATCH';
56: l_table_name CONSTANT VARCHAR2 (30) := 'gme_material_details';
57:
58: l_step_status NUMBER;
59: l_matl_dtl_tab_ing gme_common_pvt.material_details_tab;
60: l_matl_dtl_tab gme_common_pvt.material_details_tab;
61: l_btch_hdr gme_batch_header%ROWTYPE;
62: l_btch_hdr_tab gme_common_pvt.batch_headers_tab;
63: l_matl_dtl gme_material_details%ROWTYPE;
56: l_table_name CONSTANT VARCHAR2 (30) := 'gme_material_details';
57:
58: l_step_status NUMBER;
59: l_matl_dtl_tab_ing gme_common_pvt.material_details_tab;
60: l_matl_dtl_tab gme_common_pvt.material_details_tab;
61: l_btch_hdr gme_batch_header%ROWTYPE;
62: l_btch_hdr_tab gme_common_pvt.batch_headers_tab;
63: l_matl_dtl gme_material_details%ROWTYPE;
64: l_matl_dtl_rec gme_material_details%ROWTYPE;
58: l_step_status NUMBER;
59: l_matl_dtl_tab_ing gme_common_pvt.material_details_tab;
60: l_matl_dtl_tab gme_common_pvt.material_details_tab;
61: l_btch_hdr gme_batch_header%ROWTYPE;
62: l_btch_hdr_tab gme_common_pvt.batch_headers_tab;
63: l_matl_dtl gme_material_details%ROWTYPE;
64: l_matl_dtl_rec gme_material_details%ROWTYPE;
65: l_step_tab gme_common_pvt.steps_tab;
66: l_batch_step_rec gme_batch_steps%ROWTYPE;
61: l_btch_hdr gme_batch_header%ROWTYPE;
62: l_btch_hdr_tab gme_common_pvt.batch_headers_tab;
63: l_matl_dtl gme_material_details%ROWTYPE;
64: l_matl_dtl_rec gme_material_details%ROWTYPE;
65: l_step_tab gme_common_pvt.steps_tab;
66: l_batch_step_rec gme_batch_steps%ROWTYPE;
67: l_yield_type NUMBER;
68: l_phantom_batch gme_batch_header%ROWTYPE;
69: l_phantom_batch_rec gme_batch_header%ROWTYPE;
98: -- set output structure
99: x_batch_header_rec := p_batch_header_rec;
100:
101: -- if the batch is pending, call release batch
102: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending THEN
103: -- call release batch
104: gme_release_batch_pvt.release_batch
105: (p_batch_header_rec => p_batch_header_rec
106: ,x_batch_header_rec => x_batch_header_rec
105: (p_batch_header_rec => p_batch_header_rec
106: ,x_batch_header_rec => x_batch_header_rec
107: ,x_return_status => l_return_status
108: ,x_exception_material_tbl => x_exception_material_tbl);
109: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
110: x_return_status := l_return_status;
111: RAISE error_release_batch;
112: END IF;
113:
110: x_return_status := l_return_status;
111: RAISE error_release_batch;
112: END IF;
113:
114: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
115: x_return_status := gme_common_pvt.g_exceptions_err;
116: END IF;
117: END IF;
118:
111: RAISE error_release_batch;
112: END IF;
113:
114: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
115: x_return_status := gme_common_pvt.g_exceptions_err;
116: END IF;
117: END IF;
118:
119: -- set batch status
116: END IF;
117: END IF;
118:
119: -- set batch status
120: x_batch_header_rec.batch_status := gme_common_pvt.g_batch_completed;
121:
122: -- no need to set the actual completion date because it is expected to have been in p_batch_header_rec
123:
124: -- Update the batch header
126: RAISE error_update_batch;
127: END IF;
128:
129: -- Update WHO columns for output structure
130: x_batch_header_rec.last_updated_by := gme_common_pvt.g_user_ident;
131: x_batch_header_rec.last_update_date := gme_common_pvt.g_timestamp;
132: x_batch_header_rec.last_update_login := gme_common_pvt.g_login_id;
133:
134: -- Lock all the ingredents and phantom product lines associated with the batch
127: END IF;
128:
129: -- Update WHO columns for output structure
130: x_batch_header_rec.last_updated_by := gme_common_pvt.g_user_ident;
131: x_batch_header_rec.last_update_date := gme_common_pvt.g_timestamp;
132: x_batch_header_rec.last_update_login := gme_common_pvt.g_login_id;
133:
134: -- Lock all the ingredents and phantom product lines associated with the batch
135: OPEN cur_lock_batch_ingredients (x_batch_header_rec.batch_id);
128:
129: -- Update WHO columns for output structure
130: x_batch_header_rec.last_updated_by := gme_common_pvt.g_user_ident;
131: x_batch_header_rec.last_update_date := gme_common_pvt.g_timestamp;
132: x_batch_header_rec.last_update_login := gme_common_pvt.g_login_id;
133:
134: -- Lock all the ingredents and phantom product lines associated with the batch
135: OPEN cur_lock_batch_ingredients (x_batch_header_rec.batch_id);
136: FETCH cur_lock_batch_ingredients BULK COLLECT INTO l_matl_dtl_tab_ing;
155: FOR i IN 1..l_matl_dtl_tab.COUNT LOOP
156: l_matl_dtl_rec := l_matl_dtl_tab(i);
157:
158: l_yield_type := l_matl_dtl_rec.release_type;
159: IF l_yield_type = gme_common_pvt.g_mtl_autobystep_release THEN
160: OPEN Cur_associated_step(l_matl_dtl_rec.material_detail_id);
161: FETCH Cur_associated_step INTO l_step_status;
162: IF Cur_associated_step%NOTFOUND THEN
163: l_yield_type := gme_common_pvt.g_mtl_auto_release;
159: IF l_yield_type = gme_common_pvt.g_mtl_autobystep_release THEN
160: OPEN Cur_associated_step(l_matl_dtl_rec.material_detail_id);
161: FETCH Cur_associated_step INTO l_step_status;
162: IF Cur_associated_step%NOTFOUND THEN
163: l_yield_type := gme_common_pvt.g_mtl_auto_release;
164: END IF;
165: CLOSE Cur_associated_step;
166: END IF;
167:
164: END IF;
165: CLOSE Cur_associated_step;
166: END IF;
167:
168: IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) THEN
169: IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
170: IF l_yield_type = gme_common_pvt.g_mtl_auto_release THEN
171: l_yield := TRUE;
172: ELSE
165: CLOSE Cur_associated_step;
166: END IF;
167:
168: IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) THEN
169: IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
170: IF l_yield_type = gme_common_pvt.g_mtl_auto_release THEN
171: l_yield := TRUE;
172: ELSE
173: l_yield := FALSE;
166: END IF;
167:
168: IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) THEN
169: IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
170: IF l_yield_type = gme_common_pvt.g_mtl_auto_release THEN
171: l_yield := TRUE;
172: ELSE
173: l_yield := FALSE;
174: END IF;
180: ,p_update_inv_ind => x_batch_header_rec.update_inventory_ind
181: ,x_exception_material_tbl => x_exception_material_tbl
182: ,x_return_status => l_return_status);
183:
184: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
185: x_return_status := l_return_status;
186: RAISE error_process_material;
187: END IF;
188:
185: x_return_status := l_return_status;
186: RAISE error_process_material;
187: END IF;
188:
189: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
190: x_return_status := gme_common_pvt.g_exceptions_err;
191: END IF;
192: -- Pawan Kumar added this for bug 5109095
193: ELSE -- of l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
186: RAISE error_process_material;
187: END IF;
188:
189: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
190: x_return_status := gme_common_pvt.g_exceptions_err;
191: END IF;
192: -- Pawan Kumar added this for bug 5109095
193: ELSE -- of l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
194: -- This will insert exception all completed step products and byprodcuts.
189: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
190: x_return_status := gme_common_pvt.g_exceptions_err;
191: END IF;
192: -- Pawan Kumar added this for bug 5109095
193: ELSE -- of l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
194: -- This will insert exception all completed step products and byprodcuts.
195: --Bug#5296812 Added the call to the item record.Added the condition to check the inv update ind,and transaction ind.Start
196: gme_material_detail_pvt.get_item_rec
197: (p_org_id => l_matl_dtl_rec.organization_id
203: RAISE error_get_item;
204: END IF;
205: IF p_batch_header_rec.update_inventory_ind = 'Y' AND l_item_rec.mtl_transactions_enabled_flag = 'Y' THEN
206: --Bug#5296812 End.
207: IF l_step_status = gme_common_pvt.g_step_completed THEN
208:
209: l_exception_qty := l_matl_dtl_rec.wip_plan_qty - l_matl_dtl_rec.actual_qty;
210:
211: IF l_exception_qty < 0 THEN
228: ,p_force_unconsumed => fnd_api.g_false
229: ,x_exception_material_tbl => x_exception_material_tbl
230: ,x_return_status => l_return_status);
231:
232: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
233: x_return_status := l_return_status;
234: RAISE error_complete_batch;
235: END IF;
236:
233: x_return_status := l_return_status;
234: RAISE error_complete_batch;
235: END IF;
236:
237: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
238: x_return_status := gme_common_pvt.g_exceptions_err;
239: END IF;
240:
241: END IF;-- IF l_step_status = gme_common_pvt.g_step_completed THEN
234: RAISE error_complete_batch;
235: END IF;
236:
237: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
238: x_return_status := gme_common_pvt.g_exceptions_err;
239: END IF;
240:
241: END IF;-- IF l_step_status = gme_common_pvt.g_step_completed THEN
242: END IF;--IF p_batch_header_rec.update_inventory_ind = 'Y'.....
237: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
238: x_return_status := gme_common_pvt.g_exceptions_err;
239: END IF;
240:
241: END IF;-- IF l_step_status = gme_common_pvt.g_step_completed THEN
242: END IF;--IF p_batch_header_rec.update_inventory_ind = 'Y'.....
243: -- Pawan Kumar added above for bug 5109095
244: END IF; -- IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
245: END IF; -- IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod)
240:
241: END IF;-- IF l_step_status = gme_common_pvt.g_step_completed THEN
242: END IF;--IF p_batch_header_rec.update_inventory_ind = 'Y'.....
243: -- Pawan Kumar added above for bug 5109095
244: END IF; -- IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
245: END IF; -- IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod)
246: END LOOP;
247:
248: -- Complete any steps that are not complete or closed
241: END IF;-- IF l_step_status = gme_common_pvt.g_step_completed THEN
242: END IF;--IF p_batch_header_rec.update_inventory_ind = 'Y'.....
243: -- Pawan Kumar added above for bug 5109095
244: END IF; -- IF l_yield_type <> gme_common_pvt.g_mtl_autobystep_release THEN
245: END IF; -- IF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod)
246: END LOOP;
247:
248: -- Complete any steps that are not complete or closed
249: OPEN Cur_get_step_to_complete(p_batch_header_rec.batch_id);
259: ,x_batch_step_rec => l_batch_step_rec
260: ,x_exception_material_tbl => x_exception_material_tbl
261: ,x_return_status => l_return_status);
262:
263: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
264: x_return_status := l_return_status;
265: RAISE error_complete_step_rec;
266: END IF;
267:
264: x_return_status := l_return_status;
265: RAISE error_complete_step_rec;
266: END IF;
267:
268: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
269: x_return_status := gme_common_pvt.g_exceptions_err;
270: END IF;
271: END LOOP;
272:
265: RAISE error_complete_step_rec;
266: END IF;
267:
268: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
269: x_return_status := gme_common_pvt.g_exceptions_err;
270: END IF;
271: END LOOP;
272:
273: -- Complete any phantom batches that are not complete or closed
284: ,x_exception_material_tbl => x_exception_material_tbl
285: ,x_batch_header_rec => l_btch_hdr
286: ,x_return_status => l_return_status);
287:
288: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
289: x_return_status := l_return_status;
290: RAISE error_complete_batch;
291: END IF;
292:
289: x_return_status := l_return_status;
290: RAISE error_complete_batch;
291: END IF;
292:
293: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
294: x_return_status := gme_common_pvt.g_exceptions_err;
295: END IF;
296:
297: END LOOP; -- FOR i IN 1..l_btch_hdr_tab.COUNT LOOP
290: RAISE error_complete_batch;
291: END IF;
292:
293: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
294: x_return_status := gme_common_pvt.g_exceptions_err;
295: END IF;
296:
297: END LOOP; -- FOR i IN 1..l_btch_hdr_tab.COUNT LOOP
298:
300: -- phantom products are reported at the time of yield, so don't double report with phantom ingredient
301: -- all other products are reported in either process material (non auto yield) or yield_material (auto yield)
302: FOR i IN 1..l_matl_dtl_tab_ing.COUNT LOOP
303: l_matl_dtl_rec := l_matl_dtl_tab_ing(i);
304: IF l_matl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing THEN
305: -- don't check for unconsumed first because even if it's fully consumed,
306: -- but has reservation or MO, want to report it
307: --Bug#5296812 Added the call to the item record.Added the condition to check the inv update ind,and transaction ind.Start.
308: gme_material_detail_pvt.get_item_rec
339: ,p_force_unconsumed => fnd_api.g_false
340: ,x_exception_material_tbl => x_exception_material_tbl
341: ,x_return_status => l_return_status);
342:
343: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
344: x_return_status := l_return_status;
345: RAISE error_complete_batch;
346: END IF;
347:
344: x_return_status := l_return_status;
345: RAISE error_complete_batch;
346: END IF;
347:
348: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
349: x_return_status := gme_common_pvt.g_exceptions_err;
350: END IF;
351: END IF; --IF p_batch_header_rec.update_inventory_ind = 'Y'...
352: END IF;
345: RAISE error_complete_batch;
346: END IF;
347:
348: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
349: x_return_status := gme_common_pvt.g_exceptions_err;
350: END IF;
351: END IF; --IF p_batch_header_rec.update_inventory_ind = 'Y'...
352: END IF;
353: END LOOP;
351: END IF; --IF p_batch_header_rec.update_inventory_ind = 'Y'...
352: END IF;
353: END LOOP;
354:
355: IF NOT gme_common_pvt.create_history
356: (p_batch_header_rec => p_batch_header_rec
357: ,p_original_status => gme_common_pvt.g_batch_wip
358: ,p_event_id => NVL(gme_common_pvt.g_transaction_header_id,-9999)) THEN
359: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
353: END LOOP;
354:
355: IF NOT gme_common_pvt.create_history
356: (p_batch_header_rec => p_batch_header_rec
357: ,p_original_status => gme_common_pvt.g_batch_wip
358: ,p_event_id => NVL(gme_common_pvt.g_transaction_header_id,-9999)) THEN
359: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
360: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' create history returned error');
361: END IF;
354:
355: IF NOT gme_common_pvt.create_history
356: (p_batch_header_rec => p_batch_header_rec
357: ,p_original_status => gme_common_pvt.g_batch_wip
358: ,p_event_id => NVL(gme_common_pvt.g_transaction_header_id,-9999)) THEN
359: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
360: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' create history returned error');
361: END IF;
362: END IF;
366: END IF;
367:
368: EXCEPTION
369: WHEN error_update_batch THEN
370: gme_common_pvt.log_message ('GME_UNEXPECTED_ERROR', 'ERROR', SQLERRM);
371: x_return_status := FND_API.g_ret_sts_unexp_error;
372: --Bug#5296812 Handling the raised exception error_get_item.
373: WHEN error_process_material OR error_complete_batch OR
374: error_complete_step_rec OR error_release_batch OR error_get_item THEN
373: WHEN error_process_material OR error_complete_batch OR
374: error_complete_step_rec OR error_release_batch OR error_get_item THEN
375: NULL;
376: WHEN locked_by_other_user or batch_lines_locked THEN
377: gme_common_pvt.log_message (
378: 'GME_RECORD_LOCKED',
379: 'TABLE_NAME',
380: l_table_name
381: );
393: (p_material_detail_rec IN gme_material_details%ROWTYPE
394: ,p_yield IN BOOLEAN
395: ,p_trans_date IN DATE
396: ,p_update_inv_ind IN VARCHAR2
397: ,x_exception_material_tbl IN OUT NOCOPY gme_common_pvt.exceptions_tab
398: ,x_return_status OUT NOCOPY VARCHAR2) IS
399:
400:
401: l_api_name CONSTANT VARCHAR2 (30) := 'process_material';
437: -- if it's a phantom ingredient, then complete the phantom batch
438: -- which will cause the phantom product to be yielded (the passed in ingredient will be consumed in trxm mgr
439:
440: -- complete phantom batch
441: IF l_matl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing AND l_matl_dtl_rec.phantom_id IS NOT NULL THEN -- phantom ingredient -> complete the phantom batch
442: l_phantom_batch_rec.batch_id := l_matl_dtl_rec.phantom_id;
443: IF NOT gme_batch_header_dbl.fetch_row(l_phantom_batch_rec, l_phantom_batch_rec) THEN
444: RAISE error_fetch_batch;
445: END IF;
443: IF NOT gme_batch_header_dbl.fetch_row(l_phantom_batch_rec, l_phantom_batch_rec) THEN
444: RAISE error_fetch_batch;
445: END IF;
446:
447: IF l_phantom_batch_rec.batch_status IN (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip) THEN
448: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
449: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' processing phantom ingredient material_detail_id='||l_matl_dtl_rec.material_detail_id);
450: END IF;
451: -- pass in the phantom line id so that release batch will know to yield that product
459: ,x_exception_material_tbl => x_exception_material_tbl
460: ,x_batch_header_rec => l_phantom_batch_rec
461: ,x_return_status => l_return_status);
462:
463: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
464: x_return_status := l_return_status;
465: RAISE error_complete_batch;
466: END IF;
467:
464: x_return_status := l_return_status;
465: RAISE error_complete_batch;
466: END IF;
467:
468: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
469: x_return_status := gme_common_pvt.g_exceptions_err;
470: END IF;
471: END IF; -- IF l_phantom_batch_rec.batch_status IN (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip)
472: ELSIF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) AND p_yield THEN
465: RAISE error_complete_batch;
466: END IF;
467:
468: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
469: x_return_status := gme_common_pvt.g_exceptions_err;
470: END IF;
471: END IF; -- IF l_phantom_batch_rec.batch_status IN (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip)
472: ELSIF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) AND p_yield THEN
473: gme_material_detail_pvt.get_item_rec
467:
468: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
469: x_return_status := gme_common_pvt.g_exceptions_err;
470: END IF;
471: END IF; -- IF l_phantom_batch_rec.batch_status IN (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip)
472: ELSIF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) AND p_yield THEN
473: gme_material_detail_pvt.get_item_rec
474: (p_org_id => l_matl_dtl_rec.organization_id
475: ,p_item_id => l_matl_dtl_rec.inventory_item_id
468: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
469: x_return_status := gme_common_pvt.g_exceptions_err;
470: END IF;
471: END IF; -- IF l_phantom_batch_rec.batch_status IN (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip)
472: ELSIF l_matl_dtl_rec.line_type IN (gme_common_pvt.g_line_type_prod, gme_common_pvt.g_line_type_byprod) AND p_yield THEN
473: gme_material_detail_pvt.get_item_rec
474: (p_org_id => l_matl_dtl_rec.organization_id
475: ,p_item_id => l_matl_dtl_rec.inventory_item_id
476: ,x_item_rec => l_item_rec
492: ,x_exception_material_tbl => x_exception_material_tbl
493: ,x_actual_qty => l_actual_qty
494: ,x_return_status => l_return_status);
495:
496: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
497: x_return_status := l_return_status;
498: RAISE error_yield_material;
499: END IF;
500:
497: x_return_status := l_return_status;
498: RAISE error_yield_material;
499: END IF;
500:
501: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
502: x_return_status := gme_common_pvt.g_exceptions_err;
503: END IF;
504:
505: l_matl_dtl_rec.actual_qty := l_actual_qty;
498: RAISE error_yield_material;
499: END IF;
500:
501: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
502: x_return_status := gme_common_pvt.g_exceptions_err;
503: END IF;
504:
505: l_matl_dtl_rec.actual_qty := l_actual_qty;
506:
523: ,p_force_unconsumed => fnd_api.g_false
524: ,x_exception_material_tbl => x_exception_material_tbl
525: ,x_return_status => l_return_status);
526:
527: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
528: x_return_status := l_return_status;
529: RAISE error_yield_material;
530: END IF;
531:
528: x_return_status := l_return_status;
529: RAISE error_yield_material;
530: END IF;
531:
532: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
533: x_return_status := gme_common_pvt.g_exceptions_err;
534: END IF;
535: END IF;
536:
529: RAISE error_yield_material;
530: END IF;
531:
532: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
533: x_return_status := gme_common_pvt.g_exceptions_err;
534: END IF;
535: END IF;
536:
537: ELSE
572: ,p_force_unconsumed => fnd_api.g_false
573: ,x_exception_material_tbl => x_exception_material_tbl
574: ,x_return_status => l_return_status);
575:
576: IF l_return_status NOT IN (FND_API.G_RET_STS_SUCCESS, gme_common_pvt.g_exceptions_err) THEN
577: x_return_status := l_return_status;
578: RAISE error_batch_exception;
579: END IF;
580:
577: x_return_status := l_return_status;
578: RAISE error_batch_exception;
579: END IF;
580:
581: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
582: x_return_status := gme_common_pvt.g_exceptions_err;
583: END IF;
584: END IF;--IF p_update_inv_ind = 'Y' AND...
585: END IF; -- IF l_matl_dtl_rec.phantom_id IS NOT NULL...
578: RAISE error_batch_exception;
579: END IF;
580:
581: IF l_return_status = gme_common_pvt.g_exceptions_err THEN
582: x_return_status := gme_common_pvt.g_exceptions_err;
583: END IF;
584: END IF;--IF p_update_inv_ind = 'Y' AND...
585: END IF; -- IF l_matl_dtl_rec.phantom_id IS NOT NULL...
586:
596: END IF;
597:
598: EXCEPTION
599: WHEN error_fetch_batch OR error_update_row THEN
600: gme_common_pvt.log_message ('GME_UNEXPECTED_ERROR', 'ERROR', SQLERRM);
601: x_return_status := FND_API.g_ret_sts_unexp_error;
602: WHEN error_complete_batch OR error_yield_material OR error_get_item OR error_batch_exception THEN
603: NULL;
604: WHEN OTHERS THEN
615: ,p_yield_qty IN NUMBER
616: ,p_trans_date IN DATE
617: ,p_item_rec IN mtl_system_items_b%ROWTYPE
618: ,p_force_unconsumed IN VARCHAR2
619: ,x_exception_material_tbl IN OUT NOCOPY gme_common_pvt.exceptions_tab
620: ,x_actual_qty OUT NOCOPY NUMBER
621: ,x_return_status OUT NOCOPY VARCHAR2) IS
622:
623: l_api_name CONSTANT VARCHAR2 (30) := 'YIELD_MATERIAL';
621: ,x_return_status OUT NOCOPY VARCHAR2) IS
622:
623: l_api_name CONSTANT VARCHAR2 (30) := 'YIELD_MATERIAL';
624:
625: l_pending_product_lot_tab gme_common_pvt.pending_lots_tab;
626: l_pp_lot_rec gme_pending_product_lots%ROWTYPE;
627: i NUMBER;
628:
629: l_yield_qty NUMBER;
639: SELECT revision
640: FROM mtl_item_revisions_b
641: WHERE inventory_item_id = v_item_id
642: AND organization_id = v_org_id
643: AND effectivity_date <= gme_common_pvt.g_timestamp
644: ORDER BY effectivity_date desc;
645:
646: error_build_trxn EXCEPTION;
647: error_get_exception EXCEPTION;
678: So this was not getting caught in l_yield_qty <= x_actual_qty and this was
679: sending transaction quantity as null to transactions where it was failing*/
680:
681: l_yield_qty := NVL(p_yield_qty, nvl(p_material_dtl_rec.wip_plan_qty,p_material_dtl_rec.plan_qty));
682: l_trans_date := NVL(p_trans_date, gme_common_pvt.g_timestamp);
683:
684: l_start_actual_qty := x_actual_qty;
685:
686: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
705: IF p_material_dtl_rec.locator_id IS NULL THEN
706: -- check if it's locator control, we need a locator...
707: /* Bug 5441643 Added NVL condition for location control code*/
708: l_eff_locator_control :=
709: gme_common_pvt.eff_locator_control
710: (p_organization_id => p_material_dtl_rec.organization_id
711: ,p_org_control => gme_common_pvt.g_org_locator_control
712: ,p_subinventory => p_material_dtl_rec.subinventory
713: ,p_item_control => NVL(p_item_rec.location_control_code,1)
707: /* Bug 5441643 Added NVL condition for location control code*/
708: l_eff_locator_control :=
709: gme_common_pvt.eff_locator_control
710: (p_organization_id => p_material_dtl_rec.organization_id
711: ,p_org_control => gme_common_pvt.g_org_locator_control
712: ,p_subinventory => p_material_dtl_rec.subinventory
713: ,p_item_control => NVL(p_item_rec.location_control_code,1)
714: ,p_item_loc_restrict => p_item_rec.restrict_locators_code
715: ,p_action => gme_common_pvt.g_prod_comp_txn_action);
711: ,p_org_control => gme_common_pvt.g_org_locator_control
712: ,p_subinventory => p_material_dtl_rec.subinventory
713: ,p_item_control => NVL(p_item_rec.location_control_code,1)
714: ,p_item_loc_restrict => p_item_rec.restrict_locators_code
715: ,p_action => gme_common_pvt.g_prod_comp_txn_action);
716: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
717: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' l_eff_locator_control='||l_eff_locator_control);
718: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id='||p_material_dtl_rec.organization_id);
719: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' g_org_locator_control='||gme_common_pvt.g_org_locator_control);
715: ,p_action => gme_common_pvt.g_prod_comp_txn_action);
716: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
717: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' l_eff_locator_control='||l_eff_locator_control);
718: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' organization_id='||p_material_dtl_rec.organization_id);
719: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' g_org_locator_control='||gme_common_pvt.g_org_locator_control);
720: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' subinventory='||p_material_dtl_rec.subinventory);
721: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id='||p_item_rec.inventory_item_id);
722: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' location_control_code='||p_item_rec.location_control_code);
723: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' restrict_locators_code='||p_item_rec.restrict_locators_code);
720: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' subinventory='||p_material_dtl_rec.subinventory);
721: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' inventory_item_id='||p_item_rec.inventory_item_id);
722: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' location_control_code='||p_item_rec.location_control_code);
723: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' restrict_locators_code='||p_item_rec.restrict_locators_code);
724: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' p_action='||gme_common_pvt.g_prod_comp_txn_action);
725: END IF;
726: IF l_eff_locator_control <> 1 THEN
727: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
728: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' locator on material is NULL and material is eff locator control; cant yield anything; get exceptions');
761: ,p_sec_uom_code => p_item_rec.secondary_uom_code
762: ,x_actual_qty => x_actual_qty
763: ,x_return_status => l_return_status);
764:
765: IF l_return_status NOT IN (gme_common_pvt.g_not_transactable, FND_API.G_RET_STS_SUCCESS) THEN
766: x_return_status := l_return_status;
767: RAISE error_build_trxn;
768: END IF;
769: ELSE -- lot control... go to pending product lots
803: ,p_revision => l_revision
804: ,p_sec_uom_code => p_item_rec.secondary_uom_code
805: ,x_actual_qty => x_actual_qty
806: ,x_return_status => l_return_status);
807: IF l_return_status NOT IN (gme_common_pvt.g_not_transactable, FND_API.G_RET_STS_SUCCESS) THEN
808: x_return_status := l_return_status;
809: RAISE error_build_trxn;
810: END IF;
811:
871:
872: l_api_name CONSTANT VARCHAR2 (30) := 'build_and_create_transaction';
873:
874: l_transaction_rec mtl_transactions_interface%ROWTYPE;
875: l_lot_tbl gme_common_pvt.mtl_trans_lots_inter_tbl;
876: l_trxn_qty NUMBER;
877: l_dtl_qty NUMBER;
878: l_sec_qty NUMBER;
879:
927: l_sec_qty := INV_CONVERT.inv_um_convert
928: (item_id => p_mtl_dtl_rec.inventory_item_id
929: ,lot_number => p_pp_lot_rec.lot_number
930: ,organization_id => p_mtl_dtl_rec.organization_id
931: ,PRECISION => gme_common_pvt.g_precision
932: ,from_quantity => l_trxn_qty
933: ,from_unit => p_mtl_dtl_rec.dtl_um
934: ,to_unit => p_sec_uom_code
935: ,from_name => NULL
941: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' calculated l_trxn_qty := '||l_trxn_qty);
942: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' calculated l_sec_qty := '||l_sec_qty);
943: END IF;
944:
945: IF p_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod THEN
946: l_transaction_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
947: ELSE
948: l_transaction_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
949: END IF;
942: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' calculated l_sec_qty := '||l_sec_qty);
943: END IF;
944:
945: IF p_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod THEN
946: l_transaction_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
947: ELSE
948: l_transaction_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
949: END IF;
950:
944:
945: IF p_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod THEN
946: l_transaction_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
947: ELSE
948: l_transaction_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
949: END IF;
950:
951: IF ( NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT ) THEN
952: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' l_transaction_rec.transaction_type_id := '||l_transaction_rec.transaction_type_id);
1027: ,p_locator_id IN NUMBER
1028: ,p_revision IN VARCHAR2
1029: ,p_pp_lot_rec IN gme_pending_product_lots%ROWTYPE
1030: ,x_mmti_rec OUT NOCOPY mtl_transactions_interface%ROWTYPE
1031: ,x_mmli_tbl OUT NOCOPY gme_common_pvt.mtl_trans_lots_inter_tbl
1032: ,x_sec_qty OUT NOCOPY NUMBER
1033: ,x_dtl_qty OUT NOCOPY NUMBER
1034: ,x_return_status OUT NOCOPY VARCHAR2) IS
1035:
1087:
1088: CURSOR Cur_gme_batch_steps (v_batch_id NUMBER) IS
1089: SELECT count(1)
1090: FROM gme_batch_steps
1091: WHERE step_status NOT IN (gme_common_pvt.g_step_completed, gme_common_pvt.g_step_closed)
1092: AND batch_id = v_batch_id
1093: AND rownum = 1;
1094:
1095: l_is_step NUMBER;
1133: IF p_batch_header_rec.actual_cmplt_date IS NULL THEN
1134: x_batch_header_rec.actual_cmplt_date := SYSDATE;
1135: END IF;
1136:
1137: IF p_batch_header_rec.batch_type = gme_common_pvt.g_doc_type_fpo THEN
1138: RAISE error_batch_type;
1139: END IF;
1140:
1141: IF p_batch_header_rec.batch_status NOT IN
1138: RAISE error_batch_type;
1139: END IF;
1140:
1141: IF p_batch_header_rec.batch_status NOT IN
1142: (gme_common_pvt.g_batch_pending, gme_common_pvt.g_batch_wip) THEN
1143: RAISE error_batch_status;
1144: END IF;
1145:
1146: IF p_batch_header_rec.parentline_id IS NOT NULL THEN
1180: RAISE error_vr_dates;
1181: END IF;*/
1182: --sunitha ch. Bug 5336007 aded call to check_validity_rule_dates and passed p_validate_plan_dates_ind=1
1183: --to validate planned start date against validate rule dates
1184: IF NOT gme_common_pvt.check_validity_rule_dates (
1185: p_validity_rule_id => p_batch_header_rec.recipe_validity_rule_id
1186: ,p_start_date => p_batch_header_rec.actual_start_date
1187: ,p_cmplt_date => p_batch_header_rec.actual_cmplt_date
1188: ,p_batch_header_rec => p_batch_header_rec
1206: END IF;
1207:
1208: EXCEPTION
1209: WHEN error_phantom THEN
1210: gme_common_pvt.log_message ('PM_INVALID_PHANTOM_ACTION');
1211: x_return_status := FND_API.G_RET_STS_ERROR;
1212: WHEN error_batch_type OR error_batch_status THEN
1213: gme_common_pvt.log_message('GME_API_INVALID_BATCH_COMPL');
1214: x_return_status := fnd_api.g_ret_sts_error;
1209: WHEN error_phantom THEN
1210: gme_common_pvt.log_message ('PM_INVALID_PHANTOM_ACTION');
1211: x_return_status := FND_API.G_RET_STS_ERROR;
1212: WHEN error_batch_type OR error_batch_status THEN
1213: gme_common_pvt.log_message('GME_API_INVALID_BATCH_COMPL');
1214: x_return_status := fnd_api.g_ret_sts_error;
1215: WHEN error_steps_not_complete THEN
1216: gme_common_pvt.log_message('GME_STEPS_NOT_COMPLETE');
1217: x_return_status := fnd_api.g_ret_sts_error;
1212: WHEN error_batch_type OR error_batch_status THEN
1213: gme_common_pvt.log_message('GME_API_INVALID_BATCH_COMPL');
1214: x_return_status := fnd_api.g_ret_sts_error;
1215: WHEN error_steps_not_complete THEN
1216: gme_common_pvt.log_message('GME_STEPS_NOT_COMPLETE');
1217: x_return_status := fnd_api.g_ret_sts_error;
1218: WHEN error_cmplt_date THEN
1219: gme_common_pvt.log_message('GME_INVALID_DATE_RANGE'
1220: ,'DATE1','Completion date'
1215: WHEN error_steps_not_complete THEN
1216: gme_common_pvt.log_message('GME_STEPS_NOT_COMPLETE');
1217: x_return_status := fnd_api.g_ret_sts_error;
1218: WHEN error_cmplt_date THEN
1219: gme_common_pvt.log_message('GME_INVALID_DATE_RANGE'
1220: ,'DATE1','Completion date'
1221: ,'DATE2','Start date');
1222: x_return_status := fnd_api.g_ret_sts_error;
1223: WHEN error_future_date THEN