[Home] [Help]
PACKAGE BODY: APPS.EAM_WO_COMP_VALIDATE_PVT
Source
1 PACKAGE BODY EAM_WO_COMP_VALIDATE_PVT AS
2 /* $Header: EAMVWCVB.pls 120.10 2006/11/14 22:59:37 brmanesh noship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVWCVB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package EAM_WO_COMP_VALIDATE_PVT
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 14-FEB-2005 mmaduska Initial Creation
21 ***************************************************************************/
22 PROCEDURE Check_Required
23 (
24 p_eam_wo_comp_rec IN EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type
25 , x_return_status OUT NOCOPY VARCHAR2
26 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
27 )
28 IS
29 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
30 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
31 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
32 l_shutdown_type VARCHAR2(30);
33 l_wip_entity_name VARCHAR2(240);
34 l_status_type NUMBER;
35 BEGIN
36
37 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Work Order Completeion processing Check Required'); END IF;
38
39 x_return_status := FND_API.G_RET_STS_SUCCESS;
40
41 SELECT wip_entity_name
42 INTO l_wip_entity_name
43 FROM wip_entities
44 WHERE wip_entity_id = p_eam_wo_comp_rec.wip_entity_id;
45 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check Actual start date'); END IF;
46
47 SELECT status_type,shutdown_type
48 INTO l_status_type,l_shutdown_type
49 FROM wip_discrete_jobs
50 WHERE wip_entity_id = p_eam_wo_comp_rec.wip_entity_id;
51
52 IF p_eam_wo_comp_rec.actual_start_date IS NULL
53 THEN
54 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
55 l_token_tbl(1).token_value := l_wip_entity_name;
56
57 l_out_mesg_token_tbl := l_mesg_token_tbl;
58 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
59 ( p_message_name => 'EAM_WCMP_ACT_STDATE_REQ'
60 , p_token_tbl => l_Token_tbl
61 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
62 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
63 );
64 l_mesg_token_tbl := l_out_mesg_token_tbl;
65 x_mesg_token_tbl := l_mesg_token_tbl ;
66 x_return_status := FND_API.G_RET_STS_ERROR;
67 return;
68 END IF;
69
70 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check Actual end date'); END IF;
71 IF p_eam_wo_comp_rec.actual_end_date IS NULL
72 THEN
73 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
74 l_token_tbl(1).token_value := l_wip_entity_name;
75
76 l_out_mesg_token_tbl := l_mesg_token_tbl;
77 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
78 ( p_message_name => 'EAM_WCMP_ACT_ENDDATE_REQ'
79 , p_token_tbl => l_Token_tbl
80 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
81 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
82 );
83 l_mesg_token_tbl := l_out_mesg_token_tbl;
84 x_mesg_token_tbl := l_mesg_token_tbl ;
85 x_return_status := FND_API.G_RET_STS_ERROR;
86 return;
87 END IF;
88
89 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check Actual duration '); END IF;
90 IF p_eam_wo_comp_rec.actual_duration IS NULL
91 THEN
92 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
93 l_token_tbl(1).token_value := l_wip_entity_name;
94
95 l_out_mesg_token_tbl := l_mesg_token_tbl;
96 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
97 ( p_message_name => 'EAM_WCMP_ACT_DUR_REQ'
98 , p_token_tbl => l_Token_tbl
99 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
100 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
101 );
102 l_mesg_token_tbl := l_out_mesg_token_tbl;
103 x_mesg_token_tbl := l_mesg_token_tbl ;
104 x_return_status := FND_API.G_RET_STS_ERROR;
105 return;
106 END IF;
107
108 IF p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE
109 THEN
110
111 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check shutdown type '); END IF;
112 IF l_shutdown_type = 2 THEN -- Bug #5165813. Only Required shutdown_type needs to be validate
113 IF p_eam_wo_comp_rec.shutdown_start_date IS NULL OR p_eam_wo_comp_rec.shutdown_end_date IS NULL THEN
114
115 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
116 l_token_tbl(1).token_value := l_wip_entity_name;
117
118 l_out_mesg_token_tbl := l_mesg_token_tbl;
119 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
120 ( p_message_name => 'EAM_WCMPL_SHUTDOWN_DATE_MISS'
121 , p_token_tbl => l_Token_tbl
122 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
123 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
124 );
125 l_mesg_token_tbl := l_out_mesg_token_tbl;
126 x_mesg_token_tbl := l_mesg_token_tbl ;
127 x_return_status := FND_API.G_RET_STS_ERROR;
128 return;
129 END IF;
130 END IF;
131 END IF;
132
133 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check status type '); END IF;
134 IF (p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE AND l_status_type <> 3 )
135 OR
136 (
137 ( p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UNCOMPLETE)
138 AND
139 ( l_status_type not in (4 ,5))
140 )
141 THEN
142 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
143 l_token_tbl(1).token_value := l_wip_entity_name;
144 l_out_mesg_token_tbl := l_mesg_token_tbl;
145
146 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
147 ( p_message_name => 'EAM_WO_COMP_WRONG_STATUS'
148 , p_token_tbl => l_Token_tbl
149 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
150 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
151 );
152 l_mesg_token_tbl := l_out_mesg_token_tbl;
153 x_mesg_token_tbl := l_mesg_token_tbl ;
154 x_return_status := FND_API.G_RET_STS_ERROR;
155 return;
156 END IF;
157 END Check_Required;
158
159
160
161
162
163
164
165
166
167
168 PROCEDURE Check_Attributes
169 (
170 p_eam_wo_comp_rec IN EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type
171 , x_eam_wo_comp_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_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 )
175 IS
176 l_err_text VARCHAR2(2000) := NULL;
177 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
178 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
179 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
180 network_child_job_var VARCHAR2(2):='0';
181 sibling_parent_job_var VARCHAR2(2):='0';
182 l_reconciliation_code VARCHAR2(30);
183 l_manual_rebuild_flag VARCHAR2(1);
184 l_parent_wip_entity_id NUMBER;
185 l_parent_status_type NUMBER;
186 l_wip_entity_name VARCHAR2(240);
187 l_min_open_period DATE;
188 l_max_compl_op_date DATE;
189 l_min_compl_op_date DATE;
190 l_locator_id NUMBER;
191 l_completion_info NUMBER;
192 l_lot_ctrl_code NUMBER;
193 l_lot_number VARCHAR2(80);
194 l_rebuild_serial_number VARCHAR2(30);
195 l_serial_status NUMBER;
196 l_valid NUMBER := 0;
197 child_job_var VARCHAR2(2):='0';
198
199 p_subinv_ctrl NUMBER;
200 l_subinv VARCHAR2(80);
201 l_error_flag NUMBER;
202 l_error_mssg VARCHAR2(250);
203 l_locator_ctrl NUMBER ; -- Holds the Locator Control information
204 l_org_id NUMBER;
205 l_maintenance_object_type NUMBER;
206 l_count NUMBER;
207 l_serial_number VARCHAR2(30);
208
209 G_EXC_RET_MAT_INVALID_SUBINV EXCEPTION;
210 G_EXC_NOT_ENOUGH_VALUES EXCEPTION;
211 G_EXC_RET_MAT_INVALID_LOCATOR EXCEPTION;
212 G_EXC_RET_MAT_LOCATOR_NEEDED EXCEPTION;
213 G_EXC_RET_MAT_LOCATOR_RESTRIC EXCEPTION;
214 G_EXC_NO_LOT_NUMBER EXCEPTION;
215 G_EXC_LOT_NEEDED EXCEPTION;
216 G_EXC_LOT_NOT_NEEDED EXCEPTION;
217 G_EXC_LOCATOR_DEFAULT EXCEPTION;
218 l_inventory_item_id NUMBER;
219
220 CURSOR cur_work_order_details IS
221 SELECT cii.inventory_item_id
222 FROM wip_discrete_jobs wdj,csi_item_instances cii
223 WHERE wdj.wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
224 AND wdj.maintenance_object_type = 3
225 AND wdj.maintenance_object_id = cii.instance_id
226 UNION
227 SELECT wdj.maintenance_object_id
228 FROM wip_discrete_jobs wdj
229 WHERE wdj.wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
230 AND wdj.maintenance_object_type = 2;
231
232 BEGIN
233
234 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Work Order Completeion processing Check_Attributes'); END IF;
235
236 x_return_status := FND_API.G_RET_STS_SUCCESS;
237 x_eam_wo_comp_rec := p_eam_wo_comp_rec;
238 l_org_id := p_eam_wo_comp_rec.organization_id;
239
240 SELECT wip_entity_name
241 INTO l_wip_entity_name
242 FROM WIP_ENTITIES
243 WHERE wip_entity_id = p_eam_wo_comp_rec.wip_entity_id;
244
245 SELECT maintenance_object_type
246 INTO l_maintenance_object_type
247 FROM wip_discrete_jobs
248 WHERE wip_entity_id = p_eam_wo_comp_rec.wip_entity_id;
249
250 OPEN cur_work_order_details;
251 FETCH cur_work_order_details into l_inventory_item_id;
252 CLOSE cur_work_order_details;
253 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check shutdown start and end date'); END IF;
254
255 begin
256
257 IF p_eam_wo_comp_rec.actual_start_date > p_eam_wo_comp_rec.actual_end_date THEN
258 raise fnd_api.g_exc_unexpected_error;
259 END IF;
260
261 x_return_status := FND_API.G_RET_STS_SUCCESS;
262
263 exception
264 when others then
265
266 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
267 l_token_tbl(1).token_value := l_wip_entity_name;
268
269 l_out_mesg_token_tbl := l_mesg_token_tbl;
270 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
271 ( p_message_name => 'EAM_WC_SHUTDOWN_STAF_END'
272 , p_token_tbl => l_token_tbl
273 , p_mesg_token_tbl => l_mesg_token_tbl
274 , x_mesg_token_tbl => l_out_mesg_token_tbl
275 );
276 l_mesg_token_tbl := l_out_mesg_token_tbl;
277
278 x_return_status := FND_API.G_RET_STS_ERROR;
279 x_mesg_token_tbl := l_mesg_token_tbl ;
280 return;
281 end;
282
283 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check transaction date and open period'); END IF;
284 begin
285
286 SELECT NVL(MIN(period_start_date), sysdate+2)
287 INTO l_min_open_period
288 FROM org_acct_periods
289 WHERE organization_id = l_org_id
290 AND open_flag = 'Y';
291 /* Fix for bug no: 2695696 */
292 /*Fix for bug 3235163*/
293 --Previously the check was for actual_end date.It has been changed to p_transaction_date
294
295 IF (p_eam_wo_comp_rec.transaction_date < l_min_open_period) THEN
296 raise fnd_api.g_exc_unexpected_error;
297 END IF;
298 x_return_status := FND_API.G_RET_STS_SUCCESS;
299 exception
300 when others then
301
302 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
303 l_token_tbl(1).token_value := l_wip_entity_name;
304
305 l_out_mesg_token_tbl := l_mesg_token_tbl;
306 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
307 ( p_message_name => 'EAM_TRANSACTION_DATE_INVALID'
308 , p_token_tbl => l_token_tbl
309 , p_mesg_token_tbl => l_mesg_token_tbl
310 , x_mesg_token_tbl => l_out_mesg_token_tbl
311 );
312 l_mesg_token_tbl := l_out_mesg_token_tbl;
313
314 x_return_status := FND_API.G_RET_STS_ERROR;
315 x_mesg_token_tbl := l_mesg_token_tbl ;
316 return;
317
318 end;
319
320
321 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check shutdown start and end date'); END IF;
322 begin
323 IF p_eam_wo_comp_rec.shutdown_start_date > p_eam_wo_comp_rec.shutdown_end_date THEN
324 raise fnd_api.g_exc_unexpected_error;
325 END IF;
326
327 x_return_status := FND_API.G_RET_STS_SUCCESS;
328
329 exception
330 when others then
331
332 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
333 l_token_tbl(1).token_value := l_wip_entity_name;
334
335 l_out_mesg_token_tbl := l_mesg_token_tbl;
336 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
337 ( p_message_name => 'EAM_WC_SHUTDOWN_DATE_BAD'
338 , p_token_tbl => l_token_tbl
339 , p_mesg_token_tbl => l_mesg_token_tbl
340 , x_mesg_token_tbl => l_out_mesg_token_tbl
341 );
342 l_mesg_token_tbl := l_out_mesg_token_tbl;
343
344 x_return_status := FND_API.G_RET_STS_ERROR;
345 x_mesg_token_tbl := l_mesg_token_tbl ;
346 return;
347 end;
348
349
350
351 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check completion date'); END IF;
352 begin
353 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE then
354 begin
355
356 /* Fix for Bug 2100416 */
357 select nvl(max(actual_end_date), sysdate - 200000)
358 into l_max_compl_op_date
359 from eam_op_completion_txns eoct
360 where wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
361 --fix for 3543834.added where clause so that the last completion date will be fetched if the operation is complete
362 and transaction_type=1
363 and transaction_id = (select max(transaction_id)
364 from eam_op_completion_txns
365 where wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
366 and operation_seq_num = eoct.operation_seq_num
367 );
368 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Allowing for completed operations'); END IF;
369 /* Fix for bug no:2730242 */
370 select nvl(min(actual_start_date), sysdate + 200000)
371 into l_min_compl_op_date
372 from eam_op_completion_txns eoct
373 where wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
374 --fix for 3543834.added where clause so that the last completion date will be fetched if the operation is complete
375 and transaction_type=1
376 and transaction_id = (select max(transaction_id)
377 from eam_op_completion_txns
378 where wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
379 and operation_seq_num = eoct.operation_seq_num
380 );
381
382 -- mmaduska added for bug 3273898
383 -- mmaduska added and condition to solve the date time truncation problem
384
385 -- changed conditions for 3543834 so that actual_start_date and actual_end_date will be validated
386 if (
387 ((p_eam_wo_comp_rec.actual_end_date < l_max_compl_op_date) AND (l_max_compl_op_date - p_eam_wo_comp_rec.actual_end_date > (0.000011575 * 60 ))) OR
388 ((p_eam_wo_comp_rec.actual_start_date > l_min_compl_op_date) AND (p_eam_wo_comp_rec.actual_start_date - l_min_compl_op_date > (0.000011575 * 60 )))
389 )then
390 raise fnd_api.g_exc_unexpected_error;
391
392 end if;
393
394 -- if p_actual_start_date is close to l_min_compl_op_date by a min or p_actual_end_date is close to l_max_compl_op_date
395 if (p_eam_wo_comp_rec.actual_end_date < l_max_compl_op_date) then
396 x_eam_wo_comp_rec.actual_end_date := l_max_compl_op_date;
397 else
398 x_eam_wo_comp_rec.actual_end_date := p_eam_wo_comp_rec.actual_end_date;
399 end if;
400
401 if(p_eam_wo_comp_rec.actual_start_date > l_min_compl_op_date) then
402 x_eam_wo_comp_rec.actual_start_date := l_min_compl_op_date;
403 else
404 x_eam_wo_comp_rec.actual_start_date := p_eam_wo_comp_rec.actual_start_date;
405 end if;
406 exception
407 when others then
408
409 l_token_tbl(1).token_name := 'MIN_OP_DATE';
410 l_token_tbl(1).token_value := TO_CHAR(l_min_compl_op_date,'dd-MON-yyyy HH24:MI:SS');
411
412 l_token_tbl(2).token_name := 'MAX_OP_DATE';
413 l_token_tbl(2).token_value := TO_CHAR(l_max_compl_op_date,'dd-MON-yyyy HH24:MI:SS');
414
415
416 l_out_mesg_token_tbl := l_mesg_token_tbl;
417 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
418 ( p_message_name => 'EAM_WO_COMPL_DATES_INVALID'
419 , p_token_tbl => l_token_tbl
420 , p_mesg_token_tbl => l_mesg_token_tbl
421 , x_mesg_token_tbl => l_out_mesg_token_tbl
422 );
423 l_mesg_token_tbl := l_out_mesg_token_tbl;
424
425 x_return_status := FND_API.G_RET_STS_ERROR;
426 x_mesg_token_tbl := l_mesg_token_tbl ;
427 return;
428
429 end;
430 end if;
431 end;
432
433 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check duration'); END IF;
434 begin
435 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE then
436
437 begin
438 IF p_eam_wo_comp_rec.actual_duration < 0 THEN
439 raise fnd_api.g_exc_unexpected_error;
440 END IF;
441
442 x_return_status := FND_API.G_RET_STS_SUCCESS;
443
444 exception
445 when others then
446
447 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
448 l_token_tbl(1).token_value := l_wip_entity_name;
449
450 l_out_mesg_token_tbl := l_mesg_token_tbl;
451 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
452 ( p_message_name => 'EAM_WC_NEGATIVE_DURATION'
453 , p_token_tbl => l_token_tbl
454 , p_mesg_token_tbl => l_mesg_token_tbl
455 , x_mesg_token_tbl => l_out_mesg_token_tbl
456 );
457 l_mesg_token_tbl := l_out_mesg_token_tbl;
458
459 x_return_status := FND_API.G_RET_STS_ERROR;
460 x_mesg_token_tbl := l_mesg_token_tbl ;
461 return;
462 end;
463 end if;
464 end;
465
466 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check actual end date in future'); END IF;
467 begin
468 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE then
469 begin
470
471 IF p_eam_wo_comp_rec.actual_end_date > sysdate THEN
472 raise fnd_api.g_exc_unexpected_error;
473 END IF;
474
475 x_return_status := FND_API.G_RET_STS_SUCCESS;
476 exception
477 when others then
478
479 l_out_mesg_token_tbl := l_mesg_token_tbl;
480 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
481 ( p_message_name => 'EAM_END_LATER_THAN_TODAY'
482 , p_token_tbl => l_token_tbl
483 , p_mesg_token_tbl => l_mesg_token_tbl
484 , x_mesg_token_tbl => l_out_mesg_token_tbl
485 );
486 l_mesg_token_tbl := l_out_mesg_token_tbl;
487
488 x_return_status := FND_API.G_RET_STS_ERROR;
489 x_mesg_token_tbl := l_mesg_token_tbl ;
490 return;
491 end;
492 end if;
493 end;
494
495
496 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check subinventory and lot information '); END IF;
497 begin
498 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE and
499 p_eam_wo_comp_rec.completion_subinventory IS NOT NULL
500 then
501
502 begin
503 l_completion_info := 0;
504
505 IF l_maintenance_object_type = 2 THEN
506 SELECT count(*) into l_count
507 FROM wip_discrete_jobs wdj,
508 mtl_system_items_b msib
509 WHERE wdj.organization_id = msib.organization_id
510 AND wdj.maintenance_object_id = msib.inventory_item_id
511 AND wdj.organization_id = p_eam_wo_comp_rec.organization_id
512 AND wdj.wip_entity_id = p_eam_wo_comp_rec.wip_entity_id ;
513
514 IF l_count >0 THEN
515 l_completion_info := 1;
516 END IF;
517
518 END IF;
519 IF l_maintenance_object_type = 3 THEN
520
521 SELECT count(*) into l_count
522 FROM wip_discrete_jobs wdj,
523 csi_item_instances cii
524 WHERE wdj.organization_id = cii.last_vld_organization_id
525 AND wdj.maintenance_object_id = cii.instance_id
526 AND wdj.organization_id = p_eam_wo_comp_rec.organization_id
527 AND wdj.wip_entity_id = p_eam_wo_comp_rec.wip_entity_id ;
528
529
530 IF l_count > 0 THEN
531
532 SELECT cii.serial_number ,
533 msn.current_status
534 INTO l_serial_number ,
535 l_serial_status
536 FROM wip_discrete_jobs wdj,
537 csi_item_instances cii,
538 mtl_serial_numbers msn
539 WHERE wdj.wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
540 AND wdj.maintenance_object_type = 3
541 AND wdj.maintenance_object_id = cii.instance_id
542 AND cii.serial_number = msn.serial_number
543 AND cii.inventory_item_id = msn.inventory_item_id;
544
545 IF l_serial_status = 4 THEN
546 l_completion_info := 1;
547 END IF;
548
549
550 END IF;
551
552 END IF;
553
554 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check subinventory'); END IF;
555
556 IF l_completion_info = 1 THEN
557 SELECT lot_control_code into l_lot_ctrl_code
558 FROM mtl_system_items_b
559 WHERE inventory_item_id = l_inventory_item_id
560 AND organization_id = l_org_id ;
561
562 IF p_eam_wo_comp_rec.completion_subinventory IS NOT NULL THEN
563 Begin
564 select restrict_subinventories_code
565 into p_subinv_ctrl
566 from mtl_system_items_kfv
567 where organization_id = l_org_id
568 and inventory_item_id = l_inventory_item_id;
569
570 if(p_subinv_ctrl is null or p_subinv_ctrl <> 1) then
571 select secondary_inventory_name into l_subinv
572 from mtl_secondary_inventories
573 where
574 secondary_inventory_name = p_eam_wo_comp_rec.completion_subinventory
575 and organization_id = l_org_id
576 and nvl(disable_date,trunc(sysdate)+1)>trunc(sysdate)
577 and Asset_inventory = 2;
578 elsif(p_subinv_ctrl = 1) then
579 select secondary_inventory_name into l_subinv
580 from mtl_secondary_inventories
581 where
582 secondary_inventory_name = p_eam_wo_comp_rec.completion_subinventory
583 and organization_id = l_org_id
584 and nvl(disable_date,trunc(sysdate)+1)>trunc(sysdate)
585 and Asset_inventory = 2
586 and EXISTS (select secondary_inventory from mtl_item_sub_inventories
587 where secondary_inventory = secondary_inventory_name
588 and inventory_item_id = l_inventory_item_id
589 and organization_id = l_org_id);
590 end if;
591 exception
592 when no_data_found then
593 raise G_EXC_RET_MAT_INVALID_SUBINV;
594 end;
595 ELSE
596 -- raise G_EXC_NOT_ENOUGH_VALUES;
597 null;
598 END IF;
599 END IF; -- end of l_completion_info = 1
600
601 l_locator_id := p_eam_wo_comp_rec.completion_locator_id;
602
603 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check locator control code'); END IF;
604 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_MTL_TXN_PROCESS.Get_LocatorControl_Code'); END IF;
605 /* Check for Locator Control which could be defined
606 at 3 level Organization,Subinventory,Item .
607 */
608 EAM_MTL_TXN_PROCESS.Get_LocatorControl_Code(
609 l_org_id,
610 p_eam_wo_comp_rec.completion_subinventory,
611 l_inventory_item_id,
612 27,
613 l_locator_ctrl,
614 l_error_flag,
615 l_error_mssg);
616
617 if(l_error_flag <> 0) then
618 raise G_EXC_LOCATOR_DEFAULT;
619 end if;
620
621 -- if the locator control is Predefined or Dynamic Entry
622 if(l_locator_ctrl = 2 or l_locator_ctrl = 3) then
623 if(l_locator_id IS NULL) then
624 raise G_EXC_RET_MAT_LOCATOR_NEEDED;
625 end if;
626 elsif(l_locator_ctrl = 1) then -- If the locator control is NOControl
627 if(l_locator_id IS NOT NULL) then
628 raise G_EXC_RET_MAT_LOCATOR_RESTRIC;
629 end if;
630 end if; -- end of locator_control checkif
631
632 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check lot entry '); END IF;
633
634 /* CHECK for lot entry */
635 if(l_lot_ctrl_code = 2) then
636 if(p_eam_wo_comp_rec.lot_number is not null)then
637 begin
638 select
639 lot_number into l_lot_number
640 from
641 mtl_lot_numbers
642 where
643 inventory_item_id = l_inventory_item_id
644 and organization_id = l_org_id;
645 exception
646 when NO_DATA_FOUND then
647 raise G_EXC_NO_LOT_NUMBER;
648 end;
649 else
650 raise G_EXC_LOT_NEEDED;
651 end if;
652 else
653 if(p_eam_wo_comp_rec.lot_number is not null) then
654 raise G_EXC_LOT_NOT_NEEDED;
655 end if;
656 end if; -- end of lot entry check
657
658 exception
659 WHEN G_EXC_RET_MAT_INVALID_SUBINV THEN
660 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
661 l_token_tbl(1).token_value := l_wip_entity_name;
662
663 l_out_mesg_token_tbl := l_mesg_token_tbl;
664 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
665 ( p_message_name => 'EAM_WC_RET_MAT_INVALID_SUBINV'
666 , p_token_tbl => l_token_tbl
667 , p_mesg_token_tbl => l_mesg_token_tbl
668 , x_mesg_token_tbl => l_out_mesg_token_tbl
669 );
670 l_mesg_token_tbl := l_out_mesg_token_tbl;
671
672 x_return_status := FND_API.G_RET_STS_ERROR;
673 x_mesg_token_tbl := l_mesg_token_tbl ;
674 return;
675
676 WHEN G_EXC_NOT_ENOUGH_VALUES THEN
677 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
678 l_token_tbl(1).token_value := l_wip_entity_name;
679
680 l_out_mesg_token_tbl := l_mesg_token_tbl;
681 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
682 ( p_message_name => 'EAM_WC_NOT_ENOUGH_VALUES'
683 , p_token_tbl => l_token_tbl
684 , p_mesg_token_tbl => l_mesg_token_tbl
685 , x_mesg_token_tbl => l_out_mesg_token_tbl
686 );
687 l_mesg_token_tbl := l_out_mesg_token_tbl;
688
689 x_return_status := FND_API.G_RET_STS_ERROR;
690 x_mesg_token_tbl := l_mesg_token_tbl ;
691 return;
692
693 WHEN G_EXC_LOCATOR_DEFAULT THEN
694 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
695 l_token_tbl(1).token_value := l_wip_entity_name;
696
697 l_out_mesg_token_tbl := l_mesg_token_tbl;
698 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
699 ( p_message_name => 'EAM_WC_LOCATOR_DEFAULT_ERR'
700 , p_token_tbl => l_token_tbl
701 , p_mesg_token_tbl => l_mesg_token_tbl
702 , x_mesg_token_tbl => l_out_mesg_token_tbl
703 );
704 l_mesg_token_tbl := l_out_mesg_token_tbl;
705
706 x_return_status := FND_API.G_RET_STS_ERROR;
707 x_mesg_token_tbl := l_mesg_token_tbl ;
708 return;
709 WHEN G_EXC_RET_MAT_LOCATOR_NEEDED THEN
710 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
711 l_token_tbl(1).token_value := l_wip_entity_name;
712
713 l_out_mesg_token_tbl := l_mesg_token_tbl;
714 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
715 ( p_message_name => 'EAM_WC_RET_MAT_LOCATOR_NEEDED'
716 , p_token_tbl => l_token_tbl
717 , p_mesg_token_tbl => l_mesg_token_tbl
718 , x_mesg_token_tbl => l_out_mesg_token_tbl
719 );
720 l_mesg_token_tbl := l_out_mesg_token_tbl;
721
722 x_return_status := FND_API.G_RET_STS_ERROR;
723 x_mesg_token_tbl := l_mesg_token_tbl ;
724 return;
725 WHEN G_EXC_RET_MAT_LOCATOR_RESTRIC THEN
726 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
727 l_token_tbl(1).token_value := l_wip_entity_name;
728
729 l_out_mesg_token_tbl := l_mesg_token_tbl;
730 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
731 ( p_message_name => 'EAM_WC_RET_MAT_LOCATOR_RESTRICTED'
732 , p_token_tbl => l_token_tbl
733 , p_mesg_token_tbl => l_mesg_token_tbl
734 , x_mesg_token_tbl => l_out_mesg_token_tbl
735 );
736 l_mesg_token_tbl := l_out_mesg_token_tbl;
737
738 x_return_status := FND_API.G_RET_STS_ERROR;
739 x_mesg_token_tbl := l_mesg_token_tbl ;
740 return;
741 WHEN G_EXC_NO_LOT_NUMBER THEN
742 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
743 l_token_tbl(1).token_value := l_wip_entity_name;
744
745 l_out_mesg_token_tbl := l_mesg_token_tbl;
746 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
747 ( p_message_name => 'EAM_WC_NO_LOT_NUMBER'
748 , p_token_tbl => l_token_tbl
749 , p_mesg_token_tbl => l_mesg_token_tbl
750 , x_mesg_token_tbl => l_out_mesg_token_tbl
751 );
752 l_mesg_token_tbl := l_out_mesg_token_tbl;
753
754 x_return_status := FND_API.G_RET_STS_ERROR;
755 x_mesg_token_tbl := l_mesg_token_tbl ;
756 return;
757 WHEN G_EXC_LOT_NEEDED THEN
758 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
759 l_token_tbl(1).token_value := l_wip_entity_name;
760
761 l_out_mesg_token_tbl := l_mesg_token_tbl;
762 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
763 ( p_message_name => 'EAM_WC_LOT_NEEDED'
764 , p_token_tbl => l_token_tbl
765 , p_mesg_token_tbl => l_mesg_token_tbl
766 , x_mesg_token_tbl => l_out_mesg_token_tbl
767 );
768 l_mesg_token_tbl := l_out_mesg_token_tbl;
769
770 x_return_status := FND_API.G_RET_STS_ERROR;
771 x_mesg_token_tbl := l_mesg_token_tbl ;
772 return;
773 WHEN G_EXC_LOT_NOT_NEEDED THEN
774 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
775 l_token_tbl(1).token_value := l_wip_entity_name;
776
777 l_out_mesg_token_tbl := l_mesg_token_tbl;
778 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
779 ( p_message_name => 'EAM_WC_LOT_NOT_NEEDED'
780 , p_token_tbl => l_token_tbl
781 , p_mesg_token_tbl => l_mesg_token_tbl
782 , x_mesg_token_tbl => l_out_mesg_token_tbl
783 );
784 l_mesg_token_tbl := l_out_mesg_token_tbl;
785
786 x_return_status := FND_API.G_RET_STS_ERROR;
787 x_mesg_token_tbl := l_mesg_token_tbl ;
788 return;
789 end;
790
791 end if;
792 end;
793
794 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check whether child job is complete'); END IF;
795 begin
796 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE then
797 begin
798 -- Replaced the above cursor loop and cursor with the following query.
799 -- for bug #2414513.
800 SELECT '1'
801 INTO child_job_var
802 FROM dual
803 WHERE EXISTS (SELECT '1'
804 FROM wip_discrete_jobs wdj, wip_entities we
805 WHERE wdj.wip_entity_id = we.wip_entity_id
806 AND wdj.parent_wip_entity_id = p_eam_wo_comp_rec.wip_entity_id
807 AND wdj.manual_rebuild_flag = 'Y'
808 AND wdj.status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
809 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED));
810
811 if (child_job_var = '1') then
812 raise fnd_api.g_exc_unexpected_error;
813 end if;
814 exception
815 WHEN NO_DATA_FOUND THEN
816 null;
817 WHEN OTHERS THEN
818 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
819 l_token_tbl(1).token_value := l_wip_entity_name;
820
821 l_out_mesg_token_tbl := l_mesg_token_tbl;
822 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
823 ( p_message_name => 'EAM_CHILD_JOB_NOT_COMPLETE'
824 , p_token_tbl => l_token_tbl
825 , p_mesg_token_tbl => l_mesg_token_tbl
826 , x_mesg_token_tbl => l_out_mesg_token_tbl
827 );
828 l_mesg_token_tbl := l_out_mesg_token_tbl;
829
830 x_return_status := FND_API.G_RET_STS_ERROR;
831 x_mesg_token_tbl := l_mesg_token_tbl ;
832 return;
833 end;
834 end if;
835 end;
836
837 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check reconciliation code'); END IF;
838 begin
839 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE and
840 p_eam_wo_comp_rec.reconciliation_code is not null then
841
842 begin
843 SELECT mlu.lookup_code
844 INTO l_reconciliation_code
845 FROM mfg_lookups mlu
846 WHERE mlu.lookup_type = 'WIP_EAM_RECONCILIATION_CODE'
847 AND mlu.lookup_code = p_eam_wo_comp_rec.reconciliation_code;
848
849 EXCEPTION WHEN OTHERS THEN
850 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
851 l_token_tbl(1).token_value := l_wip_entity_name;
852
853 l_out_mesg_token_tbl := l_mesg_token_tbl;
854 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
855 ( p_message_name => 'EAM_WC_RECONCILIATION_CODE_INV'
856 , p_token_tbl => l_token_tbl
857 , p_mesg_token_tbl => l_mesg_token_tbl
858 , x_mesg_token_tbl => l_out_mesg_token_tbl
859 );
860 l_mesg_token_tbl := l_out_mesg_token_tbl;
861
862 x_return_status := FND_API.G_RET_STS_ERROR;
863 x_mesg_token_tbl := l_mesg_token_tbl ;
864 return;
865 end;
866 end if;
867 end;
868
869 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check whether WO network child is complete ...'); END IF;
870 begin
871 if p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE then
872 begin
873 SELECT '1'
874 INTO network_child_job_var
875 FROM dual
876 WHERE EXISTS ( SELECT '1'
877 FROM wip_discrete_jobs
878 WHERE wip_entity_id IN
879 (
880 SELECT DISTINCT child_object_id
881 FROM eam_wo_relationships
882 WHERE parent_relationship_type =1
883 START WITH parent_object_id = p_eam_wo_comp_rec.wip_entity_id AND parent_relationship_type = 1
884 CONNECT BY parent_object_id = prior child_object_id AND parent_relationship_type = 1
885 )
886 AND status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
887 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED, WIP_CONSTANTS.CANCELLED )
888
889 );
890
891 if (network_child_job_var = '1') then --In the network Work Order has Uncompleted Child Work Orders
892 raise fnd_api.g_exc_unexpected_error;
893 end if;
894
895 exception
896 WHEN NO_DATA_FOUND THEN
897 null;
898 WHEN OTHERS THEN
899 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
900 l_token_tbl(1).token_value := l_wip_entity_name;
901
902 l_out_mesg_token_tbl := l_mesg_token_tbl;
903 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
904 ( p_message_name => 'EAM_NETWRK_CHILD_JOB_NOT_COMP'
905 , p_token_tbl => l_token_tbl
906 , p_mesg_token_tbl => l_mesg_token_tbl
907 , x_mesg_token_tbl => l_out_mesg_token_tbl
908 );
909 l_mesg_token_tbl := l_out_mesg_token_tbl;
910
911 x_return_status := FND_API.G_RET_STS_ERROR;
912 x_mesg_token_tbl := l_mesg_token_tbl ;
913 return;
914 end;
915 end if;
916 end;
917
918 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check whether WO network sibling is complete ...'); END IF;
919 begin
920 IF p_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE THEN
921 begin
922 SELECT '1'
923 INTO sibling_parent_job_var
924 FROM dual
925 WHERE EXISTS (SELECT '1'
926 FROM wip_discrete_jobs
927 WHERE wip_entity_id IN
928 (
929 SELECT DISTINCT parent_object_id
930 FROM eam_wo_relationships
931 WHERE parent_relationship_type =2 and
932 child_object_id = p_eam_wo_comp_rec.wip_entity_id
933 )
934 AND status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
935 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED)
936 );
937
938 IF (sibling_parent_job_var = '1') THEN
939 raise fnd_api.g_exc_unexpected_error;
940 END IF;
941 exception
942 WHEN NO_DATA_FOUND THEN
943 null;
944 WHEN OTHERS THEN
945 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
946 l_token_tbl(1).token_value := l_wip_entity_name;
947
948 l_out_mesg_token_tbl := l_mesg_token_tbl;
949 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
950 ( p_message_name => 'EAM_NETWRK_SIB_JOB_NOT_COM'
951 , p_token_tbl => l_token_tbl
952 , p_mesg_token_tbl => l_mesg_token_tbl
953 , x_mesg_token_tbl => l_out_mesg_token_tbl
954 );
955 l_mesg_token_tbl := l_out_mesg_token_tbl;
956
957 x_return_status := FND_API.G_RET_STS_ERROR;
958 x_mesg_token_tbl := l_mesg_token_tbl ;
959 return;
960 end;
961 end if;
962 end ;
963
964 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check whether parent rebuild job is complete if manual rebuild WO ...'); END IF;
965 begin
966 SELECT manual_rebuild_flag,
967 parent_wip_entity_id
968 INTO l_manual_rebuild_flag,
969 l_parent_wip_entity_id
970 FROM WIP_DISCRETE_JOBS
971 WHERE wip_entity_id = p_eam_wo_comp_rec.wip_entity_id;
972
973 IF l_manual_rebuild_flag = 'Y' and l_parent_wip_entity_id IS NOT NULL THEN
974 SELECT status_type
975 INTO l_parent_status_type
976 FROM WIP_DISCRETE_JOBS
977 WHERE wip_entity_id = l_parent_wip_entity_id;
978
979 IF(l_parent_status_type = WIP_CONSTANTS.COMP_CHRG) THEN
980 raise fnd_api.g_exc_unexpected_error;
981 END IF;
982
983 END IF;
984 exception
985 WHEN OTHERS THEN
986 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
987 l_token_tbl(1).token_value := l_wip_entity_name;
988
989 l_out_mesg_token_tbl := l_mesg_token_tbl;
990 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
991 ( p_message_name => 'EAM_PARENT_JOB_COMPLETED'
992 , p_token_tbl => l_token_tbl
993 , p_mesg_token_tbl => l_mesg_token_tbl
994 , x_mesg_token_tbl => l_out_mesg_token_tbl
995 );
996 l_mesg_token_tbl := l_out_mesg_token_tbl;
997
998 x_return_status := FND_API.G_RET_STS_ERROR;
999 x_mesg_token_tbl := l_mesg_token_tbl ;
1000 return;
1001 end;
1002
1003 END Check_Attributes;
1004
1005
1006
1007
1008
1009
1010 PROCEDURE Check_Attributes_b4_Defaulting
1011 ( p_eam_wo_comp_rec IN EAM_PROCESS_WO_PUB.eam_wo_comp_rec_type
1012 , x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
1013 , x_return_status OUT NOCOPY VARCHAR2
1014 )
1015 IS
1016 l_err_text VARCHAR2(2000) := NULL;
1017 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
1018 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
1019 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
1020 g_dummy NUMBER;
1021
1022 BEGIN
1023
1024 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Work Order Completeion processing Check_Attributes_b4_Defaulting'); END IF;
1025
1026 x_return_status := FND_API.G_RET_STS_SUCCESS;
1027
1028 -- organization_id
1029 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Check organization_id'); END IF;
1030
1031 declare
1032 l_disable_date date;
1033 begin
1034
1035 select 1
1036 into g_dummy
1037 from mtl_parameters mp
1038 where mp.organization_id = p_eam_wo_comp_rec.organization_id;
1039
1040 select nvl(hou.date_to,sysdate+1)
1041 into l_disable_date
1042 from hr_organization_units hou
1043 where organization_id = p_eam_wo_comp_rec.organization_id;
1044
1045 if(l_disable_date < sysdate) then
1046 raise fnd_api.g_exc_unexpected_error;
1047 end if;
1048
1049 x_return_status := FND_API.G_RET_STS_SUCCESS;
1050
1051 exception
1052 when others then
1053
1054 l_token_tbl(1).token_name := 'Organization Id';
1055 l_token_tbl(1).token_value := p_eam_wo_comp_rec.organization_id;
1056
1057 l_out_mesg_token_tbl := l_mesg_token_tbl;
1058 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1059 ( p_message_name => 'EAM_WO_ORGANIZATION_ID'
1060 , p_token_tbl => l_token_tbl
1061 , p_mesg_token_tbl => l_mesg_token_tbl
1062 , x_mesg_token_tbl => l_out_mesg_token_tbl
1063 );
1064 l_mesg_token_tbl := l_out_mesg_token_tbl;
1065
1066 x_return_status := FND_API.G_RET_STS_ERROR;
1067 x_mesg_token_tbl := l_mesg_token_tbl ;
1068 return;
1069
1070 end;
1071
1072 -- organization_id (EAM enabled)
1073
1074 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating organization_id (EAM enabled) . . . '); END IF;
1075
1076 begin
1077
1078 select 1
1079 into g_dummy
1080 from wip_eam_parameters wep, mtl_parameters mp
1081 where wep.organization_id = mp.organization_id
1082 and mp.eam_enabled_flag = 'Y'
1083 and wep.organization_id = p_eam_wo_comp_rec.organization_id;
1084
1085 x_return_status := FND_API.G_RET_STS_SUCCESS;
1086
1087 exception
1088 when others then
1089
1090 l_token_tbl(1).token_name := 'Organization Id';
1091 l_token_tbl(1).token_value := p_eam_wo_comp_rec.organization_id;
1092
1093 l_out_mesg_token_tbl := l_mesg_token_tbl;
1094 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1095 ( p_message_name => 'EAM_WO_ORG_EAM_ENABLED'
1096 , p_token_tbl => l_token_tbl
1097 , p_mesg_token_tbl => l_mesg_token_tbl
1098 , x_mesg_token_tbl => l_out_mesg_token_tbl
1099 );
1100 l_mesg_token_tbl := l_out_mesg_token_tbl;
1101
1102 x_return_status := FND_API.G_RET_STS_ERROR;
1103 x_mesg_token_tbl := l_mesg_token_tbl ;
1104 return;
1105
1106 end;
1107
1108 END Check_Attributes_b4_Defaulting;
1109
1110
1111 END EAM_WO_COMP_VALIDATE_PVT;