635: -- the date after offsetting
636: -- the lead time from the implement_date
637: lv_date := p_implement_date -
638: (trunc(p_implement_Date)-
639: trunc(msc_calendar.date_offset(p_org_id,p_inst_id,1,p_implement_Date,
640: -1 * ln_pp_lead_time)));
641:
642: --if the Receiving calendar is not null
643: --validate the date against the Receiving Calendar
643: --validate the date against the Receiving Calendar
644: --else validate the date against the
645: -- Org Manufacturing Calendar
646: if p_receiving_calendar is not null then
647: lv_date := lv_date - (trunc(lv_date) - trunc(msc_calendar.PREV_WORK_DAY(p_receiving_calendar,p_inst_id, trunc(lv_date))));
648: else
649: lv_date := msc_calendar.PREV_WORK_DAY(p_org_id,p_inst_id,1,trunc(lv_date));
650: end if;
651: return greatest(trunc(sysdate),lv_date);
645: -- Org Manufacturing Calendar
646: if p_receiving_calendar is not null then
647: lv_date := lv_date - (trunc(lv_date) - trunc(msc_calendar.PREV_WORK_DAY(p_receiving_calendar,p_inst_id, trunc(lv_date))));
648: else
649: lv_date := msc_calendar.PREV_WORK_DAY(p_org_id,p_inst_id,1,trunc(lv_date));
650: end if;
651: return greatest(trunc(sysdate),lv_date);
652: exception when others then
653: return null;
712: -- after offsetting the lead time from the
713: --implement_dock_date
714: lv_date := p_implement_Dock_Date-
715: (trunc(p_implement_dock_date)-
716: trunc(msc_calendar.date_offset(p_org_id,p_inst_id,1,
717: p_implement_dock_date,-1 * x_intransit_lead_time)));
718: -- if intransit calendar is not null then validate the
719: -- date against the intransit calendar
720: -- else validate the date against the shipping calendar.
719: -- date against the intransit calendar
720: -- else validate the date against the shipping calendar.
721: if p_intransit_calendar is not null then
722: lv_date := lv_date - (trunc(lv_date) -
723: trunc(msc_calendar.PREV_WORK_DAY(p_intransit_calendar, p_inst_id, trunc(lv_date))));
724: else
725: lv_date := lv_date - (trunc(lv_date) -
726: trunc(msc_calendar.PREV_WORK_DAY(p_ship_calendar, p_inst_id, trunc(lv_date))));
727: end if;
722: lv_date := lv_date - (trunc(lv_date) -
723: trunc(msc_calendar.PREV_WORK_DAY(p_intransit_calendar, p_inst_id, trunc(lv_date))));
724: else
725: lv_date := lv_date - (trunc(lv_date) -
726: trunc(msc_calendar.PREV_WORK_DAY(p_ship_calendar, p_inst_id, trunc(lv_date))));
727: end if;
728: return greatest(trunc(sysdate),lv_date);
729: else
730: return null;