375: lStmtNum := 10;
376:
377: select CAL.CALENDAR_DATE
378: into lEstRelDate
379: from bom_calendar_dates cal,
380: mtl_system_items msi,
381: bom_cto_order_lines bcol,
382: mtl_parameters mp
383: where msi.organization_id = pOrgId
390: and cal.seq_num =
391: (select cal2.prior_seq_num
392: - (ceil(nvl(msi.fixed_lead_time,0)
393: + nvl(msi.variable_lead_time,0) * bcol.ordered_quantity))
394: from bom_calendar_dates cal2
395: where cal2.calendar_code = mp.calendar_code
396: and cal2.exception_set_id = mp.calendar_exception_set_id
397: and cal2.calendar_date = trunc(bcol.schedule_ship_date));
398:
508: lStmtNum := 13;
509:
510: select CAL.CALENDAR_DATE
511: into lEstRelDate
512: from bom_calendar_dates cal,
513: mtl_system_items msi,
514: bom_cto_order_lines bcol,
515: mtl_parameters mp
516: where msi.organization_id = pOrgId
522: and cal.calendar_code = mp.calendar_code
523: and cal.exception_set_id = mp.calendar_exception_set_id
524: and cal.seq_num =
525: (select cal2.prior_seq_num - lTotLeadTime
526: from bom_calendar_dates cal2
527: where cal2.calendar_code = mp.calendar_code
528: and cal2.exception_set_id = mp.calendar_exception_set_id
529: and cal2.calendar_date = trunc(bcol.schedule_ship_date));
530: