54: least(l_qty, l_PO_qty);
55: END IF;
56: --bug3467631
57: IF PG_DEBUG in ('Y', 'C') THEN
58: msc_sch_wb.atp_debug('qty_from_children(' ||l_parent||'): ' ||
59: p_org_avail_info.quantity_from_children(l_parent));
60: msc_sch_wb.atp_debug('rnding_leftover(' ||j||'): ' ||
61: p_org_avail_info.rnding_leftover(j));
62: END IF;
56: --bug3467631
57: IF PG_DEBUG in ('Y', 'C') THEN
58: msc_sch_wb.atp_debug('qty_from_children(' ||l_parent||'): ' ||
59: p_org_avail_info.quantity_from_children(l_parent));
60: msc_sch_wb.atp_debug('rnding_leftover(' ||j||'): ' ||
61: p_org_avail_info.rnding_leftover(j));
62: END IF;
63: j := l_parent;
64: end loop;
73: l_qty number;
74: l_parent number;
75: BEGIN
76: IF p_org_idx = 1 THEN
77: msc_sch_wb.atp_debug('req_dmd_qty1: ' || p_qty);
78: return p_qty;
79: END IF;
80:
81: l_parent := p_org_avail_info.parent_org_idx(p_org_idx);
83: IF nvl(p_org_avail_info.rounding_flag(l_parent), 2) = 1 THEN
84: l_qty := CEIL(l_qty);
85: END IF;
86:
87: msc_sch_wb.atp_debug('req_dmd_qty0: ' || l_qty);
88: l_qty := l_qty * p_org_avail_info.conversion_rate(p_org_idx);
89: l_qty := l_qty - nvl(p_org_avail_info.rnding_leftover(p_org_idx),0);
90:
91: msc_sch_wb.atp_debug('rnding_leftover('||p_org_idx||'): ' || nvl(p_org_avail_info.rnding_leftover(p_org_idx),0));
87: msc_sch_wb.atp_debug('req_dmd_qty0: ' || l_qty);
88: l_qty := l_qty * p_org_avail_info.conversion_rate(p_org_idx);
89: l_qty := l_qty - nvl(p_org_avail_info.rnding_leftover(p_org_idx),0);
90:
91: msc_sch_wb.atp_debug('rnding_leftover('||p_org_idx||'): ' || nvl(p_org_avail_info.rnding_leftover(p_org_idx),0));
92: msc_sch_wb.atp_debug('req_dmd_qty: ' || l_qty);
93: return l_qty;
94: END org_req_dmd_qty;
95:
88: l_qty := l_qty * p_org_avail_info.conversion_rate(p_org_idx);
89: l_qty := l_qty - nvl(p_org_avail_info.rnding_leftover(p_org_idx),0);
90:
91: msc_sch_wb.atp_debug('rnding_leftover('||p_org_idx||'): ' || nvl(p_org_avail_info.rnding_leftover(p_org_idx),0));
92: msc_sch_wb.atp_debug('req_dmd_qty: ' || l_qty);
93: return l_qty;
94: END org_req_dmd_qty;
95:
96: PROCEDURE Extend_Org_Avail_Info_Rec (
208: x_pegging_rec.aggregate_time_fence_date:= org_avail_info.Atf_Date(p_org_idx);
209: --populating atf date in pegging as records are deleted from alloc table
210: --based on atf date also.
211: IF PG_DEBUG in ('Y', 'C') THEN
212: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'Atf_Date ' || org_avail_info.Atf_Date(p_org_idx));
213: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_id ' || x_pegging_rec.inventory_item_id);
214: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_name ' || x_pegging_rec.inventory_item_name);
215: END IF;
216: --bug3467631 end
209: --populating atf date in pegging as records are deleted from alloc table
210: --based on atf date also.
211: IF PG_DEBUG in ('Y', 'C') THEN
212: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'Atf_Date ' || org_avail_info.Atf_Date(p_org_idx));
213: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_id ' || x_pegging_rec.inventory_item_id);
214: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_name ' || x_pegging_rec.inventory_item_name);
215: END IF;
216: --bug3467631 end
217: END Prep_Common_Pegging_Rec;
210: --based on atf date also.
211: IF PG_DEBUG in ('Y', 'C') THEN
212: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'Atf_Date ' || org_avail_info.Atf_Date(p_org_idx));
213: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_id ' || x_pegging_rec.inventory_item_id);
214: msc_sch_wb.atp_debug('Prep_Common_Pegging_Rec: ' || 'inventory_item_name ' || x_pegging_rec.inventory_item_name);
215: END IF;
216: --bug3467631 end
217: END Prep_Common_Pegging_Rec;
218:
226: p_item_idx In NUMBER
227: ) IS
228: BEGIN
229: IF PG_DEBUG in ('Y', 'C') THEN
230: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec');
231: END IF;
232:
233: Prep_Common_pegging_rec(x_pegging_rec,
234: p_atp_record,
250: THEN
251: x_pegging_rec.inventory_item_id:= org_avail_info.family_sr_id(p_org_idx);
252: x_pegging_rec.inventory_item_name := org_avail_info.family_item_name(p_org_idx);
253: IF PG_DEBUG in ('Y', 'C') THEN
254: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'inventory_item_name ' || org_avail_info.family_item_name(p_org_idx));
255: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_id ' || org_avail_info.family_sr_id(p_org_idx));
256: END IF;
257: END IF;
258: --bug3467631
251: x_pegging_rec.inventory_item_id:= org_avail_info.family_sr_id(p_org_idx);
252: x_pegging_rec.inventory_item_name := org_avail_info.family_item_name(p_org_idx);
253: IF PG_DEBUG in ('Y', 'C') THEN
254: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'inventory_item_name ' || org_avail_info.family_item_name(p_org_idx));
255: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_id ' || org_avail_info.family_sr_id(p_org_idx));
256: END IF;
257: END IF;
258: --bug3467631
259: x_pegging_rec.pegging_id := org_avail_info.demand_pegging_id(p_org_idx);
282:
283: x_pegging_rec.pegging_type := ORG_DEMAND_PEG_TYP;
284:
285: IF PG_DEBUG in ('Y', 'C') THEN
286: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
287: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
288: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
289: END IF;
290:
283: x_pegging_rec.pegging_type := ORG_DEMAND_PEG_TYP;
284:
285: IF PG_DEBUG in ('Y', 'C') THEN
286: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
287: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
288: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
289: END IF;
290:
291: END Prep_Demand_Pegging_Rec;
284:
285: IF PG_DEBUG in ('Y', 'C') THEN
286: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
287: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
288: msc_sch_wb.atp_debug('Prep_Demand_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
289: END IF;
290:
291: END Prep_Demand_Pegging_Rec;
292:
315: ) IS
316: l_parent_idx NUMBER;
317: BEGIN
318: IF PG_DEBUG in ('Y', 'C') THEN
319: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec');
320: END IF;
321:
322: l_parent_idx := org_avail_info.parent_org_idx(p_org_idx);
323:
328: item_availability_info,
329: p_item_idx);
330:
331: IF PG_DEBUG in ('Y', 'C') THEN
332: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
333: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
334: END IF;
335:
336: -- time_phased_atp changes begin
329: p_item_idx);
330:
331: IF PG_DEBUG in ('Y', 'C') THEN
332: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
333: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
334: END IF;
335:
336: -- time_phased_atp changes begin
337: --bug3467631 start
409: END IF;
410: x_pegging_rec.required_date := org_avail_info.requested_ship_date(p_org_idx);
411:
412: IF PG_DEBUG in ('Y', 'C') THEN
413: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'required_quantity: ' || x_pegging_rec.required_quantity);
414: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'required_date: ' || x_pegging_rec.required_date);
415: END IF;
416:
417: x_pegging_rec.pegging_type := 6;
410: x_pegging_rec.required_date := org_avail_info.requested_ship_date(p_org_idx);
411:
412: IF PG_DEBUG in ('Y', 'C') THEN
413: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'required_quantity: ' || x_pegging_rec.required_quantity);
414: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'required_date: ' || x_pegging_rec.required_date);
415: END IF;
416:
417: x_pegging_rec.pegging_type := 6;
418: -- Bug 3826234
421: x_pegging_rec.intransit_cal_code := org_avail_info.intransit_cal_code(p_org_idx);
422: x_pegging_rec.manufacturing_cal_code := org_avail_info.manufacturing_cal_code(p_org_idx);
423:
424: IF PG_DEBUG in ('Y', 'C') THEN
425: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
422: x_pegging_rec.manufacturing_cal_code := org_avail_info.manufacturing_cal_code(p_org_idx);
423:
424: IF PG_DEBUG in ('Y', 'C') THEN
425: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
430: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
423:
424: IF PG_DEBUG in ('Y', 'C') THEN
425: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
430: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
431: END IF;
424: IF PG_DEBUG in ('Y', 'C') THEN
425: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
430: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
431: END IF;
432:
425: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
430: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
431: END IF;
432:
433: END Prep_PO_Pegging_Rec;
426: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
427: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
428: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
429: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
430: msc_sch_wb.atp_debug('Prep_PO_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
431: END IF;
432:
433: END Prep_PO_Pegging_Rec;
434:
443: ) IS
444: l_parent_idx NUMBER;
445: BEGIN
446: IF PG_DEBUG in ('Y', 'C') THEN
447: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec');
448: END IF;
449:
450: l_parent_idx := org_avail_info.parent_org_idx(p_org_idx);
451:
449:
450: l_parent_idx := org_avail_info.parent_org_idx(p_org_idx);
451:
452: IF PG_DEBUG in ('Y', 'C') THEN
453: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
450: l_parent_idx := org_avail_info.parent_org_idx(p_org_idx);
451:
452: IF PG_DEBUG in ('Y', 'C') THEN
453: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
458: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.atf_date(p_item_idx) ' || item_availability_info.atf_date(p_item_idx));
451:
452: IF PG_DEBUG in ('Y', 'C') THEN
453: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
458: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.atf_date(p_item_idx) ' || item_availability_info.atf_date(p_item_idx));
459: END IF;
452: IF PG_DEBUG in ('Y', 'C') THEN
453: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
458: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.atf_date(p_item_idx) ' || item_availability_info.atf_date(p_item_idx));
459: END IF;
460:
453: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_idx ' || l_parent_idx);
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
458: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.atf_date(p_item_idx) ' || item_availability_info.atf_date(p_item_idx));
459: END IF;
460:
461: Prep_Common_pegging_rec(x_pegging_rec,
454: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'p_org_idx ' || p_org_idx);
455: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.sr_inventory_item_id(p_item_idx) ' || item_availability_info.sr_inventory_item_id(p_item_idx));
456: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.family_sr_id(p_item_idx) ' || item_availability_info.family_sr_id(p_item_idx));
457: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'org_avail_info.requested_ship_date(p_org_idx) ' || org_avail_info.requested_ship_date(p_org_idx));
458: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'item_availability_info.atf_date(p_item_idx) ' || item_availability_info.atf_date(p_item_idx));
459: END IF;
460:
461: Prep_Common_pegging_rec(x_pegging_rec,
462: p_atp_record,
494: --bug3467631 end
495: -- time_phased_atp changes end
496:
497: IF PG_DEBUG in ('Y', 'C') THEN
498: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_id ' || x_pegging_rec.inventory_item_id);
499: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_name ' || x_pegging_rec.inventory_item_name);
500: END IF;
501:
502: x_pegging_rec.parent_pegging_id:= org_avail_info.demand_pegging_id(p_org_idx);
495: -- time_phased_atp changes end
496:
497: IF PG_DEBUG in ('Y', 'C') THEN
498: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_id ' || x_pegging_rec.inventory_item_id);
499: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'x_pegging_rec.inventory_item_name ' || x_pegging_rec.inventory_item_name);
500: END IF;
501:
502: x_pegging_rec.parent_pegging_id:= org_avail_info.demand_pegging_id(p_org_idx);
503: x_pegging_rec.pegging_id := org_avail_info.supply_pegging_id(p_org_idx);
552: x_pegging_rec.intransit_cal_code := org_avail_info.intransit_cal_code(p_org_idx);
553: x_pegging_rec.manufacturing_cal_code := org_avail_info.manufacturing_cal_code(p_org_idx);
554:
555: IF PG_DEBUG in ('Y', 'C') THEN
556: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_quantity ' || x_pegging_rec.required_quantity);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
553: x_pegging_rec.manufacturing_cal_code := org_avail_info.manufacturing_cal_code(p_org_idx);
554:
555: IF PG_DEBUG in ('Y', 'C') THEN
556: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_quantity ' || x_pegging_rec.required_quantity);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
554:
555: IF PG_DEBUG in ('Y', 'C') THEN
556: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_quantity ' || x_pegging_rec.required_quantity);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
555: IF PG_DEBUG in ('Y', 'C') THEN
556: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_quantity ' || x_pegging_rec.required_quantity);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
556: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_quantity ' || x_pegging_rec.required_quantity);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
564: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
557: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'required_date ' || x_pegging_rec.required_date);
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
564: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
565: END IF;
558: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'infinite_time_fence ' || x_pegging_rec.infinite_time_fence);
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
564: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
565: END IF;
566:
559: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'pegging_id ' || x_pegging_rec.pegging_id);
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
564: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
565: END IF;
566:
567: x_pegging_rec.pegging_type := ORG_SUPPLY_PEG_TYP;
560: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'parent_pegging_id ' || x_pegging_rec.parent_pegging_id);
561: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'end_pegging_id ' || x_pegging_rec.end_pegging_id);
562: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'shipping_cal_code ' || x_pegging_rec.shipping_cal_code);
563: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'receiving_cal_code ' || x_pegging_rec.receiving_cal_code);
564: msc_sch_wb.atp_debug('Prep_Supply_Pegging_Rec: ' || 'intransit_cal_code ' || x_pegging_rec.intransit_cal_code);
565: END IF;
566:
567: x_pegging_rec.pegging_type := ORG_SUPPLY_PEG_TYP;
568:
744:
745: */
746:
747: IF PG_DEBUG in ('Y', 'C') THEN
748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Point 2');
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
745: */
746:
747: IF PG_DEBUG in ('Y', 'C') THEN
748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Point 2');
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
746:
747: IF PG_DEBUG in ('Y', 'C') THEN
748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Point 2');
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
747: IF PG_DEBUG in ('Y', 'C') THEN
748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Point 2');
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Point 2');
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '**** Begin Check_ATP_Subst ***');
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
750: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || '********** INPUT DATA: p_atp_record **********');
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
751: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inventory_Item_Id:' || to_char(p_atp_record.Inventory_Item_Id) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
752: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id:' || to_char(p_atp_record.request_item_id) );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
753: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'organization_id:' || to_char(p_atp_record.organization_id) );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
754: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_Ordered:' || to_char(p_atp_record.Quantity_Ordered) );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
755: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Quantity_UOM:' || p_atp_record.Quantity_UOM );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Ship_Date:' || to_char(p_atp_record.Requested_Ship_Date) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
757: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Arrival_Date:' || to_char(p_atp_record.Requested_Arrival_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Latest_Acceptable_Date:' || to_char(p_atp_record.Latest_Acceptable_Date) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delivery_Lead_Time:' || to_char(p_atp_record.Delivery_Lead_Time) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
760: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Freight_Carrier:' || p_atp_record.Freight_Carrier );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
761: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Method:' || p_atp_record.Ship_Method );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
762: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Demand_Class:' || p_atp_record.Demand_Class );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
763: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Override_Flag:' || p_atp_record.Override_Flag );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
764: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Action:' || to_char(p_atp_record.Action) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
765: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Ship_Date:' || to_char(p_atp_record.Ship_Date) );
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Available_Quantity:' || to_char(p_atp_record.Available_Quantity) );
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
767: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Requested_Date_Quantity:' || to_char(p_atp_record.Requested_Date_Quantity) );
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
768: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_id:' || to_char(p_atp_record.supplier_id) );
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
769: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'supplier_site_id:' || to_char(p_atp_record.supplier_site_id) );
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
770: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Insert_Flag:' || to_char(p_atp_record.Insert_Flag) );
771: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error_Code:' || to_char(p_atp_record.Error_Code) );
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
772: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Order_Number:' || to_char(p_atp_record.Order_Number) );
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
779: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'intransit_cal_code ' || p_atp_record.intransit_cal_code);
780: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'to_organization_id ' || p_atp_record.to_organization_id);
773: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'P_scenario_id := ' || p_scenario_id);
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
779: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'intransit_cal_code ' || p_atp_record.intransit_cal_code);
780: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'to_organization_id ' || p_atp_record.to_organization_id);
781: END IF;
774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_DIAGNOSTIC_ATP ' || MSC_ATP_PVT.G_DIAGNOSTIC_ATP);
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
779: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'intransit_cal_code ' || p_atp_record.intransit_cal_code);
780: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'to_organization_id ' || p_atp_record.to_organization_id);
781: END IF;
782: --- first we set the Request Item's sr_inv_id to a global variable
775: -- Bug 3826234
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
779: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'intransit_cal_code ' || p_atp_record.intransit_cal_code);
780: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'to_organization_id ' || p_atp_record.to_organization_id);
781: END IF;
782: --- first we set the Request Item's sr_inv_id to a global variable
783: --bug3467631 In PF cases request_item_id has member_id
776: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'shipping_cal_code ' || p_atp_record.shipping_cal_code);
777: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'manufacturing_cal_code ' || p_atp_record.manufacturing_cal_code);
778: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'receiving_cal_code ' || p_atp_record.receiving_cal_code);
779: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'intransit_cal_code ' || p_atp_record.intransit_cal_code);
780: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'to_organization_id ' || p_atp_record.to_organization_id);
781: END IF;
782: --- first we set the Request Item's sr_inv_id to a global variable
783: --bug3467631 In PF cases request_item_id has member_id
784: --MSC_ATP_SUBST.G_REQ_ITEM_SR_INV_ID := p_atp_record.inventory_item_id;
787: item_availability_info := p_item_substitute_rec;
788:
789: IF PG_DEBUG in ('Y', 'C') THEN
790: FOR i in 1..item_availability_info.inventory_item_id.count LOOP
791: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Sr Item ID : ' || item_availability_info.sr_inventory_item_id(i) ||
792: ', item name : ' || item_availability_info.item_name(i) ||
793: ', atp_flag := ' || item_availability_info.atp_flag(i) ||
794: ', atp_comp_flag := ' || item_availability_info.atp_comp_flag(i) ||
795: ', create supply flag := ' || item_availability_info.create_supply_flag(i));
798: l_requested_ship_date := p_requested_ship_date;
799:
800: l_substitution_type := p_atp_record.substitution_type;
801: IF PG_DEBUG in ('Y', 'C') THEN
802: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'substitution_type := ' || l_substitution_type);
803: END IF;
804:
805: l_org_item_detail_flag := NVL(p_atp_record.req_item_detail_flag, 2);
806: l_substitution_type := ALL_OR_NOTHING;
808:
809: l_item_count := item_availability_info.inventory_item_id.count;
810: l_inventory_item_id := item_availability_info.inventory_item_id(l_item_count);
811: IF PG_DEBUG in ('Y', 'C') THEN
812: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_inventory_item_id := ' || l_inventory_item_id);
813: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_count := ' || l_item_count);
814: END IF;
815: IF item_availability_info.inventory_item_id.count > 0 THEN
816: l_highest_rev_item_id := NVL(item_availability_info.highest_revision_item_id(1),
809: l_item_count := item_availability_info.inventory_item_id.count;
810: l_inventory_item_id := item_availability_info.inventory_item_id(l_item_count);
811: IF PG_DEBUG in ('Y', 'C') THEN
812: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_inventory_item_id := ' || l_inventory_item_id);
813: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_count := ' || l_item_count);
814: END IF;
815: IF item_availability_info.inventory_item_id.count > 0 THEN
816: l_highest_rev_item_id := NVL(item_availability_info.highest_revision_item_id(1),
817: item_availability_info.inventory_item_id(l_item_count));
833: l_sys_date_top_org := NVL(MSC_ATP_FUNC.prev_work_day(p_atp_record.organization_id,
834: p_atp_record.instance_id,
835: sysdate), sysdate);
836: IF PG_DEBUG in ('Y', 'C') THEN
837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' ||l_sys_date_top_org);
838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type, -1));
839: END IF;
840:
841: --- now check how do we need to process the request
834: p_atp_record.instance_id,
835: sysdate), sysdate);
836: IF PG_DEBUG in ('Y', 'C') THEN
837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' ||l_sys_date_top_org);
838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type, -1));
839: END IF;
840:
841: --- now check how do we need to process the request
842: IF NVL(l_substitution_type, 4) = 3 THEN
841: --- now check how do we need to process the request
842: IF NVL(l_substitution_type, 4) = 3 THEN
843: --- we look at item attribute to see what kind of substitution do we need to do
844: IF PG_DEBUG in ('Y', 'C') THEN
845: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'look at item attribute');
846: END IF;
847: If item_availability_info.inventory_item_id.count > 1 THEN
848: -- substitutes exist
849: l_substitution_type := item_availability_info.partial_fulfillment_flag(1);
852: l_substitution_type := ALL_OR_NOTHING;
853: END IF;
854: ELSIF NVL(l_substitution_type, 4) = NO_SUBSTITUTION THEN
855: IF PG_DEBUG in ('Y', 'C') THEN
856: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Not doing substitution');
857: END IF;
858: -- in this case also we process it as 'All or nothing'
859: l_substitution_type := ALL_OR_NOTHING;
860: END IF;
863: -- 2754446
864: l_orig_net_dmd := l_net_demand;
865:
866: IF PG_DEBUG in ('Y', 'C') THEN
867: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
868: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type,-1));
869: END IF;
870: --- this is done for testing
871: l_substitution_type := ALL_OR_NOTHING;
864: l_orig_net_dmd := l_net_demand;
865:
866: IF PG_DEBUG in ('Y', 'C') THEN
867: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
868: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type,-1));
869: END IF;
870: --- this is done for testing
871: l_substitution_type := ALL_OR_NOTHING;
872: IF PG_DEBUG in ('Y', 'C') THEN
869: END IF;
870: --- this is done for testing
871: l_substitution_type := ALL_OR_NOTHING;
872: IF PG_DEBUG in ('Y', 'C') THEN
873: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sysdate_top_org := ' || l_sys_date_top_org);
874: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type,-1));
875: END IF;
876: IF l_substitution_type = ALL_OR_NOTHING THEN
877:
870: --- this is done for testing
871: l_substitution_type := ALL_OR_NOTHING;
872: IF PG_DEBUG in ('Y', 'C') THEN
873: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sysdate_top_org := ' || l_sys_date_top_org);
874: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_type := ' || NVL(l_substitution_type,-1));
875: END IF;
876: IF l_substitution_type = ALL_OR_NOTHING THEN
877:
878: --- first check on-hand/scheduled receipt by request date
879: --WHILE l_item_cntr <= item_availability_info.inventory_item_id.count AND
880: -- l_net_demand > 0 LOOP --- item loop
881: FOR l_item_cntr in reverse 1..item_availability_info.inventory_item_id.count LOOP
882: IF PG_DEBUG in ('Y', 'C') THEN
883: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Processing item := ' || item_availability_info.inventory_item_id(l_item_cntr) || ' '
884: || item_availability_info.item_name(l_item_cntr));
885: END IF;
886:
887: IF l_net_demand <= 0 THEN
905: l_period_begin_idx := l_all_atp_period.level.count + 1;
906: l_sd_begin_idx := l_all_atp_supply_demand.level.count + 1;
907: END IF;
908: IF PG_DEBUG in ('Y', 'C') THEN
909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_begin_idx := ' || l_period_begin_idx);
910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_begin_idx := ' || l_sd_begin_idx);
911: END IF;
912:
913: item_availability_info.period_detail_begin_idx(l_item_cntr) := l_period_begin_idx;
906: l_sd_begin_idx := l_all_atp_supply_demand.level.count + 1;
907: END IF;
908: IF PG_DEBUG in ('Y', 'C') THEN
909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_begin_idx := ' || l_period_begin_idx);
910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_begin_idx := ' || l_sd_begin_idx);
911: END IF;
912:
913: item_availability_info.period_detail_begin_idx(l_item_cntr) := l_period_begin_idx;
914: item_availability_info.sd_detail_begin_idx(l_item_cntr) := l_sd_begin_idx;
927:
928: -- dsting 2754446
929: org_availability_info.primary_uom(1) := p_atp_record.quantity_uom;
930: IF PG_DEBUG in ('Y', 'C') THEN
931: msc_sch_wb.atp_debug('Top org uom: ' || p_atp_record.quantity_uom);
932: END IF;
933:
934:
935: --- loop through all orgs in supply chain to find item's availability in each org by request
936: --- date
937:
938: WHILE l_parent_org_cntr <= org_availability_info.organization_id.count and l_net_demand > 0 LOOP
939: IF PG_DEBUG in ('Y', 'C') THEN
940: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand : = ' || l_net_demand);
941: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
942: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
943: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process org cntr := ' || l_process_org_cntr);
944: END IF;
937:
938: WHILE l_parent_org_cntr <= org_availability_info.organization_id.count and l_net_demand > 0 LOOP
939: IF PG_DEBUG in ('Y', 'C') THEN
940: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand : = ' || l_net_demand);
941: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
942: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
943: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process org cntr := ' || l_process_org_cntr);
944: END IF;
945: --- get plan_id in for each item org combo
938: WHILE l_parent_org_cntr <= org_availability_info.organization_id.count and l_net_demand > 0 LOOP
939: IF PG_DEBUG in ('Y', 'C') THEN
940: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand : = ' || l_net_demand);
941: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
942: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
943: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process org cntr := ' || l_process_org_cntr);
944: END IF;
945: --- get plan_id in for each item org combo
946: IF l_item_cntr = l_item_count and l_process_org_cntr = 1 THEN
939: IF PG_DEBUG in ('Y', 'C') THEN
940: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand : = ' || l_net_demand);
941: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
942: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
943: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process org cntr := ' || l_process_org_cntr);
944: END IF;
945: --- get plan_id in for each item org combo
946: IF l_item_cntr = l_item_count and l_process_org_cntr = 1 THEN
947: l_plan_id := p_plan_id;
991: END IF;
992:
993: -- dsting diagnostic atp
994: IF PG_DEBUG in ('Y', 'C') THEN
995: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'plan_name: ' || l_plan_info_rec.plan_name || ' process org: ' || l_process_org_cntr);
996: END IF;
997: org_availability_info.plan_name(l_process_org_cntr) := l_plan_info_rec.plan_name;
998:
999: END IF;
997: org_availability_info.plan_name(l_process_org_cntr) := l_plan_info_rec.plan_name;
998:
999: END IF;
1000: IF PG_DEBUG in ('Y', 'C') THEN
1001: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_plan_id := ' || l_plan_id);
1002: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_assign_set_id := ' || l_assign_set_id);
1003: END IF;
1004: --- get org code for pegging purpose
1005: -- store this info for top org
998:
999: END IF;
1000: IF PG_DEBUG in ('Y', 'C') THEN
1001: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_plan_id := ' || l_plan_id);
1002: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_assign_set_id := ' || l_assign_set_id);
1003: END IF;
1004: --- get org code for pegging purpose
1005: -- store this info for top org
1006: -- we will use this info for CTP
1013:
1014: l_org_code := MSC_ATP_FUNC.get_org_code(p_atp_record.instance_id,
1015: org_availability_info.organization_id(l_process_org_cntr));
1016: IF PG_DEBUG in ('Y', 'C') THEN
1017: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_code := ' || l_org_code);
1018: END IF;
1019: IF l_process_org_cntr = 1 THEN
1020: l_top_tier_org_code := l_org_code;
1021: IF PG_DEBUG in ('Y', 'C') THEN
1018: END IF;
1019: IF l_process_org_cntr = 1 THEN
1020: l_top_tier_org_code := l_org_code;
1021: IF PG_DEBUG in ('Y', 'C') THEN
1022: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_top_tier_org_code := ' || l_top_tier_org_code);
1023: END IF;
1024: END IF;
1025: org_availability_info.org_code(l_process_org_cntr) := l_org_code;
1026:
1041: l_return_status
1042: );
1043: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1044: IF PG_DEBUG in ('Y', 'C') THEN
1045: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Get_Family_Item_Info');
1046: END IF;
1047: RAISE FND_API.G_EXC_ERROR;
1048: END IF;
1049: ELSE -- DRP plan re-set variables.
1053: item_availability_info.sr_inventory_item_id(l_item_cntr);
1054: org_availability_info.family_dest_id(l_process_org_cntr) :=
1055: item_availability_info.inventory_item_id(l_item_cntr);
1056: IF PG_DEBUG in ('Y', 'C') THEN
1057: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1058: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PF and Allocated ATP not supported for DRP Plans');
1059: msc_sch_wb.atp_debug('Re-Set Family sr ITEM ID : ' || org_availability_info.family_sr_id(l_process_org_cntr));
1060: msc_sch_wb.atp_debug('Re-Set Family ITEM ID: ' || org_availability_info.family_dest_id(l_process_org_cntr));
1061: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1054: org_availability_info.family_dest_id(l_process_org_cntr) :=
1055: item_availability_info.inventory_item_id(l_item_cntr);
1056: IF PG_DEBUG in ('Y', 'C') THEN
1057: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1058: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PF and Allocated ATP not supported for DRP Plans');
1059: msc_sch_wb.atp_debug('Re-Set Family sr ITEM ID : ' || org_availability_info.family_sr_id(l_process_org_cntr));
1060: msc_sch_wb.atp_debug('Re-Set Family ITEM ID: ' || org_availability_info.family_dest_id(l_process_org_cntr));
1061: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1062: END IF;
1055: item_availability_info.inventory_item_id(l_item_cntr);
1056: IF PG_DEBUG in ('Y', 'C') THEN
1057: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1058: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PF and Allocated ATP not supported for DRP Plans');
1059: msc_sch_wb.atp_debug('Re-Set Family sr ITEM ID : ' || org_availability_info.family_sr_id(l_process_org_cntr));
1060: msc_sch_wb.atp_debug('Re-Set Family ITEM ID: ' || org_availability_info.family_dest_id(l_process_org_cntr));
1061: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1062: END IF;
1063: END IF;
1056: IF PG_DEBUG in ('Y', 'C') THEN
1057: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1058: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PF and Allocated ATP not supported for DRP Plans');
1059: msc_sch_wb.atp_debug('Re-Set Family sr ITEM ID : ' || org_availability_info.family_sr_id(l_process_org_cntr));
1060: msc_sch_wb.atp_debug('Re-Set Family ITEM ID: ' || org_availability_info.family_dest_id(l_process_org_cntr));
1061: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1062: END IF;
1063: END IF;
1064: -- End ATP4drp
1057: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1058: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PF and Allocated ATP not supported for DRP Plans');
1059: msc_sch_wb.atp_debug('Re-Set Family sr ITEM ID : ' || org_availability_info.family_sr_id(l_process_org_cntr));
1060: msc_sch_wb.atp_debug('Re-Set Family ITEM ID: ' || org_availability_info.family_dest_id(l_process_org_cntr));
1061: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
1062: END IF;
1063: END IF;
1064: -- End ATP4drp
1065:
1089: org_req_dmd_qty(l_net_demand, org_availability_info, l_process_org_cntr);
1090: -- org_availability_info.demand_quantity(l_process_org_cntr) := l_net_demand;
1091:
1092: IF PG_DEBUG in ('Y', 'C') THEN
1093: msc_sch_wb.atp_debug('process org: ' || org_availability_info.organization_id(l_process_org_cntr));
1094: msc_sch_wb.atp_debug('UOM process org: ' || org_availability_info.primary_uom(l_process_org_cntr));
1095: msc_sch_wb.atp_debug('conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1096: msc_sch_wb.atp_debug('demand_quantity ' || l_org_code || ' ' || org_availability_info.demand_quantity(l_process_org_cntr));
1097: END IF;
1090: -- org_availability_info.demand_quantity(l_process_org_cntr) := l_net_demand;
1091:
1092: IF PG_DEBUG in ('Y', 'C') THEN
1093: msc_sch_wb.atp_debug('process org: ' || org_availability_info.organization_id(l_process_org_cntr));
1094: msc_sch_wb.atp_debug('UOM process org: ' || org_availability_info.primary_uom(l_process_org_cntr));
1095: msc_sch_wb.atp_debug('conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1096: msc_sch_wb.atp_debug('demand_quantity ' || l_org_code || ' ' || org_availability_info.demand_quantity(l_process_org_cntr));
1097: END IF;
1098: --- get item attributes
1091:
1092: IF PG_DEBUG in ('Y', 'C') THEN
1093: msc_sch_wb.atp_debug('process org: ' || org_availability_info.organization_id(l_process_org_cntr));
1094: msc_sch_wb.atp_debug('UOM process org: ' || org_availability_info.primary_uom(l_process_org_cntr));
1095: msc_sch_wb.atp_debug('conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1096: msc_sch_wb.atp_debug('demand_quantity ' || l_org_code || ' ' || org_availability_info.demand_quantity(l_process_org_cntr));
1097: END IF;
1098: --- get item attributes
1099: IF l_process_org_cntr = 1 and l_item_cntr = l_item_count THEN
1092: IF PG_DEBUG in ('Y', 'C') THEN
1093: msc_sch_wb.atp_debug('process org: ' || org_availability_info.organization_id(l_process_org_cntr));
1094: msc_sch_wb.atp_debug('UOM process org: ' || org_availability_info.primary_uom(l_process_org_cntr));
1095: msc_sch_wb.atp_debug('conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1096: msc_sch_wb.atp_debug('demand_quantity ' || l_org_code || ' ' || org_availability_info.demand_quantity(l_process_org_cntr));
1097: END IF;
1098: --- get item attributes
1099: IF l_process_org_cntr = 1 and l_item_cntr = l_item_count THEN
1100: IF PG_DEBUG in ('Y', 'C') THEN
1097: END IF;
1098: --- get item attributes
1099: IF l_process_org_cntr = 1 and l_item_cntr = l_item_count THEN
1100: IF PG_DEBUG in ('Y', 'C') THEN
1101: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'No Need to get item attributes');
1102: END IF;
1103: --we have already got values for requested item in top org
1104: org_availability_info.atp_flag(l_process_org_cntr) := item_availability_info.atp_flag(l_item_cntr);
1105: org_availability_info.atp_comp_flag(l_process_org_cntr) := item_availability_info.atp_comp_flag(l_item_cntr);
1159: END IF;
1160: l_create_supply_flag := l_item_attribute_rec.create_supply_flag;
1161: END IF;
1162: IF PG_DEBUG in ('Y', 'C') THEN
1163: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_window := ' || l_substitution_window);
1164: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_create_supply_flag := '||l_create_supply_flag);
1165: END IF;
1166:
1167: IF l_process_org_cntr = 1 and l_item_cntr <> l_item_count THEN
1160: l_create_supply_flag := l_item_attribute_rec.create_supply_flag;
1161: END IF;
1162: IF PG_DEBUG in ('Y', 'C') THEN
1163: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_substitution_window := ' || l_substitution_window);
1164: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_create_supply_flag := '||l_create_supply_flag);
1165: END IF;
1166:
1167: IF l_process_org_cntr = 1 and l_item_cntr <> l_item_count THEN
1168: item_availability_info.atp_flag(l_item_cntr) := l_item_attribute_rec.atp_flag;
1200: l_return_status
1201: );
1202: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1203: IF PG_DEBUG in ('Y', 'C') THEN
1204: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Set_Alloc_Rule_Variables');
1205: END IF;
1206: RAISE FND_API.G_EXC_ERROR;
1207: END IF;
1208:
1226: ELSE
1227: l_item_to_use := item_availability_info.inventory_item_id(l_item_cntr);
1228: END IF;
1229: IF PG_DEBUG in ('Y', 'C') THEN
1230: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date = '||l_requested_ship_date);
1231: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item to be used = '||l_item_to_use);
1232: END IF;
1233: /* New allocation logic for time_phased_atp changes end */
1234:
1227: l_item_to_use := item_availability_info.inventory_item_id(l_item_cntr);
1228: END IF;
1229: IF PG_DEBUG in ('Y', 'C') THEN
1230: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date = '||l_requested_ship_date);
1231: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item to be used = '||l_item_to_use);
1232: END IF;
1233: /* New allocation logic for time_phased_atp changes end */
1234:
1235: --- get the demand class
1242: l_requested_ship_date,
1243: NULL, -- level_id
1244: p_atp_record.demand_class);
1245: IF PG_DEBUG in ('Y', 'C') THEN
1246: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after getting the dummy demand class');
1247: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand_class = '|| l_demand_class);
1248: END IF;
1249:
1250: org_availability_info.demand_class(l_process_org_cntr) := l_demand_class;
1243: NULL, -- level_id
1244: p_atp_record.demand_class);
1245: IF PG_DEBUG in ('Y', 'C') THEN
1246: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after getting the dummy demand class');
1247: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand_class = '|| l_demand_class);
1248: END IF;
1249:
1250: org_availability_info.demand_class(l_process_org_cntr) := l_demand_class;
1251: org_availability_info.allocation_rule(l_process_org_cntr) := MSC_ATP_PVT.G_ALLOCATION_RULE_NAME;
1258: --Do material check
1259: l_atp_flag := org_availability_info.atp_flag(l_process_org_cntr);
1260: l_atp_comp_flag := org_availability_info.atp_comp_flag(l_process_org_cntr);
1261: IF PG_DEBUG in ('Y', 'C') THEN
1262: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_flag := ' || l_atp_flag);
1263: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_comp_flag := ' || l_atp_comp_flag);
1264: END IF;
1265: IF l_atp_flag = 'N' and l_atp_comp_flag = 'N' THEN
1266: IF l_process_org_cntr = 1
1259: l_atp_flag := org_availability_info.atp_flag(l_process_org_cntr);
1260: l_atp_comp_flag := org_availability_info.atp_comp_flag(l_process_org_cntr);
1261: IF PG_DEBUG in ('Y', 'C') THEN
1262: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_flag := ' || l_atp_flag);
1263: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_comp_flag := ' || l_atp_comp_flag);
1264: END IF;
1265: IF l_atp_flag = 'N' and l_atp_comp_flag = 'N' THEN
1266: IF l_process_org_cntr = 1
1267: and org_availability_info.requested_ship_date(l_process_org_cntr) < l_sys_date_top_org THEN
1277: END IF;
1278: org_availability_info.request_date_quantity(l_process_org_cntr) := l_requested_date_quantity;
1279:
1280: IF PG_DEBUG in ('Y', 'C') THEN
1281: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item is not atpable');
1282: END IF;
1283: ELSE
1284: l_get_mat_in_rec.rounding_control_flag := org_availability_info.rounding_flag(l_process_org_cntr);
1285: l_get_mat_in_rec.dest_inv_item_id := item_availability_info.inventory_item_id(l_item_cntr);
1338: l_time_phased_atp := 'N';
1339: END IF;
1340:
1341: IF PG_DEBUG in ('Y', 'C') THEN
1342: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atf_date := ' || l_mat_atp_info_rec.atf_date);
1343: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_time_phased_atp := ' || l_time_phased_atp);
1344: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty);
1345: END IF;
1346: --bug3467631 end
1339: END IF;
1340:
1341: IF PG_DEBUG in ('Y', 'C') THEN
1342: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atf_date := ' || l_mat_atp_info_rec.atf_date);
1343: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_time_phased_atp := ' || l_time_phased_atp);
1344: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty);
1345: END IF;
1346: --bug3467631 end
1347: -- time_phased_atp changes end
1340:
1341: IF PG_DEBUG in ('Y', 'C') THEN
1342: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atf_date := ' || l_mat_atp_info_rec.atf_date);
1343: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_time_phased_atp := ' || l_time_phased_atp);
1344: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty);
1345: END IF;
1346: --bug3467631 end
1347: -- time_phased_atp changes end
1348:
1366: END IF;
1367:
1368: -- dsting diagnostic atp
1369: IF PG_DEBUG in ('Y', 'C') THEN
1370: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(l_process_org_cntr));
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1367:
1368: -- dsting diagnostic atp
1369: IF PG_DEBUG in ('Y', 'C') THEN
1370: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(l_process_org_cntr));
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1368: -- dsting diagnostic atp
1369: IF PG_DEBUG in ('Y', 'C') THEN
1370: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(l_process_org_cntr));
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1369: IF PG_DEBUG in ('Y', 'C') THEN
1370: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(l_process_org_cntr));
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1377: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'infinite_time_fenc_date ' || l_get_mat_out_rec.infinite_time_fence_date ||
1370: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(l_process_org_cntr));
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1377: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'infinite_time_fenc_date ' || l_get_mat_out_rec.infinite_time_fence_date ||
1378: ' atp_rule_name ' || l_get_mat_out_rec.atp_rule_name);
1371: msc_sch_wb.atp_debug('parent index: ' || l_parent_index);
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1377: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'infinite_time_fenc_date ' || l_get_mat_out_rec.infinite_time_fence_date ||
1378: ' atp_rule_name ' || l_get_mat_out_rec.atp_rule_name);
1379: END IF;
1372: msc_sch_wb.atp_debug('process org cntr: ' || l_process_org_cntr);
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1377: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'infinite_time_fenc_date ' || l_get_mat_out_rec.infinite_time_fence_date ||
1378: ' atp_rule_name ' || l_get_mat_out_rec.atp_rule_name);
1379: END IF;
1380: org_availability_info.infinite_time_fence(l_process_org_cntr) := l_get_mat_out_rec.infinite_time_fence_date;
1373: msc_sch_wb.atp_debug('parent conversion rate: ' || org_availability_info.conversion_rate(l_parent_index));
1374: msc_sch_wb.atp_debug('process org conversion rate: ' || org_availability_info.conversion_rate(l_process_org_cntr));
1375: msc_sch_wb.atp_debug('l_requested_date_quantity: ' || l_requested_date_quantity);
1376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after get_material_atp_info');
1377: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'infinite_time_fenc_date ' || l_get_mat_out_rec.infinite_time_fence_date ||
1378: ' atp_rule_name ' || l_get_mat_out_rec.atp_rule_name);
1379: END IF;
1380: org_availability_info.infinite_time_fence(l_process_org_cntr) := l_get_mat_out_rec.infinite_time_fence_date;
1381: org_availability_info.atp_rule_name(l_process_org_cntr) := l_get_mat_out_rec.atp_rule_name;
1390: org_availability_info.request_date_quantity(l_process_org_cntr) := 0;
1391: l_requested_date_quantity := 0;
1392: END IF; -- IF l_atp_flag = 'Y'
1393: IF PG_DEBUG in ('Y', 'C') THEN
1394: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_date_quantity := ' || l_requested_date_quantity);
1395: END IF;
1396:
1397: ---add material demand
1398:
1412: l_atp_insert_rec.atf_date := org_availability_info.atf_date(l_process_org_cntr);
1413: l_atp_insert_rec.atf_date_quantity := org_availability_info.atf_date_quantity(l_process_org_cntr);
1414: l_atp_insert_rec.requested_date_quantity := org_availability_info.request_date_quantity(l_process_org_cntr);
1415: IF PG_DEBUG in ('Y', 'C') THEN
1416: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.inventory_item_id := ' || l_atp_insert_rec.inventory_item_id);
1417: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.request_item_id := ' || l_atp_insert_rec.request_item_id);
1418: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date := ' || l_atp_insert_rec.atf_date);
1419: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity := ' || l_atp_insert_rec.atf_date_quantity);
1420: END IF;
1413: l_atp_insert_rec.atf_date_quantity := org_availability_info.atf_date_quantity(l_process_org_cntr);
1414: l_atp_insert_rec.requested_date_quantity := org_availability_info.request_date_quantity(l_process_org_cntr);
1415: IF PG_DEBUG in ('Y', 'C') THEN
1416: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.inventory_item_id := ' || l_atp_insert_rec.inventory_item_id);
1417: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.request_item_id := ' || l_atp_insert_rec.request_item_id);
1418: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date := ' || l_atp_insert_rec.atf_date);
1419: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity := ' || l_atp_insert_rec.atf_date_quantity);
1420: END IF;
1421: --bug3467631 end
1414: l_atp_insert_rec.requested_date_quantity := org_availability_info.request_date_quantity(l_process_org_cntr);
1415: IF PG_DEBUG in ('Y', 'C') THEN
1416: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.inventory_item_id := ' || l_atp_insert_rec.inventory_item_id);
1417: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.request_item_id := ' || l_atp_insert_rec.request_item_id);
1418: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date := ' || l_atp_insert_rec.atf_date);
1419: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity := ' || l_atp_insert_rec.atf_date_quantity);
1420: END IF;
1421: --bug3467631 end
1422: ELSE
1415: IF PG_DEBUG in ('Y', 'C') THEN
1416: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.inventory_item_id := ' || l_atp_insert_rec.inventory_item_id);
1417: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.request_item_id := ' || l_atp_insert_rec.request_item_id);
1418: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date := ' || l_atp_insert_rec.atf_date);
1419: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity := ' || l_atp_insert_rec.atf_date_quantity);
1420: END IF;
1421: --bug3467631 end
1422: ELSE
1423: l_atp_insert_rec.request_item_id := item_availability_info.inventory_item_id(l_item_cntr);
1465: l_atp_insert_rec.quantity_ordered := least(greatest(0, l_requested_date_quantity),
1466: l_net_demand);
1467:
1468: IF PG_DEBUG in ('Y', 'C') THEN
1469: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Alloc ATP, top org,We put demand for := ' ||
1470: l_atp_insert_rec.quantity_ordered);
1471: END IF;
1472: ELSE
1473:
1489:
1490: -- dsting diag_atp
1491: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
1492: IF PG_DEBUG in ('Y', 'C') THEN
1493: msc_sch_wb.atp_debug('place full dmd: ' || l_net_demand);
1494: END IF;
1495: -- dsting 2754446
1496: -- l_atp_insert_rec.quantity_ordered := l_net_demand;
1497: l_atp_insert_rec.quantity_ordered := org_availability_info.demand_quantity(l_process_org_cntr);
1496: -- l_atp_insert_rec.quantity_ordered := l_net_demand;
1497: l_atp_insert_rec.quantity_ordered := org_availability_info.demand_quantity(l_process_org_cntr);
1498: ELSE
1499: IF PG_DEBUG in ('Y', 'C') THEN
1500: msc_sch_wb.atp_debug('place partial dmd: ' || l_atp_insert_rec.quantity_ordered);
1501: END IF;
1502: -- dsting 2754446 rounding error?
1503: l_atp_insert_rec.quantity_ordered :=
1504: least(greatest(0, l_requested_date_quantity),
1530: l_demand_id);
1531: -- time_phased_atp changes end
1532:
1533: IF PG_DEBUG in ('Y', 'C') THEN
1534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_demand_id := ' || l_demand_id);
1535: END IF;
1536: -- store demand id in org_avail_info table as we would need to update the demand
1537: -- in lower orgs if we dont have enough quantity in the org
1538: org_availability_info.demand_id(l_process_org_cntr) := l_demand_id;
1549: INTO l_pegging_id
1550: FROM dual;
1551:
1552: IF PG_DEBUG in ('Y', 'C') THEN
1553: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand pegging id := ' || l_pegging_id);
1554: END IF;
1555: org_availability_info.demand_pegging_id(l_process_org_cntr) := l_pegging_id;
1556:
1557: --- supply pegging id
1579: l_return_status);
1580: ---Now do stealing
1581:
1582: IF PG_DEBUG in ('Y', 'C') THEN
1583: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'net demand ' || l_net_demand || ' requested qty ' || l_requested_date_quantity);
1584: END IF;
1585:
1586: -- 2754446
1587: -- l_net_demand := GREATEST(l_net_demand - greatest(0, l_requested_date_quantity), 0);
1589: l_net_demand := greatest(0,
1590: l_orig_net_dmd - nvl(org_availability_info.rnding_leftover(1), 0));
1591:
1592: IF PG_DEBUG in ('Y', 'C') THEN
1593: msc_sch_wb.atp_debug('orig_net_dmd: ' || l_orig_net_dmd);
1594: msc_sch_wb.atp_debug('rnding_leftover(1): ' || org_availability_info.rnding_leftover(1));
1595: msc_sch_wb.atp_debug('req_date_qty: ' || greatest(nvl(org_availability_info.request_date_quantity(1), 0),0));
1596: msc_sch_wb.atp_debug('steal_qty: ' || org_availability_info.steal_qty(1));
1597: msc_sch_wb.atp_debug('net_dmd: ' || l_net_demand);
1590: l_orig_net_dmd - nvl(org_availability_info.rnding_leftover(1), 0));
1591:
1592: IF PG_DEBUG in ('Y', 'C') THEN
1593: msc_sch_wb.atp_debug('orig_net_dmd: ' || l_orig_net_dmd);
1594: msc_sch_wb.atp_debug('rnding_leftover(1): ' || org_availability_info.rnding_leftover(1));
1595: msc_sch_wb.atp_debug('req_date_qty: ' || greatest(nvl(org_availability_info.request_date_quantity(1), 0),0));
1596: msc_sch_wb.atp_debug('steal_qty: ' || org_availability_info.steal_qty(1));
1597: msc_sch_wb.atp_debug('net_dmd: ' || l_net_demand);
1598: END IF;
1591:
1592: IF PG_DEBUG in ('Y', 'C') THEN
1593: msc_sch_wb.atp_debug('orig_net_dmd: ' || l_orig_net_dmd);
1594: msc_sch_wb.atp_debug('rnding_leftover(1): ' || org_availability_info.rnding_leftover(1));
1595: msc_sch_wb.atp_debug('req_date_qty: ' || greatest(nvl(org_availability_info.request_date_quantity(1), 0),0));
1596: msc_sch_wb.atp_debug('steal_qty: ' || org_availability_info.steal_qty(1));
1597: msc_sch_wb.atp_debug('net_dmd: ' || l_net_demand);
1598: END IF;
1599:
1592: IF PG_DEBUG in ('Y', 'C') THEN
1593: msc_sch_wb.atp_debug('orig_net_dmd: ' || l_orig_net_dmd);
1594: msc_sch_wb.atp_debug('rnding_leftover(1): ' || org_availability_info.rnding_leftover(1));
1595: msc_sch_wb.atp_debug('req_date_qty: ' || greatest(nvl(org_availability_info.request_date_quantity(1), 0),0));
1596: msc_sch_wb.atp_debug('steal_qty: ' || org_availability_info.steal_qty(1));
1597: msc_sch_wb.atp_debug('net_dmd: ' || l_net_demand);
1598: END IF;
1599:
1600: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (l_atp_flag in ('Y', 'C')) and l_net_demand > 0 THEN
1593: msc_sch_wb.atp_debug('orig_net_dmd: ' || l_orig_net_dmd);
1594: msc_sch_wb.atp_debug('rnding_leftover(1): ' || org_availability_info.rnding_leftover(1));
1595: msc_sch_wb.atp_debug('req_date_qty: ' || greatest(nvl(org_availability_info.request_date_quantity(1), 0),0));
1596: msc_sch_wb.atp_debug('steal_qty: ' || org_availability_info.steal_qty(1));
1597: msc_sch_wb.atp_debug('net_dmd: ' || l_net_demand);
1598: END IF;
1599:
1600: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (l_atp_flag in ('Y', 'C')) and l_net_demand > 0 THEN
1601:
1599:
1600: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (l_atp_flag in ('Y', 'C')) and l_net_demand > 0 THEN
1601:
1602: IF PG_DEBUG in ('Y', 'C') THEN
1603: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'we are in the setup for stealing');
1604: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
1605: END IF;
1606: g_atp_record.error_code := MSC_ATP_PVT.ALLSUCCESS;
1607:
1600: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (l_atp_flag in ('Y', 'C')) and l_net_demand > 0 THEN
1601:
1602: IF PG_DEBUG in ('Y', 'C') THEN
1603: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'we are in the setup for stealing');
1604: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
1605: END IF;
1606: g_atp_record.error_code := MSC_ATP_PVT.ALLSUCCESS;
1607:
1608: -- time_phased_atp
1661: l_post_stealing_dmd := g_atp_record.quantity_ordered; --bug3467631 change done
1662: -- so that l_post_stealing_dmd is not passed null which completes the fix of 2754446
1663:
1664: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
1665: msc_sch_wb.atp_debug('l_post_stealing_dmd: ' || g_atp_record.quantity_ordered);
1666: END IF;
1667:
1668: MSC_AATP_PVT.Stealing(
1669: g_atp_record,
1699: -- greatest(l_net_demand, 0);
1700: -- l_net_demand := l_net_demand - l_stealing_qty;
1701:
1702: IF PG_DEBUG in ('Y', 'C') THEN
1703: msc_sch_wb.atp_debug('l_stealing_qty: ' || l_stealing_qty);
1704: msc_sch_wb.atp_debug('l_net_demand: ' || l_net_demand);
1705: msc_sch_wb.atp_debug('l_post_stealing_dmd: ' || l_post_stealing_dmd);
1706: msc_sch_wb.atp_debug('Qty till now got: ' || org_availability_info.rnding_leftover(l_process_org_cntr)); --bug3467631
1707: END IF;
1700: -- l_net_demand := l_net_demand - l_stealing_qty;
1701:
1702: IF PG_DEBUG in ('Y', 'C') THEN
1703: msc_sch_wb.atp_debug('l_stealing_qty: ' || l_stealing_qty);
1704: msc_sch_wb.atp_debug('l_net_demand: ' || l_net_demand);
1705: msc_sch_wb.atp_debug('l_post_stealing_dmd: ' || l_post_stealing_dmd);
1706: msc_sch_wb.atp_debug('Qty till now got: ' || org_availability_info.rnding_leftover(l_process_org_cntr)); --bug3467631
1707: END IF;
1708:
1701:
1702: IF PG_DEBUG in ('Y', 'C') THEN
1703: msc_sch_wb.atp_debug('l_stealing_qty: ' || l_stealing_qty);
1704: msc_sch_wb.atp_debug('l_net_demand: ' || l_net_demand);
1705: msc_sch_wb.atp_debug('l_post_stealing_dmd: ' || l_post_stealing_dmd);
1706: msc_sch_wb.atp_debug('Qty till now got: ' || org_availability_info.rnding_leftover(l_process_org_cntr)); --bug3467631
1707: END IF;
1708:
1709: org_availability_info.steal_qty(l_process_org_cntr) := l_stealing_qty;
1702: IF PG_DEBUG in ('Y', 'C') THEN
1703: msc_sch_wb.atp_debug('l_stealing_qty: ' || l_stealing_qty);
1704: msc_sch_wb.atp_debug('l_net_demand: ' || l_net_demand);
1705: msc_sch_wb.atp_debug('l_post_stealing_dmd: ' || l_post_stealing_dmd);
1706: msc_sch_wb.atp_debug('Qty till now got: ' || org_availability_info.rnding_leftover(l_process_org_cntr)); --bug3467631
1707: END IF;
1708:
1709: org_availability_info.steal_qty(l_process_org_cntr) := l_stealing_qty;
1710:
1721: l_post_stealing_dmd;
1722: -- l_net_demand;
1723:
1724: IF PG_DEBUG in ('Y', 'C') THEN
1725: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'After Stealing :'||
1726: to_char(l_net_demand));
1727: END IF;
1728:
1729: -- dsting diag_atp
1730: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP <> DIAGNOSTIC_ATP THEN
1731: --- now we update the demand
1732: IF l_process_org_cntr =1 THEN
1733: IF PG_DEBUG in ('Y', 'C') THEN
1734: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Top Org, update demand');
1735: END IF;
1736: --- for top org we always create order for the quantity ordered
1737: MSC_ATP_SUBST.UPDATE_DEMAND(org_availability_info.demand_id(l_process_org_cntr),
1738: org_availability_info.plan_id(l_process_org_cntr),
1752: l_return_status
1753: );
1754: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1755: IF PG_DEBUG in ('Y', 'C') THEN
1756: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Increment_Bucketed_Demands_Qty');
1757: END IF;
1758: RAISE FND_API.G_EXC_ERROR;
1759: END IF;
1760: /* Reset l_atf_date_qty to 0*/ --bug3467631
1762: END IF;
1763: -- time_phased_atp changes end
1764: ELSIF l_stealing_qty > 0 THEN
1765: IF PG_DEBUG in ('Y', 'C') THEN
1766: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'second or later org, update demand as there is some stolen qty');
1767: END IF;
1768: --- org in second or later tear. Create demand for quantity available (req date qty+steal qty)
1769: MSC_ATP_SUBST.UPDATE_DEMAND(org_availability_info.demand_id(l_process_org_cntr),
1770: org_availability_info.plan_id(l_process_org_cntr),
1787: l_return_status
1788: );
1789: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1790: IF PG_DEBUG in ('Y', 'C') THEN
1791: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Increment_Bucketed_Demands_Qty');
1792: END IF;
1793: RAISE FND_API.G_EXC_ERROR;
1794: END IF;
1795: /* Reset l_atf_date_qty to 0*/ --bug3467631
1802: END IF; -- IF l_atp_flag = 'N' and l_atp_comp_flag = 'N' THEN
1803:
1804: --l_net_demand := GREATEST(l_net_demand - greatest(0, l_requested_date_quantity), 0);
1805: IF PG_DEBUG in ('Y', 'C') THEN
1806: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1807: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org counter 1 := ' || l_parent_org_cntr);
1808: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
1809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date := ' || l_requested_ship_date);
1810: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
1803:
1804: --l_net_demand := GREATEST(l_net_demand - greatest(0, l_requested_date_quantity), 0);
1805: IF PG_DEBUG in ('Y', 'C') THEN
1806: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1807: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org counter 1 := ' || l_parent_org_cntr);
1808: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
1809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date := ' || l_requested_ship_date);
1810: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
1811: END IF;
1804: --l_net_demand := GREATEST(l_net_demand - greatest(0, l_requested_date_quantity), 0);
1805: IF PG_DEBUG in ('Y', 'C') THEN
1806: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1807: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org counter 1 := ' || l_parent_org_cntr);
1808: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
1809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date := ' || l_requested_ship_date);
1810: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
1811: END IF;
1812: IF l_net_demand > 0 and l_process_org_cntr >= org_availability_info.organization_id.count
1805: IF PG_DEBUG in ('Y', 'C') THEN
1806: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1807: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org counter 1 := ' || l_parent_org_cntr);
1808: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
1809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date := ' || l_requested_ship_date);
1810: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
1811: END IF;
1812: IF l_net_demand > 0 and l_process_org_cntr >= org_availability_info.organization_id.count
1813: and l_requested_ship_date >= l_sys_date_top_org THEN
1806: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1807: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org counter 1 := ' || l_parent_org_cntr);
1808: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'org count := ' || org_availability_info.organization_id.count);
1809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_requested_ship_date := ' || l_requested_ship_date);
1810: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
1811: END IF;
1812: IF l_net_demand > 0 and l_process_org_cntr >= org_availability_info.organization_id.count
1813: and l_requested_ship_date >= l_sys_date_top_org THEN
1814:
1819: -- l_sources found = 1 iff there is a good transfer source found that doesn't violate constraints
1820: -- l_transfer_found = 1 if there is any transfer source
1821: l_transfer_found := 0;
1822: IF PG_DEBUG in ('Y', 'C') THEN
1823: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
1824: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1825: END IF;
1826: WHILE l_sources_found = 0 AND l_parent_org_cntr <= org_availability_info.organization_id.count LOOP
1827: IF PG_DEBUG in ('Y', 'C') THEN
1820: -- l_transfer_found = 1 if there is any transfer source
1821: l_transfer_found := 0;
1822: IF PG_DEBUG in ('Y', 'C') THEN
1823: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
1824: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1825: END IF;
1826: WHILE l_sources_found = 0 AND l_parent_org_cntr <= org_availability_info.organization_id.count LOOP
1827: IF PG_DEBUG in ('Y', 'C') THEN
1828: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Look for sources for org :' || ORG_AVAILABILITY_INFO.organization_id(l_parent_org_cntr));
1824: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_process_org_cntr := ' || l_process_org_cntr);
1825: END IF;
1826: WHILE l_sources_found = 0 AND l_parent_org_cntr <= org_availability_info.organization_id.count LOOP
1827: IF PG_DEBUG in ('Y', 'C') THEN
1828: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Look for sources for org :' || ORG_AVAILABILITY_INFO.organization_id(l_parent_org_cntr));
1829: END IF;
1830: IF org_availability_info.atp_comp_flag(l_parent_org_cntr) in ('Y', 'C') THEN
1831: --s_cto_rearch
1832: l_item_sourcing_info_rec := l_null_item_sourcing_info_rec;
1855: ELSE
1856: l_sources := l_null_sources;
1857: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
1858: IF PG_DEBUG in ('Y', 'C') THEN
1859: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'constraint type: MATERIAL_CONSTRAINT');
1860: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'make_buy_code: ' || l_make_buy_cd);
1861: END IF;
1862: org_availability_info.constraint_type(l_parent_org_cntr) := MATERIAL_CONSTRAINT;
1863: END IF;
1856: l_sources := l_null_sources;
1857: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
1858: IF PG_DEBUG in ('Y', 'C') THEN
1859: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'constraint type: MATERIAL_CONSTRAINT');
1860: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'make_buy_code: ' || l_make_buy_cd);
1861: END IF;
1862: org_availability_info.constraint_type(l_parent_org_cntr) := MATERIAL_CONSTRAINT;
1863: END IF;
1864: END IF;
1865: IF l_return_status <> FND_API.G_RET_STS_SUCCESS OR
1866: l_sources.source_type.count = 0
1867: THEN
1868: IF PG_DEBUG in ('Y', 'C') THEN
1869: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'No sources Found for this org');
1870: END IF;
1871:
1872: ELSE
1873: IF PG_DEBUG in ('Y', 'C') THEN
1870: END IF;
1871:
1872: ELSE
1873: IF PG_DEBUG in ('Y', 'C') THEN
1874: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Sources Found, process them');
1875: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' source count := ' || l_sources.organization_id.count);
1876: END IF;
1877:
1878: FOR i in 1..l_sources.organization_id.count LOOP
1871:
1872: ELSE
1873: IF PG_DEBUG in ('Y', 'C') THEN
1874: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Sources Found, process them');
1875: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' source count := ' || l_sources.organization_id.count);
1876: END IF;
1877:
1878: FOR i in 1..l_sources.organization_id.count LOOP
1879:
1885: l_delivery_lead_time := l_sources.lead_time(i);
1886: l_ship_method := l_sources.ship_method(i);
1887:
1888: IF PG_DEBUG in ('Y', 'C') THEN
1889: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_delivery_lead_time := ' || l_delivery_lead_time);
1890: END IF;
1891:
1892: --bug3467631 making necessary changes for ship_rec_cal
1893: /* ship_rec_cal changes begin */
1891:
1892: --bug3467631 making necessary changes for ship_rec_cal
1893: /* ship_rec_cal changes begin */
1894: IF PG_DEBUG in ('Y', 'C') THEN
1895: msc_sch_wb.atp_debug('**************** Calendar Codes ******************************');
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1892: --bug3467631 making necessary changes for ship_rec_cal
1893: /* ship_rec_cal changes begin */
1894: IF PG_DEBUG in ('Y', 'C') THEN
1895: msc_sch_wb.atp_debug('**************** Calendar Codes ******************************');
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1893: /* ship_rec_cal changes begin */
1894: IF PG_DEBUG in ('Y', 'C') THEN
1895: msc_sch_wb.atp_debug('**************** Calendar Codes ******************************');
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1894: IF PG_DEBUG in ('Y', 'C') THEN
1895: msc_sch_wb.atp_debug('**************** Calendar Codes ******************************');
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1895: msc_sch_wb.atp_debug('**************** Calendar Codes ******************************');
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1903: msc_sch_wb.atp_debug('* Ship Method : '|| l_sources.Ship_Method(i) );
1896: msc_sch_wb.atp_debug('* ___________________Input_____________________');
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1903: msc_sch_wb.atp_debug('* Ship Method : '|| l_sources.Ship_Method(i) );
1904: END IF;
1897: msc_sch_wb.atp_debug('* ');
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1903: msc_sch_wb.atp_debug('* Ship Method : '|| l_sources.Ship_Method(i) );
1904: END IF;
1905:
1898: msc_sch_wb.atp_debug('* Source Type : '|| l_sources.source_type(i) );
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1903: msc_sch_wb.atp_debug('* Ship Method : '|| l_sources.Ship_Method(i) );
1904: END IF;
1905:
1906: IF l_sources.source_type(i) = MSC_ATP_PVT.TRANSFER THEN
1899: msc_sch_wb.atp_debug('* Instance ID : '|| p_atp_record.instance_id );
1900: msc_sch_wb.atp_debug('* Source Instance ID : '|| l_sources.instance_id(i) );
1901: msc_sch_wb.atp_debug('* Source Org ID : '|| l_sources.organization_id(i) );
1902: msc_sch_wb.atp_debug('* Receiving Org ID : '|| org_availability_info.organization_id(l_parent_org_cntr) );
1903: msc_sch_wb.atp_debug('* Ship Method : '|| l_sources.Ship_Method(i) );
1904: END IF;
1905:
1906: IF l_sources.source_type(i) = MSC_ATP_PVT.TRANSFER THEN
1907: -- receiving party is org
1958: null,
1959: MSC_CALENDAR.OMC);
1960: END IF;
1961: IF PG_DEBUG in ('Y', 'C') THEN
1962: msc_sch_wb.atp_debug(' ');
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1959: MSC_CALENDAR.OMC);
1960: END IF;
1961: IF PG_DEBUG in ('Y', 'C') THEN
1962: msc_sch_wb.atp_debug(' ');
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1960: END IF;
1961: IF PG_DEBUG in ('Y', 'C') THEN
1962: msc_sch_wb.atp_debug(' ');
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1961: IF PG_DEBUG in ('Y', 'C') THEN
1962: msc_sch_wb.atp_debug(' ');
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1969: msc_sch_wb.atp_debug('**************************************************************');
1962: msc_sch_wb.atp_debug(' ');
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1969: msc_sch_wb.atp_debug('**************************************************************');
1970: END IF;
1963: msc_sch_wb.atp_debug('* ___________________Output____________________');
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1969: msc_sch_wb.atp_debug('**************************************************************');
1970: END IF;
1971:
1964: msc_sch_wb.atp_debug('* ');
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1969: msc_sch_wb.atp_debug('**************************************************************');
1970: END IF;
1971:
1972: /* planned order due date as per OMC-D */
1965: msc_sch_wb.atp_debug('* Receiving calendar code : ' || l_receiving_cal_code);
1966: msc_sch_wb.atp_debug('* Intransit calendar code : ' || l_intransit_cal_code);
1967: msc_sch_wb.atp_debug('* Shipping calendar code : ' || l_shipping_cal_code);
1968: msc_sch_wb.atp_debug('* Manufacturing calendar code : ' || l_manufacturing_cal_code);
1969: msc_sch_wb.atp_debug('**************************************************************');
1970: END IF;
1971:
1972: /* planned order due date as per OMC-D */
1973: l_planned_order_date := MSC_CALENDAR.PREV_WORK_DAY(
1974: l_dest_mfg_cal_code,
1975: p_atp_record.instance_id,
1976: l_requested_ship_date);
1977: IF PG_DEBUG in ('Y', 'C') THEN
1978: msc_sch_wb.atp_debug('* Planned Order Due Date as per OMC-D: ' || l_planned_order_date);
1979: msc_sch_wb.atp_debug('* post_pro_lt: ' || org_availability_info.post_pro_lt(l_parent_org_cntr));
1980: END IF;
1981: -- ship_rec_cal changes end
1982:
1975: p_atp_record.instance_id,
1976: l_requested_ship_date);
1977: IF PG_DEBUG in ('Y', 'C') THEN
1978: msc_sch_wb.atp_debug('* Planned Order Due Date as per OMC-D: ' || l_planned_order_date);
1979: msc_sch_wb.atp_debug('* post_pro_lt: ' || org_availability_info.post_pro_lt(l_parent_org_cntr));
1980: END IF;
1981: -- ship_rec_cal changes end
1982:
1983: --- first we do a PTF check. Get start Date for PTF check
2011: org modeled as supplier which might come in future*/
2012: l_new_dock_date := l_start_date;
2013:
2014: IF PG_DEBUG in ('Y', 'C') THEN
2015: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date : '||l_start_date);
2016: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after validating on ORC : '||l_new_dock_date);
2017: END IF;
2018:
2019: -- l_start_date := MSC_CALENDAR.DATE_OFFSET ( -- Bug 3241766: l_start_date should have dock date
2012: l_new_dock_date := l_start_date;
2013:
2014: IF PG_DEBUG in ('Y', 'C') THEN
2015: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date : '||l_start_date);
2016: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after validating on ORC : '||l_new_dock_date);
2017: END IF;
2018:
2019: -- l_start_date := MSC_CALENDAR.DATE_OFFSET ( -- Bug 3241766: l_start_date should have dock date
2020: l_atp_rec.requested_ship_date := MSC_CALENDAR.DATE_OFFSET (
2023: l_start_date,
2024: -1 * NVL(l_sources.lead_time(i), 0), -1);
2025:
2026: IF PG_DEBUG in ('Y', 'C') THEN
2027: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after subtracting DLT using VIC : '||l_atp_rec.requested_ship_date);
2028: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sources.lead_time(i) : '||l_sources.lead_time(i));
2029: END IF;
2030:
2031: l_atp_rec.requested_ship_date := MSC_CALENDAR.PREV_WORK_DAY(
2024: -1 * NVL(l_sources.lead_time(i), 0), -1);
2025:
2026: IF PG_DEBUG in ('Y', 'C') THEN
2027: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after subtracting DLT using VIC : '||l_atp_rec.requested_ship_date);
2028: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sources.lead_time(i) : '||l_sources.lead_time(i));
2029: END IF;
2030:
2031: l_atp_rec.requested_ship_date := MSC_CALENDAR.PREV_WORK_DAY(
2032: l_shipping_cal_code,
2039: l_start_date := l_new_ship_date; -- Bug 3578083 -- Setting the variable that is compared with PTF date
2040: -- This should be source org's ship date.
2041:
2042: IF PG_DEBUG in ('Y', 'C') THEN
2043: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after validating on OSC : '||l_atp_rec.requested_ship_date);
2044: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'pre_pro_lt : '||org_availability_info.pre_pro_lt(l_parent_org_cntr));
2045: END IF;
2046:
2047: -- Add pre-PLT offset also: Bug 3241766
2040: -- This should be source org's ship date.
2041:
2042: IF PG_DEBUG in ('Y', 'C') THEN
2043: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date after validating on OSC : '||l_atp_rec.requested_ship_date);
2044: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'pre_pro_lt : '||org_availability_info.pre_pro_lt(l_parent_org_cntr));
2045: END IF;
2046:
2047: -- Add pre-PLT offset also: Bug 3241766
2048: l_order_date := MSC_CALENDAR.DATE_OFFSET (
2085:
2086: EXCEPTION
2087: WHEN OTHERS THEN
2088: IF PG_DEBUG in ('Y', 'C') THEN
2089: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured while getting PTF : ' || sqlerrm);
2090: END IF;
2091: --l_ptf_date := l_sysdate; -- Bug 3578083
2092: END;
2093: IF PG_DEBUG in ('Y', 'C') THEN
2090: END IF;
2091: --l_ptf_date := l_sysdate; -- Bug 3578083
2092: END;
2093: IF PG_DEBUG in ('Y', 'C') THEN
2094: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_date := ' || l_ptf_date);
2095: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_order_date := ' || l_order_date);
2096: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date := ' || l_start_date);
2097: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_enabled := ' || l_ptf_enabled);
2098: END IF;
2091: --l_ptf_date := l_sysdate; -- Bug 3578083
2092: END;
2093: IF PG_DEBUG in ('Y', 'C') THEN
2094: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_date := ' || l_ptf_date);
2095: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_order_date := ' || l_order_date);
2096: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date := ' || l_start_date);
2097: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_enabled := ' || l_ptf_enabled);
2098: END IF;
2099:
2092: END;
2093: IF PG_DEBUG in ('Y', 'C') THEN
2094: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_date := ' || l_ptf_date);
2095: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_order_date := ' || l_order_date);
2096: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date := ' || l_start_date);
2097: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_enabled := ' || l_ptf_enabled);
2098: END IF;
2099:
2100: -- calculate the ship date if we pass the ptf check
2093: IF PG_DEBUG in ('Y', 'C') THEN
2094: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_date := ' || l_ptf_date);
2095: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_order_date := ' || l_order_date);
2096: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_start_date := ' || l_start_date);
2097: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_enabled := ' || l_ptf_enabled);
2098: END IF;
2099:
2100: -- calculate the ship date if we pass the ptf check
2101: -- or we're doing diagnostic atp
2101: -- or we're doing diagnostic atp
2102: /* ship_rec_cal: not required as ship date is already calulated
2103: IF l_start_date >= l_ptf_date THEN
2104: IF PG_DEBUG in ('Y', 'C') THEN
2105: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Passed the PTF test');
2106: END IF;
2107: /* ship_rec_cal
2108: l_req_ship_date := MSC_CALENDAR.prev_work_day(l_sources.organization_id(i),
2109: p_atp_record.instance_id,
2114: p_atp_record.instance_id,
2115: l_start_date);
2116:
2117: IF PG_DEBUG in ('Y', 'C') THEN
2118: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_req_ship_date := ' || l_req_ship_date);
2119: END IF;
2120: END IF;
2121: */
2122:
2156: SELECT msc_full_pegging_s.nextval
2157: INTO l_pegging_id
2158: FROM dual;
2159: IF PG_DEBUG in ('Y', 'C') THEN
2160: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PO Pegging id := ' || l_pegging_id);
2161: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Src Organization_id := ' || l_sources.organization_id(i));
2162: END IF;
2163: org_availability_info.PO_pegging_id(l_count) := l_pegging_id;
2164: ELSIF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
2157: INTO l_pegging_id
2158: FROM dual;
2159: IF PG_DEBUG in ('Y', 'C') THEN
2160: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'PO Pegging id := ' || l_pegging_id);
2161: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Src Organization_id := ' || l_sources.organization_id(i));
2162: END IF;
2163: org_availability_info.PO_pegging_id(l_count) := l_pegging_id;
2164: ELSIF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
2165: l_transfer_found := 1;
2262: -- ship_rec_cal changes end
2263: END IF;
2264: -- bug3578083 - Constraint message should be added only if constraint actually exists
2265: IF PG_DEBUG in ('Y', 'C') THEN
2266: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_due_date ' || l_ptf_due_date);
2267: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_lt_due_date ' || l_lt_due_date);
2268: END IF;
2269: IF l_lt_due_date > l_requested_ship_date OR
2270: l_ptf_due_date > l_requested_ship_date THEN
2263: END IF;
2264: -- bug3578083 - Constraint message should be added only if constraint actually exists
2265: IF PG_DEBUG in ('Y', 'C') THEN
2266: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_ptf_due_date ' || l_ptf_due_date);
2267: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_lt_due_date ' || l_lt_due_date);
2268: END IF;
2269: IF l_lt_due_date > l_requested_ship_date OR
2270: l_ptf_due_date > l_requested_ship_date THEN
2271: -- bug3578083 - PTF constraint should be added only if plan is PTF enabled
2270: l_ptf_due_date > l_requested_ship_date THEN
2271: -- bug3578083 - PTF constraint should be added only if plan is PTF enabled
2272: IF l_ptf_enabled=2 OR l_lt_due_date > l_ptf_due_date THEN
2273: IF PG_DEBUG in ('Y', 'C') THEN
2274: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'diagnostic atp: TRANSIT_LT_CONSTRAINT');
2275: END IF;
2276: l_pegging_rec.constraint_type := TRANSIT_LT_CONSTRAINT;
2277: l_pegging_rec.constraint_date := l_lt_due_date;
2278: ELSE
2276: l_pegging_rec.constraint_type := TRANSIT_LT_CONSTRAINT;
2277: l_pegging_rec.constraint_date := l_lt_due_date;
2278: ELSE
2279: IF PG_DEBUG in ('Y', 'C') THEN
2280: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'diagnostic atp: PTF_CONSTRAINT');
2281: END IF;
2282: l_pegging_rec.constraint_type := PTF_CONSTRAINT;
2283: l_pegging_rec.constraint_date := l_ptf_due_date;
2284: END IF;
2284: END IF;
2285: END IF;
2286:
2287: IF PG_DEBUG in ('Y', 'C') THEN
2288: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Constraint due date: ' || l_pegging_rec.constraint_date);
2289: END IF;
2290:
2291: l_pegging_rec.parent_pegging_id:=
2292: org_availability_info.demand_pegging_id(l_parent_org_cntr);
2293: l_pegging_rec.end_pegging_id := org_availability_info.demand_pegging_id(1);
2294:
2295: -- dsting diag_atp
2296: IF PG_DEBUG in ('Y', 'C') THEN
2297: msc_sch_wb.atp_debug('lt or ptf constraint end_pegging_id: ' || org_availability_info.demand_pegging_id(1));
2298: END IF;
2299:
2300: MSC_ATP_PVT.G_demand_pegging_id := org_availability_info.demand_pegging_id(1);
2301: l_pegging_rec.organization_id :=
2337: MSC_ATP_DB_UTILS.Add_Pegging(l_pegging_rec, l_pegging_id);
2338: ELSE
2339: --- we fail the PTF date test
2340: IF PG_DEBUG in ('Y', 'C') THEN
2341: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Fail the PTF test, dont add org to list of org to be visited');
2342: END IF;
2343: END IF;
2344:
2345: END IF; -- IF l_sources.source_type = 'TRANSFER' THEN
2343: END IF;
2344:
2345: END IF; -- IF l_sources.source_type = 'TRANSFER' THEN
2346: IF PG_DEBUG in ('Y', 'C') THEN
2347: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_org_cntr := ' || l_parent_org_cntr);
2348: END IF;
2349: END LOOP;
2350: END IF;
2351:
2349: END LOOP;
2350: END IF;
2351:
2352: IF PG_DEBUG in ('Y', 'C') THEN
2353: msc_sch_wb.atp_debug('highest rev: ' || l_highest_rev_item_id);
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2350: END IF;
2351:
2352: IF PG_DEBUG in ('Y', 'C') THEN
2353: msc_sch_wb.atp_debug('highest rev: ' || l_highest_rev_item_id);
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2358: msc_sch_wb.atp_debug('org: ' || org_availability_info.org_code(l_parent_org_cntr));
2351:
2352: IF PG_DEBUG in ('Y', 'C') THEN
2353: msc_sch_wb.atp_debug('highest rev: ' || l_highest_rev_item_id);
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2358: msc_sch_wb.atp_debug('org: ' || org_availability_info.org_code(l_parent_org_cntr));
2359: END IF;
2352: IF PG_DEBUG in ('Y', 'C') THEN
2353: msc_sch_wb.atp_debug('highest rev: ' || l_highest_rev_item_id);
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2358: msc_sch_wb.atp_debug('org: ' || org_availability_info.org_code(l_parent_org_cntr));
2359: END IF;
2360:
2353: msc_sch_wb.atp_debug('highest rev: ' || l_highest_rev_item_id);
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2358: msc_sch_wb.atp_debug('org: ' || org_availability_info.org_code(l_parent_org_cntr));
2359: END IF;
2360:
2361: -- if this is diagnostic atp, and there are no transfer sources, and we cannot create
2354: msc_sch_wb.atp_debug('l_sources_found: ' || l_sources_found);
2355: msc_sch_wb.atp_debug('l_transfer_found: ' || l_transfer_found);
2356: msc_sch_wb.atp_debug('G_CREATE_SUPPLY: ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
2357: msc_sch_wb.atp_debug('item create_supply: ' || item_availability_info.create_supply_flag(l_item_count));
2358: msc_sch_wb.atp_debug('org: ' || org_availability_info.org_code(l_parent_org_cntr));
2359: END IF;
2360:
2361: -- if this is diagnostic atp, and there are no transfer sources, and we cannot create
2362: -- a supply on the demanded item then flag it as a material constraint.
2385:
2386: --- AT this point we should have complete picture as to what is the demand availability in each org
2387: --- So we create planned orders and peggings in each org
2388: IF PG_DEBUG in ('Y', 'C') THEN
2389: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Done with ATP check, now add pegging, planned orders');
2390: msc_sch_wb.atp_debug('reset Subst last PO pegging: ');
2391: END IF;
2392:
2393: MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING := null;
2386: --- AT this point we should have complete picture as to what is the demand availability in each org
2387: --- So we create planned orders and peggings in each org
2388: IF PG_DEBUG in ('Y', 'C') THEN
2389: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Done with ATP check, now add pegging, planned orders');
2390: msc_sch_wb.atp_debug('reset Subst last PO pegging: ');
2391: END IF;
2392:
2393: MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING := null;
2394: MSC_ATP_SUBST.G_TOP_LAST_PO_QTY := 0;
2410: IF nvl(org_availability_info.rounding_flag(l_parent_index), 2) = 1 THEN
2411: l_addt_qty := FLOOR(ROUND(l_addt_qty, 10));
2412: END IF;
2413:
2414: msc_sch_wb.atp_debug('l_addt_qty: ' || l_addt_qty);
2415:
2416: org_availability_info.quantity_from_children(l_parent_index) :=
2417: NVL(org_availability_info.quantity_from_children(l_parent_index), 0) +
2418: l_addt_qty;
2416: org_availability_info.quantity_from_children(l_parent_index) :=
2417: NVL(org_availability_info.quantity_from_children(l_parent_index), 0) +
2418: l_addt_qty;
2419:
2420: msc_sch_wb.atp_debug('qty from children('||l_parent_index||'): ' ||
2421: org_availability_info.quantity_from_children(l_parent_index));
2422: END LOOP;
2423: -- END IF;
2424: */
2424: */
2425:
2426: FOR j in reverse 1..org_availability_info.organization_id.count LOOP
2427: IF PG_DEBUG in ('Y', 'C') THEN
2428: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Process orgination := ' || org_availability_info.organization_id(j));
2429: END IF;
2430: -- dsting 2754446
2431: l_parent_index := nvl(org_availability_info.parent_org_idx(j), 1);
2432:
2430: -- dsting 2754446
2431: l_parent_index := nvl(org_availability_info.parent_org_idx(j), 1);
2432:
2433: IF PG_DEBUG in ('Y', 'C') THEN
2434: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_index := ' || l_parent_index);
2435: END IF;
2436:
2437: IF (org_availability_info.atp_flag(j) = 'N' AND org_availability_info.atp_comp_flag(j) = 'N') THEN
2438:
2437: IF (org_availability_info.atp_flag(j) = 'N' AND org_availability_info.atp_comp_flag(j) = 'N') THEN
2438:
2439: --- NON-ATPABLE ITEM item is non atpable then we add planned order in parent org
2440: IF PG_DEBUG in ('Y', 'C') THEN
2441: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item is Non Atpable');
2442: END IF;
2443:
2444: -- dsting 2754446 req_date_qty and qty_from_chld should already be rounded to correct values
2445: -- for creating a PO in the top org's uom. so convert the uom, and round to remove float precision errs
2458: / org_availability_info.conversion_rate(j);
2459: END IF;
2460:
2461: IF PG_DEBUG in ('Y', 'C') THEN
2462: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(j));
2463: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2464: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2465: END IF;
2466:
2459: END IF;
2460:
2461: IF PG_DEBUG in ('Y', 'C') THEN
2462: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(j));
2463: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2464: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2465: END IF;
2466:
2467: IF j = 1 THEN
2460:
2461: IF PG_DEBUG in ('Y', 'C') THEN
2462: msc_sch_wb.atp_debug('rounding_flag: ' || org_availability_info.rounding_flag(j));
2463: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2464: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2465: END IF;
2466:
2467: IF j = 1 THEN
2468: --- bug 2344501: set the error only if it is a top org
2527: -- Asssign the output to local variables.
2528: l_transaction_id := l_supply_rec.transaction_id;
2529: l_return_status := l_supply_rec.return_status;
2530: IF PG_DEBUG in ('Y', 'C') THEN
2531: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2532: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2528: l_transaction_id := l_supply_rec.transaction_id;
2529: l_return_status := l_supply_rec.return_status;
2530: IF PG_DEBUG in ('Y', 'C') THEN
2531: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2532: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2529: l_return_status := l_supply_rec.return_status;
2530: IF PG_DEBUG in ('Y', 'C') THEN
2531: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2532: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2537: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2530: IF PG_DEBUG in ('Y', 'C') THEN
2531: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2532: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2537: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2538: END IF;
2532: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2537: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2538: END IF;
2539:
2540: ELSE -- Create Planned Order otherwise.
2533: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2535: || l_supply_rec.supply_type);
2536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2537: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2538: END IF;
2539:
2540: ELSE -- Create Planned Order otherwise.
2541: IF PG_DEBUG in ('Y', 'C') THEN
2538: END IF;
2539:
2540: ELSE -- Create Planned Order otherwise.
2541: IF PG_DEBUG in ('Y', 'C') THEN
2542: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add planned order');
2543: END IF;
2544:
2545: MSC_ATP_DB_UTILS.Add_Planned_Order (
2546: p_atp_record.instance_id,
2583: -- END IF;
2584:
2585: --- now add PO pegging
2586: IF PG_DEBUG in ('Y', 'C') THEN
2587: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging for PO');
2588: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_index := ' || l_parent_index);
2589: END IF;
2590:
2591: Prep_PO_Pegging_Rec(l_pegging_rec,
2584:
2585: --- now add PO pegging
2586: IF PG_DEBUG in ('Y', 'C') THEN
2587: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging for PO');
2588: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_index := ' || l_parent_index);
2589: END IF;
2590:
2591: Prep_PO_Pegging_Rec(l_pegging_rec,
2592: p_atp_record,
2605: ELSIF NVL(org_availability_info.demand_id(j), -1) > 0 THEN
2606: ---Above condition will filter out al the orgs that we did not visit but added to org_availability_info
2607: -- then we remove the demand provided its not in the top org
2608: IF PG_DEBUG in ('Y', 'C') THEN
2609: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Current org := ' || org_availability_info.organization_id(j));
2610: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand id in this org := ' || org_availability_info.demand_id(j));
2611: END IF;
2612:
2613: -- dsting 2754446
2606: ---Above condition will filter out al the orgs that we did not visit but added to org_availability_info
2607: -- then we remove the demand provided its not in the top org
2608: IF PG_DEBUG in ('Y', 'C') THEN
2609: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Current org := ' || org_availability_info.organization_id(j));
2610: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand id in this org := ' || org_availability_info.demand_id(j));
2611: END IF;
2612:
2613: -- dsting 2754446
2614: /*
2630: * org_availability_info.conversion_rate(l_parent_index);
2631: END IF;
2632:
2633: IF PG_DEBUG in ('Y', 'C') THEN
2634: msc_sch_wb.atp_debug('l_parent_index: ' || l_parent_index);
2635: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2636: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2637: END IF;
2638:
2631: END IF;
2632:
2633: IF PG_DEBUG in ('Y', 'C') THEN
2634: msc_sch_wb.atp_debug('l_parent_index: ' || l_parent_index);
2635: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2636: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2637: END IF;
2638:
2639: -- dsting do not update demands for diagnostic atp
2632:
2633: IF PG_DEBUG in ('Y', 'C') THEN
2634: msc_sch_wb.atp_debug('l_parent_index: ' || l_parent_index);
2635: msc_sch_wb.atp_debug('l_avail_qty_top_uom: ' || l_avail_qty_top_uom);
2636: msc_sch_wb.atp_debug('l_available_quantity: ' || l_available_quantity);
2637: END IF;
2638:
2639: -- dsting do not update demands for diagnostic atp
2640: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP <> DIAGNOSTIC_ATP THEN
2642: IF j > 1 AND l_available_quantity <= 0
2643: THEN
2644: --- if we do nto get anything from this org then we remove the demand
2645: IF PG_DEBUG in ('Y', 'C') THEN
2646: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Delete Demand');
2647: END IF;
2648: MSC_ATP_SUBST.delete_demand_subst(org_availability_info.demand_id(j),
2649: org_availability_info.plan_id(j));
2650: ELSE
2650: ELSE
2651:
2652: --- update demand
2653: IF PG_DEBUG in ('Y', 'C') THEN
2654: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_available_quantity := ' || l_available_quantity);
2655: END IF;
2656:
2657: -- 2754446
2658: -- IF org_availability_info.demand_quantity(j) > l_available_quantity and j > 1
2661: THEN
2662: --- we update demands from J > 1 because we want to retain full demand in top org
2663: --- as CTP is still left to be done
2664: IF PG_DEBUG in ('Y', 'C') THEN
2665: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Update demand');
2666: END IF;
2667: MSC_ATP_SUBST.UPDATE_DEMAND(org_availability_info.demand_id(j),
2668: org_availability_info.plan_id(j),
2669: -- dsting 2754446
2685: l_return_status
2686: );
2687: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2688: IF PG_DEBUG in ('Y', 'C') THEN
2689: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Increment_Bucketed_Demands_Qty');
2690: END IF;
2691: RAISE FND_API.G_EXC_ERROR;
2692: END IF;
2693: END IF;
2694: -- time_phased_atp changes end
2695:
2696: END IF;
2697: IF PG_DEBUG in ('Y', 'C') THEN
2698: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add pegging');
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2695:
2696: END IF;
2697: IF PG_DEBUG in ('Y', 'C') THEN
2698: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add pegging');
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2703: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity :=' || l_atp_insert_rec.atf_date_quantity);
2696: END IF;
2697: IF PG_DEBUG in ('Y', 'C') THEN
2698: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add pegging');
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2703: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity :=' || l_atp_insert_rec.atf_date_quantity);
2704: END IF;
2697: IF PG_DEBUG in ('Y', 'C') THEN
2698: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add pegging');
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2703: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity :=' || l_atp_insert_rec.atf_date_quantity);
2704: END IF;
2705:
2698: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add pegging');
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2703: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity :=' || l_atp_insert_rec.atf_date_quantity);
2704: END IF;
2705:
2706: END IF;
2699: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP Flag := ' || org_availability_info.atp_flag(J));
2700: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag :=' || org_availability_info.atp_comp_flag(j));
2701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.quantity_ordered :=' || l_atp_insert_rec.quantity_ordered);
2702: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.requested_date_quantity :=' || l_atp_insert_rec.requested_date_quantity);
2703: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_insert_rec.atf_date_quantity :=' || l_atp_insert_rec.atf_date_quantity);
2704: END IF;
2705:
2706: END IF;
2707: END IF; -- dsting diagnostic ATP
2706: END IF;
2707: END IF; -- dsting diagnostic ATP
2708:
2709: IF PG_DEBUG in ('Y', 'C') THEN
2710: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging after onhand pass');
2711: END IF;
2712:
2713: -- 2754446
2714: l_PO_qty := org_availability_info.demand_quantity(j)
2718: l_PO_qty := CEIL(ROUND(l_PO_qty,10));
2719: END IF;
2720:
2721: IF PG_DEBUG in ('Y', 'C') THEN
2722: msc_sch_wb.atp_debug('l_PO_qty: ' || l_PO_qty);
2723: msc_sch_wb.atp_debug('dmd qty: ' || org_availability_info.demand_quantity(j));
2724: msc_sch_Wb.atp_debug('conv rate: ' || org_availability_info.conversion_rate(l_parent_index));
2725: END IF;
2726:
2719: END IF;
2720:
2721: IF PG_DEBUG in ('Y', 'C') THEN
2722: msc_sch_wb.atp_debug('l_PO_qty: ' || l_PO_qty);
2723: msc_sch_wb.atp_debug('dmd qty: ' || org_availability_info.demand_quantity(j));
2724: msc_sch_Wb.atp_debug('conv rate: ' || org_availability_info.conversion_rate(l_parent_index));
2725: END IF;
2726:
2727: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP OR
2720:
2721: IF PG_DEBUG in ('Y', 'C') THEN
2722: msc_sch_wb.atp_debug('l_PO_qty: ' || l_PO_qty);
2723: msc_sch_wb.atp_debug('dmd qty: ' || org_availability_info.demand_quantity(j));
2724: msc_sch_Wb.atp_debug('conv rate: ' || org_availability_info.conversion_rate(l_parent_index));
2725: END IF;
2726:
2727: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP OR
2728: (l_available_quantity > 0 or j =1)
2728: (l_available_quantity > 0 or j =1)
2729: THEN
2730: --- now add demand pegging
2731: IF PG_DEBUG in ('Y', 'C') THEN
2732: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add demand Pegging');
2733: END IF;
2734:
2735: Prep_Demand_Pegging_rec(l_pegging_rec,
2736: p_atp_record,
2744: -- dsting or if we're doing diagnostic atp
2745: -- dsting 2754446
2746: l_pegging_rec.supply_demand_quantity:= org_availability_info.demand_quantity(j);
2747: IF PG_DEBUG in ('Y', 'C') THEN
2748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' J1:= ' || j);
2749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'quantity := ' || l_pegging_rec.supply_demand_quantity);
2750: END IF;
2751: ELSE
2752: --- if it is other org then we create demand for least of what we need and what is available
2745: -- dsting 2754446
2746: l_pegging_rec.supply_demand_quantity:= org_availability_info.demand_quantity(j);
2747: IF PG_DEBUG in ('Y', 'C') THEN
2748: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' J1:= ' || j);
2749: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'quantity := ' || l_pegging_rec.supply_demand_quantity);
2750: END IF;
2751: ELSE
2752: --- if it is other org then we create demand for least of what we need and what is available
2753: -- dsting 2754446
2754: l_pegging_rec.supply_demand_quantity:=
2755: least(org_availability_info.demand_quantity(j),
2756: l_available_quantity * org_availability_info.conversion_rate(j));
2757: IF PG_DEBUG in ('Y', 'C') THEN
2758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' J:= ' || j);
2759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'quantity := ' ||
2760: l_pegging_rec.supply_demand_quantity);
2761: END IF;
2762:
2755: least(org_availability_info.demand_quantity(j),
2756: l_available_quantity * org_availability_info.conversion_rate(j));
2757: IF PG_DEBUG in ('Y', 'C') THEN
2758: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' J:= ' || j);
2759: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'quantity := ' ||
2760: l_pegging_rec.supply_demand_quantity);
2761: END IF;
2762:
2763: END IF;
2770: --- we add supply pegging only for item where atp_flag = 'Y'
2771: IF org_availability_info.atp_flag(j) in ('Y', 'C') THEN
2772: --- now add supply pegging
2773: IF PG_DEBUG in ('Y', 'C') THEN
2774: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add Supply Pegging');
2775: END IF;
2776:
2777: Prep_Supply_Pegging_Rec(l_pegging_rec,
2778: p_atp_record,
2789: END IF;
2790: -- END IF; -- if l_available_qty > 0
2791:
2792: IF PG_DEBUG in ('Y', 'C') THEN
2793: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after adding Supply and Demand Pegging');
2794: END IF;
2795: --- now add planned order
2796: IF j > 1 and (l_available_quantity > 0 or MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP) THEN
2797: --- we create planned order for tier 2 orgs only
2796: IF j > 1 and (l_available_quantity > 0 or MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP) THEN
2797: --- we create planned order for tier 2 orgs only
2798: -- we create the planned order in parent org
2799: IF PG_DEBUG in ('Y', 'C') THEN
2800: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_available_quantity > 0 or Diagnostic ATP');
2801: msc_sch_wb.atp_debug('qty from children: ' || NVL(org_availability_info.quantity_from_children(l_parent_index), 0));
2802: msc_sch_wb.atp_debug('l_available_quantity: '|| l_available_quantity);
2803: END IF;
2804:
2797: --- we create planned order for tier 2 orgs only
2798: -- we create the planned order in parent org
2799: IF PG_DEBUG in ('Y', 'C') THEN
2800: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_available_quantity > 0 or Diagnostic ATP');
2801: msc_sch_wb.atp_debug('qty from children: ' || NVL(org_availability_info.quantity_from_children(l_parent_index), 0));
2802: msc_sch_wb.atp_debug('l_available_quantity: '|| l_available_quantity);
2803: END IF;
2804:
2805: -- We balance out the supply/demand for the parent org since it is not a constraint node
2798: -- we create the planned order in parent org
2799: IF PG_DEBUG in ('Y', 'C') THEN
2800: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_available_quantity > 0 or Diagnostic ATP');
2801: msc_sch_wb.atp_debug('qty from children: ' || NVL(org_availability_info.quantity_from_children(l_parent_index), 0));
2802: msc_sch_wb.atp_debug('l_available_quantity: '|| l_available_quantity);
2803: END IF;
2804:
2805: -- We balance out the supply/demand for the parent org since it is not a constraint node
2806: -- for the last transfer child of an org that gets into org_availability_info,
2819: NVL(org_availability_info.quantity_from_children(l_parent_index), 0) -
2820: greatest(org_availability_info.request_date_quantity(l_parent_index), 0)
2821: ) + l_available_quantity;
2822: IF PG_DEBUG in ('Y', 'C') THEN
2823: msc_sch_wb.atp_debug('remaining dmd qty of parent: ' || l_diag_supply_qty);
2824: END IF;
2825: ELSE
2826: -- dsting 2754446
2827: -- l_diag_supply_qty := least(org_availability_info.demand_quantity(j),
2827: -- l_diag_supply_qty := least(org_availability_info.demand_quantity(j),
2828: l_diag_supply_qty := least(l_PO_qty,
2829: greatest(0,l_available_quantity));
2830: IF PG_DEBUG in ('Y', 'C') THEN
2831: msc_sch_Wb.atp_debug('l_PO_qty: ' || l_PO_qty);
2832: msc_sch_wb.atp_debug('l_PO_qty - avail qty: ' || l_diag_supply_qty);
2833: END IF;
2834: END IF;
2835:
2828: l_diag_supply_qty := least(l_PO_qty,
2829: greatest(0,l_available_quantity));
2830: IF PG_DEBUG in ('Y', 'C') THEN
2831: msc_sch_Wb.atp_debug('l_PO_qty: ' || l_PO_qty);
2832: msc_sch_wb.atp_debug('l_PO_qty - avail qty: ' || l_diag_supply_qty);
2833: END IF;
2834: END IF;
2835:
2836: -- dsting set G_TOP_LAST_PO_PEGGING and G_TOP_LAST_PO_QTY in case the ctp
2838: IF l_parent_index = 1 AND MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING is NULL THEN
2839: MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING := org_availability_info.PO_Pegging_id(j);
2840: MSC_ATP_SUBST.G_TOP_LAST_PO_QTY := l_diag_supply_qty;
2841: IF PG_DEBUG in ('Y', 'C') THEN
2842: msc_sch_wb.atp_debug('Subst last PO pegging: ' || MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING);
2843: END IF;
2844: END IF;
2845:
2846: IF l_diag_supply_qty > 0
2891: -- Asssign the output to local variables.
2892: l_transaction_id := l_supply_rec.transaction_id;
2893: l_return_status := l_supply_rec.return_status;
2894: IF PG_DEBUG in ('Y', 'C') THEN
2895: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2896: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2892: l_transaction_id := l_supply_rec.transaction_id;
2893: l_return_status := l_supply_rec.return_status;
2894: IF PG_DEBUG in ('Y', 'C') THEN
2895: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2896: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2900: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2893: l_return_status := l_supply_rec.return_status;
2894: IF PG_DEBUG in ('Y', 'C') THEN
2895: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2896: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2900: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2901: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2894: IF PG_DEBUG in ('Y', 'C') THEN
2895: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2896: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2900: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2901: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2902: END IF;
2896: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'DRP Plan Add Planned Inbound');
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2900: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2901: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2902: END IF;
2903:
2904: ELSE -- Create Planned Order otherwise.
2897: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
2898: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
2899: || l_supply_rec.supply_type);
2900: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
2901: msc_sch_wb.atp_debug('----- ATP4drp Specific Debug Messages -----');
2902: END IF;
2903:
2904: ELSE -- Create Planned Order otherwise.
2905: IF PG_DEBUG in ('Y', 'C') THEN
2902: END IF;
2903:
2904: ELSE -- Create Planned Order otherwise.
2905: IF PG_DEBUG in ('Y', 'C') THEN
2906: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add planned order');
2907: END IF;
2908: MSC_ATP_DB_UTILS.Add_Planned_Order(
2909: p_atp_record.instance_id,
2910: org_availability_info.plan_id(l_parent_index),
2950: MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP
2951: THEN
2952:
2953: IF PG_DEBUG in ('Y', 'C') THEN
2954: msc_sch_wb.atp_debug('balance supply/demand for nonconstrained node');
2955: END IF;
2956: -- Begin ATP4drp Create Planned Arrivals for DRP plans
2957: IF (NVL(MSC_ATP_PVT.G_PLAN_INFO_REC.plan_type,1) = 5) THEN
2958: l_supply_rec.instance_id := p_atp_record.instance_id;
2998: -- Asssign the output to local variables.
2999: l_transaction_id := l_supply_rec.transaction_id;
3000: l_return_status := l_supply_rec.return_status;
3001: IF PG_DEBUG in ('Y', 'C') THEN
3002: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
3003: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
3004: || l_supply_rec.supply_type);
3005: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
3006: END IF;
2999: l_transaction_id := l_supply_rec.transaction_id;
3000: l_return_status := l_supply_rec.return_status;
3001: IF PG_DEBUG in ('Y', 'C') THEN
3002: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
3003: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
3004: || l_supply_rec.supply_type);
3005: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
3006: END IF;
3007:
3001: IF PG_DEBUG in ('Y', 'C') THEN
3002: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Id l_transaction_id: ' || l_transaction_id);
3003: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Supply Type l_supply_rec.supply_type: '
3004: || l_supply_rec.supply_type);
3005: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Return Status l_return_status: ' || l_return_status);
3006: END IF;
3007:
3008: ELSE -- Create Planned Order otherwise.
3009: MSC_ATP_DB_UTILS.Add_Planned_Order(
3046: END IF;
3047:
3048: --- now add PO pegging
3049: IF PG_DEBUG in ('Y', 'C') THEN
3050: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging for PO');
3051: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_index := ' || l_parent_index);
3052: END IF;
3053:
3054: Prep_PO_Pegging_Rec(l_pegging_rec,
3047:
3048: --- now add PO pegging
3049: IF PG_DEBUG in ('Y', 'C') THEN
3050: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging for PO');
3051: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_parent_index := ' || l_parent_index);
3052: END IF;
3053:
3054: Prep_PO_Pegging_Rec(l_pegging_rec,
3055: p_atp_record,
3069: END IF;
3070: END IF; -- <
3071: END IF; -- IF NVL(org_availability_info.demand_id(j), -1) > 0 THEN
3072: IF PG_DEBUG in ('Y', 'C') THEN
3073: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'after adding pegging for supplies, demand and planned order');
3074: END IF;
3075:
3076:
3077:
3092: NVL(org_availability_info.steal_qty(j), 0)),
3093: l_PO_qty/org_availability_info.conversion_rate(l_parent_index));
3094:
3095: IF PG_DEBUG in ('Y', 'C') THEN
3096: msc_sch_wb.atp_debug('ATP_Check_Subst: Update children quantity in parent org: idx '
3097: || l_parent_index || ' qty: ' || org_availability_info.quantity_from_children(l_parent_index));
3098: END IF;
3099: END IF;
3100: */
3111: and organization_id = org_availability_info.organization_id(j);
3112: END LOOP;
3113:
3114: IF PG_DEBUG in ('Y', 'C') THEN
3115: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'After getting availablity for current item in all orgs');
3116: END IF;
3117: -- now we populate item info
3118: IF PG_DEBUG in ('Y', 'C') THEN
3119: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'End pegging id := ' || org_availability_info.demand_pegging_id(1));
3115: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'After getting availablity for current item in all orgs');
3116: END IF;
3117: -- now we populate item info
3118: IF PG_DEBUG in ('Y', 'C') THEN
3119: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'End pegging id := ' || org_availability_info.demand_pegging_id(1));
3120: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_counter := ' || l_item_cntr);
3121: END IF;
3122: Item_availability_info.End_pegging_id(l_item_cntr) := org_availability_info.demand_pegging_id(1);
3123: Item_availability_info.request_date_quantity(l_item_cntr) :=
3116: END IF;
3117: -- now we populate item info
3118: IF PG_DEBUG in ('Y', 'C') THEN
3119: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'End pegging id := ' || org_availability_info.demand_pegging_id(1));
3120: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_counter := ' || l_item_cntr);
3121: END IF;
3122: Item_availability_info.End_pegging_id(l_item_cntr) := org_availability_info.demand_pegging_id(1);
3123: Item_availability_info.request_date_quantity(l_item_cntr) :=
3124: GREATEST(org_availability_info.request_date_quantity(1), 0) +
3131: l_sd_end_idx := l_all_atp_supply_demand.level.count;
3132:
3133: IF PG_DEBUG in ('Y', 'C') THEN
3134: --bug3467631 start
3135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_date_quantity := ' || Item_availability_info.request_date_quantity(l_item_cntr));
3136: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Atf_Date_Quantity := ' || Item_availability_info.Atf_Date_Quantity(l_item_cntr));
3137: --bug3467631 end
3138: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_end_idx := ' || l_period_end_idx);
3139: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_end_idx := ' || l_sd_end_idx);
3132:
3133: IF PG_DEBUG in ('Y', 'C') THEN
3134: --bug3467631 start
3135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_date_quantity := ' || Item_availability_info.request_date_quantity(l_item_cntr));
3136: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Atf_Date_Quantity := ' || Item_availability_info.Atf_Date_Quantity(l_item_cntr));
3137: --bug3467631 end
3138: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_end_idx := ' || l_period_end_idx);
3139: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_end_idx := ' || l_sd_end_idx);
3140: END IF;
3134: --bug3467631 start
3135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_date_quantity := ' || Item_availability_info.request_date_quantity(l_item_cntr));
3136: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Atf_Date_Quantity := ' || Item_availability_info.Atf_Date_Quantity(l_item_cntr));
3137: --bug3467631 end
3138: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_end_idx := ' || l_period_end_idx);
3139: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_end_idx := ' || l_sd_end_idx);
3140: END IF;
3141:
3142: item_availability_info.period_detail_end_Idx(l_item_cntr) := l_period_end_idx;
3135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_date_quantity := ' || Item_availability_info.request_date_quantity(l_item_cntr));
3136: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Atf_Date_Quantity := ' || Item_availability_info.Atf_Date_Quantity(l_item_cntr));
3137: --bug3467631 end
3138: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_period_end_idx := ' || l_period_end_idx);
3139: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sd_end_idx := ' || l_sd_end_idx);
3140: END IF;
3141:
3142: item_availability_info.period_detail_end_Idx(l_item_cntr) := l_period_end_idx;
3143: item_availability_info.sd_detail_end_idx(l_item_cntr) := l_sd_end_idx;
3142: item_availability_info.period_detail_end_Idx(l_item_cntr) := l_period_end_idx;
3143: item_availability_info.sd_detail_end_idx(l_item_cntr) := l_sd_end_idx;
3144:
3145: IF PG_DEBUG in ('Y', 'C') THEN
3146: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'After updating item info');
3147: END IF;
3148:
3149: -- Set p_atp_record to the item that is used to satisfy the demand
3150: IF l_net_demand <= 0 THEN
3148:
3149: -- Set p_atp_record to the item that is used to satisfy the demand
3150: IF l_net_demand <= 0 THEN
3151: IF PG_DEBUG in ('Y', 'C') THEN
3152: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Met the requirement using item ' || item_availability_info.item_name(l_item_cntr));
3153: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Sr inv Id for the item := ' || item_availability_info.sr_inventory_item_id(l_item_cntr));
3154: END IF;
3155: --IF item_availability_info.sr_inventory_item_id(l_item_cntr) <> p_atp_record.inventory_item_id THEN
3156: --bug3467631
3149: -- Set p_atp_record to the item that is used to satisfy the demand
3150: IF l_net_demand <= 0 THEN
3151: IF PG_DEBUG in ('Y', 'C') THEN
3152: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Met the requirement using item ' || item_availability_info.item_name(l_item_cntr));
3153: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Sr inv Id for the item := ' || item_availability_info.sr_inventory_item_id(l_item_cntr));
3154: END IF;
3155: --IF item_availability_info.sr_inventory_item_id(l_item_cntr) <> p_atp_record.inventory_item_id THEN
3156: --bug3467631
3157: IF item_availability_info.sr_inventory_item_id(l_item_cntr) <>
3157: IF item_availability_info.sr_inventory_item_id(l_item_cntr) <>
3158: NVL(p_atp_record.request_item_id,
3159: p_atp_record.inventory_item_id) THEN
3160: IF PG_DEBUG in ('Y', 'C') THEN
3161: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand is satisfied by substitute');
3162: END IF;
3163: --- set the flag
3164: l_satisfied_by_subst_flag := 1;
3165: ELSE
3163: --- set the flag
3164: l_satisfied_by_subst_flag := 1;
3165: ELSE
3166: IF PG_DEBUG in ('Y', 'C') THEN
3167: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand is satisfied by the original item');
3168: END IF;
3169: l_satisfied_by_subst_flag := 2;
3170: END IF;
3171: IF PG_DEBUG in ('Y', 'C') THEN
3168: END IF;
3169: l_satisfied_by_subst_flag := 2;
3170: END IF;
3171: IF PG_DEBUG in ('Y', 'C') THEN
3172: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := ' || l_satisfied_by_subst_flag);
3173: END IF;
3174:
3175: --l_demand_satisfied_by_item_id := item_availability_info.sr_inventory_item_id(l_item_cntr);
3176: /* time_phased_atp changes begin
3187: p_atp_record.original_item_id := item_availability_info.sr_inventory_item_id(l_item_count);
3188: p_atp_record.original_item_name := item_availability_info.item_name(l_item_count);
3189:
3190: IF PG_DEBUG in ('Y', 'C') THEN
3191: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3188: p_atp_record.original_item_name := item_availability_info.item_name(l_item_count);
3189:
3190: IF PG_DEBUG in ('Y', 'C') THEN
3191: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3196: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3189:
3190: IF PG_DEBUG in ('Y', 'C') THEN
3191: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3196: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3197: END IF;
3190: IF PG_DEBUG in ('Y', 'C') THEN
3191: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3196: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3197: END IF;
3198: -- time_phased_atp changes end
3191: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3196: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3197: END IF;
3198: -- time_phased_atp changes end
3199:
3192: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3193: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3194: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3195: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3196: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3197: END IF;
3198: -- time_phased_atp changes end
3199:
3200: --p_atp_record.End_pegging_id := item_availability_info.End_pegging_id(l_item_cntr);
3236: END IF;
3237:
3238: --- add suply demand and period details
3239: IF PG_DEBUG in ('Y', 'C') THEN
3240: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_begin_idx := '|| item_availability_info.period_detail_begin_idx(l_item_cntr));
3241: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_end_idx := ' || item_availability_info.period_detail_end_idx(l_item_cntr));
3242: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_begin_idx:= ' || item_availability_info.sd_detail_begin_idx(l_item_cntr));
3243: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_end_idx:= ' || item_availability_info.sd_detail_end_idx(l_item_cntr));
3244: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.Atf_Date_Quantity:= ' || p_atp_record.Atf_Date_Quantity); --bug3467631
3237:
3238: --- add suply demand and period details
3239: IF PG_DEBUG in ('Y', 'C') THEN
3240: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_begin_idx := '|| item_availability_info.period_detail_begin_idx(l_item_cntr));
3241: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_end_idx := ' || item_availability_info.period_detail_end_idx(l_item_cntr));
3242: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_begin_idx:= ' || item_availability_info.sd_detail_begin_idx(l_item_cntr));
3243: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_end_idx:= ' || item_availability_info.sd_detail_end_idx(l_item_cntr));
3244: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.Atf_Date_Quantity:= ' || p_atp_record.Atf_Date_Quantity); --bug3467631
3245: END IF;
3238: --- add suply demand and period details
3239: IF PG_DEBUG in ('Y', 'C') THEN
3240: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_begin_idx := '|| item_availability_info.period_detail_begin_idx(l_item_cntr));
3241: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_end_idx := ' || item_availability_info.period_detail_end_idx(l_item_cntr));
3242: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_begin_idx:= ' || item_availability_info.sd_detail_begin_idx(l_item_cntr));
3243: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_end_idx:= ' || item_availability_info.sd_detail_end_idx(l_item_cntr));
3244: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.Atf_Date_Quantity:= ' || p_atp_record.Atf_Date_Quantity); --bug3467631
3245: END IF;
3246: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
3239: IF PG_DEBUG in ('Y', 'C') THEN
3240: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_begin_idx := '|| item_availability_info.period_detail_begin_idx(l_item_cntr));
3241: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_end_idx := ' || item_availability_info.period_detail_end_idx(l_item_cntr));
3242: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_begin_idx:= ' || item_availability_info.sd_detail_begin_idx(l_item_cntr));
3243: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_end_idx:= ' || item_availability_info.sd_detail_end_idx(l_item_cntr));
3244: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.Atf_Date_Quantity:= ' || p_atp_record.Atf_Date_Quantity); --bug3467631
3245: END IF;
3246: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
3247: l_all_atp_supply_demand,
3240: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_begin_idx := '|| item_availability_info.period_detail_begin_idx(l_item_cntr));
3241: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'period_detail_end_idx := ' || item_availability_info.period_detail_end_idx(l_item_cntr));
3242: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_begin_idx:= ' || item_availability_info.sd_detail_begin_idx(l_item_cntr));
3243: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'sd_detail_end_idx:= ' || item_availability_info.sd_detail_end_idx(l_item_cntr));
3244: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.Atf_Date_Quantity:= ' || p_atp_record.Atf_Date_Quantity); --bug3467631
3245: END IF;
3246: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
3247: l_all_atp_supply_demand,
3248: item_availability_info.period_detail_begin_idx(l_item_cntr),
3256: FOR i in (l_item_cntr +1)..l_item_count LOOP
3257: IF NOT (l_org_item_detail_flag = 1 and l_satisfied_by_subst_flag = 1 and
3258: item_availability_info.sr_inventory_item_id(i) = MSC_ATP_SUBST.G_REQ_ITEM_SR_INV_ID) THEN
3259: IF PG_DEBUG in ('Y', 'C') THEN
3260: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'remove demands for item ' || item_availability_info.item_name(i));
3261: END IF;
3262: MSC_ATP_DB_UTILS.Remove_Invalid_SD_Rec(
3263: item_availability_info.End_pegging_id(i),
3264: null,
3273: --l_item_cntr := l_item_cntr + 1;
3274:
3275: END LOOP; --- WHILE item_counter <= item_availability_info.inventory_item_id.count AND
3276: IF PG_DEBUG in ('Y', 'C') THEN
3277: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item Availability Picture After Onhand search');
3278: END IF;
3279:
3280: IF PG_DEBUG in ('Y', 'C') THEN
3281: For i in 1..item_availability_info.inventory_item_id.count LOOP --bug3467631
3278: END IF;
3279:
3280: IF PG_DEBUG in ('Y', 'C') THEN
3281: For i in 1..item_availability_info.inventory_item_id.count LOOP --bug3467631
3282: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.item_name(i) ||' ' ||item_availability_info.sr_inventory_item_id(i) ||
3283: ' ' || item_availability_info.request_date_quantity(i) ||
3284: ' ' || item_availability_info.Atf_Date_Quantity(i));
3285: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.family_sr_id(i) ||' ' ||item_availability_info.family_item_name(i));
3286:
3281: For i in 1..item_availability_info.inventory_item_id.count LOOP --bug3467631
3282: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.item_name(i) ||' ' ||item_availability_info.sr_inventory_item_id(i) ||
3283: ' ' || item_availability_info.request_date_quantity(i) ||
3284: ' ' || item_availability_info.Atf_Date_Quantity(i));
3285: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.family_sr_id(i) ||' ' ||item_availability_info.family_item_name(i));
3286:
3287: END LOOP;
3288: END IF;
3289:
3287: END LOOP;
3288: END IF;
3289:
3290: IF PG_DEBUG in ('Y', 'C') THEN
3291: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do backward CTP pass if needed. net demand: ' || l_net_demand);
3292: END IF;
3293:
3294:
3295: --- if demand is not met then do CTP
3300: --l_org_item_detail_flag := NVL(p_atp_record.req_item_detail_flag, 2);
3301: --l_org_item_detail_flag := 1;
3302: l_net_demand_after_oh_check := l_net_demand;
3303: IF PG_DEBUG in ('Y', 'C') THEN
3304: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Net demand after Onhand search := ' || l_net_demand);
3305: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_item_detail_flag := ' || l_org_item_detail_flag);
3306: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := ' || l_satisfied_by_subst_flag);
3307: END IF;
3308: IF ((l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1)) or (l_net_demand_after_oh_check > 0) THEN
3301: --l_org_item_detail_flag := 1;
3302: l_net_demand_after_oh_check := l_net_demand;
3303: IF PG_DEBUG in ('Y', 'C') THEN
3304: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Net demand after Onhand search := ' || l_net_demand);
3305: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_item_detail_flag := ' || l_org_item_detail_flag);
3306: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := ' || l_satisfied_by_subst_flag);
3307: END IF;
3308: IF ((l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1)) or (l_net_demand_after_oh_check > 0) THEN
3309:
3302: l_net_demand_after_oh_check := l_net_demand;
3303: IF PG_DEBUG in ('Y', 'C') THEN
3304: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Net demand after Onhand search := ' || l_net_demand);
3305: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_item_detail_flag := ' || l_org_item_detail_flag);
3306: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := ' || l_satisfied_by_subst_flag);
3307: END IF;
3308: IF ((l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1)) or (l_net_demand_after_oh_check > 0) THEN
3309:
3310: --- get create supply flag
3309:
3310: --- get create supply flag
3311: --- if create supply flag is null then default it to Demanded item
3312: IF PG_DEBUG in ('Y', 'C') THEN
3313: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Backward Ctp');
3314: END IF;
3315: l_create_supply_flag := MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG;
3316: l_count := item_availability_info.inventory_item_id.count;
3317: IF PG_DEBUG in ('Y', 'C') THEN
3314: END IF;
3315: l_create_supply_flag := MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG;
3316: l_count := item_availability_info.inventory_item_id.count;
3317: IF PG_DEBUG in ('Y', 'C') THEN
3318: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_CREATE_SUPPLY_FLAG := ' || MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG);
3319: END IF;
3320: --- bug 2388707: if demand has already been met then just add req item to the list of items
3321: -- to do CTP on
3322: IF (l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1) THEN
3332: ELSIF MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = G_HIGHEST_REV_ITEM THEN
3333: IF item_availability_info.inventory_item_id.count = 1 THEN
3334: --- we will come here if there are no substitutes or we are not substituting
3335: IF PG_DEBUG in ('Y', 'C') THEN
3336: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'One item. highest rev ' || l_highest_rev_item_id);
3337: END IF;
3338: IF (l_highest_rev_item_id = l_inventory_item_id) AND
3339: (item_availability_info.create_supply_flag(l_item_count) = 1) THEN
3340:
3342: END IF;
3343: ELSE
3344: --- we will come here if we have one or more substitutes and we are doing substitution
3345: IF PG_DEBUG in ('Y', 'C') THEN
3346: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Multiple items');
3347: END IF;
3348: For i in 1..item_availability_info.inventory_item_id.count LOOP
3349: -- find highest revision item
3350: IF item_availability_info.inventory_item_id(i) = l_highest_rev_item_id THEN
3349: -- find highest revision item
3350: IF item_availability_info.inventory_item_id(i) = l_highest_rev_item_id THEN
3351: l_highest_rev_item_index := i;
3352: IF PG_DEBUG in ('Y', 'C') THEN
3353: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'i := ' || i);
3354: END IF;
3355: EXIT;
3356: END IF;
3357:
3356: END IF;
3357:
3358: END LOOP;
3359: IF PG_DEBUG in ('Y', 'C') THEN
3360: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Counter for High. rev. item := ' || l_highest_rev_item_index);
3361: END IF;
3362: MSC_ATP_SUBST.Copy_Item_Info_rec(item_availability_info, l_item_ctp_info, l_highest_rev_item_index);
3363: END IF; -- IF item_availability_info.inventory_item_id.count = 1 THEN
3364: ELSE --- item attribute
3372: END IF;
3373: END IF; -- IF MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = 701
3374:
3375: IF PG_DEBUG in ('Y', 'C') THEN
3376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'List of items to do CTP on');
3377: For i in reverse 1..l_item_ctp_info.inventory_item_id.count LOOP
3378: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || l_item_ctp_info.item_name(i) || ' ' || l_item_ctp_info.sr_inventory_item_id(i) );
3379: END LOOP;
3380: msc_sch_wb.atp_debug('Subst last PO pegging: ' || MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING);
3374:
3375: IF PG_DEBUG in ('Y', 'C') THEN
3376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'List of items to do CTP on');
3377: For i in reverse 1..l_item_ctp_info.inventory_item_id.count LOOP
3378: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || l_item_ctp_info.item_name(i) || ' ' || l_item_ctp_info.sr_inventory_item_id(i) );
3379: END LOOP;
3380: msc_sch_wb.atp_debug('Subst last PO pegging: ' || MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING);
3381: END IF;
3382:
3376: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'List of items to do CTP on');
3377: For i in reverse 1..l_item_ctp_info.inventory_item_id.count LOOP
3378: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || l_item_ctp_info.item_name(i) || ' ' || l_item_ctp_info.sr_inventory_item_id(i) );
3379: END LOOP;
3380: msc_sch_wb.atp_debug('Subst last PO pegging: ' || MSC_ATP_SUBST.G_TOP_LAST_PO_PEGGING);
3381: END IF;
3382:
3383: -- AT this point we know on what item do we need to do CTP
3384: --l_net_demand :=
3400: EXIT;
3401: END IF;
3402: l_net_demand := p_atp_record.quantity_ordered - l_item_ctp_info.request_date_quantity(i);
3403: IF PG_DEBUG in ('Y', 'C') THEN
3404: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do CTP on := ' || l_item_ctp_info.item_name(i) || ' '
3405: || l_item_ctp_info.sr_inventory_item_id(i));
3406: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3407: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag := ' || l_item_ctp_info.atp_comp_flag(i));
3408: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'create_supply_flag := ' || l_item_ctp_info.create_supply_flag(i));
3402: l_net_demand := p_atp_record.quantity_ordered - l_item_ctp_info.request_date_quantity(i);
3403: IF PG_DEBUG in ('Y', 'C') THEN
3404: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do CTP on := ' || l_item_ctp_info.item_name(i) || ' '
3405: || l_item_ctp_info.sr_inventory_item_id(i));
3406: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3407: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag := ' || l_item_ctp_info.atp_comp_flag(i));
3408: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'create_supply_flag := ' || l_item_ctp_info.create_supply_flag(i));
3409: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end pegging id := ' || l_item_ctp_info.end_pegging_id(i));
3410: END IF;
3403: IF PG_DEBUG in ('Y', 'C') THEN
3404: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do CTP on := ' || l_item_ctp_info.item_name(i) || ' '
3405: || l_item_ctp_info.sr_inventory_item_id(i));
3406: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3407: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag := ' || l_item_ctp_info.atp_comp_flag(i));
3408: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'create_supply_flag := ' || l_item_ctp_info.create_supply_flag(i));
3409: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end pegging id := ' || l_item_ctp_info.end_pegging_id(i));
3410: END IF;
3411:
3404: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do CTP on := ' || l_item_ctp_info.item_name(i) || ' '
3405: || l_item_ctp_info.sr_inventory_item_id(i));
3406: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3407: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag := ' || l_item_ctp_info.atp_comp_flag(i));
3408: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'create_supply_flag := ' || l_item_ctp_info.create_supply_flag(i));
3409: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end pegging id := ' || l_item_ctp_info.end_pegging_id(i));
3410: END IF;
3411:
3412: IF l_item_ctp_info.atp_comp_flag(i) in ('Y', 'C', 'R') and l_item_ctp_info.create_supply_flag(i) = 1 THEN
3405: || l_item_ctp_info.sr_inventory_item_id(i));
3406: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3407: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_comp_flag := ' || l_item_ctp_info.atp_comp_flag(i));
3408: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'create_supply_flag := ' || l_item_ctp_info.create_supply_flag(i));
3409: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end pegging id := ' || l_item_ctp_info.end_pegging_id(i));
3410: END IF;
3411:
3412: IF l_item_ctp_info.atp_comp_flag(i) in ('Y', 'C', 'R') and l_item_ctp_info.create_supply_flag(i) = 1 THEN
3413:
3433: p_atp_record.organization_id
3434: );*/
3435: -- dsting
3436: IF PG_DEBUG in ('Y', 'C') THEN
3437: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'assigning item_name: ' ||l_item_ctp_info.item_name(i));
3438: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'assigning inventory_item_id: ' ||l_atp_rec.inventory_item_id);
3439: END IF;
3440: l_atp_rec.inventory_item_name := l_item_ctp_info.item_name(i);
3441: l_atp_rec.request_item_id := l_item_ctp_info.sr_inventory_item_id(i);
3434: );*/
3435: -- dsting
3436: IF PG_DEBUG in ('Y', 'C') THEN
3437: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'assigning item_name: ' ||l_item_ctp_info.item_name(i));
3438: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'assigning inventory_item_id: ' ||l_atp_rec.inventory_item_id);
3439: END IF;
3440: l_atp_rec.inventory_item_name := l_item_ctp_info.item_name(i);
3441: l_atp_rec.request_item_id := l_item_ctp_info.sr_inventory_item_id(i);
3442: l_atp_rec.organization_id := p_atp_record.organization_id;
3450: l_atp_rec.refresh_number := p_refresh_number;
3451: l_atp_rec.refresh_number := null;
3452: l_atp_rec.ship_date := null;
3453: IF PG_DEBUG in ('Y', 'C') THEN
3454: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand class for CTP := ' || l_item_ctp_info.demand_class(i));
3455: END IF;
3456: l_atp_rec.demand_class := l_item_ctp_info.demand_class(i);
3457:
3458: l_plan_id := l_item_ctp_info.plan_id(i);
3459: l_assign_set_id := l_item_ctp_info.assign_set_id(i);
3460:
3461: l_atp_rec.subs_demand_id := l_item_ctp_info.demand_id(i); --5088719
3462: IF PG_DEBUG in ('Y', 'C') THEN
3463: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.demand_id(i) ' || l_item_ctp_info.demand_id(i));
3464: END IF;
3465:
3466: l_atp_rec.original_item_flag := 1;
3467: l_atp_rec.top_tier_org_flag := 1;
3495: --Bug 3878343 , set l_atp_period to NULL, incase CTP is not done.
3496: l_atp_period := L_NULL_ATP_PERIOD;
3497: END IF;
3498: IF PG_DEBUG in ('Y', 'C') THEN
3499: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3500: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3501: END IF;
3502: l_net_demand := l_net_demand - l_atp_rec.requested_date_quantity;
3503: IF PG_DEBUG in ('Y', 'C') THEN
3496: l_atp_period := L_NULL_ATP_PERIOD;
3497: END IF;
3498: IF PG_DEBUG in ('Y', 'C') THEN
3499: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3500: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3501: END IF;
3502: l_net_demand := l_net_demand - l_atp_rec.requested_date_quantity;
3503: IF PG_DEBUG in ('Y', 'C') THEN
3504: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3500: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3501: END IF;
3502: l_net_demand := l_net_demand - l_atp_rec.requested_date_quantity;
3503: IF PG_DEBUG in ('Y', 'C') THEN
3504: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand := ' || l_net_demand);
3505: END IF;
3506:
3507: IF l_item_count = 1 THEN
3508: IF PG_DEBUG in ('Y', 'C') THEN
3505: END IF;
3506:
3507: IF l_item_count = 1 THEN
3508: IF PG_DEBUG in ('Y', 'C') THEN
3509: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Only one item');
3510: END IF;
3511: l_item_idx := 1;
3512: ELSE
3513: --bug 2388707: If demand has already been met then we are just looking for original item
3516: l_item_idx := l_item_count;
3517:
3518: ELSIF MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = G_DEMANDED_ITEM THEN
3519: IF PG_DEBUG in ('Y', 'C') THEN
3520: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'More item but we retun the index for original item');
3521: END IF;
3522: l_item_idx := l_item_count;
3523: ELSIF MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = G_HIGHEST_REV_ITEM THEN
3524: IF PG_DEBUG in ('Y', 'C') THEN
3521: END IF;
3522: l_item_idx := l_item_count;
3523: ELSIF MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = G_HIGHEST_REV_ITEM THEN
3524: IF PG_DEBUG in ('Y', 'C') THEN
3525: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Index for highest rev item');
3526: END IF;
3527: l_item_idx := l_highest_rev_item_index;
3528: ELSE
3529:
3530: IF l_item_ctp_info.inventory_item_id.count = 1 THEN
3531: --- this case will be true only if we have already satisfied the demand
3532: --- using a substitute
3533: IF PG_DEBUG in ('Y', 'C') THEN
3534: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'we have alread met req. We return index for req item');
3535: END IF;
3536: l_item_idx := l_item_count;
3537: ELSE
3538: IF PG_DEBUG in ('Y', 'C') THEN
3535: END IF;
3536: l_item_idx := l_item_count;
3537: ELSE
3538: IF PG_DEBUG in ('Y', 'C') THEN
3539: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Item Attib, index of current item');
3540: END IF;
3541: l_item_idx := i;
3542: END IF;
3543: END IF;
3542: END IF;
3543: END IF;
3544: END IF;
3545: IF PG_DEBUG in ('Y', 'C') THEN
3546: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_idx := ' || l_item_idx);
3547: END IF;
3548: l_item_ctp_info.request_date_quantity(i) :=
3549: NVL(l_item_ctp_info.request_date_quantity(i), 0) + l_atp_rec.requested_date_quantity;
3550: item_availability_info.request_date_quantity(l_item_idx) :=
3558: NVL(item_availability_info.atf_date_quantity(l_item_idx), 0) +
3559: + NVL(l_atp_rec.atf_date_quantity, l_atp_rec.requested_date_quantity);
3560:
3561: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
3562: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := '|| item_availability_info.request_date_quantity(l_item_idx));
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3559: + NVL(l_atp_rec.atf_date_quantity, l_atp_rec.requested_date_quantity);
3560:
3561: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
3562: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := '|| item_availability_info.request_date_quantity(l_item_idx));
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3560:
3561: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
3562: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := '|| item_availability_info.request_date_quantity(l_item_idx));
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3561: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
3562: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := '|| item_availability_info.request_date_quantity(l_item_idx));
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3569: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.Atf_Date := ' || l_item_ctp_info.Atf_Date(i));
3562: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := '|| item_availability_info.request_date_quantity(l_item_idx));
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3569: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.Atf_Date := ' || l_item_ctp_info.Atf_Date(i));
3570: END IF;
3563: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.requested_date_quantity := ' || l_atp_rec.requested_date_quantity);
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3569: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.Atf_Date := ' || l_item_ctp_info.Atf_Date(i));
3570: END IF;
3571: IF l_net_demand <= 0 THEN
3564: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.requested_date_quantity := ' || l_item_ctp_info.request_date_quantity(i));
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3569: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.Atf_Date := ' || l_item_ctp_info.Atf_Date(i));
3570: END IF;
3571: IF l_net_demand <= 0 THEN
3572: IF l_net_demand_after_oh_check > 0 THEN
3565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(l_item_idx) := '|| item_availability_info.atf_date_quantity(l_item_idx));
3566: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_rec.atf_date_quantity := ' || l_atp_rec.atf_date_quantity);
3567: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.atf_date_quantity := ' || l_item_ctp_info.atf_date_quantity(i));
3568: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.request_date_quantity(l_item_idx) := ' || item_availability_info.request_date_quantity(l_item_idx));
3569: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.Atf_Date := ' || l_item_ctp_info.Atf_Date(i));
3570: END IF;
3571: IF l_net_demand <= 0 THEN
3572: IF l_net_demand_after_oh_check > 0 THEN
3573: -- we have met the demand
3574: --- update the p_atp_record
3575: --l_ordered_item_id := p_atp_record.inventory_item_id;
3576: --l_demand_satisfied_by_item_id := l_item_ctp_info.sr_inventory_item_id(i);
3577: IF PG_DEBUG in ('Y', 'C') THEN
3578: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Met the requirement using item ' || l_item_ctp_info.item_name(i));
3579: END IF;
3580: --bug3467631
3581: IF l_item_ctp_info.sr_inventory_item_id(i) <> NVL(p_atp_record.request_item_id,
3582: p_atp_record.inventory_item_id) THEN
3580: --bug3467631
3581: IF l_item_ctp_info.sr_inventory_item_id(i) <> NVL(p_atp_record.request_item_id,
3582: p_atp_record.inventory_item_id) THEN
3583: IF PG_DEBUG in ('Y', 'C') THEN
3584: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand is satisfied by substitute');
3585: END IF;
3586: --- set the flag
3587: l_satisfied_by_subst_flag := 1;
3588: ELSE
3586: --- set the flag
3587: l_satisfied_by_subst_flag := 1;
3588: ELSE
3589: IF PG_DEBUG in ('Y', 'C') THEN
3590: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand is satisfied by the original item');
3591: END IF;
3592: l_satisfied_by_subst_flag := 2;
3593: END IF;
3594: IF PG_DEBUG in ('Y', 'C') THEN
3591: END IF;
3592: l_satisfied_by_subst_flag := 2;
3593: END IF;
3594: IF PG_DEBUG in ('Y', 'C') THEN
3595: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := ' || l_satisfied_by_subst_flag);
3596: END IF;
3597:
3598: p_atp_record.requested_date_quantity := p_atp_record.quantity_ordered;
3599: p_atp_record.Atf_Date_Quantity :=
3611: p_atp_record.original_item_id := item_availability_info.sr_inventory_item_id(l_item_count);
3612: p_atp_record.original_item_name := item_availability_info.item_name(l_item_count);
3613:
3614: IF PG_DEBUG in ('Y', 'C') THEN
3615: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3612: p_atp_record.original_item_name := item_availability_info.item_name(l_item_count);
3613:
3614: IF PG_DEBUG in ('Y', 'C') THEN
3615: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3620: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3613:
3614: IF PG_DEBUG in ('Y', 'C') THEN
3615: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3620: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3621: END IF;
3614: IF PG_DEBUG in ('Y', 'C') THEN
3615: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3620: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3621: END IF;
3622: -- time_phased_atp changes end
3615: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3620: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3621: END IF;
3622: -- time_phased_atp changes end
3623: --p_atp_record.End_pegging_id := item_availability_info.End_pegging_id(l_item_cntr);
3616: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3617: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3618: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3619: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3620: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3621: END IF;
3622: -- time_phased_atp changes end
3623: --p_atp_record.End_pegging_id := item_availability_info.End_pegging_id(l_item_cntr);
3624: --- this variable is populated in end_peggign id for this line in procedure schedule
3678: NOT(l_satisfied_by_subst_flag = 1 and l_org_item_detail_flag = 1 AND
3679: item_availability_info.sr_inventory_item_id(j) = MSC_ATP_SUBST.G_REQ_ITEM_SR_INV_ID) THEN
3680:
3681: IF PG_DEBUG in ('Y', 'C') THEN
3682: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove Pegging for item := ' || item_availability_info.inventory_item_id(i));
3683: END IF;
3684:
3685: MSC_ATP_DB_UTILS.Remove_Invalid_SD_Rec(
3686: item_availability_info.End_pegging_id(j),
3697:
3698: --- we had already met the deamand using on hand/sch receipts of substitute item
3699: -- now we have found enough quantity for ordered item as well so we will update the columns
3700: IF PG_DEBUG in ('Y', 'C') THEN
3701: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'demand met by a subst, provide detail for origninal item');
3702: END IF;
3703: MSC_ATP_PVT.G_DEMAND_PEGGING_ID := l_demand_pegging_id;
3704: p_atp_record.req_item_req_date_qty := p_atp_record.quantity_ordered;
3705:
3794: END LOOP;
3795: END IF;
3796:
3797: IF PG_DEBUG in ('Y', 'C') THEN
3798: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'net demand after backward CTP := ' || l_net_demand);
3799: END IF;
3800: IF PG_DEBUG in ('Y', 'C') THEN
3801: FOR i in reverse 1..item_availability_info.inventory_item_id.count LOOP
3802: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.item_name(i) || ' ' ||
3798: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'net demand after backward CTP := ' || l_net_demand);
3799: END IF;
3800: IF PG_DEBUG in ('Y', 'C') THEN
3801: FOR i in reverse 1..item_availability_info.inventory_item_id.count LOOP
3802: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.item_name(i) || ' ' ||
3803: item_availability_info.sr_inventory_item_id(i) || ' ' ||
3804: item_availability_info.request_date_quantity(i));
3805: END LOOP;
3806: END IF;
3805: END LOOP;
3806: END IF;
3807:
3808: IF PG_DEBUG in ('Y', 'C') THEN
3809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.inventory_item_name: ' || p_atp_record.inventory_item_name );
3810: END IF;
3811:
3812: -- dsting skip Forward scheduling for diagnostic ATP
3813: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
3811:
3812: -- dsting skip Forward scheduling for diagnostic ATP
3813: IF MSC_ATP_PVT.G_DIAGNOSTIC_ATP = DIAGNOSTIC_ATP THEN
3814: IF PG_DEBUG in ('Y', 'C') THEN
3815: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'no forward pass for diagnostic ATP');
3816: END IF;
3817:
3818: IF l_net_demand > 0 THEN
3819: /* time_phased_atp changes begin
3830: p_atp_record.original_item_name := item_availability_info.item_name(l_item_count);
3831: -- time_phased_atp changes end
3832:
3833: IF PG_DEBUG in ('Y', 'C') THEN
3834: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3831: -- time_phased_atp changes end
3832:
3833: IF PG_DEBUG in ('Y', 'C') THEN
3834: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3839: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3832:
3833: IF PG_DEBUG in ('Y', 'C') THEN
3834: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3839: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3840: END IF;
3833: IF PG_DEBUG in ('Y', 'C') THEN
3834: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3839: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3840: END IF;
3841: p_atp_record.atf_date_quantity := item_availability_info.atf_date_quantity(l_item_count);
3834: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_id := ' || p_atp_record.inventory_item_id);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3839: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3840: END IF;
3841: p_atp_record.atf_date_quantity := item_availability_info.atf_date_quantity(l_item_count);
3842: p_atp_record.requested_date_quantity := item_availability_info.request_date_quantity(l_item_count);
3835: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'inventory_item_name := ' || p_atp_record.inventory_item_name);
3836: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_id := ' || p_atp_record.request_item_id);
3837: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'request_item_name := ' || p_atp_record.request_item_name);
3838: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_id := ' || p_atp_record.original_item_id);
3839: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'original_item_name := ' || p_atp_record.original_item_name);
3840: END IF;
3841: p_atp_record.atf_date_quantity := item_availability_info.atf_date_quantity(l_item_count);
3842: p_atp_record.requested_date_quantity := item_availability_info.request_date_quantity(l_item_count);
3843: p_atp_record.available_quantity := item_availability_info.request_date_quantity(l_item_count);
3848: goto CLEANUP;
3849: END IF;
3850:
3851: IF PG_DEBUG in ('Y', 'C') THEN
3852: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Do forward scheduling if needed. net demand: ' || l_net_demand);
3853: END IF;
3854:
3855: --- we are done with backward CTP. Now do Forward Schedulling if needed
3856: IF ((l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1)) or (l_net_demand > 0) THEN
3859: ELSE
3860: l_insert_flag := p_atp_record.insert_flag;
3861: END IF;
3862: IF PG_DEBUG in ('Y', 'C') THEN
3863: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inside Forward Scheduling');
3864: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item count := ' || item_availability_info.inventory_item_id.count);
3865: END IF;
3866: FOR i in reverse 1..item_availability_info.inventory_item_id.count LOOP
3867: --- look for date by which we can meet by onhand
3860: l_insert_flag := p_atp_record.insert_flag;
3861: END IF;
3862: IF PG_DEBUG in ('Y', 'C') THEN
3863: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Inside Forward Scheduling');
3864: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item count := ' || item_availability_info.inventory_item_id.count);
3865: END IF;
3866: FOR i in reverse 1..item_availability_info.inventory_item_id.count LOOP
3867: --- look for date by which we can meet by onhand
3868: l_net_demand := p_atp_record.quantity_ordered - item_availability_info.request_date_quantity(i);
3866: FOR i in reverse 1..item_availability_info.inventory_item_id.count LOOP
3867: --- look for date by which we can meet by onhand
3868: l_net_demand := p_atp_record.quantity_ordered - item_availability_info.request_date_quantity(i);
3869: IF PG_DEBUG in ('Y', 'C') THEN
3870: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Get future onhand date for item := ' ||
3871: item_availability_info.item_name(i));
3872: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Net demand future case := ' || l_net_demand);
3873: END IF;
3874: --- first update the demand so that the picture gets adjusted
3868: l_net_demand := p_atp_record.quantity_ordered - item_availability_info.request_date_quantity(i);
3869: IF PG_DEBUG in ('Y', 'C') THEN
3870: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Get future onhand date for item := ' ||
3871: item_availability_info.item_name(i));
3872: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Net demand future case := ' || l_net_demand);
3873: END IF;
3874: --- first update the demand so that the picture gets adjusted
3875: MSC_ATP_SUBST.UPDATE_DEMAND(item_availability_info.demand_id(i),
3876: item_availability_info.plan_id(i),
3897: l_return_status
3898: );
3899: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3900: IF PG_DEBUG in ('Y', 'C') THEN
3901: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Error occured in procedure Increment_Bucketed_Demands_Qty');
3902: END IF;
3903: RAISE FND_API.G_EXC_ERROR;
3904: END IF;
3905: END IF;
3905: END IF;
3906: -- time_phased_atp changes end
3907:
3908: IF PG_DEBUG in ('Y', 'C') THEN
3909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now get the future date');
3910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.atp_flag(i));
3911: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_flag(i));
3912: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_comp_flag(i));
3913: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
3906: -- time_phased_atp changes end
3907:
3908: IF PG_DEBUG in ('Y', 'C') THEN
3909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now get the future date');
3910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.atp_flag(i));
3911: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_flag(i));
3912: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_comp_flag(i));
3913: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
3914: END IF;
3907:
3908: IF PG_DEBUG in ('Y', 'C') THEN
3909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now get the future date');
3910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.atp_flag(i));
3911: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_flag(i));
3912: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_comp_flag(i));
3913: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
3914: END IF;
3915: IF item_availability_info.atp_flag(i) = 'N' and item_availability_info.atp_comp_flag(i) = 'N' THEN
3908: IF PG_DEBUG in ('Y', 'C') THEN
3909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now get the future date');
3910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.atp_flag(i));
3911: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_flag(i));
3912: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_comp_flag(i));
3913: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
3914: END IF;
3915: IF item_availability_info.atp_flag(i) = 'N' and item_availability_info.atp_comp_flag(i) = 'N' THEN
3916: --- we will come here only if item if req_date is passed due
3909: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now get the future date');
3910: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || item_availability_info.atp_flag(i));
3911: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_flag(i));
3912: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'atp_flag := ' || item_availability_info.atp_comp_flag(i));
3913: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_sys_date_top_org := ' || l_sys_date_top_org);
3914: END IF;
3915: IF item_availability_info.atp_flag(i) = 'N' and item_availability_info.atp_comp_flag(i) = 'N' THEN
3916: --- we will come here only if item if req_date is passed due
3917: l_atp_date_quantity_this_level := p_atp_record.quantity_ordered;
3944: (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1) AND
3945: (MSC_ATP_PVT.G_ALLOCATION_METHOD = 1) THEN
3946:
3947: IF PG_DEBUG in ('Y', 'C') THEN
3948: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Allocated ATP with demand priority');
3949: END IF;
3950: ---forward steal
3951: MSC_ATP_PVT.G_DEMAND_PEGGING_ID := item_availability_info.end_pegging_id(i);
3952:
3996: );
3997:
3998: item_availability_info.fwd_steal_peg_begin_idx(i) := l_fwd_atp_pegging_tab.count +1;
3999: IF PG_DEBUG in ('Y', 'C') THEN
4000: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Fwd peg count for curr item := ' || l_atp_pegging_tab.count);
4001: END IF;
4002: FOR j in 1..l_atp_pegging_tab.count LOOP
4003: l_fwd_atp_pegging_tab.extend;
4004: l_fwd_atp_pegging_tab(l_fwd_atp_pegging_tab.count) := l_atp_pegging_tab(j);
4005:
4006: END LOOP;
4007: item_availability_info.fwd_steal_peg_end_idx(i) := l_fwd_atp_pegging_tab.count;
4008: IF PG_DEBUG in ('Y', 'C') THEN
4009: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'fwd peg count := ' || l_fwd_atp_pegging_tab.count);
4010: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4011: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4012: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3409973
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4006: END LOOP;
4007: item_availability_info.fwd_steal_peg_end_idx(i) := l_fwd_atp_pegging_tab.count;
4008: IF PG_DEBUG in ('Y', 'C') THEN
4009: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'fwd peg count := ' || l_fwd_atp_pegging_tab.count);
4010: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4011: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4012: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3409973
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4014: END IF;
4007: item_availability_info.fwd_steal_peg_end_idx(i) := l_fwd_atp_pegging_tab.count;
4008: IF PG_DEBUG in ('Y', 'C') THEN
4009: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'fwd peg count := ' || l_fwd_atp_pegging_tab.count);
4010: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4011: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4012: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3409973
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4014: END IF;
4015: ELSE
4008: IF PG_DEBUG in ('Y', 'C') THEN
4009: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'fwd peg count := ' || l_fwd_atp_pegging_tab.count);
4010: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4011: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4012: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3409973
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4014: END IF;
4015: ELSE
4016: IF PG_DEBUG in ('Y', 'C') THEN
4009: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'fwd peg count := ' || l_fwd_atp_pegging_tab.count);
4010: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4011: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4012: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3409973
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4014: END IF;
4015: ELSE
4016: IF PG_DEBUG in ('Y', 'C') THEN
4017: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP without demand priority allocated ATP');
4013: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4014: END IF;
4015: ELSE
4016: IF PG_DEBUG in ('Y', 'C') THEN
4017: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'ATP without demand priority allocated ATP');
4018: END IF;
4019: --bug3467631 Inside Forward Scheduling re-initializing MSC_ATP_PVT.G_ITEM_INFO_REC
4020: --otherwise it will have substitute's values even when we are processing member item.
4021: --bug3467631 start
4096: SELECT msc_full_pegging_s.nextval
4097: INTO l_pegging_id
4098: FROM dual;
4099: IF PG_DEBUG in ('Y', 'C') THEN
4100: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Update with pegging info');
4101: END IF;
4102: item_availability_info.future_supply_peg_id(i) := l_pegging_id;
4103: FOR j in 1..l_atp_period.Level.COUNT LOOP
4104: l_atp_period.Pegging_Id(j) := l_pegging_id;
4112:
4113:
4114: --- now add period and supply details
4115: IF PG_DEBUG in ('Y', 'C') THEN
4116: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add Supply demand details for the item');
4117: END IF;
4118: MSC_ATP_PROC.Details_Output(l_atp_period,
4119: l_atp_supply_demand,
4120: l_all_atp_period,
4128: item_availability_info.fut_atp_prd_detl_end_idx(i) := l_period_end_idx;
4129: item_availability_info.fut_atp_sd_detl_begin_idx(i) := l_sd_begin_idx;
4130: item_availability_info.fut_atp_sd_detl_end_idx(i) := l_sd_end_idx;
4131: IF PG_DEBUG in ('Y', 'C') THEN
4132: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3467631
4133: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4134: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4136: END IF;
4129: item_availability_info.fut_atp_sd_detl_begin_idx(i) := l_sd_begin_idx;
4130: item_availability_info.fut_atp_sd_detl_end_idx(i) := l_sd_end_idx;
4131: IF PG_DEBUG in ('Y', 'C') THEN
4132: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3467631
4133: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4134: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4136: END IF;
4137: END IF; --- IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4130: item_availability_info.fut_atp_sd_detl_end_idx(i) := l_sd_end_idx;
4131: IF PG_DEBUG in ('Y', 'C') THEN
4132: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3467631
4133: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4134: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4136: END IF;
4137: END IF; --- IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4138: --bug3467631 start
4131: IF PG_DEBUG in ('Y', 'C') THEN
4132: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_used_available_quantity := ' || l_used_available_quantity); --bug3467631
4133: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_this_level := ' || l_atp_date_this_level);
4134: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atp_date_quantity_this_level := ' || l_atp_date_quantity_this_level);
4135: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_atf_date_qty := ' || l_atf_date_qty); --bug3467631
4136: END IF;
4137: END IF; --- IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4138: --bug3467631 start
4139: --added to set atf_date_quantity for item
4156: LEAST(GREATEST(l_used_available_quantity, 0) +
4157: GREATEST(item_availability_info.request_date_quantity(i),0),
4158: MSC_ATP_PVT.INFINITE_NUMBER);--bug3467631
4159: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
4160: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(i) := ' ||
4161: item_availability_info.atf_date_quantity(i)); --bug3467631
4162: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.used_available_quantity(i) := ' ||
4163: item_availability_info.used_available_quantity(i));
4164: END IF;
4158: MSC_ATP_PVT.INFINITE_NUMBER);--bug3467631
4159: IF PG_DEBUG in ('Y', 'C') THEN --bug3467631
4160: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.atf_date_quantity(i) := ' ||
4161: item_availability_info.atf_date_quantity(i)); --bug3467631
4162: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item_availability_info.used_available_quantity(i) := ' ||
4163: item_availability_info.used_available_quantity(i));
4164: END IF;
4165: IF (l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1 AND i = l_item_count) THEN
4166: IF PG_DEBUG in ('Y', 'C') THEN
4163: item_availability_info.used_available_quantity(i));
4164: END IF;
4165: IF (l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1 AND i = l_item_count) THEN
4166: IF PG_DEBUG in ('Y', 'C') THEN
4167: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'we have met the demand, we just check for avail of req item');
4168: END IF;
4169: EXIT;
4170: END IF;
4171: ELSE
4176: END IF;
4177:
4178: END LOOP;
4179: IF PG_DEBUG in ('Y', 'C') THEN
4180: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Now do Forward CTP');
4181: END IF;
4182: IF (l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1
4183: and l_net_demand_after_oh_check > 0) THEN
4184: IF PG_DEBUG in ('Y', 'C') THEN
4181: END IF;
4182: IF (l_org_item_detail_flag = 1 AND l_satisfied_by_subst_flag = 1
4183: and l_net_demand_after_oh_check > 0) THEN
4184: IF PG_DEBUG in ('Y', 'C') THEN
4185: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || ' Demand was met by a CTP on sub. reset the l_item_ctp_info table');
4186: END IF;
4187: l_item_ctp_info := l_null_item_avail_info;
4188: IF (MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG <> G_HIGHEST_REV_ITEM) or
4189: (MSC_ATP_SUBST.G_CREATE_SUPPLY_FLAG = G_HIGHEST_REV_ITEM and
4195: FOR i in reverse 1..l_item_ctp_info.inventory_item_id.count LOOP
4196:
4197: l_net_demand := p_atp_record.quantity_ordered - l_item_ctp_info.request_date_quantity(i);
4198: IF PG_DEBUG in ('Y', 'C') THEN
4199: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.request_date_quantity(i) := ' || l_item_ctp_info.request_date_quantity(i));
4200: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand forward case := ' || l_net_demand);
4201: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Future atp date :=' || item_availability_info.future_atp_date(i));
4202: END IF;
4203: IF l_item_ctp_info.atp_comp_flag(i) in ('Y', 'C', 'R') and l_item_ctp_info.create_supply_flag(i) = 1 THEN
4196:
4197: l_net_demand := p_atp_record.quantity_ordered - l_item_ctp_info.request_date_quantity(i);
4198: IF PG_DEBUG in ('Y', 'C') THEN
4199: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.request_date_quantity(i) := ' || l_item_ctp_info.request_date_quantity(i));
4200: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand forward case := ' || l_net_demand);
4201: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Future atp date :=' || item_availability_info.future_atp_date(i));
4202: END IF;
4203: IF l_item_ctp_info.atp_comp_flag(i) in ('Y', 'C', 'R') and l_item_ctp_info.create_supply_flag(i) = 1 THEN
4204: IF l_item_count = 1 THEN
4197: l_net_demand := p_atp_record.quantity_ordered - l_item_ctp_info.request_date_quantity(i);
4198: IF PG_DEBUG in ('Y', 'C') THEN
4199: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_ctp_info.request_date_quantity(i) := ' || l_item_ctp_info.request_date_quantity(i));
4200: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_net_demand forward case := ' || l_net_demand);
4201: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Future atp date :=' || item_availability_info.future_atp_date(i));
4202: END IF;
4203: IF l_item_ctp_info.atp_comp_flag(i) in ('Y', 'C', 'R') and l_item_ctp_info.create_supply_flag(i) = 1 THEN
4204: IF l_item_count = 1 THEN
4205: l_item_idx := 1;
4224: END IF;
4225: END IF;
4226: END IF;
4227: IF PG_DEBUG in ('Y', 'C') THEN
4228: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_idx := ' || l_item_idx);
4229: END IF;
4230: l_atp_rec.error_code := 0;
4231: l_atp_rec.available_quantity := NULL;
4232: l_atp_rec.requested_date_quantity := NULL;
4291: l_atp_supply_demand,
4292: x_return_status);
4293:
4294: IF PG_DEBUG in ('Y', 'C') THEN
4295: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date from multi level CTP := ' || l_atp_rec.ship_date);
4296: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date from SRs on this level :='
4297: || item_availability_info.future_atp_date(l_item_idx));
4298: END IF;
4299:
4292: x_return_status);
4293:
4294: IF PG_DEBUG in ('Y', 'C') THEN
4295: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date from multi level CTP := ' || l_atp_rec.ship_date);
4296: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Date from SRs on this level :='
4297: || item_availability_info.future_atp_date(l_item_idx));
4298: END IF;
4299:
4300: IF l_atp_rec.ship_date < item_availability_info.future_atp_date(l_item_idx) THEN
4299:
4300: IF l_atp_rec.ship_date < item_availability_info.future_atp_date(l_item_idx) THEN
4301: -- going down is better
4302: IF PG_DEBUG in ('Y', 'C') THEN
4303: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Going down is better. so we add the supply demand dets');
4304: END IF;
4305: --- add l_atp_period and l_atp_supply_demand
4306: -- dsting: l_period_begin_idx := l_all_atp_supply_demand.level.COUNT;
4307: l_period_begin_idx := l_all_atp_period.level.COUNT;
4344:
4345: --- recreate forward pegging array
4346: l_atp_pegging_tab.delete;
4347: IF PG_DEBUG in ('Y', 'C') THEN
4348: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4349: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_idx));
4350: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_idx));
4351: END IF;
4352: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_idx)..item_availability_info.fwd_steal_peg_end_idx(l_item_idx) LOOP
4345: --- recreate forward pegging array
4346: l_atp_pegging_tab.delete;
4347: IF PG_DEBUG in ('Y', 'C') THEN
4348: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4349: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_idx));
4350: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_idx));
4351: END IF;
4352: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_idx)..item_availability_info.fwd_steal_peg_end_idx(l_item_idx) LOOP
4353: l_atp_pegging_tab.extend;
4346: l_atp_pegging_tab.delete;
4347: IF PG_DEBUG in ('Y', 'C') THEN
4348: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4349: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_idx));
4350: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_idx));
4351: END IF;
4352: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_idx)..item_availability_info.fwd_steal_peg_end_idx(l_item_idx) LOOP
4353: l_atp_pegging_tab.extend;
4354: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(j);
4353: l_atp_pegging_tab.extend;
4354: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(j);
4355: END LOOP;
4356: IF PG_DEBUG in ('Y', 'C') THEN
4357: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'count after recreating := ' || l_atp_pegging_tab.count);
4358: END IF;
4359:
4360: MSC_ATP_DB_UTILS.Remove_Invalid_Future_SD(l_atp_pegging_tab);
4361: END IF;
4363:
4364: --- going down is worse than date on this level.
4365: --- we remove pegging and supply demands
4366: IF PG_DEBUG in ('Y', 'C') THEN
4367: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Staying on this level is OK. We remove pegging for current level');
4368: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_FUTURE_PEGGING_ID := ' || MSC_ATP_PVT.G_FUTURE_PEGGING_ID);
4369: END IF;
4370: MSC_ATP_DB_UTILS.Remove_Invalid_SD_Rec(
4371: MSC_ATP_PVT.G_FUTURE_PEGGING_ID,
4364: --- going down is worse than date on this level.
4365: --- we remove pegging and supply demands
4366: IF PG_DEBUG in ('Y', 'C') THEN
4367: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Staying on this level is OK. We remove pegging for current level');
4368: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'G_FUTURE_PEGGING_ID := ' || MSC_ATP_PVT.G_FUTURE_PEGGING_ID);
4369: END IF;
4370: MSC_ATP_DB_UTILS.Remove_Invalid_SD_Rec(
4371: MSC_ATP_PVT.G_FUTURE_PEGGING_ID,
4372: null,
4386: --- now we should know dates for all the items
4387: --- we can now compare the dates and give the best results back
4388: IF PG_DEBUG in ('Y', 'C') THEN
4389: For i in reverse 1..item_availability_info.inventory_item_id.count LOOP
4390: msc_sch_wb.atp_debug('Item :'||i || item_availability_info.sr_inventory_item_id(i) ||
4391: ', Avail Date : ' || item_availability_info.future_atp_date(i) ||
4392: ', : used_available_quantity ' || item_availability_info.used_available_quantity(i)||
4393: ', : Atf_Date_Quantity ' || item_availability_info.Atf_Date_Quantity(i) ||
4394: ', : Atf_Date ' || item_availability_info.Atf_Date(i));
4436:
4437: --- recreate forward pegging array
4438: l_atp_pegging_tab.delete;
4439: IF PG_DEBUG in ('Y', 'C') THEN
4440: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4441: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_count));
4442: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_count));
4443: END IF;
4444: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_count)..item_availability_info.fwd_steal_peg_end_idx(l_item_count) LOOP
4437: --- recreate forward pegging array
4438: l_atp_pegging_tab.delete;
4439: IF PG_DEBUG in ('Y', 'C') THEN
4440: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4441: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_count));
4442: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_count));
4443: END IF;
4444: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_count)..item_availability_info.fwd_steal_peg_end_idx(l_item_count) LOOP
4445: l_atp_pegging_tab.extend;
4438: l_atp_pegging_tab.delete;
4439: IF PG_DEBUG in ('Y', 'C') THEN
4440: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4441: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(l_item_count));
4442: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(l_item_count));
4443: END IF;
4444: FOR j in item_availability_info.fwd_steal_peg_begin_idx(l_item_count)..item_availability_info.fwd_steal_peg_end_idx(l_item_count) LOOP
4445: l_atp_pegging_tab.extend;
4446: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(j);
4445: l_atp_pegging_tab.extend;
4446: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(j);
4447: END LOOP;
4448: IF PG_DEBUG in ('Y', 'C') THEN
4449: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'count after recreating := ' || l_atp_pegging_tab.count);
4450: END IF;
4451:
4452: MSC_ATP_DB_UTILS.Remove_Invalid_Future_SD(l_atp_pegging_tab);
4453: END IF;
4476: END LOOP;
4477: --- now we have found best case scenrio
4478: --- so we populate the info
4479: IF PG_DEBUG in ('Y', 'C') THEN
4480: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_idx := ' || l_item_idx);
4481: END IF;
4482:
4483: -- time_phased_atp
4484: --p_atp_record.inventory_item_id := item_availability_info.sr_inventory_item_id(l_item_idx);
4511: p_atp_record.ship_date := item_availability_info.future_atp_date(l_item_idx);
4512: p_atp_record.available_quantity := item_availability_info.atp_date_quantity(l_item_idx);
4513: --p_atp_record.inventory_item_name := item_availability_info.item_name(l_item_idx); --bug3467631 set above
4514: IF PG_DEBUG in ('Y', 'C') THEN
4515: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.inventory_item_id := '|| p_atp_record.inventory_item_id);
4516: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_pegging_id := ' || item_availability_info.end_pegging_id(l_item_idx));
4517: END IF;
4518: MSC_ATP_PVT.G_DEMAND_PEGGING_ID := item_availability_info.end_pegging_id(l_item_idx);
4519:
4512: p_atp_record.available_quantity := item_availability_info.atp_date_quantity(l_item_idx);
4513: --p_atp_record.inventory_item_name := item_availability_info.item_name(l_item_idx); --bug3467631 set above
4514: IF PG_DEBUG in ('Y', 'C') THEN
4515: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'p_atp_record.inventory_item_id := '|| p_atp_record.inventory_item_id);
4516: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_pegging_id := ' || item_availability_info.end_pegging_id(l_item_idx));
4517: END IF;
4518: MSC_ATP_PVT.G_DEMAND_PEGGING_ID := item_availability_info.end_pegging_id(l_item_idx);
4519:
4520: --- now populate the info for original item
4532:
4533: --- now we add supply demand and period details
4534: --- first we add details for backward search
4535: IF PG_DEBUG in ('Y', 'C') THEN
4536: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add details for pegging for backward search');
4537: END IF;
4538: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
4539: l_all_atp_supply_demand,
4540: item_availability_info.period_detail_begin_idx(l_item_idx),
4545: x_atp_supply_demand,
4546: l_return_status);
4547: --- now add details for backward CTP
4548: IF PG_DEBUG in ('Y', 'C') THEN
4549: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add details for backward CTP');
4550: END IF;
4551: IF item_availability_info.ctp_prd_detl_begin_idx(l_item_idx) is not null and
4552: item_availability_info.ctp_sd_detl_begin_idx(l_item_idx) is not null THEN
4553: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
4561: l_return_status);
4562: END IF;
4563: --- now add future atp details
4564: IF PG_DEBUG in ('Y', 'C') THEN
4565: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'add details for forward search');
4566: END IF;
4567: IF NVL(item_availability_info.fut_ctp_prd_detl_begin_idx(l_item_idx), 0 ) > 0 THEN
4568: --- going down is better
4569: --- ad future period and supply demand details
4567: IF NVL(item_availability_info.fut_ctp_prd_detl_begin_idx(l_item_idx), 0 ) > 0 THEN
4568: --- going down is better
4569: --- ad future period and supply demand details
4570: IF PG_DEBUG in ('Y', 'C') THEN
4571: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add s/d details for forward CTP');
4572: END IF;
4573: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
4574: l_all_atp_supply_demand,
4575: item_availability_info.fut_ctp_prd_detl_begin_idx(l_item_idx),
4586: --- first we add pegging for this supply
4587: IF item_availability_info.atp_flag(l_item_idx) = 'N'
4588: and item_availability_info.atp_flag(l_item_idx) = 'N' THEN
4589: IF PG_DEBUG in ('Y', 'C') THEN
4590: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'item is non-atpable, dont do pegging');
4591: END IF;
4592: ELSE
4593: ---forward steal: demand has already been created, we dont want to create it again
4594: IF NOT((MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4594: IF NOT((MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4595: (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1) AND
4596: (MSC_ATP_PVT.G_ALLOCATION_METHOD = 1)) THEN
4597: IF PG_DEBUG in ('Y', 'C') THEN
4598: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Add pegging and s/d details for SRS');
4599: END IF;
4600:
4601: l_pegging_rec.session_id:= MSC_ATP_PVT.G_SESSION_ID;
4602: l_pegging_rec.order_line_id:= MSC_ATP_PVT.G_ORDER_LINE_ID;
4624: l_pegging_rec.inventory_item_name := item_availability_info.item_name(l_item_idx);
4625: END IF;
4626: -- time_phased_atp changes end
4627: IF PG_DEBUG in ('Y', 'C') THEN
4628: msc_sch_wb.atp_debug('family_sr_id: ' || item_availability_info.family_sr_id(l_item_idx));
4629: msc_sch_wb.atp_debug('family_item_name: ' || item_availability_info.family_item_name(l_item_idx));
4630: msc_sch_wb.atp_debug('sr_inventory_item_id: ' || item_availability_info.sr_inventory_item_id(l_item_idx));
4631: msc_sch_wb.atp_debug('item_name: ' || item_availability_info.item_name(l_item_idx));
4632: END IF;
4625: END IF;
4626: -- time_phased_atp changes end
4627: IF PG_DEBUG in ('Y', 'C') THEN
4628: msc_sch_wb.atp_debug('family_sr_id: ' || item_availability_info.family_sr_id(l_item_idx));
4629: msc_sch_wb.atp_debug('family_item_name: ' || item_availability_info.family_item_name(l_item_idx));
4630: msc_sch_wb.atp_debug('sr_inventory_item_id: ' || item_availability_info.sr_inventory_item_id(l_item_idx));
4631: msc_sch_wb.atp_debug('item_name: ' || item_availability_info.item_name(l_item_idx));
4632: END IF;
4633:
4626: -- time_phased_atp changes end
4627: IF PG_DEBUG in ('Y', 'C') THEN
4628: msc_sch_wb.atp_debug('family_sr_id: ' || item_availability_info.family_sr_id(l_item_idx));
4629: msc_sch_wb.atp_debug('family_item_name: ' || item_availability_info.family_item_name(l_item_idx));
4630: msc_sch_wb.atp_debug('sr_inventory_item_id: ' || item_availability_info.sr_inventory_item_id(l_item_idx));
4631: msc_sch_wb.atp_debug('item_name: ' || item_availability_info.item_name(l_item_idx));
4632: END IF;
4633:
4634: l_pegging_rec.aggregate_time_fence_date := item_availability_info.Atf_Date(l_item_idx); --bug3467631
4627: IF PG_DEBUG in ('Y', 'C') THEN
4628: msc_sch_wb.atp_debug('family_sr_id: ' || item_availability_info.family_sr_id(l_item_idx));
4629: msc_sch_wb.atp_debug('family_item_name: ' || item_availability_info.family_item_name(l_item_idx));
4630: msc_sch_wb.atp_debug('sr_inventory_item_id: ' || item_availability_info.sr_inventory_item_id(l_item_idx));
4631: msc_sch_wb.atp_debug('item_name: ' || item_availability_info.item_name(l_item_idx));
4632: END IF;
4633:
4634: l_pegging_rec.aggregate_time_fence_date := item_availability_info.Atf_Date(l_item_idx); --bug3467631
4635: l_pegging_rec.resource_id := NULL;
4656: l_pegging_rec.request_item_id := p_atp_record.request_item_id;
4657:
4658: MSC_ATP_SUBST.add_pegging(l_pegging_rec);
4659: IF PG_DEBUG in ('Y', 'C') THEN
4660: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_future_supply_pegging_id :=' || l_pegging_id);
4661: END IF;
4662: MSC_ATP_SUBST.Details_Output(l_all_atp_period,
4663: l_all_atp_supply_demand,
4664: item_availability_info.fut_atp_prd_detl_begin_idx(l_item_idx),
4672: END IF; -- IF NOT((MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4673: END IF;
4674: --- now delete pegging and supply demand info
4675: IF PG_DEBUG in ('Y', 'C') THEN
4676: msc_Sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove pegging and supply demand details for all items');
4677: END IF;
4678: --- now delete pegging and supply demand info
4679: IF PG_DEBUG in ('Y', 'C') THEN
4680: msc_Sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove pegging and supply demand details for all items');
4676: msc_Sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove pegging and supply demand details for all items');
4677: END IF;
4678: --- now delete pegging and supply demand info
4679: IF PG_DEBUG in ('Y', 'C') THEN
4680: msc_Sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove pegging and supply demand details for all items');
4681: END IF;
4682:
4683: For j in 1..item_availability_info.inventory_item_id.count LOOP
4684: IF PG_DEBUG in ('Y', 'C') THEN
4681: END IF;
4682:
4683: For j in 1..item_availability_info.inventory_item_id.count LOOP
4684: IF PG_DEBUG in ('Y', 'C') THEN
4685: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'In loop for removing supply demand of all items');
4686: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_idx :- ' || l_item_idx);
4687: END IF;
4688: IF (item_availability_info.inventory_item_id(j)
4689: <> item_availability_info.inventory_item_id(l_item_idx)) THEN
4682:
4683: For j in 1..item_availability_info.inventory_item_id.count LOOP
4684: IF PG_DEBUG in ('Y', 'C') THEN
4685: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'In loop for removing supply demand of all items');
4686: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_item_idx :- ' || l_item_idx);
4687: END IF;
4688: IF (item_availability_info.inventory_item_id(j)
4689: <> item_availability_info.inventory_item_id(l_item_idx)) THEN
4690:
4689: <> item_availability_info.inventory_item_id(l_item_idx)) THEN
4690:
4691:
4692: IF PG_DEBUG in ('Y', 'C') THEN
4693: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'Remove Pegging for item := '
4694: || item_availability_info.inventory_item_id(j));
4695: END IF;
4696: ---- remove forward stealing pegging
4697: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
4701:
4702: --- recreate forward pegging array
4703: l_atp_pegging_tab.delete;
4704: IF PG_DEBUG in ('Y', 'C') THEN
4705: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4706: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(j));
4707: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(j));
4708: END IF;
4709: FOR l_item_cntr in item_availability_info.fwd_steal_peg_begin_idx(j)..item_availability_info.fwd_steal_peg_end_idx(j) LOOP
4702: --- recreate forward pegging array
4703: l_atp_pegging_tab.delete;
4704: IF PG_DEBUG in ('Y', 'C') THEN
4705: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4706: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(j));
4707: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(j));
4708: END IF;
4709: FOR l_item_cntr in item_availability_info.fwd_steal_peg_begin_idx(j)..item_availability_info.fwd_steal_peg_end_idx(j) LOOP
4710: l_atp_pegging_tab.extend;
4703: l_atp_pegging_tab.delete;
4704: IF PG_DEBUG in ('Y', 'C') THEN
4705: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'idemand priority alloc ATP, count := '|| l_atp_pegging_tab.count);
4706: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'begin_Idx := ' ||item_availability_info.fwd_steal_peg_begin_idx(j));
4707: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'end_idx := ' || item_availability_info.fwd_steal_peg_end_idx(j));
4708: END IF;
4709: FOR l_item_cntr in item_availability_info.fwd_steal_peg_begin_idx(j)..item_availability_info.fwd_steal_peg_end_idx(j) LOOP
4710: l_atp_pegging_tab.extend;
4711: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(l_item_cntr);
4710: l_atp_pegging_tab.extend;
4711: l_atp_pegging_tab(l_atp_pegging_tab.count) := l_fwd_atp_pegging_tab(l_item_cntr);
4712: END LOOP;
4713: IF PG_DEBUG in ('Y', 'C') THEN
4714: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'count after recreating := ' || l_atp_pegging_tab.count);
4715: END IF;
4716:
4717: MSC_ATP_DB_UTILS.Remove_Invalid_Future_SD(l_atp_pegging_tab);
4718: END IF;
4730:
4731: END IF;
4732: --- now set the error code
4733: IF PG_DEBUG in ('Y', 'C') THEN
4734: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_item_detail_flag := ' || l_org_item_detail_flag);
4735: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := '|| l_satisfied_by_subst_flag);
4736: END IF;
4737: IF ((NVL(l_org_item_detail_flag, -1) <>1 OR NVL(l_satisfied_by_subst_flag,-1) <> 1)) THEN
4738:
4731: END IF;
4732: --- now set the error code
4733: IF PG_DEBUG in ('Y', 'C') THEN
4734: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_org_item_detail_flag := ' || l_org_item_detail_flag);
4735: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'l_satisfied_by_subst_flag := '|| l_satisfied_by_subst_flag);
4736: END IF;
4737: IF ((NVL(l_org_item_detail_flag, -1) <>1 OR NVL(l_satisfied_by_subst_flag,-1) <> 1)) THEN
4738:
4739: IF item_availability_info.atp_flag(l_item_idx) = 'N'
4742: --- if item we used to satify the demand is non-atpable then we want to show thate error
4743: -- we will come here only if date is apps due
4744: ELSE
4745: IF PG_DEBUG in ('Y', 'C') THEN
4746: msc_Sch_wb.atp_debug('ATP_Check_Subst: ' || 'Set error code');
4747: END IF;
4748: IF p_atp_record.ship_date is not NULL THEN
4749: p_atp_record.error_code := MSC_ATP_PVT.ATP_REQ_DATE_FAIL;
4750:
4761: EXCEPTION
4762:
4763: WHEN MSC_ATP_PVT.NO_MATCHING_DATE_IN_CAL THEN --bug3583705
4764: IF PG_DEBUG in ('Y', 'C') THEN
4765: msc_sch_wb.atp_debug('MAtching cal date not found, in atp_check_subs');
4766: END IF;
4767: p_atp_record.error_code := MSC_ATP_PVT.NO_MATCHING_CAL_DATE;
4768: RAISE MSC_ATP_PVT.NO_MATCHING_DATE_IN_CAL;
4769:
4786: IF (p_atp_record.error_code IS NULL) or (p_atp_record.error_code IN (0,61,150)) THEN
4787: IF l_msg_app='MRP' AND l_msg_name='GEN-DATE OUT OF BOUNDS' THEN
4788: p_atp_record.error_code := MSC_ATP_PVT.NO_MATCHING_CAL_DATE;
4789: IF PG_DEBUG in ('Y', 'C') THEN
4790: msc_sch_wb.atp_debug('ATP_CHECK_SUBS: NO_MATCHING_CAL_DATE');
4791: END IF;
4792: ELSE
4793: p_atp_record.error_code := MSC_ATP_PVT.ATP_PROCESSING_ERROR; -- ATP Processing Error
4794: IF PG_DEBUG in ('Y', 'C') THEN
4791: END IF;
4792: ELSE
4793: p_atp_record.error_code := MSC_ATP_PVT.ATP_PROCESSING_ERROR; -- ATP Processing Error
4794: IF PG_DEBUG in ('Y', 'C') THEN
4795: msc_sch_wb.atp_debug('ATP_CHECK_SUBS: ATP_PROCESSING_ERROR');
4796: END IF;
4797: END IF;
4798: END IF;
4799: --bug3583705 end
4800: IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
4801: FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME , 'ATP_CHECK_SUBST');
4802: END IF;
4803: IF PG_DEBUG in ('Y', 'C') THEN
4804: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'error := ' || sqlerrm);
4805: END IF;
4806:
4807: FOR i in 1..item_availability_info.inventory_item_id.count LOOP
4808: IF PG_DEBUG in ('Y', 'C') THEN
4805: END IF;
4806:
4807: FOR i in 1..item_availability_info.inventory_item_id.count LOOP
4808: IF PG_DEBUG in ('Y', 'C') THEN
4809: msc_sch_wb.atp_debug('ATP_Check_Subst: ' || 'delete demand for item ' || item_availability_info.item_name(i)
4810: || ' ' || item_availability_info.sr_inventory_item_id(i));
4811: END IF;
4812:
4813: MSC_ATP_DB_UTILS.Remove_Invalid_SD_Rec(item_availability_info.end_pegging_id(i),
4846: l_request_date date;
4847: BEGIN
4848:
4849: IF PG_DEBUG in ('Y', 'C') THEN
4850: msc_sch_wb.atp_debug('**** Begin Get_Item_Substitutes ****');
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4847: BEGIN
4848:
4849: IF PG_DEBUG in ('Y', 'C') THEN
4850: msc_sch_wb.atp_debug('**** Begin Get_Item_Substitutes ****');
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4848:
4849: IF PG_DEBUG in ('Y', 'C') THEN
4850: msc_sch_wb.atp_debug('**** Begin Get_Item_Substitutes ****');
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4849: IF PG_DEBUG in ('Y', 'C') THEN
4850: msc_sch_wb.atp_debug('**** Begin Get_Item_Substitutes ****');
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4857: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4850: msc_sch_wb.atp_debug('**** Begin Get_Item_Substitutes ****');
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4857: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4858: END IF;
4851: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_inventory_item_id = ' || p_inventory_item_id);
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4857: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4858: END IF;
4859:
4852: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_instance_id := ' || p_instance_id);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4857: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4858: END IF;
4859:
4860: l_request_date := trunc(p_request_date);
4853: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_plan_id := ' || p_plan_id);
4854: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_id := ' || p_customer_id);
4855: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_customer_site_id := ' || p_customer_site_id);
4856: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_request_date := ' || p_request_date);
4857: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4858: END IF;
4859:
4860: l_request_date := trunc(p_request_date);
4861:
4859:
4860: l_request_date := trunc(p_request_date);
4861:
4862: IF PG_DEBUG in ('Y', 'C') THEN
4863: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'G_HIERARCHY_PROFILE = '||MSC_ATP_PVT.G_HIERARCHY_PROFILE);
4864: END IF;
4865: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 2) THEN
4866: IF PG_DEBUG in ('Y', 'C') THEN
4867: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Customer class alloc atp. Set the local varibale from global var');
4863: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'G_HIERARCHY_PROFILE = '||MSC_ATP_PVT.G_HIERARCHY_PROFILE);
4864: END IF;
4865: IF (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 2) THEN
4866: IF PG_DEBUG in ('Y', 'C') THEN
4867: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Customer class alloc atp. Set the local varibale from global var');
4868: END IF;
4869: l_customer_id := MSC_ATP_PVT.G_PARTNER_ID;
4870: l_customer_site_id := MSC_ATP_PVT.G_PARTNER_SITE_ID;
4871: ELSIF p_customer_id is not null and p_customer_site_id is not null THEN
4870: l_customer_site_id := MSC_ATP_PVT.G_PARTNER_SITE_ID;
4871: ELSIF p_customer_id is not null and p_customer_site_id is not null THEN
4872:
4873: IF PG_DEBUG in ('Y', 'C') THEN
4874: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Convert customer/site id');
4875: END IF;
4876: BEGIN
4877: SELECT TP_ID
4878: INTO l_customer_id
4885: l_customer_id := NULL;
4886: END ;
4887:
4888: IF PG_DEBUG in ('Y', 'C') THEN
4889: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_id = '||l_customer_id);
4890: END IF;
4891:
4892: BEGIN
4893: SELECT TP_SITE_ID
4900: WHEN NO_DATA_FOUND THEN
4901: l_customer_site_id := null;
4902: END ;
4903: IF PG_DEBUG in ('Y', 'C') THEN
4904: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_site_id := ' || l_customer_site_id);
4905: END IF;
4906:
4907: ELSE
4908: IF PG_DEBUG in ('Y', 'C') THEN
4905: END IF;
4906:
4907: ELSE
4908: IF PG_DEBUG in ('Y', 'C') THEN
4909: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Customer/customer site is not give');
4910: END IF;
4911: l_customer_id := null;
4912: l_customer_site_id := null;
4913: END IF;
4912: l_customer_site_id := null;
4913: END IF;
4914:
4915: IF PG_DEBUG in ('Y', 'C') THEN
4916: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_id := ' || l_customer_id);
4917: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_site_id := ' || l_customer_site_id);
4918: END IF;
4919:
4920: IF l_customer_id is NULL or l_customer_site_id is NULL THEN
4913: END IF;
4914:
4915: IF PG_DEBUG in ('Y', 'C') THEN
4916: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_id := ' || l_customer_id);
4917: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'l_customer_site_id := ' || l_customer_site_id);
4918: END IF;
4919:
4920: IF l_customer_id is NULL or l_customer_site_id is NULL THEN
4921: --- no customer defined, get generic rule
4982: Order By mis.rank desc;
4983:
4984:
4985: IF PG_DEBUG in ('Y', 'C') THEN
4986: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
4987: END IF;
4988: ELSE
4989: SELECT count(*)
4990: INTO l_count
4996: AND mis.customer_id = l_customer_id
4997: AND mis.customer_site_id = l_customer_site_id;
4998:
4999: IF PG_DEBUG in ('Y', 'C') THEN
5000: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Number of customer specific rule := ' || l_count);
5001: END IF;
5002:
5003: IF l_count > 0 THEN
5004: ---- customer specific rule
5002:
5003: IF l_count > 0 THEN
5004: ---- customer specific rule
5005: IF PG_DEBUG in ('Y', 'C') THEN
5006: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Get Customer specific rule');
5007: END IF;
5008: SELECT mis.higher_item_id, mis.partial_fulfillment_flag,
5009: msi1.sr_inventory_item_id, msi1.item_name, mis.highest_item_id,
5010: mis.effective_date, mis.disable_date,
5070: -- time_phased_atp changes end
5071: Order By mis.effective_date, mis.rank desc;
5072:
5073: IF PG_DEBUG in ('Y', 'C') THEN
5074: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'p_item_table.count := ' || p_item_table.inventory_item_id.count);
5075: END IF;
5076:
5077: FOR i in 1..p_item_table.inventory_item_id.count LOOP
5078: IF PG_DEBUG in ('Y', 'C') THEN
5075: END IF;
5076:
5077: FOR i in 1..p_item_table.inventory_item_id.count LOOP
5078: IF PG_DEBUG in ('Y', 'C') THEN
5079: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg :: effective dt : disbale dt ');
5080: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : '
5081: || p_item_table.sr_inventory_item_id(i) || ' : '
5082: || p_item_table.item_name(i) || ' : '
5083: || p_item_table.partial_fulfillment_flag(i)
5076:
5077: FOR i in 1..p_item_table.inventory_item_id.count LOOP
5078: IF PG_DEBUG in ('Y', 'C') THEN
5079: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg :: effective dt : disbale dt ');
5080: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : '
5081: || p_item_table.sr_inventory_item_id(i) || ' : '
5082: || p_item_table.item_name(i) || ' : '
5083: || p_item_table.partial_fulfillment_flag(i)
5084: || l_effective_dates(i)
5082: || p_item_table.item_name(i) || ' : '
5083: || p_item_table.partial_fulfillment_flag(i)
5084: || l_effective_dates(i)
5085: || l_disable_dates(i));
5086: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5087: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5088: || p_item_table.family_dest_id(i) || ' : '
5089: || p_item_table.family_item_name(i) || ' : '
5090: || p_item_table.atf_date(i));
5083: || p_item_table.partial_fulfillment_flag(i)
5084: || l_effective_dates(i)
5085: || l_disable_dates(i));
5086: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5087: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5088: || p_item_table.family_dest_id(i) || ' : '
5089: || p_item_table.family_item_name(i) || ' : '
5090: || p_item_table.atf_date(i));
5091: END IF;
5093: ELSE
5094: ---generic rule
5095:
5096: IF PG_DEBUG in ('Y', 'C') THEN
5097: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'Get Generic rule');
5098: END IF;
5099: --- get generic rule
5100: --- no customer defined, get generic rule
5101: SELECT mis.higher_item_id, mis.partial_fulfillment_flag,
5177: END IF;
5178:
5179: FOR i in 1..p_item_table.inventory_item_id.count LOOP
5180: IF PG_DEBUG in ('Y', 'C') THEN
5181: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg ');
5182: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : ' || p_item_table.sr_inventory_item_id(i) || ' : ' ||
5183: p_item_table.item_name(i) || ' : ' || p_item_table.partial_fulfillment_flag(i));
5184: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5185: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5178:
5179: FOR i in 1..p_item_table.inventory_item_id.count LOOP
5180: IF PG_DEBUG in ('Y', 'C') THEN
5181: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg ');
5182: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : ' || p_item_table.sr_inventory_item_id(i) || ' : ' ||
5183: p_item_table.item_name(i) || ' : ' || p_item_table.partial_fulfillment_flag(i));
5184: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5185: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5186: || p_item_table.family_dest_id(i) || ' : '
5180: IF PG_DEBUG in ('Y', 'C') THEN
5181: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg ');
5182: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : ' || p_item_table.sr_inventory_item_id(i) || ' : ' ||
5183: p_item_table.item_name(i) || ' : ' || p_item_table.partial_fulfillment_flag(i));
5184: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5185: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5186: || p_item_table.family_dest_id(i) || ' : '
5187: || p_item_table.family_item_name(i) || ' : '
5188: || p_item_table.atf_date(i));
5181: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: Inv_id : sr_inv_id : item_name : par_full_flg ');
5182: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.inventory_item_id(i) || ' : ' || p_item_table.sr_inventory_item_id(i) || ' : ' ||
5183: p_item_table.item_name(i) || ' : ' || p_item_table.partial_fulfillment_flag(i));
5184: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || 'counter: family_sr_id : family_dest_id : family_item_name : atf_date ');
5185: msc_sch_wb.atp_debug('Get_Item_Substitutes: ' || i || ' : ' || p_item_table.family_sr_id(i) || ' : '
5186: || p_item_table.family_dest_id(i) || ' : '
5187: || p_item_table.family_item_name(i) || ' : '
5188: || p_item_table.atf_date(i));
5189: END IF;
5197: p_quantity number)
5198: IS
5199: BEGIN
5200: IF PG_DEBUG in ('Y', 'C') THEN
5201: msc_sch_wb.atp_debug('BEGIN Update_demand ');
5202: msc_sch_wb.atp_debug('Update_demand: ' || 'p_demand_id := ' || p_demand_id);
5203: msc_sch_wb.atp_debug('Update_demand: ' || 'p_plan_id := ' || p_plan_id);
5204: msc_sch_wb.atp_debug('Update_demand: ' || 'p_quantity := ' || p_quantity);
5205: END IF;
5198: IS
5199: BEGIN
5200: IF PG_DEBUG in ('Y', 'C') THEN
5201: msc_sch_wb.atp_debug('BEGIN Update_demand ');
5202: msc_sch_wb.atp_debug('Update_demand: ' || 'p_demand_id := ' || p_demand_id);
5203: msc_sch_wb.atp_debug('Update_demand: ' || 'p_plan_id := ' || p_plan_id);
5204: msc_sch_wb.atp_debug('Update_demand: ' || 'p_quantity := ' || p_quantity);
5205: END IF;
5206:
5199: BEGIN
5200: IF PG_DEBUG in ('Y', 'C') THEN
5201: msc_sch_wb.atp_debug('BEGIN Update_demand ');
5202: msc_sch_wb.atp_debug('Update_demand: ' || 'p_demand_id := ' || p_demand_id);
5203: msc_sch_wb.atp_debug('Update_demand: ' || 'p_plan_id := ' || p_plan_id);
5204: msc_sch_wb.atp_debug('Update_demand: ' || 'p_quantity := ' || p_quantity);
5205: END IF;
5206:
5207: update msc_demands
5200: IF PG_DEBUG in ('Y', 'C') THEN
5201: msc_sch_wb.atp_debug('BEGIN Update_demand ');
5202: msc_sch_wb.atp_debug('Update_demand: ' || 'p_demand_id := ' || p_demand_id);
5203: msc_sch_wb.atp_debug('Update_demand: ' || 'p_plan_id := ' || p_plan_id);
5204: msc_sch_wb.atp_debug('Update_demand: ' || 'p_quantity := ' || p_quantity);
5205: END IF;
5206:
5207: update msc_demands
5208: set using_requirement_quantity = p_quantity
5208: set using_requirement_quantity = p_quantity
5209: where demand_id = p_demand_id
5210: and plan_id = p_plan_id;
5211: IF PG_DEBUG in ('Y', 'C') THEN
5212: msc_sch_wb.atp_debug('Update_demand: ' || 'Number of Rows Updated := ' || SQL%ROWCOUNT);
5213: END IF;
5214:
5215: IF MSC_ATP_PVT.G_INV_CTP = 4 and MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y'
5216: AND MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1 AND MSC_ATP_PVT.G_ALLOCATION_METHOD = 1 THEN
5215: IF MSC_ATP_PVT.G_INV_CTP = 4 and MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y'
5216: AND MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1 AND MSC_ATP_PVT.G_ALLOCATION_METHOD = 1 THEN
5217:
5218: IF PG_DEBUG in ('Y', 'C') THEN
5219: msc_sch_wb.atp_debug('Update_demand: ' || 'Update preallocated demand');
5220: END IF;
5221: update msc_alloc_demands
5222: set allocated_quantity = p_quantity
5223: where parent_demand_id = p_demand_id
5223: where parent_demand_id = p_demand_id
5224: and plan_id = p_plan_id;
5225:
5226: IF PG_DEBUG in ('Y', 'C') THEN
5227: msc_sch_wb.atp_debug('Update_demand: ' || 'Number of Rows Updated := ' || SQL%ROWCOUNT);
5228: END IF;
5229: END IF;
5230:
5231:
5236: p_plan_id number)
5237: IS
5238: BEGIN
5239: IF PG_DEBUG in ('Y', 'C') THEN
5240: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'BEGIN delete demand subst ');
5241: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_demand_id := ' || p_demand_id);
5242: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_plan_id := ' || p_plan_id);
5243: END IF;
5244:
5237: IS
5238: BEGIN
5239: IF PG_DEBUG in ('Y', 'C') THEN
5240: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'BEGIN delete demand subst ');
5241: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_demand_id := ' || p_demand_id);
5242: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_plan_id := ' || p_plan_id);
5243: END IF;
5244:
5245:
5238: BEGIN
5239: IF PG_DEBUG in ('Y', 'C') THEN
5240: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'BEGIN delete demand subst ');
5241: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_demand_id := ' || p_demand_id);
5242: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'p_plan_id := ' || p_plan_id);
5243: END IF;
5244:
5245:
5246: --- DELETE DEMAND
5248: where demand_id = p_demand_id
5249: and plan_id = p_plan_id;
5250:
5251: IF PG_DEBUG in ('Y', 'C') THEN
5252: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'Number of Rows deleted := ' || SQL%ROWCOUNT);
5253: END IF;
5254:
5255: IF MSC_ATP_PVT.G_INV_CTP = 4 and MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y'
5256: AND MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1 AND MSC_ATP_PVT.G_ALLOCATION_METHOD = 1 THEN
5255: IF MSC_ATP_PVT.G_INV_CTP = 4 and MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y'
5256: AND MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1 AND MSC_ATP_PVT.G_ALLOCATION_METHOD = 1 THEN
5257:
5258: IF PG_DEBUG in ('Y', 'C') THEN
5259: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'Delete Allocated demand');
5260: END IF;
5261: delete msc_alloc_demands
5262: where parent_demand_id = p_demand_id
5263: and plan_id = p_plan_id;
5262: where parent_demand_id = p_demand_id
5263: and plan_id = p_plan_id;
5264:
5265: IF PG_DEBUG in ('Y', 'C') THEN
5266: msc_sch_wb.atp_debug('Delete_demand_subst: ' || 'Number of Rows deleted := ' || SQL%ROWCOUNT);
5267: END IF;
5268:
5269: END IF;
5270:
5275: p_pegging_rec IN mrp_atp_details_temp%ROWTYPE)
5276: IS
5277: BEGIN
5278: IF PG_DEBUG in ('Y', 'C') THEN
5279: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'Add pegging for Peg id : ' || p_pegging_rec.pegging_id);
5280: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'intransit lead time: ' || p_pegging_rec.INTRANSIT_LEAD_TIME);
5281: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'aggregate_time_fence_date: ' || p_pegging_rec.aggregate_time_fence_date); --bug3467631
5282: END IF;
5283:
5276: IS
5277: BEGIN
5278: IF PG_DEBUG in ('Y', 'C') THEN
5279: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'Add pegging for Peg id : ' || p_pegging_rec.pegging_id);
5280: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'intransit lead time: ' || p_pegging_rec.INTRANSIT_LEAD_TIME);
5281: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'aggregate_time_fence_date: ' || p_pegging_rec.aggregate_time_fence_date); --bug3467631
5282: END IF;
5283:
5284: INSERT into mrp_atp_details_temp
5277: BEGIN
5278: IF PG_DEBUG in ('Y', 'C') THEN
5279: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'Add pegging for Peg id : ' || p_pegging_rec.pegging_id);
5280: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'intransit lead time: ' || p_pegging_rec.INTRANSIT_LEAD_TIME);
5281: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'aggregate_time_fence_date: ' || p_pegging_rec.aggregate_time_fence_date); --bug3467631
5282: END IF;
5283:
5284: INSERT into mrp_atp_details_temp
5285: (session_id,
5470: p_pegging_rec.intransit_cal_code, -- Bug 3826234
5471: p_pegging_rec.manufacturing_cal_code -- Bug 3826234
5472: );
5473: IF PG_DEBUG in ('Y', 'C') THEN
5474: msc_sch_wb.atp_debug('ADD_PEGGING: ' || 'Number of rows : ' || SQL%ROWCOUNT);
5475: END IF;
5476: END ADD_PEGGING;
5477:
5478: Procedure Extend_Item_Info_Rec_Typ(
5613: i PLS_INTEGER;
5614: Begin
5615:
5616: IF PG_DEBUG in ('Y', 'C') THEN
5617: msc_sch_wb.atp_debug('***** Begin Details_Output Procedure *****');
5618: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_period_idx : = ' || p_begin_period_idx);
5619: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_period_idx := ' || p_end_period_idx);
5620: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_sd_idx := ' || p_begin_sd_idx);
5621: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_sd_idx := ' || p_end_sd_idx);
5614: Begin
5615:
5616: IF PG_DEBUG in ('Y', 'C') THEN
5617: msc_sch_wb.atp_debug('***** Begin Details_Output Procedure *****');
5618: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_period_idx : = ' || p_begin_period_idx);
5619: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_period_idx := ' || p_end_period_idx);
5620: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_sd_idx := ' || p_begin_sd_idx);
5621: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_sd_idx := ' || p_end_sd_idx);
5622: END IF;
5615:
5616: IF PG_DEBUG in ('Y', 'C') THEN
5617: msc_sch_wb.atp_debug('***** Begin Details_Output Procedure *****');
5618: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_period_idx : = ' || p_begin_period_idx);
5619: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_period_idx := ' || p_end_period_idx);
5620: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_sd_idx := ' || p_begin_sd_idx);
5621: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_sd_idx := ' || p_end_sd_idx);
5622: END IF;
5623:
5616: IF PG_DEBUG in ('Y', 'C') THEN
5617: msc_sch_wb.atp_debug('***** Begin Details_Output Procedure *****');
5618: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_period_idx : = ' || p_begin_period_idx);
5619: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_period_idx := ' || p_end_period_idx);
5620: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_sd_idx := ' || p_begin_sd_idx);
5621: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_sd_idx := ' || p_end_sd_idx);
5622: END IF;
5623:
5624: x_return_status := FND_API.G_RET_STS_SUCCESS;
5617: msc_sch_wb.atp_debug('***** Begin Details_Output Procedure *****');
5618: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_period_idx : = ' || p_begin_period_idx);
5619: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_period_idx := ' || p_end_period_idx);
5620: msc_sch_wb.atp_debug('Details_Output: ' || 'p_begin_sd_idx := ' || p_begin_sd_idx);
5621: msc_sch_wb.atp_debug('Details_Output: ' || 'p_end_sd_idx := ' || p_end_sd_idx);
5622: END IF;
5623:
5624: x_return_status := FND_API.G_RET_STS_SUCCESS;
5625:
5756: x_atp_supply_demand.End_Pegging_Id(l_count+l_sd_count):=
5757: p_atp_supply_demand.End_Pegging_Id(i);
5758:
5759: IF PG_DEBUG in ('Y', 'C') THEN
5760: msc_sch_wb.atp_debug('Details_Output: item '||
5761: p_atp_supply_demand.inventory_item_id(i)||
5762: ' : org '|| p_atp_supply_demand.organization_id(i) ||
5763: ' : qty '|| p_atp_supply_demand.supply_demand_quantity(i) ||
5764: ' : peg '|| p_atp_supply_demand.pegging_id(i));
5768: END LOOP;
5769: END IF;
5770:
5771: IF PG_DEBUG in ('Y', 'C') THEN
5772: msc_sch_wb.atp_debug('***** End Details_Output Procedure *****');
5773: END IF;
5774:
5775: END Details_Output;
5776:
5781: l_return_status varchar2(1);
5782: l_count number;
5783: BEGIN
5784: IF PG_DEBUG in ('Y', 'C') THEN
5785: msc_sch_wb.atp_debug('***** start Copy_Item_Info_Rec ****');
5786: END IF;
5787: MSC_ATP_SUBST.Extend_Item_Info_Rec_Typ(p_child_item_info, l_return_status);
5788: l_count := p_child_item_info.inventory_item_id.count;
5789: p_child_item_info.inventory_item_id(l_count) := p_parent_item_info.inventory_item_id(p_index);
5838: p_child_item_info.Atf_Date_Quantity(l_count) := p_parent_item_info.Atf_Date_Quantity(p_index);
5839:
5840:
5841: IF PG_DEBUG in ('Y', 'C') THEN
5842: msc_sch_wb.atp_debug('***** END Copy_Item_Info_Rec ****');
5843: END IF;
5844:
5845: END Copy_Item_Info_Rec;
5846:
5860: temp_sd_qty number;
5861: l_record_source number := 2; -- for plan order pegging
5862: BEGIN
5863: IF PG_DEBUG in ('Y', 'C') THEN
5864: msc_sch_wb.atp_debug('***** Begin SUBST Add_Mat_Demand *****');
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5861: l_record_source number := 2; -- for plan order pegging
5862: BEGIN
5863: IF PG_DEBUG in ('Y', 'C') THEN
5864: msc_sch_wb.atp_debug('***** Begin SUBST Add_Mat_Demand *****');
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5862: BEGIN
5863: IF PG_DEBUG in ('Y', 'C') THEN
5864: msc_sch_wb.atp_debug('***** Begin SUBST Add_Mat_Demand *****');
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5863: IF PG_DEBUG in ('Y', 'C') THEN
5864: msc_sch_wb.atp_debug('***** Begin SUBST Add_Mat_Demand *****');
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5864: msc_sch_wb.atp_debug('***** Begin SUBST Add_Mat_Demand *****');
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5865: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.quantity_ordered '||p_atp_rec.quantity_ordered);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5866: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.requested_ship_date '||p_atp_rec.requested_ship_date);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5874: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'request_item_id :=' || p_atp_rec.request_item_id);
5867: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.origination_type '||p_atp_rec.origination_type);
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5874: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'request_item_id :=' || p_atp_rec.request_item_id);
5875: END IF;
5868: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.inventory_item_id '||p_atp_rec.inventory_item_id);
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5874: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'request_item_id :=' || p_atp_rec.request_item_id);
5875: END IF;
5876: --IF (p_atp_rec.origination_type NOT IN (6, 30)) THEN
5869: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.organization_id '||p_atp_rec.organization_id);
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5874: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'request_item_id :=' || p_atp_rec.request_item_id);
5875: END IF;
5876: --IF (p_atp_rec.origination_type NOT IN (6, 30)) THEN
5877:
5870: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.demand_source_line '||p_atp_rec.demand_source_line);
5871: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.instance_id '||p_atp_rec.instance_id);
5872: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_plan_id = ' || p_plan_id);
5873: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'p_atp_rec.action '||p_atp_rec.action);
5874: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'request_item_id :=' || p_atp_rec.request_item_id);
5875: END IF;
5876: --IF (p_atp_rec.origination_type NOT IN (6, 30)) THEN
5877:
5878: IF PG_DEBUG in ('Y', 'C') THEN
5875: END IF;
5876: --IF (p_atp_rec.origination_type NOT IN (6, 30)) THEN
5877:
5878: IF PG_DEBUG in ('Y', 'C') THEN
5879: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'before insert into msc_demands');
5880: END IF;
5881:
5882: INSERT INTO MSC_DEMANDS(
5883: DEMAND_ID,
5936: --1657855, remove support for min allocation
5937: ---p_atp_rec.stolen_flag)
5938: RETURNING DEMAND_ID INTO x_demand_id;
5939: IF PG_DEBUG in ('Y', 'C') THEN
5940: msc_sch_wb.atp_debug('Add_Mat_Demand: ' || 'Numbe of rows inserted := ' || SQL%ROWCOUNT);
5941: END IF;
5942: IF ((MSC_ATP_PVT.G_INV_CTP = 4) AND
5943: (MSC_ATP_PVT.G_ALLOCATED_ATP = 'Y') AND
5944: (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1) AND
5944: (MSC_ATP_PVT.G_HIERARCHY_PROFILE = 1) AND
5945: (MSC_ATP_PVT.G_ALLOCATION_METHOD = 1)) THEN
5946:
5947: IF PG_DEBUG in ('Y', 'C') THEN
5948: msc_sch_wb.atp_debug('Add_Mat_Demand: before insert into'||
5949: ' msc_alloc_demands');
5950: END IF;
5951:
5952: INSERT INTO MSC_ALLOC_DEMANDS(
5984: sysdate);
5985: END IF;
5986: --END IF;
5987: IF PG_DEBUG in ('Y', 'C') THEN
5988: msc_sch_wb.atp_debug('***** End Add_Mat_Demand *****');
5989: END IF;
5990:
5991: END Add_Mat_Demand;
5992: */