82: l_maxSchedSeqNum NUMBER;
83: l_schedMethod NUMBER;
84: begin
85: savepoint wipiscdb0;
86: if (l_logLevel <= wip_constants.trace_logging) then
87: l_params(1).paramName := 'p_orgID';
88: l_params(1).paramValue := p_orgID;
89: l_params(2).paramName := 'p_wipEntityID';
90: l_params(2).paramValue := p_wipEntityID;
117: if(fnd_api.to_boolean(nvl(p_initMsgList, fnd_api.g_true))) then
118: fnd_msg_pub.initialize;
119: end if;
120:
121: if (l_logLevel <= wip_constants.full_logging) then
122: wip_logger.log('reading job/schedule...', l_retStatus);
123: end if;
124: if(p_midPntMethod is not null) then
125: l_schedMethod := p_midPntMethod;
123: end if;
124: if(p_midPntMethod is not null) then
125: l_schedMethod := p_midPntMethod;
126: elsif(p_opSeqNum is not null) then
127: l_schedMethod := wip_constants.midpoint;
128: elsif(p_startDate is not null) then
129: l_schedMethod := wip_constants.forwards;
130: else
131: l_schedMethod := wip_constants.backwards;
125: l_schedMethod := p_midPntMethod;
126: elsif(p_opSeqNum is not null) then
127: l_schedMethod := wip_constants.midpoint;
128: elsif(p_startDate is not null) then
129: l_schedMethod := wip_constants.forwards;
130: else
131: l_schedMethod := wip_constants.backwards;
132: end if;
133:
127: l_schedMethod := wip_constants.midpoint;
128: elsif(p_startDate is not null) then
129: l_schedMethod := wip_constants.forwards;
130: else
131: l_schedMethod := wip_constants.backwards;
132: end if;
133:
134: getMidPointInfo(p_midPntOpSeqNum => p_opSeqNum,
135: p_midPntResSeqNum => p_resSeqNum,
166: from wip_repetitive_schedules
167: where repetitive_schedule_id = p_repSchedID;
168: end if;
169: */
170: if (l_logLevel <= wip_constants.full_logging) then
171: wip_logger.log('scheduling job/schedule...', l_retStatus);
172: end if;
173:
174: wip_infResSched_grp.schedule(p_orgID => p_orgID,
183: if(x_returnStatus <> fnd_api.g_ret_sts_success) then
184: raise fnd_api.g_exc_unexpected_error;
185: end if;
186:
187: if (l_logLevel <= wip_constants.full_logging) then
188: wip_logger.log('writing job/schedule...', l_retStatus);
189: end if;
190:
191: writeJobSchedule(p_wipEntityID => p_wipEntityID,
204: if(x_returnStatus <> fnd_api.g_ret_sts_success) then
205: raise fnd_api.g_exc_unexpected_error;
206: end if;
207:
208: if (l_logLevel <= wip_constants.trace_logging) then
209: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.schedule',
210: p_procReturnStatus => x_returnStatus,
211: p_msg => 'success',
212: x_returnStatus => l_retStatus);
219: rollback to wipiscdb0;
220: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
221: wip_utilities.get_message_stack(p_msg => x_errorMsg,
222: p_delete_stack => fnd_api.g_false);
223: if (l_logLevel <= wip_constants.trace_logging) then
224: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.schedule',
225: p_procReturnStatus => x_returnStatus,
226: p_msg => 'error: ' || x_errorMsg,
227: x_returnStatus => l_retStatus);
237: p_procedure_name => 'schedule',
238: p_error_text => SQLERRM);
239: wip_utilities.get_message_stack(p_msg => x_errorMsg,
240: p_delete_stack => fnd_api.g_false);
241: if (l_logLevel <= wip_constants.trace_logging) then
242: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.schedule',
243: p_procReturnStatus => x_returnStatus,
244: p_msg => 'unexp error: ' || x_errorMsg,
245: x_returnStatus => l_retStatus);
262: l_logLevel NUMBER := fnd_log.g_current_runtime_level;
263: l_params wip_logger.param_tbl_t;
264: l_retStatus VARCHAR2(1);
265: begin
266: if (l_logLevel <= wip_constants.trace_logging) then
267: l_params(1).paramName := 'p_midPntOpSeqNum';
268: l_params(1).paramValue := p_midPntOpSeqNum;
269: l_params(2).paramName := 'p_midPntResSeqNum';
270: l_params(2).paramValue := p_midPntResSeqNum;
280: p_params => l_params,
281: x_returnStatus => l_retStatus);
282: end if;
283:
284: if(p_schedMethod in (wip_constants.forwards,
285: wip_constants.backwards,
286: wip_constants.midpoint)) then
287:
288: if(l_logLevel <= wip_constants.full_logging) then
281: x_returnStatus => l_retStatus);
282: end if;
283:
284: if(p_schedMethod in (wip_constants.forwards,
285: wip_constants.backwards,
286: wip_constants.midpoint)) then
287:
288: if(l_logLevel <= wip_constants.full_logging) then
289: wip_logger.log('entire job reschedule', l_retStatus);
282: end if;
283:
284: if(p_schedMethod in (wip_constants.forwards,
285: wip_constants.backwards,
286: wip_constants.midpoint)) then
287:
288: if(l_logLevel <= wip_constants.full_logging) then
289: wip_logger.log('entire job reschedule', l_retStatus);
290: end if;
284: if(p_schedMethod in (wip_constants.forwards,
285: wip_constants.backwards,
286: wip_constants.midpoint)) then
287:
288: if(l_logLevel <= wip_constants.full_logging) then
289: wip_logger.log('entire job reschedule', l_retStatus);
290: end if;
291:
292: select min(operation_seq_num),
296: from wip_operations
297: where wip_entity_id = p_wipEntityID
298: and organization_id = p_orgID;
299:
300: elsif(p_schedMethod = wip_constants.midpoint_forwards) then
301:
302: if(l_logLevel <= wip_constants.full_logging) then
303: wip_logger.log('midpoint forward', l_retStatus);
304: end if;
298: and organization_id = p_orgID;
299:
300: elsif(p_schedMethod = wip_constants.midpoint_forwards) then
301:
302: if(l_logLevel <= wip_constants.full_logging) then
303: wip_logger.log('midpoint forward', l_retStatus);
304: end if;
305:
306: x_minOpSeqNum := p_midPntOpSeqNum;
330: where wip_entity_id = p_wipEntityID
331: and organization_id = p_orgID
332: and operation_seq_num = x_maxOpSeqNum;
333:
334: elsif(p_schedMethod = wip_constants.midpoint_backwards) then
335: x_maxOpSeqNum := p_midPntOpSeqNum;
336:
337: if (p_midPntOpSeqNum is not null AND
338: p_midPntResSeqNum is not null) then
346: else
347: x_maxSchedSeqNum := null;
348: end if;
349:
350: if(l_logLevel <= wip_constants.full_logging) then
351: wip_logger.log('midpoint backward', l_retStatus);
352: end if;
353:
354: select min(operation_seq_num)
362: from wip_operation_resources
363: where wip_entity_id = p_wipEntityID
364: and organization_id = p_orgID
365: and operation_seq_num = x_minOpSeqNum;
366: elsif(p_schedMethod = wip_constants.current_op) then
367:
368: if(l_logLevel <= wip_constants.full_logging) then
369: wip_logger.log('current op', l_retStatus);
370: end if;
364: and organization_id = p_orgID
365: and operation_seq_num = x_minOpSeqNum;
366: elsif(p_schedMethod = wip_constants.current_op) then
367:
368: if(l_logLevel <= wip_constants.full_logging) then
369: wip_logger.log('current op', l_retStatus);
370: end if;
371:
372: x_minOpSeqNum := p_midPntOpSeqNum;
376: from wip_operation_resources
377: where wip_entity_id = p_wipEntityID
378: and organization_id = p_orgID
379: and operation_seq_num = p_midPntOpSeqNum;
380: elsif(p_schedMethod = wip_constants.current_sub_grp) then
381:
382: if(l_logLevel <= wip_constants.full_logging) then
383: wip_logger.log('current sub grp', l_retStatus);
384: end if;
378: and organization_id = p_orgID
379: and operation_seq_num = p_midPntOpSeqNum;
380: elsif(p_schedMethod = wip_constants.current_sub_grp) then
381:
382: if(l_logLevel <= wip_constants.full_logging) then
383: wip_logger.log('current sub grp', l_retStatus);
384: end if;
385:
386: x_minOpSeqNum := p_midPntOpSeqNum;
394: and operation_seq_num = p_midPntOpSeqNum
395: and substitute_group_num = p_subGrpNum;
396: else --current op resource
397:
398: if(l_logLevel <= wip_constants.full_logging) then
399: wip_logger.log('current op res', l_retStatus);
400: end if;
401:
402: x_minOpSeqNum := p_midPntOpSeqNum;
417:
418: x_maxSchedSeqNum := x_minSchedSeqNum;
419: end if;
420:
421: if(l_logLevel <= wip_constants.full_logging) then
422: wip_logger.log('min op seq' || x_minOpSeqNum, l_retStatus);
423: wip_logger.log('min sched seq' || x_minSchedSeqNum, l_retStatus);
424: wip_logger.log('max op seq' || x_maxOpSeqNum, l_retStatus);
425: wip_logger.log('max sched seq' || x_maxSchedSeqNum, l_retStatus);
424: wip_logger.log('max op seq' || x_maxOpSeqNum, l_retStatus);
425: wip_logger.log('max sched seq' || x_maxSchedSeqNum, l_retStatus);
426: end if;
427:
428: if(l_logLevel <= wip_constants.trace_logging) then
429: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.schedule',
430: p_procReturnStatus => 'N/A',
431: p_msg => 'success',
432: x_returnStatus => l_retStatus);
534: and wori.resource_seq_num = wor.resource_seq_num
535: for update nowait;
536: begin
537:
538: if (l_logLevel <= wip_constants.trace_logging) then
539: l_params(1).paramName := 'p_wipEntityID';
540: l_params(1).paramValue := p_wipEntityID;
541: l_params(2).paramName := 'p_repSchedID';
542: l_params(2).paramValue := p_repSchedID;
585: bdr.available_24_hours_flag,
586: --l_hrVal * nvl(muc.conversion_rate,0) *
587: --Bug 4614036:Rounding of usage rate to next minute is handled.
588: /*
589: round((decode(wor.basis_type, wip_constants.per_lot, 1, decode(p_quantity,null,wdj.start_quantity,p_quantity)) *
590: inv_convert.inv_um_convert(0,
591: NULL,
592: wor.usage_rate_or_amount,
593: wor.UOM_CODE,
598: / (
599: -- 60*24 * least(wor.assigned_units, bdr.capacity_units) * --Fixed bug #5618787
600: 24 * least(wor.assigned_units, bdr.capacity_units) *
601: decode(wp.include_resource_utilization,
602: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
603: decode(wp.include_resource_efficiency,
604: wip_constants.yes, nvl(bdr.efficiency, 1), 1)
605: ),
606: */
600: 24 * least(wor.assigned_units, bdr.capacity_units) *
601: decode(wp.include_resource_utilization,
602: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
603: decode(wp.include_resource_efficiency,
604: wip_constants.yes, nvl(bdr.efficiency, 1), 1)
605: ),
606: */
607: -- Start of fix for Bug #5657612: Use ceil function to round up the usage rate to next minute
608: -- bug 6741020: pass a precision = 6 to inv_um_convert as resource usage form field
612: /*Bug#13718464- Checking if any of the units is 0, so that the totalDaysUsg is 0
613: - This handles the case of zero denominator*/
614: decode(( least(wor.assigned_units, bdr.capacity_units) *
615: decode(wp.include_resource_utilization,
616: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
617: decode(wp.include_resource_efficiency,
618: wip_constants.yes, nvl(bdr.efficiency, 1), 1) ),0,0,
619: ceil((decode(wor.basis_type, wip_constants.per_lot, 1, decode(p_quantity,null,wdj.start_quantity,p_quantity)) *
620: inv_convert.inv_um_convert(0,
614: decode(( least(wor.assigned_units, bdr.capacity_units) *
615: decode(wp.include_resource_utilization,
616: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
617: decode(wp.include_resource_efficiency,
618: wip_constants.yes, nvl(bdr.efficiency, 1), 1) ),0,0,
619: ceil((decode(wor.basis_type, wip_constants.per_lot, 1, decode(p_quantity,null,wdj.start_quantity,p_quantity)) *
620: inv_convert.inv_um_convert(0,
621: 10,
622: wor.usage_rate_or_amount,
615: decode(wp.include_resource_utilization,
616: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
617: decode(wp.include_resource_efficiency,
618: wip_constants.yes, nvl(bdr.efficiency, 1), 1) ),0,0,
619: ceil((decode(wor.basis_type, wip_constants.per_lot, 1, decode(p_quantity,null,wdj.start_quantity,p_quantity)) *
620: inv_convert.inv_um_convert(0,
621: 10,
622: wor.usage_rate_or_amount,
623: wor.UOM_CODE,
625: NULL,
626: NULL )*60) /
627: ( least(wor.assigned_units, bdr.capacity_units) *
628: decode(wp.include_resource_utilization,
629: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
630: decode(wp.include_resource_efficiency,
631: wip_constants.yes, nvl(bdr.efficiency, 1), 1) )
632: ) / (60 * 24)),
633: -- End of fix for Bug #5657612
627: ( least(wor.assigned_units, bdr.capacity_units) *
628: decode(wp.include_resource_utilization,
629: wip_constants.yes, nvl(bdr.utilization, 1), 1) *
630: decode(wp.include_resource_efficiency,
631: wip_constants.yes, nvl(bdr.efficiency, 1), 1) )
632: ) / (60 * 24)),
633: -- End of fix for Bug #5657612
634: wor.assigned_units
635: bulk collect into x_resTbls.opSeqNum,
698: --lock the resource instances
699: open c_resInsts;
700: close c_resInsts;
701:
702: if (l_logLevel <= wip_constants.trace_logging) then
703: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.readJobSchedule',
704: p_procReturnStatus => x_returnStatus,
705: p_msg => 'success',
706: x_returnStatus => l_retStatus);
706: x_returnStatus => l_retStatus);
707: end if;
708: exception
709: /*Fix bug 8914181 (FP 8894732)*/
710: when wip_constants.records_locked then
711: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
712: if (l_logLevel <= wip_constants.trace_logging) then
713: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.readJobSchedule',
714: p_procReturnStatus => x_returnStatus,
708: exception
709: /*Fix bug 8914181 (FP 8894732)*/
710: when wip_constants.records_locked then
711: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
712: if (l_logLevel <= wip_constants.trace_logging) then
713: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.readJobSchedule',
714: p_procReturnStatus => x_returnStatus,
715: p_msg => 'records were locked',
716: x_returnStatus => l_retStatus);
721: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
722: fnd_msg_pub.add_exc_msg(p_pkg_name => 'wip_infinite_scheduler_pvt',
723: p_procedure_name => 'readJobSchedule',
724: p_error_text => SQLERRM);
725: if (l_logLevel <= wip_constants.trace_logging) then
726: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.readJobSchedule',
727: p_procReturnStatus => x_returnStatus,
728: p_msg => 'unexp error: ' || SQLERRM,
729: x_returnStatus => l_retStatus);
768: l_retStatus VARCHAR2(1);
769: l_jobdate_align NUMBER := null;
770: begin
771: savepoint wipiscdb100;
772: if (l_logLevel <= wip_constants.trace_logging) then
773: l_params(1).paramName := 'p_wipEntityID';
774: l_params(1).paramValue := p_wipEntityID;
775: l_params(2).paramName := 'p_repSchedID';
776: l_params(2).paramValue := p_repSchedID;
814: and organization_id = p_orgID
815: and operation_seq_num = x_resTbls.opSeqNum(i)
816: and resource_seq_num = x_resTbls.resSeqNum(i);
817:
818: if(l_logLevel <= wip_constants.full_logging) then
819: wip_logger.log('wrote resources', l_retStatus);
820: end if;
821:
822:
831: and organization_id = p_orgID
832: and operation_seq_num = x_resTbls.opSeqNum(i)
833: and resource_seq_num = x_resTbls.resSeqNum(i);
834:
835: if(l_logLevel <= wip_constants.full_logging) then
836: wip_logger.log('wrote resource instances', l_retStatus);
837: end if;
838:
839: delete wip_operation_resource_usage
902: l_progID,
903: l_sysdate);
904: end if;
905: end loop;
906: if(l_logLevel <= wip_constants.full_logging) then
907: wip_logger.log('wrote resource usages', l_retStatus);
908: end if;
909:
910: insert into wip_operation_resource_usage
975: and woru.operation_seq_num = wor.operation_seq_num
976: and woru.resource_seq_num = wor.resource_seq_num;
977:
978:
979: if(l_logLevel <= wip_constants.full_logging) then
980: wip_logger.log('wrote ' || SQL%ROWCOUNT || ' resource instance usages', l_retStatus);
981: end if;
982:
983: if(l_logLevel <= wip_constants.full_logging) then
979: if(l_logLevel <= wip_constants.full_logging) then
980: wip_logger.log('wrote ' || SQL%ROWCOUNT || ' resource instance usages', l_retStatus);
981: end if;
982:
983: if(l_logLevel <= wip_constants.full_logging) then
984: wip_logger.log('about to start op processing', l_retStatus);
985: end if;
986: --base operation dates off of op resource dates
987: select wo.operation_seq_num,
1013: and wo.organization_id = p_orgID
1014: and wo.wip_entity_id = wor.wip_entity_id (+)
1015: and wo.organization_id = wor.organization_id (+)
1016: and wo.operation_seq_num = wor.operation_seq_num (+)
1017: and wip_constants.sched_yes = wor.scheduled_flag (+)
1018: group by wo.operation_seq_num;
1019:
1020: if(l_logLevel <= wip_constants.full_logging) then
1021: wip_logger.log('about to start op processing', l_retStatus);
1016: and wo.operation_seq_num = wor.operation_seq_num (+)
1017: and wip_constants.sched_yes = wor.scheduled_flag (+)
1018: group by wo.operation_seq_num;
1019:
1020: if(l_logLevel <= wip_constants.full_logging) then
1021: wip_logger.log('about to start op processing', l_retStatus);
1022: end if;
1023:
1024: for i in 1..l_opTbls.opSeqNum.count loop
1057: l_opTbls.startDate(i) := p_anchorDate;
1058: l_opTbls.endDate(i) := p_anchorDate;
1059: for j in 1..x_resTbls.resID.count loop
1060: if(x_resTbls.opSeqNum(j) < l_opTbls.opSeqNum(i) and
1061: x_resTbls.schedFlag(j) = wip_constants.sched_prior) then
1062: l_opTbls.startDate(i) := x_resTbls.endDate(j);
1063: l_opTbls.endDate(i) := x_resTbls.endDate(j);
1064: else
1065: exit;
1080: exit;
1081: end if;
1082: end loop;
1083:
1084: if(l_logLevel <= wip_constants.full_logging) then
1085: wip_logger.log('about to write ops', l_retStatus);
1086: end if;
1087:
1088: if(l_startOpIdx is not null) then
1101: program_update_date = l_sysDate
1102: where wip_entity_id = p_wipEntityID
1103: and organization_id = p_orgID
1104: and operation_seq_num = l_opTbls.opSeqNum(i);
1105: if(l_logLevel <= wip_constants.full_logging) then
1106: wip_logger.log('wrote ops', l_retStatus);
1107: end if;
1108:
1109: --update mtl requirement dates if job has routing
1135: and organization_id = p_orgID
1136: and operation_seq_num = 1;
1137: end if;
1138:
1139: if(l_logLevel <= wip_constants.full_logging) then
1140: wip_logger.log('wrote material requirements', l_retStatus);
1141: end if;
1142:
1143: --now update job dates
1147: from wip_operation_resources
1148: where wip_entity_id = p_wipEntityID
1149: and organization_id = p_orgID;
1150:
1151: if(l_logLevel <= wip_constants.full_logging) then
1152: wip_logger.log('min res date:' || to_char(l_minResStartDate, g_logDateFmt), l_retStatus);
1153: wip_logger.log('max res date:' || to_char(l_maxResEndDate, g_logDateFmt), l_retStatus);
1154: end if;
1155: --if there are no resources, set the local variables to p_anchorDate
1156: --so below update is correct.
1157: l_jobdate_align := nvl(fnd_profile.value('WIP:ALIGN_JOB_DATE'),1);
1158: l_jobStartDate := nvl(l_minResStartDate, p_anchorDate);
1159: l_jobCplDate := nvl(l_maxResEndDate, p_anchorDate);
1160: if l_jobdate_align = WIP_CONSTANTS.NO and p_schedMethod = WIP_CONSTANTS.FORWARDS then
1161: l_jobStartDate := p_anchorDate;
1162: end if;
1163: if l_jobdate_align = WIP_CONSTANTS.NO and p_schedMethod = WIP_CONSTANTS.BACKWARDS then
1164: l_jobCplDate := p_anchorDate;
1159: l_jobCplDate := nvl(l_maxResEndDate, p_anchorDate);
1160: if l_jobdate_align = WIP_CONSTANTS.NO and p_schedMethod = WIP_CONSTANTS.FORWARDS then
1161: l_jobStartDate := p_anchorDate;
1162: end if;
1163: if l_jobdate_align = WIP_CONSTANTS.NO and p_schedMethod = WIP_CONSTANTS.BACKWARDS then
1164: l_jobCplDate := p_anchorDate;
1165: end if;
1166:
1167: update wip_discrete_jobs
1176: program_update_date = l_sysDate
1177: where wip_entity_id = p_wipEntityID
1178: and organization_id = p_orgID;
1179:
1180: if (l_logLevel <= wip_constants.trace_logging) then
1181: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.writeJobSchedule',
1182: p_procReturnStatus => x_returnStatus,
1183: p_msg => 'success',
1184: x_returnStatus => l_retStatus);
1189: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
1190: fnd_msg_pub.add_exc_msg(p_pkg_name => 'wip_infinite_scheduler_pvt',
1191: p_procedure_name => 'writeJobSchedule',
1192: p_error_text => SQLERRM);
1193: if (l_logLevel <= wip_constants.trace_logging) then
1194: wip_logger.exitPoint(p_procName => 'wip_infinite_scheduler_pvt.writeJobSchedule',
1195: p_procReturnStatus => x_returnStatus,
1196: p_msg => 'unexp error: ' || SQLERRM,
1197: x_returnStatus => l_retStatus);