15: l_api_name CONSTANT VARCHAR2 (30) := 'insert_material_line';
16: l_material_detail_rec gme_material_details%ROWTYPE;
17: l_batchstep_items gme_batch_step_items%ROWTYPE;
18: l_batch_step_rec gme_batch_steps%ROWTYPE;
19: l_out_material_detail_tbl gme_common_pvt.material_details_tab;
20: l_material_detail_tbl gme_common_pvt.material_details_tab;
21: l_recipe_id NUMBER;
22: l_message_count NUMBER;
23: l_message_list VARCHAR2 (2000);
16: l_material_detail_rec gme_material_details%ROWTYPE;
17: l_batchstep_items gme_batch_step_items%ROWTYPE;
18: l_batch_step_rec gme_batch_steps%ROWTYPE;
19: l_out_material_detail_tbl gme_common_pvt.material_details_tab;
20: l_material_detail_tbl gme_common_pvt.material_details_tab;
21: l_recipe_id NUMBER;
22: l_message_count NUMBER;
23: l_message_list VARCHAR2 (2000);
24: l_proc VARCHAR2 (100);
51:
52: -- renumber subsequent lines
53: UPDATE gme_material_details
54: SET line_no = line_no + 1
55: ,last_updated_by = gme_common_pvt.g_user_ident
56: ,last_update_date = gme_common_pvt.g_timestamp
57: ,last_update_login = gme_common_pvt.g_login_id
58: WHERE batch_id = p_material_detail_rec.batch_id
59: AND line_type = p_material_detail_rec.line_type
52: -- renumber subsequent lines
53: UPDATE gme_material_details
54: SET line_no = line_no + 1
55: ,last_updated_by = gme_common_pvt.g_user_ident
56: ,last_update_date = gme_common_pvt.g_timestamp
57: ,last_update_login = gme_common_pvt.g_login_id
58: WHERE batch_id = p_material_detail_rec.batch_id
59: AND line_type = p_material_detail_rec.line_type
60: AND line_no >= p_material_detail_rec.line_no;
53: UPDATE gme_material_details
54: SET line_no = line_no + 1
55: ,last_updated_by = gme_common_pvt.g_user_ident
56: ,last_update_date = gme_common_pvt.g_timestamp
57: ,last_update_login = gme_common_pvt.g_login_id
58: WHERE batch_id = p_material_detail_rec.batch_id
59: AND line_type = p_material_detail_rec.line_type
60: AND line_no >= p_material_detail_rec.line_no;
61:
106: END IF;
107:
108: l_material_detail_rec := x_material_detail_rec;
109:
110: gme_common_pvt.calc_mtl_req_date
111: (p_batch_header_rec => p_batch_header_rec
112: ,p_batchstep_rec => p_batch_step_rec
113: ,p_mtl_dtl_rec => l_material_detail_rec
114: ,x_mtl_req_date => x_material_detail_rec.material_requirement_date
114: ,x_mtl_req_date => x_material_detail_rec.material_requirement_date
115: ,x_return_status => x_return_status);
116:
117: IF x_return_status <> fnd_api.g_ret_sts_success THEN
118: l_proc := 'gme_common_pvt.calc_mtl_req_date';
119: RAISE error_processing;
120: END IF;
121:
122: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
124: || TO_CHAR(x_material_detail_rec.material_requirement_date,
125: gme_material_detail_pvt.g_date_fmt));
126: END IF;
127: /* Bug 4866700 added update inventory check */
128: IF x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing AND
129: x_material_detail_rec.phantom_type = 0 AND
130: p_batch_header_rec.update_inventory_ind = 'Y' THEN
131: l_material_detail_tbl (1) := x_material_detail_rec;
132:
132:
133: -- add material line into invisible move order
134: gme_move_orders_pvt.create_move_order_lines
135: (p_move_order_header_id => p_batch_header_rec.move_order_header_id
136: ,p_move_order_type => gme_common_pvt.g_invis_move_order_type
137: ,p_material_details_tbl => l_material_detail_tbl
138: ,x_material_details_tbl => l_out_material_detail_tbl
139: ,x_trolin_tbl => l_trolin_tbl
140: ,x_return_status => x_return_status);
248: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
249: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': ' || l_proc|| ' error returned');
250: END IF;
251: WHEN error_dbl THEN
252: gme_common_pvt.log_message ('GME_UNEXPECTED_ERROR', 'ERROR', SQLERRM);
253: x_return_status := FND_API.g_ret_sts_unexp_error;
254:
255: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
256: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': '
257: || l_proc|| ' unexpected error: '|| SQLERRM);
258: END IF;
259:
260: WHEN error_dispensing THEN
261: gme_common_pvt.log_message ('GME_DISPENSE_NON_RESERVE');
262: x_return_status := l_return_status;
263: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
264: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': '
265: || l_proc|| 'Dispensing error returned ');
293: x_return_status := FND_API.G_RET_STS_SUCCESS;
294:
295: --Bug#5078853 added check for invalid batch type
296: IF p_batch_header_rec.batch_type <> 0 THEN
297: gme_common_pvt.log_message ('GME_INV_BATCH_TYPE_OPER');
298: RAISE validation_error;
299: END IF;
300:
301: IF (p_batch_header_rec.batch_status NOT IN
298: RAISE validation_error;
299: END IF;
300:
301: IF (p_batch_header_rec.batch_status NOT IN
302: (gme_common_pvt.g_batch_pending
303: ,gme_common_pvt.g_batch_wip
304: ,gme_common_pvt.g_batch_completed )) THEN
305: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
306: RAISE validation_error;
299: END IF;
300:
301: IF (p_batch_header_rec.batch_status NOT IN
302: (gme_common_pvt.g_batch_pending
303: ,gme_common_pvt.g_batch_wip
304: ,gme_common_pvt.g_batch_completed )) THEN
305: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
306: RAISE validation_error;
307: END IF;
300:
301: IF (p_batch_header_rec.batch_status NOT IN
302: (gme_common_pvt.g_batch_pending
303: ,gme_common_pvt.g_batch_wip
304: ,gme_common_pvt.g_batch_completed )) THEN
305: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
306: RAISE validation_error;
307: END IF;
308:
301: IF (p_batch_header_rec.batch_status NOT IN
302: (gme_common_pvt.g_batch_pending
303: ,gme_common_pvt.g_batch_wip
304: ,gme_common_pvt.g_batch_completed )) THEN
305: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
306: RAISE validation_error;
307: END IF;
308:
309: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
306: RAISE validation_error;
307: END IF;
308:
309: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
310: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
311: ,gme_common_pvt.g_step_wip
312: ,gme_common_pvt.g_step_completed)) THEN
313: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
314: RAISE validation_error;
307: END IF;
308:
309: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
310: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
311: ,gme_common_pvt.g_step_wip
312: ,gme_common_pvt.g_step_completed)) THEN
313: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
314: RAISE validation_error;
315: END IF;
308:
309: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
310: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
311: ,gme_common_pvt.g_step_wip
312: ,gme_common_pvt.g_step_completed)) THEN
313: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
314: RAISE validation_error;
315: END IF;
316: END IF;
309: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
310: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
311: ,gme_common_pvt.g_step_wip
312: ,gme_common_pvt.g_step_completed)) THEN
313: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
314: RAISE validation_error;
315: END IF;
316: END IF;
317:
405: RAISE val_error;
406: END IF;
407:
408: -- ByProduct_Type
409: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_byprod THEN
410: validate_byproduct_type
411: (p_byproduct_type => p_material_detail_rec.by_product_type
412: ,x_return_status => x_return_status);
413:
446:
447: /* Bug#5078853 moved this code over here */
448: -- Release_Type
449: -- following should be validated in form
450: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_byprod AND
451: p_material_detail_rec.by_product_type = 'S' THEN
452: x_material_detail_rec.release_type := 1;
453: ELSIF p_material_detail_rec.release_type IS NULL THEN
454: x_material_detail_rec.release_type := gme_common_pvt.g_release_type;
450: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_byprod AND
451: p_material_detail_rec.by_product_type = 'S' THEN
452: x_material_detail_rec.release_type := 1;
453: ELSIF p_material_detail_rec.release_type IS NULL THEN
454: x_material_detail_rec.release_type := gme_common_pvt.g_release_type;
455: ELSE
456: validate_release_type
457: (p_material_detail_rec => p_material_detail_rec
458: ,p_release_type => p_material_detail_rec.release_type
465: END IF;
466:
467: -- Calculate status of material based on release type, association and batch/step status
468: l_status := p_batch_header_rec.batch_status;
469: IF p_material_detail_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
470: p_batch_step_rec.batchstep_id IS NOT NULL THEN
471: l_status := p_batch_step_rec.step_status;
472: END IF;
473:
471: l_status := p_batch_step_rec.step_status;
472: END IF;
473:
474: -- Plan_Qty
475: IF l_status = gme_common_pvt.g_batch_pending THEN
476: validate_plan_qty (p_plan_qty => p_material_detail_rec.plan_qty
477: ,x_return_status => x_return_status);
478:
479: IF x_return_status <> fnd_api.g_ret_sts_success THEN
484: x_material_detail_rec.plan_qty := 0;
485: END IF;
486:
487: -- WIP_Plan_Qty
488: IF l_status <> gme_common_pvt.g_batch_wip THEN
489: x_material_detail_rec.wip_plan_qty := NULL;
490: ELSE
491: validate_wip_plan_qty
492: (p_wip_plan_qty => p_material_detail_rec.wip_plan_qty
506: p_material_detail_rec.actual_qty = 0 THEN
507:
508: x_material_detail_rec.actual_qty := 0;
509: ELSE
510: IF l_status NOT IN ( gme_common_pvt.g_batch_wip,
511: gme_common_pvt.g_batch_completed ) THEN
512: gme_common_pvt.log_message ('GME_INV_STAT_UPD_ACT');
513: RAISE val_error;
514: END IF;
507:
508: x_material_detail_rec.actual_qty := 0;
509: ELSE
510: IF l_status NOT IN ( gme_common_pvt.g_batch_wip,
511: gme_common_pvt.g_batch_completed ) THEN
512: gme_common_pvt.log_message ('GME_INV_STAT_UPD_ACT');
513: RAISE val_error;
514: END IF;
515: validate_actual_qty (p_actual_qty => x_material_detail_rec.actual_qty
508: x_material_detail_rec.actual_qty := 0;
509: ELSE
510: IF l_status NOT IN ( gme_common_pvt.g_batch_wip,
511: gme_common_pvt.g_batch_completed ) THEN
512: gme_common_pvt.log_message ('GME_INV_STAT_UPD_ACT');
513: RAISE val_error;
514: END IF;
515: validate_actual_qty (p_actual_qty => x_material_detail_rec.actual_qty
516: ,x_return_status => x_return_status);
523:
524:
525: /* Bug#5078853 modified validation for scrap factor */
526: -- Scrap_Factor
527: IF p_batch_header_rec.batch_status <> gme_common_pvt.g_batch_pending OR
528: p_material_detail_rec.scrap_factor IS NULL OR
529: p_material_detail_rec.scrap_factor = 0 OR
530: p_material_detail_rec.line_type <> gme_common_pvt.g_line_type_ing THEN
531: x_material_detail_rec.scrap_factor := 0;
526: -- Scrap_Factor
527: IF p_batch_header_rec.batch_status <> gme_common_pvt.g_batch_pending OR
528: p_material_detail_rec.scrap_factor IS NULL OR
529: p_material_detail_rec.scrap_factor = 0 OR
530: p_material_detail_rec.line_type <> gme_common_pvt.g_line_type_ing THEN
531: x_material_detail_rec.scrap_factor := 0;
532: ELSE
533: validate_scrap_factor(p_scrap => p_material_detail_rec.scrap_factor
534: ,x_return_status => x_return_status);
594: x_material_detail_rec.rounding_direction := NULL;
595: END IF;
596:
597: -- Cost_Alloc
598: IF x_material_detail_rec.line_type = gme_common_pvt.g_line_type_prod THEN
599: -- validate 0 <= cost_alloc <= 1
600: -- at save_batch, check that sum(cost_alloc for all products) <= 1
601: validate_cost_alloc
602: (p_material_detail_rec => p_material_detail_rec
610: x_material_detail_rec.cost_alloc := NULL;
611: END IF;
612:
613: -- Phantom_Type
614: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending AND
615: x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
616: validate_phantom_type
617: (p_phantom_type => p_material_detail_rec.phantom_type
618: ,x_return_status => x_return_status);
611: END IF;
612:
613: -- Phantom_Type
614: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending AND
615: x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
616: validate_phantom_type
617: (p_phantom_type => p_material_detail_rec.phantom_type
618: ,x_return_status => x_return_status);
619:
625: x_material_detail_rec.phantom_type := 0;
626: END IF;
627:
628: -- Contribute_Yield_Ind
629: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
630: validate_contr_yield_ind
631: (p_contr_yield_ind => p_material_detail_rec.contribute_yield_ind
632: ,x_return_status => x_return_status);
633:
658: x_material_detail_rec.subinventory := NULL;
659: x_material_detail_rec.locator_id := NULL;
660: ELSIF p_material_detail_rec.subinventory IS NULL THEN
661: --Bug#5078853 Begin get the default sub inv and locator either from gme_parameters or from Item Master
662: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
663: gme_common_pvt.get_supply_defaults ( p_organization_id => x_material_detail_rec.organization_id
664: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
665: ,x_subinventory => x_material_detail_rec.subinventory
666: ,x_locator_id => x_material_detail_rec.locator_id
659: x_material_detail_rec.locator_id := NULL;
660: ELSIF p_material_detail_rec.subinventory IS NULL THEN
661: --Bug#5078853 Begin get the default sub inv and locator either from gme_parameters or from Item Master
662: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
663: gme_common_pvt.get_supply_defaults ( p_organization_id => x_material_detail_rec.organization_id
664: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
665: ,x_subinventory => x_material_detail_rec.subinventory
666: ,x_locator_id => x_material_detail_rec.locator_id
667: ,x_return_status => x_return_status );
669: l_val_proc := 'get_supply_defaults';
670: RAISE val_error;
671: END IF;
672: ELSE
673: gme_common_pvt.get_yield_defaults ( p_organization_id => x_material_detail_rec.organization_id
674: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
675: ,p_line_type => p_material_detail_rec.line_type
676: ,x_subinventory => x_material_detail_rec.subinventory
677: ,x_locator_id => x_material_detail_rec.locator_id
697: x_material_detail_rec.locator_id := NULL;
698: ELSIF p_material_detail_rec.locator_id IS NULL THEN
699: /* Bug#5078853 Begin if we come here then locator id is not being passed from public api
700: so get the default locator id to validate with passed sub inv */
701: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
702: gme_common_pvt.get_supply_defaults ( p_organization_id => x_material_detail_rec.organization_id
703: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
704: ,x_subinventory => l_subinventory
705: ,x_locator_id => x_material_detail_rec.locator_id
698: ELSIF p_material_detail_rec.locator_id IS NULL THEN
699: /* Bug#5078853 Begin if we come here then locator id is not being passed from public api
700: so get the default locator id to validate with passed sub inv */
701: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
702: gme_common_pvt.get_supply_defaults ( p_organization_id => x_material_detail_rec.organization_id
703: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
704: ,x_subinventory => l_subinventory
705: ,x_locator_id => x_material_detail_rec.locator_id
706: ,x_return_status => x_return_status );
708: l_val_proc := 'get_supply_defaults';
709: RAISE val_error;
710: END IF;
711: ELSE
712: gme_common_pvt.get_yield_defaults ( p_organization_id => x_material_detail_rec.organization_id
713: ,p_inventory_item_id => p_material_detail_rec.inventory_item_id
714: ,p_line_type => p_material_detail_rec.line_type
715: ,x_subinventory => l_subinventory
716: ,x_locator_id => x_material_detail_rec.locator_id
739: END IF; -- IF x_material_detail_rec.locator_id IS NOT NULL ...
740: END IF; -- IF x_material_detail_rec.subinventory = ...
741:
742: /* Bug#5078853 added the following call for flex field validation
743: gme_common_pvt.g_flex_validate_prof has to be set in public API to enforce flex field validation */
744: gme_validate_flex_fld_pvt.validate_flex_material_details
745: ( p_material_detail_rec => p_material_detail_rec
746: ,x_material_detail_rec => x_material_detail_rec
747: ,x_return_status => x_return_status);
907: OPEN item_no_cursor (p_batch_header_rec.organization_id, l_item_rec.inventory_item_id);
908: FETCH item_no_cursor INTO l_item_no;
909: CLOSE item_no_cursor;
910:
911: gme_common_pvt.log_message ('GME_UPD_ACTUAL_QTY_ERR'
912: ,'ITEM_NO'
913: ,l_item_no);
914: x_return_status := fnd_api.g_ret_sts_error;
915: WHEN open_actual_qty_unexp_error THEN
961: SELECT transaction_id1
962: FROM gme_transaction_pairs
963: WHERE batch_id = v_batch_id
964: AND material_detail_id = v_material_detail_id
965: AND pair_type = gme_common_pvt.g_pairs_reversal_type);
966:
967: CURSOR cur_get_mtl_trxn_lot (v_trans_id NUMBER)
968: IS
969: SELECT COUNT (1)
1045: * lot - 1 transaction
1046: */
1047:
1048: l_release_type := l_mtl_dtl_rec.release_type;
1049: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release AND
1050: p_batchstep_id IS NULL THEN
1051: l_release_type := gme_common_pvt.g_mtl_auto_release;
1052: END IF;
1053:
1047:
1048: l_release_type := l_mtl_dtl_rec.release_type;
1049: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release AND
1050: p_batchstep_id IS NULL THEN
1051: l_release_type := gme_common_pvt.g_mtl_auto_release;
1052: END IF;
1053:
1054: -- if it's auto by step, ensure we have the step status...
1055: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release THEN
1051: l_release_type := gme_common_pvt.g_mtl_auto_release;
1052: END IF;
1053:
1054: -- if it's auto by step, ensure we have the step status...
1055: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release THEN
1056: IF p_step_status IS NULL THEN
1057: OPEN cur_get_step_status(p_batchstep_id);
1058: FETCH cur_get_step_status INTO l_step_status;
1059: CLOSE cur_get_step_status;
1065: -- Not open for products/byproducts that are not in completed state (auto) or
1066: -- wip/completed (manual/incremental)
1067:
1068: IF l_mtl_dtl_rec.line_type IN
1069: (gme_common_pvt.g_line_type_prod
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1066: -- wip/completed (manual/incremental)
1067:
1068: IF l_mtl_dtl_rec.line_type IN
1069: (gme_common_pvt.g_line_type_prod
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1067:
1068: IF l_mtl_dtl_rec.line_type IN
1069: (gme_common_pvt.g_line_type_prod
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1068: IF l_mtl_dtl_rec.line_type IN
1069: (gme_common_pvt.g_line_type_prod
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1069: (gme_common_pvt.g_line_type_prod
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1070: ,gme_common_pvt.g_line_type_byprod)
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1078: ,gme_common_pvt.g_batch_completed))
1071: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1078: ,gme_common_pvt.g_batch_completed))
1079: ) THEN
1072: AND l_step_status <> gme_common_pvt.g_step_completed)
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1078: ,gme_common_pvt.g_batch_completed))
1079: ) THEN
1080: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1073: OR (l_release_type = gme_common_pvt.g_mtl_auto_release
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1078: ,gme_common_pvt.g_batch_completed))
1079: ) THEN
1080: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1081: gme_debug.put_line
1074: AND p_batch_status <> gme_common_pvt.g_batch_completed)
1075: OR (l_release_type IN (gme_common_pvt.g_mtl_manual_release,
1076: gme_common_pvt.g_mtl_incremental_release)
1077: AND p_batch_status NOT IN (gme_common_pvt.g_batch_wip
1078: ,gme_common_pvt.g_batch_completed))
1079: ) THEN
1080: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1081: gme_debug.put_line
1082: ( g_pkg_name
1090: RETURN -1;
1091: END IF;
1092:
1093: -- Not open for ingredients that are not in WIP or completed state
1094: IF l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
1095: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1096: AND l_step_status NOT IN
1097: (gme_common_pvt.g_step_wip
1098: ,gme_common_pvt.g_step_completed) )
1091: END IF;
1092:
1093: -- Not open for ingredients that are not in WIP or completed state
1094: IF l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
1095: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1096: AND l_step_status NOT IN
1097: (gme_common_pvt.g_step_wip
1098: ,gme_common_pvt.g_step_completed) )
1099: -- following for manual, incremental and auto
1093: -- Not open for ingredients that are not in WIP or completed state
1094: IF l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
1095: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1096: AND l_step_status NOT IN
1097: (gme_common_pvt.g_step_wip
1098: ,gme_common_pvt.g_step_completed) )
1099: -- following for manual, incremental and auto
1100: OR (p_batch_status NOT IN
1101: (gme_common_pvt.g_batch_wip
1094: IF l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
1095: AND ( (l_release_type = gme_common_pvt.g_mtl_autobystep_release
1096: AND l_step_status NOT IN
1097: (gme_common_pvt.g_step_wip
1098: ,gme_common_pvt.g_step_completed) )
1099: -- following for manual, incremental and auto
1100: OR (p_batch_status NOT IN
1101: (gme_common_pvt.g_batch_wip
1102: ,gme_common_pvt.g_batch_completed) ) ) THEN
1097: (gme_common_pvt.g_step_wip
1098: ,gme_common_pvt.g_step_completed) )
1099: -- following for manual, incremental and auto
1100: OR (p_batch_status NOT IN
1101: (gme_common_pvt.g_batch_wip
1102: ,gme_common_pvt.g_batch_completed) ) ) THEN
1103: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1104: gme_debug.put_line
1105: ( g_pkg_name
1098: ,gme_common_pvt.g_step_completed) )
1099: -- following for manual, incremental and auto
1100: OR (p_batch_status NOT IN
1101: (gme_common_pvt.g_batch_wip
1102: ,gme_common_pvt.g_batch_completed) ) ) THEN
1103: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1104: gme_debug.put_line
1105: ( g_pkg_name
1106: || '.'
1270: OPEN cur_sub_control (l_mtl_dtl_rec.organization_id, l_mtl_dtl_rec.subinventory);
1271: FETCH cur_sub_control INTO l_sub_locator_type;
1272: CLOSE cur_sub_control;
1273:
1274: IF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing) THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1271: FETCH cur_sub_control INTO l_sub_locator_type;
1272: CLOSE cur_sub_control;
1273:
1274: IF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing) THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1279: l_txn_action := gme_common_pvt.g_byprod_comp_txn_action;
1272: CLOSE cur_sub_control;
1273:
1274: IF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing) THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1279: l_txn_action := gme_common_pvt.g_byprod_comp_txn_action;
1280: END IF;
1273:
1274: IF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing) THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1279: l_txn_action := gme_common_pvt.g_byprod_comp_txn_action;
1280: END IF;
1281: --Bug#5129153 If item is revision controlled and revision field is NULL then return -1. Start.
1274: IF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing) THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1279: l_txn_action := gme_common_pvt.g_byprod_comp_txn_action;
1280: END IF;
1281: --Bug#5129153 If item is revision controlled and revision field is NULL then return -1. Start.
1282: IF l_rev_code = 2 AND l_mtl_dtl_rec.revision IS NULL THEN
1275: l_txn_action := gme_common_pvt.g_ing_issue_txn_action;
1276: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_prod) THEN
1277: l_txn_action := gme_common_pvt.g_prod_comp_txn_action;
1278: ELSIF (l_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_byprod) THEN
1279: l_txn_action := gme_common_pvt.g_byprod_comp_txn_action;
1280: END IF;
1281: --Bug#5129153 If item is revision controlled and revision field is NULL then return -1. Start.
1282: IF l_rev_code = 2 AND l_mtl_dtl_rec.revision IS NULL THEN
1283: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1293: END IF;
1294: --Bug#5129153 End.
1295: /* Bug 5441643 Added NVL condition for location control code*/
1296: l_eff_locator_control :=
1297: gme_common_pvt.eff_locator_control
1298: (p_organization_id => l_mtl_dtl_rec.organization_id
1299: ,p_org_control => gme_common_pvt.g_org_locator_control
1300: ,p_subinventory => l_mtl_dtl_rec.subinventory
1301: ,p_sub_control => l_sub_locator_type
1295: /* Bug 5441643 Added NVL condition for location control code*/
1296: l_eff_locator_control :=
1297: gme_common_pvt.eff_locator_control
1298: (p_organization_id => l_mtl_dtl_rec.organization_id
1299: ,p_org_control => gme_common_pvt.g_org_locator_control
1300: ,p_subinventory => l_mtl_dtl_rec.subinventory
1301: ,p_sub_control => l_sub_locator_type
1302: ,p_item_control => NVL(l_location_control_code,1)
1303: ,p_item_loc_restrict => l_restrict_locators_code
1389:
1390: l_api_name CONSTANT VARCHAR2 (30) := 'PROCESS_ACTUAL_QTY';
1391:
1392: l_mmt_rec mtl_material_transactions%ROWTYPE;
1393: l_mmln_tbl gme_common_pvt.mtl_trans_lots_num_tbl;
1394:
1395: l_mmti_rec mtl_transactions_interface%ROWTYPE;
1396: l_mmli_tbl gme_common_pvt.mtl_trans_lots_inter_tbl;
1397:
1392: l_mmt_rec mtl_material_transactions%ROWTYPE;
1393: l_mmln_tbl gme_common_pvt.mtl_trans_lots_num_tbl;
1394:
1395: l_mmti_rec mtl_transactions_interface%ROWTYPE;
1396: l_mmli_tbl gme_common_pvt.mtl_trans_lots_inter_tbl;
1397:
1398: error_trans EXCEPTION;
1399:
1400: BEGIN
1477: ( g_pkg_name
1478: || '.'
1479: || l_api_name
1480: ||' transaction header id after create mtl txn'
1481: || gme_common_pvt.g_transaction_header_id);
1482: END IF;
1483: ELSE
1484: /* Bug 5681997 added condition to touch txns only if enabled */
1485: IF p_item_rec.mtl_transactions_enabled_flag = 'Y' THEN
1582: x_mmti_rec.transaction_source_id := p_matl_dtl_rec.batch_id;
1583: x_mmti_rec.organization_id := p_matl_dtl_rec.organization_id;
1584:
1585: --getting transaction_type_id depends on the line type
1586: IF l_line_type = gme_common_pvt.g_line_type_ing THEN
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1583: x_mmti_rec.organization_id := p_matl_dtl_rec.organization_id;
1584:
1585: --getting transaction_type_id depends on the line type
1586: IF l_line_type = gme_common_pvt.g_line_type_ing THEN
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1591: x_mmti_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
1584:
1585: --getting transaction_type_id depends on the line type
1586: IF l_line_type = gme_common_pvt.g_line_type_ing THEN
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1591: x_mmti_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
1592: END IF;
1585: --getting transaction_type_id depends on the line type
1586: IF l_line_type = gme_common_pvt.g_line_type_ing THEN
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1591: x_mmti_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
1592: END IF;
1593: --x_mmti_rec.TRANSACTION_TYPE_ID := 44;
1586: IF l_line_type = gme_common_pvt.g_line_type_ing THEN
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1591: x_mmti_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
1592: END IF;
1593: --x_mmti_rec.TRANSACTION_TYPE_ID := 44;
1594: x_mmti_rec.subinventory_code := p_matl_dtl_rec.subinventory;
1587: x_mmti_rec.transaction_type_id := gme_common_pvt.g_ing_issue;
1588: ELSIF l_line_type = gme_common_pvt.g_line_type_prod THEN
1589: x_mmti_rec.transaction_type_id := gme_common_pvt.g_prod_completion;
1590: ELSIF l_line_type = gme_common_pvt.g_line_type_byprod THEN
1591: x_mmti_rec.transaction_type_id := gme_common_pvt.g_byprod_completion;
1592: END IF;
1593: --x_mmti_rec.TRANSACTION_TYPE_ID := 44;
1594: x_mmti_rec.subinventory_code := p_matl_dtl_rec.subinventory;
1595: x_mmti_rec.locator_id := p_matl_dtl_rec.locator_id;
1599:
1600: /*Bug#5394232 Begin
1601: if we don't pass any date to this procedure then we have to default the trans date*/
1602: IF x_mmti_rec.transaction_date IS NULL THEN
1603: gme_common_pvt.fetch_trans_date(
1604: p_material_detail_id => p_matl_dtl_rec.material_detail_id
1605: ,p_invoke_mode => 'T'
1606: ,x_trans_date => l_trans_date
1607: ,x_return_status => x_return_status );
1644: END IF;
1645:
1646: -- Calculate Transaction Date
1647: l_release_type := p_matl_dtl_rec.release_type;
1648: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release AND
1649: p_batch_step_rec.batchstep_id IS NULL THEN
1650: l_release_type := gme_common_pvt.g_mtl_auto_release;
1651: END IF;
1652:
1646: -- Calculate Transaction Date
1647: l_release_type := p_matl_dtl_rec.release_type;
1648: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release AND
1649: p_batch_step_rec.batchstep_id IS NULL THEN
1650: l_release_type := gme_common_pvt.g_mtl_auto_release;
1651: END IF;
1652:
1653: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release THEN -- abs... dates come from step
1654: IF p_batch_step_rec.step_status = gme_common_pvt.g_step_completed THEN
1649: p_batch_step_rec.batchstep_id IS NULL THEN
1650: l_release_type := gme_common_pvt.g_mtl_auto_release;
1651: END IF;
1652:
1653: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release THEN -- abs... dates come from step
1654: IF p_batch_step_rec.step_status = gme_common_pvt.g_step_completed THEN
1655: x_mmti_rec.transaction_date := p_batch_step_rec.actual_cmplt_date;
1656: ELSE -- must be WIP
1657: x_mmti_rec.transaction_date := p_batch_step_rec.actual_start_date;
1650: l_release_type := gme_common_pvt.g_mtl_auto_release;
1651: END IF;
1652:
1653: IF l_release_type = gme_common_pvt.g_mtl_autobystep_release THEN -- abs... dates come from step
1654: IF p_batch_step_rec.step_status = gme_common_pvt.g_step_completed THEN
1655: x_mmti_rec.transaction_date := p_batch_step_rec.actual_cmplt_date;
1656: ELSE -- must be WIP
1657: x_mmti_rec.transaction_date := p_batch_step_rec.actual_start_date;
1658: END IF;
1657: x_mmti_rec.transaction_date := p_batch_step_rec.actual_start_date;
1658: END IF;
1659: ELSE -- auto release... dates come from batch
1660: IF p_batch_hdr_rec.batch_status =
1661: gme_common_pvt.g_batch_completed THEN
1662: x_mmti_rec.transaction_date :=
1663: p_batch_hdr_rec.actual_cmplt_date;
1664: ELSE -- must be WIP
1665: x_mmti_rec.transaction_date :=
1782: x_conv_qty := inv_convert.inv_um_convert
1783: (item_id => p_item_id
1784: ,lot_number => p_lot_number
1785: ,organization_id => p_org_id
1786: ,precision => gme_common_pvt.g_precision
1787: ,from_quantity => p_qty
1788: ,from_unit => p_from_um
1789: ,to_unit => p_to_um
1790: ,from_name => NULL
1789: ,to_unit => p_to_um
1790: ,from_name => NULL
1791: ,to_name => NULL);
1792:
1793: -- Note: -99999 should be in gme_common_pvt
1794: IF x_conv_qty = -99999 THEN
1795: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1796: gme_debug.put_line
1797: ( g_pkg_name
1859:
1860: x_return_status := fnd_api.g_ret_sts_success;
1861:
1862: IF p_item_id IS NULL THEN
1863: gme_common_pvt.log_message ('GME_NO_KEYS', 'TABLE_NAME', 'mtl_system_items_b');
1864: RAISE error_get_item;
1865: END IF;
1866:
1867: OPEN cur_get_item_rec (p_org_id, p_item_id);
1868: FETCH cur_get_item_rec INTO x_item_rec;
1869: CLOSE cur_get_item_rec;
1870:
1871: IF x_item_rec.inventory_item_id IS NULL THEN -- not found
1872: gme_common_pvt.log_message ('PM_INVALID_ITEM');
1873:
1874: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1875: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' no record in mtl_system_items_b: ');
1876: gme_debug.put_line(g_pkg_name||'.'||l_api_name||'inventory_item_id = ' ||p_item_id );
1942: -- lab_batch 1 eng item Y OK
1943: -- lab_batch 0 eng item Y N
1944: -- lab_batch 1 eng item N OK
1945: -- lab_batch 0 eng item N OK
1946: IF gme_common_pvt.g_lab_ind = 0 AND x_item_rec.eng_item_flag = 'Y' THEN
1947: l_field := 'eng_item_flag';
1948: RAISE error_validate;
1949: END IF;
1950:
1981: FROM mtl_system_items_kfv
1982: WHERE inventory_item_id = p_item_id
1983: AND organization_id = p_org_id;
1984: --Bug#5078853
1985: gme_common_pvt.log_message ('GME_INV_ITEM_INSERT', 'ITEM_NO', l_field);
1986: x_return_status := fnd_api.g_ret_sts_error;
1987:
1988: WHEN OTHERS THEN
1989: fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
2037:
2038: -- revision_qty_control_code
2039: -- 1=No revision qty control; 2=Under revision qty control
2040: IF p_item_rec.revision_qty_control_code = 1 THEN
2041: gme_common_pvt.log_message ('GME_NOT_REV_CTRL');
2042: RAISE error_not_revision_control;
2043: END IF;
2044:
2045: OPEN cur_get_revision (p_item_rec.organization_id
2048: FETCH cur_get_revision INTO l_is_revision_found;
2049: CLOSE cur_get_revision;
2050:
2051: IF l_is_revision_found IS NULL OR l_is_revision_found <> 1 THEN
2052: gme_common_pvt.log_message ('GME_REV_NOT_DEFD');
2053: RAISE error_revision_not_found;
2054: END IF;
2055:
2056: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2094: -- value of 1 means Yes; byproducts are available for insert, update and delete
2095: -- value of 2 means No; byproducts are not available
2096: -- if this parameter is set to 2 and the material being inserted is a byproduct, then
2097: -- raise an error
2098: IF gme_common_pvt.g_byprod_active = 2 AND
2099: p_line_type = gme_common_pvt.g_line_type_byprod THEN
2100: fnd_message.set_name ('GMD', 'FM_BYPROD_INACTIVE');
2101: fnd_msg_pub.ADD;
2102: RAISE validation_error;
2095: -- value of 2 means No; byproducts are not available
2096: -- if this parameter is set to 2 and the material being inserted is a byproduct, then
2097: -- raise an error
2098: IF gme_common_pvt.g_byprod_active = 2 AND
2099: p_line_type = gme_common_pvt.g_line_type_byprod THEN
2100: fnd_message.set_name ('GMD', 'FM_BYPROD_INACTIVE');
2101: fnd_msg_pub.ADD;
2102: RAISE validation_error;
2103: END IF;
2102: RAISE validation_error;
2103: END IF;
2104:
2105: IF p_line_type NOT IN
2106: (gme_common_pvt.g_line_type_ing
2107: ,gme_common_pvt.g_line_type_prod
2108: ,gme_common_pvt.g_line_type_byprod) THEN
2109: gme_common_pvt.log_message ('GME_INVALID_LINE_TYPE');
2110: RAISE validation_error;
2103: END IF;
2104:
2105: IF p_line_type NOT IN
2106: (gme_common_pvt.g_line_type_ing
2107: ,gme_common_pvt.g_line_type_prod
2108: ,gme_common_pvt.g_line_type_byprod) THEN
2109: gme_common_pvt.log_message ('GME_INVALID_LINE_TYPE');
2110: RAISE validation_error;
2111: END IF;
2104:
2105: IF p_line_type NOT IN
2106: (gme_common_pvt.g_line_type_ing
2107: ,gme_common_pvt.g_line_type_prod
2108: ,gme_common_pvt.g_line_type_byprod) THEN
2109: gme_common_pvt.log_message ('GME_INVALID_LINE_TYPE');
2110: RAISE validation_error;
2111: END IF;
2112:
2105: IF p_line_type NOT IN
2106: (gme_common_pvt.g_line_type_ing
2107: ,gme_common_pvt.g_line_type_prod
2108: ,gme_common_pvt.g_line_type_byprod) THEN
2109: gme_common_pvt.log_message ('GME_INVALID_LINE_TYPE');
2110: RAISE validation_error;
2111: END IF;
2112:
2113: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2161: FETCH cur_byprod_type INTO l_exists;
2162: CLOSE cur_byprod_type;
2163:
2164: IF l_exists IS NULL OR l_exists <> 1 THEN
2165: gme_common_pvt.log_message ('GME_INVALID_BYPROD_TYPE');
2166: RAISE invalid_byproduct_type;
2167: END IF;
2168: END IF;
2169:
2216:
2217: x_return_status := fnd_api.g_ret_sts_success;
2218:
2219: IF p_line_no <= 0 THEN
2220: gme_common_pvt.log_message ('GME_INVALID_LINE_NUMBER');
2221: RAISE invalid_line_no;
2222: END IF;
2223:
2224: OPEN cur_last_line_no(p_batch_id, p_line_type);
2296: RAISE invalid_dtl_um;
2297: END IF;
2298: */
2299:
2300: IF l_disable_date <= gme_common_pvt.g_timestamp THEN
2301: gme_common_pvt.log_message ('GME_UM_DISABLED');
2302: RAISE disabled_dtl_um;
2303: END IF;
2304:
2297: END IF;
2298: */
2299:
2300: IF l_disable_date <= gme_common_pvt.g_timestamp THEN
2301: gme_common_pvt.log_message ('GME_UM_DISABLED');
2302: RAISE disabled_dtl_um;
2303: END IF;
2304:
2305: get_converted_qty (
2355:
2356: x_return_status := fnd_api.g_ret_sts_success;
2357:
2358: IF p_plan_qty < 0 THEN
2359: gme_common_pvt.log_message ('GME_INVALID_PLAN_QTY');
2360: RAISE val_error;
2361: END IF;
2362:
2363: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2396:
2397: x_return_status := fnd_api.g_ret_sts_success;
2398:
2399: IF p_wip_plan_qty < 0 THEN
2400: gme_common_pvt.log_message ('GME_INVALID_WIP_PLAN_QTY');
2401: RAISE val_error;
2402: END IF;
2403:
2404: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2437:
2438: x_return_status := fnd_api.g_ret_sts_success;
2439:
2440: IF p_actual_qty < 0 THEN
2441: gme_common_pvt.log_message ('GME_INVALID_ACTUAL_QTY');
2442: RAISE val_error;
2443: END IF;
2444:
2445: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2491: FETCH cur_rel_type INTO l_exists;
2492: CLOSE cur_rel_type;
2493:
2494: IF l_exists IS NULL OR l_exists <> 1 THEN
2495: gme_common_pvt.log_message ('GME_INVALID_RELEASE_TYPE');
2496: RAISE val_error;
2497: END IF;
2498:
2499: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2533:
2534: x_return_status := fnd_api.g_ret_sts_success;
2535:
2536: IF (p_scrap < 0 OR p_scrap > 1000000) THEN
2537: gme_common_pvt.log_message ('GME_INVALID_SCRAP_FACTOR');
2538: RAISE val_error;
2539: END IF;
2540:
2541: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2574:
2575: x_return_status := fnd_api.g_ret_sts_success;
2576:
2577: IF p_scale_mult <= 0 THEN
2578: gme_common_pvt.log_message ('GME_INVALID_SCALE_MULT');
2579: RAISE val_error;
2580: END IF;
2581:
2582: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2615:
2616: x_return_status := fnd_api.g_ret_sts_success;
2617:
2618: IF (p_scale_var < 0 OR p_scale_var > 100) THEN
2619: gme_common_pvt.log_message ('GME_INVALID_SCALE_ROUND_VAR');
2620: RAISE val_error;
2621: END IF;
2622:
2623: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2669: FETCH cur_round_dir INTO l_exists;
2670: CLOSE cur_round_dir;
2671:
2672: IF l_exists IS NULL OR l_exists <> 1 THEN
2673: gme_common_pvt.log_message ('GME_INVALID_ROUND_DIR');
2674: RAISE val_error;
2675: END IF;
2676:
2677: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2723: FETCH cur_scale_type INTO l_exists;
2724: CLOSE cur_scale_type;
2725:
2726: IF l_exists IS NULL OR l_exists <> 1 THEN
2727: gme_common_pvt.log_message ('GME_INVALID_SCALE_TYPE');
2728: RAISE val_error;
2729: END IF;
2730:
2731: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2792: OPEN Cur_get_batch_status(l_batch_id);
2793: FETCH Cur_get_batch_status INTO l_status;
2794: CLOSE Cur_get_batch_status;
2795:
2796: IF l_status = gme_common_pvt.g_batch_wip THEN
2797: OPEN Cur_get_step_status(l_material_detail_id);
2798: FETCH Cur_get_step_status INTO l_rel_type,l_step_status;
2799: CLOSE Cur_get_step_status;
2800: END IF;
2800: END IF;
2801:
2802: /* For the completed batches and the wip batches where the associated step is
2803: completed, the cost allocation is not updatable */
2804: IF l_status = gme_common_pvt.g_batch_completed OR
2805: ( l_status = gme_common_pvt.g_batch_wip AND l_rel_type=gme_common_pvt.g_mtl_autobystep_release AND
2806: l_step_status = gme_common_pvt.g_step_completed) THEN
2807: IF l_material_detail_id is NULL THEN
2808: /* in insert */
2801:
2802: /* For the completed batches and the wip batches where the associated step is
2803: completed, the cost allocation is not updatable */
2804: IF l_status = gme_common_pvt.g_batch_completed OR
2805: ( l_status = gme_common_pvt.g_batch_wip AND l_rel_type=gme_common_pvt.g_mtl_autobystep_release AND
2806: l_step_status = gme_common_pvt.g_step_completed) THEN
2807: IF l_material_detail_id is NULL THEN
2808: /* in insert */
2809: IF p_material_detail_rec.cost_alloc <> 0 THEN
2802: /* For the completed batches and the wip batches where the associated step is
2803: completed, the cost allocation is not updatable */
2804: IF l_status = gme_common_pvt.g_batch_completed OR
2805: ( l_status = gme_common_pvt.g_batch_wip AND l_rel_type=gme_common_pvt.g_mtl_autobystep_release AND
2806: l_step_status = gme_common_pvt.g_step_completed) THEN
2807: IF l_material_detail_id is NULL THEN
2808: /* in insert */
2809: IF p_material_detail_rec.cost_alloc <> 0 THEN
2810: gme_common_pvt.log_message ('GME_INVALID_COST_ALLOC');
2806: l_step_status = gme_common_pvt.g_step_completed) THEN
2807: IF l_material_detail_id is NULL THEN
2808: /* in insert */
2809: IF p_material_detail_rec.cost_alloc <> 0 THEN
2810: gme_common_pvt.log_message ('GME_INVALID_COST_ALLOC');
2811: RAISE val_error;
2812: END IF;
2813: ELSE
2814: /* in update */
2816: FETCH Cur_get_cost_alloc INTO l_cost_alloc;
2817: CLOSE Cur_get_cost_alloc;
2818: /*if the passed cost allocation is diff from stored cost alloc raise error */
2819: IF l_cost_alloc <> p_material_detail_rec.cost_alloc THEN
2820: gme_common_pvt.log_message ('GME_COST_ALLOC_CANNOT_UPD');
2821: RAISE val_error;
2822: END IF;
2823: END IF;
2824: END IF;
2823: END IF;
2824: END IF;
2825: --commented out the following lines
2826: /*IF p_cost_alloc < 0 OR p_cost_alloc > 1 THEN
2827: gme_common_pvt.log_message ('GME_INVALID_COST_ALLOC');
2828: RAISE val_error;
2829: END IF; */
2830: --FPBug#4524232 End
2831: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2874: FETCH cur_phantom_type INTO l_exists;
2875: CLOSE cur_phantom_type;
2876:
2877: IF l_exists IS NULL OR l_exists <> 1 THEN
2878: gme_common_pvt.log_message ('GME_INV_PHANTOM_TYPE');
2879: RAISE val_error;
2880: END IF;
2881:
2882: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2915:
2916: x_return_status := fnd_api.g_ret_sts_success;
2917:
2918: IF p_contr_yield_ind NOT IN ('Y', 'N') THEN
2919: gme_common_pvt.log_message ('GME_INVALID_CONTR_YIELD');
2920: RAISE val_error;
2921: END IF;
2922:
2923: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
2957:
2958: x_return_status := fnd_api.g_ret_sts_success;
2959:
2960: IF p_contr_step_qty_ind NOT IN ('Y', 'N') THEN
2961: gme_common_pvt.log_message ('GME_INVALID_CONTR_STEP');
2962: RAISE val_error;
2963: END IF;
2964:
2965: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
3000: x_return_status := fnd_api.g_ret_sts_success;
3001:
3002: IF p_subinv IS NULL THEN
3003: NULL; -- not required
3004: ELSIF gme_common_pvt.check_subinventory
3005: (p_organization_id => p_item_rec.organization_id
3006: ,p_subinventory => p_subinv
3007: ,p_inventory_item_id => p_item_rec.inventory_item_id
3008: ,p_restrict_subinv => p_item_rec.restrict_subinventories_code) THEN
3060: END IF;
3061:
3062: x_return_status := fnd_api.g_ret_sts_success;
3063:
3064: IF p_line_type = gme_common_pvt.g_line_type_ing THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3061:
3062: x_return_status := fnd_api.g_ret_sts_success;
3063:
3064: IF p_line_type = gme_common_pvt.g_line_type_ing THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3069: l_txn_action_id := gme_common_pvt.g_byprod_comp_txn_action;
3062: x_return_status := fnd_api.g_ret_sts_success;
3063:
3064: IF p_line_type = gme_common_pvt.g_line_type_ing THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3069: l_txn_action_id := gme_common_pvt.g_byprod_comp_txn_action;
3070: END IF;
3063:
3064: IF p_line_type = gme_common_pvt.g_line_type_ing THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3069: l_txn_action_id := gme_common_pvt.g_byprod_comp_txn_action;
3070: END IF;
3071:
3064: IF p_line_type = gme_common_pvt.g_line_type_ing THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3069: l_txn_action_id := gme_common_pvt.g_byprod_comp_txn_action;
3070: END IF;
3071:
3072: IF p_locator_id IS NULL THEN
3065: l_txn_action_id := gme_common_pvt.g_ing_issue_txn_action;
3066: ELSIF p_line_type = gme_common_pvt.g_line_type_prod THEN
3067: l_txn_action_id := gme_common_pvt.g_prod_comp_txn_action;
3068: ELSIF p_line_type = gme_common_pvt.g_line_type_byprod THEN
3069: l_txn_action_id := gme_common_pvt.g_byprod_comp_txn_action;
3070: END IF;
3071:
3072: IF p_locator_id IS NULL THEN
3073: NULL; -- not required
3075: OPEN cur_sub_control (p_item_rec.organization_id, p_subinv);
3076: FETCH cur_sub_control INTO l_sub_locator_type;
3077: CLOSE cur_sub_control;
3078: /* Bug 5441643 Added NVL condition for location control code*/
3079: IF gme_common_pvt.check_locator
3080: (p_organization_id => p_item_rec.organization_id
3081: ,p_locator_id => p_locator_id
3082: ,p_subinventory => p_subinv
3083: ,p_inventory_item_id => p_item_rec.inventory_item_id
3080: (p_organization_id => p_item_rec.organization_id
3081: ,p_locator_id => p_locator_id
3082: ,p_subinventory => p_subinv
3083: ,p_inventory_item_id => p_item_rec.inventory_item_id
3084: ,p_org_control => gme_common_pvt.g_org_locator_control
3085: ,p_sub_control => l_sub_locator_type
3086: ,p_item_control => NVL(p_item_rec.location_control_code,1)
3087: ,p_item_loc_restrict => p_item_rec.restrict_locators_code
3088: ,p_org_neg_allowed => gme_common_pvt.g_allow_neg_inv
3084: ,p_org_control => gme_common_pvt.g_org_locator_control
3085: ,p_sub_control => l_sub_locator_type
3086: ,p_item_control => NVL(p_item_rec.location_control_code,1)
3087: ,p_item_loc_restrict => p_item_rec.restrict_locators_code
3088: ,p_org_neg_allowed => gme_common_pvt.g_allow_neg_inv
3089: ,p_txn_action_id => l_txn_action_id) THEN
3090: NULL;
3091: ELSE
3092: RAISE loc_not_valid;
3144: l_message_list VARCHAR2 (2000);
3145:
3146: l_ph_batch_header_rec gme_batch_header%ROWTYPE;
3147: l_batch_header_rec gme_batch_header%ROWTYPE;
3148: l_out_material_detail_tbl gme_common_pvt.material_details_tab;
3149: l_material_detail_tbl gme_common_pvt.material_details_tab;
3150: l_trolin_tbl inv_move_order_pub.trolin_tbl_type;
3151:
3152: l_mtl_dtl_rec gme_material_details%ROWTYPE;
3145:
3146: l_ph_batch_header_rec gme_batch_header%ROWTYPE;
3147: l_batch_header_rec gme_batch_header%ROWTYPE;
3148: l_out_material_detail_tbl gme_common_pvt.material_details_tab;
3149: l_material_detail_tbl gme_common_pvt.material_details_tab;
3150: l_trolin_tbl inv_move_order_pub.trolin_tbl_type;
3151:
3152: l_mtl_dtl_rec gme_material_details%ROWTYPE;
3153: l_ph_mtl_dtl_rec gme_material_details%ROWTYPE;
3152: l_mtl_dtl_rec gme_material_details%ROWTYPE;
3153: l_ph_mtl_dtl_rec gme_material_details%ROWTYPE;
3154: l_db_mtl_dtl_rec gme_material_details%ROWTYPE;
3155: l_batch_step_rec gme_batch_steps%ROWTYPE;
3156: l_exception_material_tbl gme_common_pvt.exceptions_tab;
3157: l_ph_batch_step_rec gme_batch_steps%ROWTYPE;
3158: l_phantom_batch_header_rec_out gme_batch_header%ROWTYPE;
3159: l_step_tbl gme_reschedule_step_pvt.step_tab;
3160: x_batch_step_rec gme_batch_steps%ROWTYPE;
3205: -- batch_status is used to decide whether to use plan or wip_plan
3206: l_factor := 1;
3207: l_batch_status := p_batch_header_rec.batch_status;
3208:
3209: IF l_batch_status = gme_common_pvt.g_batch_pending THEN
3210: l_qty := l_mtl_dtl_rec.plan_qty;
3211: --Bug#4965141 check for zero plan qty
3212: IF l_db_mtl_dtl_rec.plan_qty = 0 THEN
3213: l_eff_qty := 1;
3214: ELSE
3215: l_eff_qty := l_db_mtl_dtl_rec.plan_qty;
3216: END IF;
3217: l_factor := l_mtl_dtl_rec.plan_qty / l_eff_qty;
3218: ELSIF l_batch_status = gme_common_pvt.g_batch_wip THEN
3219: l_qty := l_mtl_dtl_rec.wip_plan_qty;
3220: --Bug#4965141 check for zero wip plan qty
3221: IF NVL(l_db_mtl_dtl_rec.wip_plan_qty,0) = 0 THEN
3222: l_eff_qty := 1;
3231: gme_debug.put_line(g_pkg_name||'.'||l_api_name||' l_factor='||l_factor);
3232: END IF;
3233:
3234: l_status := p_batch_header_rec.batch_status;
3235: IF l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3236: p_batch_step_rec.batchstep_id IS NOT NULL THEN
3237: l_status := p_batch_step_rec.step_status;
3238: END IF;
3239:
3248: l_old_wip_plan := l_db_mtl_dtl_rec.wip_plan_qty;
3249: l_new_wip_plan := l_mtl_dtl_rec.wip_plan_qty;
3250:
3251: IF l_old_scrap <> l_new_scrap
3252: AND l_status = gme_common_pvt.g_batch_pending
3253: AND l_old_plan_qty = l_new_plan_qty THEN
3254: l_old_plan_qty := x_material_detail_rec.plan_qty
3255: / (1 + l_old_scrap);
3256: x_material_detail_rec.plan_qty :=
3256: x_material_detail_rec.plan_qty :=
3257: l_old_plan_qty
3258: * (1 + x_material_detail_rec.scrap_factor);
3259: ELSIF l_old_scrap <> l_new_scrap
3260: AND l_status = gme_common_pvt.g_batch_wip
3261: AND l_old_wip_plan = l_new_wip_plan THEN
3262: l_old_plan_qty :=
3263: x_material_detail_rec.wip_plan_qty
3264: / (1 + l_old_scrap);
3268: END IF;
3269: /* 5391396 moved the code up*/
3270: IF l_mtl_dtl_rec.release_type <> l_db_mtl_dtl_rec.release_type THEN
3271:
3272: gme_common_pvt.calc_mtl_req_date
3273: (p_batch_header_rec => p_batch_header_rec
3274: ,p_batchstep_rec => p_batch_step_rec
3275: ,p_mtl_dtl_rec => l_mtl_dtl_rec
3276: ,x_mtl_req_date => l_mtl_dtl_rec.material_requirement_date
3276: ,x_mtl_req_date => l_mtl_dtl_rec.material_requirement_date
3277: ,x_return_status => x_return_status);
3278:
3279: IF x_return_status <> fnd_api.g_ret_sts_success THEN
3280: l_proc := 'gme_common_pvt.calc_mtl_req_date';
3281: RAISE error_processing;
3282: END IF;
3283:
3284: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3284: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3285: gme_debug.put_line ( g_pkg_name
3286: || '.'
3287: || l_api_name
3288: || ' after gme_common_pvt.calc_mtl_req_date');
3289: gme_debug.put_line
3290: ( g_pkg_name
3291: || '.'
3292: || l_api_name
3296: ,'YYYY-MON-DD HH24:MI:SS') );
3297: END IF;
3298: /* Pawan Kumar bug 5127489 Changed so as to change the move order
3299: and reservation dates */
3300: gme_common_pvt.material_date_change (
3301: p_material_detail_id => l_mtl_dtl_rec.material_detail_id
3302: ,p_material_date => l_mtl_dtl_rec.material_requirement_date
3303: ,x_return_status => x_return_status );
3304:
3302: ,p_material_date => l_mtl_dtl_rec.material_requirement_date
3303: ,x_return_status => x_return_status );
3304:
3305: IF x_return_status <> fnd_api.g_ret_sts_success THEN
3306: l_proc := 'gme_common_pvt.material_date_change';
3307: RAISE error_processing;
3308: END IF;
3309: --Bug#5159393 Susruth D.
3310: l_mtl_dtl_rec.last_update_date := gme_common_pvt.g_timestamp;
3306: l_proc := 'gme_common_pvt.material_date_change';
3307: RAISE error_processing;
3308: END IF;
3309: --Bug#5159393 Susruth D.
3310: l_mtl_dtl_rec.last_update_date := gme_common_pvt.g_timestamp;
3311: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3312: gme_debug.put_line ( g_pkg_name
3313: || '.'
3314: || l_api_name
3311: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3312: gme_debug.put_line ( g_pkg_name
3313: || '.'
3314: || l_api_name
3315: || ' after gme_common_pvt.material_date_change');
3316: gme_debug.put_line
3317: ( g_pkg_name
3318: || '.'
3319: || l_api_name
3341: l_ph_mtl_dtl_rec.subinventory := l_mtl_dtl_rec.subinventory;
3342: l_ph_mtl_dtl_rec.locator_id := l_mtl_dtl_rec.locator_id;
3343: --sunitha ch. bug 5566769 update the revision field of the phantom batch
3344: l_ph_mtl_dtl_rec.revision := l_mtl_dtl_rec.revision;
3345: IF l_status = gme_common_pvt.g_batch_pending AND (l_mtl_dtl_rec.plan_qty <> l_db_mtl_dtl_rec.plan_qty) THEN
3346: IF (l_mtl_dtl_rec.dtl_um = l_ph_mtl_dtl_rec.dtl_um) THEN
3347: l_ph_mtl_dtl_rec.plan_qty := l_mtl_dtl_rec.plan_qty;
3348: ELSE
3349: l_ph_mtl_dtl_rec.plan_qty := inv_convert.inv_um_convert(item_id => l_mtl_dtl_rec.inventory_item_id
3347: l_ph_mtl_dtl_rec.plan_qty := l_mtl_dtl_rec.plan_qty;
3348: ELSE
3349: l_ph_mtl_dtl_rec.plan_qty := inv_convert.inv_um_convert(item_id => l_mtl_dtl_rec.inventory_item_id
3350: ,organization_id => l_mtl_dtl_rec.organization_id
3351: ,precision => gme_common_pvt.g_precision
3352: ,from_quantity => l_mtl_dtl_rec.plan_qty
3353: ,from_unit => l_mtl_dtl_rec.dtl_um
3354: ,to_unit => l_ph_mtl_dtl_rec.dtl_um
3355: ,from_name => NULL
3360: l_ph_mtl_dtl_rec.wip_plan_qty := l_mtl_dtl_rec.wip_plan_qty;
3361: ELSE
3362: l_ph_mtl_dtl_rec.wip_plan_qty := inv_convert.inv_um_convert(item_id => l_mtl_dtl_rec.inventory_item_id
3363: ,organization_id => l_mtl_dtl_rec.organization_id
3364: ,precision => gme_common_pvt.g_precision
3365: ,from_quantity => l_mtl_dtl_rec.wip_plan_qty
3366: ,from_unit => l_mtl_dtl_rec.dtl_um
3367: ,to_unit => l_ph_mtl_dtl_rec.dtl_um
3368: ,from_name => NULL
3371: END IF;
3372: /* End Bug 4867497 */
3373:
3374: IF l_db_mtl_dtl_rec.phantom_id IS NOT NULL THEN
3375: IF (l_db_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing ) THEN
3376: /*REWORK Sunitha ch. Bug 5353941 Check whether phantom material is associated to
3377: step and call reschedule batch if it is not associated to step or call
3378: rescedule step for that batch if it is associated to step*/
3379: l_ph_batch_header_rec.batch_id := l_db_mtl_dtl_rec.phantom_id;
3404: END IF;
3405: END IF; --IF l_factor <> 1
3406:
3407: IF(l_mtl_dtl_rec.material_requirement_date <> l_db_mtl_dtl_rec.material_requirement_date ) THEN
3408: IF(l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3409: gme_common_pvt.is_material_assoc_to_step
3410: (l_ph_mtl_dtl_rec.material_detail_id )) THEN
3411:
3412: /* REWORK Sunitha Bug 5353941. Following select statement will only execute for ingredient of parent batch and never for product of phantom batch as we have the check of line type to be ingredient. */
3405: END IF; --IF l_factor <> 1
3406:
3407: IF(l_mtl_dtl_rec.material_requirement_date <> l_db_mtl_dtl_rec.material_requirement_date ) THEN
3408: IF(l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3409: gme_common_pvt.is_material_assoc_to_step
3410: (l_ph_mtl_dtl_rec.material_detail_id )) THEN
3411:
3412: /* REWORK Sunitha Bug 5353941. Following select statement will only execute for ingredient of parent batch and never for product of phantom batch as we have the check of line type to be ingredient. */
3413:
3443: ,x_return_status => x_return_status);
3444: END IF;
3445: END IF; --l_mtl_dtl_rec.material_requirement_date <> l_db_mtl_dtl_rec.material_requirement_date
3446: /* End Bug 5353941 REWORK*/
3447: END IF;--IF l_db_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
3448: ELSE -- if it is phantom Product
3449: /*Sunitha Ch. Bug#5391396 rescheduling batch/step when update yield Type
3450: of the Child batch is done */
3451: IF ( l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3447: END IF;--IF l_db_mtl_dtl_rec.line_type = gme_common_pvt.g_line_type_ing
3448: ELSE -- if it is phantom Product
3449: /*Sunitha Ch. Bug#5391396 rescheduling batch/step when update yield Type
3450: of the Child batch is done */
3451: IF ( l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3452: gme_common_pvt.is_material_assoc_to_step
3453: (l_ph_mtl_dtl_rec.material_detail_id )) THEN
3454: SELECT plan_start_date
3455: INTO l_plan_cmplt_date
3448: ELSE -- if it is phantom Product
3449: /*Sunitha Ch. Bug#5391396 rescheduling batch/step when update yield Type
3450: of the Child batch is done */
3451: IF ( l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3452: gme_common_pvt.is_material_assoc_to_step
3453: (l_ph_mtl_dtl_rec.material_detail_id )) THEN
3454: SELECT plan_start_date
3455: INTO l_plan_cmplt_date
3456: FROM gme_batch_steps
3468: WHERE batch_id = l_ph_mtl_dtl_rec.batch_id;
3469: END IF;
3470: l_mtl_dtl_rec.material_requirement_date:=l_plan_cmplt_date;
3471: l_ph_mtl_dtl_rec.material_requirement_date := l_mtl_dtl_rec.material_requirement_date;
3472: IF(l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3473: gme_common_pvt.is_material_assoc_to_step
3474: (l_mtl_dtl_rec.material_detail_id )) THEN
3475:
3476: /* Sunitha Bug 5391396 . Following select statement will only execute for ingredient of parent batch and never for product of phantom batch as we have the check of line type to be ingredient. */
3469: END IF;
3470: l_mtl_dtl_rec.material_requirement_date:=l_plan_cmplt_date;
3471: l_ph_mtl_dtl_rec.material_requirement_date := l_mtl_dtl_rec.material_requirement_date;
3472: IF(l_mtl_dtl_rec.release_type = gme_common_pvt.g_mtl_autobystep_release AND
3473: gme_common_pvt.is_material_assoc_to_step
3474: (l_mtl_dtl_rec.material_detail_id )) THEN
3475:
3476: /* Sunitha Bug 5391396 . Following select statement will only execute for ingredient of parent batch and never for product of phantom batch as we have the check of line type to be ingredient. */
3477: l_batch_step_rec:=p_batch_step_rec;
3549:
3550: -- add material line into invisible move order
3551: gme_move_orders_pvt.create_move_order_lines
3552: (p_move_order_header_id => p_batch_header_rec.move_order_header_id
3553: ,p_move_order_type => gme_common_pvt.g_invis_move_order_type
3554: ,p_material_details_tbl => l_material_detail_tbl
3555: ,x_material_details_tbl => l_out_material_detail_tbl
3556: ,x_trolin_tbl => l_trolin_tbl
3557: ,x_return_status => x_return_status);
3596: l_proc := 'gme_material_details_dbl.update_row';
3597: RAISE error_dbl;
3598: -- nsinghi bug#5208923. added the else part.
3599: ELSE
3600: gme_common_pvt.get_who(x_user_ident => x_material_detail_rec.last_updated_by,
3601: x_login_id => x_material_detail_rec.last_update_login,
3602: x_timestamp => x_material_detail_rec.last_update_date,
3603: x_return_status => x_return_status);
3604: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3601: x_login_id => x_material_detail_rec.last_update_login,
3602: x_timestamp => x_material_detail_rec.last_update_date,
3603: x_return_status => x_return_status);
3604: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3605: l_proc := 'gme_common_pvt.get_who ';
3606: RAISE error_processing;
3607: END IF;
3608:
3609: END IF;
3661: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3662: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': ' || l_proc|| ' error returned');
3663: END IF;
3664: WHEN error_dbl THEN
3665: gme_common_pvt.log_message ('GME_UNEXPECTED_ERROR', 'ERROR', SQLERRM);
3666: x_return_status := FND_API.g_ret_sts_unexp_error;
3667:
3668: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
3669: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': '
3731: l_batch_status := p_batch_header_rec.batch_status;
3732: l_step_status := p_batch_step_rec.step_status;
3733:
3734: IF p_material_detail_rec.formulaline_id IS NOT NULL THEN
3735: gme_common_pvt.log_message ('GME_FORMID_CHG_NOT_ALLOWED');
3736: RAISE error_no_upd;
3737: END IF;
3738:
3739: IF p_material_detail_rec.inventory_item_id IS NOT NULL THEN
3736: RAISE error_no_upd;
3737: END IF;
3738:
3739: IF p_material_detail_rec.inventory_item_id IS NOT NULL THEN
3740: gme_common_pvt.log_message ('GME_ITEMID_CHG_NOT_ALLOWED');
3741: RAISE error_no_upd;
3742: END IF;
3743:
3744: --Bug#5078853
3745: IF p_material_detail_rec.phantom_line_id IS NOT NULL OR
3746: p_material_detail_rec.backordered_qty IS NOT NULL OR
3747: p_material_detail_rec.original_primary_qty IS NOT NULL OR
3748: p_material_detail_rec.move_order_line_id IS NOT NULL THEN
3749: gme_common_pvt.log_message ('GME_FIELD_CHG_NOT_ALLOWED');
3750: RAISE error_no_upd;
3751: END IF;
3752:
3753: get_item_rec
3776: END IF;
3777: END IF;
3778: END IF;
3779:
3780: IF x_material_detail_rec.line_type = gme_common_pvt.g_line_type_byprod THEN
3781: IF p_material_detail_rec.by_product_type IS NOT NULL THEN
3782: IF p_material_detail_rec.by_product_type = fnd_api.g_miss_char THEN
3783: x_material_detail_rec.by_product_type := NULL;
3784: ELSE
3800: x_material_detail_rec.by_product_type := NULL;
3801: END IF;
3802:
3803: IF p_material_detail_rec.release_type IS NOT NULL THEN
3804: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending THEN
3805: IF p_material_detail_rec.release_type = fnd_api.g_miss_num THEN
3806: l_field := 'release_type';
3807: RAISE error_no_null;
3808: ELSE
3818: RAISE val_error;
3819: END IF;
3820: END IF;
3821: ELSE
3822: gme_common_pvt.log_message ('GME_INV_STAT_UPD_REL');
3823: RAISE expected_error;
3824: END IF;
3825: END IF;
3826:
3825: END IF;
3826:
3827: -- Set status of material based on release type, assocation and step status
3828: IF x_material_detail_rec.release_type =
3829: gme_common_pvt.g_mtl_autobystep_release
3830: AND p_batch_step_rec.batchstep_id IS NOT NULL THEN
3831: l_status := p_batch_step_rec.step_status;
3832: ELSE
3833: l_status := p_batch_header_rec.batch_status;
3833: l_status := p_batch_header_rec.batch_status;
3834: END IF;
3835:
3836: IF p_material_detail_rec.plan_qty IS NOT NULL THEN
3837: IF l_batch_status = gme_common_pvt.g_batch_pending THEN
3838: IF p_material_detail_rec.plan_qty = fnd_api.g_miss_num THEN
3839: l_field := 'plan_qty';
3840: RAISE error_no_null;
3841: ELSE
3850: RAISE val_error;
3851: END IF;
3852: END IF;
3853: ELSE
3854: gme_common_pvt.log_message ('GME_INV_STAT_UPD_PLAN_QTY');
3855: RAISE expected_error;
3856: END IF;
3857: END IF;
3858:
3856: END IF;
3857: END IF;
3858:
3859: IF p_material_detail_rec.dtl_um IS NOT NULL THEN
3860: IF l_batch_status = gme_common_pvt.g_batch_pending THEN
3861: IF p_material_detail_rec.dtl_um = fnd_api.g_miss_char THEN
3862: l_field := 'dtl_um';
3863: RAISE error_no_null;
3864: ELSE
3877: RAISE val_error;
3878: END IF;
3879: END IF;
3880: ELSE
3881: gme_common_pvt.log_message ('GME_INV_STAT_UPD_DTL_UM');
3882: RAISE expected_error;
3883: END IF;
3884: END IF;
3885:
3883: END IF;
3884: END IF;
3885:
3886: IF p_material_detail_rec.wip_plan_qty IS NOT NULL THEN
3887: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_wip THEN
3888: IF p_material_detail_rec.wip_plan_qty = fnd_api.g_miss_num THEN
3889: l_field := 'wip_plan_qty';
3890: RAISE error_no_null;
3891: ELSE
3900: RAISE val_error;
3901: END IF;
3902: END IF;
3903: ELSE
3904: gme_common_pvt.log_message ('GME_INV_STAT_UPD_WIP_PLAN');
3905: RAISE expected_error;
3906: END IF;
3907: END IF;
3908:
3907: END IF;
3908:
3909: --Bug#5078853 modified validation for actual qty
3910: IF p_material_detail_rec.actual_qty IS NOT NULL THEN
3911: IF p_batch_header_rec.batch_status IN (gme_common_pvt.g_batch_wip,
3912: gme_common_pvt.g_batch_completed )THEN
3913: IF p_material_detail_rec.actual_qty = fnd_api.g_miss_num THEN
3914: l_field := 'actual_qty';
3915: RAISE error_no_null;
3908:
3909: --Bug#5078853 modified validation for actual qty
3910: IF p_material_detail_rec.actual_qty IS NOT NULL THEN
3911: IF p_batch_header_rec.batch_status IN (gme_common_pvt.g_batch_wip,
3912: gme_common_pvt.g_batch_completed )THEN
3913: IF p_material_detail_rec.actual_qty = fnd_api.g_miss_num THEN
3914: l_field := 'actual_qty';
3915: RAISE error_no_null;
3916: ELSE
3924: RAISE val_error;
3925: END IF;
3926: END IF;
3927: ELSE
3928: gme_common_pvt.log_message ('GME_INV_STAT_UPD_ACT');
3929: RAISE expected_error;
3930: END IF; /*status check */
3931: END IF;
3932:
3931: END IF;
3932:
3933: --Bug#5078853 allow scrap factor to be changed in pending
3934: -- don't allow NULL
3935: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending AND
3936: p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
3937:
3938: IF p_material_detail_rec.scrap_factor IS NOT NULL THEN
3939: IF p_material_detail_rec.scrap_factor = fnd_api.g_miss_num THEN
3932:
3933: --Bug#5078853 allow scrap factor to be changed in pending
3934: -- don't allow NULL
3935: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending AND
3936: p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
3937:
3938: IF p_material_detail_rec.scrap_factor IS NOT NULL THEN
3939: IF p_material_detail_rec.scrap_factor = fnd_api.g_miss_num THEN
3940: l_field := 'scrap_factor';
3964: END IF;
3965:
3966: --Bug#5078853 scale type can be changed in both pending and WIP
3967: IF p_material_detail_rec.scale_type IS NOT NULL THEN
3968: IF p_batch_header_rec.batch_status IN ( gme_common_pvt.g_batch_pending,
3969: gme_common_pvt.g_batch_wip ) THEN
3970: -- scale_type can be changed, but not to NULL
3971: IF p_material_detail_rec.scale_type = fnd_api.g_miss_num THEN
3972: l_field := 'scale_type';
3965:
3966: --Bug#5078853 scale type can be changed in both pending and WIP
3967: IF p_material_detail_rec.scale_type IS NOT NULL THEN
3968: IF p_batch_header_rec.batch_status IN ( gme_common_pvt.g_batch_pending,
3969: gme_common_pvt.g_batch_wip ) THEN
3970: -- scale_type can be changed, but not to NULL
3971: IF p_material_detail_rec.scale_type = fnd_api.g_miss_num THEN
3972: l_field := 'scale_type';
3973: RAISE error_no_null;
4024: x_material_detail_rec.scale_rounding_variance := NULL;
4025: x_material_detail_rec.rounding_direction := NULL;
4026: END IF; /* x_material_detail_rec.scale_type = 2 */
4027: ELSE
4028: gme_common_pvt.log_message ('GME_INV_STAT_UPD_SCALE_TYPE');
4029: RAISE expected_error;
4030: END IF; /* status check */
4031: END IF; /* p_material_detail_rec.scale_type IS NOT NULL */
4032:
4030: END IF; /* status check */
4031: END IF; /* p_material_detail_rec.scale_type IS NOT NULL */
4032:
4033: -- can change cost alloc for product; ignore other line types
4034: IF x_material_detail_rec.line_type = gme_common_pvt.g_line_type_prod THEN
4035: -- validate 0 <= cost_alloc <= 1
4036: -- at save_batch, check that sum(cost_alloc for all products) <= 1
4037: validate_cost_alloc
4038: (p_material_detail_rec => p_material_detail_rec
4048: --Bug#5078853 modified
4049: -- can change phantom type for ingredient only if not exploded;
4050: -- error otherwise
4051: IF p_material_detail_rec.phantom_type IS NOT NULL
4052: AND x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing
4053: AND x_material_detail_rec.phantom_id IS NULL
4054: AND p_material_detail_rec.phantom_type <> x_material_detail_rec.phantom_type THEN
4055:
4056: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending THEN
4052: AND x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing
4053: AND x_material_detail_rec.phantom_id IS NULL
4054: AND p_material_detail_rec.phantom_type <> x_material_detail_rec.phantom_type THEN
4055:
4056: IF p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending THEN
4057: x_material_detail_rec.phantom_type := p_material_detail_rec.phantom_type;
4058:
4059: validate_phantom_type
4060: (p_phantom_type => x_material_detail_rec.phantom_type
4072: l_val_proc := 'validate_phantom_type_change';
4073: RAISE val_error;
4074: END IF;
4075: ELSE
4076: gme_common_pvt.log_message ('GME_INV_STAT_UPD_PHAN_TYPE');
4077: RAISE expected_error;
4078: END IF; /* batch status check */
4079: END IF;
4080:
4078: END IF; /* batch status check */
4079: END IF;
4080:
4081: -- can't update to NULL; only update for ingred, ignore other line type
4082: IF x_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing THEN
4083: validate_contr_yield_ind
4084: (p_contr_yield_ind => x_material_detail_rec.contribute_yield_ind
4085: ,x_return_status => x_return_status);
4086:
4162: END IF;
4163: END IF;
4164:
4165: /* Bug#5078853 added the following call for flex field validation
4166: gme_common_pvt.g_flex_validate_prof has to be set in public API to enforce flex field validation
4167: l_material_detail_rec will have flex field values passed from public API , if any*/
4168:
4169: l_material_detail_rec.material_detail_id := x_material_detail_rec.material_detail_id;
4170: gme_validate_flex_fld_pvt.validate_flex_material_details
4182: END IF;
4183:
4184: EXCEPTION
4185: WHEN error_no_null THEN
4186: gme_common_pvt.log_message ('GME_INVALID_VALUE_SPECIFIED'
4187: ,'FIELD_NAME'
4188: ,l_field);
4189: x_return_status := fnd_api.g_ret_sts_error;
4190: WHEN error_no_upd OR expected_error THEN
4263: x_return_status := fnd_api.g_ret_sts_success;
4264:
4265: /* validate batch for material deletion */
4266: IF p_batch_header_rec.batch_type <> 0 THEN
4267: gme_common_pvt.log_message('GME_INV_BATCH_TYPE_OPER');
4268: RAISE val_error;
4269: END IF;
4270:
4271: --Fetch allow material deletion profile
4274: CLOSE c_get_delete;
4275:
4276: l_delete_ind := NVL(l_delete_ind, 1);
4277:
4278: IF NOT( p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending OR
4279: (l_delete_ind = 2 AND
4280: p_batch_header_rec.batch_status = gme_common_pvt.g_batch_wip AND
4281: p_batch_header_rec. automatic_step_calculation = 0)
4282: ) THEN
4276: l_delete_ind := NVL(l_delete_ind, 1);
4277:
4278: IF NOT( p_batch_header_rec.batch_status = gme_common_pvt.g_batch_pending OR
4279: (l_delete_ind = 2 AND
4280: p_batch_header_rec.batch_status = gme_common_pvt.g_batch_wip AND
4281: p_batch_header_rec. automatic_step_calculation = 0)
4282: ) THEN
4283: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
4284: RAISE val_error;
4279: (l_delete_ind = 2 AND
4280: p_batch_header_rec.batch_status = gme_common_pvt.g_batch_wip AND
4281: p_batch_header_rec. automatic_step_calculation = 0)
4282: ) THEN
4283: gme_common_pvt.log_message ('GME_INV_BATCH_STATUS_OPER');
4284: RAISE val_error;
4285: END IF;
4286:
4287: /* check step status if material is assocaited to step */
4285: END IF;
4286:
4287: /* check step status if material is assocaited to step */
4288: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
4289: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
4290: ,gme_common_pvt.g_step_wip)) THEN
4291: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
4292: RAISE val_error;
4293: END IF;
4286:
4287: /* check step status if material is assocaited to step */
4288: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
4289: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
4290: ,gme_common_pvt.g_step_wip)) THEN
4291: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
4292: RAISE val_error;
4293: END IF;
4294: END IF; /* p_batch_step_rec.batchstep_id IS NOT NULL */
4287: /* check step status if material is assocaited to step */
4288: IF p_batch_step_rec.batchstep_id IS NOT NULL THEN
4289: IF (p_batch_step_rec.step_status NOT IN (gme_common_pvt.g_step_pending
4290: ,gme_common_pvt.g_step_wip)) THEN
4291: gme_common_pvt.log_message('PC_STEP_STATUS_ERR');
4292: RAISE val_error;
4293: END IF;
4294: END IF; /* p_batch_step_rec.batchstep_id IS NOT NULL */
4295:
4293: END IF;
4294: END IF; /* p_batch_step_rec.batchstep_id IS NOT NULL */
4295:
4296: --line can't be deleted if line is ing and has an exploded phantom
4297: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing AND
4298: p_material_detail_rec.phantom_id IS NOT NULL THEN
4299: gme_common_pvt.log_message('GME_NO_DEL_PHANT_ING');
4300: RAISE val_error;
4301: END IF; /* exploded phantom check */
4295:
4296: --line can't be deleted if line is ing and has an exploded phantom
4297: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_ing AND
4298: p_material_detail_rec.phantom_id IS NOT NULL THEN
4299: gme_common_pvt.log_message('GME_NO_DEL_PHANT_ING');
4300: RAISE val_error;
4301: END IF; /* exploded phantom check */
4302:
4303: /* if there is only one ingredient or product we should not the delete */
4300: RAISE val_error;
4301: END IF; /* exploded phantom check */
4302:
4303: /* if there is only one ingredient or product we should not the delete */
4304: IF p_material_detail_rec.line_type IN (gme_common_pvt.g_line_type_ing,
4305: gme_common_pvt.g_line_type_prod) THEN
4306: OPEN num_detail_lines(p_batch_header_rec.batch_id,p_material_detail_rec.line_type);
4307: FETCH num_detail_lines INTO l_material_count;
4308: CLOSE num_detail_lines;
4301: END IF; /* exploded phantom check */
4302:
4303: /* if there is only one ingredient or product we should not the delete */
4304: IF p_material_detail_rec.line_type IN (gme_common_pvt.g_line_type_ing,
4305: gme_common_pvt.g_line_type_prod) THEN
4306: OPEN num_detail_lines(p_batch_header_rec.batch_id,p_material_detail_rec.line_type);
4307: FETCH num_detail_lines INTO l_material_count;
4308: CLOSE num_detail_lines;
4309: IF l_material_count = 1 THEN
4306: OPEN num_detail_lines(p_batch_header_rec.batch_id,p_material_detail_rec.line_type);
4307: FETCH num_detail_lines INTO l_material_count;
4308: CLOSE num_detail_lines;
4309: IF l_material_count = 1 THEN
4310: gme_common_pvt.log_message('GME_ONE_ING_PROD_REQD');
4311: RAISE val_error;
4312: END IF;
4313: END IF; /* number of lines check */
4314:
4311: RAISE val_error;
4312: END IF;
4313: END IF; /* number of lines check */
4314:
4315: IF p_material_detail_rec.line_type = gme_common_pvt.g_line_type_prod THEN
4316: --if product is primary product then donot allow deletion
4317: OPEN c_prim_prod(p_batch_header_rec.recipe_validity_rule_id, p_material_detail_rec.material_detail_id);
4318: FETCH c_prim_prod INTO l_dummy;
4319: IF c_prim_prod%FOUND THEN
4317: OPEN c_prim_prod(p_batch_header_rec.recipe_validity_rule_id, p_material_detail_rec.material_detail_id);
4318: FETCH c_prim_prod INTO l_dummy;
4319: IF c_prim_prod%FOUND THEN
4320: CLOSE c_prim_prod;
4321: gme_common_pvt.log_message('GME_PRIM_PROD_NO_DEL');
4322: RAISE val_error;
4323: END IF;
4324: CLOSE c_prim_prod;
4325:
4326: /*OPEN cur_parent_phant(p_batch_header_rec.batch_id, p_material_detail_rec.inventory_item_id);
4327: FETCH cur_parent_phant INTO l_dummy;
4328: IF cur_parent_phant%FOUND THEN
4329: CLOSE cur_parent_phant;
4330: gme_common_pvt.log_message('GME_NO_DEL_PHANT_PROD');
4331: RAISE val_error;
4332: END IF;
4333: CLOSE cur_parent_phant; */
4334: END IF; /* line type check */
4372: IF gme_reservations_pvt.pending_reservations_exist
4373: (p_organization_id => p_material_detail_rec.organization_id
4374: ,p_batch_id => p_material_detail_rec.batch_id
4375: ,p_material_detail_id => p_material_detail_rec.material_detail_id) THEN
4376: gme_common_pvt.log_message ('GME_PENDING_RSRV_EXIST');
4377: RAISE val_error;
4378: END IF;
4379:
4380: IF gme_move_orders_pvt.pending_move_orders_exist
4380: IF gme_move_orders_pvt.pending_move_orders_exist
4381: (p_organization_id => p_material_detail_rec.organization_id
4382: ,p_batch_id => p_material_detail_rec.batch_id
4383: ,p_material_detail_id => p_material_detail_rec.material_detail_id) THEN
4384: gme_common_pvt.log_message ('GME_PENDING_MO_EXIST');
4385: RAISE val_error;
4386: END IF;
4387:
4388: IF nvl(g_debug, gme_debug.g_log_procedure + 1) <= gme_debug.g_log_procedure THEN
4419: l_batch_step_rec gme_batch_steps%ROWTYPE;
4420: l_rsc_count NUMBER;
4421: l_proc VARCHAR2(100);
4422:
4423: l_mmt_tbl gme_common_pvt.mtl_mat_tran_tbl;
4424:
4425: error_processing EXCEPTION;
4426: error_dbl EXCEPTION;
4427:
4524:
4525: -- renumber subsequent lines
4526: UPDATE gme_material_details
4527: SET line_no = line_no - 1
4528: ,last_updated_by = gme_common_pvt.g_user_ident
4529: ,last_update_date = gme_common_pvt.g_timestamp
4530: ,last_update_login = gme_common_pvt.g_login_id
4531: WHERE batch_id = p_material_detail_rec.batch_id
4532: AND line_type = p_material_detail_rec.line_type
4525: -- renumber subsequent lines
4526: UPDATE gme_material_details
4527: SET line_no = line_no - 1
4528: ,last_updated_by = gme_common_pvt.g_user_ident
4529: ,last_update_date = gme_common_pvt.g_timestamp
4530: ,last_update_login = gme_common_pvt.g_login_id
4531: WHERE batch_id = p_material_detail_rec.batch_id
4532: AND line_type = p_material_detail_rec.line_type
4533: AND line_no >= p_material_detail_rec.line_no;
4526: UPDATE gme_material_details
4527: SET line_no = line_no - 1
4528: ,last_updated_by = gme_common_pvt.g_user_ident
4529: ,last_update_date = gme_common_pvt.g_timestamp
4530: ,last_update_login = gme_common_pvt.g_login_id
4531: WHERE batch_id = p_material_detail_rec.batch_id
4532: AND line_type = p_material_detail_rec.line_type
4533: AND line_no >= p_material_detail_rec.line_no;
4534:
4579: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
4580: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': ' || l_proc|| ' error returned');
4581: END IF;
4582: WHEN error_dbl THEN
4583: gme_common_pvt.log_message ('GME_UNEXPECTED_ERROR', 'ERROR', SQLERRM);
4584: x_return_status := FND_API.g_ret_sts_unexp_error;
4585:
4586: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
4587: gme_debug.put_line (g_pkg_name||'.'||l_api_name|| ': '