51: ,p_validity_rule_id IN NUMBER
52: ,p_use_workday_cal IN VARCHAR2
53: ,p_contiguity_override IN VARCHAR2
54: ,p_use_least_cost_validity_rule IN VARCHAR2 := fnd_api.g_false
55: ,x_exception_material_tbl OUT NOCOPY gme_common_pvt.exceptions_tab
56: ,x_return_status OUT NOCOPY VARCHAR2)
57: IS
58: l_api_name CONSTANT VARCHAR2 (30) := 'CREATE_PHANTOM';
59: /* Exception definitions */
98: SELECT material_detail_id
99: FROM gme_material_details
100: WHERE batch_id = v_batch_id
101: AND inventory_item_id = v_inventory_item_id
102: AND line_type = gme_common_pvt.g_line_type_prod
103: ORDER BY line_no;
104: BEGIN
105: IF g_debug <= gme_debug.g_log_procedure THEN
106: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
125: l_phant_batch := p_batch_header_rec;
126:
127: /* Check for phantom specific validations */
128: IF x_material_detail_rec.phantom_type = 0 THEN
129: gme_common_pvt.log_message ('PM_NOTAPHANTOM');
130: RAISE not_a_phantom;
131: ELSIF NVL (x_material_detail_rec.phantom_id, 0) > 0 THEN
132: gme_common_pvt.log_message ('PM_PHANTOM_EXISTS');
133: RAISE phantom_exists;
128: IF x_material_detail_rec.phantom_type = 0 THEN
129: gme_common_pvt.log_message ('PM_NOTAPHANTOM');
130: RAISE not_a_phantom;
131: ELSIF NVL (x_material_detail_rec.phantom_id, 0) > 0 THEN
132: gme_common_pvt.log_message ('PM_PHANTOM_EXISTS');
133: RAISE phantom_exists;
134: END IF;
135:
136: /* No need for scrap factor since plan_qty now includes scrap factor */
139: /* Check for the validity rule passed in */
140: IF p_validity_rule_id IS NULL THEN
141: IF l_batch_header.laboratory_ind = 1 THEN
142: l_object_type := 'L';
143: ELSIF l_batch_header.batch_type = gme_common_pvt.g_doc_type_fpo THEN
144: l_object_type := 'F';
145: ELSE
146: l_object_type := 'P';
147: END IF;
198: l_phant_batch.batch_no := p_batch_no;
199: l_phant_batch.recipe_validity_rule_id := l_validity_rule_id;
200:
201: IF x_material_detail_rec.release_type IN
202: (gme_common_pvt.g_mtl_autobystep_release
203: ,gme_common_pvt.g_mtl_incremental_release
204: ,gme_common_pvt.g_mtl_manual_release) THEN
205: OPEN cur_step_matl_detail (x_material_detail_rec.material_detail_id);
206:
199: l_phant_batch.recipe_validity_rule_id := l_validity_rule_id;
200:
201: IF x_material_detail_rec.release_type IN
202: (gme_common_pvt.g_mtl_autobystep_release
203: ,gme_common_pvt.g_mtl_incremental_release
204: ,gme_common_pvt.g_mtl_manual_release) THEN
205: OPEN cur_step_matl_detail (x_material_detail_rec.material_detail_id);
206:
207: FETCH cur_step_matl_detail
200:
201: IF x_material_detail_rec.release_type IN
202: (gme_common_pvt.g_mtl_autobystep_release
203: ,gme_common_pvt.g_mtl_incremental_release
204: ,gme_common_pvt.g_mtl_manual_release) THEN
205: OPEN cur_step_matl_detail (x_material_detail_rec.material_detail_id);
206:
207: FETCH cur_step_matl_detail
208: INTO l_step_rec;
246: || x_return_status);
247: END IF;
248:
249: IF x_return_status <> fnd_api.g_ret_sts_success
250: AND x_return_status <> gme_common_pvt.g_inv_short_err THEN
251: ROLLBACK TO SAVEPOINT create_auto_phantom;
252: RAISE batch_creation_failed;
253: END IF;
254:
252: RAISE batch_creation_failed;
253: END IF;
254:
255: l_phant_batch.parentline_id := p_material_detail_rec.material_detail_id;
256: l_phant_batch.last_update_date := gme_common_pvt.g_timestamp;
257:
258: IF NOT gme_batch_header_dbl.update_row (p_batch_header => l_phant_batch) THEN
259: RAISE batch_upd_error;
260: END IF;
271: SET phantom_line_id = p_material_detail_rec.material_detail_id
272: ,release_type = x_material_detail_rec.release_type
273: ,subinventory = x_material_detail_rec.subinventory
274: ,locator_id = x_material_detail_rec.locator_id
275: ,last_update_date = gme_common_pvt.g_timestamp
276: ,last_updated_by = gme_common_pvt.g_user_ident
277: ,last_update_login = gme_common_pvt.g_login_id
278: WHERE material_detail_id = l_prod_mtl_dtl_id;
279:
272: ,release_type = x_material_detail_rec.release_type
273: ,subinventory = x_material_detail_rec.subinventory
274: ,locator_id = x_material_detail_rec.locator_id
275: ,last_update_date = gme_common_pvt.g_timestamp
276: ,last_updated_by = gme_common_pvt.g_user_ident
277: ,last_update_login = gme_common_pvt.g_login_id
278: WHERE material_detail_id = l_prod_mtl_dtl_id;
279:
280: x_material_detail_rec.phantom_id := l_phant_batch.batch_id;
273: ,subinventory = x_material_detail_rec.subinventory
274: ,locator_id = x_material_detail_rec.locator_id
275: ,last_update_date = gme_common_pvt.g_timestamp
276: ,last_updated_by = gme_common_pvt.g_user_ident
277: ,last_update_login = gme_common_pvt.g_login_id
278: WHERE material_detail_id = l_prod_mtl_dtl_id;
279:
280: x_material_detail_rec.phantom_id := l_phant_batch.batch_id;
281: x_material_detail_rec.phantom_line_id := l_prod_mtl_dtl_id;
282:
283: UPDATE gme_material_details
284: SET phantom_line_id = l_prod_mtl_dtl_id
285: ,phantom_id = l_phant_batch.batch_id
286: ,last_update_date = gme_common_pvt.g_timestamp
287: ,last_updated_by = gme_common_pvt.g_user_ident
288: ,last_update_login = gme_common_pvt.g_login_id
289: WHERE material_detail_id = p_material_detail_rec.material_detail_id;
290:
283: UPDATE gme_material_details
284: SET phantom_line_id = l_prod_mtl_dtl_id
285: ,phantom_id = l_phant_batch.batch_id
286: ,last_update_date = gme_common_pvt.g_timestamp
287: ,last_updated_by = gme_common_pvt.g_user_ident
288: ,last_update_login = gme_common_pvt.g_login_id
289: WHERE material_detail_id = p_material_detail_rec.material_detail_id;
290:
291: x_return_status := fnd_api.g_ret_sts_success;
284: SET phantom_line_id = l_prod_mtl_dtl_id
285: ,phantom_id = l_phant_batch.batch_id
286: ,last_update_date = gme_common_pvt.g_timestamp
287: ,last_updated_by = gme_common_pvt.g_user_ident
288: ,last_update_login = gme_common_pvt.g_login_id
289: WHERE material_detail_id = p_material_detail_rec.material_detail_id;
290:
291: x_return_status := fnd_api.g_ret_sts_success;
292:
389: PROCEDURE fetch_step_phantoms (
390: p_batch_id IN NUMBER
391: ,p_batchstep_id IN NUMBER
392: ,p_all_release_type_assoc IN NUMBER DEFAULT 0
393: ,x_phantom_ids OUT NOCOPY gme_common_pvt.number_tab
394: ,x_return_status OUT NOCOPY VARCHAR2)
395: IS
396: l_api_name CONSTANT VARCHAR2 (30) := 'FETCH_STEP_PHANTOMS';
397:
403: FROM gme_batch_step_items i, gme_material_details d
404: WHERE d.batch_id = v_batch_id
405: AND i.material_detail_id = d.material_detail_id
406: AND batchstep_id = v_batchstep_id
407: AND ( d.release_type = gme_common_pvt.g_mtl_autobystep_release
408: OR ( d.release_type IN
409: (gme_common_pvt.g_mtl_manual_release
410: ,gme_common_pvt.g_mtl_incremental_release)
411: AND p_all_release_type_assoc = 1) )
405: AND i.material_detail_id = d.material_detail_id
406: AND batchstep_id = v_batchstep_id
407: AND ( d.release_type = gme_common_pvt.g_mtl_autobystep_release
408: OR ( d.release_type IN
409: (gme_common_pvt.g_mtl_manual_release
410: ,gme_common_pvt.g_mtl_incremental_release)
411: AND p_all_release_type_assoc = 1) )
412: AND NVL (d.phantom_id, 0) > 0;
413:
406: AND batchstep_id = v_batchstep_id
407: AND ( d.release_type = gme_common_pvt.g_mtl_autobystep_release
408: OR ( d.release_type IN
409: (gme_common_pvt.g_mtl_manual_release
410: ,gme_common_pvt.g_mtl_incremental_release)
411: AND p_all_release_type_assoc = 1) )
412: AND NVL (d.phantom_id, 0) > 0;
413:
414: no_keys EXCEPTION;
436: END IF;
437: EXCEPTION
438: WHEN no_keys THEN
439: x_return_status := fnd_api.g_ret_sts_error;
440: gme_common_pvt.log_message ('GME_NO_KEYS'
441: ,'TABLE_NAME'
442: ,'FETCH_STEP_PHANTOMS');
443: WHEN OTHERS THEN
444: IF g_debug <= gme_debug.g_log_unexpected THEN
471: =============================================================================================*/
472: PROCEDURE fetch_line_phantoms (
473: p_batch_id IN NUMBER
474: ,p_include_step IN BOOLEAN DEFAULT TRUE
475: ,x_phantom_ids OUT NOCOPY gme_common_pvt.number_tab
476: ,x_return_status OUT NOCOPY VARCHAR2)
477: IS
478: l_api_name CONSTANT VARCHAR2 (30) := 'FETCH_LINE_PHANTOMS';
479:
499: END IF;
500:
501: IF p_include_step THEN
502: OPEN cur_matl_phant_ids (p_batch_id
503: ,gme_common_pvt.g_mtl_autobystep_release);
504: ELSE
505: OPEN cur_matl_phant_ids (p_batch_id
506: ,gme_common_pvt.g_mtl_incremental_release);
507: END IF;
502: OPEN cur_matl_phant_ids (p_batch_id
503: ,gme_common_pvt.g_mtl_autobystep_release);
504: ELSE
505: OPEN cur_matl_phant_ids (p_batch_id
506: ,gme_common_pvt.g_mtl_incremental_release);
507: END IF;
508:
509: FETCH cur_matl_phant_ids
510: BULK COLLECT INTO x_phantom_ids;
516: END IF;
517: EXCEPTION
518: WHEN no_keys THEN
519: x_return_status := fnd_api.g_ret_sts_error;
520: gme_common_pvt.log_message ('GME_NO_KEYS'
521: ,'TABLE_NAME'
522: ,'FETCH_LINE_PHANTOMS');
523: WHEN OTHERS THEN
524: IF g_debug <= gme_debug.g_log_unexpected THEN