34: cursor c_allrows is
35: select 1
36: from wip_job_schedule_interface
37: where group_id = p_groupID
38: and process_status = wip_constants.pending
39: and process_phase = wip_constants.ml_validation
40: and load_type <> wip_constants.create_sched
41: for update nowait;
42:
35: select 1
36: from wip_job_schedule_interface
37: where group_id = p_groupID
38: and process_status = wip_constants.pending
39: and process_phase = wip_constants.ml_validation
40: and load_type <> wip_constants.create_sched
41: for update nowait;
42:
43: cursor c_wjsi is
36: from wip_job_schedule_interface
37: where group_id = p_groupID
38: and process_status = wip_constants.pending
39: and process_phase = wip_constants.ml_validation
40: and load_type <> wip_constants.create_sched
41: for update nowait;
42:
43: cursor c_wjsi is
44: select rowid,
45: header_id,
46: interface_id
47: from wip_job_schedule_interface
48: where group_id = p_groupID
49: and process_phase = wip_constants.ml_validation
50: and process_status in (wip_constants.running, wip_constants.warning)
51: and load_type <> wip_constants.create_sched;
52: begin
53: x_returnStatus := fnd_api.g_ret_sts_success;
46: interface_id
47: from wip_job_schedule_interface
48: where group_id = p_groupID
49: and process_phase = wip_constants.ml_validation
50: and process_status in (wip_constants.running, wip_constants.warning)
51: and load_type <> wip_constants.create_sched;
52: begin
53: x_returnStatus := fnd_api.g_ret_sts_success;
54: if (l_logLevel <= wip_constants.trace_logging) then
47: from wip_job_schedule_interface
48: where group_id = p_groupID
49: and process_phase = wip_constants.ml_validation
50: and process_status in (wip_constants.running, wip_constants.warning)
51: and load_type <> wip_constants.create_sched;
52: begin
53: x_returnStatus := fnd_api.g_ret_sts_success;
54: if (l_logLevel <= wip_constants.trace_logging) then
55: l_params(1).paramName := 'p_groupID';
50: and process_status in (wip_constants.running, wip_constants.warning)
51: and load_type <> wip_constants.create_sched;
52: begin
53: x_returnStatus := fnd_api.g_ret_sts_success;
54: if (l_logLevel <= wip_constants.trace_logging) then
55: l_params(1).paramName := 'p_groupID';
56: l_params(1).paramValue := p_groupID;
57: l_params(2).paramName := 'p_validationLevel';
58: l_params(2).paramValue := p_validationLevel;
68:
69: select count(*) into l_requestCount
70: from wip_job_schedule_interface
71: where group_id = p_groupID
72: and process_status = wip_constants.pending
73: and process_phase = wip_constants.ml_validation
74: and load_type <> wip_constants.create_sched;
75:
76: if (l_logLevel <= wip_constants.trace_logging) then
69: select count(*) into l_requestCount
70: from wip_job_schedule_interface
71: where group_id = p_groupID
72: and process_status = wip_constants.pending
73: and process_phase = wip_constants.ml_validation
74: and load_type <> wip_constants.create_sched;
75:
76: if (l_logLevel <= wip_constants.trace_logging) then
77: wip_logger.log(l_requestCount || ' pending request(s) found for group_id' || p_groupID || ' for discrete processing', l_retStatus);
70: from wip_job_schedule_interface
71: where group_id = p_groupID
72: and process_status = wip_constants.pending
73: and process_phase = wip_constants.ml_validation
74: and load_type <> wip_constants.create_sched;
75:
76: if (l_logLevel <= wip_constants.trace_logging) then
77: wip_logger.log(l_requestCount || ' pending request(s) found for group_id' || p_groupID || ' for discrete processing', l_retStatus);
78: end if;
72: and process_status = wip_constants.pending
73: and process_phase = wip_constants.ml_validation
74: and load_type <> wip_constants.create_sched;
75:
76: if (l_logLevel <= wip_constants.trace_logging) then
77: wip_logger.log(l_requestCount || ' pending request(s) found for group_id' || p_groupID || ' for discrete processing', l_retStatus);
78: end if;
79:
80: -- lock all the records
85:
86: -- assign interface_id and set process_status to running
87: update wip_job_schedule_interface
88: set interface_id = wip_interface_s.nextval,
89: process_status = wip_constants.running
90: where group_id = p_groupID
91: and process_status = wip_constants.pending
92: and process_phase = wip_constants.ml_validation
93: and load_type <> wip_constants.create_sched;
87: update wip_job_schedule_interface
88: set interface_id = wip_interface_s.nextval,
89: process_status = wip_constants.running
90: where group_id = p_groupID
91: and process_status = wip_constants.pending
92: and process_phase = wip_constants.ml_validation
93: and load_type <> wip_constants.create_sched;
94:
95: if (p_commitFlag <> 0) then
88: set interface_id = wip_interface_s.nextval,
89: process_status = wip_constants.running
90: where group_id = p_groupID
91: and process_status = wip_constants.pending
92: and process_phase = wip_constants.ml_validation
93: and load_type <> wip_constants.create_sched;
94:
95: if (p_commitFlag <> 0) then
96: commit;
89: process_status = wip_constants.running
90: where group_id = p_groupID
91: and process_status = wip_constants.pending
92: and process_phase = wip_constants.ml_validation
93: and load_type <> wip_constants.create_sched;
94:
95: if (p_commitFlag <> 0) then
96: commit;
97: end if;
124: from wip_job_schedule_interface wjsi,
125: wip_job_dtls_interface wjdi
126: where wjdi.parent_header_id = wjsi.header_id
127: and wjdi.group_id = wjsi.group_id
128: and wjdi.process_phase = wip_constants.ml_validation
129: and wjdi.process_status = wip_constants.pending
130: and wjsi.rowid = wjsi_rec.rowid
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
125: wip_job_dtls_interface wjdi
126: where wjdi.parent_header_id = wjsi.header_id
127: and wjdi.group_id = wjsi.group_id
128: and wjdi.process_phase = wip_constants.ml_validation
129: and wjdi.process_status = wip_constants.pending
130: and wjsi.rowid = wjsi_rec.rowid
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
133: wip_constants.resched_job);
127: and wjdi.group_id = wjsi.group_id
128: and wjdi.process_phase = wip_constants.ml_validation
129: and wjdi.process_status = wip_constants.pending
130: and wjsi.rowid = wjsi_rec.rowid
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
133: wip_constants.resched_job);
134:
135: if (l_logLevel <= wip_constants.trace_logging) then
128: and wjdi.process_phase = wip_constants.ml_validation
129: and wjdi.process_status = wip_constants.pending
130: and wjsi.rowid = wjsi_rec.rowid
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
133: wip_constants.resched_job);
134:
135: if (l_logLevel <= wip_constants.trace_logging) then
136: wip_logger.log('There are ' || l_totalNum || ' detail records....', l_retStatus);
129: and wjdi.process_status = wip_constants.pending
130: and wjsi.rowid = wjsi_rec.rowid
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
133: wip_constants.resched_job);
134:
135: if (l_logLevel <= wip_constants.trace_logging) then
136: wip_logger.log('There are ' || l_totalNum || ' detail records....', l_retStatus);
137: end if;
131: and wjsi.load_type in (wip_constants.create_job,
132: wip_constants.create_ns_job,
133: wip_constants.resched_job);
134:
135: if (l_logLevel <= wip_constants.trace_logging) then
136: wip_logger.log('There are ' || l_totalNum || ' detail records....', l_retStatus);
137: end if;
138:
139: if ( l_totalNum > 0 ) then
170: wip_job_schedule_interface wjsi
171: where wjsi.rowid = wjsi_rec.rowid
172: and wdj.wip_entity_id = wjsi.wip_entity_id
173: and wdj.organization_id = wjsi.organization_id
174: and wjsi.load_type in (WIP_CONSTANTS.CREATE_JOB,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
171: where wjsi.rowid = wjsi_rec.rowid
172: and wdj.wip_entity_id = wjsi.wip_entity_id
173: and wdj.organization_id = wjsi.organization_id
174: and wjsi.load_type in (WIP_CONSTANTS.CREATE_JOB,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
179: if (l_wjsi_new_status_type IN (WIP_CONSTANTS.RELEASED,WIP_CONSTANTS.HOLD)) then
172: and wdj.wip_entity_id = wjsi.wip_entity_id
173: and wdj.organization_id = wjsi.organization_id
174: and wjsi.load_type in (WIP_CONSTANTS.CREATE_JOB,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
179: if (l_wjsi_new_status_type IN (WIP_CONSTANTS.RELEASED,WIP_CONSTANTS.HOLD)) then
180: if((wip_osp.po_req_created( l_wdj_wip_entity_id,
173: and wdj.organization_id = wjsi.organization_id
174: and wjsi.load_type in (WIP_CONSTANTS.CREATE_JOB,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
179: if (l_wjsi_new_status_type IN (WIP_CONSTANTS.RELEASED,WIP_CONSTANTS.HOLD)) then
180: if((wip_osp.po_req_created( l_wdj_wip_entity_id,
181: null,
174: and wjsi.load_type in (WIP_CONSTANTS.CREATE_JOB,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
179: if (l_wjsi_new_status_type IN (WIP_CONSTANTS.RELEASED,WIP_CONSTANTS.HOLD)) then
180: if((wip_osp.po_req_created( l_wdj_wip_entity_id,
181: null,
182: l_wdj_organization_id,
175: WIP_CONSTANTS.CREATE_NS_JOB,
176: WIP_CONSTANTS.CREATE_EAM_JOB,
177: WIP_CONSTANTS.RESCHED_EAM_JOB,
178: WIP_CONSTANTS.RESCHED_JOB) ;
179: if (l_wjsi_new_status_type IN (WIP_CONSTANTS.RELEASED,WIP_CONSTANTS.HOLD)) then
180: if((wip_osp.po_req_created( l_wdj_wip_entity_id,
181: null,
182: l_wdj_organization_id,
183: null,
180: if((wip_osp.po_req_created( l_wdj_wip_entity_id,
181: null,
182: l_wdj_organization_id,
183: null,
184: WIP_CONSTANTS.DISCRETE
185: ) = FALSE) or l_wdj_old_status_type in (WIP_CONSTANTS.UNRELEASED)) then
186: wip_osp.release_validation(l_wdj_wip_entity_id,
187: l_wdj_organization_id,
188: NULL) ;
181: null,
182: l_wdj_organization_id,
183: null,
184: WIP_CONSTANTS.DISCRETE
185: ) = FALSE) or l_wdj_old_status_type in (WIP_CONSTANTS.UNRELEASED)) then
186: wip_osp.release_validation(l_wdj_wip_entity_id,
187: l_wdj_organization_id,
188: NULL) ;
189: end if ;
195: wip_validateMLHeader_pvt.setInterfaceError(wjsi_rec.rowid,
196: wjsi_rec.interface_id,
197: x_errorMsg,
198: g_wipMLError);
199: if (l_logLevel <= wip_constants.trace_logging) then
200: wip_logger.log('interface ' || wjsi_rec.interface_id || ' failed: ' || x_errorMsg, l_retStatus);
201: end if;
202: end;
203: end loop;
202: end;
203: end loop;
204:
205: update wip_job_schedule_interface
206: set process_status = wip_constants.completed,
207: process_phase = wip_constants.ml_complete
208: where group_id = p_groupID
209: and process_status in (wip_constants.running, wip_constants.warning)
210: and process_phase = wip_constants.ml_validation
203: end loop;
204:
205: update wip_job_schedule_interface
206: set process_status = wip_constants.completed,
207: process_phase = wip_constants.ml_complete
208: where group_id = p_groupID
209: and process_status in (wip_constants.running, wip_constants.warning)
210: and process_phase = wip_constants.ml_validation
211: and load_type <> wip_constants.create_sched;
205: update wip_job_schedule_interface
206: set process_status = wip_constants.completed,
207: process_phase = wip_constants.ml_complete
208: where group_id = p_groupID
209: and process_status in (wip_constants.running, wip_constants.warning)
210: and process_phase = wip_constants.ml_validation
211: and load_type <> wip_constants.create_sched;
212:
213: if (p_commitFlag <> 0) then
206: set process_status = wip_constants.completed,
207: process_phase = wip_constants.ml_complete
208: where group_id = p_groupID
209: and process_status in (wip_constants.running, wip_constants.warning)
210: and process_phase = wip_constants.ml_validation
211: and load_type <> wip_constants.create_sched;
212:
213: if (p_commitFlag <> 0) then
214: commit;
207: process_phase = wip_constants.ml_complete
208: where group_id = p_groupID
209: and process_status in (wip_constants.running, wip_constants.warning)
210: and process_phase = wip_constants.ml_validation
211: and load_type <> wip_constants.create_sched;
212:
213: if (p_commitFlag <> 0) then
214: commit;
215: end if;
216:
217: select count(*) into l_errRecCount
218: from wip_job_schedule_interface
219: where group_id = p_groupID
220: and process_status = wip_constants.error;
221:
222: if(l_errRecCount > 0) then
223: x_returnStatus := fnd_api.g_ret_sts_error;
224: else
224: else
225: x_returnStatus := fnd_api.g_ret_sts_success;
226: end if;
227:
228: if (l_logLevel <= wip_constants.trace_logging) then
229: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
230: p_procReturnStatus => x_returnStatus,
231: p_msg => 'success',
232: x_returnStatus => l_retStatus);
231: p_msg => 'success',
232: x_returnStatus => l_retStatus);
233: end if;
234: exception
235: when wip_constants.records_locked then
236: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
237: if (l_logLevel <= wip_constants.trace_logging) then
238: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
239: p_procReturnStatus => x_returnStatus,
233: end if;
234: exception
235: when wip_constants.records_locked then
236: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
237: if (l_logLevel <= wip_constants.trace_logging) then
238: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
239: p_procReturnStatus => x_returnStatus,
240: p_msg => 'records locked',
241: x_returnStatus => l_retStatus);
243: fnd_message.set_name('WIP', 'WIP_LOCKED_ROW_ALREADY_LOCKED');
244: x_errorMsg := fnd_message.get;
245: when fnd_api.g_exc_unexpected_error then
246: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
247: if (l_logLevel <= wip_constants.trace_logging) then
248: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
249: p_procReturnStatus => x_returnStatus,
250: p_msg => x_errorMsg,
251: x_returnStatus => l_retStatus);
277: where interface_id = p_interfaceID
278: for update nowait;
279: begin
280: x_returnStatus := fnd_api.g_ret_sts_success;
281: if (l_logLevel <= wip_constants.trace_logging) then
282: l_params(1).paramName := 'p_interfaceID';
283: l_params(1).paramValue := p_interfaceID;
284: l_params(2).paramName := 'p_validationLevel';
285: l_params(2).paramValue := p_validationLevel;
299: select count(*)
300: into l_totalNum
301: from wip_job_schedule_interface
302: where interface_id = p_interfaceID
303: and process_status = wip_constants.pending
304: and process_phase = wip_constants.ml_validation
305: and load_type in (wip_constants.create_job, wip_constants.create_ns_job);
306:
307: if ( l_totalNum <> 1 ) then
300: into l_totalNum
301: from wip_job_schedule_interface
302: where interface_id = p_interfaceID
303: and process_status = wip_constants.pending
304: and process_phase = wip_constants.ml_validation
305: and load_type in (wip_constants.create_job, wip_constants.create_ns_job);
306:
307: if ( l_totalNum <> 1 ) then
308: fnd_message.set_name('WIP', 'WIP_WJSI_ONE_ROW');
301: from wip_job_schedule_interface
302: where interface_id = p_interfaceID
303: and process_status = wip_constants.pending
304: and process_phase = wip_constants.ml_validation
305: and load_type in (wip_constants.create_job, wip_constants.create_ns_job);
306:
307: if ( l_totalNum <> 1 ) then
308: fnd_message.set_name('WIP', 'WIP_WJSI_ONE_ROW');
309: x_errorMsg := fnd_message.get;
327: close c_allrows;
328: end if;
329:
330: update wip_job_schedule_interface
331: set process_status = wip_constants.running
332: where interface_id = p_interfaceID;
333:
334: -- do the validation for those records
335: wip_validateMLHeader_pvt.validateMLHeader(p_groupID => l_groupID,
343: select count(*)
344: into l_totalNum
345: from wip_job_schedule_interface
346: where interface_id = p_interfaceID
347: and process_status in (wip_constants.running, wip_constants.warning);
348:
349: if ( l_totalNum <> 1 ) then
350: fnd_message.set_name('WIP', 'WIP_WJSI_VAL_FAILED');
351: x_errorMsg := fnd_message.get;
362: from wip_job_schedule_interface wjsi,
363: wip_job_dtls_interface wjdi
364: where wjdi.parent_header_id = wjsi.header_id
365: and wjdi.group_id = wjsi.group_id
366: and wjdi.process_phase = wip_constants.ml_validation
367: and wjdi.process_status = wip_constants.pending
368: and wjsi.rowid = l_rowid;
369:
370: if (l_logLevel <= wip_constants.trace_logging) then
363: wip_job_dtls_interface wjdi
364: where wjdi.parent_header_id = wjsi.header_id
365: and wjdi.group_id = wjsi.group_id
366: and wjdi.process_phase = wip_constants.ml_validation
367: and wjdi.process_status = wip_constants.pending
368: and wjsi.rowid = l_rowid;
369:
370: if (l_logLevel <= wip_constants.trace_logging) then
371: wip_logger.log('There are ' || l_totalNum || ' detail records....', l_retStatus);
366: and wjdi.process_phase = wip_constants.ml_validation
367: and wjdi.process_status = wip_constants.pending
368: and wjsi.rowid = l_rowid;
369:
370: if (l_logLevel <= wip_constants.trace_logging) then
371: wip_logger.log('There are ' || l_totalNum || ' detail records....', l_retStatus);
372: end if;
373:
374: if ( l_totalNum > 0 ) then
398: from wip_job_schedule_interface
399: where rowid = l_rowid;
400:
401: update wip_job_schedule_interface
402: set process_status = wip_constants.completed
403: where rowid = l_rowid;
404:
405: if (l_logLevel <= wip_constants.trace_logging) then
406: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
401: update wip_job_schedule_interface
402: set process_status = wip_constants.completed
403: where rowid = l_rowid;
404:
405: if (l_logLevel <= wip_constants.trace_logging) then
406: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
407: p_procReturnStatus => x_returnStatus,
408: p_msg => 'success',
409: x_returnStatus => l_retStatus);
408: p_msg => 'success',
409: x_returnStatus => l_retStatus);
410: end if;
411: exception
412: when wip_constants.records_locked then
413: x_returnStatus := fnd_api.g_ret_sts_unexp_error;
414: fnd_message.set_name('WIP', 'WIP_LOCKED_ROW_ALREADY_LOCKED');
415: x_errorMsg := fnd_message.get;
416: wip_validateMLHeader_pvt.setInterfaceError(l_rowid,
416: wip_validateMLHeader_pvt.setInterfaceError(l_rowid,
417: p_interfaceID,
418: x_errorMsg,
419: g_wipMLError);
420: if (l_logLevel <= wip_constants.trace_logging) then
421: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
422: p_procReturnStatus => x_returnStatus,
423: p_msg => 'records locked',
424: x_returnStatus => l_retStatus);
428: wip_validateMLHeader_pvt.setInterfaceError(l_rowid,
429: p_interfaceID,
430: x_errorMsg,
431: g_wipMLError);
432: if (l_logLevel <= wip_constants.trace_logging) then
433: wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
434: p_procReturnStatus => x_returnStatus,
435: p_msg => x_errorMsg,
436: x_returnStatus => l_retStatus);
477: l_orgID
478: from wip_job_schedule_interface
479: where rowid = p_rowid;
480:
481: if ( l_wjsiSerOp is null and l_loadType = wip_constants.resched_job ) then
482: -- due to re-exploding, we may need to clear out the serialization start op
483: update wip_discrete_jobs wdj
484: set serialization_start_op = null
485: where wip_entity_id = l_wipEntityID
511: mtl_system_items msi
512: where wdj.primary_item_id = msi.inventory_item_id
513: and wdj.organization_id = msi.organization_id
514: and wdj.wip_entity_id = l_wipEntityID
515: and msi.serial_number_control_code = wip_constants.full_sn;
516:
517: open c_ops(l_wipEntityID);
518: loop
519: fetch c_ops into l_curOpSeq;
536: raise fnd_api.g_exc_unexpected_error;
537: end if;
538:
539: --job must be unreleased to change the serialization op on a reschedule request.
540: if ( l_loadType = wip_constants.resched_job and l_wjsiSerOp is not null ) then
541: select 1
542: into l_dummy
543: from wip_discrete_jobs
544: where wip_entity_id = l_wipEntityID
541: select 1
542: into l_dummy
543: from wip_discrete_jobs
544: where wip_entity_id = l_wipEntityID
545: and status_type = wip_constants.unreleased;
546: end if;
547:
548: l_msg := 'WIP_ML_SER_DEF_FAILURE';
549: wip_job_dtls_substitutions.default_serial_associations(p_rowid => p_rowid,