83: l_plan_type number;
84: begin
85:
86: select plan_type into l_plan_type
87: from msc_plans where plan_id=p_plan_id;
88:
89: if (l_plan_type = 6) then -- SNO
90: return trunc(p_bkt_end_date);
91: end if;
98:
99: l_calendar_code := fnd_profile.value('MSC_BKT_REFERENCE_CALENDAR');
100: if (l_calendar_code is null) then
101: select mtp.calendar_code into l_calendar_code
102: from msc_trading_partners mtp, msc_plans mp
103: where mtp.sr_tp_id = mp.organization_id
104: and mtp.sr_instance_id = mp.sr_instance_id
105: and mp.plan_id =p_plan_id and mtp.PARTNER_TYPE =3;
106:
267: and p_date between bkt_start_date and bkt_end_date;
268:
269:
270: select sr_instance_id into l_sr_instance_id
271: from msc_plans where plan_id=p_plan_id;
272:
273:
274: return msc_hub_calendar.last_work_date(p_plan_id,l_sr_instance_id,
275: l_bkt_type,l_bkt_start_date,
277: exception
278:
279: when no_data_found then -- if the date is not in any bucket, return the plan start date
280: select curr_start_date into x_date
281: from msc_plans where plan_id = p_plan_id;
282:
283: return x_date;
284: end last_work_date;
285:
326:
327: l_calendar_code := fnd_profile.value('MSC_BKT_REFERENCE_CALENDAR');
328: if (l_calendar_code is null) then
329: select mtp.calendar_code into l_calendar_code
330: from msc_trading_partners mtp, msc_plans mp
331: where mtp.sr_tp_id = mp.organization_id
332: and mtp.sr_instance_id = mp.sr_instance_id
333: and mp.plan_id =p_plan_id and mtp.PARTNER_TYPE =3;
334: