44: l_org_code VARCHAR2(7);
45: BEGIN
46:
47: IF PG_DEBUG in ('Y', 'C') THEN
48: msc_sch_wb.atp_debug('***** Get_Item_Demand_Alloc_Percent *****');
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
45: BEGIN
46:
47: IF PG_DEBUG in ('Y', 'C') THEN
48: msc_sch_wb.atp_debug('***** Get_Item_Demand_Alloc_Percent *****');
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
46:
47: IF PG_DEBUG in ('Y', 'C') THEN
48: msc_sch_wb.atp_debug('***** Get_Item_Demand_Alloc_Percent *****');
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
47: IF PG_DEBUG in ('Y', 'C') THEN
48: msc_sch_wb.atp_debug('***** Get_Item_Demand_Alloc_Percent *****');
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
48: msc_sch_wb.atp_debug('***** Get_Item_Demand_Alloc_Percent *****');
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
49: msc_sch_wb.atp_debug('p_plan_id =' || p_plan_id);
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
50: msc_sch_wb.atp_debug('p_demand_id =' || p_demand_id);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
51: msc_sch_wb.atp_debug('p_demand_date =' || p_demand_date );
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
59: msc_sch_wb.atp_debug('p_record_class =' || p_record_class);
52: msc_sch_wb.atp_debug('p_assembly_item_id =' || p_assembly_item_id);
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
59: msc_sch_wb.atp_debug('p_record_class =' || p_record_class);
60: END IF;
53: msc_sch_wb.atp_debug('p_source_org_id =' || p_source_org_id);
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
59: msc_sch_wb.atp_debug('p_record_class =' || p_record_class);
60: END IF;
61:
54: msc_sch_wb.atp_debug('p_inventory_item_id =' || p_inventory_item_id);
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
59: msc_sch_wb.atp_debug('p_record_class =' || p_record_class);
60: END IF;
61:
62: l_alloc_rule := MSC_AATP_FUNC.Get_DC_Alloc_Percent(p_instance_id, p_inventory_item_id, p_org_id,
55: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
56: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
57: msc_sch_wb.atp_debug('p_origination_type =' || p_origination_type );
58: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
59: msc_sch_wb.atp_debug('p_record_class =' || p_record_class);
60: END IF;
61:
62: l_alloc_rule := MSC_AATP_FUNC.Get_DC_Alloc_Percent(p_instance_id, p_inventory_item_id, p_org_id,
63: null, null, p_demand_class, p_demand_date);
61:
62: l_alloc_rule := MSC_AATP_FUNC.Get_DC_Alloc_Percent(p_instance_id, p_inventory_item_id, p_org_id,
63: null, null, p_demand_class, p_demand_date);
64: IF PG_DEBUG in ('Y', 'C') THEN
65: msc_sch_wb.atp_debug('l_alloc_rule : '||l_alloc_rule);
66: END IF;
67:
68: -- dsting #1625776
69: -- If no rule exists for the demand on the demand date, and the demand date is > sysdate
94: -- class. if the demand is the dependent demand, we see how we allocate for
95: -- the parent supply, we do the same thing to it's dependent demand.
96:
97: IF PG_DEBUG in ('Y', 'C') THEN
98: msc_sch_wb.atp_debug('this is indep demand, origination_type = '||p_origination_type);
99: END IF;
100: /*
101: bug 2783787 (ssurendr) - null demand_class in request should be regarded as "OTHER"
102: MSC_ATP_PROC.get_org_default_info(p_instance_id, p_org_id, l_default_atp_rule_id,
103: l_calendar_code, l_calendar_exception_set_id, l_default_demand_class,
104: l_org_code);
105:
106: IF PG_DEBUG in ('Y', 'C') THEN
107: msc_sch_wb.atp_debug('l_default_atp_rule_id='||l_default_atp_rule_id);
108: msc_sch_wb.atp_debug('l_calendar_code='||l_calendar_code);
109: msc_sch_wb.atp_debug('l_calendar_exception_set_id'||l_calendar_exception_set_id);
110: msc_sch_wb.atp_debug('l_default_demand_class'||l_default_demand_class);
111: msc_sch_wb.atp_debug('l_org_code'||l_org_code);
104: l_org_code);
105:
106: IF PG_DEBUG in ('Y', 'C') THEN
107: msc_sch_wb.atp_debug('l_default_atp_rule_id='||l_default_atp_rule_id);
108: msc_sch_wb.atp_debug('l_calendar_code='||l_calendar_code);
109: msc_sch_wb.atp_debug('l_calendar_exception_set_id'||l_calendar_exception_set_id);
110: msc_sch_wb.atp_debug('l_default_demand_class'||l_default_demand_class);
111: msc_sch_wb.atp_debug('l_org_code'||l_org_code);
112: END IF;
105:
106: IF PG_DEBUG in ('Y', 'C') THEN
107: msc_sch_wb.atp_debug('l_default_atp_rule_id='||l_default_atp_rule_id);
108: msc_sch_wb.atp_debug('l_calendar_code='||l_calendar_code);
109: msc_sch_wb.atp_debug('l_calendar_exception_set_id'||l_calendar_exception_set_id);
110: msc_sch_wb.atp_debug('l_default_demand_class'||l_default_demand_class);
111: msc_sch_wb.atp_debug('l_org_code'||l_org_code);
112: END IF;
113: */
106: IF PG_DEBUG in ('Y', 'C') THEN
107: msc_sch_wb.atp_debug('l_default_atp_rule_id='||l_default_atp_rule_id);
108: msc_sch_wb.atp_debug('l_calendar_code='||l_calendar_code);
109: msc_sch_wb.atp_debug('l_calendar_exception_set_id'||l_calendar_exception_set_id);
110: msc_sch_wb.atp_debug('l_default_demand_class'||l_default_demand_class);
111: msc_sch_wb.atp_debug('l_org_code'||l_org_code);
112: END IF;
113: */
114:
107: msc_sch_wb.atp_debug('l_default_atp_rule_id='||l_default_atp_rule_id);
108: msc_sch_wb.atp_debug('l_calendar_code='||l_calendar_code);
109: msc_sch_wb.atp_debug('l_calendar_exception_set_id'||l_calendar_exception_set_id);
110: msc_sch_wb.atp_debug('l_default_demand_class'||l_default_demand_class);
111: msc_sch_wb.atp_debug('l_org_code'||l_org_code);
112: END IF;
113: */
114:
115: BEGIN
196: l_alloc_percent := 0.0;
197: when others then
198: l_alloc_percent := NULL;
199: IF PG_DEBUG in ('Y', 'C') THEN
200: msc_sch_wb.atp_debug('Exception in Get_Item_Demand_Alloc_Percent');
201: END IF;
202: END;
203:
204: IF PG_DEBUG in ('Y', 'C') THEN
201: END IF;
202: END;
203:
204: IF PG_DEBUG in ('Y', 'C') THEN
205: msc_sch_wb.atp_debug('before leave the if, l_alloc_percent = '|| l_alloc_percent);
206: END IF;
207:
208: ELSE
209:
210: -- this is dependent demand, we see how we alocate the parent supply,
211: -- and do the same thing for it's demand
212:
213: IF PG_DEBUG in ('Y', 'C') THEN
214: msc_sch_wb.atp_debug('this is dependent demand');
215: msc_sch_wb.atp_debug('Get_Item_Demand_Alloc_Percent: ' || 'G_TIME_PHASED_PF_ENABLED := ' || MSC_ATP_PVT.G_TIME_PHASED_PF_ENABLED);
216: END IF;
217: -- Check if there is an allocation rule defined at component level.
218: -- If no rule at component level, consider every demand and supply, that means
211: -- and do the same thing for it's demand
212:
213: IF PG_DEBUG in ('Y', 'C') THEN
214: msc_sch_wb.atp_debug('this is dependent demand');
215: msc_sch_wb.atp_debug('Get_Item_Demand_Alloc_Percent: ' || 'G_TIME_PHASED_PF_ENABLED := ' || MSC_ATP_PVT.G_TIME_PHASED_PF_ENABLED);
216: END IF;
217: -- Check if there is an allocation rule defined at component level.
218: -- If no rule at component level, consider every demand and supply, that means
219: -- consider allocation percent to be 1 (100%), else check if there is a rule at
223: p_instance_id, p_inventory_item_id, p_org_id,
224: null, null, p_demand_class, p_demand_date);
225:
226: IF PG_DEBUG in ('Y', 'C') THEN
227: msc_sch_wb.atp_debug('before entering the parent if, l_alloc_percent = '||l_alloc_percent);
228: END IF;
229:
230: IF l_alloc_percent IS NOT NULL THEN
231: */
245: null, null,p_demand_class, p_demand_date), l_alloc_rule);
246: END IF;
247:
248: IF PG_DEBUG in ('Y', 'C') THEN
249: msc_sch_wb.atp_debug('before leaving the parent if, l_alloc_percent = '||l_alloc_percent);
250: END IF;
251: /*
252: ELSE
253: l_alloc_percent := 1;
254: END IF;
255: */
256:
257: IF PG_DEBUG in ('Y', 'C') THEN
258: msc_sch_wb.atp_debug('before leave the if, l_alloc_percent = '||l_alloc_percent);
259: END IF;
260:
261: END IF;
262:
260:
261: END IF;
262:
263: IF PG_DEBUG in ('Y', 'C') THEN
264: msc_sch_wb.atp_debug('before returning, l_alloc_percent = '||l_alloc_percent);
265: END IF;
266: return(l_alloc_percent);
267:
268: END Get_Item_Demand_Alloc_Percent;
281: l_rule_name VARCHAR2(30);
282: l_time_phase NUMBER;
283: BEGIN
284: IF PG_DEBUG in ('Y', 'C') THEN
285: msc_sch_wb.atp_debug('***** Get_DC_Alloc_Percent *****');
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
282: l_time_phase NUMBER;
283: BEGIN
284: IF PG_DEBUG in ('Y', 'C') THEN
285: msc_sch_wb.atp_debug('***** Get_DC_Alloc_Percent *****');
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
283: BEGIN
284: IF PG_DEBUG in ('Y', 'C') THEN
285: msc_sch_wb.atp_debug('***** Get_DC_Alloc_Percent *****');
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
284: IF PG_DEBUG in ('Y', 'C') THEN
285: msc_sch_wb.atp_debug('***** Get_DC_Alloc_Percent *****');
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
292: msc_sch_wb.atp_debug('p_request_date =' || p_request_date );
285: msc_sch_wb.atp_debug('***** Get_DC_Alloc_Percent *****');
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
292: msc_sch_wb.atp_debug('p_request_date =' || p_request_date );
293: END IF;
286: msc_sch_wb.atp_debug('p_instance_id =' || p_instance_id);
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
292: msc_sch_wb.atp_debug('p_request_date =' || p_request_date );
293: END IF;
294:
287: msc_sch_wb.atp_debug('p_inv_item_id =' || p_inv_item_id);
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
292: msc_sch_wb.atp_debug('p_request_date =' || p_request_date );
293: END IF;
294:
295: --IF p_inv_item_id is not null THEN placed down
288: msc_sch_wb.atp_debug('p_org_id =' || p_org_id);
289: msc_sch_wb.atp_debug('p_dept_id =' || p_dept_id);
290: msc_sch_wb.atp_debug('p_res_id =' || p_res_id);
291: msc_sch_wb.atp_debug('p_demand_class =' || p_demand_class);
292: msc_sch_wb.atp_debug('p_request_date =' || p_request_date );
293: END IF;
294:
295: --IF p_inv_item_id is not null THEN placed down
296: -- Get the allocation percent for the item/demand class. If no rule found,
320: IF p_inv_item_id is not null THEN
321: IF G_HIERARCHY_PROFILE = 1 THEN ---bug3099066
322: BEGIN ---Bug 3099066
323: IF PG_DEBUG in ('Y', 'C') THEN
324: msc_sch_wb.atp_debug('Get the Allocation on Request Date');
325: END IF;
326:
327: SELECT allocation_percent/100
328: INTO l_alloc_percent
335: AND p_request_date between effective_date and disable_date;
336: EXCEPTION
337: WHEN NO_DATA_FOUND THEN
338: IF PG_DEBUG in ('Y', 'C') THEN
339: msc_sch_wb.atp_debug('Inside Exception Get the Allocation on Sysdate');
340: END IF;
341: IF (p_request_date < trunc(sysdate)) THEN
342: IF PG_DEBUG in ('Y', 'C') THEN
343: msc_sch_wb.atp_debug('Inside IF of Exception');
339: msc_sch_wb.atp_debug('Inside Exception Get the Allocation on Sysdate');
340: END IF;
341: IF (p_request_date < trunc(sysdate)) THEN
342: IF PG_DEBUG in ('Y', 'C') THEN
343: msc_sch_wb.atp_debug('Inside IF of Exception');
344: END IF;
345:
346: BEGIN
347:
369: AND level_id = -1;
370: END;
371: ELSE
372: IF PG_DEBUG in ('Y', 'C') THEN
373: msc_sch_wb.atp_debug('Inside Else of Exception');
374: END IF;
375:
376: SELECT DECODE(count(allocation_percent), 0, NULL, 0)
377: INTO l_alloc_percent
385: END;
386: ELSE
387: BEGIN ---Bug 3099066
388: IF PG_DEBUG in ('Y', 'C') THEN
389: msc_sch_wb.atp_debug('Get the Allocation on Request Date:2');
390: END IF;
391:
392: SELECT allocation_percent/100
393: INTO l_alloc_percent
401: EXCEPTION
402:
403: WHEN NO_DATA_FOUND THEN
404: IF PG_DEBUG in ('Y', 'C') THEN
405: msc_sch_wb.atp_debug('Get the Allocation on Sysdate:2');
406: END IF;
407:
408: IF (p_request_date < trunc(sysdate)) THEN
409: BEGIN
449: ELSE
450: IF G_HIERARCHY_PROFILE = 1 THEN ---bug3333114 start
451: BEGIN
452: IF PG_DEBUG in ('Y', 'C') THEN
453: msc_sch_wb.atp_debug('Get the Allocation on Request Date:1');
454: END IF;
455:
456: SELECT allocation_percent/100
457: INTO l_alloc_percent
466:
467: EXCEPTION
468: WHEN NO_DATA_FOUND THEN
469: IF PG_DEBUG in ('Y', 'C') THEN
470: msc_sch_wb.atp_debug('Get the Allocation on Sysdate:1');
471: END IF;
472: IF (p_request_date < trunc(sysdate)) THEN
473: IF PG_DEBUG in ('Y', 'C') THEN
474: msc_sch_wb.atp_debug('Inside IF');
470: msc_sch_wb.atp_debug('Get the Allocation on Sysdate:1');
471: END IF;
472: IF (p_request_date < trunc(sysdate)) THEN
473: IF PG_DEBUG in ('Y', 'C') THEN
474: msc_sch_wb.atp_debug('Inside IF');
475: END IF;
476: BEGIN
477: SELECT allocation_percent/100
478: INTO l_alloc_percent
498: AND level_id = -1;
499: END;
500: ELSE
501: IF PG_DEBUG in ('Y', 'C') THEN
502: msc_sch_wb.atp_debug('Inside Else');
503: END IF;
504:
505: SELECT DECODE(count(allocation_percent), 0, NULL, 0)
506: INTO l_alloc_percent
515: END;
516: ELSE
517: BEGIN
518: IF PG_DEBUG in ('Y', 'C') THEN
519: msc_sch_wb.atp_debug('Get the Allocation on Request Date:2');
520: END IF;
521: SELECT allocation_percent/100
522: INTO l_alloc_percent
523: FROM msc_resource_hierarchy_mv
530: AND p_request_date between effective_date and disable_date;
531: EXCEPTION
532: WHEN NO_DATA_FOUND THEN
533: IF PG_DEBUG in ('Y', 'C') THEN
534: msc_sch_wb.atp_debug('Get the Allocation on Sysdate:2');
535: END IF;
536:
537: IF (p_request_date < trunc(sysdate)) THEN
538:
574: END;
575: END IF;
576: END IF; --bug3333114 end
577: IF PG_DEBUG in ('Y', 'C') THEN
578: msc_sch_wb.atp_debug('Call to alloc:' || to_char(l_alloc_percent));
579: END IF;
580: return (l_alloc_percent);
581:
582: EXCEPTION
581:
582: EXCEPTION
583: WHEN OTHERS THEN
584: IF PG_DEBUG in ('Y', 'C') THEN
585: msc_sch_wb.atp_debug('Error code:' || to_char(sqlcode));
586: END IF;
587: return(0.0);
588: END Get_DC_Alloc_Percent;
589:
602: l_alloc_percent NUMBER;
603: BEGIN
604:
605: IF PG_DEBUG in ('Y', 'C') THEN
606: msc_sch_wb.atp_debug('******** Get_Res_demand_Alloc_Percent ********');
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
603: BEGIN
604:
605: IF PG_DEBUG in ('Y', 'C') THEN
606: msc_sch_wb.atp_debug('******** Get_Res_demand_Alloc_Percent ********');
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
604:
605: IF PG_DEBUG in ('Y', 'C') THEN
606: msc_sch_wb.atp_debug('******** Get_Res_demand_Alloc_Percent ********');
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
605: IF PG_DEBUG in ('Y', 'C') THEN
606: msc_sch_wb.atp_debug('******** Get_Res_demand_Alloc_Percent ********');
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
606: msc_sch_wb.atp_debug('******** Get_Res_demand_Alloc_Percent ********');
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
614: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_class =' || p_demand_class);
607: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_date =' || p_demand_date );
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
614: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_class =' || p_demand_class);
615: END IF;
608: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_assembly_item_id =' || p_assembly_item_id);
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
614: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_class =' || p_demand_class);
615: END IF;
616:
609: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_org_id =' || p_org_id);
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
614: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_class =' || p_demand_class);
615: END IF;
616:
617: --Check if there is any allocation rule for the resource
610: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_instance_id =' || p_instance_id);
611: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_dept_id =' || p_dept_id);
612: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_res_id =' || p_res_id);
613: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_record_class =' || p_record_class);
614: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'p_demand_class =' || p_demand_class);
615: END IF;
616:
617: --Check if there is any allocation rule for the resource
618:
619: l_alloc_rule := MSC_AATP_FUNC.Get_DC_Alloc_Percent(p_instance_id, null, p_org_id, p_dept_id,
620: p_res_id, p_demand_class, p_demand_date);
621:
622: IF PG_DEBUG in ('Y', 'C') THEN
623: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'After resource DC Alloc rule :' ||to_char(l_alloc_rule));
624: END IF;
625: IF l_alloc_rule IS NULL THEN
626: --For Bug # 1409203, if no rule at resource level
627: --every supply demand must be counted.
634: -- and do the same thing for its demand
635: l_alloc_percent := NVL(MSC_AATP_FUNC.Get_DC_Alloc_Percent(p_instance_id, p_assembly_item_id, p_org_id,
636: null, null, p_demand_class, p_demand_date), l_alloc_rule);
637: IF PG_DEBUG in ('Y', 'C') THEN
638: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'After parent item DC Alloc Percent :' ||to_char(l_alloc_percent));
639: END IF;
640: END IF;
641: /*
642: -- If no allocation percentage specified for any demand classes for
647: p_dept_id, p_res_id, p_demand_class, p_demand_date);
648: END IF;
649: */
650: IF PG_DEBUG in ('Y', 'C') THEN
651: msc_sch_wb.atp_debug('Get_Res_Demand_Alloc_Percent: ' || 'Before Leaving Res Demand Alloc Percent :' ||to_char(l_alloc_percent));
652: END IF;
653: return (l_alloc_percent);
654:
655: END GET_RES_DEMAND_ALLOC_PERCENT;
674: l_time_phase_id NUMBER;
675: l_temp NUMBER := 0;
676: BEGIN
677: IF PG_DEBUG in ('Y', 'C') THEN
678: msc_sch_wb.atp_debug('BEGIN Get_Hierarchy_Demand_Class');
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
675: l_temp NUMBER := 0;
676: BEGIN
677: IF PG_DEBUG in ('Y', 'C') THEN
678: msc_sch_wb.atp_debug('BEGIN Get_Hierarchy_Demand_Class');
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
676: BEGIN
677: IF PG_DEBUG in ('Y', 'C') THEN
678: msc_sch_wb.atp_debug('BEGIN Get_Hierarchy_Demand_Class');
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
677: IF PG_DEBUG in ('Y', 'C') THEN
678: msc_sch_wb.atp_debug('BEGIN Get_Hierarchy_Demand_Class');
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
678: msc_sch_wb.atp_debug('BEGIN Get_Hierarchy_Demand_Class');
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
686: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
679: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_inventory_item_id : ' ||p_inventory_item_id);
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
686: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
687: END IF;
680: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
686: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
687: END IF;
688:
681: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
686: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
687: END IF;
688:
689:
682: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
683: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
684: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
685: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
686: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
687: END IF;
688:
689:
690: -- now this function supports 2 functionalities.
717: MSC_ATP_PVT.G_ALLOCATION_RULE_NAME := null;
718: END;
719:
720: IF PG_DEBUG in ('Y', 'C') THEN
721: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_time_phase_id '||l_time_phase_id);
722: END IF;
723:
724: IF l_time_phase_id IS NOT NULL THEN
725:
745:
746: END IF;
747:
748: IF PG_DEBUG in ('Y', 'C') THEN
749: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||
750: l_hierarchy_demand_class);
751: END IF;
752:
753: ELSIF (G_HIERARCHY_PROFILE = 2) THEN
766: END;
767: END IF; -- IF p_customer_id IS NOT NULL
768:
769: IF PG_DEBUG in ('Y', 'C') THEN
770: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_class_code '||l_class_code);
771: END IF;
772:
773: BEGIN
774: --diag_atp
790: -- we won't find the dummy demand class
791: END;
792:
793: IF PG_DEBUG in ('Y', 'C') THEN
794: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_time_phase_id '||l_time_phase_id);
795: END IF;
796:
797: IF (p_partner_id IS NOT NULL AND p_level_id is null) OR
798: (p_level_id in (2, 3)) THEN -- level 2 + level 3
802: -- level 3
803: -- try to find the match demand class for
804: -- that class_code+partner_id+partner_site_id
805: IF PG_DEBUG in ('Y', 'C') THEN
806: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3');
807: END IF;
808:
809: BEGIN
810: SELECT distinct demand_class
822: l_hierarchy_demand_class := null;
823: END;
824:
825: IF PG_DEBUG in ('Y', 'C') THEN
826: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the first select');
827: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
828: END IF;
829:
830:
823: END;
824:
825: IF PG_DEBUG in ('Y', 'C') THEN
826: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the first select');
827: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
828: END IF;
829:
830:
831: IF l_hierarchy_demand_class IS NULL THEN
833: -- for class_code+partner_id+partner_site_id
834: -- try to find the match demand class for that
835: -- class_code+partner_id+others
836: IF PG_DEBUG in ('Y', 'C') THEN
837: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, first select fails');
838: END IF;
839:
840: BEGIN
841: SELECT distinct demand_class
851: l_hierarchy_demand_class := null;
852: END;
853:
854: IF PG_DEBUG in ('Y', 'C') THEN
855: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the second select');
856: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
857: END IF;
858:
859: END IF; -- IF l_hierarchy_demand_class IS NULL
852: END;
853:
854: IF PG_DEBUG in ('Y', 'C') THEN
855: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the second select');
856: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
857: END IF;
858:
859: END IF; -- IF l_hierarchy_demand_class IS NULL
860:
865:
866: -- try to find the match demand class for that
867: -- class_code+others+others
868: IF PG_DEBUG in ('Y', 'C') THEN
869: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, second select fails');
870: END IF;
871:
872: -- bug 1680773
873: -- before we try class+others+others,
891:
892: BEGIN
893:
894: IF PG_DEBUG in ('Y', 'C') THEN
895: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_time_phase_id = '||l_time_phase_id);
896: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_class_code = '||l_class_code);
897: END IF;
898: SELECT distinct demand_class
899: INTO l_hierarchy_demand_class
892: BEGIN
893:
894: IF PG_DEBUG in ('Y', 'C') THEN
895: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_time_phase_id = '||l_time_phase_id);
896: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_class_code = '||l_class_code);
897: END IF;
898: SELECT distinct demand_class
899: INTO l_hierarchy_demand_class
900: FROM msc_allocations
905: AND partner_site_id = -1;
906: EXCEPTION
907: WHEN NO_DATA_FOUND THEN
908: IF PG_DEBUG in ('Y', 'C') THEN
909: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'NO DATA FOUND');
910: END IF;
911: -- no match for
912: -- class_code + other+other
913: l_hierarchy_demand_class := null;
920: END IF; */
921:
922:
923: IF PG_DEBUG in ('Y', 'C') THEN
924: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the third select');
925: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
926: END IF;
927:
928:
921:
922:
923: IF PG_DEBUG in ('Y', 'C') THEN
924: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the third select');
925: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
926: END IF;
927:
928:
929: END IF; -- l_hierarchy_demand_class IS NULL THEN
946: -- match to 0 percent.
947: -- if no, then find others+others+others
948:
949: IF PG_DEBUG in ('Y', 'C') THEN
950: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, third select fails');
951: END IF;
952:
953: /*SELECT count(*)
954: INTO l_temp
982: l_hierarchy_demand_class := '-1';
983: END IF;
984: */
985: IF PG_DEBUG in ('Y', 'C') THEN
986: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the 4th select');
987: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
988: END IF;
989:
990:
983: END IF;
984: */
985: IF PG_DEBUG in ('Y', 'C') THEN
986: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 3, after the 4th select');
987: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
988: END IF;
989:
990:
991: END IF; -- IF l_hierarchy_demand_class IS NULL
992: ELSIF (p_partner_site_id IS NULL AND p_level_id is null) OR
993: (p_level_id = 2) THEN
994:
995: IF PG_DEBUG in ('Y', 'C') THEN
996: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2');
997: END IF;
998:
999: -- level 2
1000: -- try to find the match demand class for
1014: l_hierarchy_demand_class := null;
1015: END;
1016:
1017: IF PG_DEBUG in ('Y', 'C') THEN
1018: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the first select');
1019: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1020: END IF;
1021:
1022: IF l_hierarchy_demand_class IS NULL THEN
1015: END;
1016:
1017: IF PG_DEBUG in ('Y', 'C') THEN
1018: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the first select');
1019: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1020: END IF;
1021:
1022: IF l_hierarchy_demand_class IS NULL THEN
1023: -- could not find the match demand class
1025: -- try to find the match demand class for that
1026: -- class_code+others
1027:
1028: IF PG_DEBUG in ('Y', 'C') THEN
1029: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, first select fails');
1030: END IF;
1031:
1032: BEGIN
1033: SELECT distinct demand_class
1041: WHEN NO_DATA_FOUND THEN
1042: l_hierarchy_demand_class := null;
1043: END;
1044: IF PG_DEBUG in ('Y', 'C') THEN
1045: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the second select');
1046: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1047: END IF;
1048:
1049: END IF; -- IF l_hierarchy_demand_class IS NULL
1042: l_hierarchy_demand_class := null;
1043: END;
1044: IF PG_DEBUG in ('Y', 'C') THEN
1045: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the second select');
1046: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1047: END IF;
1048:
1049: END IF; -- IF l_hierarchy_demand_class IS NULL
1050: -- bug 1680773
1059: -- match to 0 percent.
1060: -- if no, then find others+others
1061:
1062: IF PG_DEBUG in ('Y', 'C') THEN
1063: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, second select fails');
1064: END IF;
1065: /*
1066: SELECT count(*)
1067: INTO l_temp
1096: l_hierarchy_demand_class := '-1';
1097: END IF;
1098: */
1099: IF PG_DEBUG in ('Y', 'C') THEN
1100: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the third select');
1101: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1102: END IF;
1103: END IF; -- IF l_hierarchy_demand_class IS NULL
1104:
1097: END IF;
1098: */
1099: IF PG_DEBUG in ('Y', 'C') THEN
1100: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 2, after the third select');
1101: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1102: END IF;
1103: END IF; -- IF l_hierarchy_demand_class IS NULL
1104:
1105: END IF; -- IF (p_partner_site_id IS NOT NULL AND p_level_id is null)
1113: -- partner_id, assume it is others
1114: -- find the match demand class for others
1115:
1116: IF PG_DEBUG in ('Y', 'C') THEN
1117: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 1');
1118: END IF;
1119: IF p_level_id = 1 THEN
1120: BEGIN
1121: SELECT distinct demand_class
1129: l_hierarchy_demand_class := null;
1130: END;
1131:
1132: IF PG_DEBUG in ('Y', 'C') THEN
1133: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 1, after the first select');
1134: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1135: END IF;
1136:
1137: END IF;
1130: END;
1131:
1132: IF PG_DEBUG in ('Y', 'C') THEN
1133: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 1, after the first select');
1134: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1135: END IF;
1136:
1137: END IF;
1138:
1154:
1155: END IF; -- IF l_hierarchy_demand_class IS NULL
1156:
1157: IF PG_DEBUG in ('Y', 'C') THEN
1158: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 1, after the second select');
1159: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1160: END IF;
1161:
1162: END IF; -- IF p_partner_id IS NOT NULL THEN
1155: END IF; -- IF l_hierarchy_demand_class IS NULL
1156:
1157: IF PG_DEBUG in ('Y', 'C') THEN
1158: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'level 1, after the second select');
1159: msc_sch_wb.atp_debug('Get_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1160: END IF;
1161:
1162: END IF; -- IF p_partner_id IS NOT NULL THEN
1163: END IF; -- IF (G_HIERARCHY_PROFILE = 1)
1162: END IF; -- IF p_partner_id IS NOT NULL THEN
1163: END IF; -- IF (G_HIERARCHY_PROFILE = 1)
1164:
1165: IF PG_DEBUG in ('Y', 'C') THEN
1166: msc_sch_wb.atp_debug('END Get_Hierarchy_Demand_Class');
1167: END IF;
1168: --bug 2424357: trat others as -1
1169: --RETURN NVL(l_hierarchy_demand_class, '@@@'); -- 1680773
1170: RETURN NVL(l_hierarchy_demand_class, '-1'); -- 1680773
1185: l_alloc_percent NUMBER := 0.0;
1186: l_rule_name VARCHAR2(30);
1187: BEGIN
1188: IF PG_DEBUG in ('Y', 'C') THEN
1189: msc_sch_wb.atp_debug('******** Get_Allowed_Stolen_Percent ********');
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1186: l_rule_name VARCHAR2(30);
1187: BEGIN
1188: IF PG_DEBUG in ('Y', 'C') THEN
1189: msc_sch_wb.atp_debug('******** Get_Allowed_Stolen_Percent ********');
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1187: BEGIN
1188: IF PG_DEBUG in ('Y', 'C') THEN
1189: msc_sch_wb.atp_debug('******** Get_Allowed_Stolen_Percent ********');
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1188: IF PG_DEBUG in ('Y', 'C') THEN
1189: msc_sch_wb.atp_debug('******** Get_Allowed_Stolen_Percent ********');
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1196: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_request_date =' || p_request_date );
1189: msc_sch_wb.atp_debug('******** Get_Allowed_Stolen_Percent ********');
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1196: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_request_date =' || p_request_date );
1197: END IF;
1190: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_instance_id =' || p_instance_id);
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1196: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_request_date =' || p_request_date );
1197: END IF;
1198:
1191: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_inv_item_id =' || p_inv_item_id);
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1196: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_request_date =' || p_request_date );
1197: END IF;
1198:
1199: IF p_inv_item_id is not null THEN
1192: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_org_id =' || p_org_id);
1193: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_dept_id =' || p_dept_id);
1194: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_res_id =' || p_res_id);
1195: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_demand_class =' || p_demand_class);
1196: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'p_request_date =' || p_request_date );
1197: END IF;
1198:
1199: IF p_inv_item_id is not null THEN
1200: -- Get the allocation percent for the item/demand class. If no rule found,
1260: -- Changes For bug 2384551 end
1261: WHEN OTHERS THEN
1262: l_alloc_percent := NULL;
1263: IF PG_DEBUG in ('Y', 'C') THEN
1264: msc_sch_wb.atp_debug('Exception in Get_Allowed_Stolen_Percent');
1265: END IF;
1266: END;
1267:
1268: ELSE
1329: -- Changes For bug 2384551 end
1330: WHEN OTHERS THEN
1331: l_alloc_percent := NULL;
1332: IF PG_DEBUG in ('Y', 'C') THEN
1333: msc_sch_wb.atp_debug('Exception in Get_Allowed_Stolen_Percent');
1334: END IF;
1335: END;
1336:
1337: END IF;
1335: END;
1336:
1337: END IF;
1338: IF PG_DEBUG in ('Y', 'C') THEN
1339: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'Call to alloc:' || to_char(l_alloc_percent));
1340: END IF;
1341: return (l_alloc_percent);
1342: EXCEPTION
1343: WHEN OTHERS THEN
1341: return (l_alloc_percent);
1342: EXCEPTION
1343: WHEN OTHERS THEN
1344: IF PG_DEBUG in ('Y', 'C') THEN
1345: msc_sch_wb.atp_debug('Get_Allowed_Stolen_Percent: ' || 'Error code:' || to_char(sqlcode));
1346: END IF;
1347: return(0.0);
1348: END Get_Allowed_Stolen_Percent;
1349:
1369: l_time_phase_id NUMBER;
1370: l_temp NUMBER := 0;
1371: BEGIN
1372: IF PG_DEBUG in ('Y', 'C') THEN
1373: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'BEGIN Get_Hierarchy_Demand_Class');
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1370: l_temp NUMBER := 0;
1371: BEGIN
1372: IF PG_DEBUG in ('Y', 'C') THEN
1373: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'BEGIN Get_Hierarchy_Demand_Class');
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1371: BEGIN
1372: IF PG_DEBUG in ('Y', 'C') THEN
1373: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'BEGIN Get_Hierarchy_Demand_Class');
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1372: IF PG_DEBUG in ('Y', 'C') THEN
1373: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'BEGIN Get_Hierarchy_Demand_Class');
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1373: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'BEGIN Get_Hierarchy_Demand_Class');
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1374: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_department_id : ' ||p_department_id);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1382: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
1375: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_resource_id : ' ||p_resource_id);
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1382: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
1383: END IF;
1376: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_id : ' ||p_partner_id);
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1382: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
1383: END IF;
1384:
1377: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_partner_site_id : ' ||p_partner_site_id);
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1382: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
1383: END IF;
1384:
1385:
1378: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_request_date : ' ||p_request_date);
1379: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_organization_id : ' ||p_organization_id);
1380: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_instance_id : ' ||p_instance_id);
1381: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_level_id : ' ||p_level_id);
1382: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'p_demand_class : ' ||p_demand_class);
1383: END IF;
1384:
1385:
1386: -- now this function supports 2 functionalities.
1416: MSC_ATP_PVT.G_ALLOCATION_RULE_NAME := null;
1417: END;
1418:
1419: IF PG_DEBUG in ('Y', 'C') THEN
1420: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_time_phase_id '||l_time_phase_id);
1421: END IF;
1422:
1423: IF l_time_phase_id IS NOT NULL THEN
1424:
1444:
1445: END IF;
1446:
1447: IF PG_DEBUG in ('Y', 'C') THEN
1448: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||
1449: l_hierarchy_demand_class);
1450: END IF;
1451:
1452: ELSIF (G_HIERARCHY_PROFILE = 2) THEN
1465: END;
1466: END IF; -- IF p_customer_id IS NOT NULL
1467:
1468: IF PG_DEBUG in ('Y', 'C') THEN
1469: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_class_code '||l_class_code);
1470: END IF;
1471:
1472: BEGIN
1473:
1490: -- we won't find the dummy demand class
1491: END;
1492:
1493: IF PG_DEBUG in ('Y', 'C') THEN
1494: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_time_phase_id '||l_time_phase_id);
1495: END IF;
1496:
1497: IF (p_partner_id IS NOT NULL AND p_level_id is null) OR
1498: (p_level_id in (2, 3)) THEN -- level 2 + level 3
1502: -- level 3
1503: -- try to find the match demand class for
1504: -- that class_code+partner_id+partner_site_id
1505: IF PG_DEBUG in ('Y', 'C') THEN
1506: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3');
1507: END IF;
1508:
1509: BEGIN
1510: SELECT distinct demand_class
1522: l_hierarchy_demand_class := null;
1523: END;
1524:
1525: IF PG_DEBUG in ('Y', 'C') THEN
1526: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the first select');
1527: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1528: END IF;
1529:
1530:
1523: END;
1524:
1525: IF PG_DEBUG in ('Y', 'C') THEN
1526: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the first select');
1527: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1528: END IF;
1529:
1530:
1531: IF l_hierarchy_demand_class IS NULL THEN
1533: -- for class_code+partner_id+partner_site_id
1534: -- try to find the match demand class for that
1535: -- class_code+partner_id+others
1536: IF PG_DEBUG in ('Y', 'C') THEN
1537: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, first select fails');
1538: END IF;
1539:
1540: BEGIN
1541: SELECT distinct demand_class
1551: l_hierarchy_demand_class := null;
1552: END;
1553:
1554: IF PG_DEBUG in ('Y', 'C') THEN
1555: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the second select');
1556: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1557: END IF;
1558:
1559: END IF; -- IF l_hierarchy_demand_class IS NULL
1552: END;
1553:
1554: IF PG_DEBUG in ('Y', 'C') THEN
1555: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the second select');
1556: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1557: END IF;
1558:
1559: END IF; -- IF l_hierarchy_demand_class IS NULL
1560:
1565:
1566: -- try to find the match demand class for that
1567: -- class_code+others+others
1568: IF PG_DEBUG in ('Y', 'C') THEN
1569: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, second select fails');
1570: END IF;
1571:
1572: BEGIN
1573:
1571:
1572: BEGIN
1573:
1574: IF PG_DEBUG in ('Y', 'C') THEN
1575: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_time_phase_id = '||l_time_phase_id);
1576: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_class_code = '||l_class_code);
1577: END IF;
1578: SELECT distinct demand_class
1579: INTO l_hierarchy_demand_class
1572: BEGIN
1573:
1574: IF PG_DEBUG in ('Y', 'C') THEN
1575: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_time_phase_id = '||l_time_phase_id);
1576: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_class_code = '||l_class_code);
1577: END IF;
1578: SELECT distinct demand_class
1579: INTO l_hierarchy_demand_class
1580: FROM msc_allocations
1585: AND partner_site_id = -1;
1586: EXCEPTION
1587: WHEN NO_DATA_FOUND THEN
1588: IF PG_DEBUG in ('Y', 'C') THEN
1589: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'NO DATA FOUND');
1590: END IF;
1591: -- no match for
1592: -- class_code + other+other
1593: l_hierarchy_demand_class := null;
1595:
1596:
1597:
1598: IF PG_DEBUG in ('Y', 'C') THEN
1599: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the third select');
1600: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1601: END IF;
1602:
1603:
1596:
1597:
1598: IF PG_DEBUG in ('Y', 'C') THEN
1599: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the third select');
1600: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1601: END IF;
1602:
1603:
1604: END IF; -- l_hierarchy_demand_class IS NULL THEN
1613: -- try to find the match demand class for that
1614: -- others+others+others
1615:
1616: IF PG_DEBUG in ('Y', 'C') THEN
1617: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, third select fails');
1618: END IF;
1619:
1620: BEGIN
1621: SELECT distinct demand_class
1631: l_hierarchy_demand_class := '-1';
1632: END;
1633:
1634: IF PG_DEBUG in ('Y', 'C') THEN
1635: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the 4th select');
1636: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1637: END IF;
1638:
1639:
1632: END;
1633:
1634: IF PG_DEBUG in ('Y', 'C') THEN
1635: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 3, after the 4th select');
1636: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1637: END IF;
1638:
1639:
1640: END IF; -- IF l_hierarchy_demand_class IS NULL
1641: ELSIF (p_partner_site_id IS NULL AND p_level_id is null) OR
1642: (p_level_id = 2) THEN
1643:
1644: IF PG_DEBUG in ('Y', 'C') THEN
1645: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2');
1646: END IF;
1647:
1648: -- level 2
1649: -- try to find the match demand class for
1663: l_hierarchy_demand_class := null;
1664: END;
1665:
1666: IF PG_DEBUG in ('Y', 'C') THEN
1667: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the first select');
1668: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1669: END IF;
1670:
1671: IF l_hierarchy_demand_class IS NULL THEN
1664: END;
1665:
1666: IF PG_DEBUG in ('Y', 'C') THEN
1667: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the first select');
1668: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1669: END IF;
1670:
1671: IF l_hierarchy_demand_class IS NULL THEN
1672: -- could not find the match demand class
1674: -- try to find the match demand class for that
1675: -- class_code+others
1676:
1677: IF PG_DEBUG in ('Y', 'C') THEN
1678: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, first select fails');
1679: END IF;
1680:
1681: BEGIN
1682: SELECT distinct demand_class
1690: WHEN NO_DATA_FOUND THEN
1691: l_hierarchy_demand_class := null;
1692: END;
1693: IF PG_DEBUG in ('Y', 'C') THEN
1694: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the second select');
1695: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1696: END IF;
1697:
1698: END IF; -- IF l_hierarchy_demand_class IS NULL
1691: l_hierarchy_demand_class := null;
1692: END;
1693: IF PG_DEBUG in ('Y', 'C') THEN
1694: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the second select');
1695: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1696: END IF;
1697:
1698: END IF; -- IF l_hierarchy_demand_class IS NULL
1699: -- bug 1680773
1702: -- for (class_code+partner_id) and
1703: -- (class_code+others )
1704:
1705: IF PG_DEBUG in ('Y', 'C') THEN
1706: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, second select fails');
1707: END IF;
1708:
1709: BEGIN
1710: SELECT distinct demand_class
1719: l_hierarchy_demand_class := '-1';
1720:
1721: END;
1722: IF PG_DEBUG in ('Y', 'C') THEN
1723: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the third select');
1724: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1725: END IF;
1726: END IF; -- IF l_hierarchy_demand_class IS NULL
1727:
1720:
1721: END;
1722: IF PG_DEBUG in ('Y', 'C') THEN
1723: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 2, after the third select');
1724: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1725: END IF;
1726: END IF; -- IF l_hierarchy_demand_class IS NULL
1727:
1728: END IF; -- IF (p_partner_site_id IS NOT NULL AND p_level_id is null)
1736: -- partner_id, assume it is others
1737: -- find the match demand class for others
1738:
1739: IF PG_DEBUG in ('Y', 'C') THEN
1740: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 1');
1741: END IF;
1742: IF p_level_id = 1 THEN
1743: BEGIN
1744: SELECT distinct demand_class
1752: l_hierarchy_demand_class := null;
1753: END;
1754:
1755: IF PG_DEBUG in ('Y', 'C') THEN
1756: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 1, after the first select');
1757: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1758: END IF;
1759:
1760: END IF;
1753: END;
1754:
1755: IF PG_DEBUG in ('Y', 'C') THEN
1756: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 1, after the first select');
1757: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1758: END IF;
1759:
1760: END IF;
1761:
1776:
1777: END IF; -- IF l_hierarchy_demand_class IS NULL
1778:
1779: IF PG_DEBUG in ('Y', 'C') THEN
1780: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 1, after the second select');
1781: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1782: END IF;
1783:
1784: END IF; -- IF p_partner_id IS NOT NULL THEN
1777: END IF; -- IF l_hierarchy_demand_class IS NULL
1778:
1779: IF PG_DEBUG in ('Y', 'C') THEN
1780: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'level 1, after the second select');
1781: msc_sch_wb.atp_debug('Get_Res_Hierarchy_Demand_Class: ' || 'l_hierarchy_demand_class = '||l_hierarchy_demand_class);
1782: END IF;
1783:
1784: END IF; -- IF p_partner_id IS NOT NULL THEN
1785: END IF; -- IF (G_HIERARCHY_PROFILE = 1)
1784: END IF; -- IF p_partner_id IS NOT NULL THEN
1785: END IF; -- IF (G_HIERARCHY_PROFILE = 1)
1786:
1787: IF PG_DEBUG in ('Y', 'C') THEN
1788: msc_sch_wb.atp_debug('END Get_RES_Hierarchy_Demand_Class');
1789: END IF;
1790: --bug 2424357: trat others as -1
1791: --RETURN NVL(l_hierarchy_demand_class, '@@@'); -- 1680773
1792: RETURN NVL(l_hierarchy_demand_class, '-1'); -- 1680773