135: IS
136: l_count NUMBER;
137: l_api_name CONSTANT VARCHAR2 (30) := 'CONSTRUCT_BATCH_HEADER';
138: BEGIN
139: IF g_debug <= gme_debug.g_log_procedure THEN
140: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
141: || l_api_name);
142: END IF;
143:
136: l_count NUMBER;
137: l_api_name CONSTANT VARCHAR2 (30) := 'CONSTRUCT_BATCH_HEADER';
138: BEGIN
139: IF g_debug <= gme_debug.g_log_procedure THEN
140: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
141: || l_api_name);
142: END IF;
143:
144: /* Create defaults for mandatory columns that have not been specified */
177: RETURN TRUE;
178: END IF;
179: EXCEPTION
180: WHEN OTHERS THEN
181: IF g_debug <= gme_debug.g_log_unexpected THEN
182: gme_debug.put_line ( 'When others exception in '
183: || g_pkg_name
184: || '.'
185: || l_api_name
178: END IF;
179: EXCEPTION
180: WHEN OTHERS THEN
181: IF g_debug <= gme_debug.g_log_unexpected THEN
182: gme_debug.put_line ( 'When others exception in '
183: || g_pkg_name
184: || '.'
185: || l_api_name
186: || ' Error is '
217: WHEN duplicate_wip_entity THEN
218: x_return_status := fnd_api.g_ret_sts_error;
219: gme_common_pvt.log_message('GME_WIP_ENTITY_EXISTS');
220: WHEN OTHERS THEN
221: IF g_debug <= gme_debug.g_log_unexpected THEN
222: gme_debug.put_line ( 'When others exception in '
223: || g_pkg_name
224: || '.'
225: || l_api_name
218: x_return_status := fnd_api.g_ret_sts_error;
219: gme_common_pvt.log_message('GME_WIP_ENTITY_EXISTS');
220: WHEN OTHERS THEN
221: IF g_debug <= gme_debug.g_log_unexpected THEN
222: gme_debug.put_line ( 'When others exception in '
223: || g_pkg_name
224: || '.'
225: || l_api_name
226: || ' Error is '
541: Fixed_process_loss_failure EXCEPTION;
542: -- Rajesh Patangya Bug # 6752637
543: update_step_mtq_failure EXCEPTION;
544: BEGIN
545: IF g_debug <= gme_debug.g_log_procedure THEN
546: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
547: || l_api_name);
548: END IF;
549: x_return_status := fnd_api.g_ret_sts_success;
542: -- Rajesh Patangya Bug # 6752637
543: update_step_mtq_failure EXCEPTION;
544: BEGIN
545: IF g_debug <= gme_debug.g_log_procedure THEN
546: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
547: || l_api_name);
548: END IF;
549: x_return_status := fnd_api.g_ret_sts_success;
550: -- Initialize output batch header
568: FETCH cur_get_doc_ord
569: INTO l_doc_numbering;
570:
571: CLOSE cur_get_doc_ord;
572: IF g_debug <= gme_debug.g_log_procedure THEN
573: gme_debug.put_line ('BEfore document numbering check' || g_pkg_name || '.'
574: || l_api_name);
575: END IF;
576: IF l_doc_numbering = 1 THEN
569: INTO l_doc_numbering;
570:
571: CLOSE cur_get_doc_ord;
572: IF g_debug <= gme_debug.g_log_procedure THEN
573: gme_debug.put_line ('BEfore document numbering check' || g_pkg_name || '.'
574: || l_api_name);
575: END IF;
576: IF l_doc_numbering = 1 THEN
577: IF x_batch_header_rec.batch_no IS NULL THEN
593: END IF;
594: END IF;
595: END IF; /* x_batch_header_rec.batch_no IS NULL */
596: END IF; /* IF l_doc_numbering = 1 */
597: IF g_debug <= gme_debug.g_log_procedure THEN
598: gme_debug.put_line ('before laboratory check' || g_pkg_name || '.'
599: || l_api_name);
600: END IF;
601:
594: END IF;
595: END IF; /* x_batch_header_rec.batch_no IS NULL */
596: END IF; /* IF l_doc_numbering = 1 */
597: IF g_debug <= gme_debug.g_log_procedure THEN
598: gme_debug.put_line ('before laboratory check' || g_pkg_name || '.'
599: || l_api_name);
600: END IF;
601:
602: IF (gme_common_pvt.g_lab_ind = 1 AND gme_common_pvt.g_plant_ind = 1) THEN
615: ELSIF (gme_common_pvt.g_plant_ind = 1) THEN
616: x_batch_header_rec.laboratory_ind := 0;
617: x_batch_header_rec.update_inventory_ind := 'Y';
618: END IF;
619: IF g_debug <= gme_debug.g_log_procedure THEN
620: gme_debug.put_line ('After laboratory check' || g_pkg_name || '.'
621: || l_api_name);
622: END IF;
623:
616: x_batch_header_rec.laboratory_ind := 0;
617: x_batch_header_rec.update_inventory_ind := 'Y';
618: END IF;
619: IF g_debug <= gme_debug.g_log_procedure THEN
620: gme_debug.put_line ('After laboratory check' || g_pkg_name || '.'
621: || l_api_name);
622: END IF;
623:
624: -- Validate/fill in batch header columns
628:
629: IF NOT l_return THEN
630: RAISE invalid_header_values;
631: END IF;
632: IF g_debug <= gme_debug.g_log_procedure THEN
633: gme_debug.put_line ('After contruct batch header' || g_pkg_name || '.'
634: || l_api_name);
635: END IF;
636:
629: IF NOT l_return THEN
630: RAISE invalid_header_values;
631: END IF;
632: IF g_debug <= gme_debug.g_log_procedure THEN
633: gme_debug.put_line ('After contruct batch header' || g_pkg_name || '.'
634: || l_api_name);
635: END IF;
636:
637: IF g_debug <= gme_debug.g_log_statement THEN
633: gme_debug.put_line ('After contruct batch header' || g_pkg_name || '.'
634: || l_api_name);
635: END IF;
636:
637: IF g_debug <= gme_debug.g_log_statement THEN
638: gme_debug.put_line ( g_pkg_name
639: || '.'
640: || l_api_name
641: || 'Starting Validity rule processing');
634: || l_api_name);
635: END IF;
636:
637: IF g_debug <= gme_debug.g_log_statement THEN
638: gme_debug.put_line ( g_pkg_name
639: || '.'
640: || l_api_name
641: || 'Starting Validity rule processing');
642: END IF;
666: gme_common_pvt.log_message ('GME_API_INVALID_RULE');
667: RAISE expected_error;
668: END IF;
669:
670: IF g_debug <= gme_debug.g_log_statement THEN
671: gme_debug.put_line ( g_pkg_name
672: || '.'
673: || l_api_name
674: || 'Calling gmd_recipe_data_pub.get_recipe_data');
667: RAISE expected_error;
668: END IF;
669:
670: IF g_debug <= gme_debug.g_log_statement THEN
671: gme_debug.put_line ( g_pkg_name
672: || '.'
673: || l_api_name
674: || 'Calling gmd_recipe_data_pub.get_recipe_data');
675: END IF;
691: ,x_oprn_resc_rec => gme_common_pvt.resources
692: ,x_formula_header_rec => l_formula_master
693: ,x_formula_dtl_tbl => gme_common_pvt.materials
694: ,x_recp_resc_proc_param_tbl => gme_common_pvt.process_parameters);
695: IF g_debug <= gme_debug.g_log_statement THEN
696: gme_debug.put_line
697: ( g_pkg_name
698: || '.'
699: || l_api_name
692: ,x_formula_header_rec => l_formula_master
693: ,x_formula_dtl_tbl => gme_common_pvt.materials
694: ,x_recp_resc_proc_param_tbl => gme_common_pvt.process_parameters);
695: IF g_debug <= gme_debug.g_log_statement THEN
696: gme_debug.put_line
697: ( g_pkg_name
698: || '.'
699: || l_api_name
700: || 'Return from gmd_recipe_data_pub.get_recipe_data '
713: l_recipe.routing_id := gme_common_pvt.routings(1).routing_id;
714: END IF;
715: END IF; /* IF p_creation_mode <> 'LCF' THEN */
716:
717: IF (g_debug = gme_debug.g_log_statement) THEN
718: gme_debug.put_line ( g_pkg_name
719: || ':Creation mode '
720: || p_creation_mode
721: || ' Batch size '
714: END IF;
715: END IF; /* IF p_creation_mode <> 'LCF' THEN */
716:
717: IF (g_debug = gme_debug.g_log_statement) THEN
718: gme_debug.put_line ( g_pkg_name
719: || ':Creation mode '
720: || p_creation_mode
721: || ' Batch size '
722: || p_batch_size
721: || ' Batch size '
722: || p_batch_size
723: || ' '
724: || p_batch_size_uom);
725: gme_debug.put_line ('Return Status was ' || l_return_status);
726: gme_debug.put_line ('return_code = ' || TO_CHAR (l_return_code) );
727: gme_debug.put_line ( '# of Steps = '
728: || TO_CHAR (gme_common_pvt.steps.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
722: || p_batch_size
723: || ' '
724: || p_batch_size_uom);
725: gme_debug.put_line ('Return Status was ' || l_return_status);
726: gme_debug.put_line ('return_code = ' || TO_CHAR (l_return_code) );
727: gme_debug.put_line ( '# of Steps = '
728: || TO_CHAR (gme_common_pvt.steps.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
730: || TO_CHAR (gme_common_pvt.activities.COUNT) );
723: || ' '
724: || p_batch_size_uom);
725: gme_debug.put_line ('Return Status was ' || l_return_status);
726: gme_debug.put_line ('return_code = ' || TO_CHAR (l_return_code) );
727: gme_debug.put_line ( '# of Steps = '
728: || TO_CHAR (gme_common_pvt.steps.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
730: || TO_CHAR (gme_common_pvt.activities.COUNT) );
731: gme_debug.put_line ( '# of Rsrc = '
725: gme_debug.put_line ('Return Status was ' || l_return_status);
726: gme_debug.put_line ('return_code = ' || TO_CHAR (l_return_code) );
727: gme_debug.put_line ( '# of Steps = '
728: || TO_CHAR (gme_common_pvt.steps.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
730: || TO_CHAR (gme_common_pvt.activities.COUNT) );
731: gme_debug.put_line ( '# of Rsrc = '
732: || TO_CHAR (gme_common_pvt.resources.COUNT) );
733: gme_debug.put_line ( '# of Matl = '
727: gme_debug.put_line ( '# of Steps = '
728: || TO_CHAR (gme_common_pvt.steps.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
730: || TO_CHAR (gme_common_pvt.activities.COUNT) );
731: gme_debug.put_line ( '# of Rsrc = '
732: || TO_CHAR (gme_common_pvt.resources.COUNT) );
733: gme_debug.put_line ( '# of Matl = '
734: || TO_CHAR
735: (gme_common_pvt.routing_materials.COUNT) );
729: gme_debug.put_line ( '# of Acts = '
730: || TO_CHAR (gme_common_pvt.activities.COUNT) );
731: gme_debug.put_line ( '# of Rsrc = '
732: || TO_CHAR (gme_common_pvt.resources.COUNT) );
733: gme_debug.put_line ( '# of Matl = '
734: || TO_CHAR
735: (gme_common_pvt.routing_materials.COUNT) );
736: gme_debug.put_line ( '# of Depd = '
737: || TO_CHAR
732: || TO_CHAR (gme_common_pvt.resources.COUNT) );
733: gme_debug.put_line ( '# of Matl = '
734: || TO_CHAR
735: (gme_common_pvt.routing_materials.COUNT) );
736: gme_debug.put_line ( '# of Depd = '
737: || TO_CHAR
738: (gme_common_pvt.step_dependencies.COUNT) );
739: gme_debug.put_line ( '# of Lines = '
740: || TO_CHAR (gme_common_pvt.materials.COUNT) );
735: (gme_common_pvt.routing_materials.COUNT) );
736: gme_debug.put_line ( '# of Depd = '
737: || TO_CHAR
738: (gme_common_pvt.step_dependencies.COUNT) );
739: gme_debug.put_line ( '# of Lines = '
740: || TO_CHAR (gme_common_pvt.materials.COUNT) );
741: END IF;
742:
743: IF l_return_status <> fnd_api.g_ret_sts_success THEN
772: l_number_of_formula_lines := 0;
773: l_total_input_qty := 0;
774: l_total_output_qty := 0;
775:
776: IF g_debug <= gme_debug.g_log_statement THEN
777: gme_debug.put_line ( g_pkg_name
778: || '.'
779: || l_api_name
780: || 'Start material processing');
773: l_total_input_qty := 0;
774: l_total_output_qty := 0;
775:
776: IF g_debug <= gme_debug.g_log_statement THEN
777: gme_debug.put_line ( g_pkg_name
778: || '.'
779: || l_api_name
780: || 'Start material processing');
781: END IF;
923: END IF;
924: END IF; /* l_item_master.inventory_item_id IS NULL OR */
925: END LOOP; /* l_formula_material IN formula_details_cursor */
926:
927: IF g_debug <= gme_debug.g_log_statement THEN
928: gme_debug.put_line ( g_pkg_name
929: || '.'
930: || l_api_name
931: || 'Finished material processing');
924: END IF; /* l_item_master.inventory_item_id IS NULL OR */
925: END LOOP; /* l_formula_material IN formula_details_cursor */
926:
927: IF g_debug <= gme_debug.g_log_statement THEN
928: gme_debug.put_line ( g_pkg_name
929: || '.'
930: || l_api_name
931: || 'Finished material processing');
932: END IF;
1017: ,NULL
1018: ,NULL);
1019:
1020: IF l_temp_qty < 0 THEN
1021: IF (g_debug = gme_debug.g_log_statement) THEN
1022: gme_debug.put_line
1023: ('Failed in UOM Conv from formula product UOM to requested UOM');
1024: END IF;
1025:
1018: ,NULL);
1019:
1020: IF l_temp_qty < 0 THEN
1021: IF (g_debug = gme_debug.g_log_statement) THEN
1022: gme_debug.put_line
1023: ('Failed in UOM Conv from formula product UOM to requested UOM');
1024: END IF;
1025:
1026: l_item_id :=
1067: IF production_rules_cursor%NOTFOUND THEN
1068: l_primaries := 'OUTPUTS';
1069: gme_common_pvt.g_batch_scale_factor := 1;
1070:
1071: IF (g_debug = gme_debug.g_log_statement) THEN
1072: gme_debug.put_line
1073: ('CREATING BY RECIPE/VERSION WITHOUT SCALING');
1074: END IF;
1075: ELSE
1068: l_primaries := 'OUTPUTS';
1069: gme_common_pvt.g_batch_scale_factor := 1;
1070:
1071: IF (g_debug = gme_debug.g_log_statement) THEN
1072: gme_debug.put_line
1073: ('CREATING BY RECIPE/VERSION WITHOUT SCALING');
1074: END IF;
1075: ELSE
1076: l_total_output_qty := 0;
1094: ,NULL
1095: ,NULL);
1096:
1097: IF l_temp_qty < 0 THEN
1098: IF (g_debug = gme_debug.g_log_statement) THEN
1099: gme_debug.put_line
1100: ('Failed in UOM Conv from formula product UOM to requested UOM');
1101: END IF;
1102:
1095: ,NULL);
1096:
1097: IF l_temp_qty < 0 THEN
1098: IF (g_debug = gme_debug.g_log_statement) THEN
1099: gme_debug.put_line
1100: ('Failed in UOM Conv from formula product UOM to requested UOM');
1101: END IF;
1102:
1103: l_item_id :=
1197: ,NULL
1198: ,NULL);
1199:
1200: IF l_temp_qty < 0 THEN
1201: IF (g_debug = gme_debug.g_log_statement) THEN
1202: gme_debug.put_line
1203: ('Failed in UOM Conv from formula product UOM to routing UOM');
1204: END IF;
1205:
1198: ,NULL);
1199:
1200: IF l_temp_qty < 0 THEN
1201: IF (g_debug = gme_debug.g_log_statement) THEN
1202: gme_debug.put_line
1203: ('Failed in UOM Conv from formula product UOM to routing UOM');
1204: END IF;
1205:
1206: l_item_id :=
1216: END IF;
1217: /* l_material_details(loop_count).line_type IN (1, 2) */
1218: END LOOP; /* loop_count IN 1 .. l_number_of_formula_lines */
1219:
1220: IF (g_debug = gme_debug.g_log_statement) THEN
1221: gme_debug.put_line ( 'tot_output before scaling is '
1222: || TO_CHAR (l_total_output_qty_c) );
1223: END IF;
1224: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1217: /* l_material_details(loop_count).line_type IN (1, 2) */
1218: END LOOP; /* loop_count IN 1 .. l_number_of_formula_lines */
1219:
1220: IF (g_debug = gme_debug.g_log_statement) THEN
1221: gme_debug.put_line ( 'tot_output before scaling is '
1222: || TO_CHAR (l_total_output_qty_c) );
1223: END IF;
1224: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1225:
1225:
1226: -- Bug 10624995 - rearrange logic as to handle integer scale items for non scaled batches.
1227: l_change_made := 0;
1228: IF gme_common_pvt.g_batch_scale_factor <> 1 THEN
1229: IF (g_debug = gme_debug.g_log_statement) THEN
1230: gme_debug.put_line
1231: ( 'scale factor is '
1232: || TO_CHAR
1233: (gme_common_pvt.g_batch_scale_factor) );
1226: -- Bug 10624995 - rearrange logic as to handle integer scale items for non scaled batches.
1227: l_change_made := 0;
1228: IF gme_common_pvt.g_batch_scale_factor <> 1 THEN
1229: IF (g_debug = gme_debug.g_log_statement) THEN
1230: gme_debug.put_line
1231: ( 'scale factor is '
1232: || TO_CHAR
1233: (gme_common_pvt.g_batch_scale_factor) );
1234: END IF;
1261: x_return_status => x_return_status);
1262:
1263: x_batch_header_rec.batch_status := gme_common_pvt.g_batch_pending;
1264:
1265: IF (g_debug = gme_debug.g_log_statement) THEN
1266: gme_debug.put_line ( 'return from scale_batch is: '
1267: || x_return_status);
1268: END IF;
1269:
1262:
1263: x_batch_header_rec.batch_status := gme_common_pvt.g_batch_pending;
1264:
1265: IF (g_debug = gme_debug.g_log_statement) THEN
1266: gme_debug.put_line ( 'return from scale_batch is: '
1267: || x_return_status);
1268: END IF;
1269:
1270: IF x_return_status <> fnd_api.g_ret_sts_success THEN
1303: l_scale_rec.qty := l_material_details (loop_count).plan_qty;
1304: l_scale_rec.scale_multiple := l_material_details (loop_count).scale_multiple;
1305: l_scale_rec.rounding_direction := l_material_details (loop_count).rounding_direction;
1306:
1307: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1304: l_scale_rec.scale_multiple := l_material_details (loop_count).scale_multiple;
1305: l_scale_rec.rounding_direction := l_material_details (loop_count).rounding_direction;
1306:
1307: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1312: gme_debug.put_line('rnd direction '||l_scale_rec.rounding_direction);
1305: l_scale_rec.rounding_direction := l_material_details (loop_count).rounding_direction;
1306:
1307: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1312: gme_debug.put_line('rnd direction '||l_scale_rec.rounding_direction);
1313: END IF;
1306:
1307: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1312: gme_debug.put_line('rnd direction '||l_scale_rec.rounding_direction);
1313: END IF;
1314:
1307: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1312: gme_debug.put_line('rnd direction '||l_scale_rec.rounding_direction);
1313: END IF;
1314:
1315: gmd_common_scale.integer_multiple_scale
1308: gme_debug.put_line('values going to int mult scale are: ');
1309: gme_debug.put_line('qty '||l_scale_rec.qty);
1310: gme_debug.put_line('rnd variance '||l_scale_rec.scale_rounding_variance);
1311: gme_debug.put_line('multiple '||l_scale_rec.scale_multiple);
1312: gme_debug.put_line('rnd direction '||l_scale_rec.rounding_direction);
1313: END IF;
1314:
1315: gmd_common_scale.integer_multiple_scale
1316: ( p_scale_rec => l_scale_rec
1324:
1325: l_material_details (loop_count).plan_qty := l_scale_rec_out.qty;
1326: l_material_details (loop_count).original_qty := l_scale_rec_out.qty;
1327:
1328: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1329: gme_debug.put_line('plan actual after integer scaling is '||l_material_details (loop_count).plan_qty);
1330: END IF;
1331: END IF; /* l_material_detail_rec.scale_type = 2 */
1332: END LOOP;
1325: l_material_details (loop_count).plan_qty := l_scale_rec_out.qty;
1326: l_material_details (loop_count).original_qty := l_scale_rec_out.qty;
1327:
1328: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
1329: gme_debug.put_line('plan actual after integer scaling is '||l_material_details (loop_count).plan_qty);
1330: END IF;
1331: END IF; /* l_material_detail_rec.scale_type = 2 */
1332: END LOOP;
1333: -- End herbal life fix.
1360: ,NULL
1361: ,NULL);
1362:
1363: IF l_temp_qty < 0 THEN
1364: IF (g_debug = gme_debug.g_log_statement) THEN
1365: gme_debug.put_line
1366: ('Failed in UOM Conv from formula product UOM to routing UOM');
1367: END IF;
1368:
1361: ,NULL);
1362:
1363: IF l_temp_qty < 0 THEN
1364: IF (g_debug = gme_debug.g_log_statement) THEN
1365: gme_debug.put_line
1366: ('Failed in UOM Conv from formula product UOM to routing UOM');
1367: END IF;
1368:
1369: l_item_id :=
1379: END IF; /* IF routing and formula uoms are same */
1380: END IF; /* If line type > 0 */
1381: END LOOP;
1382:
1383: IF (g_debug = gme_debug.g_log_statement) THEN
1384: gme_debug.put_line ( 'Total Output after scaling is '
1385: || TO_CHAR (l_total_output_qty_b) );
1386: END IF;
1387: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1380: END IF; /* If line type > 0 */
1381: END LOOP;
1382:
1383: IF (g_debug = gme_debug.g_log_statement) THEN
1384: gme_debug.put_line ( 'Total Output after scaling is '
1385: || TO_CHAR (l_total_output_qty_b) );
1386: END IF;
1387: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1388: END IF; /* IF l_change_made */
1445: l_material_details (l_row_count).original_qty;
1446: END IF;
1447: END LOOP; /* l_row_count IN 1 .. l_number_of_formula_lines */
1448:
1449: IF (g_debug = gme_debug.g_log_statement) THEN
1450: gme_debug.put_line ( 'Total Output after Process Loss is '
1451: || TO_CHAR (l_total_output_qty_b) );
1452: END IF;
1453: END IF; /* IF p_creation_mode <> 'LCF' THEN */
1446: END IF;
1447: END LOOP; /* l_row_count IN 1 .. l_number_of_formula_lines */
1448:
1449: IF (g_debug = gme_debug.g_log_statement) THEN
1450: gme_debug.put_line ( 'Total Output after Process Loss is '
1451: || TO_CHAR (l_total_output_qty_b) );
1452: END IF;
1453: END IF; /* IF p_creation_mode <> 'LCF' THEN */
1454:
1502:
1503: gme_common_pvt.g_routing_scale_factor :=
1504: l_total_output_qty_b / l_total_output_qty_c;
1505:
1506: IF (g_debug = gme_debug.g_log_statement) THEN
1507: gme_debug.put_line ( 'Routing scale factor is '
1508: || gme_common_pvt.g_routing_scale_factor);
1509: END IF;
1510: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1503: gme_common_pvt.g_routing_scale_factor :=
1504: l_total_output_qty_b / l_total_output_qty_c;
1505:
1506: IF (g_debug = gme_debug.g_log_statement) THEN
1507: gme_debug.put_line ( 'Routing scale factor is '
1508: || gme_common_pvt.g_routing_scale_factor);
1509: END IF;
1510: END IF; /* IF gme_common_pvt.routings.COUNT <> 0 */
1511: ELSE /* IF l_formula_master.scale_type <> 1 */
1515: END IF;
1516:
1517: -- Fixed Process Loss ME
1518:
1519: IF (g_debug = gme_debug.g_log_statement) THEN
1520: gme_debug.put_line ('Before calling the Fixed Proccess Loss '
1521: || p_batch_header_rec.fixed_process_loss_applied);
1522: END IF;
1523:
1516:
1517: -- Fixed Process Loss ME
1518:
1519: IF (g_debug = gme_debug.g_log_statement) THEN
1520: gme_debug.put_line ('Before calling the Fixed Proccess Loss '
1521: || p_batch_header_rec.fixed_process_loss_applied);
1522: END IF;
1523:
1524: IF(p_batch_header_rec.fixed_process_loss_applied = 'Y') THEN
1533: ,x_batch_header_rec => x_batch_header_rec
1534: ,x_material_tbl => l_material_details
1535: ,x_return_status => x_return_status
1536: );
1537: IF (g_debug = gme_debug.g_log_statement) THEN
1538: gme_debug.put_line ('Return status after apply Fixed Proccess Loss '
1539: || x_return_status);
1540: END IF;
1541: IF x_return_status <> fnd_api.g_ret_sts_success THEN
1534: ,x_material_tbl => l_material_details
1535: ,x_return_status => x_return_status
1536: );
1537: IF (g_debug = gme_debug.g_log_statement) THEN
1538: gme_debug.put_line ('Return status after apply Fixed Proccess Loss '
1539: || x_return_status);
1540: END IF;
1541: IF x_return_status <> fnd_api.g_ret_sts_success THEN
1542: RAISE Fixed_process_loss_failure;
1540: END IF;
1541: IF x_return_status <> fnd_api.g_ret_sts_success THEN
1542: RAISE Fixed_process_loss_failure;
1543: ELSE
1544: IF (g_debug = gme_debug.g_log_statement) THEN
1545: gme_debug.put_line ('Return from Apply Fixed Proccess Loss is ' || x_return_status);
1546: END IF;
1547: END IF;
1548: END IF;
1541: IF x_return_status <> fnd_api.g_ret_sts_success THEN
1542: RAISE Fixed_process_loss_failure;
1543: ELSE
1544: IF (g_debug = gme_debug.g_log_statement) THEN
1545: gme_debug.put_line ('Return from Apply Fixed Proccess Loss is ' || x_return_status);
1546: END IF;
1547: END IF;
1548: END IF;
1549:
1547: END IF;
1548: END IF;
1549:
1550: -- Fixed Process Loss ME
1551: IF (g_debug = gme_debug.g_log_statement) THEN
1552: gme_debug.put_line ('After calling Apply Fixed Proccess Loss return is' || x_return_status);
1553: gme_debug.put_line ('fnd return is ' || fnd_api.g_ret_sts_success);
1554: END IF;
1555:
1548: END IF;
1549:
1550: -- Fixed Process Loss ME
1551: IF (g_debug = gme_debug.g_log_statement) THEN
1552: gme_debug.put_line ('After calling Apply Fixed Proccess Loss return is' || x_return_status);
1553: gme_debug.put_line ('fnd return is ' || fnd_api.g_ret_sts_success);
1554: END IF;
1555:
1556: -- If we've found any errors, don't start the updates.
1549:
1550: -- Fixed Process Loss ME
1551: IF (g_debug = gme_debug.g_log_statement) THEN
1552: gme_debug.put_line ('After calling Apply Fixed Proccess Loss return is' || x_return_status);
1553: gme_debug.put_line ('fnd return is ' || fnd_api.g_ret_sts_success);
1554: END IF;
1555:
1556: -- If we've found any errors, don't start the updates.
1557: -- IF gme_common_pvt.g_error_count > 0 THEN
1557: -- IF gme_common_pvt.g_error_count > 0 THEN
1558: -- RAISE expected_error;
1559: -- END IF;
1560:
1561: IF g_debug <= gme_debug.g_log_statement THEN
1562: gme_debug.put_line ( g_pkg_name
1563: || '.'
1564: || l_api_name
1565: || 'Start dbl pcrocessing');
1558: -- RAISE expected_error;
1559: -- END IF;
1560:
1561: IF g_debug <= gme_debug.g_log_statement THEN
1562: gme_debug.put_line ( g_pkg_name
1563: || '.'
1564: || l_api_name
1565: || 'Start dbl pcrocessing');
1566: END IF;
1575: gme_common_pvt.create_document_no (l_in_batch_header
1576: ,x_batch_header_rec);*/
1577: SELECT trim(TO_CHAR(systimestamp,'DD:MM:YYYY HH24:MI:SS:FF6')) INTO l_doc_timestamp FROM DUAL;
1578:
1579: IF g_debug <= gme_debug.g_log_statement THEN
1580: gme_debug.put_line ( g_pkg_name
1581: || '.'
1582: || l_api_name
1583: || 'Initial Doc No(timestamp): '||l_doc_timestamp);
1576: ,x_batch_header_rec);*/
1577: SELECT trim(TO_CHAR(systimestamp,'DD:MM:YYYY HH24:MI:SS:FF6')) INTO l_doc_timestamp FROM DUAL;
1578:
1579: IF g_debug <= gme_debug.g_log_statement THEN
1580: gme_debug.put_line ( g_pkg_name
1581: || '.'
1582: || l_api_name
1583: || 'Initial Doc No(timestamp): '||l_doc_timestamp);
1584: END IF;
1614:
1615: l_number_of_text_lines := 0;
1616:
1617: --Bug#5112133 add some debug messages for copy formula text GME Parameter
1618: IF (g_debug = gme_debug.g_log_statement) THEN
1619: gme_debug.put_line ('copy_formula_text_ind = '||gme_common_pvt.g_copy_formula_text_ind);
1620: END IF;
1621: -- If the formula has text and we have to copy it then generate
1622: -- the text header row first as database constraints impose this
1615: l_number_of_text_lines := 0;
1616:
1617: --Bug#5112133 add some debug messages for copy formula text GME Parameter
1618: IF (g_debug = gme_debug.g_log_statement) THEN
1619: gme_debug.put_line ('copy_formula_text_ind = '||gme_common_pvt.g_copy_formula_text_ind);
1620: END IF;
1621: -- If the formula has text and we have to copy it then generate
1622: -- the text header row first as database constraints impose this
1623: IF gme_common_pvt.g_copy_formula_text_ind = 1
1628: IF l_return THEN
1629: x_batch_header_rec.text_code := l_text_header.text_code;
1630: ELSE
1631: --Bug#5112133
1632: IF (g_debug = gme_debug.g_log_statement) THEN
1633: gme_debug.put_line ('Error in inserting text code = '||l_formula_master.text_code);
1634: END IF;
1635: -- We could not insert the text header. Panic
1636: RAISE expected_error;
1629: x_batch_header_rec.text_code := l_text_header.text_code;
1630: ELSE
1631: --Bug#5112133
1632: IF (g_debug = gme_debug.g_log_statement) THEN
1633: gme_debug.put_line ('Error in inserting text code = '||l_formula_master.text_code);
1634: END IF;
1635: -- We could not insert the text header. Panic
1636: RAISE expected_error;
1637: END IF;
1684: IF l_return = TRUE THEN
1685:
1686: IF x_batch_header_rec.text_code IS NOT NULL THEN
1687: --Bug#5112133
1688: IF (g_debug = gme_debug.g_log_statement) THEN
1689: gme_debug.put_line ('x_batch_header_rec.text_code = '||x_batch_header_rec.text_code);
1690: gme_debug.put_line ('Inserting formula header text in batch header edit text');
1691: END IF;
1692: FOR l_fm_text_tbl_row IN
1685:
1686: IF x_batch_header_rec.text_code IS NOT NULL THEN
1687: --Bug#5112133
1688: IF (g_debug = gme_debug.g_log_statement) THEN
1689: gme_debug.put_line ('x_batch_header_rec.text_code = '||x_batch_header_rec.text_code);
1690: gme_debug.put_line ('Inserting formula header text in batch header edit text');
1691: END IF;
1692: FOR l_fm_text_tbl_row IN
1693: fm_text_tbl_cursor (l_formula_master.text_code) LOOP
1686: IF x_batch_header_rec.text_code IS NOT NULL THEN
1687: --Bug#5112133
1688: IF (g_debug = gme_debug.g_log_statement) THEN
1689: gme_debug.put_line ('x_batch_header_rec.text_code = '||x_batch_header_rec.text_code);
1690: gme_debug.put_line ('Inserting formula header text in batch header edit text');
1691: END IF;
1692: FOR l_fm_text_tbl_row IN
1693: fm_text_tbl_cursor (l_formula_master.text_code) LOOP
1694: l_number_of_text_lines := l_number_of_text_lines + 1;
1717: END LOOP;
1718: END IF;
1719:
1720: --Bug#5112133
1721: IF (g_debug = gme_debug.g_log_statement) THEN
1722: gme_debug.put_line ('l_number_of_formula_lines = '||l_number_of_formula_lines);
1723: END IF;
1724:
1725: FOR l_row_count IN 1 .. l_number_of_formula_lines LOOP
1718: END IF;
1719:
1720: --Bug#5112133
1721: IF (g_debug = gme_debug.g_log_statement) THEN
1722: gme_debug.put_line ('l_number_of_formula_lines = '||l_number_of_formula_lines);
1723: END IF;
1724:
1725: FOR l_row_count IN 1 .. l_number_of_formula_lines LOOP
1726: -- Create rows for details' text.
1723: END IF;
1724:
1725: FOR l_row_count IN 1 .. l_number_of_formula_lines LOOP
1726: -- Create rows for details' text.
1727: IF (g_debug = gme_debug.g_log_statement) THEN
1728: gme_debug.put_line ('l text code is '||l_material_details (l_row_count).text_code);
1729: END IF;
1730: IF l_material_details (l_row_count).text_code IS NOT NULL
1731: AND gme_common_pvt.g_copy_formula_text_ind = 1 THEN
1724:
1725: FOR l_row_count IN 1 .. l_number_of_formula_lines LOOP
1726: -- Create rows for details' text.
1727: IF (g_debug = gme_debug.g_log_statement) THEN
1728: gme_debug.put_line ('l text code is '||l_material_details (l_row_count).text_code);
1729: END IF;
1730: IF l_material_details (l_row_count).text_code IS NOT NULL
1731: AND gme_common_pvt.g_copy_formula_text_ind = 1 THEN
1732: l_text_code := l_material_details (l_row_count).text_code;
1776: END LOOP; -- text lines loop.
1777: ELSE
1778: -- We could not insert the text header. Panic
1779: --Bug#5112133
1780: IF (g_debug = gme_debug.g_log_statement) THEN
1781: gme_debug.put_line ('Error in inserting text header');
1782: END IF;
1783: RAISE expected_error;
1784: END IF;
1777: ELSE
1778: -- We could not insert the text header. Panic
1779: --Bug#5112133
1780: IF (g_debug = gme_debug.g_log_statement) THEN
1781: gme_debug.put_line ('Error in inserting text header');
1782: END IF;
1783: RAISE expected_error;
1784: END IF;
1785: END IF;
1822: END IF;
1823:
1824: END IF;
1825: -- GMO changes end
1826: IF (g_debug = gme_debug.g_log_statement) THEN
1827: gme_debug.put_line ('MATERTIAL lines to be INSERTED ' || l_row_count);
1828: END IF;
1829:
1830: l_return :=
1823:
1824: END IF;
1825: -- GMO changes end
1826: IF (g_debug = gme_debug.g_log_statement) THEN
1827: gme_debug.put_line ('MATERTIAL lines to be INSERTED ' || l_row_count);
1828: END IF;
1829:
1830: l_return :=
1831: gme_material_details_dbl.insert_row
1831: gme_material_details_dbl.insert_row
1832: (l_material_details (l_row_count)
1833: ,l_material_details (l_row_count) );
1834:
1835: IF (g_debug = gme_debug.g_log_statement) THEN
1836: gme_debug.put_line ('MATERTIAL_INSERTED');
1837: END IF;
1838:
1839: IF NOT l_return THEN
1832: (l_material_details (l_row_count)
1833: ,l_material_details (l_row_count) );
1834:
1835: IF (g_debug = gme_debug.g_log_statement) THEN
1836: gme_debug.put_line ('MATERTIAL_INSERTED');
1837: END IF;
1838:
1839: IF NOT l_return THEN
1840: RAISE unexpected_error;
1841: END IF;
1842: -- Pawan Kumar added for bug 4947535
1843:
1844: IF (l_config_id IS NOT NULL AND l_material_details(l_row_count).dispense_ind = 'Y') then
1845: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1846: gme_debug.put_line (g_pkg_name||'.'||l_api_name||'Instantiating material line id'
1847: || l_material_details (l_row_count).material_detail_id);
1848: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' config id ' || l_config_id);
1849: END IF;
1842: -- Pawan Kumar added for bug 4947535
1843:
1844: IF (l_config_id IS NOT NULL AND l_material_details(l_row_count).dispense_ind = 'Y') then
1845: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1846: gme_debug.put_line (g_pkg_name||'.'||l_api_name||'Instantiating material line id'
1847: || l_material_details (l_row_count).material_detail_id);
1848: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' config id ' || l_config_id);
1849: END IF;
1850: GMO_DISPENSE_GRP.INSTANTIATE_DISPENSE_SETUP
1844: IF (l_config_id IS NOT NULL AND l_material_details(l_row_count).dispense_ind = 'Y') then
1845: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1846: gme_debug.put_line (g_pkg_name||'.'||l_api_name||'Instantiating material line id'
1847: || l_material_details (l_row_count).material_detail_id);
1848: gme_debug.put_line (g_pkg_name||'.'||l_api_name||' config id ' || l_config_id);
1849: END IF;
1850: GMO_DISPENSE_GRP.INSTANTIATE_DISPENSE_SETUP
1851: (p_api_version => 1.0
1852: ,p_dispense_config_id => l_config_id
1905: END IF;
1906:
1907: CLOSE get_prim_prod;
1908:
1909: IF g_debug <= gme_debug.g_log_statement THEN
1910: gme_debug.put_line ( g_pkg_name
1911: || '.'
1912: || l_api_name
1913: || 'Start step processing');
1906:
1907: CLOSE get_prim_prod;
1908:
1909: IF g_debug <= gme_debug.g_log_statement THEN
1910: gme_debug.put_line ( g_pkg_name
1911: || '.'
1912: || l_api_name
1913: || 'Start step processing');
1914: END IF;
1988: x_batch_header_rec.plan_cmplt_date :=
1989: gme_common_pvt.g_timestamp;
1990: END IF;
1991:
1992: IF (g_debug = gme_debug.g_log_statement) THEN
1993: gme_debug.put_line
1994: ( 'production rule start_date '
1995: || TO_CHAR
1996: (x_batch_header_rec.plan_start_date
1989: gme_common_pvt.g_timestamp;
1990: END IF;
1991:
1992: IF (g_debug = gme_debug.g_log_statement) THEN
1993: gme_debug.put_line
1994: ( 'production rule start_date '
1995: || TO_CHAR
1996: (x_batch_header_rec.plan_start_date
1997: ,'DD-MON-YYYY HH24:MI:SS') );
1994: ( 'production rule start_date '
1995: || TO_CHAR
1996: (x_batch_header_rec.plan_start_date
1997: ,'DD-MON-YYYY HH24:MI:SS') );
1998: gme_debug.put_line
1999: ( 'production rule end_date '
2000: || TO_CHAR
2001: (x_batch_header_rec.plan_cmplt_date
2002: ,'DD-MON-YYYY HH24:MI:SS') );
2010: ,x_contiguous_ind => l_cont_ind
2011: ,x_return_status => l_return_status);
2012:
2013: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2014: IF (g_debug = gme_debug.g_log_statement) THEN
2015: gme_debug.put_line
2016: ( 'GMD_RECIPE_FETCH_PUB.FETCH_CONTIGUOUS_IND returned error '
2017: || l_return_status);
2018: END IF;
2011: ,x_return_status => l_return_status);
2012:
2013: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2014: IF (g_debug = gme_debug.g_log_statement) THEN
2015: gme_debug.put_line
2016: ( 'GMD_RECIPE_FETCH_PUB.FETCH_CONTIGUOUS_IND returned error '
2017: || l_return_status);
2018: END IF;
2019:
2019:
2020: l_cont_ind := 0;
2021: END IF;
2022:
2023: IF (g_debug = gme_debug.g_log_statement) THEN
2024: gme_debug.put_line ( 'Calendar code found '
2025: || gme_common_pvt.g_calendar_code);
2026: gme_debug.put_line ('Cont ID found ' || l_cont_ind);
2027: END IF;
2020: l_cont_ind := 0;
2021: END IF;
2022:
2023: IF (g_debug = gme_debug.g_log_statement) THEN
2024: gme_debug.put_line ( 'Calendar code found '
2025: || gme_common_pvt.g_calendar_code);
2026: gme_debug.put_line ('Cont ID found ' || l_cont_ind);
2027: END IF;
2028:
2022:
2023: IF (g_debug = gme_debug.g_log_statement) THEN
2024: gme_debug.put_line ( 'Calendar code found '
2025: || gme_common_pvt.g_calendar_code);
2026: gme_debug.put_line ('Cont ID found ' || l_cont_ind);
2027: END IF;
2028:
2029: l_duration :=
2030: ( x_batch_header_rec.plan_cmplt_date
2030: ( x_batch_header_rec.plan_cmplt_date
2031: - x_batch_header_rec.plan_start_date)
2032: * 24;
2033:
2034: IF (g_debug = gme_debug.g_log_statement) THEN
2035: gme_debug.put_line ('l duration ' || l_duration);
2036: END IF;
2037:
2038: IF p_batch_header_rec.plan_start_date IS NOT NULL
2031: - x_batch_header_rec.plan_start_date)
2032: * 24;
2033:
2034: IF (g_debug = gme_debug.g_log_statement) THEN
2035: gme_debug.put_line ('l duration ' || l_duration);
2036: END IF;
2037:
2038: IF p_batch_header_rec.plan_start_date IS NOT NULL
2039: OR ( p_batch_header_rec.plan_start_date IS NULL
2055: END IF;
2056:
2057: l_cal_count := l_contig_period_tbl.COUNT;
2058:
2059: IF (g_debug = gme_debug.g_log_statement) THEN
2060: gme_debug.put_line ('l cal_count ' || l_cal_count);
2061: gme_debug.put_line ( 'p_contiguity_override '
2062: || p_contiguity_override);
2063: END IF;
2056:
2057: l_cal_count := l_contig_period_tbl.COUNT;
2058:
2059: IF (g_debug = gme_debug.g_log_statement) THEN
2060: gme_debug.put_line ('l cal_count ' || l_cal_count);
2061: gme_debug.put_line ( 'p_contiguity_override '
2062: || p_contiguity_override);
2063: END IF;
2064:
2057: l_cal_count := l_contig_period_tbl.COUNT;
2058:
2059: IF (g_debug = gme_debug.g_log_statement) THEN
2060: gme_debug.put_line ('l cal_count ' || l_cal_count);
2061: gme_debug.put_line ( 'p_contiguity_override '
2062: || p_contiguity_override);
2063: END IF;
2064:
2065: IF l_cont_ind = 1
2088: END IF;
2089:
2090: l_cal_count := l_contig_period_tbl.COUNT;
2091:
2092: IF (g_debug = gme_debug.g_log_statement) THEN
2093: gme_debug.put_line ('l cal_count ' || l_cal_count);
2094: gme_debug.put_line ( 'p_contiguity_override '
2095: || p_contiguity_override);
2096: END IF;
2089:
2090: l_cal_count := l_contig_period_tbl.COUNT;
2091:
2092: IF (g_debug = gme_debug.g_log_statement) THEN
2093: gme_debug.put_line ('l cal_count ' || l_cal_count);
2094: gme_debug.put_line ( 'p_contiguity_override '
2095: || p_contiguity_override);
2096: END IF;
2097:
2090: l_cal_count := l_contig_period_tbl.COUNT;
2091:
2092: IF (g_debug = gme_debug.g_log_statement) THEN
2093: gme_debug.put_line ('l cal_count ' || l_cal_count);
2094: gme_debug.put_line ( 'p_contiguity_override '
2095: || p_contiguity_override);
2096: END IF;
2097:
2098: IF l_cont_ind = 1
2168: AND wip_entity_name = l_prefix||l_doc_timestamp;
2169: END IF;
2170: -- 5698727
2171:
2172: IF (g_debug = gme_debug.g_log_statement) THEN
2173: gme_debug.put_line ( 'Calculated Start date is '
2174: || TO_CHAR (x_batch_header_rec.plan_start_date
2175: ,'DD-MON-YYYY HH24:MI:SS') );
2176: gme_debug.put_line ( 'Calculated Cmplt date is '
2169: END IF;
2170: -- 5698727
2171:
2172: IF (g_debug = gme_debug.g_log_statement) THEN
2173: gme_debug.put_line ( 'Calculated Start date is '
2174: || TO_CHAR (x_batch_header_rec.plan_start_date
2175: ,'DD-MON-YYYY HH24:MI:SS') );
2176: gme_debug.put_line ( 'Calculated Cmplt date is '
2177: || TO_CHAR (x_batch_header_rec.plan_cmplt_date
2172: IF (g_debug = gme_debug.g_log_statement) THEN
2173: gme_debug.put_line ( 'Calculated Start date is '
2174: || TO_CHAR (x_batch_header_rec.plan_start_date
2175: ,'DD-MON-YYYY HH24:MI:SS') );
2176: gme_debug.put_line ( 'Calculated Cmplt date is '
2177: || TO_CHAR (x_batch_header_rec.plan_cmplt_date
2178: ,'DD-MON-YYYY HH24:MI:SS') );
2179: END IF;
2180:
2228: ,x_batch_header_rec) ) THEN
2229: RAISE batch_header_fetch_failure;
2230: END IF;
2231:
2232: IF g_debug <= gme_debug.g_log_statement THEN
2233: gme_debug.put_line ( g_pkg_name
2234: || '.'
2235: || l_api_name
2236: || 'Calculate mtl req date');
2229: RAISE batch_header_fetch_failure;
2230: END IF;
2231:
2232: IF g_debug <= gme_debug.g_log_statement THEN
2233: gme_debug.put_line ( g_pkg_name
2234: || '.'
2235: || l_api_name
2236: || 'Calculate mtl req date');
2237: END IF;
2268: ELSIF gme_common_pvt.g_ingr_sub_date = 3 THEN
2269: l_ingred_req_date := NVL(p_batch_header_rec.plan_cmplt_date, x_batch_header_rec.plan_cmplt_date);
2270: END IF;
2271:
2272: IF g_debug <= gme_debug.g_log_statement THEN
2273: gme_debug.put_line ( g_pkg_name||'.'|| l_api_name
2274: || ' l_ingred_req_date '||TO_CHAR(l_ingred_req_date, 'MON-DD-YYYY HH24:MI:SS'));
2275: END IF;
2276:
2269: l_ingred_req_date := NVL(p_batch_header_rec.plan_cmplt_date, x_batch_header_rec.plan_cmplt_date);
2270: END IF;
2271:
2272: IF g_debug <= gme_debug.g_log_statement THEN
2273: gme_debug.put_line ( g_pkg_name||'.'|| l_api_name
2274: || ' l_ingred_req_date '||TO_CHAR(l_ingred_req_date, 'MON-DD-YYYY HH24:MI:SS'));
2275: END IF;
2276:
2277: gmdfmval_pub.get_substitute_line_item (
2304: ( l_new_item_rec.ENG_ITEM_FLAG = 'Y' AND NVL(x_batch_header_rec.laboratory_ind,0) <> 1 ) THEN
2305: RAISE invalid_item_substitute;
2306: END IF;
2307:
2308: IF (g_debug <= gme_debug.g_log_statement) THEN
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2305: RAISE invalid_item_substitute;
2306: END IF;
2307:
2308: IF (g_debug <= gme_debug.g_log_statement) THEN
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2313: gme_debug.put_line('Initial Scale multiple: '||l_material_details (l_row_count).scale_multiple);
2306: END IF;
2307:
2308: IF (g_debug <= gme_debug.g_log_statement) THEN
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2313: gme_debug.put_line('Initial Scale multiple: '||l_material_details (l_row_count).scale_multiple);
2314: END IF;
2307:
2308: IF (g_debug <= gme_debug.g_log_statement) THEN
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2313: gme_debug.put_line('Initial Scale multiple: '||l_material_details (l_row_count).scale_multiple);
2314: END IF;
2315:
2308: IF (g_debug <= gme_debug.g_log_statement) THEN
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2313: gme_debug.put_line('Initial Scale multiple: '||l_material_details (l_row_count).scale_multiple);
2314: END IF;
2315:
2316: l_item_substituted := TRUE;
2309: gme_debug.put_line('Calculated mtl req date: '||l_material_details (l_row_count).material_requirement_date);
2310: gme_debug.put_line('Initial Item ID: '||l_material_details (l_row_count).inventory_item_id);
2311: gme_debug.put_line('Initial Plan Qty: '||l_material_details (l_row_count).plan_qty);
2312: gme_debug.put_line('Initial Detail UOM: '||l_material_details (l_row_count).dtl_um);
2313: gme_debug.put_line('Initial Scale multiple: '||l_material_details (l_row_count).scale_multiple);
2314: END IF;
2315:
2316: l_item_substituted := TRUE;
2317: l_curr_item_substituted := TRUE;
2322: l_material_details (l_row_count).original_qty := l_formula_tbl(1).qty;
2323: l_material_details (l_row_count).dtl_um := l_formula_tbl(1).detail_uom;
2324: l_material_details (l_row_count).scale_multiple := l_formula_tbl(1).scale_multiple;
2325:
2326: IF (g_debug <= gme_debug.g_log_statement) THEN
2327: gme_debug.put_line('Substitued Item ID: '||l_formula_tbl(1).inventory_item_id);
2328: gme_debug.put_line('Substitued Plan Qty: '||l_formula_tbl(1).qty);
2329: gme_debug.put_line('Substituted Detail UOM: '||l_formula_tbl(1).detail_uom);
2330: gme_debug.put_line('Substituted Scale multiple: '||l_formula_tbl(1).scale_multiple);
2323: l_material_details (l_row_count).dtl_um := l_formula_tbl(1).detail_uom;
2324: l_material_details (l_row_count).scale_multiple := l_formula_tbl(1).scale_multiple;
2325:
2326: IF (g_debug <= gme_debug.g_log_statement) THEN
2327: gme_debug.put_line('Substitued Item ID: '||l_formula_tbl(1).inventory_item_id);
2328: gme_debug.put_line('Substitued Plan Qty: '||l_formula_tbl(1).qty);
2329: gme_debug.put_line('Substituted Detail UOM: '||l_formula_tbl(1).detail_uom);
2330: gme_debug.put_line('Substituted Scale multiple: '||l_formula_tbl(1).scale_multiple);
2331: END IF;
2324: l_material_details (l_row_count).scale_multiple := l_formula_tbl(1).scale_multiple;
2325:
2326: IF (g_debug <= gme_debug.g_log_statement) THEN
2327: gme_debug.put_line('Substitued Item ID: '||l_formula_tbl(1).inventory_item_id);
2328: gme_debug.put_line('Substitued Plan Qty: '||l_formula_tbl(1).qty);
2329: gme_debug.put_line('Substituted Detail UOM: '||l_formula_tbl(1).detail_uom);
2330: gme_debug.put_line('Substituted Scale multiple: '||l_formula_tbl(1).scale_multiple);
2331: END IF;
2332:
2325:
2326: IF (g_debug <= gme_debug.g_log_statement) THEN
2327: gme_debug.put_line('Substitued Item ID: '||l_formula_tbl(1).inventory_item_id);
2328: gme_debug.put_line('Substitued Plan Qty: '||l_formula_tbl(1).qty);
2329: gme_debug.put_line('Substituted Detail UOM: '||l_formula_tbl(1).detail_uom);
2330: gme_debug.put_line('Substituted Scale multiple: '||l_formula_tbl(1).scale_multiple);
2331: END IF;
2332:
2333: /*if the new item uom is not the primary uom then calculate the primary quantity*/
2326: IF (g_debug <= gme_debug.g_log_statement) THEN
2327: gme_debug.put_line('Substitued Item ID: '||l_formula_tbl(1).inventory_item_id);
2328: gme_debug.put_line('Substitued Plan Qty: '||l_formula_tbl(1).qty);
2329: gme_debug.put_line('Substituted Detail UOM: '||l_formula_tbl(1).detail_uom);
2330: gme_debug.put_line('Substituted Scale multiple: '||l_formula_tbl(1).scale_multiple);
2331: END IF;
2332:
2333: /*if the new item uom is not the primary uom then calculate the primary quantity*/
2334: IF l_formula_tbl(1).detail_uom <> l_new_item_rec.primary_uom_code THEN
2343: ELSE
2344: l_temp_qty := l_material_details(l_row_count).plan_qty;
2345: END IF;
2346:
2347: IF (g_debug < gme_debug.g_log_statement) THEN
2348: gme_debug.put_line('Initial Original Primary Qty: '||l_material_details (l_row_count).original_primary_qty);
2349: gme_debug.put_line('Substituted Original Priamry Qty: '||l_temp_qty);
2350: END IF;
2351:
2344: l_temp_qty := l_material_details(l_row_count).plan_qty;
2345: END IF;
2346:
2347: IF (g_debug < gme_debug.g_log_statement) THEN
2348: gme_debug.put_line('Initial Original Primary Qty: '||l_material_details (l_row_count).original_primary_qty);
2349: gme_debug.put_line('Substituted Original Priamry Qty: '||l_temp_qty);
2350: END IF;
2351:
2352: /* assign to original primary qty */
2345: END IF;
2346:
2347: IF (g_debug < gme_debug.g_log_statement) THEN
2348: gme_debug.put_line('Initial Original Primary Qty: '||l_material_details (l_row_count).original_primary_qty);
2349: gme_debug.put_line('Substituted Original Priamry Qty: '||l_temp_qty);
2350: END IF;
2351:
2352: /* assign to original primary qty */
2353: l_material_details (l_row_count).original_primary_qty := l_temp_qty;
2375: OPEN c_batchsteps (l_material_details(l_row_count).material_detail_id);
2376: FETCH c_batchsteps INTO l_batchstep_rec;
2377: CLOSE c_batchsteps;
2378:
2379: IF (g_debug <= gme_debug.g_log_statement) THEN
2380: gme_debug.put_line ('Before updating step qty after the substitution');
2381: END IF;
2382: gme_update_step_qty_pvt.update_step_qty (p_batch_step_rec => l_batchstep_rec,
2383: x_message_count => l_message_count,
2376: FETCH c_batchsteps INTO l_batchstep_rec;
2377: CLOSE c_batchsteps;
2378:
2379: IF (g_debug <= gme_debug.g_log_statement) THEN
2380: gme_debug.put_line ('Before updating step qty after the substitution');
2381: END IF;
2382: gme_update_step_qty_pvt.update_step_qty (p_batch_step_rec => l_batchstep_rec,
2383: x_message_count => l_message_count,
2384: x_message_list => l_message_list,
2384: x_message_list => l_message_list,
2385: x_return_status => x_return_status,
2386: x_batch_step_rec => x_batchstep_rec
2387: );
2388: IF (g_debug <= gme_debug.g_log_statement) THEN
2389: gme_debug.put_line ('After update step qty, return status is:' || x_return_status);
2390: END IF;
2391: IF x_return_status <> fnd_api.g_ret_sts_success THEN
2392: -- We could not update the step qty
2385: x_return_status => x_return_status,
2386: x_batch_step_rec => x_batchstep_rec
2387: );
2388: IF (g_debug <= gme_debug.g_log_statement) THEN
2389: gme_debug.put_line ('After update step qty, return status is:' || x_return_status);
2390: END IF;
2391: IF x_return_status <> fnd_api.g_ret_sts_success THEN
2392: -- We could not update the step qty
2393: RAISE unexpected_error;
2420: x_batch_header_rec => x_batch_header_rec,
2421: x_return_status => x_return_status
2422: );
2423:
2424: IF (g_debug <= gme_debug.g_log_statement) THEN
2425: gme_debug.put_line('Batch Planned Start Date '||TO_CHAR(x_batch_header_rec.plan_start_date,'MON-DD-YYYY HH24:MI:SS'));
2426: gme_debug.put_line('Batch Planned Completion Date '||TO_CHAR(x_batch_header_rec.plan_cmplt_date,'MON-DD-YYYY HH24:MI:SS'));
2427: END IF;
2428:
2421: x_return_status => x_return_status
2422: );
2423:
2424: IF (g_debug <= gme_debug.g_log_statement) THEN
2425: gme_debug.put_line('Batch Planned Start Date '||TO_CHAR(x_batch_header_rec.plan_start_date,'MON-DD-YYYY HH24:MI:SS'));
2426: gme_debug.put_line('Batch Planned Completion Date '||TO_CHAR(x_batch_header_rec.plan_cmplt_date,'MON-DD-YYYY HH24:MI:SS'));
2427: END IF;
2428:
2429: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2422: );
2423:
2424: IF (g_debug <= gme_debug.g_log_statement) THEN
2425: gme_debug.put_line('Batch Planned Start Date '||TO_CHAR(x_batch_header_rec.plan_start_date,'MON-DD-YYYY HH24:MI:SS'));
2426: gme_debug.put_line('Batch Planned Completion Date '||TO_CHAR(x_batch_header_rec.plan_cmplt_date,'MON-DD-YYYY HH24:MI:SS'));
2427: END IF;
2428:
2429: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2430: RAISE unexpected_error;
2448: END IF; /* ASQC */
2449: END IF; /* Update inventory*/
2450: -- nsinghi bug#5674398 END
2451:
2452: IF (g_debug = gme_debug.g_log_statement) THEN
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2449: END IF; /* Update inventory*/
2450: -- nsinghi bug#5674398 END
2451:
2452: IF (g_debug = gme_debug.g_log_statement) THEN
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2450: -- nsinghi bug#5674398 END
2451:
2452: IF (g_debug = gme_debug.g_log_statement) THEN
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2451:
2452: IF (g_debug = gme_debug.g_log_statement) THEN
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2459: || TO_CHAR (p_batch_header_rec.plan_start_date
2452: IF (g_debug = gme_debug.g_log_statement) THEN
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2459: || TO_CHAR (p_batch_header_rec.plan_start_date
2460: ,'DD-MON-YYYY HH24:MI:SS') );
2453: gme_debug.put_line ('p_creation_mode=' || p_creation_mode);
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2459: || TO_CHAR (p_batch_header_rec.plan_start_date
2460: ,'DD-MON-YYYY HH24:MI:SS') );
2461: gme_debug.put_line ( 'User passed Cmplt date is '
2454: gme_debug.put_line ('prim_prod_qty=' || l_prim_prod_qty);
2455: gme_debug.put_line ('prim_prod_um=' || l_prim_prod_um);
2456: gme_debug.put_line ('p_batch_size=' || p_batch_size);
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2459: || TO_CHAR (p_batch_header_rec.plan_start_date
2460: ,'DD-MON-YYYY HH24:MI:SS') );
2461: gme_debug.put_line ( 'User passed Cmplt date is '
2462: || TO_CHAR (p_batch_header_rec.plan_cmplt_date
2457: gme_debug.put_line ('p_batch_size_uom=' || p_batch_size_uom);
2458: gme_debug.put_line ( 'User passed Start date is '
2459: || TO_CHAR (p_batch_header_rec.plan_start_date
2460: ,'DD-MON-YYYY HH24:MI:SS') );
2461: gme_debug.put_line ( 'User passed Cmplt date is '
2462: || TO_CHAR (p_batch_header_rec.plan_cmplt_date
2463: ,'DD-MON-YYYY HH24:MI:SS') );
2464: END IF;
2465:
2480: l_to_uom := l_prim_prod_um;
2481: RAISE conversion_failure;
2482: END IF;
2483:
2484: IF (g_debug = gme_debug.g_log_statement) THEN
2485: gme_debug.put_line ('requested qty in dtl uom=' || l_temp_qty);
2486: gme_debug.put_line ('requested qty in dtl uom rounded=' || round(l_temp_qty, 4));
2487: END IF;
2488:
2481: RAISE conversion_failure;
2482: END IF;
2483:
2484: IF (g_debug = gme_debug.g_log_statement) THEN
2485: gme_debug.put_line ('requested qty in dtl uom=' || l_temp_qty);
2486: gme_debug.put_line ('requested qty in dtl uom rounded=' || round(l_temp_qty, 4));
2487: END IF;
2488:
2489: --sunitha bug # 5484529 Convert the p_batch_size(user entered product plan quantity
2482: END IF;
2483:
2484: IF (g_debug = gme_debug.g_log_statement) THEN
2485: gme_debug.put_line ('requested qty in dtl uom=' || l_temp_qty);
2486: gme_debug.put_line ('requested qty in dtl uom rounded=' || round(l_temp_qty, 4));
2487: END IF;
2488:
2489: --sunitha bug # 5484529 Convert the p_batch_size(user entered product plan quantity
2490: --to the Routing uom and then Compare it with the l_temp_qty.
2508: ,l_recipe_validity_rule.detail_uom
2509: ,NULL
2510: ,NULL), 5) <> ROUND (l_temp_qty, 5) ) THEN */
2511:
2512: IF (g_debug = gme_debug.g_log_statement) THEN
2513: gme_debug.put_line('Batch failed to be created for qty requested with creation by product qty');
2514: END IF;
2515:
2516: RAISE create_by_product_failure;
2509: ,NULL
2510: ,NULL), 5) <> ROUND (l_temp_qty, 5) ) THEN */
2511:
2512: IF (g_debug = gme_debug.g_log_statement) THEN
2513: gme_debug.put_line('Batch failed to be created for qty requested with creation by product qty');
2514: END IF;
2515:
2516: RAISE create_by_product_failure;
2517: END IF;
2516: RAISE create_by_product_failure;
2517: END IF;
2518: END IF;
2519: ELSIF NOT l_prim_prod_found THEN
2520: IF (g_debug = gme_debug.g_log_statement) THEN
2521: gme_debug.put_line ('I could not find the prim product');
2522: END IF;
2523: END IF;
2524:
2517: END IF;
2518: END IF;
2519: ELSIF NOT l_prim_prod_found THEN
2520: IF (g_debug = gme_debug.g_log_statement) THEN
2521: gme_debug.put_line ('I could not find the prim product');
2522: END IF;
2523: END IF;
2524:
2525: IF (g_debug = gme_debug.g_log_statement) THEN
2521: gme_debug.put_line ('I could not find the prim product');
2522: END IF;
2523: END IF;
2524:
2525: IF (g_debug = gme_debug.g_log_statement) THEN
2526: gme_debug.put_line ('Checking dates against validity rule');
2527: END IF;
2528:
2529: IF p_creation_mode <> 'LCF' THEN
2522: END IF;
2523: END IF;
2524:
2525: IF (g_debug = gme_debug.g_log_statement) THEN
2526: gme_debug.put_line ('Checking dates against validity rule');
2527: END IF;
2528:
2529: IF p_creation_mode <> 'LCF' THEN
2530: IF (NOT gme_common_pvt.check_validity_rule_dates
2535: RAISE date_exceed_validity_rule;
2536: END IF;
2537: END IF; /* IF p_creation_mode <> 'LCF' THEN */
2538:
2539: IF (g_debug = gme_debug.g_log_statement) THEN
2540: gme_debug.put_line ( 'BATCH CREATED, ID = '
2541: || TO_CHAR (x_batch_header_rec.batch_id) );
2542: END IF;
2543:
2536: END IF;
2537: END IF; /* IF p_creation_mode <> 'LCF' THEN */
2538:
2539: IF (g_debug = gme_debug.g_log_statement) THEN
2540: gme_debug.put_line ( 'BATCH CREATED, ID = '
2541: || TO_CHAR (x_batch_header_rec.batch_id) );
2542: END IF;
2543:
2544: /* Update WIP entity table to put the primary product id */
2548:
2549: -- Rajesh Patangya Bug # 6752637
2550: /* Now its time to calculate the MTQ for steps based on the product */
2551: IF gme_common_pvt.routings.COUNT <> 0 THEN
2552: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2553: gme_debug.put_line ( g_pkg_name
2554: || '.'
2555: || l_api_name
2556: || 'Calling Update_step_mtq');
2549: -- Rajesh Patangya Bug # 6752637
2550: /* Now its time to calculate the MTQ for steps based on the product */
2551: IF gme_common_pvt.routings.COUNT <> 0 THEN
2552: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2553: gme_debug.put_line ( g_pkg_name
2554: || '.'
2555: || l_api_name
2556: || 'Calling Update_step_mtq');
2557: END IF;
2560: RAISE update_step_mtq_failure;
2561: END IF;
2562: END IF;
2563:
2564: IF g_debug <= gme_debug.g_log_statement THEN
2565: gme_debug.put_line ( g_pkg_name
2566: || '.'
2567: || l_api_name
2568: || 'Start phantom processing');
2561: END IF;
2562: END IF;
2563:
2564: IF g_debug <= gme_debug.g_log_statement THEN
2565: gme_debug.put_line ( g_pkg_name
2566: || '.'
2567: || l_api_name
2568: || 'Start phantom processing');
2569: END IF;
2627: -- Now invisible move orders and high level reservations will get created for phantom batches.
2628: IF x_batch_header_rec.batch_type = 0 AND NVL (x_batch_header_rec.update_inventory_ind, 'Y') = 'Y' THEN
2629: /* Check inventory shortages */
2630: IF (gme_common_pvt.g_check_shortages_ind = 1 AND g_no_phant_short_check = 0) THEN
2631: IF g_debug <= gme_debug.g_log_statement THEN
2632: gme_debug.put_line ( g_pkg_name || '.'|| l_api_name|| ' Calling shortages ');
2633: END IF;
2634: gme_common_pvt.get_batch_shortages
2635: (p_organization_id => x_batch_header_rec.organization_id
2628: IF x_batch_header_rec.batch_type = 0 AND NVL (x_batch_header_rec.update_inventory_ind, 'Y') = 'Y' THEN
2629: /* Check inventory shortages */
2630: IF (gme_common_pvt.g_check_shortages_ind = 1 AND g_no_phant_short_check = 0) THEN
2631: IF g_debug <= gme_debug.g_log_statement THEN
2632: gme_debug.put_line ( g_pkg_name || '.'|| l_api_name|| ' Calling shortages ');
2633: END IF;
2634: gme_common_pvt.get_batch_shortages
2635: (p_organization_id => x_batch_header_rec.organization_id
2636: ,p_batch_id => x_batch_header_rec.batch_id
2656: END IF;
2657: END IF;
2658:
2659: /* Create invisible move order */
2660: IF g_debug <= gme_debug.g_log_statement THEN
2661: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating Invisible Move Order ');
2662: END IF;
2663:
2664: gme_move_orders_pvt.create_move_order_hdr
2657: END IF;
2658:
2659: /* Create invisible move order */
2660: IF g_debug <= gme_debug.g_log_statement THEN
2661: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating Invisible Move Order ');
2662: END IF;
2663:
2664: gme_move_orders_pvt.create_move_order_hdr
2665: (p_organization_id => x_batch_header_rec.organization_id
2666: ,p_move_order_type => gme_common_pvt.g_invis_move_order_type
2667: ,x_move_order_header_id => x_batch_header_rec.move_order_header_id
2668: ,x_return_status => l_return_status);
2669:
2670: IF g_debug <= gme_debug.g_log_statement THEN
2671: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| 'Invisible Move Order is Created');
2672: END IF;
2673:
2674: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2667: ,x_move_order_header_id => x_batch_header_rec.move_order_header_id
2668: ,x_return_status => l_return_status);
2669:
2670: IF g_debug <= gme_debug.g_log_statement THEN
2671: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| 'Invisible Move Order is Created');
2672: END IF;
2673:
2674: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2675: RAISE create_mo_hdr_err;
2673:
2674: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2675: RAISE create_mo_hdr_err;
2676: ELSE
2677: IF g_debug <= gme_debug.g_log_statement THEN
2678: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating Invisible Move Order Lines');
2679: END IF;
2680:
2681: l_in_material_details := l_material_details;
2674: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2675: RAISE create_mo_hdr_err;
2676: ELSE
2677: IF g_debug <= gme_debug.g_log_statement THEN
2678: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating Invisible Move Order Lines');
2679: END IF;
2680:
2681: l_in_material_details := l_material_details;
2682: gme_move_orders_pvt.create_move_order_lines
2690: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
2691: RAISE create_mo_line_err;
2692: END IF;
2693:
2694: IF g_debug <= gme_debug.g_log_statement THEN
2695: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| 'Invisible Move Order Lines is Created');
2696: END IF;
2697: END IF;
2698:
2691: RAISE create_mo_line_err;
2692: END IF;
2693:
2694: IF g_debug <= gme_debug.g_log_statement THEN
2695: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| 'Invisible Move Order Lines is Created');
2696: END IF;
2697: END IF;
2698:
2699: /* Update batch header with move_order_header_id */
2720: END IF;
2721:
2722: /* Create High Level Reservations */
2723: IF (gme_common_pvt.g_create_high_level_resv_ind = 1) THEN
2724: IF g_debug <= gme_debug.g_log_statement THEN
2725: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating reservations for batch id '|| x_batch_header_rec.batch_id);
2726: END IF;
2727:
2728: gme_reservations_pvt.create_batch_reservations
2721:
2722: /* Create High Level Reservations */
2723: IF (gme_common_pvt.g_create_high_level_resv_ind = 1) THEN
2724: IF g_debug <= gme_debug.g_log_statement THEN
2725: gme_debug.put_line ( g_pkg_name|| '.'|| l_api_name|| ' Creating reservations for batch id '|| x_batch_header_rec.batch_id);
2726: END IF;
2727:
2728: gme_reservations_pvt.create_batch_reservations
2729: (p_batch_id => x_batch_header_rec.batch_id
2729: (p_batch_id => x_batch_header_rec.batch_id
2730: ,p_timefence => gme_common_pvt.g_reservation_timefence
2731: ,x_return_status => l_return_status);
2732:
2733: IF g_debug <= gme_debug.g_log_statement THEN
2734: gme_debug.put_line ( g_pkg_name
2735: || '.'
2736: || l_api_name
2737: || ' Reservations are created'
2730: ,p_timefence => gme_common_pvt.g_reservation_timefence
2731: ,x_return_status => l_return_status);
2732:
2733: IF g_debug <= gme_debug.g_log_statement THEN
2734: gme_debug.put_line ( g_pkg_name
2735: || '.'
2736: || l_api_name
2737: || ' Reservations are created'
2738: || l_return_status);
2740: END IF;
2741:
2742: /* Create Move Order */
2743: IF (gme_common_pvt.g_create_move_orders_ind = 1) THEN
2744: IF g_debug <= gme_debug.g_log_statement THEN
2745: gme_debug.put_line ( g_pkg_name
2746: || '.'
2747: || l_api_name
2748: || ' Creating Explicit Move Order ');
2741:
2742: /* Create Move Order */
2743: IF (gme_common_pvt.g_create_move_orders_ind = 1) THEN
2744: IF g_debug <= gme_debug.g_log_statement THEN
2745: gme_debug.put_line ( g_pkg_name
2746: || '.'
2747: || l_api_name
2748: || ' Creating Explicit Move Order ');
2749: END IF;
2752: (p_batch_header_rec => x_batch_header_rec
2753: ,p_material_details_tbl => l_material_details
2754: ,x_return_status => l_return_status);
2755:
2756: IF g_debug <= gme_debug.g_log_statement THEN
2757: gme_debug.put_line ( g_pkg_name
2758: || '.'
2759: || l_api_name
2760: || ' Explicit Move Order are created '
2753: ,p_material_details_tbl => l_material_details
2754: ,x_return_status => l_return_status);
2755:
2756: IF g_debug <= gme_debug.g_log_statement THEN
2757: gme_debug.put_line ( g_pkg_name
2758: || '.'
2759: || l_api_name
2760: || ' Explicit Move Order are created '
2761: || l_return_status);
2773: X_MSG_COUNT => l_message_count,
2774: X_MSG_DATA => l_msg_data,
2775: P_ENTITY_NAME => 'BATCH',
2776: P_ENTITY_KEY => x_batch_header_rec.batch_id) ;
2777: IF g_debug <= gme_debug.g_log_statement THEN
2778: gme_debug.put_line ( g_pkg_name
2779: || '.'
2780: || l_api_name
2781: || ' Calling instantiate_advanced_pi ');
2774: X_MSG_DATA => l_msg_data,
2775: P_ENTITY_NAME => 'BATCH',
2776: P_ENTITY_KEY => x_batch_header_rec.batch_id) ;
2777: IF g_debug <= gme_debug.g_log_statement THEN
2778: gme_debug.put_line ( g_pkg_name
2779: || '.'
2780: || l_api_name
2781: || ' Calling instantiate_advanced_pi ');
2782: END IF;
2787: /*Bug#7493614 moved the workflow event call to the end of the batch
2788: create procedure */
2789: wf_event.RAISE (p_event_name => gme_common_pvt.G_BATCH_CREATED
2790: ,p_event_key => x_batch_header_rec.batch_id);
2791: IF g_debug <= gme_debug.g_log_procedure THEN
2792: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2793: END IF;
2794: EXCEPTION
2795: WHEN doc_num_is_not_passed THEN
2788: create procedure */
2789: wf_event.RAISE (p_event_name => gme_common_pvt.G_BATCH_CREATED
2790: ,p_event_key => x_batch_header_rec.batch_id);
2791: IF g_debug <= gme_debug.g_log_procedure THEN
2792: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2793: END IF;
2794: EXCEPTION
2795: WHEN doc_num_is_not_passed THEN
2796: x_return_status := fnd_api.g_ret_sts_error;
2810: --FPBug#4351032
2811: WHEN validation_failure OR expected_error OR scaling_failure OR date_exceed_validity_rule OR batch_header_fetch_failure OR error_count_exceeded OR expected_error OR unexpected_error OR invalid_item_substitute OR material_dtl_fetch_failure THEN
2812: x_return_status := fnd_api.g_ret_sts_error;
2813: WHEN error_cont_period THEN
2814: IF (g_debug = gme_debug.g_log_statement) THEN
2815: gme_debug.put_line ('Contiguity period ... _failed');
2816: END IF;
2817:
2818: x_return_status := l_return_status;
2811: WHEN validation_failure OR expected_error OR scaling_failure OR date_exceed_validity_rule OR batch_header_fetch_failure OR error_count_exceeded OR expected_error OR unexpected_error OR invalid_item_substitute OR material_dtl_fetch_failure THEN
2812: x_return_status := fnd_api.g_ret_sts_error;
2813: WHEN error_cont_period THEN
2814: IF (g_debug = gme_debug.g_log_statement) THEN
2815: gme_debug.put_line ('Contiguity period ... _failed');
2816: END IF;
2817:
2818: x_return_status := l_return_status;
2819: WHEN error_non_contiguious THEN
2816: END IF;
2817:
2818: x_return_status := l_return_status;
2819: WHEN error_non_contiguious THEN
2820: IF (g_debug = gme_debug.g_log_statement) THEN
2821: gme_debug.put_line ('Contiguity period ... not found');
2822: END IF;
2823:
2824: gme_common_pvt.log_message ('GME_NON_CONTIGUOUS_TIME');
2817:
2818: x_return_status := l_return_status;
2819: WHEN error_non_contiguious THEN
2820: IF (g_debug = gme_debug.g_log_statement) THEN
2821: gme_debug.put_line ('Contiguity period ... not found');
2822: END IF;
2823:
2824: gme_common_pvt.log_message ('GME_NON_CONTIGUOUS_TIME');
2825: x_return_status := 'C';
2839: fnd_message.set_token ('FROM_UOM', l_from_uom);
2840: fnd_message.set_token ('TO_UOM', l_to_uom);
2841: fnd_msg_pub.ADD;
2842: WHEN Fixed_process_loss_failure THEN
2843: IF (g_debug = gme_debug.g_log_statement) THEN
2844: gme_debug.put_line ('Failed to apply FPL');
2845: END IF;
2846: WHEN create_by_product_failure THEN
2847: gme_common_pvt.log_message ('GME_API_CREATE_BY_PROD_FAIL');
2840: fnd_message.set_token ('TO_UOM', l_to_uom);
2841: fnd_msg_pub.ADD;
2842: WHEN Fixed_process_loss_failure THEN
2843: IF (g_debug = gme_debug.g_log_statement) THEN
2844: gme_debug.put_line ('Failed to apply FPL');
2845: END IF;
2846: WHEN create_by_product_failure THEN
2847: gme_common_pvt.log_message ('GME_API_CREATE_BY_PROD_FAIL');
2848: x_return_status := fnd_api.g_ret_sts_error;
2846: WHEN create_by_product_failure THEN
2847: gme_common_pvt.log_message ('GME_API_CREATE_BY_PROD_FAIL');
2848: x_return_status := fnd_api.g_ret_sts_error;
2849:
2850: IF (g_debug = gme_debug.g_log_statement) THEN
2851: gme_debug.put_line ('GME_API_CREATE_BY_PROD_FAIL');
2852: END IF;
2853: WHEN error_in_integer_scale THEN -- 10624995
2854: gme_common_pvt.log_message ('GME_INTEGER_MULTIPLE_SCALE_ERR');
2847: gme_common_pvt.log_message ('GME_API_CREATE_BY_PROD_FAIL');
2848: x_return_status := fnd_api.g_ret_sts_error;
2849:
2850: IF (g_debug = gme_debug.g_log_statement) THEN
2851: gme_debug.put_line ('GME_API_CREATE_BY_PROD_FAIL');
2852: END IF;
2853: WHEN error_in_integer_scale THEN -- 10624995
2854: gme_common_pvt.log_message ('GME_INTEGER_MULTIPLE_SCALE_ERR');
2855: x_return_status := FND_API.g_ret_sts_error;
2853: WHEN error_in_integer_scale THEN -- 10624995
2854: gme_common_pvt.log_message ('GME_INTEGER_MULTIPLE_SCALE_ERR');
2855: x_return_status := FND_API.g_ret_sts_error;
2856:
2857: IF (g_debug = gme_debug.g_log_statement) THEN
2858: gme_debug.put_line ('Integer scaling failed for non scaled batch.. should not happen !!');
2859: END IF;
2860: WHEN inventory_shortage OR create_mo_hdr_err OR create_mo_line_err OR
2861: calc_mtl_req_date_err OR gmo_instantiate_err OR wip_entity_err THEN
2854: gme_common_pvt.log_message ('GME_INTEGER_MULTIPLE_SCALE_ERR');
2855: x_return_status := FND_API.g_ret_sts_error;
2856:
2857: IF (g_debug = gme_debug.g_log_statement) THEN
2858: gme_debug.put_line ('Integer scaling failed for non scaled batch.. should not happen !!');
2859: END IF;
2860: WHEN inventory_shortage OR create_mo_hdr_err OR create_mo_line_err OR
2861: calc_mtl_req_date_err OR gmo_instantiate_err OR wip_entity_err THEN
2862: x_return_status := l_return_status;
2860: WHEN inventory_shortage OR create_mo_hdr_err OR create_mo_line_err OR
2861: calc_mtl_req_date_err OR gmo_instantiate_err OR wip_entity_err THEN
2862: x_return_status := l_return_status;
2863: WHEN error_truncate_date THEN
2864: IF (g_debug = gme_debug.g_log_statement) THEN
2865: gme_debug.put_line ('truncate date procedure error');
2866: END IF;
2867:
2868: x_return_status := fnd_api.g_ret_sts_error;
2861: calc_mtl_req_date_err OR gmo_instantiate_err OR wip_entity_err THEN
2862: x_return_status := l_return_status;
2863: WHEN error_truncate_date THEN
2864: IF (g_debug = gme_debug.g_log_statement) THEN
2865: gme_debug.put_line ('truncate date procedure error');
2866: END IF;
2867:
2868: x_return_status := fnd_api.g_ret_sts_error;
2869: --FPBug#4395561
2868: x_return_status := fnd_api.g_ret_sts_error;
2869: --FPBug#4395561
2870: WHEN create_flex_failure THEN
2871: x_return_status := l_return_status;
2872: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2873: gme_debug.put_line ('Creating the default values of the DFF failure');
2874: END IF;
2875: -- Rajesh Patangya Bug # 6752637
2876: WHEN update_step_mtq_failure THEN
2869: --FPBug#4395561
2870: WHEN create_flex_failure THEN
2871: x_return_status := l_return_status;
2872: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2873: gme_debug.put_line ('Creating the default values of the DFF failure');
2874: END IF;
2875: -- Rajesh Patangya Bug # 6752637
2876: WHEN update_step_mtq_failure THEN
2877: x_return_status := fnd_api.g_ret_sts_error;
2874: END IF;
2875: -- Rajesh Patangya Bug # 6752637
2876: WHEN update_step_mtq_failure THEN
2877: x_return_status := fnd_api.g_ret_sts_error;
2878: IF (g_debug = gme_debug.g_log_statement) THEN
2879: gme_debug.put_line ('MTQ Calculation failure');
2880: END IF;
2881: WHEN OTHERS THEN
2882: IF g_debug <= gme_debug.g_log_unexpected THEN
2875: -- Rajesh Patangya Bug # 6752637
2876: WHEN update_step_mtq_failure THEN
2877: x_return_status := fnd_api.g_ret_sts_error;
2878: IF (g_debug = gme_debug.g_log_statement) THEN
2879: gme_debug.put_line ('MTQ Calculation failure');
2880: END IF;
2881: WHEN OTHERS THEN
2882: IF g_debug <= gme_debug.g_log_unexpected THEN
2883: gme_debug.put_line ( 'When others exception in '
2878: IF (g_debug = gme_debug.g_log_statement) THEN
2879: gme_debug.put_line ('MTQ Calculation failure');
2880: END IF;
2881: WHEN OTHERS THEN
2882: IF g_debug <= gme_debug.g_log_unexpected THEN
2883: gme_debug.put_line ( 'When others exception in '
2884: || g_pkg_name
2885: || '.'
2886: || l_api_name
2879: gme_debug.put_line ('MTQ Calculation failure');
2880: END IF;
2881: WHEN OTHERS THEN
2882: IF g_debug <= gme_debug.g_log_unexpected THEN
2883: gme_debug.put_line ( 'When others exception in '
2884: || g_pkg_name
2885: || '.'
2886: || l_api_name
2887: || ' Error is '
2889: END IF;
2890:
2891: fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
2892:
2893: IF (g_debug = gme_debug.g_log_statement) THEN
2894: gme_debug.put_line (SQLERRM);
2895: END IF;
2896: x_return_status := fnd_api.g_ret_sts_unexp_error;
2897: END create_batch;
2890:
2891: fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
2892:
2893: IF (g_debug = gme_debug.g_log_statement) THEN
2894: gme_debug.put_line (SQLERRM);
2895: END IF;
2896: x_return_status := fnd_api.g_ret_sts_unexp_error;
2897: END create_batch;
2898:
2975: LOOP
2976: FETCH step_mtq_cursor INTO l_batch_steps ;
2977: EXIT WHEN step_mtq_cursor%NOTFOUND;
2978:
2979: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2980: gme_debug.put_line (' MTQ = ' || NVL(l_batch_steps.minimum_transfer_qty,0)
2981: || ' Step_qty = ' || NVL(l_batch_steps.plan_step_qty,0)
2982: || ' Routingstep_id = ' || l_batch_steps.routingstep_id );
2983: END IF;
2976: FETCH step_mtq_cursor INTO l_batch_steps ;
2977: EXIT WHEN step_mtq_cursor%NOTFOUND;
2978:
2979: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2980: gme_debug.put_line (' MTQ = ' || NVL(l_batch_steps.minimum_transfer_qty,0)
2981: || ' Step_qty = ' || NVL(l_batch_steps.plan_step_qty,0)
2982: || ' Routingstep_id = ' || l_batch_steps.routingstep_id );
2983: END IF;
2984:
2998: WHERE batch_id = l_batch_steps.batch_id
2999: AND routingstep_id = l_batch_steps.routingstep_id
3000: AND batchstep_id = l_batch_steps.batchstep_id ;
3001:
3002: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3003: gme_debug.put_line (' Update Calculated MTQ = ' || l_calculated_mtq );
3004: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
2999: AND routingstep_id = l_batch_steps.routingstep_id
3000: AND batchstep_id = l_batch_steps.batchstep_id ;
3001:
3002: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3003: gme_debug.put_line (' Update Calculated MTQ = ' || l_calculated_mtq );
3004: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3007: gme_debug.put_line (' Cannot Calculated MTQ for step id ' || l_batch_steps.routingstep_id);
3002: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3003: gme_debug.put_line (' Update Calculated MTQ = ' || l_calculated_mtq );
3004: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3007: gme_debug.put_line (' Cannot Calculated MTQ for step id ' || l_batch_steps.routingstep_id);
3008: gme_debug.put_line (' step qty is ' || l_step_qty);
3009: gme_debug.put_line (' total output is ' || l_total_output_qty);
3010: END IF;
3003: gme_debug.put_line (' Update Calculated MTQ = ' || l_calculated_mtq );
3004: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3007: gme_debug.put_line (' Cannot Calculated MTQ for step id ' || l_batch_steps.routingstep_id);
3008: gme_debug.put_line (' step qty is ' || l_step_qty);
3009: gme_debug.put_line (' total output is ' || l_total_output_qty);
3010: END IF;
3011: NULL; -- This is here just in case debug is not on.
3004: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3007: gme_debug.put_line (' Cannot Calculated MTQ for step id ' || l_batch_steps.routingstep_id);
3008: gme_debug.put_line (' step qty is ' || l_step_qty);
3009: gme_debug.put_line (' total output is ' || l_total_output_qty);
3010: END IF;
3011: NULL; -- This is here just in case debug is not on.
3012: END IF;
3005: ELSE
3006: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3007: gme_debug.put_line (' Cannot Calculated MTQ for step id ' || l_batch_steps.routingstep_id);
3008: gme_debug.put_line (' step qty is ' || l_step_qty);
3009: gme_debug.put_line (' total output is ' || l_total_output_qty);
3010: END IF;
3011: NULL; -- This is here just in case debug is not on.
3012: END IF;
3013: END IF;
3020: WHEN no_data_found THEN
3021: RETURN TRUE ;
3022: WHEN OTHERS THEN
3023: fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
3024: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3025: gme_debug.put_line (SQLERRM);
3026: END IF;
3027: RETURN FALSE ;
3028: END update_step_mtq ;
3021: RETURN TRUE ;
3022: WHEN OTHERS THEN
3023: fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
3024: IF (NVL(G_DEBUG,-1) = GME_DEBUG.G_LOG_STATEMENT) THEN
3025: gme_debug.put_line (SQLERRM);
3026: END IF;
3027: RETURN FALSE ;
3028: END update_step_mtq ;
3029: