26: ();
27: l_gme_batch_step_activities gme_create_step_pvt.gme_batch_step_activities_tab
28: := gme_create_step_pvt.gme_batch_step_activities_tab
29: ();
30: l_gme_batch_step_resources gme_create_step_pvt.gme_batch_step_resources_tab
31: := gme_create_step_pvt.gme_batch_step_resources_tab
32: ();
33: l_gme_rsrc_parameters gme_create_step_pvt.gme_process_parameters_tab
34: := gme_create_step_pvt.gme_process_parameters_tab
27: l_gme_batch_step_activities gme_create_step_pvt.gme_batch_step_activities_tab
28: := gme_create_step_pvt.gme_batch_step_activities_tab
29: ();
30: l_gme_batch_step_resources gme_create_step_pvt.gme_batch_step_resources_tab
31: := gme_create_step_pvt.gme_batch_step_resources_tab
32: ();
33: l_gme_rsrc_parameters gme_create_step_pvt.gme_process_parameters_tab
34: := gme_create_step_pvt.gme_process_parameters_tab
35: ();
57: l_charge gme_batch_steps.plan_charges%TYPE;
58: l_uom_class mtl_units_of_measure.uom_class%TYPE;
59: l_batchstep_activity_id gme_batch_step_activities.batchstep_activity_id%TYPE;
60: l_activity_factor gme_batch_step_activities.plan_activity_factor%TYPE;
61: l_resources gme_batch_step_resources.resources%TYPE;
62: l_batchstep_ids_tab l_batchstep_ids;
63: l_total_scale_by_charge PLS_INTEGER;
64: l_count_scale_by_charge PLS_INTEGER;
65: l_return_status VARCHAR2 (1);
125:
126: CURSOR cur_get_resources (v_batchstep_activity_id NUMBER)
127: IS
128: SELECT batchstep_resource_id, plan_rsrc_usage, plan_rsrc_count
129: FROM gme_batch_step_resources
130: WHERE batchstep_activity_id = v_batchstep_activity_id;
131:
132: CURSOR cur_recipe_id (v_recipe_validity_rule_id NUMBER)
133: IS
159: AND batchstep_id = v_batchstep_id
160: AND ROWNUM = 1;
161:
162: CURSOR cur_get_resource_dates (
163: v_resources gme_batch_step_resources.resources%TYPE
164: ,v_batch_id NUMBER
165: ,v_batchstep_id NUMBER)
166: IS
167: SELECT plan_start_date, plan_cmplt_date
164: ,v_batch_id NUMBER
165: ,v_batchstep_id NUMBER)
166: IS
167: SELECT plan_start_date, plan_cmplt_date
168: FROM gme_batch_step_resources
169: WHERE resources = v_resources
170: AND batch_id = v_batch_id
171: AND batchstep_id = v_batchstep_id;
172:
467: END LOOP; /* WHILE i IS NOT NULL; STEP ACTIVITIES */
468:
469: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
470: gme_debug.put_line ('Completed GME_BATCH_STEP_ACTIVITIES');
471: -- Create data for GME_BATCH_STEP_RESOURCES and GME_RESOURCE_TXNS...
472: gme_debug.put_line ('GME_BATCH_STEP_RESOURCES');
473: END IF;
474:
475: i := p_recipe_rout_resc_tbl.FIRST;
468:
469: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
470: gme_debug.put_line ('Completed GME_BATCH_STEP_ACTIVITIES');
471: -- Create data for GME_BATCH_STEP_RESOURCES and GME_RESOURCE_TXNS...
472: gme_debug.put_line ('GME_BATCH_STEP_RESOURCES');
473: END IF;
474:
475: i := p_recipe_rout_resc_tbl.FIRST;
476: j := 0;
475: i := p_recipe_rout_resc_tbl.FIRST;
476: j := 0;
477:
478: WHILE i IS NOT NULL LOOP
479: l_gme_batch_step_resources.EXTEND;
480:
481: IF (j = 0) THEN
482: j := l_gme_batch_step_resources.FIRST;
483: ELSE
478: WHILE i IS NOT NULL LOOP
479: l_gme_batch_step_resources.EXTEND;
480:
481: IF (j = 0) THEN
482: j := l_gme_batch_step_resources.FIRST;
483: ELSE
484: j := l_gme_batch_step_resources.NEXT (j);
485: END IF;
486:
480:
481: IF (j = 0) THEN
482: j := l_gme_batch_step_resources.FIRST;
483: ELSE
484: j := l_gme_batch_step_resources.NEXT (j);
485: END IF;
486:
487: l_gme_batch_step_resources (j).batch_id := l_batch_id;
488: l_gme_batch_step_resources (j).organization_id :=
483: ELSE
484: j := l_gme_batch_step_resources.NEXT (j);
485: END IF;
486:
487: l_gme_batch_step_resources (j).batch_id := l_batch_id;
488: l_gme_batch_step_resources (j).organization_id :=
489: p_gme_batch_header_rec.organization_id;
490: l_gme_batch_step_resources (j).resources :=
491: p_recipe_rout_resc_tbl (i).resources;
484: j := l_gme_batch_step_resources.NEXT (j);
485: END IF;
486:
487: l_gme_batch_step_resources (j).batch_id := l_batch_id;
488: l_gme_batch_step_resources (j).organization_id :=
489: p_gme_batch_header_rec.organization_id;
490: l_gme_batch_step_resources (j).resources :=
491: p_recipe_rout_resc_tbl (i).resources;
492: l_gme_batch_step_resources (j).cost_analysis_code :=
486:
487: l_gme_batch_step_resources (j).batch_id := l_batch_id;
488: l_gme_batch_step_resources (j).organization_id :=
489: p_gme_batch_header_rec.organization_id;
490: l_gme_batch_step_resources (j).resources :=
491: p_recipe_rout_resc_tbl (i).resources;
492: l_gme_batch_step_resources (j).cost_analysis_code :=
493: p_recipe_rout_resc_tbl (i).cost_analysis_code;
494: l_gme_batch_step_resources (j).cost_cmpntcls_id :=
488: l_gme_batch_step_resources (j).organization_id :=
489: p_gme_batch_header_rec.organization_id;
490: l_gme_batch_step_resources (j).resources :=
491: p_recipe_rout_resc_tbl (i).resources;
492: l_gme_batch_step_resources (j).cost_analysis_code :=
493: p_recipe_rout_resc_tbl (i).cost_analysis_code;
494: l_gme_batch_step_resources (j).cost_cmpntcls_id :=
495: p_recipe_rout_resc_tbl (i).cost_cmpntcls_id;
496: l_gme_batch_step_resources (j).prim_rsrc_ind :=
490: l_gme_batch_step_resources (j).resources :=
491: p_recipe_rout_resc_tbl (i).resources;
492: l_gme_batch_step_resources (j).cost_analysis_code :=
493: p_recipe_rout_resc_tbl (i).cost_analysis_code;
494: l_gme_batch_step_resources (j).cost_cmpntcls_id :=
495: p_recipe_rout_resc_tbl (i).cost_cmpntcls_id;
496: l_gme_batch_step_resources (j).prim_rsrc_ind :=
497: p_recipe_rout_resc_tbl (i).prim_rsrc_ind;
498: l_gme_batch_step_resources (j).scale_type :=
492: l_gme_batch_step_resources (j).cost_analysis_code :=
493: p_recipe_rout_resc_tbl (i).cost_analysis_code;
494: l_gme_batch_step_resources (j).cost_cmpntcls_id :=
495: p_recipe_rout_resc_tbl (i).cost_cmpntcls_id;
496: l_gme_batch_step_resources (j).prim_rsrc_ind :=
497: p_recipe_rout_resc_tbl (i).prim_rsrc_ind;
498: l_gme_batch_step_resources (j).scale_type :=
499: p_recipe_rout_resc_tbl (i).scale_type;
500: l_gme_batch_step_resources (j).plan_rsrc_count :=
494: l_gme_batch_step_resources (j).cost_cmpntcls_id :=
495: p_recipe_rout_resc_tbl (i).cost_cmpntcls_id;
496: l_gme_batch_step_resources (j).prim_rsrc_ind :=
497: p_recipe_rout_resc_tbl (i).prim_rsrc_ind;
498: l_gme_batch_step_resources (j).scale_type :=
499: p_recipe_rout_resc_tbl (i).scale_type;
500: l_gme_batch_step_resources (j).plan_rsrc_count :=
501: p_recipe_rout_resc_tbl (i).resource_count;
502: l_gme_batch_step_resources (j).plan_rsrc_qty :=
496: l_gme_batch_step_resources (j).prim_rsrc_ind :=
497: p_recipe_rout_resc_tbl (i).prim_rsrc_ind;
498: l_gme_batch_step_resources (j).scale_type :=
499: p_recipe_rout_resc_tbl (i).scale_type;
500: l_gme_batch_step_resources (j).plan_rsrc_count :=
501: p_recipe_rout_resc_tbl (i).resource_count;
502: l_gme_batch_step_resources (j).plan_rsrc_qty :=
503: p_recipe_rout_resc_tbl (i).process_qty;
504: l_gme_batch_step_resources (j).original_rsrc_qty :=
498: l_gme_batch_step_resources (j).scale_type :=
499: p_recipe_rout_resc_tbl (i).scale_type;
500: l_gme_batch_step_resources (j).plan_rsrc_count :=
501: p_recipe_rout_resc_tbl (i).resource_count;
502: l_gme_batch_step_resources (j).plan_rsrc_qty :=
503: p_recipe_rout_resc_tbl (i).process_qty;
504: l_gme_batch_step_resources (j).original_rsrc_qty :=
505: p_recipe_rout_resc_tbl (i).process_qty;
506: l_gme_batch_step_resources (j).resource_qty_um :=
500: l_gme_batch_step_resources (j).plan_rsrc_count :=
501: p_recipe_rout_resc_tbl (i).resource_count;
502: l_gme_batch_step_resources (j).plan_rsrc_qty :=
503: p_recipe_rout_resc_tbl (i).process_qty;
504: l_gme_batch_step_resources (j).original_rsrc_qty :=
505: p_recipe_rout_resc_tbl (i).process_qty;
506: l_gme_batch_step_resources (j).resource_qty_um :=
507: p_recipe_rout_resc_tbl (i).process_uom;
508: l_gme_batch_step_resources (j).plan_rsrc_usage :=
502: l_gme_batch_step_resources (j).plan_rsrc_qty :=
503: p_recipe_rout_resc_tbl (i).process_qty;
504: l_gme_batch_step_resources (j).original_rsrc_qty :=
505: p_recipe_rout_resc_tbl (i).process_qty;
506: l_gme_batch_step_resources (j).resource_qty_um :=
507: p_recipe_rout_resc_tbl (i).process_uom;
508: l_gme_batch_step_resources (j).plan_rsrc_usage :=
509: p_recipe_rout_resc_tbl (i).resource_usage
510: * p_recipe_rout_resc_tbl (i).resource_count;
504: l_gme_batch_step_resources (j).original_rsrc_qty :=
505: p_recipe_rout_resc_tbl (i).process_qty;
506: l_gme_batch_step_resources (j).resource_qty_um :=
507: p_recipe_rout_resc_tbl (i).process_uom;
508: l_gme_batch_step_resources (j).plan_rsrc_usage :=
509: p_recipe_rout_resc_tbl (i).resource_usage
510: * p_recipe_rout_resc_tbl (i).resource_count;
511: l_gme_batch_step_resources (j).original_rsrc_usage :=
512: p_recipe_rout_resc_tbl (i).resource_usage
507: p_recipe_rout_resc_tbl (i).process_uom;
508: l_gme_batch_step_resources (j).plan_rsrc_usage :=
509: p_recipe_rout_resc_tbl (i).resource_usage
510: * p_recipe_rout_resc_tbl (i).resource_count;
511: l_gme_batch_step_resources (j).original_rsrc_usage :=
512: p_recipe_rout_resc_tbl (i).resource_usage
513: * p_recipe_rout_resc_tbl (i).resource_count;
514: l_gme_batch_step_resources (j).usage_um :=
515: p_recipe_rout_resc_tbl (i).usage_um;
510: * p_recipe_rout_resc_tbl (i).resource_count;
511: l_gme_batch_step_resources (j).original_rsrc_usage :=
512: p_recipe_rout_resc_tbl (i).resource_usage
513: * p_recipe_rout_resc_tbl (i).resource_count;
514: l_gme_batch_step_resources (j).usage_um :=
515: p_recipe_rout_resc_tbl (i).usage_um;
516: l_gme_batch_step_resources (j).offset_interval :=
517: p_recipe_rout_resc_tbl (i).offset_interval;
518: l_gme_batch_step_resources (j).capacity_um :=
512: p_recipe_rout_resc_tbl (i).resource_usage
513: * p_recipe_rout_resc_tbl (i).resource_count;
514: l_gme_batch_step_resources (j).usage_um :=
515: p_recipe_rout_resc_tbl (i).usage_um;
516: l_gme_batch_step_resources (j).offset_interval :=
517: p_recipe_rout_resc_tbl (i).offset_interval;
518: l_gme_batch_step_resources (j).capacity_um :=
519: p_recipe_rout_resc_tbl (i).capacity_uom;
520: l_gme_batch_step_resources (j).min_capacity :=
514: l_gme_batch_step_resources (j).usage_um :=
515: p_recipe_rout_resc_tbl (i).usage_um;
516: l_gme_batch_step_resources (j).offset_interval :=
517: p_recipe_rout_resc_tbl (i).offset_interval;
518: l_gme_batch_step_resources (j).capacity_um :=
519: p_recipe_rout_resc_tbl (i).capacity_uom;
520: l_gme_batch_step_resources (j).min_capacity :=
521: p_recipe_rout_resc_tbl (i).min_capacity;
522: l_gme_batch_step_resources (j).max_capacity :=
516: l_gme_batch_step_resources (j).offset_interval :=
517: p_recipe_rout_resc_tbl (i).offset_interval;
518: l_gme_batch_step_resources (j).capacity_um :=
519: p_recipe_rout_resc_tbl (i).capacity_uom;
520: l_gme_batch_step_resources (j).min_capacity :=
521: p_recipe_rout_resc_tbl (i).min_capacity;
522: l_gme_batch_step_resources (j).max_capacity :=
523: p_recipe_rout_resc_tbl (i).max_capacity;
524: l_gme_batch_step_resources (j).capacity_tolerance :=
518: l_gme_batch_step_resources (j).capacity_um :=
519: p_recipe_rout_resc_tbl (i).capacity_uom;
520: l_gme_batch_step_resources (j).min_capacity :=
521: p_recipe_rout_resc_tbl (i).min_capacity;
522: l_gme_batch_step_resources (j).max_capacity :=
523: p_recipe_rout_resc_tbl (i).max_capacity;
524: l_gme_batch_step_resources (j).capacity_tolerance :=
525: p_recipe_rout_resc_tbl (i).capacity_tolerance;
526: l_gme_batch_step_resources (j).calculate_charges :=
520: l_gme_batch_step_resources (j).min_capacity :=
521: p_recipe_rout_resc_tbl (i).min_capacity;
522: l_gme_batch_step_resources (j).max_capacity :=
523: p_recipe_rout_resc_tbl (i).max_capacity;
524: l_gme_batch_step_resources (j).capacity_tolerance :=
525: p_recipe_rout_resc_tbl (i).capacity_tolerance;
526: l_gme_batch_step_resources (j).calculate_charges :=
527: p_recipe_rout_resc_tbl (i).capacity_constraint;
528: l_gme_batch_step_resources (j).process_parameter_1 :=
522: l_gme_batch_step_resources (j).max_capacity :=
523: p_recipe_rout_resc_tbl (i).max_capacity;
524: l_gme_batch_step_resources (j).capacity_tolerance :=
525: p_recipe_rout_resc_tbl (i).capacity_tolerance;
526: l_gme_batch_step_resources (j).calculate_charges :=
527: p_recipe_rout_resc_tbl (i).capacity_constraint;
528: l_gme_batch_step_resources (j).process_parameter_1 :=
529: p_recipe_rout_resc_tbl (i).process_parameter_1;
530: l_gme_batch_step_resources (j).process_parameter_2 :=
524: l_gme_batch_step_resources (j).capacity_tolerance :=
525: p_recipe_rout_resc_tbl (i).capacity_tolerance;
526: l_gme_batch_step_resources (j).calculate_charges :=
527: p_recipe_rout_resc_tbl (i).capacity_constraint;
528: l_gme_batch_step_resources (j).process_parameter_1 :=
529: p_recipe_rout_resc_tbl (i).process_parameter_1;
530: l_gme_batch_step_resources (j).process_parameter_2 :=
531: p_recipe_rout_resc_tbl (i).process_parameter_2;
532: l_gme_batch_step_resources (j).process_parameter_3 :=
526: l_gme_batch_step_resources (j).calculate_charges :=
527: p_recipe_rout_resc_tbl (i).capacity_constraint;
528: l_gme_batch_step_resources (j).process_parameter_1 :=
529: p_recipe_rout_resc_tbl (i).process_parameter_1;
530: l_gme_batch_step_resources (j).process_parameter_2 :=
531: p_recipe_rout_resc_tbl (i).process_parameter_2;
532: l_gme_batch_step_resources (j).process_parameter_3 :=
533: p_recipe_rout_resc_tbl (i).process_parameter_3;
534: l_gme_batch_step_resources (j).process_parameter_4 :=
528: l_gme_batch_step_resources (j).process_parameter_1 :=
529: p_recipe_rout_resc_tbl (i).process_parameter_1;
530: l_gme_batch_step_resources (j).process_parameter_2 :=
531: p_recipe_rout_resc_tbl (i).process_parameter_2;
532: l_gme_batch_step_resources (j).process_parameter_3 :=
533: p_recipe_rout_resc_tbl (i).process_parameter_3;
534: l_gme_batch_step_resources (j).process_parameter_4 :=
535: p_recipe_rout_resc_tbl (i).process_parameter_4;
536: l_gme_batch_step_resources (j).process_parameter_5 :=
530: l_gme_batch_step_resources (j).process_parameter_2 :=
531: p_recipe_rout_resc_tbl (i).process_parameter_2;
532: l_gme_batch_step_resources (j).process_parameter_3 :=
533: p_recipe_rout_resc_tbl (i).process_parameter_3;
534: l_gme_batch_step_resources (j).process_parameter_4 :=
535: p_recipe_rout_resc_tbl (i).process_parameter_4;
536: l_gme_batch_step_resources (j).process_parameter_5 :=
537: p_recipe_rout_resc_tbl (i).process_parameter_5;
538:
532: l_gme_batch_step_resources (j).process_parameter_3 :=
533: p_recipe_rout_resc_tbl (i).process_parameter_3;
534: l_gme_batch_step_resources (j).process_parameter_4 :=
535: p_recipe_rout_resc_tbl (i).process_parameter_4;
536: l_gme_batch_step_resources (j).process_parameter_5 :=
537: p_recipe_rout_resc_tbl (i).process_parameter_5;
538:
539: IF l_gme_batch_step_resources (j).scale_type <> 0 THEN
540: IF l_gme_batch_step_resources (j).plan_rsrc_qty = 0
535: p_recipe_rout_resc_tbl (i).process_parameter_4;
536: l_gme_batch_step_resources (j).process_parameter_5 :=
537: p_recipe_rout_resc_tbl (i).process_parameter_5;
538:
539: IF l_gme_batch_step_resources (j).scale_type <> 0 THEN
540: IF l_gme_batch_step_resources (j).plan_rsrc_qty = 0
541: AND l_gme_batch_step_resources (j).plan_rsrc_usage <> 0 THEN
542: gme_common_pvt.log_message
543: ('gme_rsrc_qty_usage_oprn'
536: l_gme_batch_step_resources (j).process_parameter_5 :=
537: p_recipe_rout_resc_tbl (i).process_parameter_5;
538:
539: IF l_gme_batch_step_resources (j).scale_type <> 0 THEN
540: IF l_gme_batch_step_resources (j).plan_rsrc_qty = 0
541: AND l_gme_batch_step_resources (j).plan_rsrc_usage <> 0 THEN
542: gme_common_pvt.log_message
543: ('gme_rsrc_qty_usage_oprn'
544: ,'RESOURCE'
537: p_recipe_rout_resc_tbl (i).process_parameter_5;
538:
539: IF l_gme_batch_step_resources (j).scale_type <> 0 THEN
540: IF l_gme_batch_step_resources (j).plan_rsrc_qty = 0
541: AND l_gme_batch_step_resources (j).plan_rsrc_usage <> 0 THEN
542: gme_common_pvt.log_message
543: ('gme_rsrc_qty_usage_oprn'
544: ,'RESOURCE'
545: ,p_recipe_rout_resc_tbl (i).resources
554: END IF;
555:
556: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
557: gme_debug.put_line ( ' plan_rsrc_qty '
558: || l_gme_batch_step_resources (j).plan_rsrc_qty);
559: END IF;
560:
561: -- Link this resource to the batch step it belongs to...
562: IF (p_recipe_rout_resc_tbl (i).routingstep_id IS NOT NULL) THEN
562: IF (p_recipe_rout_resc_tbl (i).routingstep_id IS NOT NULL) THEN
563: SELECT batchstep_id
564: ,plan_start_date
565: ,plan_cmplt_date
566: INTO l_gme_batch_step_resources (j).batchstep_id
567: ,l_gme_batch_step_resources (j).plan_start_date
568: ,l_gme_batch_step_resources (j).plan_cmplt_date
569: FROM gme_batch_steps
570: WHERE batch_id = l_batch_id
563: SELECT batchstep_id
564: ,plan_start_date
565: ,plan_cmplt_date
566: INTO l_gme_batch_step_resources (j).batchstep_id
567: ,l_gme_batch_step_resources (j).plan_start_date
568: ,l_gme_batch_step_resources (j).plan_cmplt_date
569: FROM gme_batch_steps
570: WHERE batch_id = l_batch_id
571: AND routingstep_id = p_recipe_rout_resc_tbl (i).routingstep_id;
564: ,plan_start_date
565: ,plan_cmplt_date
566: INTO l_gme_batch_step_resources (j).batchstep_id
567: ,l_gme_batch_step_resources (j).plan_start_date
568: ,l_gme_batch_step_resources (j).plan_cmplt_date
569: FROM gme_batch_steps
570: WHERE batch_id = l_batch_id
571: AND routingstep_id = p_recipe_rout_resc_tbl (i).routingstep_id;
572: ELSE
572: ELSE
573: SELECT batchstep_id
574: ,plan_start_date
575: ,plan_cmplt_date
576: INTO l_gme_batch_step_resources (j).batchstep_id
577: ,l_gme_batch_step_resources (j).plan_start_date
578: ,l_gme_batch_step_resources (j).plan_cmplt_date
579: FROM gme_batch_steps
580: WHERE batch_id = l_batch_id
573: SELECT batchstep_id
574: ,plan_start_date
575: ,plan_cmplt_date
576: INTO l_gme_batch_step_resources (j).batchstep_id
577: ,l_gme_batch_step_resources (j).plan_start_date
578: ,l_gme_batch_step_resources (j).plan_cmplt_date
579: FROM gme_batch_steps
580: WHERE batch_id = l_batch_id
581: AND batchstep_id = l_last_batchstep_id;
574: ,plan_start_date
575: ,plan_cmplt_date
576: INTO l_gme_batch_step_resources (j).batchstep_id
577: ,l_gme_batch_step_resources (j).plan_start_date
578: ,l_gme_batch_step_resources (j).plan_cmplt_date
579: FROM gme_batch_steps
580: WHERE batch_id = l_batch_id
581: AND batchstep_id = l_last_batchstep_id;
582: END IF;
585: -- Note: To go from resources upto activity, you key on batch_id, batchstep_id and
586: -- oprn_line_id -> because oprn can be repeated many times in different steps so, if you have
587: -- batchstep_id and then oprn_line_id, you will get a unique row from gme_batch_step_activities...
588: SELECT batchstep_activity_id
589: INTO l_gme_batch_step_resources (j).batchstep_activity_id
590: FROM gme_batch_step_activities
591: WHERE batch_id = l_batch_id
592: AND batchstep_id = l_gme_batch_step_resources (j).batchstep_id
593: AND oprn_line_id = p_recipe_rout_resc_tbl (i).oprn_line_id;
588: SELECT batchstep_activity_id
589: INTO l_gme_batch_step_resources (j).batchstep_activity_id
590: FROM gme_batch_step_activities
591: WHERE batch_id = l_batch_id
592: AND batchstep_id = l_gme_batch_step_resources (j).batchstep_id
593: AND oprn_line_id = p_recipe_rout_resc_tbl (i).oprn_line_id;
594:
595: -- Insert text if copy text is on and there is text on the resource passed in...
596: -- Note... this should also work for insert step because an operation can have text
598: IF (p_recipe_rout_resc_tbl (i).text_code IS NOT NULL)
599: AND (gme_common_pvt.g_copy_routing_text_ind = '1') THEN
600: l_gmd_text_code := p_recipe_rout_resc_tbl (i).text_code;
601: l_text_string :=
602: 'gme_batch_step_resources' || '|' || TO_CHAR (l_batch_id)
603: || '|';
604: l_text_string :=
605: l_text_string
606: || TO_CHAR (l_gme_batch_step_resources (j).batchstep_activity_id)
602: 'gme_batch_step_resources' || '|' || TO_CHAR (l_batch_id)
603: || '|';
604: l_text_string :=
605: l_text_string
606: || TO_CHAR (l_gme_batch_step_resources (j).batchstep_activity_id)
607: || '|';
608: l_text_string :=
609: l_text_string || p_recipe_rout_resc_tbl (i).resources;
610:
622:
623: IF (l_return_status <> x_return_status) THEN
624: RAISE error_create_text;
625: ELSE
626: l_gme_batch_step_resources (j).text_code := l_gme_text_code;
627: END IF;
628: END IF;
629:
630: --FPBug#4395561 Start
627: END IF;
628: END IF;
629:
630: --FPBug#4395561 Start
631: /* call create flex procedure to insert the default values of the GME_BATCH_STEP_RESOURCES_FLEX
632: DFF's segments if they are enabled */
633: l_return_status:=NULL;
634: gme_validate_flex_fld_pvt.create_flex_step_resources (
635: l_gme_batch_step_resources (j),
631: /* call create flex procedure to insert the default values of the GME_BATCH_STEP_RESOURCES_FLEX
632: DFF's segments if they are enabled */
633: l_return_status:=NULL;
634: gme_validate_flex_fld_pvt.create_flex_step_resources (
635: l_gme_batch_step_resources (j),
636: l_gme_batch_step_resources (j),
637: l_return_status);
638: IF l_return_status <> FND_API.g_ret_sts_success THEN
639: RAISE create_flex_failure;
632: DFF's segments if they are enabled */
633: l_return_status:=NULL;
634: gme_validate_flex_fld_pvt.create_flex_step_resources (
635: l_gme_batch_step_resources (j),
636: l_gme_batch_step_resources (j),
637: l_return_status);
638: IF l_return_status <> FND_API.g_ret_sts_success THEN
639: RAISE create_flex_failure;
640: END IF;
639: RAISE create_flex_failure;
640: END IF;
641: --FPBug#4395561 End
642:
643: IF (gme_batch_step_resources_dbl.insert_row
644: (p_batch_step_resources => l_gme_batch_step_resources
645: (j)
646: ,x_batch_step_resources => l_gme_batch_step_resources
647: (j) ) ) THEN
640: END IF;
641: --FPBug#4395561 End
642:
643: IF (gme_batch_step_resources_dbl.insert_row
644: (p_batch_step_resources => l_gme_batch_step_resources
645: (j)
646: ,x_batch_step_resources => l_gme_batch_step_resources
647: (j) ) ) THEN
648: NULL;
642:
643: IF (gme_batch_step_resources_dbl.insert_row
644: (p_batch_step_resources => l_gme_batch_step_resources
645: (j)
646: ,x_batch_step_resources => l_gme_batch_step_resources
647: (j) ) ) THEN
648: NULL;
649: ELSE
650: RAISE error_insert_b_step_res;
652:
653: i := p_recipe_rout_resc_tbl.NEXT (i);
654: END LOOP; /* WHILE i IS NOT NULL; */
655:
656: IF l_gme_batch_step_resources.COUNT > 0 THEN
657: gme_batch_step_chg_pvt.set_sequence_dependent_id (l_batch_id);
658: END IF;
659:
660: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
657: gme_batch_step_chg_pvt.set_sequence_dependent_id (l_batch_id);
658: END IF;
659:
660: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
661: gme_debug.put_line ('Completed GME_BATCH_STEP_RESOURCES');
662: gme_debug.put_line ('GME_step_process_parameters');
663: END IF;
664:
665: FOR m IN 1 .. p_resc_parameters_tbl.COUNT LOOP
703:
704: -- Link this process parameters to the resources it belongs to..
705: SELECT batchstep_resource_id
706: INTO l_gme_rsrc_parameters (m).batchstep_resource_id
707: FROM gme_batch_step_resources
708: WHERE batch_id = l_batch_id
709: AND batchstep_id = l_gme_rsrc_parameters (m).batchstep_id
710: AND batchstep_activity_id =
711: l_gme_rsrc_parameters (m).batchstep_activity_id
1019: FETCH cur_get_batch_steps
1020: INTO l_batchstep_id, l_qty, l_plan_charges;
1021:
1022: WHILE cur_get_batch_steps%FOUND LOOP
1023: UPDATE gme_batch_step_resources
1024: SET plan_rsrc_usage =
1025: ROUND ( (l_qty / plan_rsrc_qty * plan_rsrc_usage), 32)
1026: WHERE batchstep_id = l_batchstep_id
1027: AND scale_type = 1
1048: FROM gme_batch_steps
1049: WHERE batchstep_id = l_last_batchstep_id;
1050:
1051: -- Round the plan_rsrc_qty to 32 decimal places.
1052: UPDATE gme_batch_step_resources
1053: SET plan_rsrc_qty = ROUND (l_qty, 32)
1054: WHERE batchstep_id = l_last_batchstep_id
1055: AND scale_type <>
1056: 0
1062: gme_debug.put_line (' plan charges ' || TO_CHAR (l_plan_charges) );
1063: END IF;
1064:
1065: IF l_plan_charges IS NOT NULL THEN
1066: UPDATE gme_batch_step_resources
1067: SET plan_rsrc_usage =
1068: ROUND (plan_rsrc_usage * l_plan_charges, 32)
1069: WHERE batchstep_id = l_last_batchstep_id AND scale_type = 2;
1070: -- scale_type = 2 denotes scale by charge...
1074: -- Because of the limitation in forms taking only 1 message at a time (?), we will put one message if this occurs,
1075: -- NOT one message per occurrence.
1076: SELECT COUNT (1)
1077: INTO l_count_scale_by_charge
1078: FROM gme_batch_step_resources
1079: WHERE batchstep_id = l_last_batchstep_id AND scale_type = 2;
1080: -- scale_type = 2 denotes scale by charge...
1081: END IF;
1082:
1093: FETCH cur_get_step_activities
1094: INTO l_batchstep_activity_id, l_activity_factor;
1095:
1096: WHILE cur_get_step_activities%FOUND LOOP
1097: UPDATE gme_batch_step_resources
1098: SET plan_rsrc_usage =
1099: ROUND (plan_rsrc_usage * l_activity_factor, 32)
1100: ,plan_rsrc_qty =
1101: ROUND (plan_rsrc_qty * l_activity_factor, 32)
1127: FETCH cur_get_batch_steps
1128: INTO l_batchstep_id, l_qty, l_plan_charges;
1129:
1130: WHILE cur_get_batch_steps%FOUND LOOP
1131: UPDATE gme_batch_step_resources
1132: SET plan_rsrc_qty = ROUND (l_qty, 32)
1133: WHERE batchstep_id = l_batchstep_id
1134: AND scale_type <> 0
1135: AND plan_rsrc_qty <> 0;
1140: || TO_CHAR (l_plan_charges) );
1141: END IF;
1142:
1143: IF l_plan_charges IS NOT NULL THEN
1144: UPDATE gme_batch_step_resources
1145: SET plan_rsrc_usage =
1146: ROUND (plan_rsrc_usage * l_plan_charges, 32)
1147: WHERE batchstep_id = l_batchstep_id AND scale_type = 2;
1148: -- scale_type = 2 denotes scale by charge...
1152: -- Because of the limitation in forms taking only 1 message at a time (?), we will put one message if this occurs,
1153: -- NOT one message per occurrence.
1154: SELECT COUNT (1)
1155: INTO l_count_scale_by_charge
1156: FROM gme_batch_step_resources
1157: WHERE batchstep_id = l_batchstep_id AND scale_type = 2;
1158: -- scale_type = 2 denotes scale by charge...
1159: END IF;
1160:
1178: FETCH cur_get_activities
1179: INTO l_batchstep_activity_id, l_activity_factor;
1180:
1181: WHILE cur_get_activities%FOUND LOOP
1182: UPDATE gme_batch_step_resources
1183: SET plan_rsrc_usage =
1184: ROUND (plan_rsrc_usage * l_activity_factor, 32)
1185: ,plan_rsrc_qty =
1186: ROUND (plan_rsrc_qty * l_activity_factor, 32)
1945: l_step_duration_tab step_duration_tab;
1946: x_act_tab activities_tab;
1947: x_act_row gme_batch_step_activities%ROWTYPE;
1948: x_rsrc_tab resources_tab;
1949: x_rsrc_row gme_batch_step_resources%ROWTYPE;
1950: x_rsrc_txns_tab rsrc_txns_tab;
1951: x_step_row gme_batch_steps%ROWTYPE;
1952: x_max_act_date DATE;
1953: x_max_rsrc_date DATE;
1960: x_step_start_date DATE;
1961: x_step_no gme_batch_steps.batchstep_no%TYPE;
1962: max_cmplt_date DATE;
1963: min_start_date DATE;
1964: l_usage_hrs gme_batch_step_resources.plan_rsrc_usage%TYPE;
1965: l_batchstep_activity_id NUMBER;
1966: l_batchstep_id NUMBER;
1967: l_cal_count NUMBER;
1968: l_contig_period_tbl gmp_calendar_api.contig_period_tbl;
1978:
1979: CURSOR cur_get_act_rsrcs (v_batchstep_activity_id NUMBER)
1980: IS
1981: SELECT *
1982: FROM gme_batch_step_resources
1983: WHERE batchstep_activity_id = v_batchstep_activity_id;
1984:
1985: CURSOR cur_get_step_id (v_step NUMBER, v_batch_id NUMBER)
1986: IS
2524: x_max_act_date := x_act_tab (j).plan_cmplt_date;
2525: END IF;
2526:
2527: FOR k IN x_rsrc_tab.FIRST .. x_rsrc_tab.LAST LOOP
2528: UPDATE gme_batch_step_resources
2529: SET plan_start_date = x_rsrc_tab (k).plan_start_date
2530: ,plan_cmplt_date = x_rsrc_tab (k).plan_cmplt_date
2531: WHERE batchstep_resource_id =
2532: x_rsrc_tab (k).batchstep_resource_id;
3087: x_return_status := fnd_api.g_ret_sts_unexp_error;
3088: END copy_and_create_text;
3089:
3090: PROCEDURE get_usage_in_hours (
3091: p_plan_rsrc_usage IN gme_batch_step_resources.plan_rsrc_usage%TYPE
3092: ,p_usage_um IN gme_batch_step_resources.usage_um%TYPE
3093: ,x_usage_hrs OUT NOCOPY gme_batch_step_resources.plan_rsrc_usage%TYPE
3094: ,x_return_status OUT NOCOPY VARCHAR2)
3095: IS
3088: END copy_and_create_text;
3089:
3090: PROCEDURE get_usage_in_hours (
3091: p_plan_rsrc_usage IN gme_batch_step_resources.plan_rsrc_usage%TYPE
3092: ,p_usage_um IN gme_batch_step_resources.usage_um%TYPE
3093: ,x_usage_hrs OUT NOCOPY gme_batch_step_resources.plan_rsrc_usage%TYPE
3094: ,x_return_status OUT NOCOPY VARCHAR2)
3095: IS
3096: l_hour_um mtl_units_of_measure.uom_code%TYPE;
3089:
3090: PROCEDURE get_usage_in_hours (
3091: p_plan_rsrc_usage IN gme_batch_step_resources.plan_rsrc_usage%TYPE
3092: ,p_usage_um IN gme_batch_step_resources.usage_um%TYPE
3093: ,x_usage_hrs OUT NOCOPY gme_batch_step_resources.plan_rsrc_usage%TYPE
3094: ,x_return_status OUT NOCOPY VARCHAR2)
3095: IS
3096: l_hour_um mtl_units_of_measure.uom_code%TYPE;
3097: l_hour_uom_class mtl_units_of_measure.uom_class%TYPE;
3191: ,v_activity_id NUMBER)
3192: IS
3193: SELECT batchstep_resource_id, offset_interval, plan_rsrc_usage
3194: ,plan_rsrc_count, usage_um
3195: FROM gme_batch_step_resources
3196: WHERE batchstep_id = v_step_id
3197: AND batch_id = v_batch_id
3198: AND batchstep_activity_id = v_activity_id;
3199:
3201: l_rsrc_duration NUMBER;
3202: l_act_duration NUMBER;
3203: l_max_rsrc_duration NUMBER;
3204: l_max_act_duration NUMBER;
3205: x_usage_hour gme_batch_step_resources.plan_rsrc_usage%TYPE;
3206: l_usage_hrs gme_batch_step_resources.plan_rsrc_usage%TYPE;
3207: l_return_status VARCHAR2 (1);
3208: missing_profile_option EXCEPTION;
3209: l_api_name CONSTANT VARCHAR2 (30) := 'get_max_duration';
3202: l_act_duration NUMBER;
3203: l_max_rsrc_duration NUMBER;
3204: l_max_act_duration NUMBER;
3205: x_usage_hour gme_batch_step_resources.plan_rsrc_usage%TYPE;
3206: l_usage_hrs gme_batch_step_resources.plan_rsrc_usage%TYPE;
3207: l_return_status VARCHAR2 (1);
3208: missing_profile_option EXCEPTION;
3209: l_api_name CONSTANT VARCHAR2 (30) := 'get_max_duration';
3210: BEGIN
3287:
3288: PROCEDURE insert_resource_txns (
3289: p_gme_batch_header_rec IN gme_batch_header%ROWTYPE
3290: ,p_doc_type IN VARCHAR2
3291: ,p_batch_step_resources_rec IN gme_batch_step_resources%ROWTYPE
3292: ,x_return_status OUT NOCOPY VARCHAR2)
3293: IS
3294: l_gme_resource_txns gme_resource_txns%ROWTYPE;
3295: l_txn_usage NUMBER;