20: ,p_step_cmplt_date IN DATE := NULL
21: ,p_step_due_date IN DATE := NULL)
22: IS
23: -- Local variables
24: l_gme_batch_steps gme_create_step_pvt.gme_batch_steps_tab
25: := gme_create_step_pvt.gme_batch_steps_tab
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
21: ,p_step_due_date IN DATE := NULL)
22: IS
23: -- Local variables
24: l_gme_batch_steps gme_create_step_pvt.gme_batch_steps_tab
25: := gme_create_step_pvt.gme_batch_steps_tab
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: ();
47: i PLS_INTEGER;
48: j PLS_INTEGER;
49: l_batch_id gme_batch_header.batch_id%TYPE;
50: l_step_tbl gmd_auto_step_calc.step_rec_tbl;
51: l_batchstep_id gme_batch_steps.batchstep_id%TYPE;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
48: j PLS_INTEGER;
49: l_batch_id gme_batch_header.batch_id%TYPE;
50: l_step_tbl gmd_auto_step_calc.step_rec_tbl;
51: l_batchstep_id gme_batch_steps.batchstep_id%TYPE;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
49: l_batch_id gme_batch_header.batch_id%TYPE;
50: l_step_tbl gmd_auto_step_calc.step_rec_tbl;
51: l_batchstep_id gme_batch_steps.batchstep_id%TYPE;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
57: l_charge gme_batch_steps.plan_charges%TYPE;
50: l_step_tbl gmd_auto_step_calc.step_rec_tbl;
51: l_batchstep_id gme_batch_steps.batchstep_id%TYPE;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
57: l_charge gme_batch_steps.plan_charges%TYPE;
58: l_uom_class mtl_units_of_measure.uom_class%TYPE;
51: l_batchstep_id gme_batch_steps.batchstep_id%TYPE;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
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;
52: l_last_batchstep_id gme_batch_steps.batchstep_id%TYPE;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
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;
53: l_qty gme_batch_steps.plan_step_qty%TYPE;
54: l_mass_qty gme_batch_steps.plan_mass_qty%TYPE;
55: l_volume_qty gme_batch_steps.plan_volume_qty%TYPE;
56: l_plan_charges gme_batch_steps.plan_charges%TYPE;
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;
100:
101: CURSOR cur_get_batch_steps (v_batch_id NUMBER, v_count NUMBER DEFAULT 0)
102: IS
103: SELECT batchstep_id, plan_step_qty, plan_charges
104: FROM gme_batch_steps
105: WHERE batch_id = v_batch_id
106: AND ( v_count <> 1
107: OR ( v_count = 1
108: AND batchstep_id = (SELECT MAX (batchstep_id)
105: WHERE batch_id = v_batch_id
106: AND ( v_count <> 1
107: OR ( v_count = 1
108: AND batchstep_id = (SELECT MAX (batchstep_id)
109: FROM gme_batch_steps
110: WHERE batch_id = v_batch_id) ) );
111:
112: CURSOR cur_get_activities (v_batch_id NUMBER)
113: IS
136: WHERE recipe_validity_rule_id = v_recipe_validity_rule_id;
137:
138: CURSOR cur_step_dates (
139: v_batch_id gme_batch_header.batch_id%TYPE
140: ,v_batchstep_id gme_batch_steps.batchstep_id%TYPE)
141: IS
142: SELECT plan_start_date, plan_cmplt_date
143: FROM gme_batch_steps
144: WHERE batch_id = v_batch_id AND batchstep_id = v_batchstep_id;
139: v_batch_id gme_batch_header.batch_id%TYPE
140: ,v_batchstep_id gme_batch_steps.batchstep_id%TYPE)
141: IS
142: SELECT plan_start_date, plan_cmplt_date
143: FROM gme_batch_steps
144: WHERE batch_id = v_batch_id AND batchstep_id = v_batchstep_id;
145:
146: CURSOR cur_step_plan_cmplt_date (
147: v_batch_id gme_batch_header.batch_id%TYPE
144: WHERE batch_id = v_batch_id AND batchstep_id = v_batchstep_id;
145:
146: CURSOR cur_step_plan_cmplt_date (
147: v_batch_id gme_batch_header.batch_id%TYPE
148: ,v_batchstep_id gme_batch_steps.batchstep_id%TYPE)
149: IS
150: SELECT plan_cmplt_date
151: FROM gme_batch_steps
152: WHERE batch_id = v_batch_id AND batchstep_id = v_batchstep_id;
147: v_batch_id gme_batch_header.batch_id%TYPE
148: ,v_batchstep_id gme_batch_steps.batchstep_id%TYPE)
149: IS
150: SELECT plan_cmplt_date
151: FROM gme_batch_steps
152: WHERE batch_id = v_batch_id AND batchstep_id = v_batchstep_id;
153:
154: CURSOR cur_is_charge_associated (v_batch_id NUMBER, v_batchstep_id NUMBER)
155: IS
172:
173: CURSOR cur_get_batchstep_ids (v_batch_id NUMBER)
174: IS
175: SELECT batchstep_id
176: FROM gme_batch_steps
177: WHERE batch_id = v_batch_id;
178: BEGIN
179: IF g_debug <= gme_debug.g_log_procedure THEN
180: gme_debug.put_line ('Entering api ' || g_pkg_name || '.'
203:
204: -- Note that by doing an extend to the PL/SQL table, a record is added to the collection
205: -- and all elements are initialized to NULL. Therefore, no need to initialize NULL elements
206: -- explicitly through an assignment statement as that is done in the EXTEND!
207: -- Create data for GME_BATCH_STEPS...
208: i := p_recipe_rout_step_tbl.FIRST;
209: j := 0;
210: l_step_charge_rsrc_tab.DELETE ();
211:
213: IF (NVL(g_debug, -1) = gme_debug.g_log_statement) THEN
214: gme_debug.put_line ('copy_routing_text_ind = '||gme_common_pvt.g_copy_routing_text_ind);
215: END IF;
216: WHILE i IS NOT NULL LOOP
217: l_gme_batch_steps.EXTEND;
218:
219: IF (j = 0) THEN
220: j := l_gme_batch_steps.FIRST;
221: ELSE
216: WHILE i IS NOT NULL LOOP
217: l_gme_batch_steps.EXTEND;
218:
219: IF (j = 0) THEN
220: j := l_gme_batch_steps.FIRST;
221: ELSE
222: j := l_gme_batch_steps.NEXT (j);
223: END IF;
224:
218:
219: IF (j = 0) THEN
220: j := l_gme_batch_steps.FIRST;
221: ELSE
222: j := l_gme_batch_steps.NEXT (j);
223: END IF;
224:
225: l_gme_batch_steps (j).batch_id := l_batch_id;
226: l_gme_batch_steps (j).routingstep_id :=
221: ELSE
222: j := l_gme_batch_steps.NEXT (j);
223: END IF;
224:
225: l_gme_batch_steps (j).batch_id := l_batch_id;
226: l_gme_batch_steps (j).routingstep_id :=
227: p_recipe_rout_step_tbl (i).routingstep_id;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
222: j := l_gme_batch_steps.NEXT (j);
223: END IF;
224:
225: l_gme_batch_steps (j).batch_id := l_batch_id;
226: l_gme_batch_steps (j).routingstep_id :=
227: p_recipe_rout_step_tbl (i).routingstep_id;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
224:
225: l_gme_batch_steps (j).batch_id := l_batch_id;
226: l_gme_batch_steps (j).routingstep_id :=
227: p_recipe_rout_step_tbl (i).routingstep_id;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
226: l_gme_batch_steps (j).routingstep_id :=
227: p_recipe_rout_step_tbl (i).routingstep_id;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
227: p_recipe_rout_step_tbl (i).routingstep_id;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
228: l_gme_batch_steps (j).batchstep_no :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
236: l_gme_batch_steps (j).max_step_capacity :=
229: p_recipe_rout_step_tbl (i).routingstep_no;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
236: l_gme_batch_steps (j).max_step_capacity :=
237: p_recipe_rout_step_tbl (i).max_capacity;
230: l_gme_batch_steps (j).oprn_id := p_recipe_rout_step_tbl (i).oprn_id;
231: l_gme_batch_steps (j).step_status := gme_common_pvt.g_step_pending;
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
236: l_gme_batch_steps (j).max_step_capacity :=
237: p_recipe_rout_step_tbl (i).max_capacity;
238: l_gme_batch_steps (j).max_step_capacity_um :=
232: l_gme_batch_steps (j).quality_status := 1;
233: l_gme_batch_steps (j).delete_mark := 0;
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
236: l_gme_batch_steps (j).max_step_capacity :=
237: p_recipe_rout_step_tbl (i).max_capacity;
238: l_gme_batch_steps (j).max_step_capacity_um :=
239: p_recipe_rout_step_tbl (i).capacity_uom;
240: l_gme_batch_steps (j).minimum_transfer_qty :=
234: l_gme_batch_steps (j).step_qty_um :=
235: p_recipe_rout_step_tbl (i).process_qty_uom;
236: l_gme_batch_steps (j).max_step_capacity :=
237: p_recipe_rout_step_tbl (i).max_capacity;
238: l_gme_batch_steps (j).max_step_capacity_um :=
239: p_recipe_rout_step_tbl (i).capacity_uom;
240: l_gme_batch_steps (j).minimum_transfer_qty :=
241: p_recipe_rout_step_tbl (i).minimum_transfer_qty;
242: l_gme_batch_steps (j).plan_step_qty :=
236: l_gme_batch_steps (j).max_step_capacity :=
237: p_recipe_rout_step_tbl (i).max_capacity;
238: l_gme_batch_steps (j).max_step_capacity_um :=
239: p_recipe_rout_step_tbl (i).capacity_uom;
240: l_gme_batch_steps (j).minimum_transfer_qty :=
241: p_recipe_rout_step_tbl (i).minimum_transfer_qty;
242: l_gme_batch_steps (j).plan_step_qty :=
243: p_recipe_rout_step_tbl (i).step_qty;
244: l_gme_batch_steps (j).plan_start_date := gme_common_pvt.g_timestamp;
238: l_gme_batch_steps (j).max_step_capacity_um :=
239: p_recipe_rout_step_tbl (i).capacity_uom;
240: l_gme_batch_steps (j).minimum_transfer_qty :=
241: p_recipe_rout_step_tbl (i).minimum_transfer_qty;
242: l_gme_batch_steps (j).plan_step_qty :=
243: p_recipe_rout_step_tbl (i).step_qty;
244: l_gme_batch_steps (j).plan_start_date := gme_common_pvt.g_timestamp;
245: l_gme_batch_steps (j).plan_cmplt_date := gme_common_pvt.g_timestamp;
246: l_gme_batch_steps (j).plan_charges := 0;
240: l_gme_batch_steps (j).minimum_transfer_qty :=
241: p_recipe_rout_step_tbl (i).minimum_transfer_qty;
242: l_gme_batch_steps (j).plan_step_qty :=
243: p_recipe_rout_step_tbl (i).step_qty;
244: l_gme_batch_steps (j).plan_start_date := gme_common_pvt.g_timestamp;
245: l_gme_batch_steps (j).plan_cmplt_date := gme_common_pvt.g_timestamp;
246: l_gme_batch_steps (j).plan_charges := 0;
247:
248: IF p_gme_batch_header_rec.enforce_step_dependency = 1 THEN
241: p_recipe_rout_step_tbl (i).minimum_transfer_qty;
242: l_gme_batch_steps (j).plan_step_qty :=
243: p_recipe_rout_step_tbl (i).step_qty;
244: l_gme_batch_steps (j).plan_start_date := gme_common_pvt.g_timestamp;
245: l_gme_batch_steps (j).plan_cmplt_date := gme_common_pvt.g_timestamp;
246: l_gme_batch_steps (j).plan_charges := 0;
247:
248: IF p_gme_batch_header_rec.enforce_step_dependency = 1 THEN
249: l_gme_batch_steps (j).steprelease_type := 1;
242: l_gme_batch_steps (j).plan_step_qty :=
243: p_recipe_rout_step_tbl (i).step_qty;
244: l_gme_batch_steps (j).plan_start_date := gme_common_pvt.g_timestamp;
245: l_gme_batch_steps (j).plan_cmplt_date := gme_common_pvt.g_timestamp;
246: l_gme_batch_steps (j).plan_charges := 0;
247:
248: IF p_gme_batch_header_rec.enforce_step_dependency = 1 THEN
249: l_gme_batch_steps (j).steprelease_type := 1;
250: ELSE
245: l_gme_batch_steps (j).plan_cmplt_date := gme_common_pvt.g_timestamp;
246: l_gme_batch_steps (j).plan_charges := 0;
247:
248: IF p_gme_batch_header_rec.enforce_step_dependency = 1 THEN
249: l_gme_batch_steps (j).steprelease_type := 1;
250: ELSE
251: l_gme_batch_steps (j).steprelease_type :=
252: p_recipe_rout_step_tbl (i).steprelease_type;
253: END IF; /*enforce_step_dependency = 1 */
247:
248: IF p_gme_batch_header_rec.enforce_step_dependency = 1 THEN
249: l_gme_batch_steps (j).steprelease_type := 1;
250: ELSE
251: l_gme_batch_steps (j).steprelease_type :=
252: p_recipe_rout_step_tbl (i).steprelease_type;
253: END IF; /*enforce_step_dependency = 1 */
254:
255: IF p_step_due_date IS NULL THEN
252: p_recipe_rout_step_tbl (i).steprelease_type;
253: END IF; /*enforce_step_dependency = 1 */
254:
255: IF p_step_due_date IS NULL THEN
256: l_gme_batch_steps (j).due_date :=
257: l_gme_batch_steps (j).plan_cmplt_date;
258: ELSE
259: l_gme_batch_steps (j).due_date := p_step_due_date;
260: END IF;
253: END IF; /*enforce_step_dependency = 1 */
254:
255: IF p_step_due_date IS NULL THEN
256: l_gme_batch_steps (j).due_date :=
257: l_gme_batch_steps (j).plan_cmplt_date;
258: ELSE
259: l_gme_batch_steps (j).due_date := p_step_due_date;
260: END IF;
261:
255: IF p_step_due_date IS NULL THEN
256: l_gme_batch_steps (j).due_date :=
257: l_gme_batch_steps (j).plan_cmplt_date;
258: ELSE
259: l_gme_batch_steps (j).due_date := p_step_due_date;
260: END IF;
261:
262: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
263: gme_debug.put_line ( ' minimum_transfer_qty '
260: END IF;
261:
262: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
263: gme_debug.put_line ( ' minimum_transfer_qty '
264: || l_gme_batch_steps (j).minimum_transfer_qty);
265: gme_debug.put_line ( ' max step capacity '
266: || l_gme_batch_steps (j).max_step_capacity);
267: gme_debug.put_line ( ' max step capacity uom '
268: || l_gme_batch_steps (j).max_step_capacity_um);
262: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
263: gme_debug.put_line ( ' minimum_transfer_qty '
264: || l_gme_batch_steps (j).minimum_transfer_qty);
265: gme_debug.put_line ( ' max step capacity '
266: || l_gme_batch_steps (j).max_step_capacity);
267: gme_debug.put_line ( ' max step capacity uom '
268: || l_gme_batch_steps (j).max_step_capacity_um);
269: END IF;
270:
264: || l_gme_batch_steps (j).minimum_transfer_qty);
265: gme_debug.put_line ( ' max step capacity '
266: || l_gme_batch_steps (j).max_step_capacity);
267: gme_debug.put_line ( ' max step capacity uom '
268: || l_gme_batch_steps (j).max_step_capacity_um);
269: END IF;
270:
271: -- Insert text if copy text is on and there is text on the step passed in...
272: -- Note... this should also work for insert step because an operation can have text
274: IF (p_recipe_rout_step_tbl (i).text_code IS NOT NULL)
275: AND (gme_common_pvt.g_copy_routing_text_ind = 1) THEN
276: l_gmd_text_code := p_recipe_rout_step_tbl (i).text_code;
277: l_text_string :=
278: 'gme_batch_steps' || '|' || TO_CHAR (l_batch_id)
279: || '|';
280: l_text_string :=
281: l_text_string || l_gme_batch_steps (j).batchstep_no;
282: --Bug#5112133
277: l_text_string :=
278: 'gme_batch_steps' || '|' || TO_CHAR (l_batch_id)
279: || '|';
280: l_text_string :=
281: l_text_string || l_gme_batch_steps (j).batchstep_no;
282: --Bug#5112133
283: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
284: gme_debug.put_line ('text code for step=' || l_gmd_text_code);
285: gme_debug.put_line ('key_field for step=' || l_text_string);
292:
293: IF (l_return_status <> x_return_status) THEN
294: RAISE error_create_text;
295: ELSE
296: l_gme_batch_steps (j).text_code := l_gme_text_code;
297: END IF;
298: END IF;
299:
300: gmd_gme_int.check_qc(p_routingid => p_gme_batch_header_rec.routing_id,
297: END IF;
298: END IF;
299:
300: gmd_gme_int.check_qc(p_routingid => p_gme_batch_header_rec.routing_id,
301: p_routingstepid => l_gme_batch_steps(j).routingstep_id,
302: p_recipeid => l_recipe_id,
303: p_organization_id => p_gme_batch_header_rec.organization_id,
304: p_resultout => l_qc_status);
305: IF (l_qc_status = 'S') THEN
302: p_recipeid => l_recipe_id,
303: p_organization_id => p_gme_batch_header_rec.organization_id,
304: p_resultout => l_qc_status);
305: IF (l_qc_status = 'S') THEN
306: l_gme_batch_steps(j).quality_status := 2;
307: END IF;
308:
309:
310: --FPBug#4395561 Start
311: /* call create flex procedure to insert the default values of the BATCH_STEPS_DTL_FLEX
312: DFF's segments if they are enabled */
313: l_return_status := NULL;
314: gme_validate_flex_fld_pvt.create_flex_batch_step (
315: l_gme_batch_steps (j),
316: l_gme_batch_steps (j),
317: l_return_status);
318: IF l_return_status <> FND_API.g_ret_sts_success THEN
319: RAISE create_flex_failure;
312: DFF's segments if they are enabled */
313: l_return_status := NULL;
314: gme_validate_flex_fld_pvt.create_flex_batch_step (
315: l_gme_batch_steps (j),
316: l_gme_batch_steps (j),
317: l_return_status);
318: IF l_return_status <> FND_API.g_ret_sts_success THEN
319: RAISE create_flex_failure;
320: END IF;
319: RAISE create_flex_failure;
320: END IF;
321: --FPBug#4395561 End
322:
323: IF (gme_batch_steps_dbl.insert_row
324: (p_batch_step => l_gme_batch_steps
325: (j)
326: ,x_batch_step => l_gme_batch_steps
327: (j) ) =
320: END IF;
321: --FPBug#4395561 End
322:
323: IF (gme_batch_steps_dbl.insert_row
324: (p_batch_step => l_gme_batch_steps
325: (j)
326: ,x_batch_step => l_gme_batch_steps
327: (j) ) =
328: TRUE) THEN
322:
323: IF (gme_batch_steps_dbl.insert_row
324: (p_batch_step => l_gme_batch_steps
325: (j)
326: ,x_batch_step => l_gme_batch_steps
327: (j) ) =
328: TRUE) THEN
329: -- Keep the last batchstep_id produced... this is required for single step insert... since we don't
330: -- have the routingstep_id, we need this when linking the activities and resources back to the step.
327: (j) ) =
328: TRUE) THEN
329: -- Keep the last batchstep_id produced... this is required for single step insert... since we don't
330: -- have the routingstep_id, we need this when linking the activities and resources back to the step.
331: l_last_batchstep_id := l_gme_batch_steps (j).batchstep_id;
332: l_step_charge_rsrc_tab (l_last_batchstep_id).resources :=
333: p_recipe_rout_step_tbl (j).resources;
334:
335: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
389: ,plan_cmplt_date
390: INTO l_gme_batch_step_activities (j).batchstep_id
391: ,l_gme_batch_step_activities (j).plan_start_date
392: ,l_gme_batch_step_activities (j).plan_cmplt_date
393: FROM gme_batch_steps
394: WHERE batch_id = l_batch_id
395: AND routingstep_id = p_recipe_rout_act_tbl (i).routingstep_id;
396: ELSE
397: SELECT batchstep_id
399: ,plan_cmplt_date
400: INTO l_gme_batch_step_activities (j).batchstep_id
401: ,l_gme_batch_step_activities (j).plan_start_date
402: ,l_gme_batch_step_activities (j).plan_cmplt_date
403: FROM gme_batch_steps
404: WHERE batch_id = l_batch_id
405: AND batchstep_id = l_last_batchstep_id;
406: END IF;
407:
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
573: SELECT batchstep_id
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;
583:
681: -- Link this process parameters to the batch step it belongs to...
682: IF (p_resc_parameters_tbl (m).routingstep_id IS NOT NULL) THEN
683: SELECT batchstep_id
684: INTO l_gme_rsrc_parameters (m).batchstep_id
685: FROM gme_batch_steps
686: WHERE batch_id = l_batch_id
687: AND routingstep_id = p_resc_parameters_tbl (m).routingstep_id;
688: ELSE
689: SELECT batchstep_id
687: AND routingstep_id = p_resc_parameters_tbl (m).routingstep_id;
688: ELSE
689: SELECT batchstep_id
690: INTO l_gme_rsrc_parameters (m).batchstep_id
691: FROM gme_batch_steps
692: WHERE batch_id = l_batch_id
693: AND batchstep_id = l_last_batchstep_id;
694: END IF;
695:
761:
762: IF (p_recipe_rout_matl_tbl (i).routingstep_id IS NOT NULL) THEN
763: SELECT batchstep_id
764: INTO l_gme_batch_step_items (j).batchstep_id
765: FROM gme_batch_steps
766: WHERE batch_id = l_batch_id
767: AND routingstep_id = p_recipe_rout_matl_tbl (i).routingstep_id;
768: ELSE
769: l_gme_batch_step_items (j).batchstep_id := l_last_batchstep_id;
843: l_gme_batch_step_dep (j).batch_id := l_batch_id;
844:
845: SELECT batchstep_id
846: INTO l_gme_batch_step_dep (j).batchstep_id
847: FROM gme_batch_steps
848: WHERE batch_id = l_batch_id
849: AND batchstep_no = p_routing_depd_tbl (i).routingstep_no;
850:
851: SELECT batchstep_id
849: AND batchstep_no = p_routing_depd_tbl (i).routingstep_no;
850:
851: SELECT batchstep_id
852: INTO l_gme_batch_step_dep (j).dep_step_id
853: FROM gme_batch_steps
854: WHERE batch_id = l_batch_id
855: AND batchstep_no = p_routing_depd_tbl (i).dep_routingstep_no;
856:
857: l_gme_batch_step_dep (j).dep_type := p_routing_depd_tbl (i).dep_type;
927: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
928: gme_debug.put_line ('done step calc...');
929: END IF;
930:
931: -- Update the plan_step_qty in GME_BATCH_STEPS
932: FOR i IN l_step_tbl.FIRST .. l_step_tbl.LAST LOOP
933: -- Round the step_qty, step_mass_qty, step_vol_qty to 32 decimal places.
934: UPDATE gme_batch_steps
935: SET plan_step_qty = ROUND (l_step_tbl (i).step_qty, 32)
930:
931: -- Update the plan_step_qty in GME_BATCH_STEPS
932: FOR i IN l_step_tbl.FIRST .. l_step_tbl.LAST LOOP
933: -- Round the step_qty, step_mass_qty, step_vol_qty to 32 decimal places.
934: UPDATE gme_batch_steps
935: SET plan_step_qty = ROUND (l_step_tbl (i).step_qty, 32)
936: ,plan_mass_qty = ROUND (l_step_tbl (i).step_mass_qty, 32)
937: ,mass_ref_um = l_step_tbl (i).step_mass_uom
938: ,plan_volume_qty = ROUND (l_step_tbl (i).step_vol_qty, 32)
1000: || l_return_status);
1001: gme_debug.put_line (' charges ' || TO_CHAR (l_charge) );
1002: END IF;
1003:
1004: UPDATE gme_batch_steps
1005: SET plan_charges = l_charge
1006: WHERE batchstep_id = l_last_batchstep_id;
1007: ELSE
1008: update_charges (p_batch_id => l_batch_id
1044: AND p_recipe_rout_step_tbl (1).routingstep_id IS NULL) THEN
1045: -- This is an insert step... deal with only that new step...
1046: SELECT plan_step_qty, plan_charges
1047: INTO l_qty, l_plan_charges
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
1296: ('p_step_cmplt_date diff from l_step_plan_cmplt_date');
1297: END IF;
1298:
1299: IF (p_step_cmplt_date > l_step_plan_cmplt_date) THEN
1300: UPDATE gme_batch_steps
1301: SET plan_cmplt_date = p_step_cmplt_date
1302: ,last_updated_by = gme_common_pvt.g_user_ident
1303: ,last_update_date = gme_common_pvt.g_timestamp
1304: ,last_update_login = gme_common_pvt.g_login_id
1423:
1424: IF ( p_recipe_rout_step_tbl.COUNT = 1
1425: AND p_recipe_rout_step_tbl (1).routingstep_id IS NULL) THEN
1426: wf_event.RAISE (p_event_name => gme_common_pvt.G_BATCHSTEP_CREATED
1427: ,p_event_key => l_gme_batch_steps (1).batchstep_id);
1428: END IF;
1429:
1430: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
1431: gme_debug.put_line
1548: IS
1549: x_charge_tab charge_tab;
1550: x_num_steps PLS_INTEGER;
1551: l_return_status VARCHAR2 (1);
1552: x_charge gme_batch_steps.plan_charges%TYPE;
1553: l_api_name CONSTANT VARCHAR2 (30) := 'update charges';
1554:
1555: -- Cursor Definitions
1556: CURSOR cur_get_steps (v_batch_id NUMBER)
1556: CURSOR cur_get_steps (v_batch_id NUMBER)
1557: IS
1558: SELECT batchstep_id, plan_mass_qty, mass_ref_um, plan_volume_qty
1559: ,volume_ref_um
1560: FROM gme_batch_steps
1561: WHERE batch_id = v_batch_id;
1562:
1563: x_cur_step_rec cur_get_steps%ROWTYPE;
1564: error_calc_charge EXCEPTION;
1616: INTO x_cur_step_rec;
1617: END LOOP;
1618:
1619: FOR i IN 1 .. x_charge_tab.COUNT LOOP
1620: UPDATE gme_batch_steps
1621: SET plan_charges = x_charge_tab (i).charge
1622: WHERE batchstep_id = x_charge_tab (i).step_id;
1623: END LOOP;
1624:
1666: CURSOR cur_get_step_date_4_cal (v_step_id NUMBER, v_batch_id NUMBER)
1667: IS
1668: SELECT dep_type, r.plan_start_date, r.plan_cmplt_date
1669: ,standard_delay
1670: FROM gme_batch_step_dependencies d, gme_batch_steps r
1671: WHERE d.batch_id = r.batch_id
1672: AND d.batch_id = v_batch_id
1673: AND r.batchstep_id = d.dep_step_id
1674: AND d.batchstep_id = v_step_id;
1677: IS
1678: SELECT MAX (DECODE (dep_type
1679: ,1, r.plan_start_date + standard_delay / 24
1680: ,0, r.plan_cmplt_date + standard_delay / 24) )
1681: FROM gme_batch_step_dependencies d, gme_batch_steps r
1682: WHERE d.batch_id = r.batch_id
1683: AND d.batch_id = v_batch_id
1684: AND r.batchstep_id = d.dep_step_id
1685: AND d.batchstep_id = v_step_id;
1934: p_gme_batch_header_rec IN gme_batch_header%ROWTYPE
1935: ,p_use_workday_cal IN VARCHAR2
1936: ,p_contiguity_override IN VARCHAR2
1937: ,p_return_status OUT NOCOPY VARCHAR2
1938: ,p_step_id IN gme_batch_steps.batchstep_id%TYPE
1939: DEFAULT NULL
1940: ,p_plan_start_date IN DATE DEFAULT NULL
1941: ,p_plan_cmplt_date IN DATE DEFAULT NULL)
1942: IS
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;
1954: l_return_status VARCHAR2 (1);
1955: x_routing_id gme_batch_header.routing_id%TYPE;
1957: l_batch_id gme_batch_header.batch_id%TYPE;
1958: x_batch_duration NUMBER;
1959: x_batch_start_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;
1984:
1985: CURSOR cur_get_step_id (v_step NUMBER, v_batch_id NUMBER)
1986: IS
1987: SELECT batchstep_id
1988: FROM gme_batch_steps
1989: WHERE batch_id = v_batch_id AND batchstep_no = v_step;
1990:
1991: CURSOR cur_get_step (v_batchstep_id NUMBER)
1992: IS
1990:
1991: CURSOR cur_get_step (v_batchstep_id NUMBER)
1992: IS
1993: SELECT batchstep_no
1994: FROM gme_batch_steps
1995: WHERE batchstep_id = v_batchstep_id;
1996:
1997: CURSOR cur_get_activity (v_batchstep_activity_id NUMBER)
1998: IS
2088: x_gmd_step_tbl (1).step_id := p_step_id;
2089:
2090: SELECT batchstep_no
2091: INTO x_gmd_step_tbl (1).step_no
2092: FROM gme_batch_steps
2093: WHERE batchstep_id = p_step_id;
2094: END IF;
2095:
2096: -- Calculate the duration of each step...
2120: -- If both dates are null, that's OK too, the code below will use the batch plan start date.
2121: IF (p_plan_start_date IS NULL) AND (p_plan_cmplt_date IS NOT NULL) THEN
2122: SELECT batchstep_no
2123: INTO x_step_no
2124: FROM gme_batch_steps
2125: WHERE batchstep_id = p_step_id;
2126:
2127: IF l_use_workday_cal = fnd_api.g_true THEN
2128: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2318: /* Calculate the dates for all the rows in X_step_tbl */
2319: FOR i IN x_step_tbl.FIRST .. x_step_tbl.LAST LOOP
2320: SELECT *
2321: INTO x_step_row
2322: FROM gme_batch_steps
2323: WHERE batchstep_id = x_step_tbl (i);
2324:
2325: IF (NVL (g_debug, -1) = gme_debug.g_log_statement) THEN
2326: gme_debug.put_line ('step_id=' || x_step_tbl (i) );
2551: ,plan_cmplt_date = x_act_tab (k).plan_cmplt_date
2552: WHERE batchstep_activity_id = x_act_tab (k).batchstep_activity_id;
2553: END LOOP;
2554:
2555: UPDATE gme_batch_steps
2556: SET plan_start_date = x_step_row.plan_start_date
2557: ,plan_cmplt_date = x_step_row.plan_cmplt_date
2558: ,due_date = x_step_row.due_date
2559: WHERE batchstep_id = x_step_row.batchstep_id;
2563: IF (p_step_id IS NULL) THEN
2564: -- not a single step insert... however, that should also be considered for updating the header dates...
2565: SELECT MAX (plan_cmplt_date)
2566: INTO max_cmplt_date
2567: FROM gme_batch_steps
2568: WHERE batch_id = l_batch_id;
2569:
2570: SELECT MIN (plan_start_date)
2571: INTO min_start_date
2568: WHERE batch_id = l_batch_id;
2569:
2570: SELECT MIN (plan_start_date)
2571: INTO min_start_date
2572: FROM gme_batch_steps
2573: WHERE batch_id = l_batch_id;
2574:
2575: IF p_gme_batch_header_rec.batch_status = 2 THEN
2576: -- Pawan Kumar made following changes for bug 5015873
2693: x_return_status OUT NOCOPY VARCHAR2) IS
2694:
2695: CURSOR cur_get_leaf_nodes (v_batch_id NUMBER) IS
2696: SELECT batchstep_id, batchstep_no
2697: FROM gme_batch_steps
2698: WHERE batch_id = v_batch_id
2699: AND batchstep_id NOT IN (SELECT dep_step_id
2700: FROM gme_batch_step_dependencies
2701: WHERE batch_id = v_batch_id);
2713: CURSOR Cur_get_branches(v_batch_id NUMBER, v_batchstep_id NUMBER) IS
2714: SELECT branch, LENGTH(branch) sz
2715: FROM (SELECT REPLACE(sys_connect_by_path(LPAD(s.batchstep_no, 5, 0)||LPAD(p.batchstep_no, 5, 0 )||dep_type||LPAD(standard_delay, 3,0),' '), ' ', NULL) branch
2716: FROM (SELECT * FROM gme_batch_step_dependencies WHERE batch_id = v_batch_id) d,
2717: (SELECT * FROM gme_batch_steps WHERE batch_id = v_batch_id) s,
2718: (SELECT * FROM gme_batch_steps WHERE batch_id = v_batch_id) p
2719: WHERE s.batchstep_id = d.batchstep_id
2720: AND p.batchstep_id = d.dep_step_id
2721: AND connect_by_isleaf = 1
2714: SELECT branch, LENGTH(branch) sz
2715: FROM (SELECT REPLACE(sys_connect_by_path(LPAD(s.batchstep_no, 5, 0)||LPAD(p.batchstep_no, 5, 0 )||dep_type||LPAD(standard_delay, 3,0),' '), ' ', NULL) branch
2716: FROM (SELECT * FROM gme_batch_step_dependencies WHERE batch_id = v_batch_id) d,
2717: (SELECT * FROM gme_batch_steps WHERE batch_id = v_batch_id) s,
2718: (SELECT * FROM gme_batch_steps WHERE batch_id = v_batch_id) p
2719: WHERE s.batchstep_id = d.batchstep_id
2720: AND p.batchstep_id = d.dep_step_id
2721: AND connect_by_isleaf = 1
2722: START WITH d.batchstep_id = v_batchstep_id
2911: /* Calculate the step quantities for all the rows in X_step_tbl */
2912: FOR i IN 1 .. x_step_rows LOOP
2913: SELECT plan_step_qty
2914: INTO x_step_qty
2915: FROM gme_batch_steps
2916: WHERE batchstep_no = p_step_tbl (i).step_no
2917: AND batch_id = p_parent_id;
2918:
2919: x_step_qty := x_step_qty * x_scale_factor;