[Home] [Help]
PACKAGE BODY: APPS.EAM_OP_COMP_VALIDATE_PVT
Source
1 PACKAGE BODY EAM_OP_COMP_VALIDATE_PVT AS
2 /* $Header: EAMVOCVB.pls 120.4 2006/08/22 10:16:20 sdandapa noship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVOCVB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package EAM_OP_COMP_VALIDATE_PVT
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 14-FEB-2005 mmaduska Initial Creation
21 ***************************************************************************/
22
23
24 PROCEDURE Check_Required
25 (
26 p_eam_op_comp_rec IN EAM_PROCESS_WO_PUB.eam_op_comp_rec_type
27 , x_return_status OUT NOCOPY VARCHAR2
28 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
29 )IS
30
31 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
32 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
33 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
34 l_shutdown_type varchar2(30);
35 BEGIN
36
37 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Operation Completeion Populate null columns'); END IF;
38
39 x_return_status := FND_API.G_RET_STS_SUCCESS;
40
41
42 IF p_eam_op_comp_rec.operation_seq_num IS NULL
43 THEN
44 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : operation_seq_num ...'); END IF;
45 l_token_tbl(1).token_name := 'WIP_ENTITY_ID';
46 l_token_tbl(1).token_value := p_eam_op_comp_rec.wip_entity_id;
47
48 l_out_mesg_token_tbl := l_mesg_token_tbl;
49 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
50 ( p_message_name => 'EAM_OPCL_OP_REQUIRED'
51 , p_token_tbl => l_Token_tbl
52 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
53 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
54 );
55 x_mesg_token_tbl := l_out_mesg_token_tbl;
56
57 x_return_status := FND_API.G_RET_STS_ERROR;
58
59 END IF;
60
61 IF p_eam_op_comp_rec.actual_start_date IS NULL
62 THEN
63 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : actual_start_date ...'); END IF;
64 l_token_tbl(1).token_name := 'OP_SEQ_NO';
65 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
66
67 l_out_mesg_token_tbl := l_mesg_token_tbl;
68 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
69 ( p_message_name => 'EAM_OPCL_ACTSTD_REQUIRED'
70 , p_token_tbl => l_Token_tbl
71 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
72 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
73 );
74 x_mesg_token_tbl := l_out_mesg_token_tbl;
75
76 x_return_status := FND_API.G_RET_STS_ERROR;
77
78 END IF;
79
80 IF p_eam_op_comp_rec.actual_end_date IS NULL
81 THEN
82 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : Actual end date ...'); END IF;
83 l_token_tbl(1).token_name := 'OP_SEQ_NO';
84 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
85
86 l_out_mesg_token_tbl := l_mesg_token_tbl;
87 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
88 ( p_message_name => 'EAM_OPCL_ACTEND_REQUIRED'
89 , p_token_tbl => l_Token_tbl
90 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
91 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
92 );
93 x_mesg_token_tbl := l_out_mesg_token_tbl;
94
95 x_return_status := FND_API.G_RET_STS_ERROR;
96
97 END IF;
98
99 IF p_eam_op_comp_rec.actual_duration IS NULL
100 THEN
101 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : Actual duration ...'); END IF;
102 l_token_tbl(1).token_name := 'OP_SEQ_NO';
103 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
104
105 l_out_mesg_token_tbl := l_mesg_token_tbl;
106 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
107 ( p_message_name => 'EAM_OPCL_ACTDUR_REQUIRED'
108 , p_token_tbl => l_Token_tbl
109 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
110 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
111 );
112 x_mesg_token_tbl := l_out_mesg_token_tbl;
113
114 x_return_status := FND_API.G_RET_STS_ERROR;
115
116 END IF;
117
118
119 IF p_eam_op_comp_rec.transaction_type IS NULL
120 THEN
121 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : transaction_type ...'); END IF;
122 l_token_tbl(1).token_name := 'OP_SEQ_NO';
123 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
124
125 l_out_mesg_token_tbl := l_mesg_token_tbl;
126 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
127 ( p_message_name => 'EAM_OPCL_TRANX_REQUIRED'
128 , p_token_tbl => l_Token_tbl
129 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
130 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
131 );
132 x_mesg_token_tbl := l_out_mesg_token_tbl;
133
134 x_return_status := FND_API.G_RET_STS_ERROR;
135
136 END IF;
137
138 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE
139 THEN
140 SELECT shutdown_type into l_shutdown_type
141 FROM wip_discrete_jobs
142 WHERE wip_entity_id = p_eam_op_comp_rec.wip_entity_id;
143
144 IF l_shutdown_type IS NOT NULL THEN
145 IF p_eam_op_comp_rec.shutdown_start_date IS NULL OR p_eam_op_comp_rec.shutdown_end_date IS NULL THEN
146 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Op Comp : shutdown information ...'); END IF;
147
148 l_token_tbl(1).token_name := 'OP_SEQ_NO';
149 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
150
151 l_out_mesg_token_tbl := l_mesg_token_tbl;
152 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
153 ( p_message_name => 'EAM_OPCL_SHUTDOWN_REQUIRED'
154 , p_token_tbl => l_Token_tbl
155 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
156 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
157 );
158 x_mesg_token_tbl := l_out_mesg_token_tbl;
159
160 x_return_status := FND_API.G_RET_STS_ERROR;
161 END IF;
162 END IF;
163 END IF;
164
165 END Check_Required;
166
167
168
169 PROCEDURE Check_Attributes
170 (
171 p_eam_op_comp_rec IN EAM_PROCESS_WO_PUB. eam_op_comp_rec_type
172 , x_return_status OUT NOCOPY VARCHAR2
173 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
174 )IS
175 l_err_text VARCHAR2(2000) := NULL;
176 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
177 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
178 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
179 l_open_acct_per_date DATE;
180 l_reconciliation_code VARCHAR2(30);
181 l_prev_uncomplete NUMBER := 0;
182 l_prev_completed_after NUMBER := 0;
183 l_job_status NUMBER;
184 l_max_prior_end_date DATE;
185 l_shutdown_type VARCHAR2(30);
186
187 CURSOR CON IS
188 select count(won.prior_operation)
189 from wip_operation_networks won
190 where
191 won.wip_entity_id = p_eam_op_comp_rec.wip_entity_id and
192 won.next_operation = p_eam_op_comp_rec.operation_seq_num and
193 exists (
194 select 1 from wip_operations
195 where
196 wip_entity_id = p_eam_op_comp_rec.wip_entity_id and
197 operation_seq_num = won.prior_operation and
198 nvl(operation_completed,'N') <> 'Y'
199 );
200
201 CURSOR CON1 IS
202 select count(won.next_operation)
203 from wip_operation_networks won
204 where
205 won.wip_entity_id = p_eam_op_comp_rec.wip_entity_id and
206 won.prior_operation = p_eam_op_comp_rec.operation_seq_num and
207 exists (
208 select 1 from wip_operations
209 where
210 wip_entity_id = p_eam_op_comp_rec.wip_entity_id and
211 operation_seq_num = won.next_operation and
212 operation_completed = 'Y'
213 );
214
215 --added for fix to bug 3543834:
216 CURSOR CON3 IS
217 select nvl(max(actual_end_date),sysdate-20000)
218 from eam_op_completion_txns eoct,wip_operation_networks won
219 where eoct.wip_entity_id = p_eam_op_comp_rec.wip_entity_id
220 and eoct.operation_seq_num=won.prior_operation
221 and won.wip_entity_id=eoct.wip_entity_id
222 and won.next_operation=p_eam_op_comp_rec.operation_seq_num
223 and transaction_type=1
224 and transaction_id = (select max(transaction_id)
225 from eam_op_completion_txns
226 where wip_entity_id = p_eam_op_comp_rec.wip_entity_id
227 and operation_seq_num = eoct.operation_seq_num
228 );
229
230 BEGIN
231
232 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Operation Completeion Check Attributes'); END IF;
233
234 x_return_status := FND_API.G_RET_STS_SUCCESS;
235
236 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking actual start and end date ...'); END IF;
237 BEGIN
238 IF p_eam_op_comp_rec.actual_start_date > p_eam_op_comp_rec.actual_end_date THEN
239 raise fnd_api.g_exc_unexpected_error;
240 END IF;
241
242 x_return_status := FND_API.G_RET_STS_SUCCESS;
243
244 EXCEPTION
245 WHEN OTHERS THEN
246 l_token_tbl(1).token_name := 'OP_SEQ_NO';
247 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
248
249 l_out_mesg_token_tbl := l_mesg_token_tbl;
250 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
251 ( p_message_name => 'EAM_OPCMPL_DATE_BAD'
252 , p_token_tbl => l_token_tbl
253 , p_mesg_token_tbl => l_mesg_token_tbl
254 , x_mesg_token_tbl => l_out_mesg_token_tbl
255 );
256 l_mesg_token_tbl := l_out_mesg_token_tbl;
257
258 x_return_status := FND_API.G_RET_STS_ERROR;
259 x_mesg_token_tbl := l_mesg_token_tbl ;
260 RETURN;
261 END;
262
263 BEGIN
264 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking shutdown start and end date ...'); END IF;
265 IF p_eam_op_comp_rec.shutdown_start_date > p_eam_op_comp_rec.shutdown_end_date THEN
266 raise fnd_api.g_exc_unexpected_error;
267 END IF;
268
269 x_return_status := FND_API.G_RET_STS_SUCCESS;
270
271 EXCEPTION
272 WHEN OTHERS THEN
273 l_token_tbl(1).token_name := 'OP_SEQ_NO';
274 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
275
276 l_out_mesg_token_tbl := l_mesg_token_tbl;
277 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
278 ( p_message_name => 'EAM_OP_SHUTDOWN_DATE_BAD'
279 , p_token_tbl => l_token_tbl
280 , p_mesg_token_tbl => l_mesg_token_tbl
281 , x_mesg_token_tbl => l_out_mesg_token_tbl
282 );
283 l_mesg_token_tbl := l_out_mesg_token_tbl;
284
285 x_return_status := FND_API.G_RET_STS_ERROR;
286 x_mesg_token_tbl := l_mesg_token_tbl ;
287 RETURN;
288 END;
289
290 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking actual duration ...'); END IF;
291 BEGIN
292 IF p_eam_op_comp_rec.actual_duration < 0 THEN
293 raise fnd_api.g_exc_unexpected_error;
294 END IF;
295
299 WHEN OTHERS THEN
296 x_return_status := FND_API.G_RET_STS_SUCCESS;
297
298 EXCEPTION
300 l_token_tbl(1).token_name := 'OP_SEQ_NO';
301 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
302
303 l_out_mesg_token_tbl := l_mesg_token_tbl;
304 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
305 ( p_message_name => 'EAM_OP_COMP_DURATION_BAD'
306 , p_token_tbl => l_token_tbl
307 , p_mesg_token_tbl => l_mesg_token_tbl
308 , x_mesg_token_tbl => l_out_mesg_token_tbl
309 );
310 l_mesg_token_tbl := l_out_mesg_token_tbl;
311
312 x_return_status := FND_API.G_RET_STS_ERROR;
313 x_mesg_token_tbl := l_mesg_token_tbl ;
314 RETURN;
315 END;
316
317 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking actual end date ...'); END IF;
318 BEGIN
319 IF p_eam_op_comp_rec.actual_end_date > sysdate THEN
320 raise fnd_api.g_exc_unexpected_error;
321 END IF;
322
323 x_return_status := FND_API.G_RET_STS_SUCCESS;
324
325 EXCEPTION
326 WHEN OTHERS THEN
327
328 l_token_tbl(1).token_name := 'OP_SEQ_NO';
329 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
330
331 l_out_mesg_token_tbl := l_mesg_token_tbl;
332 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
333 ( p_message_name => 'EAM_OP_END_LATER_THAN_TODAY'
334 , p_token_tbl => l_token_tbl
335 , p_mesg_token_tbl => l_mesg_token_tbl
336 , x_mesg_token_tbl => l_out_mesg_token_tbl
337 );
338 l_mesg_token_tbl := l_out_mesg_token_tbl;
339
340 x_return_status := FND_API.G_RET_STS_ERROR;
341 x_mesg_token_tbl := l_mesg_token_tbl ;
342 RETURN;
343 END;
344
345 --also added following code as part of bug 5476770
346 BEGIN
347 IF p_eam_op_comp_rec.shutdown_end_date > sysdate THEN
348 raise fnd_api.g_exc_unexpected_error;
349 END IF;
350
351 x_return_status := FND_API.G_RET_STS_SUCCESS;
352
353 EXCEPTION
354 WHEN OTHERS THEN
355
356 l_token_tbl(1).token_name := 'OP_SEQ_NO';
357 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
358
359 l_out_mesg_token_tbl := l_mesg_token_tbl;
360 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
361 ( p_message_name => 'EAM_SHUTDOWN_DATE_IN_FUTURE'
362 , p_token_tbl => l_token_tbl
363 , p_mesg_token_tbl => l_mesg_token_tbl
364 , x_mesg_token_tbl => l_out_mesg_token_tbl
365 );
366 l_mesg_token_tbl := l_out_mesg_token_tbl;
367
368 x_return_status := FND_API.G_RET_STS_ERROR;
369 x_mesg_token_tbl := l_mesg_token_tbl ;
370 RETURN;
371 END;
372
373 --end of code as part of bug 5476770
374
375
376 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking open period ...'); END IF;
377 BEGIN
378 SELECT NVL(MIN(period_start_date), sysdate+1)
379 INTO l_open_acct_per_date
380 FROM org_acct_periods
381 WHERE organization_id = (select organization_id from wip_discrete_jobs where wip_entity_id = p_eam_op_comp_rec.wip_entity_id)
382 AND open_flag = 'Y';
383
384 IF sysdate < l_open_acct_per_date THEN -- p_transaction_date < l_open_acct_per_date
385 raise fnd_api.g_exc_unexpected_error;
386 END IF;
387
388 x_return_status := FND_API.G_RET_STS_SUCCESS;
389
390 EXCEPTION
391 WHEN OTHERS THEN
392
393 l_token_tbl(1).token_name := 'OP_SEQ_NO';
394 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
395
396 l_out_mesg_token_tbl := l_mesg_token_tbl;
397 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
398 ( p_message_name => 'EAM_OP_TRANSACTION_DATE_INVALID'
399 , p_token_tbl => l_token_tbl
400 , p_mesg_token_tbl => l_mesg_token_tbl
401 , x_mesg_token_tbl => l_out_mesg_token_tbl
402 );
403 l_mesg_token_tbl := l_out_mesg_token_tbl;
404
405 x_return_status := FND_API.G_RET_STS_ERROR;
406 x_mesg_token_tbl := l_mesg_token_tbl ;
407 RETURN;
408 END;
409
410 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking reconciliation code ...'); END IF;
411 BEGIN
412 IF p_eam_op_comp_rec.reconciliation_code IS NOT NULL THEN
413
414 SELECT ml.lookup_code
415 INTO l_reconciliation_code
416 FROM mfg_lookups ml -- Fix for Bug 3509465
417 WHERE ml.lookup_type = 'WIP_EAM_RECONCILIATION_CODE'
418 AND ml.lookup_code = p_eam_op_comp_rec.reconciliation_code;
419
420 END IF;
421
422 x_return_status := FND_API.G_RET_STS_SUCCESS;
423
424 EXCEPTION
425 WHEN NO_DATA_FOUND THEN
426
427 l_token_tbl(1).token_name := 'OP_SEQ_NO';
428 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
429
430 l_out_mesg_token_tbl := l_mesg_token_tbl;
431 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
432 ( p_message_name => 'EAM_OP_RECONCILIATION_CODE'
433 , p_token_tbl => l_token_tbl
434 , p_mesg_token_tbl => l_mesg_token_tbl
435 , x_mesg_token_tbl => l_out_mesg_token_tbl
436 );
437 l_mesg_token_tbl := l_out_mesg_token_tbl;
438
439 x_return_status := FND_API.G_RET_STS_ERROR;
440 x_mesg_token_tbl := l_mesg_token_tbl ;
441 RETURN;
442 END;
443
444
448 INTO l_shutdown_type
445 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE THEN
446 BEGIN
447 SELECT shutdown_type
449 FROM wip_operations
450 WHERE wip_entity_id = p_eam_op_comp_rec.wip_entity_id
451 AND operation_seq_num = p_eam_op_comp_rec.operation_seq_num;
452
453 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking shutdown start and end date ...'); END IF;
454
455 IF l_shutdown_type IS NOT NULL AND to_number(l_shutdown_type) = 2 THEN
456 IF p_eam_op_comp_rec.shutdown_start_date IS NULL OR p_eam_op_comp_rec.shutdown_end_date IS NULL THEN
457 raise fnd_api.g_exc_unexpected_error;
458 END IF;
459 END IF;
460
461 x_return_status := FND_API.G_RET_STS_SUCCESS;
462
463 EXCEPTION
464 WHEN NO_DATA_FOUND THEN
465
466 l_token_tbl(1).token_name := 'OP_SEQ_NO';
467 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
468
469 l_out_mesg_token_tbl := l_mesg_token_tbl;
470 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
471 ( p_message_name => 'EAM_OP_SHUTDOWN_DATE_MISS'
472 , p_token_tbl => l_token_tbl
473 , p_mesg_token_tbl => l_mesg_token_tbl
474 , x_mesg_token_tbl => l_out_mesg_token_tbl
475 );
476 l_mesg_token_tbl := l_out_mesg_token_tbl;
477
478 x_return_status := FND_API.G_RET_STS_ERROR;
479 x_mesg_token_tbl := l_mesg_token_tbl ;
480 RETURN;
481 END;
482 END IF;
483
484 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UNCOMPLETE THEN
485 BEGIN
486 open CON1;
487 fetch CON1 into l_prev_uncomplete;
488 if (CON1%NOTFOUND) then
489 l_prev_uncomplete := 0;
490 end if;
491 close CON1;
492
493 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking prev_uncomplete ...'); END IF;
494 IF l_prev_uncomplete > 0 THEN
495 raise fnd_api.g_exc_unexpected_error;
496 END IF;
497
498 x_return_status := FND_API.G_RET_STS_SUCCESS;
499
500 EXCEPTION
501 WHEN OTHERS THEN
502
503 --following 2 lines removed as part of bug 5440339
504 --l_token_tbl(1).token_name := 'OP_SEQ_NO';
505 --l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
506
507 l_out_mesg_token_tbl := l_mesg_token_tbl;
508 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
509 ( p_message_name => 'EAM_NEXT_OP_COMPLETED'
510 , p_token_tbl => l_token_tbl
511 , p_mesg_token_tbl => l_mesg_token_tbl
512 , x_mesg_token_tbl => l_out_mesg_token_tbl
513 );
514 l_mesg_token_tbl := l_out_mesg_token_tbl;
515
516 x_return_status := FND_API.G_RET_STS_ERROR;
517 x_mesg_token_tbl := l_mesg_token_tbl ;
518 RETURN;
519 END;
520 END IF;
521
522 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE THEN
523 BEGIN
524 open CON;
525 fetch CON into l_prev_uncomplete;
526 if (CON%NOTFOUND) then
527 l_prev_uncomplete := 0;
528 end if;
529 close CON;
530 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking prev_uncomplete ...'); END IF;
531
532 IF l_prev_uncomplete > 0 THEN
533 raise fnd_api.g_exc_unexpected_error;
534 END IF;
535
536 x_return_status := FND_API.G_RET_STS_SUCCESS;
537
538 EXCEPTION
539 WHEN OTHERS THEN
540
541 --following 2 lines removed as part of bug 5440339
542 --l_token_tbl(1).token_name := 'OP_SEQ_NO';
543 --l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
544
545 l_out_mesg_token_tbl := l_mesg_token_tbl;
546 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
547 ( p_message_name => 'EAM_PREV_OP_NOT_COMPLETED'
548 , p_token_tbl => l_token_tbl
549 , p_mesg_token_tbl => l_mesg_token_tbl
550 , x_mesg_token_tbl => l_out_mesg_token_tbl
551 );
552 l_mesg_token_tbl := l_out_mesg_token_tbl;
553
554 x_return_status := FND_API.G_RET_STS_ERROR;
555 x_mesg_token_tbl := l_mesg_token_tbl ;
556 RETURN;
557 END;
558 END IF;
559
560 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UNCOMPLETE THEN
561 begin
562 SELECT status_type
563 INTO l_job_status
564 FROM wip_discrete_jobs
565 WHERE wip_entity_id = p_eam_op_comp_rec.wip_entity_id;
566 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking status_type ...'); END IF;
567
568 IF (l_job_status = 4 ) THEN
569 raise fnd_api.g_exc_unexpected_error;
570 END IF;
571
572 x_return_status := FND_API.G_RET_STS_SUCCESS;
573
574 EXCEPTION
575 WHEN OTHERS THEN
576
577 l_token_tbl(1).token_name := 'OP_SEQ_NO';
578 l_token_tbl(1).token_value := p_eam_op_comp_rec.operation_seq_num;
579
580 l_out_mesg_token_tbl := l_mesg_token_tbl;
581 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
582 ( p_message_name => 'EAM_OP_COMP_WOCOMP_TEST'
583 , p_token_tbl => l_token_tbl
584 , p_mesg_token_tbl => l_mesg_token_tbl
585 , x_mesg_token_tbl => l_out_mesg_token_tbl
586 );
587 l_mesg_token_tbl := l_out_mesg_token_tbl;
588
589 x_return_status := FND_API.G_RET_STS_ERROR;
590 x_mesg_token_tbl := l_mesg_token_tbl ;
591 RETURN;
592 END;
593 END IF;
594
598 fetch CON3 into l_max_prior_end_date;
595 IF p_eam_op_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE THEN
596 BEGIN
597 open CON3;
599 close CON3;
600 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Checking actual start date and max_prior_end_date ...'); END IF;
601
602 if(p_eam_op_comp_rec.actual_start_date < l_max_prior_end_date) then
603 raise fnd_api.g_exc_unexpected_error;
604 end if;
605
606 x_return_status := FND_API.G_RET_STS_SUCCESS;
607
608 EXCEPTION
609 WHEN OTHERS THEN
610 l_token_tbl(1).token_name := 'MIN_START_DATE';
611 l_token_tbl(1).token_value := TO_CHAR(l_max_prior_end_date,'dd-MON-yyyy HH24:MI:SS');
612
613 l_out_mesg_token_tbl := l_mesg_token_tbl;
614 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
615 ( p_message_name => 'EAM_PRIOR_OP_COMPLETED_AFTER'
616 , p_token_tbl => l_token_tbl
617 , p_mesg_token_tbl => l_mesg_token_tbl
618 , x_mesg_token_tbl => l_out_mesg_token_tbl
619 );
620 l_mesg_token_tbl := l_out_mesg_token_tbl;
621
622 x_return_status := FND_API.G_RET_STS_ERROR;
623 x_mesg_token_tbl := l_mesg_token_tbl ;
624 RETURN;
625 END;
626 END IF;
627
628 END Check_Attributes;
629
630 END EAM_OP_COMP_VALIDATE_PVT;