[Home] [Help]
64: UNION
65: SELECT p_material_step_id from dual;
66: --Bug#5606246 end
67: BEGIN
68: IF g_debug <= gme_debug.g_log_procedure THEN
69: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
70: || l_api_name||' with batchstep_id '||p_batch_step_rec.batchstep_id);
71: END IF;
72:
65: SELECT p_material_step_id from dual;
66: --Bug#5606246 end
67: BEGIN
68: IF g_debug <= gme_debug.g_log_procedure THEN
69: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
70: || l_api_name||' with batchstep_id '||p_batch_step_rec.batchstep_id);
71: END IF;
72:
73: /* Set the savepoint before proceeding */
73: /* Set the savepoint before proceeding */
74: SAVEPOINT update_step_qty;
75: /* Set the return status to success initially */
76: x_return_status := fnd_api.g_ret_sts_success;
77: IF g_debug <= gme_debug.g_log_statement THEN
78: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
79: || l_api_name||'p_routing_scale_factor ' || p_routing_scale_factor);
80: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
81: || l_api_name||'p_backflush_factor ' || p_backflush_factor);
74: SAVEPOINT update_step_qty;
75: /* Set the return status to success initially */
76: x_return_status := fnd_api.g_ret_sts_success;
77: IF g_debug <= gme_debug.g_log_statement THEN
78: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
79: || l_api_name||'p_routing_scale_factor ' || p_routing_scale_factor);
80: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
81: || l_api_name||'p_backflush_factor ' || p_backflush_factor);
82: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
76: x_return_status := fnd_api.g_ret_sts_success;
77: IF g_debug <= gme_debug.g_log_statement THEN
78: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
79: || l_api_name||'p_routing_scale_factor ' || p_routing_scale_factor);
80: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
81: || l_api_name||'p_backflush_factor ' || p_backflush_factor);
82: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
83: || l_api_name||'p_dependency_type ' || p_dependency_type);
84: END IF;
78: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
79: || l_api_name||'p_routing_scale_factor ' || p_routing_scale_factor);
80: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
81: || l_api_name||'p_backflush_factor ' || p_backflush_factor);
82: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
83: || l_api_name||'p_dependency_type ' || p_dependency_type);
84: END IF;
85:
86: /* Initialize output batch step row */
108:
109: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
110: RAISE fnd_api.g_exc_error;
111: END IF;
112: IF g_debug <= gme_debug.g_log_statement THEN
113: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
114: || l_api_name||': Resource transactions loaded '||l_rec);
115: END IF;
116: l_rec := 0;
109: IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
110: RAISE fnd_api.g_exc_error;
111: END IF;
112: IF g_debug <= gme_debug.g_log_statement THEN
113: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
114: || l_api_name||': Resource transactions loaded '||l_rec);
115: END IF;
116: l_rec := 0;
117:
129: /* passed in WIP we have to calculate for the whole batch as this procedure */
130: /* might be called from uncertify batch wherein we have to decrease the */
131: /* succeeding step quantities. */
132:
133: IF g_debug <= gme_debug.g_log_statement THEN
134: gme_debug.put_line ('Calling calc_step_qty. step status is ' ||x_batch_step_rec.step_status);
135: END IF;
136:
137: IF x_batch_step_rec.step_status IN
130: /* might be called from uncertify batch wherein we have to decrease the */
131: /* succeeding step quantities. */
132:
133: IF g_debug <= gme_debug.g_log_statement THEN
134: gme_debug.put_line ('Calling calc_step_qty. step status is ' ||x_batch_step_rec.step_status);
135: END IF;
136:
137: IF x_batch_step_rec.step_status IN
138: (gme_common_pvt.g_step_pending
171: l_rec :=
172: gmd_auto_step_calc.get_step_rec (x_batch_step_rec.batchstep_no
173: ,l_step_tbl);
174:
175: IF g_debug <= gme_debug.g_log_statement THEN
176: gme_debug.put_line ('Back from calc_step_qty. qty is ' ||l_step_tbl (l_rec).step_qty);
177: gme_debug.put_line ('MASS qty is ' ||l_step_tbl (l_rec).step_mass_qty);
178: gme_debug.put_line ('VOL qty is ' ||l_step_tbl (l_rec).step_vol_qty);
179: END IF;
172: gmd_auto_step_calc.get_step_rec (x_batch_step_rec.batchstep_no
173: ,l_step_tbl);
174:
175: IF g_debug <= gme_debug.g_log_statement THEN
176: gme_debug.put_line ('Back from calc_step_qty. qty is ' ||l_step_tbl (l_rec).step_qty);
177: gme_debug.put_line ('MASS qty is ' ||l_step_tbl (l_rec).step_mass_qty);
178: gme_debug.put_line ('VOL qty is ' ||l_step_tbl (l_rec).step_vol_qty);
179: END IF;
180:
173: ,l_step_tbl);
174:
175: IF g_debug <= gme_debug.g_log_statement THEN
176: gme_debug.put_line ('Back from calc_step_qty. qty is ' ||l_step_tbl (l_rec).step_qty);
177: gme_debug.put_line ('MASS qty is ' ||l_step_tbl (l_rec).step_mass_qty);
178: gme_debug.put_line ('VOL qty is ' ||l_step_tbl (l_rec).step_vol_qty);
179: END IF;
180:
181: /* If step status is not in pending then actual quantities have to be updated. */
174:
175: IF g_debug <= gme_debug.g_log_statement THEN
176: gme_debug.put_line ('Back from calc_step_qty. qty is ' ||l_step_tbl (l_rec).step_qty);
177: gme_debug.put_line ('MASS qty is ' ||l_step_tbl (l_rec).step_mass_qty);
178: gme_debug.put_line ('VOL qty is ' ||l_step_tbl (l_rec).step_vol_qty);
179: END IF;
180:
181: /* If step status is not in pending then actual quantities have to be updated. */
182: IF x_batch_step_rec.step_status > gme_common_pvt.g_step_pending THEN
312: END LOOP; /* FOR dep_steps*/
313: END IF; /* IF x_batch_step_rec.step_status IN (2, 3) */
314: END IF; /*IF l_batch_header.automatic_step_calculation = 1*/
315:
316: IF g_debug <= gme_debug.g_log_procedure THEN
317: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
318: END IF;
319: EXCEPTION
320: WHEN batch_step_fetch_error THEN
313: END IF; /* IF x_batch_step_rec.step_status IN (2, 3) */
314: END IF; /*IF l_batch_header.automatic_step_calculation = 1*/
315:
316: IF g_debug <= gme_debug.g_log_procedure THEN
317: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
318: END IF;
319: EXCEPTION
320: WHEN batch_step_fetch_error THEN
321: ROLLBACK TO SAVEPOINT update_step_qty;
349: x_return_status := l_return_status;
350: fnd_msg_pub.count_and_get (p_count => x_message_count
351: ,p_data => x_message_list);
352: WHEN OTHERS THEN
353: IF g_debug <= gme_debug.g_log_unexpected THEN
354: gme_debug.put_line ( 'When others exception in '
355: || g_pkg_name
356: || '.'
357: || l_api_name
350: fnd_msg_pub.count_and_get (p_count => x_message_count
351: ,p_data => x_message_list);
352: WHEN OTHERS THEN
353: IF g_debug <= gme_debug.g_log_unexpected THEN
354: gme_debug.put_line ( 'When others exception in '
355: || g_pkg_name
356: || '.'
357: || l_api_name
358: || ' Error is '
390: l_um_type mtl_uom_conversions.uom_class%TYPE;
391: l_std_factor NUMBER;
392: l_api_name CONSTANT VARCHAR2 (30) := 'calculate_mass_vol_qty';
393: BEGIN
394: IF g_debug <= gme_debug.g_log_procedure THEN
395: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
396: || l_api_name);
397: END IF;
398:
391: l_std_factor NUMBER;
392: l_api_name CONSTANT VARCHAR2 (30) := 'calculate_mass_vol_qty';
393: BEGIN
394: IF g_debug <= gme_debug.g_log_procedure THEN
395: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
396: || l_api_name);
397: END IF;
398:
399: OPEN cur_get_uom;
424: NVL (p_batch_step_rec.plan_step_qty * l_std_factor, 0);
425: END IF; /* IF p_batch_step_rec.step_status > 1 */
426: END IF; /* IF l_um_type = gme_common_pvt.g_mass_um_type */
427:
428: IF g_debug <= gme_debug.g_log_procedure THEN
429: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
430: END IF;
431: EXCEPTION
432: WHEN OTHERS THEN
425: END IF; /* IF p_batch_step_rec.step_status > 1 */
426: END IF; /* IF l_um_type = gme_common_pvt.g_mass_um_type */
427:
428: IF g_debug <= gme_debug.g_log_procedure THEN
429: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
430: END IF;
431: EXCEPTION
432: WHEN OTHERS THEN
433: IF g_debug <= gme_debug.g_log_unexpected THEN
429: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
430: END IF;
431: EXCEPTION
432: WHEN OTHERS THEN
433: IF g_debug <= gme_debug.g_log_unexpected THEN
434: gme_debug.put_line ( 'When others exception in '
435: || g_pkg_name
436: || '.'
437: || l_api_name
430: END IF;
431: EXCEPTION
432: WHEN OTHERS THEN
433: IF g_debug <= gme_debug.g_log_unexpected THEN
434: gme_debug.put_line ( 'When others exception in '
435: || g_pkg_name
436: || '.'
437: || l_api_name
438: || ' Error is '
476: l_charges NUMBER;
477: l_orig_charges NUMBER;
478: l_charge_diff NUMBER;
479: BEGIN
480: IF g_debug <= gme_debug.g_log_procedure THEN
481: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
482: || l_api_name);
483: END IF;
484:
477: l_orig_charges NUMBER;
478: l_charge_diff NUMBER;
479: BEGIN
480: IF g_debug <= gme_debug.g_log_procedure THEN
481: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
482: || l_api_name);
483: END IF;
484:
485: /* Set the return status to success initially */
547: ,p_batch_step_rec) ) THEN
548: RAISE batch_step_fetch_err;
549: END IF;
550:
551: IF g_debug <= gme_debug.g_log_procedure THEN
552: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
553: END IF;
554: EXCEPTION
555: WHEN compute_resource_error THEN
548: RAISE batch_step_fetch_err;
549: END IF;
550:
551: IF g_debug <= gme_debug.g_log_procedure THEN
552: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
553: END IF;
554: EXCEPTION
555: WHEN compute_resource_error THEN
556: x_return_status := l_return_status;
556: x_return_status := l_return_status;
557: WHEN batch_step_upd_err OR error_calc_charge OR batch_step_fetch_err THEN
558: x_return_status := fnd_api.g_ret_sts_error;
559: WHEN OTHERS THEN
560: IF g_debug <= gme_debug.g_log_unexpected THEN
561: gme_debug.put_line ( 'When others exception in '
562: || g_pkg_name
563: || '.'
564: || l_api_name
557: WHEN batch_step_upd_err OR error_calc_charge OR batch_step_fetch_err THEN
558: x_return_status := fnd_api.g_ret_sts_error;
559: WHEN OTHERS THEN
560: IF g_debug <= gme_debug.g_log_unexpected THEN
561: gme_debug.put_line ( 'When others exception in '
562: || g_pkg_name
563: || '.'
564: || l_api_name
565: || ' Error is '
674: error_step_not_found EXCEPTION;
675: error_calc_charge_conv EXCEPTION;
676: error_max_cap_not_mass_vol EXCEPTION;
677: BEGIN
678: IF g_debug <= gme_debug.g_log_procedure THEN
679: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
680: || l_api_name);
681: END IF;
682:
675: error_calc_charge_conv EXCEPTION;
676: error_max_cap_not_mass_vol EXCEPTION;
677: BEGIN
678: IF g_debug <= gme_debug.g_log_procedure THEN
679: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
680: || l_api_name);
681: END IF;
682:
683: /* Initialize the return status to success */
684: x_return_status := fnd_api.g_ret_sts_success;
685: x_charge := 0;
686: l_remaining_quantity := -1;
687:
688: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
689: gme_debug.put_line('pmassqty: '||p_mass_qty);
690: gme_debug.put_line('pvolqty: '||p_vol_qty);
691: END IF;
692:
685: x_charge := 0;
686: l_remaining_quantity := -1;
687:
688: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
689: gme_debug.put_line('pmassqty: '||p_mass_qty);
690: gme_debug.put_line('pvolqty: '||p_vol_qty);
691: END IF;
692:
693: /* Get the max capacity and uom for the current step */
686: l_remaining_quantity := -1;
687:
688: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
689: gme_debug.put_line('pmassqty: '||p_mass_qty);
690: gme_debug.put_line('pvolqty: '||p_vol_qty);
691: END IF;
692:
693: /* Get the max capacity and uom for the current step */
694: OPEN cur_get_max_capacity;
701: RAISE error_step_not_found;
702: END IF;
703: CLOSE cur_get_max_capacity;
704:
705: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
706: gme_debug.put_line('Max capacity, UOM: '||x_max_cap||', '||x_max_cap_uom);
707: gme_debug.put_line('Step Qty, UOM: '||x_step_qty||', '||x_step_qty_uom);
708: END IF;
709:
702: END IF;
703: CLOSE cur_get_max_capacity;
704:
705: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
706: gme_debug.put_line('Max capacity, UOM: '||x_max_cap||', '||x_max_cap_uom);
707: gme_debug.put_line('Step Qty, UOM: '||x_step_qty||', '||x_step_qty_uom);
708: END IF;
709:
710: /* Bug#5231180 Begin if we pass step qty and max capacity use them otherwise get the values
703: CLOSE cur_get_max_capacity;
704:
705: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
706: gme_debug.put_line('Max capacity, UOM: '||x_max_cap||', '||x_max_cap_uom);
707: gme_debug.put_line('Step Qty, UOM: '||x_step_qty||', '||x_step_qty_uom);
708: END IF;
709:
710: /* Bug#5231180 Begin if we pass step qty and max capacity use them otherwise get the values
711: from table. these will be passed from recalculate charges procedure */
735: CLOSE cur_get_std_factor;
736:
737: x_std_capacity := x_max_cap * x_std_factor;
738:
739: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
740: gme_debug.put_line('x_um_type: '||x_um_type);
741: gme_debug.put_line('Standard Factor: '||x_std_factor);
742: gme_debug.put_line('Standard Capacity: '||x_std_capacity);
743: END IF;
736:
737: x_std_capacity := x_max_cap * x_std_factor;
738:
739: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
740: gme_debug.put_line('x_um_type: '||x_um_type);
741: gme_debug.put_line('Standard Factor: '||x_std_factor);
742: gme_debug.put_line('Standard Capacity: '||x_std_capacity);
743: END IF;
744:
737: x_std_capacity := x_max_cap * x_std_factor;
738:
739: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
740: gme_debug.put_line('x_um_type: '||x_um_type);
741: gme_debug.put_line('Standard Factor: '||x_std_factor);
742: gme_debug.put_line('Standard Capacity: '||x_std_capacity);
743: END IF;
744:
745: --Bug2617151
738:
739: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
740: gme_debug.put_line('x_um_type: '||x_um_type);
741: gme_debug.put_line('Standard Factor: '||x_std_factor);
742: gme_debug.put_line('Standard Capacity: '||x_std_capacity);
743: END IF;
744:
745: --Bug2617151
746: OPEN cur_get_tolerance;
751: CLOSE cur_get_tolerance;
752:
753: x_stdum_tolerance := (x_tolerance * x_std_capacity) / 100;
754:
755: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
756: gme_debug.put_line('x_tolerance: '||x_tolerance);
757: gme_debug.put_line('x_stdum_tolerance: '||x_stdum_tolerance);
758: gme_debug.put_line('gme_common_pvt.g_mass_um_type: '||gme_common_pvt.g_mass_um_type);
759: gme_debug.put_line('gme_common_pvt.g_volume_um_type: '||gme_common_pvt.g_volume_um_type);
752:
753: x_stdum_tolerance := (x_tolerance * x_std_capacity) / 100;
754:
755: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
756: gme_debug.put_line('x_tolerance: '||x_tolerance);
757: gme_debug.put_line('x_stdum_tolerance: '||x_stdum_tolerance);
758: gme_debug.put_line('gme_common_pvt.g_mass_um_type: '||gme_common_pvt.g_mass_um_type);
759: gme_debug.put_line('gme_common_pvt.g_volume_um_type: '||gme_common_pvt.g_volume_um_type);
760: END IF;
753: x_stdum_tolerance := (x_tolerance * x_std_capacity) / 100;
754:
755: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
756: gme_debug.put_line('x_tolerance: '||x_tolerance);
757: gme_debug.put_line('x_stdum_tolerance: '||x_stdum_tolerance);
758: gme_debug.put_line('gme_common_pvt.g_mass_um_type: '||gme_common_pvt.g_mass_um_type);
759: gme_debug.put_line('gme_common_pvt.g_volume_um_type: '||gme_common_pvt.g_volume_um_type);
760: END IF;
761:
754:
755: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
756: gme_debug.put_line('x_tolerance: '||x_tolerance);
757: gme_debug.put_line('x_stdum_tolerance: '||x_stdum_tolerance);
758: gme_debug.put_line('gme_common_pvt.g_mass_um_type: '||gme_common_pvt.g_mass_um_type);
759: gme_debug.put_line('gme_common_pvt.g_volume_um_type: '||gme_common_pvt.g_volume_um_type);
760: END IF;
761:
762: -- Capacity will be in either mass or volume...
755: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
756: gme_debug.put_line('x_tolerance: '||x_tolerance);
757: gme_debug.put_line('x_stdum_tolerance: '||x_stdum_tolerance);
758: gme_debug.put_line('gme_common_pvt.g_mass_um_type: '||gme_common_pvt.g_mass_um_type);
759: gme_debug.put_line('gme_common_pvt.g_volume_um_type: '||gme_common_pvt.g_volume_um_type);
760: END IF;
761:
762: -- Capacity will be in either mass or volume...
763: IF x_um_type = gme_common_pvt.g_mass_um_type THEN
760: END IF;
761:
762: -- Capacity will be in either mass or volume...
763: IF x_um_type = gme_common_pvt.g_mass_um_type THEN
764: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
765: gme_debug.put_line('This is MASS type.');
766: END IF;
767:
768: IF (p_mass_qty IS NULL) THEN
761:
762: -- Capacity will be in either mass or volume...
763: IF x_um_type = gme_common_pvt.g_mass_um_type THEN
764: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
765: gme_debug.put_line('This is MASS type.');
766: END IF;
767:
768: IF (p_mass_qty IS NULL) THEN
769: RAISE error_calc_charge_conv;
768: IF (p_mass_qty IS NULL) THEN
769: RAISE error_calc_charge_conv;
770: END IF;
771:
772: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
773: gme_debug.put_line('qty is: '||MOD (p_mass_qty, x_std_capacity));
774: END IF;
775:
776: IF (MOD (p_mass_qty, x_std_capacity) > x_stdum_tolerance) THEN
769: RAISE error_calc_charge_conv;
770: END IF;
771:
772: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
773: gme_debug.put_line('qty is: '||MOD (p_mass_qty, x_std_capacity));
774: END IF;
775:
776: IF (MOD (p_mass_qty, x_std_capacity) > x_stdum_tolerance) THEN
777: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
773: gme_debug.put_line('qty is: '||MOD (p_mass_qty, x_std_capacity));
774: END IF;
775:
776: IF (MOD (p_mass_qty, x_std_capacity) > x_stdum_tolerance) THEN
777: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
778: gme_debug.put_line('MASS point 1A');
779: END IF;
780:
781: x_charge := CEIL (p_mass_qty / x_std_capacity);
774: END IF;
775:
776: IF (MOD (p_mass_qty, x_std_capacity) > x_stdum_tolerance) THEN
777: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
778: gme_debug.put_line('MASS point 1A');
779: END IF;
780:
781: x_charge := CEIL (p_mass_qty / x_std_capacity);
782: l_remaining_quantity := MOD (p_mass_qty, x_std_capacity);
780:
781: x_charge := CEIL (p_mass_qty / x_std_capacity);
782: l_remaining_quantity := MOD (p_mass_qty, x_std_capacity);
783: ELSE
784: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
785: gme_debug.put_line('MASS point 1B');
786: END IF;
787: x_charge := TRUNC (p_mass_qty / x_std_capacity);
788:
781: x_charge := CEIL (p_mass_qty / x_std_capacity);
782: l_remaining_quantity := MOD (p_mass_qty, x_std_capacity);
783: ELSE
784: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
785: gme_debug.put_line('MASS point 1B');
786: END IF;
787: x_charge := TRUNC (p_mass_qty / x_std_capacity);
788:
789: -- Bug 12568872 - initialize charge to 1 if necessary.
791: x_charge := 1;
792: END IF;
793: END IF;
794:
795: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
796: gme_debug.put_line('x_charge is: '||x_charge);
797: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
798: END IF;
799:
792: END IF;
793: END IF;
794:
795: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
796: gme_debug.put_line('x_charge is: '||x_charge);
797: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
798: END IF;
799:
800: ELSIF x_um_type = gme_common_pvt.g_volume_um_type THEN
793: END IF;
794:
795: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
796: gme_debug.put_line('x_charge is: '||x_charge);
797: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
798: END IF;
799:
800: ELSIF x_um_type = gme_common_pvt.g_volume_um_type THEN
801:
798: END IF;
799:
800: ELSIF x_um_type = gme_common_pvt.g_volume_um_type THEN
801:
802: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
803: gme_debug.put_line('This is VOLUME type.');
804: END IF;
805:
806: IF (p_vol_qty IS NULL) THEN
799:
800: ELSIF x_um_type = gme_common_pvt.g_volume_um_type THEN
801:
802: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
803: gme_debug.put_line('This is VOLUME type.');
804: END IF;
805:
806: IF (p_vol_qty IS NULL) THEN
807: RAISE error_calc_charge_conv;
806: IF (p_vol_qty IS NULL) THEN
807: RAISE error_calc_charge_conv;
808: END IF;
809:
810: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
811: gme_debug.put_line('qty is: '||MOD (p_vol_qty, x_std_capacity));
812: END IF;
813:
814: IF (MOD (p_vol_qty, x_std_capacity) > x_stdum_tolerance) THEN
807: RAISE error_calc_charge_conv;
808: END IF;
809:
810: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
811: gme_debug.put_line('qty is: '||MOD (p_vol_qty, x_std_capacity));
812: END IF;
813:
814: IF (MOD (p_vol_qty, x_std_capacity) > x_stdum_tolerance) THEN
815: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
811: gme_debug.put_line('qty is: '||MOD (p_vol_qty, x_std_capacity));
812: END IF;
813:
814: IF (MOD (p_vol_qty, x_std_capacity) > x_stdum_tolerance) THEN
815: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
816: gme_debug.put_line('VOLUME point 1A');
817: END IF;
818: x_charge := CEIL (p_vol_qty / x_std_capacity);
819: l_remaining_quantity := MOD (p_vol_qty, x_std_capacity);
812: END IF;
813:
814: IF (MOD (p_vol_qty, x_std_capacity) > x_stdum_tolerance) THEN
815: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
816: gme_debug.put_line('VOLUME point 1A');
817: END IF;
818: x_charge := CEIL (p_vol_qty / x_std_capacity);
819: l_remaining_quantity := MOD (p_vol_qty, x_std_capacity);
820: ELSE
817: END IF;
818: x_charge := CEIL (p_vol_qty / x_std_capacity);
819: l_remaining_quantity := MOD (p_vol_qty, x_std_capacity);
820: ELSE
821: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
822: gme_debug.put_line('VOLUME point 1B');
823: END IF;
824: x_charge := TRUNC (p_vol_qty / x_std_capacity);
825:
818: x_charge := CEIL (p_vol_qty / x_std_capacity);
819: l_remaining_quantity := MOD (p_vol_qty, x_std_capacity);
820: ELSE
821: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
822: gme_debug.put_line('VOLUME point 1B');
823: END IF;
824: x_charge := TRUNC (p_vol_qty / x_std_capacity);
825:
826: -- Bug 12568872 - initialize charge to 1 if necessary.
828: x_charge := 1;
829: END IF;
830: END IF;
831:
832: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
833: gme_debug.put_line('x_charge is: '||x_charge);
834: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
835: END IF;
836:
829: END IF;
830: END IF;
831:
832: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
833: gme_debug.put_line('x_charge is: '||x_charge);
834: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
835: END IF;
836:
837: ELSE
830: END IF;
831:
832: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
833: gme_debug.put_line('x_charge is: '||x_charge);
834: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
835: END IF;
836:
837: ELSE
838: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
834: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
835: END IF;
836:
837: ELSE
838: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
839: gme_debug.put_line('OTHER UOM TYPE');
840: END IF;
841:
842: x_temp_qty :=
835: END IF;
836:
837: ELSE
838: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
839: gme_debug.put_line('OTHER UOM TYPE');
840: END IF;
841:
842: x_temp_qty :=
843: inv_convert.inv_um_convert
872: END IF;
873: END IF;
874: END IF; /* if (x_temp_qty < 0) then */
875:
876: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
877: gme_debug.put_line('x_charge is: '||x_charge);
878: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
879: END IF;
880: END IF;
873: END IF;
874: END IF; /* if (x_temp_qty < 0) then */
875:
876: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
877: gme_debug.put_line('x_charge is: '||x_charge);
878: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
879: END IF;
880: END IF;
881: END IF; /*if x_max_cap_uom is not null then */
874: END IF; /* if (x_temp_qty < 0) then */
875:
876: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
877: gme_debug.put_line('x_charge is: '||x_charge);
878: gme_debug.put_line('l_remaining_quantity is: '||l_remaining_quantity);
879: END IF;
880: END IF;
881: END IF; /*if x_max_cap_uom is not null then */
882:
881: END IF; /*if x_max_cap_uom is not null then */
882:
883: /*Checking the scale type of the resource before
884: populating the charges table*/
885: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
886: gme_debug.put_line ('p_resources is' || p_resources);
887: END IF;
888:
889: IF p_resources IS NOT NULL THEN
882:
883: /*Checking the scale type of the resource before
884: populating the charges table*/
885: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
886: gme_debug.put_line ('p_resources is' || p_resources);
887: END IF;
888:
889: IF p_resources IS NOT NULL THEN
890: OPEN cur_get_scale_type (p_resources);
892: INTO l_scale_type;
893:
894: CLOSE cur_get_scale_type;
895:
896: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
897: gme_debug.put_line ('l_scale_type is' || l_scale_type);
898: END IF;
899:
900: IF l_scale_type = 1 THEN
893:
894: CLOSE cur_get_scale_type;
895:
896: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
897: gme_debug.put_line ('l_scale_type is' || l_scale_type);
898: END IF;
899:
900: IF l_scale_type = 1 THEN
901: --Generating the charge details and populating the gme_batch_step_charges table.
914: IF x_std_factor <> 1 AND l_remaining_quantity <> -1 THEN
915: l_remaining_quantity := (l_remaining_quantity / x_std_factor);
916: END IF;
917:
918: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
919: gme_debug.put_line ( 'l_remaining_quantity is'
920: || l_remaining_quantity);
921: END IF;
922:
915: l_remaining_quantity := (l_remaining_quantity / x_std_factor);
916: END IF;
917:
918: IF NVL (g_debug, -1) = gme_debug.g_log_statement THEN
919: gme_debug.put_line ( 'l_remaining_quantity is'
920: || l_remaining_quantity);
921: END IF;
922:
923: l_batch_step_charges_in.batch_id := l_batch_id;
939: END IF;
940: END IF; /*if l_scale_type = 1*/
941: END IF; /*if p_resource is not null*/
942:
943: IF g_debug <= gme_debug.g_log_procedure THEN
944: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
945: END IF;
946: EXCEPTION
947: WHEN error_step_not_found THEN
940: END IF; /*if l_scale_type = 1*/
941: END IF; /*if p_resource is not null*/
942:
943: IF g_debug <= gme_debug.g_log_procedure THEN
944: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
945: END IF;
946: EXCEPTION
947: WHEN error_step_not_found THEN
948: x_return_status := fnd_api.g_ret_sts_error;
967: gme_common_pvt.log_message ('GME_INSERT_CHARGE_ERROR'
968: ,'STEP_NO'
969: ,x_step_no);
970: WHEN OTHERS THEN
971: IF g_debug <= gme_debug.g_log_unexpected THEN
972: gme_debug.put_line ( 'When others exception in '
973: || g_pkg_name
974: || '.'
975: || l_api_name
968: ,'STEP_NO'
969: ,x_step_no);
970: WHEN OTHERS THEN
971: IF g_debug <= gme_debug.g_log_unexpected THEN
972: gme_debug.put_line ( 'When others exception in '
973: || g_pkg_name
974: || '.'
975: || l_api_name
976: || ' Error is '
1024: step_activity_fetch_error EXCEPTION;
1025: step_resource_upd_err EXCEPTION;
1026: step_activity_upd_err EXCEPTION;
1027: BEGIN
1028: IF g_debug <= gme_debug.g_log_procedure THEN
1029: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1030: || l_api_name);
1031: END IF;
1032:
1025: step_resource_upd_err EXCEPTION;
1026: step_activity_upd_err EXCEPTION;
1027: BEGIN
1028: IF g_debug <= gme_debug.g_log_procedure THEN
1029: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1030: || l_api_name);
1031: END IF;
1032:
1033: /* Initialize the return status to success */
1104: RAISE step_activity_upd_err;
1105: END IF;
1106: END LOOP; /* FOR i IN 1..l_batchstep_activity_ids.COUNT LOOP */
1107:
1108: IF g_debug <= gme_debug.g_log_procedure THEN
1109: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
1110: END IF;
1111: EXCEPTION
1112: WHEN step_activity_fetch_error THEN
1105: END IF;
1106: END LOOP; /* FOR i IN 1..l_batchstep_activity_ids.COUNT LOOP */
1107:
1108: IF g_debug <= gme_debug.g_log_procedure THEN
1109: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
1110: END IF;
1111: EXCEPTION
1112: WHEN step_activity_fetch_error THEN
1113: x_return_status := fnd_api.g_ret_sts_error;
1135: fnd_msg_pub.add_exc_msg ('gme_update_step_qty_pvt'
1136: ,'UPDATE_ACTIVITIES');
1137: END IF;
1138: WHEN OTHERS THEN
1139: IF g_debug <= gme_debug.g_log_unexpected THEN
1140: gme_debug.put_line ( 'When others exception in '
1141: || g_pkg_name
1142: || '.'
1143: || l_api_name
1136: ,'UPDATE_ACTIVITIES');
1137: END IF;
1138: WHEN OTHERS THEN
1139: IF g_debug <= gme_debug.g_log_unexpected THEN
1140: gme_debug.put_line ( 'When others exception in '
1141: || g_pkg_name
1142: || '.'
1143: || l_api_name
1144: || ' Error is '
1237: error_txns_update EXCEPTION;
1238: error_fetch_rsrc_tran EXCEPTION;
1239: qty_below_cap_error EXCEPTION;
1240: BEGIN
1241: IF g_debug <= gme_debug.g_log_procedure THEN
1242: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1243: || l_api_name);
1244: END IF;
1245:
1238: error_fetch_rsrc_tran EXCEPTION;
1239: qty_below_cap_error EXCEPTION;
1240: BEGIN
1241: IF g_debug <= gme_debug.g_log_procedure THEN
1242: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1243: || l_api_name);
1244: END IF;
1245:
1246: /* Initialize the return status to success */
1513: INTO l_prev_plan_charges;
1514:
1515: CLOSE cur_prev_plan_charge;
1516:
1517: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1518: gme_debug.put_line ( ' plan rsrc qty:'
1519: || l_gme_batchstep_resources.plan_rsrc_qty
1520: || ' Plan actv:'
1521: || l_prev_plan_actv_fact);
1514:
1515: CLOSE cur_prev_plan_charge;
1516:
1517: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1518: gme_debug.put_line ( ' plan rsrc qty:'
1519: || l_gme_batchstep_resources.plan_rsrc_qty
1520: || ' Plan actv:'
1521: || l_prev_plan_actv_fact);
1522: END IF;
1734: NVL (l_gme_batchstep_resources.plan_rsrc_qty, 0);
1735: END IF; /* IF p_batch_hdr_rec.automatic_step_calculation = 1 */
1736:
1737: /* We should check for the process qty going below the min capacity based on the profile */
1738: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1739: gme_debug.put_line
1740: ( ' Allow qty to go below capacity profile value:'
1741: || l_allow_qty_below_cap);
1742: END IF;
1735: END IF; /* IF p_batch_hdr_rec.automatic_step_calculation = 1 */
1736:
1737: /* We should check for the process qty going below the min capacity based on the profile */
1738: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1739: gme_debug.put_line
1740: ( ' Allow qty to go below capacity profile value:'
1741: || l_allow_qty_below_cap);
1742: END IF;
1743:
1793: gme_common_pvt.g_step_pending
1794: OR ( p_batch_hdr_rec.automatic_step_calculation = 1
1795: AND p_batch_step_rec.step_status =
1796: gme_common_pvt.g_step_wip) ) THEN
1797: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1798: gme_debug.put_line (' invoking pending usage');
1799: END IF;
1800:
1801: adjust_pending_usage
1794: OR ( p_batch_hdr_rec.automatic_step_calculation = 1
1795: AND p_batch_step_rec.step_status =
1796: gme_common_pvt.g_step_wip) ) THEN
1797: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1798: gme_debug.put_line (' invoking pending usage');
1799: END IF;
1800:
1801: adjust_pending_usage
1802: (p_batch_step_resources_rec => l_gme_batchstep_resources
1823: RAISE step_resource_upd_err;
1824: END IF;
1825: END LOOP; /* FOR i IN 1..l_batchstep_resource_ids.COUNT LOOP */
1826:
1827: IF g_debug <= gme_debug.g_log_procedure THEN
1828: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
1829: END IF;
1830: EXCEPTION
1831: WHEN activity_resource_fetch_error THEN
1824: END IF;
1825: END LOOP; /* FOR i IN 1..l_batchstep_resource_ids.COUNT LOOP */
1826:
1827: IF g_debug <= gme_debug.g_log_procedure THEN
1828: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
1829: END IF;
1830: EXCEPTION
1831: WHEN activity_resource_fetch_error THEN
1832: x_return_status := fnd_api.g_ret_sts_error;
1843: gme_common_pvt.log_message ('GME_API_RSRC_QTY_BELOW_CAP'
1844: ,'RESOURCES'
1845: ,l_gme_batchstep_resources.resources);
1846: WHEN OTHERS THEN
1847: IF g_debug <= gme_debug.g_log_unexpected THEN
1848: gme_debug.put_line ( 'When others exception in '
1849: || g_pkg_name
1850: || '.'
1851: || l_api_name
1844: ,'RESOURCES'
1845: ,l_gme_batchstep_resources.resources);
1846: WHEN OTHERS THEN
1847: IF g_debug <= gme_debug.g_log_unexpected THEN
1848: gme_debug.put_line ( 'When others exception in '
1849: || g_pkg_name
1850: || '.'
1851: || l_api_name
1852: || ' Error is '
1901: resource_trans_ins_err EXCEPTION;
1902: -- p_tran_rec gmi_trans_engine_pub.ictran_rec;
1903: -- l_tran_rec_out gmi_trans_engine_pub.ictran_rec;
1904: BEGIN
1905: IF g_debug <= gme_debug.g_log_procedure THEN
1906: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1907: || l_api_name);
1908: END IF;
1909:
1902: -- p_tran_rec gmi_trans_engine_pub.ictran_rec;
1903: -- l_tran_rec_out gmi_trans_engine_pub.ictran_rec;
1904: BEGIN
1905: IF g_debug <= gme_debug.g_log_procedure THEN
1906: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
1907: || l_api_name);
1908: END IF;
1909:
1910: /* Initialize the return status to success */
1950: ,l_usage_hrs
1951: ,l_return_status);
1952:
1953: IF l_return_status = 'S' THEN
1954: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1955: gme_debug.put_line ( 'l_return_status'
1956: || l_return_status
1957: || ' usage'
1958: || l_usage_hrs);
1951: ,l_return_status);
1952:
1953: IF l_return_status = 'S' THEN
1954: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1955: gme_debug.put_line ( 'l_return_status'
1956: || l_return_status
1957: || ' usage'
1958: || l_usage_hrs);
1959: END IF;
2010: ,l_ins_resource_row) ) THEN
2011: RAISE resource_trans_ins_err;
2012: END IF;
2013:
2014: IF g_debug <= gme_debug.g_log_procedure THEN
2015: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2016: END IF;
2017: EXCEPTION
2018: WHEN resource_trans_ins_err THEN
2011: RAISE resource_trans_ins_err;
2012: END IF;
2013:
2014: IF g_debug <= gme_debug.g_log_procedure THEN
2015: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2016: END IF;
2017: EXCEPTION
2018: WHEN resource_trans_ins_err THEN
2019: x_return_status := fnd_api.g_ret_sts_error;
2019: x_return_status := fnd_api.g_ret_sts_error;
2020: WHEN fnd_api.g_exc_error THEN
2021: x_return_status := fnd_api.g_ret_sts_error;
2022: WHEN OTHERS THEN
2023: IF g_debug <= gme_debug.g_log_unexpected THEN
2024: gme_debug.put_line ( 'When others exception in '
2025: || g_pkg_name
2026: || '.'
2027: || l_api_name
2020: WHEN fnd_api.g_exc_error THEN
2021: x_return_status := fnd_api.g_ret_sts_error;
2022: WHEN OTHERS THEN
2023: IF g_debug <= gme_debug.g_log_unexpected THEN
2024: gme_debug.put_line ( 'When others exception in '
2025: || g_pkg_name
2026: || '.'
2027: || l_api_name
2028: || ' Error is '
2064: l_tot_usage NUMBER;
2065: l_tran_count NUMBER;
2066: l_return_status VARCHAR2 (1);
2067: BEGIN
2068: IF g_debug <= gme_debug.g_log_procedure THEN
2069: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2070: || l_api_name);
2071: END IF;
2072:
2065: l_tran_count NUMBER;
2066: l_return_status VARCHAR2 (1);
2067: BEGIN
2068: IF g_debug <= gme_debug.g_log_procedure THEN
2069: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2070: || l_api_name);
2071: END IF;
2072:
2073: /* Initialize return status to success */
2080: INTO l_tot_usage, l_tran_count;
2081:
2082: CLOSE cur_sum_usage;
2083:
2084: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2085: gme_debug.put_line ( ' tot usage:'
2086: || l_tot_usage
2087: || ' count:'
2088: || l_tran_count);
2081:
2082: CLOSE cur_sum_usage;
2083:
2084: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2085: gme_debug.put_line ( ' tot usage:'
2086: || l_tot_usage
2087: || ' count:'
2088: || l_tran_count);
2089: END IF;
2089: END IF;
2090:
2091: IF (l_tot_usage <> p_batch_step_resources_rec.plan_rsrc_usage)
2092: OR (l_tran_count <> p_batch_step_resources_rec.plan_rsrc_count) THEN
2093: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2094: gme_debug.put_line
2095: ( ' Pending Plan Usage:'
2096: || TO_CHAR (p_batch_step_resources_rec.plan_rsrc_usage)
2097: || ' Plan Count:'
2090:
2091: IF (l_tot_usage <> p_batch_step_resources_rec.plan_rsrc_usage)
2092: OR (l_tran_count <> p_batch_step_resources_rec.plan_rsrc_count) THEN
2093: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2094: gme_debug.put_line
2095: ( ' Pending Plan Usage:'
2096: || TO_CHAR (p_batch_step_resources_rec.plan_rsrc_usage)
2097: || ' Plan Count:'
2098: || TO_CHAR (p_batch_step_resources_rec.plan_rsrc_count) );
2110: l_alloc_usage :=
2111: p_batch_step_resources_rec.plan_rsrc_usage
2112: / p_batch_step_resources_rec.plan_rsrc_count;
2113:
2114: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2115: gme_debug.put_line (' Alloc Usage:' || TO_CHAR (l_alloc_usage) );
2116: END IF;
2117:
2118: l_batch_hdr.batch_id := p_batch_step_resources_rec.batch_id;
2111: p_batch_step_resources_rec.plan_rsrc_usage
2112: / p_batch_step_resources_rec.plan_rsrc_count;
2113:
2114: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2115: gme_debug.put_line (' Alloc Usage:' || TO_CHAR (l_alloc_usage) );
2116: END IF;
2117:
2118: l_batch_hdr.batch_id := p_batch_step_resources_rec.batch_id;
2119:
2139: EXCEPTION
2140: WHEN fnd_api.g_exc_error THEN
2141: x_return_status := fnd_api.g_ret_sts_error;
2142: WHEN OTHERS THEN
2143: IF g_debug <= gme_debug.g_log_unexpected THEN
2144: gme_debug.put_line ( 'When others exception in '
2145: || g_pkg_name
2146: || '.'
2147: || l_api_name
2140: WHEN fnd_api.g_exc_error THEN
2141: x_return_status := fnd_api.g_ret_sts_error;
2142: WHEN OTHERS THEN
2143: IF g_debug <= gme_debug.g_log_unexpected THEN
2144: gme_debug.put_line ( 'When others exception in '
2145: || g_pkg_name
2146: || '.'
2147: || l_api_name
2148: || ' Error is '
2231: l_sum_comp_usage_loop NUMBER;
2232: l_hold_trans_index NUMBER;
2233:
2234: BEGIN
2235: IF g_debug <= gme_debug.g_log_procedure THEN
2236: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2237: || l_api_name);
2238: END IF;
2239:
2232: l_hold_trans_index NUMBER;
2233:
2234: BEGIN
2235: IF g_debug <= gme_debug.g_log_procedure THEN
2236: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2237: || l_api_name);
2238: END IF;
2239:
2240: /* Initialize return status to success */
2239:
2240: /* Initialize return status to success */
2241: x_return_status := fnd_api.g_ret_sts_success;
2242:
2243: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2244: gme_debug.put_line ( ' Adjusting actual usage :'
2245: || p_batch_step_resources_rec.actual_rsrc_usage);
2246: END IF;
2247:
2240: /* Initialize return status to success */
2241: x_return_status := fnd_api.g_ret_sts_success;
2242:
2243: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2244: gme_debug.put_line ( ' Adjusting actual usage :'
2245: || p_batch_step_resources_rec.actual_rsrc_usage);
2246: END IF;
2247:
2248: /* Lets fetch all the active resource transactions for the current resource */
2285: END IF;
2286:
2287: CLOSE cur_sum_comp_usage;
2288:
2289: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2290: gme_debug.put_line
2291: ( ' Completed Usage:'
2292: || TO_CHAR (l_sum_comp_usage)
2293: || ' Actual Usage:'
2286:
2287: CLOSE cur_sum_comp_usage;
2288:
2289: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2290: gme_debug.put_line
2291: ( ' Completed Usage:'
2292: || TO_CHAR (l_sum_comp_usage)
2293: || ' Actual Usage:'
2294: || TO_CHAR (p_batch_step_resources_rec.actual_rsrc_usage)
2303: INTO l_cnt_comp_usage;
2304:
2305: CLOSE cur_count_comp_usage;
2306:
2307: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2308: gme_debug.put_line ( ' Completed Transaction Count:'
2309: || TO_CHAR (l_cnt_comp_usage) );
2310: END IF;
2311:
2304:
2305: CLOSE cur_count_comp_usage;
2306:
2307: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2308: gme_debug.put_line ( ' Completed Transaction Count:'
2309: || TO_CHAR (l_cnt_comp_usage) );
2310: END IF;
2311:
2312: /* Step 2 : */
2411: /* IF l_sum_comp_usage < p_batch_step_resources_rec.actual_rsrc_usage */
2412: END IF;
2413: /* IF l_sum_comp_usage <> p_batch_step_resources_rec.actual_rsrc_usage */
2414:
2415: IF g_debug <= gme_debug.g_log_procedure THEN
2416: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2417: END IF;
2418: EXCEPTION
2419: WHEN fnd_api.g_exc_error THEN
2412: END IF;
2413: /* IF l_sum_comp_usage <> p_batch_step_resources_rec.actual_rsrc_usage */
2414:
2415: IF g_debug <= gme_debug.g_log_procedure THEN
2416: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2417: END IF;
2418: EXCEPTION
2419: WHEN fnd_api.g_exc_error THEN
2420: x_return_status := fnd_api.g_ret_sts_error;
2418: EXCEPTION
2419: WHEN fnd_api.g_exc_error THEN
2420: x_return_status := fnd_api.g_ret_sts_error;
2421: WHEN OTHERS THEN
2422: IF g_debug <= gme_debug.g_log_unexpected THEN
2423: gme_debug.put_line ( 'When others exception in '
2424: || g_pkg_name
2425: || '.'
2426: || l_api_name
2419: WHEN fnd_api.g_exc_error THEN
2420: x_return_status := fnd_api.g_ret_sts_error;
2421: WHEN OTHERS THEN
2422: IF g_debug <= gme_debug.g_log_unexpected THEN
2423: gme_debug.put_line ( 'When others exception in '
2424: || g_pkg_name
2425: || '.'
2426: || l_api_name
2427: || ' Error is '
2497: -- 8564008 added the parameters for the call to gme_create_step_pvt.get_usage_in_hours.
2498: l_usage_hrs NUMBER;
2499: l_usage_conv_ret_status VARCHAR2(1000);
2500: BEGIN
2501: IF g_debug <= gme_debug.g_log_procedure THEN
2502: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2503: || l_api_name);
2504: END IF;
2505:
2498: l_usage_hrs NUMBER;
2499: l_usage_conv_ret_status VARCHAR2(1000);
2500: BEGIN
2501: IF g_debug <= gme_debug.g_log_procedure THEN
2502: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
2503: || l_api_name);
2504: END IF;
2505:
2506: /* Initialize return status to success */
2532: IF l_return_status <> x_return_status THEN
2533: RAISE fnd_api.g_exc_error;
2534: END IF;
2535:
2536: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2537: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Line ID '||l_resource_txns.line_id);
2538: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Resource Txns Count '||l_resource_tab.COUNT);
2539: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Step Status '||l_step_status);
2540: END IF;
2533: RAISE fnd_api.g_exc_error;
2534: END IF;
2535:
2536: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2537: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Line ID '||l_resource_txns.line_id);
2538: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Resource Txns Count '||l_resource_tab.COUNT);
2539: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Step Status '||l_step_status);
2540: END IF;
2541:
2534: END IF;
2535:
2536: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2537: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Line ID '||l_resource_txns.line_id);
2538: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Resource Txns Count '||l_resource_tab.COUNT);
2539: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Step Status '||l_step_status);
2540: END IF;
2541:
2542:
2535:
2536: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2537: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Line ID '||l_resource_txns.line_id);
2538: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Resource Txns Count '||l_resource_tab.COUNT);
2539: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Step Status '||l_step_status);
2540: END IF;
2541:
2542:
2543: /* If the step is in WIP then we need to adjust the pending transactions */
2566: NVL (p_batch_step_resources_rec.actual_rsrc_usage, 0)
2567: - p_batch_step_resources_rec.plan_rsrc_usage;
2568:
2569: -- Bug 8564008
2570: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2571: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_prev_usage > p_batch_step_resources_rec.plan_rsrc_usage l_alloc_usage :'||l_alloc_usage);
2572: END IF;
2573: ELSE
2574: l_alloc_usage :=
2567: - p_batch_step_resources_rec.plan_rsrc_usage;
2568:
2569: -- Bug 8564008
2570: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2571: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_prev_usage > p_batch_step_resources_rec.plan_rsrc_usage l_alloc_usage :'||l_alloc_usage);
2572: END IF;
2573: ELSE
2574: l_alloc_usage :=
2575: NVL (p_batch_step_resources_rec.actual_rsrc_usage, 0)
2575: NVL (p_batch_step_resources_rec.actual_rsrc_usage, 0)
2576: - NVL (l_prev_usage, 0);
2577:
2578: -- Bug 8564008
2579: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2580: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage :'||l_alloc_usage);
2581: END IF;
2582: END IF;
2583:
2576: - NVL (l_prev_usage, 0);
2577:
2578: -- Bug 8564008
2579: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2580: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage :'||l_alloc_usage);
2581: END IF;
2582: END IF;
2583:
2584: IF l_tran_count > 0 THEN
2585: l_alloc_usage := l_alloc_usage / l_tran_count;
2586: END IF;
2587:
2588: -- Bug 8564008
2589: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2590: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage :'||l_alloc_usage);
2591: END IF;
2592: END IF; /* IF l_step_status = 2 */
2593:
2586: END IF;
2587:
2588: -- Bug 8564008
2589: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2590: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage :'||l_alloc_usage);
2591: END IF;
2592: END IF; /* IF l_step_status = 2 */
2593:
2594: l_remaining_tran_count := l_tran_count;
2593:
2594: l_remaining_tran_count := l_tran_count;
2595: FOR i IN 1 .. l_resource_tab.COUNT LOOP
2596: -- Bug 8564008
2597: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2598: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Processing the resource transactions loop');
2599: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_tab (i).completed_ind :'||l_resource_tab (i).completed_ind);
2600: END IF;
2601:
2594: l_remaining_tran_count := l_tran_count;
2595: FOR i IN 1 .. l_resource_tab.COUNT LOOP
2596: -- Bug 8564008
2597: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2598: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Processing the resource transactions loop');
2599: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_tab (i).completed_ind :'||l_resource_tab (i).completed_ind);
2600: END IF;
2601:
2602: IF l_resource_tab (i).completed_ind = 0 THEN
2595: FOR i IN 1 .. l_resource_tab.COUNT LOOP
2596: -- Bug 8564008
2597: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2598: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Processing the resource transactions loop');
2599: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_tab (i).completed_ind :'||l_resource_tab (i).completed_ind);
2600: END IF;
2601:
2602: IF l_resource_tab (i).completed_ind = 0 THEN
2603: l_resource_txns := l_resource_tab (i);
2602: IF l_resource_tab (i).completed_ind = 0 THEN
2603: l_resource_txns := l_resource_tab (i);
2604:
2605: -- Bug 8564008
2606: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2607: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_step_status :'||l_step_status);
2608: END IF;
2609:
2610: IF l_step_status = gme_common_pvt.g_step_wip THEN
2603: l_resource_txns := l_resource_tab (i);
2604:
2605: -- Bug 8564008
2606: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2607: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_step_status :'||l_step_status);
2608: END IF;
2609:
2610: IF l_step_status = gme_common_pvt.g_step_wip THEN
2611: l_remaining_tran_count := l_remaining_tran_count - 1;
2611: l_remaining_tran_count := l_remaining_tran_count - 1;
2612: l_usage := l_resource_txns.resource_usage - l_alloc_usage;
2613:
2614: -- Bug 8564008
2615: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2616: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_remaining_tran_count :'||l_remaining_tran_count);
2617: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :'|| l_resource_txns.resource_usage);
2618: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage:'|| l_alloc_usage);
2619: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage :'|| l_usage);
2612: l_usage := l_resource_txns.resource_usage - l_alloc_usage;
2613:
2614: -- Bug 8564008
2615: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2616: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_remaining_tran_count :'||l_remaining_tran_count);
2617: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :'|| l_resource_txns.resource_usage);
2618: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage:'|| l_alloc_usage);
2619: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage :'|| l_usage);
2620: END IF;
2613:
2614: -- Bug 8564008
2615: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2616: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_remaining_tran_count :'||l_remaining_tran_count);
2617: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :'|| l_resource_txns.resource_usage);
2618: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage:'|| l_alloc_usage);
2619: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage :'|| l_usage);
2620: END IF;
2621:
2614: -- Bug 8564008
2615: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2616: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_remaining_tran_count :'||l_remaining_tran_count);
2617: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :'|| l_resource_txns.resource_usage);
2618: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage:'|| l_alloc_usage);
2619: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage :'|| l_usage);
2620: END IF;
2621:
2622: -- nsinghi bug#5609683
2615: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2616: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_remaining_tran_count :'||l_remaining_tran_count);
2617: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :'|| l_resource_txns.resource_usage);
2618: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_alloc_usage:'|| l_alloc_usage);
2619: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage :'|| l_usage);
2620: END IF;
2621:
2622: -- nsinghi bug#5609683
2623: /* Restructured the usage and strt date calculation based on following code Logic --
2655: ELSIF l_usage > 0 THEN
2656: l_resource_txns.resource_usage := l_usage;
2657:
2658: -- Bug 8564008
2659: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2660: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage > 0 processing ');
2661: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :' || l_resource_txns.resource_usage);
2662: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.end_date :'|| to_char(l_resource_txns.end_date, 'DD-MON-RRRR HH24:MI:SS'));
2663: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modifying the usage using the hours conversion');
2656: l_resource_txns.resource_usage := l_usage;
2657:
2658: -- Bug 8564008
2659: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2660: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage > 0 processing ');
2661: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :' || l_resource_txns.resource_usage);
2662: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.end_date :'|| to_char(l_resource_txns.end_date, 'DD-MON-RRRR HH24:MI:SS'));
2663: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modifying the usage using the hours conversion');
2664: END IF;
2657:
2658: -- Bug 8564008
2659: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2660: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage > 0 processing ');
2661: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :' || l_resource_txns.resource_usage);
2662: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.end_date :'|| to_char(l_resource_txns.end_date, 'DD-MON-RRRR HH24:MI:SS'));
2663: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modifying the usage using the hours conversion');
2664: END IF;
2665:
2658: -- Bug 8564008
2659: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2660: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage > 0 processing ');
2661: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :' || l_resource_txns.resource_usage);
2662: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.end_date :'|| to_char(l_resource_txns.end_date, 'DD-MON-RRRR HH24:MI:SS'));
2663: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modifying the usage using the hours conversion');
2664: END IF;
2665:
2666: -- Bug 8564008
2659: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2660: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_usage > 0 processing ');
2661: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.resource_usage :' || l_resource_txns.resource_usage);
2662: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': l_resource_txns.end_date :'|| to_char(l_resource_txns.end_date, 'DD-MON-RRRR HH24:MI:SS'));
2663: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modifying the usage using the hours conversion');
2664: END IF;
2665:
2666: -- Bug 8564008
2667: -- added the call to gme_create_step_pvt.get_usage_in_hours
2675: x_usage_hrs => l_usage_hrs,
2676: x_return_status => l_usage_conv_ret_status
2677: );
2678:
2679: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2680: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modified resource usage is :'||l_usage_hrs);
2681: END IF;
2682:
2683: -- 8564008
2676: x_return_status => l_usage_conv_ret_status
2677: );
2678:
2679: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2680: gme_debug.put_line(g_pkg_name||'.'||l_api_name||': Modified resource usage is :'||l_usage_hrs);
2681: END IF;
2682:
2683: -- 8564008
2684: -- Use new converted variable for date computation.
2718: END IF; /* IF l_step_status = 2 */
2719: END IF; /* IF l_resource_tab(i).completed_ind = 0 */
2720: END LOOP; /* FOR i IN 1..l_resource_tab.COUNT */
2721:
2722: IF g_debug <= gme_debug.g_log_procedure THEN
2723: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2724: END IF;
2725: EXCEPTION
2726: WHEN fnd_api.g_exc_error THEN
2719: END IF; /* IF l_resource_tab(i).completed_ind = 0 */
2720: END LOOP; /* FOR i IN 1..l_resource_tab.COUNT */
2721:
2722: IF g_debug <= gme_debug.g_log_procedure THEN
2723: gme_debug.put_line ('Exiting api ' || g_pkg_name || '.' || l_api_name);
2724: END IF;
2725: EXCEPTION
2726: WHEN fnd_api.g_exc_error THEN
2727: x_return_status := l_return_status;
2725: EXCEPTION
2726: WHEN fnd_api.g_exc_error THEN
2727: x_return_status := l_return_status;
2728: WHEN OTHERS THEN
2729: IF g_debug <= gme_debug.g_log_unexpected THEN
2730: gme_debug.put_line ( 'When others exception in '
2731: || g_pkg_name
2732: || '.'
2733: || l_api_name
2726: WHEN fnd_api.g_exc_error THEN
2727: x_return_status := l_return_status;
2728: WHEN OTHERS THEN
2729: IF g_debug <= gme_debug.g_log_unexpected THEN
2730: gme_debug.put_line ( 'When others exception in '
2731: || g_pkg_name
2732: || '.'
2733: || l_api_name
2734: || ' Error is '
2799: error_in_update_step EXCEPTION;
2800: invalid_value EXCEPTION;
2801: error_in_clear_charges EXCEPTION;
2802: BEGIN
2803: IF g_debug <= gme_debug.g_log_procedure THEN
2804: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'|| l_api_name);
2805: END IF;
2806:
2807: x_return_status := fnd_api.g_ret_sts_success;
2800: invalid_value EXCEPTION;
2801: error_in_clear_charges EXCEPTION;
2802: BEGIN
2803: IF g_debug <= gme_debug.g_log_procedure THEN
2804: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'|| l_api_name);
2805: END IF;
2806:
2807: x_return_status := fnd_api.g_ret_sts_success;
2808: x_batchstep_rec := p_batchstep_rec;
2813: END IF;
2814:
2815: /* validate the calculation type */
2816: IF p_cal_type NOT IN ('R','P') THEN
2817: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2818: gme_debug.put_line('Invalid value for p_cal_type');
2819: END IF;
2820: RAISE invalid_value;
2821: END IF;
2814:
2815: /* validate the calculation type */
2816: IF p_cal_type NOT IN ('R','P') THEN
2817: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2818: gme_debug.put_line('Invalid value for p_cal_type');
2819: END IF;
2820: RAISE invalid_value;
2821: END IF;
2822:
2833: END IF;
2834:
2835: l_max_capacity := l_step_rec.max_step_capacity;
2836:
2837: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2838: gme_debug.put_line('DB Step Qty: '||l_step_qty);
2839: gme_debug.put_line('Step Qty: '||l_in_step_qty);
2840: gme_debug.put_line('Max Capacity of the Step: '||l_max_capacity);
2841: END IF;
2834:
2835: l_max_capacity := l_step_rec.max_step_capacity;
2836:
2837: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2838: gme_debug.put_line('DB Step Qty: '||l_step_qty);
2839: gme_debug.put_line('Step Qty: '||l_in_step_qty);
2840: gme_debug.put_line('Max Capacity of the Step: '||l_max_capacity);
2841: END IF;
2842:
2835: l_max_capacity := l_step_rec.max_step_capacity;
2836:
2837: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2838: gme_debug.put_line('DB Step Qty: '||l_step_qty);
2839: gme_debug.put_line('Step Qty: '||l_in_step_qty);
2840: gme_debug.put_line('Max Capacity of the Step: '||l_max_capacity);
2841: END IF;
2842:
2843: IF p_cal_type = 'P' THEN
2836:
2837: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2838: gme_debug.put_line('DB Step Qty: '||l_step_qty);
2839: gme_debug.put_line('Step Qty: '||l_in_step_qty);
2840: gme_debug.put_line('Max Capacity of the Step: '||l_max_capacity);
2841: END IF;
2842:
2843: IF p_cal_type = 'P' THEN
2844: /* if the cal type P that means step update is triggering recalculate charges*/
2853: END IF;
2854:
2855: IF l_calc_step_qty THEN
2856:
2857: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2858: gme_debug.put_line('Calculating the Charges');
2859: END IF;
2860:
2861: /*if we come here then there is change in the step qty and we have to recalculate charges
2854:
2855: IF l_calc_step_qty THEN
2856:
2857: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2858: gme_debug.put_line('Calculating the Charges');
2859: END IF;
2860:
2861: /*if we come here then there is change in the step qty and we have to recalculate charges
2862: max step capacity uom and all */
2877: ,x_resource => l_resource
2878: ,x_return_status => l_return_status);
2879:
2880: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2881: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2882: gme_debug.put_line('Error in calculating the max capacity');
2883: END IF;
2884: RAISE error_in_calc_capacity;
2885: END IF;
2878: ,x_return_status => l_return_status);
2879:
2880: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2881: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2882: gme_debug.put_line('Error in calculating the max capacity');
2883: END IF;
2884: RAISE error_in_calc_capacity;
2885: END IF;
2886:
2883: END IF;
2884: RAISE error_in_calc_capacity;
2885: END IF;
2886:
2887: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2888: gme_debug.put_line('Calculated Max Step Qty: '||x_batchstep_rec.max_step_capacity);
2889: gme_debug.put_line('Capacity Resource : '||l_resource);
2890: END IF;
2891:
2884: RAISE error_in_calc_capacity;
2885: END IF;
2886:
2887: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2888: gme_debug.put_line('Calculated Max Step Qty: '||x_batchstep_rec.max_step_capacity);
2889: gme_debug.put_line('Capacity Resource : '||l_resource);
2890: END IF;
2891:
2892: /*clear the charges */
2885: END IF;
2886:
2887: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2888: gme_debug.put_line('Calculated Max Step Qty: '||x_batchstep_rec.max_step_capacity);
2889: gme_debug.put_line('Capacity Resource : '||l_resource);
2890: END IF;
2891:
2892: /*clear the charges */
2893: /*DELETE FROM gme_batch_step_charges
2913: l_mass_qty := x_batchstep_rec.plan_mass_qty;
2914: l_vol_qty := x_batchstep_rec.plan_volume_qty;
2915: END IF;
2916:
2917: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2918: gme_debug.put_line('Mass Qty: '||l_mass_qty||' Volume Qty: '||l_vol_qty);
2919: END IF;
2920:
2921: /* we have the max capacity and resource here */
2914: l_vol_qty := x_batchstep_rec.plan_volume_qty;
2915: END IF;
2916:
2917: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2918: gme_debug.put_line('Mass Qty: '||l_mass_qty||' Volume Qty: '||l_vol_qty);
2919: END IF;
2920:
2921: /* we have the max capacity and resource here */
2922: gme_update_step_qty_pvt.calc_charge (
2929: ,x_charge => l_charge
2930: ,x_return_status => l_return_status);
2931:
2932: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2933: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2934: gme_debug.put_line('error in calc_charge');
2935: END IF;
2936: RAISE error_calc_charge;
2937: END IF;
2930: ,x_return_status => l_return_status);
2931:
2932: IF l_return_status <> fnd_api.g_ret_sts_success THEN
2933: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2934: gme_debug.put_line('error in calc_charge');
2935: END IF;
2936: RAISE error_calc_charge;
2937: END IF;
2938:
2946: IF NOT gme_batch_steps_dbl.update_row(p_batch_step => x_batchstep_rec) THEN
2947: RAISE error_in_update_step;
2948: END IF;
2949:
2950: IF g_debug <= gme_debug.g_log_procedure THEN
2951: gme_debug.put_line ('Existing api ' || g_pkg_name || '.'|| l_api_name);
2952: END IF;
2953: EXCEPTION
2954: WHEN error_batchstep_id OR error_in_calc_capacity OR error_in_clear_charges THEN
2947: RAISE error_in_update_step;
2948: END IF;
2949:
2950: IF g_debug <= gme_debug.g_log_procedure THEN
2951: gme_debug.put_line ('Existing api ' || g_pkg_name || '.'|| l_api_name);
2952: END IF;
2953: EXCEPTION
2954: WHEN error_batchstep_id OR error_in_calc_capacity OR error_in_clear_charges THEN
2955: x_return_status := fnd_api.g_ret_sts_error;
2953: EXCEPTION
2954: WHEN error_batchstep_id OR error_in_calc_capacity OR error_in_clear_charges THEN
2955: x_return_status := fnd_api.g_ret_sts_error;
2956: WHEN OTHERS THEN
2957: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2958: gme_debug.put_line(g_pkg_name || '.'|| l_api_name --> when others '
2959: || SQLERRM);
2960: END IF;
2961: x_return_status := fnd_api.g_ret_sts_unexp_error;
2954: WHEN error_batchstep_id OR error_in_calc_capacity OR error_in_clear_charges THEN
2955: x_return_status := fnd_api.g_ret_sts_error;
2956: WHEN OTHERS THEN
2957: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2958: gme_debug.put_line(g_pkg_name || '.'|| l_api_name --> when others '
2959: || SQLERRM);
2960: END IF;
2961: x_return_status := fnd_api.g_ret_sts_unexp_error;
2962: END recalculate_charges;