[Home] [Help]
PACKAGE BODY: APPS.EAM_WO_VALIDATE_PVT
Source
1 PACKAGE BODY EAM_WO_VALIDATE_PVT AS
2 /* $Header: EAMVWOVB.pls 120.35 2010/12/17 01:52:44 mashah ship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVWOVB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Body of package EAM_WO_VALIDATE_PVT
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 30-JUN-2002 Kenichi Nagumo Initial Creation
21 -- 02-May-2005 Anju Gupta IB/Transactable project changes for R12
22 ***************************************************************************/
23
24 G_Pkg_Name VARCHAR2(30) := 'EAM_WO_VALIDATE_PVT';
25
26 g_token_tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
27 g_dummy NUMBER;
28 g_obj_source VARCHAR2(30) := EAM_CONSTANTS.G_OBJ_SOURCE;
29 g_obj_type VARCHAR2(30) := EAM_CONSTANTS.G_OBJ_TYPE;
30 g_act_source VARCHAR2(30) := EAM_CONSTANTS.G_ACT_SOURCE;
31 g_act_cause VARCHAR2(30) := EAM_CONSTANTS.G_ACT_CAUSE;
32 g_act_type VARCHAR2(30) := EAM_CONSTANTS.G_ACT_TYPE;
33 g_wo_type VARCHAR2(30) := EAM_CONSTANTS.G_WO_TYPE;
34 g_shutdown_type VARCHAR2(30):= EAM_CONSTANTS.G_SHUTDOWN_TYPE;
35
36 /*******************************************************************
37 * Procedure : Check_Existence
38 * Returns : None
39 * Parameters IN : Work Order Record
40 * Parameters OUT NOCOPY: Old Work Order Record
41 * Mesg Token Table
42 * Return Status
43 * Purpose : Procedure will query the old EAM work order
44 * record and return it in old record variables. If the
45 * Transaction Type is Create and the record already
46 * exists the return status would be error or if the
47 * transaction type is Update and the record
48 * does not exist then the return status would be an
49 * error as well. Mesg_Token_Table will carry the
50 * error messsage and the tokens associated with the
51 * message.
52 *********************************************************************/
53
54 PROCEDURE Check_Existence
55 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
56 , x_old_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
57 , x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
58 , x_return_status OUT NOCOPY VARCHAR2
59 )
60 IS
61 l_token_tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
62 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
63 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
64 l_return_status VARCHAR2(1);
65 BEGIN
66
67 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Quering Work Order'); END IF;
68
69 EAM_WO_UTILITY_PVT.Query_Row
70 ( p_wip_entity_id => p_eam_wo_rec.wip_entity_id
71 , p_organization_id => p_eam_wo_rec.organization_id
72 , x_eam_wo_rec => x_old_eam_wo_rec
73 , x_Return_status => l_return_status
74 );
75
76 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Query Row Returned with : ' || l_return_status); END IF;
77
78 IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND AND
79 p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
80 THEN
81 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
82 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
83
84 l_out_mesg_token_tbl := l_mesg_token_tbl;
85 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
86 ( x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
87 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
88 , p_message_name => 'EAM_WO_ALREADY_EXISTS'
89 , p_token_tbl => l_token_tbl
90 );
91 l_mesg_token_tbl := l_out_mesg_token_tbl;
92
93 l_return_status := FND_API.G_RET_STS_ERROR;
94
95 ELSIF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_NOT_FOUND AND
96 p_eam_wo_rec.transaction_type IN
97 (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
98 THEN
99 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
100 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
101
102 l_out_mesg_token_tbl := l_mesg_token_tbl;
103 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
104 ( x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
105 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
106 , p_message_name => 'EAM_WO_DOESNOT_EXISTS'
107 , p_token_tbl => l_token_tbl
108 );
109 l_mesg_token_tbl := l_out_mesg_token_tbl;
110
111 l_return_status := FND_API.G_RET_STS_ERROR;
112
113 ELSIF l_Return_status = FND_API.G_RET_STS_UNEXP_ERROR
114 THEN
115 l_out_mesg_token_tbl := l_mesg_token_tbl;
116 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
117 ( x_Mesg_token_tbl => l_out_Mesg_Token_Tbl
118 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
119 , p_message_name => NULL
120 , p_message_text => 'Unexpected error while existence verification of ' || 'EAM WO '|| p_eam_wo_rec.wip_entity_name , p_token_tbl => l_token_tbl
121 );
122 l_mesg_token_tbl := l_out_mesg_token_tbl;
123 l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
124
125 ELSE /* Assign the relevant transaction type for SYNC operations */
126 IF p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_SYNC THEN
127 IF l_return_status = EAM_PROCESS_WO_PVT.G_RECORD_FOUND THEN
128 x_old_eam_wo_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_UPDATE;
129 ELSE
130 x_old_eam_wo_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_CREATE;
131 END IF;
132 END IF;
133 l_return_status := FND_API.G_RET_STS_SUCCESS;
134
135 END IF;
136
137 x_return_status := l_return_status;
138 x_mesg_token_tbl := l_mesg_token_tbl;
139 END Check_Existence;
140
141
142
143 /********************************************************************
144 * Procedure : Check_Attributes_b4_Defaulting
145 * Parameters IN : Work Order Column record
146 * Parameters OUT NOCOPY: Return Status
147 * Mesg Token Table
148 * Purpose : Check_Attrbibutes_b4_Defaulting procedure will validate all item
149 * attributes that are required in defaulting other items
150
151 -- Change History
152 -- 02-May-2005 Anju Gupta IB/Transactable Asset changes for R12
153 **********************************************************************/
154
155 PROCEDURE Check_Attributes_b4_Defaulting
156 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
157 , x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
158 , x_return_status OUT NOCOPY VARCHAR2
159 )
160 IS
161 l_err_text VARCHAR2(2000) := NULL;
162 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
163 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
164 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
165 l_old_eam_wo_moid NUMBER := 0;
166
167 BEGIN
168
169 x_return_status := FND_API.G_RET_STS_SUCCESS;
170
171 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within WO Check Attributes b4 Defaulting . . . '); END IF;
172
173
174 -- organization_id
175
176 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating organization_id . . . '); END IF;
177
178 declare
179 l_disable_date date;
180 begin
181 select 1
182 into g_dummy
183 from mtl_parameters mp
184 where mp.organization_id = p_eam_wo_rec.organization_id;
185
186 select nvl(hou.date_to,sysdate+1)
187 into l_disable_date
188 from hr_organization_units hou
189 where organization_id = p_eam_wo_rec.organization_id;
190
191 if(l_disable_date < sysdate) then
192 raise fnd_api.g_exc_unexpected_error;
193 end if;
194
195 x_return_status := FND_API.G_RET_STS_SUCCESS;
196
197 exception
198 when others then
199 l_token_tbl(1).token_name := 'Organization Id';
200 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
201
202 l_out_mesg_token_tbl := l_mesg_token_tbl;
203 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
204 ( p_message_name => 'EAM_WO_ORGANIZATION_ID'
205 , p_token_tbl => l_token_tbl
206 , p_mesg_token_tbl => l_mesg_token_tbl
207 , x_mesg_token_tbl => l_out_mesg_token_tbl
208 );
209 l_mesg_token_tbl := l_out_mesg_token_tbl;
210
211 x_return_status := FND_API.G_RET_STS_ERROR;
212 x_mesg_token_tbl := l_mesg_token_tbl ;
213 return;
214
215 end;
216
217
218 -- organization_id (EAM enabled)
219
220 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating organization_id (EAM enabled) . . . '); END IF;
221
222 --Only check EAM enabled for CMRO, part of bug fix 9313320
223 IF p_eam_wo_rec.maintenance_object_source = 2 then
224
225 begin
226
227 select 1
228 into g_dummy
229 from mtl_parameters mp
230 where mp.eam_enabled_flag = 'Y'
231 and mp.organization_id = p_eam_wo_rec.organization_id;
232
233 x_return_status := FND_API.G_RET_STS_SUCCESS;
234
235 exception
236 when no_data_found then
237 l_token_tbl(1).token_name := 'Organization Id';
238 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
239
240 l_out_mesg_token_tbl := l_mesg_token_tbl;
241 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
242 ( p_message_name => 'EAM_WO_ORG_EAM_ENABLED'
243 , p_token_tbl => l_token_tbl
244 , p_mesg_token_tbl => l_mesg_token_tbl
245 , x_mesg_token_tbl => l_out_mesg_token_tbl
246 );
247 l_mesg_token_tbl := l_out_mesg_token_tbl;
248
249 x_return_status := FND_API.G_RET_STS_ERROR;
250 x_mesg_token_tbl := l_mesg_token_tbl ;
251 return;
252
253 end;
254
255 ELSE -- For EAM work orders, if mtl org is EAM enabled, then it must be the same as the maintenance org
256 begin
257 select 1
258 into g_dummy
259 from wip_eam_parameters wep, mtl_parameters mp
260 where wep.organization_id = mp.organization_id
261 and mp.eam_enabled_flag = 'Y'
262 and wep.organization_id = p_eam_wo_rec.organization_id;
263
264 x_return_status := FND_API.G_RET_STS_SUCCESS;
265
266 exception
267 when no_data_found then
268
269 l_token_tbl(1).token_name := 'Organization Id';
270 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
271
272 l_out_mesg_token_tbl := l_mesg_token_tbl;
273 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
274 ( p_message_name => 'EAM_WO_ORG_EAM_ENABLED'
275 , p_token_tbl => l_token_tbl
276 , p_mesg_token_tbl => l_mesg_token_tbl
277 , x_mesg_token_tbl => l_out_mesg_token_tbl
278 );
279 l_mesg_token_tbl := l_out_mesg_token_tbl;
280
281 x_return_status := FND_API.G_RET_STS_ERROR;
282 x_mesg_token_tbl := l_mesg_token_tbl ;
283 return;
284
285 end;
286
287
288 END IF;
289
290 -- maintenance_object_source
291
292 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_source . . . '); END IF;
293
294 begin
295
296 if p_eam_wo_rec.maintenance_object_source is null or
297 p_eam_wo_rec.maintenance_object_source = fnd_api.g_miss_num
298 then
299 raise fnd_api.g_exc_error;
300 end if;
301
302 select 1 into g_dummy from
303 mfg_lookups where lookup_type = g_obj_source
304 and lookup_code = p_eam_wo_rec.maintenance_object_source;
305
306 x_return_status := FND_API.G_RET_STS_SUCCESS;
307
308 exception
309 when fnd_api.g_exc_error then
310
311 l_token_tbl(1).token_name := 'Object Source';
312 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_source;
313
314 l_out_mesg_token_tbl := l_mesg_token_tbl;
315 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
316 ( p_message_name => 'EAM_WO_MAINT_OBJ_SRC_REQUIRED'
317 , p_token_tbl => l_token_tbl
318 , p_mesg_token_tbl => l_mesg_token_tbl
319 , x_mesg_token_tbl => l_out_mesg_token_tbl
320 );
321 l_mesg_token_tbl := l_out_mesg_token_tbl;
322
323 x_return_status := FND_API.G_RET_STS_ERROR;
324 x_mesg_token_tbl := l_mesg_token_tbl ;
325 return;
326
327 when no_data_found then
328
329 l_token_tbl(1).token_name := 'Object Source';
330 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_source;
331
332 l_out_mesg_token_tbl := l_mesg_token_tbl;
333 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
334 ( p_message_name => 'EAM_WO_MAINT_OBJ_SOURCE'
335 , p_token_tbl => l_token_tbl
336 , p_mesg_token_tbl => l_mesg_token_tbl
337 , x_mesg_token_tbl => l_out_mesg_token_tbl
338 );
339 l_mesg_token_tbl := l_out_mesg_token_tbl;
340
341 x_return_status := FND_API.G_RET_STS_ERROR;
342 x_mesg_token_tbl := l_mesg_token_tbl ;
343 return;
344
345 end;
346
347 -- maintenance_object_type
348
349 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_type . . . '); END IF;
350
351 begin
352
353 if p_eam_wo_rec.maintenance_object_type is null or
354 p_eam_wo_rec.maintenance_object_type = fnd_api.g_miss_num or
355 p_eam_wo_rec.maintenance_object_type = 1
356 then
357 raise fnd_api.g_exc_error;
358 end if;
359
360 select 1 into g_dummy from
361 mfg_lookups where lookup_type = g_obj_type
362 and lookup_code = p_eam_wo_rec.maintenance_object_type;
363
364 x_return_status := FND_API.G_RET_STS_SUCCESS;
365
366 exception
367 when fnd_api.g_exc_error then
368
369 l_token_tbl(1).token_name := 'Object Type';
370 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_type;
371
372 l_out_mesg_token_tbl := l_mesg_token_tbl;
373 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
374 ( p_message_name => 'EAM_WO_MAINT_OBJ_TYPE_REQUIRED'
375 , p_token_tbl => l_token_tbl
376 , p_mesg_token_tbl => l_mesg_token_tbl
377 , x_mesg_token_tbl => l_out_mesg_token_tbl
378 );
379 l_mesg_token_tbl := l_out_mesg_token_tbl;
380
381 x_return_status := FND_API.G_RET_STS_ERROR;
382 x_mesg_token_tbl := l_mesg_token_tbl ;
383 return;
384
385 when no_data_found then
386
387 l_token_tbl(1).token_name := 'Object Type';
388 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_type;
389
390 l_out_mesg_token_tbl := l_mesg_token_tbl;
391 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
392 ( p_message_name => 'EAM_WO_MAINT_OBJ_TYPE'
393 , p_token_tbl => l_token_tbl
394 , p_mesg_token_tbl => l_mesg_token_tbl
395 , x_mesg_token_tbl => l_out_mesg_token_tbl
396 );
397 l_mesg_token_tbl := l_out_mesg_token_tbl;
398
399 x_return_status := FND_API.G_RET_STS_ERROR;
400 x_mesg_token_tbl := l_mesg_token_tbl ;
401 return;
402
403 end;
404
405 -- maintenance_object_id
406
407 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_id . . . '); END IF;
408
409 begin
410
411 if p_eam_wo_rec.maintenance_object_id is null or
412 p_eam_wo_rec.maintenance_object_id = fnd_api.g_miss_num
413 then
414 raise fnd_api.g_exc_error;
415 end if;
416
417 IF p_eam_wo_rec.maintenance_object_type = 3 then
418 --CMRO does not use the EAM family of maintenance orgs concept.
419 IF p_eam_wo_rec.maintenance_object_source = 1 THEN
420
421 IF p_eam_wo_rec.transaction_type <> EAM_PROCESS_WO_PVT.G_OPR_CREATE THEN
422 select maintenance_object_id into l_old_eam_wo_moid
423 from wip_discrete_jobs
424 where wip_entity_id = p_eam_wo_rec.wip_entity_id
425 and organization_id = p_eam_wo_rec.organization_id
426 and rownum = 1;
427 END IF;
428 IF p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
429 OR (p_eam_wo_rec.transaction_type <> EAM_PROCESS_WO_PVT.G_OPR_CREATE
430 AND l_old_eam_wo_moid <> p_eam_wo_rec.maintenance_object_id) THEN
431 -- Code for create validation
432 select 1 into g_dummy
433 from csi_item_instances cii, mtl_parameters mp
434 where cii.last_vld_organization_id = mp.organization_id
435 and mp.maint_organization_id = p_eam_wo_rec.organization_id
436 and cii.instance_id = p_eam_wo_rec.maintenance_object_id
437 and cii.inventory_item_id = nvl(p_eam_wo_rec.asset_group_id, p_eam_wo_rec.rebuild_item_id)
438 and rownum = 1;
439 END IF;
440 END IF;
441
442 ELSIF p_eam_wo_rec.maintenance_object_type = 2 then
443 if (p_eam_wo_rec.maintenance_object_source = 1) then
444 select 1 into g_dummy from mtl_system_items msi, mtl_parameters mp where
445 msi.organization_id = mp.organization_id
446 and mp.maint_organization_id = p_eam_wo_rec.organization_id
447 and msi.inventory_item_id = p_eam_wo_rec.maintenance_object_id
448 and rownum = 1;
449 elsif (p_eam_wo_rec.maintenance_object_source = 2) then
450 select 1 into g_dummy from mtl_system_items where
451 organization_id = p_eam_wo_rec.organization_id
452 and inventory_item_id = p_eam_wo_rec.maintenance_object_id;
453 end if;
454 END IF;
455
456 x_return_status := FND_API.G_RET_STS_SUCCESS;
457
458 exception
459 when fnd_api.g_exc_error then
460
461 l_token_tbl(1).token_name := 'Object Id';
462 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_id;
463
464 l_out_mesg_token_tbl := l_mesg_token_tbl;
465 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
466 ( p_message_name => 'EAM_WO_MAINT_OBJ_ID_REQUIRED'
467 , p_token_tbl => l_token_tbl
468 , p_mesg_token_tbl => l_mesg_token_tbl
469 , x_mesg_token_tbl => l_out_mesg_token_tbl
470 );
471 l_mesg_token_tbl := l_out_mesg_token_tbl;
472
473 x_return_status := FND_API.G_RET_STS_ERROR;
474 x_mesg_token_tbl := l_mesg_token_tbl ;
475 return;
476
477 when others then
478
479 l_token_tbl(1).token_name := 'Object Id';
480 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_id;
481
482 l_out_mesg_token_tbl := l_mesg_token_tbl;
483 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
484 ( p_message_name => 'EAM_WO_MAINT_OBJ_ID'
485 , p_token_tbl => l_token_tbl
486 , p_mesg_token_tbl => l_mesg_token_tbl
487 , x_mesg_token_tbl => l_out_mesg_token_tbl
488 );
489 l_mesg_token_tbl := l_out_mesg_token_tbl;
490
491 x_return_status := FND_API.G_RET_STS_ERROR;
492 x_mesg_token_tbl := l_mesg_token_tbl ;
493 return;
494
495 end;
496
497 -- rebuild_item_id
498
499 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating rebuild_item_id . . . '); END IF;
500
501 begin
502
503 -- for CMRO work orders, the rebuild_item_id cannot be null.
504 if p_eam_wo_rec.maintenance_object_source = 2 and
505 p_eam_wo_rec.rebuild_item_id is null
506 then
507 raise fnd_api.g_exc_error;
508 end if;
509
510 x_return_status := FND_API.G_RET_STS_SUCCESS;
511
512 exception
513
514 when fnd_api.g_exc_error then
515
516 l_token_tbl(1).token_name := 'Wip Id';
517 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
518
519 l_out_mesg_token_tbl := l_mesg_token_tbl;
520 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
521 ( p_message_name => 'EAM_WO_REBUILD_ITEM_REQUIRED'
522 , p_token_tbl => l_token_tbl
523 , p_mesg_token_tbl => l_mesg_token_tbl
524 , x_mesg_token_tbl => l_out_mesg_token_tbl
525 );
526 l_mesg_token_tbl := l_out_mesg_token_tbl;
527
528 x_return_status := FND_API.G_RET_STS_ERROR;
529 x_mesg_token_tbl := l_mesg_token_tbl ;
530 return;
531
532 end;
533
534 -- rebuild_item_id and asset_group_id
535
536 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating rebuild_item_id and asset_group_id. . . '); END IF;
537
538 begin
539
540 -- rebuild_item_id and asset_group_id cannot both be null.
541 if p_eam_wo_rec.asset_group_id is null and
542 p_eam_wo_rec.rebuild_item_id is null
543 then
544 raise fnd_api.g_exc_error;
545 end if;
546
547 x_return_status := FND_API.G_RET_STS_SUCCESS;
548
549 exception
550 when fnd_api.g_exc_error then
551
552 l_token_tbl(1).token_name := 'Wip Id';
553 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
554
555 l_out_mesg_token_tbl := l_mesg_token_tbl;
556 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
557 ( p_message_name => 'EAM_WO_AG_RB_REQUIRED'
558 , p_token_tbl => l_token_tbl
559 , p_mesg_token_tbl => l_mesg_token_tbl
560 , x_mesg_token_tbl => l_out_mesg_token_tbl
561 );
562 l_mesg_token_tbl := l_out_mesg_token_tbl;
563
564 x_return_status := FND_API.G_RET_STS_ERROR;
565 x_mesg_token_tbl := l_mesg_token_tbl ;
566 return;
567
568 end;
569
570
571 -- wip_entity_id
572
573 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating wip_entity_id . . . '); END IF;
574
575 begin
576
577 if p_eam_wo_rec.wip_entity_id is not null and
578 p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
579 then
580 raise fnd_api.g_exc_error;
581 end if;
582
583 x_return_status := FND_API.G_RET_STS_SUCCESS;
584
585 exception
586 when fnd_api.g_exc_error then
587
588 l_token_tbl(1).token_name := 'Wip Entity Id';
589 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
590
591 l_out_mesg_token_tbl := l_mesg_token_tbl;
592 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
593 ( p_message_name => 'EAM_WO_WIP_ENTITY_ID'
594 , p_token_tbl => l_token_tbl
595 , p_mesg_token_tbl => l_mesg_token_tbl
596 , x_mesg_token_tbl => l_out_mesg_token_tbl
597 );
598 l_mesg_token_tbl := l_out_mesg_token_tbl;
599
600 x_return_status := FND_API.G_RET_STS_ERROR;
601 x_mesg_token_tbl := l_mesg_token_tbl ;
602 return;
603
604 end;
605
606
607 EXCEPTION
608 WHEN OTHERS THEN
609
610 l_token_tbl(1).token_name := 'Validation (Check Attributes b4 defaulting)';
611 l_token_tbl(1).token_value := substrb(SQLERRM,1,200);
612
613 l_out_mesg_token_tbl := l_mesg_token_tbl;
614 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
615 ( p_message_name => NULL
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 -- Return the status and message table.
623 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
624 x_mesg_token_tbl := l_mesg_token_tbl ;
625
626 END Check_Attributes_b4_Defaulting;
627
628 /********************************************************************
629 * Procedure : Check_Attributes
630 * Parameters IN : Work Order Column record
631 * Old Work Order Column record
632 * Parameters OUT NOCOPY: Return Status
633 * Mesg Token Table
634 * Purpose : Check_Attrbibutes procedure will validate every
635 * revised item attrbiute in its entirety.
636 -- Change History
637 -- Anju Gupta 05/03/05 IB/Transactable Asset changes for R12
638 **********************************************************************/
639
640 PROCEDURE Check_Attributes
641 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
642 , p_old_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
643 , x_return_status OUT NOCOPY VARCHAR2
644 , x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
645 )
646 IS
647 l_err_text VARCHAR2(2000) := NULL;
648 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
649 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
650 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
651 l_mo_err_flag VARCHAR2(1) ;
652 l_trans_exist VARCHAR2(1);
653
654 l_rebuild_status NUMBER;
655 l_current_status NUMBER;
656 l_enabled_flag VARCHAR2(1);
657
658 l_wo_asset_activity_err EXCEPTION;
659
660 BEGIN
661 l_mo_err_flag:= '';
662 x_return_status := FND_API.G_RET_STS_SUCCESS;
663
664 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Within WO Check Attributes . . . '); END IF;
665
666
667 -- organization_id
668
669 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating organization_id . . . '); END IF;
670
671 declare
672 l_disable_date date;
673 begin
674 select 1
675 into g_dummy
676 from mtl_parameters mp
677 where mp.organization_id = p_eam_wo_rec.organization_id;
678
679 select nvl(hou.date_to,sysdate+1)
680 into l_disable_date
681 from hr_organization_units hou
682 where organization_id = p_eam_wo_rec.organization_id;
683
684 if(l_disable_date < sysdate) then
685 raise fnd_api.g_exc_unexpected_error;
686 end if;
687
688 x_return_status := FND_API.G_RET_STS_SUCCESS;
689
690 exception
691
692 when fnd_api.g_exc_unexpected_error then
693 l_token_tbl(1).token_name := 'Organization Id';
694 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
695
696 l_out_mesg_token_tbl := l_mesg_token_tbl;
697 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
698 ( p_message_name => 'EAM_WO_ORGANIZATION_ID'
699 , p_token_tbl => l_token_tbl
700 , p_mesg_token_tbl => l_mesg_token_tbl
701 , x_mesg_token_tbl => l_out_mesg_token_tbl
702 );
703 l_mesg_token_tbl := l_out_mesg_token_tbl;
704
705 x_return_status := FND_API.G_RET_STS_ERROR;
706 x_mesg_token_tbl := l_mesg_token_tbl ;
707 return;
708
709 when no_data_found then
710
711 l_token_tbl(1).token_name := 'Organization Id';
712 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
713
714 l_out_mesg_token_tbl := l_mesg_token_tbl;
715 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
716 ( p_message_name => 'EAM_WO_ORGANIZATION_ID'
717 , p_token_tbl => l_token_tbl
718 , p_mesg_token_tbl => l_mesg_token_tbl
719 , x_mesg_token_tbl => l_out_mesg_token_tbl
720 );
721 l_mesg_token_tbl := l_out_mesg_token_tbl;
722
723 x_return_status := FND_API.G_RET_STS_ERROR;
724 x_mesg_token_tbl := l_mesg_token_tbl ;
725 return;
726
727
728
729 end;
730
731 /* PJM MOAC Changes */
732 fnd_profile.put('MFG_ORGANIZATION_ID', p_eam_wo_rec.organization_id);
733
734
735 -- organization_id (EAM enabled)
736
737 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating organization_id (EAM enabled) . . . '); END IF;
738
739 --Only check EAM enabled for CMRO, part of bug fix 9313320
740 IF p_eam_wo_rec.maintenance_object_source = 2 then
741
742 begin
743 select 1
744 into g_dummy
745 from mtl_parameters mp
746 where mp.eam_enabled_flag = 'Y'
747 and mp.organization_id = p_eam_wo_rec.organization_id;
748
749 x_return_status := FND_API.G_RET_STS_SUCCESS;
750
751 exception
752
753 when no_data_found then
754 l_token_tbl(1).token_name := 'Organization Id';
755 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
756
757 l_out_mesg_token_tbl := l_mesg_token_tbl;
758 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
759 ( p_message_name => 'EAM_WO_ORG_EAM_ENABLED'
760 , p_token_tbl => l_token_tbl
761 , p_mesg_token_tbl => l_mesg_token_tbl
762 , x_mesg_token_tbl => l_out_mesg_token_tbl
763 );
764 l_mesg_token_tbl := l_out_mesg_token_tbl;
765
766 x_return_status := FND_API.G_RET_STS_ERROR;
767 x_mesg_token_tbl := l_mesg_token_tbl ;
768 return;
769
770 end;
771
772 ELSE -- For EAM work orders, if mtl org is EAM enabled, then it must be the same as the maintenance org
773 begin
774 select 1
775 into g_dummy
776 from wip_eam_parameters wep, mtl_parameters mp
777 where wep.organization_id = mp.organization_id
778 and mp.eam_enabled_flag = 'Y'
779 and wep.organization_id = p_eam_wo_rec.organization_id;
780
781 x_return_status := FND_API.G_RET_STS_SUCCESS;
782
783 exception
784 when no_data_found then
785
786 l_token_tbl(1).token_name := 'Organization Id';
787 l_token_tbl(1).token_value := p_eam_wo_rec.organization_id;
788
789 l_out_mesg_token_tbl := l_mesg_token_tbl;
790 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
791 ( p_message_name => 'EAM_WO_ORG_EAM_ENABLED'
792 , p_token_tbl => l_token_tbl
793 , p_mesg_token_tbl => l_mesg_token_tbl
794 , x_mesg_token_tbl => l_out_mesg_token_tbl
795 );
796 l_mesg_token_tbl := l_out_mesg_token_tbl;
797
798 x_return_status := FND_API.G_RET_STS_ERROR;
799 x_mesg_token_tbl := l_mesg_token_tbl ;
800 return;
801
802 end;
803
804 END IF;
805 -- maintenance_object_type
806
807 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_type . . . '); END IF;
808
809 begin
810
811 if (p_eam_wo_rec.maintenance_object_type is not null) then
812
813 select 1
814 into g_dummy
815 from mfg_lookups
816 where lookup_type = g_obj_type
817 and lookup_code = p_eam_wo_rec.maintenance_object_type;
818
819 x_return_status := FND_API.G_RET_STS_SUCCESS;
820
821 end if;
822
823 exception
824 when no_data_found then
825 l_token_tbl(1).token_name := 'Maintenance Object Type';
826 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_type;
827
828 l_out_mesg_token_tbl := l_mesg_token_tbl;
829 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
830 ( p_message_name => 'EAM_WO_MAINT_OBJECT_TYPE'
831 , p_token_tbl => l_token_tbl
832 , p_mesg_token_tbl => l_mesg_token_tbl
833 , x_mesg_token_tbl => l_out_mesg_token_tbl
834 );
835 l_mesg_token_tbl := l_out_mesg_token_tbl;
836
837 x_return_status := FND_API.G_RET_STS_ERROR;
838 x_mesg_token_tbl := l_mesg_token_tbl ;
839 return;
840
841 end;
842
843
844 -- object_source_id
845
846 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_id . . . '); END IF;
847
848 begin
849
850 if (p_eam_wo_rec.maintenance_object_type is not null) then
851
852 if (p_eam_wo_rec.maintenance_object_type = 3 and p_eam_wo_rec.maintenance_object_source = 1) then
853
854 IF p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
855 OR (p_eam_wo_rec.transaction_type <> EAM_PROCESS_WO_PVT.G_OPR_CREATE
856 AND p_eam_wo_rec.maintenance_object_id <> p_old_eam_wo_rec.maintenance_object_id) THEN
857 -- Code for creation
858 select 1 into g_dummy
859 from csi_item_instances cii, mtl_parameters mp
860 where cii.last_vld_organization_id = mp.organization_id
861 and mp.maint_organization_id = p_eam_wo_rec.organization_id
862 and cii.instance_id = p_eam_wo_rec.maintenance_object_id;
863 END IF;
864
865 x_return_status := FND_API.G_RET_STS_SUCCESS;
866
867 elsif (p_eam_wo_rec.maintenance_object_type = 2) then
868 if (p_eam_wo_rec.maintenance_object_source = 1) then
869 select 1
870 into g_dummy
871 from mtl_system_items msi, mtl_parameters mp
872 where msi.organization_id = mp.organization_id
873 and mp.maint_organization_id = p_eam_wo_rec.organization_id
874 and inventory_item_id = p_eam_wo_rec.maintenance_object_id
875 and rownum = 1;
876 elsif (p_eam_wo_rec.maintenance_object_source = 2) then
877 select 1
878 into g_dummy
879 from mtl_system_items
880 where organization_id = p_eam_wo_rec.organization_id
881 and inventory_item_id = p_eam_wo_rec.maintenance_object_id;
882 end if;
883
884 x_return_status := FND_API.G_RET_STS_SUCCESS;
885
886 end if;
887
888 end if;
889
890 exception
891 when others then
892 l_token_tbl(1).token_name := 'Maintenance Object Id';
893 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_id;
894
895 l_out_mesg_token_tbl := l_mesg_token_tbl;
896 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
897 ( p_message_name => 'EAM_WO_MAINT_OBJECT_ID'
898 , p_token_tbl => l_token_tbl
899 , p_mesg_token_tbl => l_mesg_token_tbl
900 , x_mesg_token_tbl => l_out_mesg_token_tbl
901 );
902 l_mesg_token_tbl := l_out_mesg_token_tbl;
903
904 x_return_status := FND_API.G_RET_STS_ERROR;
905 x_mesg_token_tbl := l_mesg_token_tbl ;
906 return;
907
908 end;
909
910
911
912 -- maintenance object
913 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance object . . . '); END IF;
914
915 begin
916
917 if (p_eam_wo_rec.asset_group_id is not null) and (p_eam_wo_rec.rebuild_item_id is not null) then
918
919 raise fnd_api.g_exc_unexpected_error;
920
921 end if;
922
923 x_return_status := FND_API.G_RET_STS_SUCCESS;
924
925 exception
926 when fnd_api.g_exc_unexpected_error then
927
928 l_token_tbl(1).token_name := 'Asset Group';
929 l_token_tbl(1).token_value := p_eam_wo_rec.asset_group_id;
930
931 l_out_mesg_token_tbl := l_mesg_token_tbl;
932 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
933 ( p_message_name => 'EAM_WO_AG_RB_DUPLICATE'
934 , p_token_tbl => l_token_tbl
935 , p_mesg_token_tbl => l_mesg_token_tbl
936 , x_mesg_token_tbl => l_out_mesg_token_tbl
937 );
938 l_mesg_token_tbl := l_out_mesg_token_tbl;
939
940 x_return_status := FND_API.G_RET_STS_ERROR;
941 x_mesg_token_tbl := l_mesg_token_tbl ;
942 return;
943
944 end;
945
946 -- asset_group_id
947 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating asset_group_id . . . '); END IF;
948
949 begin
950
951 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE and p_eam_wo_rec.asset_group_id is not null) then
952
953 if(p_eam_wo_rec.asset_number is null)
954 then
955 raise fnd_api.g_exc_unexpected_error;
956 end if;
957
958 select 1
959 into g_dummy
960 from mtl_system_items msi, csi_item_instances cii, mtl_parameters mp
961 where cii.inventory_item_id = p_eam_wo_rec.asset_group_id
962 and cii.inventory_item_id = msi.inventory_item_id
963 and cii.last_vld_organization_id = mp.organization_id
964 and msi.organization_id = mp.organization_id
965 and mp.maint_organization_id = p_eam_wo_rec.organization_id
966 and cii.serial_number = p_eam_wo_rec.asset_number
967 and msi.eam_item_type = 1
968 and ROWNUM =1 ;
969 end if;
970
971 x_return_status := FND_API.G_RET_STS_SUCCESS;
972
973 exception
974 when others then
975
976 l_token_tbl(1).token_name := 'Asset Group';
977 l_token_tbl(1).token_value := p_eam_wo_rec.asset_group_id;
978
979 l_out_mesg_token_tbl := l_mesg_token_tbl;
980 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
981 ( p_message_name => 'EAM_WO_ASSET_GROUP'
982 , p_token_tbl => l_token_tbl
983 , p_mesg_token_tbl => l_mesg_token_tbl
984 , x_mesg_token_tbl => l_out_mesg_token_tbl
985 );
986 l_mesg_token_tbl := l_out_mesg_token_tbl;
987
988 x_return_status := FND_API.G_RET_STS_ERROR;
989 x_mesg_token_tbl := l_mesg_token_tbl ;
990 return;
991
992 end;
993
994 -- asset_number
995 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating asset_number . . . '); END IF;
996
997 begin
998
999 if (p_eam_wo_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE,EAM_PROCESS_WO_PVT.G_OPR_UPDATE) and p_eam_wo_rec.asset_number is not null) then
1000
1001 /* In update mode do not check the current maintenance organization*/
1002 select 1
1003 into g_dummy
1004 from csi_item_instances cii
1005 where cii.inventory_item_id = p_eam_wo_rec.asset_group_id
1006 and cii.serial_number = p_eam_wo_rec.asset_number
1007 and nvl(cii.maintainable_flag, 'Y') = 'Y'
1008 and nvl(cii.active_start_date, sysdate-1) <= sysdate
1009 and nvl(cii.active_end_date, sysdate+1) >= sysdate ;
1010
1011 end if;
1012
1013 x_return_status := FND_API.G_RET_STS_SUCCESS;
1014
1015 exception
1016 when no_data_found then
1017
1018 l_token_tbl(1).token_name := 'Asset Number';
1019 l_token_tbl(1).token_value := p_eam_wo_rec.asset_number;
1020
1021 l_out_mesg_token_tbl := l_mesg_token_tbl;
1022 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1023 ( p_message_name => 'EAM_WO_ASSET_NUMBER'
1024 , p_token_tbl => l_token_tbl
1025 , p_mesg_token_tbl => l_mesg_token_tbl
1026 , x_mesg_token_tbl => l_out_mesg_token_tbl
1027 );
1028 l_mesg_token_tbl := l_out_mesg_token_tbl;
1029
1030 x_return_status := FND_API.G_RET_STS_ERROR;
1031 x_mesg_token_tbl := l_mesg_token_tbl ;
1032 return;
1033
1034 end;
1035
1036
1037
1038 -- eam_linear_location_id
1039 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating eam_linear_location_id . . . '); END IF;
1040
1041 begin
1042
1043 if (p_eam_wo_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE,
1044 EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
1045 and p_eam_wo_rec.eam_linear_location_id is not null) then
1046
1047 select 1
1048 into g_dummy
1049 from eam_linear_locations
1050 where eam_linear_id = p_eam_wo_rec.eam_linear_location_id;
1051
1052 end if;
1053
1054 x_return_status := FND_API.G_RET_STS_SUCCESS;
1055
1056 exception
1057 when no_data_found then
1058
1059 l_token_tbl(1).token_name := 'LIN_LOC';
1060 l_token_tbl(1).token_value := p_eam_wo_rec.eam_linear_location_id;
1061
1062 l_out_mesg_token_tbl := l_mesg_token_tbl;
1063 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1064 ( p_message_name => 'EAM_WO_LINEAR_LOCATION'
1065 , p_token_tbl => l_token_tbl
1066 , p_mesg_token_tbl => l_mesg_token_tbl
1067 , x_mesg_token_tbl => l_out_mesg_token_tbl
1068 );
1069 l_mesg_token_tbl := l_out_mesg_token_tbl;
1070
1071 x_return_status := FND_API.G_RET_STS_ERROR;
1072 x_mesg_token_tbl := l_mesg_token_tbl ;
1073 return;
1074
1075 end;
1076
1077
1078 -- rebuild_item_id
1079 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating rebuild_item_id . . . '); END IF;
1080
1081 begin
1082
1083 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE and p_eam_wo_rec.rebuild_item_id is not null) then
1084
1085 IF p_eam_wo_rec.maintenance_object_source = 2 then -- for fix 9313320 do not check maint org for CMRO
1086
1087 select 1
1088 into g_dummy
1089 from mtl_system_items msi, mtl_parameters mp
1090 where msi.inventory_item_id = p_eam_wo_rec.rebuild_item_id
1091 and msi.organization_id = mp.organization_id
1092 -- and mp.maint_organization_id = p_eam_wo_rec.organization_id
1093 and msi.eam_item_type = 3
1094 and rownum = 1;
1095
1096 else
1097 select 1
1098 into g_dummy
1099 from mtl_system_items msi, mtl_parameters mp
1100 where msi.inventory_item_id = p_eam_wo_rec.rebuild_item_id
1101 and msi.organization_id = mp.organization_id
1102 and mp.maint_organization_id = p_eam_wo_rec.organization_id
1103 and msi.eam_item_type = 3
1104 and rownum = 1;
1105 end if;
1106 end if;
1107
1108 x_return_status := FND_API.G_RET_STS_SUCCESS;
1109
1110 exception
1111 when no_data_found then
1112
1113 l_token_tbl(1).token_name := 'Rebuild Item Id';
1114 l_token_tbl(1).token_value := p_eam_wo_rec.rebuild_item_id;
1115
1116 l_out_mesg_token_tbl := l_mesg_token_tbl;
1117 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1118 ( p_message_name => 'EAM_WO_REBUILD_ITEM_ID'
1119 , p_token_tbl => l_token_tbl
1120 , p_mesg_token_tbl => l_mesg_token_tbl
1121 , x_mesg_token_tbl => l_out_mesg_token_tbl
1122 );
1123 l_mesg_token_tbl := l_out_mesg_token_tbl;
1124
1125 x_return_status := FND_API.G_RET_STS_ERROR;
1126 x_mesg_token_tbl := l_mesg_token_tbl ;
1127 return;
1128
1129 end;
1130
1131 -- rebuild_serial_number
1132 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating rebuild_serial_number . . . '); END IF;
1133
1134 begin
1135 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
1136
1137 if(p_eam_wo_rec.rebuild_item_id is null and
1138 p_eam_wo_rec.rebuild_serial_number is not null) then
1139 raise fnd_api.g_exc_unexpected_error;
1140 end if;
1141
1142 if(p_eam_wo_rec.rebuild_item_id is not null and
1143 p_eam_wo_rec.rebuild_serial_number is not null) then
1144
1145 select 1
1146 into g_dummy
1147 from csi_item_instances cii, mtl_parameters mp
1148 where cii.inventory_item_id = p_eam_wo_rec.rebuild_item_id
1149 and cii.last_vld_organization_id = mp.organization_id
1150 and mp.maint_organization_id = p_eam_wo_rec.organization_id
1151 and cii.serial_number = p_eam_wo_rec.rebuild_serial_number
1152 and nvl(cii.maintainable_flag, 'Y') = 'Y'
1153 and nvl(cii.active_start_date, sysdate-1) <= sysdate
1154 and nvl(cii.active_end_date, sysdate+1) >= sysdate;
1155 end if;
1156
1157 /* Since serial numbers can be dynamically generated at SO issue and the
1158 condition was actually commented out, we dont have to perform this query
1159 at all*/
1160
1161 end if;
1162
1163
1164
1165 /* Validation added so that rebuild serial number is not
1166 updateable if the WO is in status Released */
1167 /***** Enahancement No. : 2943473 ******/
1168
1169 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
1170 and p_eam_wo_rec.rebuild_item_id is not null
1171 and p_eam_wo_rec.rebuild_serial_number is not null
1172 and nvl(p_old_eam_wo_rec.rebuild_serial_number,'null_old_serial_number') <>
1173 nvl(p_eam_wo_rec.rebuild_serial_number,'null_old_serial_number') )
1174 THEN
1175
1176 IF ( p_eam_wo_rec.status_type = WIP_CONSTANTS.RELEASED
1177 and p_old_eam_wo_rec.status_type = WIP_CONSTANTS.RELEASED )
1178 THEN
1179 EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
1180 X_Wip_Id => p_eam_wo_rec.wip_entity_id,
1181 X_Rep_Id => -1,
1182 X_Line_Id => -1,
1183 X_Ent_Type=> 6,
1184 X_Return_Status=>l_trans_exist);
1185
1186 IF(l_trans_exist='F') THEN
1187 raise fnd_api.g_exc_unexpected_error;
1188 END IF;
1189 END IF;
1190 END IF;
1191
1192
1193
1194 x_return_status := FND_API.G_RET_STS_SUCCESS;
1195
1196 exception
1197 when others then
1198
1199 l_token_tbl(1).token_name := 'Rebuild Serial Number';
1200 l_token_tbl(1).token_value := p_eam_wo_rec.rebuild_serial_Number;
1201
1202 l_out_mesg_token_tbl := l_mesg_token_tbl;
1203 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1204 ( p_message_name => 'EAM_WO_REBUILD_SERIAL_NUMBER'
1205 , p_token_tbl => l_token_tbl
1206 , p_mesg_token_tbl => l_mesg_token_tbl
1207 , x_mesg_token_tbl => l_out_mesg_token_tbl
1208 );
1209 l_mesg_token_tbl := l_out_mesg_token_tbl;
1210
1211 x_return_status := FND_API.G_RET_STS_ERROR;
1212 x_mesg_token_tbl := l_mesg_token_tbl ;
1213 return;
1214
1215 end;
1216
1217 -- end if;
1218
1219 -- Serial rebuild number not instantiated status =1
1220 -- When a work order created on non instantiated rebuild serial number is released ,its must have an parent work order
1221 -- 3659469
1222
1223 -- Serial rebuild number is required while releasing the work order if Rebuild number is serial controlled
1224 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating if rebuild_serial_number is mandatory . . . '); END IF;
1225 BEGIN
1226 IF p_eam_wo_rec.status_type = 3
1227 and p_eam_wo_rec.rebuild_item_id IS NOT NULL
1228 and p_eam_wo_rec.rebuild_serial_number IS NULL
1229 and p_eam_wo_rec.maintenance_object_source = 1 THEN -- SKIP FOR CMRO
1230
1231 select serial_number_control_code
1232 into g_dummy
1233 from mtl_system_items msi, mtl_parameters mp
1234 where msi.inventory_item_id = p_eam_wo_rec.rebuild_item_id
1235 and msi.organization_id = mp.organization_id
1236 and mp.maint_organization_id = p_eam_wo_rec.organization_id and rownum = 1;
1237
1238 if g_dummy <> 1 then
1239 raise fnd_api.g_exc_unexpected_error;
1240 end if ;
1241
1242 END IF;
1243
1244 x_return_status := FND_API.G_RET_STS_SUCCESS;
1245
1246 exception
1247 when others then
1248
1249 l_token_tbl(1).token_name := 'Work_Order_Id';
1250 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
1251
1252 l_out_mesg_token_tbl := l_mesg_token_tbl;
1253 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1254 ( p_message_name => 'EAM_REBUILD_SER_REQD'
1255 , p_token_tbl => l_token_tbl
1256 , p_mesg_token_tbl => l_mesg_token_tbl
1257 , x_mesg_token_tbl => l_out_mesg_token_tbl
1258 );
1259 l_mesg_token_tbl := l_out_mesg_token_tbl;
1260
1261 x_return_status := FND_API.G_RET_STS_ERROR;
1262 x_mesg_token_tbl := l_mesg_token_tbl ;
1263 return;
1264
1265 end ;
1266
1267 -- parent_wip_entity_id
1268 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating parent_wip_entity_id . . . '); END IF;
1269
1270 begin
1271 /* Following validation ensures that only WO of parents of serialized
1272 rebuildables can become parent work orders of rebuild WO and any
1273 WO on asset and rebuildables can become Parent WO for non-serialized rebuilds */
1274
1275 l_rebuild_status := 0;
1276 /*Currently parent_wip_entity can only be specified for a rebuildable work order */
1277 if p_eam_wo_rec.parent_wip_entity_id is not null then
1278 IF p_eam_wo_rec.manual_rebuild_flag='Y' THEN /* Added if condition for bug no 3336489 */
1279
1280 IF ( p_eam_wo_rec.maintenance_object_type = 3 and p_eam_wo_rec.maintenance_object_source = 1)
1281 THEN
1282
1283 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating parent_wip_entity_id . rebuild status=' || l_rebuild_status); END IF;
1284
1285 SELECT 1
1286 INTO g_dummy
1287 FROM mtl_object_genealogy mog, mtl_serial_numbers msn, wip_discrete_jobs wdj,
1288 mtl_serial_numbers msn1, csi_item_instances cii, mtl_parameters mp, csi_item_instances cii1
1289 WHERE p_eam_wo_rec.rebuild_item_id is not null
1290 and cii.instance_id = p_eam_wo_rec.maintenance_object_id
1291 and cii.last_vld_organization_id = mp.organization_id
1292 and mp.maint_organization_id = p_eam_wo_rec.organization_id
1293 and nvl(cii.network_asset_flag,'N') = 'N'
1294 and msn.current_organization_id = cii.last_vld_organization_id
1295 and msn.serial_number = cii.serial_number
1296 and msn.inventory_item_id = cii.inventory_item_id
1297 and mog.object_id = msn.gen_object_id
1298 and mog.parent_object_id = msn1.gen_object_id
1299 and msn1.current_organization_id = mp.organization_id
1300 and cii1.serial_number = msn1.serial_number
1301 and cii1.inventory_item_id = msn1.inventory_item_id
1302 and cii1.last_vld_organization_id = msn1.current_organization_id
1303 and cii1.instance_id = wdj.maintenance_object_id
1304 and wdj.maintenance_object_type=3
1305 and wdj.status_type not in (5,12,14)
1306 and wdj.wip_entity_id = p_eam_wo_rec.parent_wip_entity_id
1307 and wdj.organization_id = p_eam_wo_rec.organization_id
1308 and mog.genealogy_type = 5
1309 and nvl(mog.start_date_active,sysdate) <= sysdate
1310 and nvl(mog.end_date_active,sysdate+1) > sysdate ;
1311
1312 ELSE
1313 SELECT 1 INTO
1314 g_dummy
1315 FROM wip_discrete_jobs
1316 WHERE
1317 p_eam_wo_rec.rebuild_item_id is not null
1318 and organization_id = p_eam_wo_rec.organization_id
1319 and wip_entity_id = p_eam_wo_rec.parent_wip_entity_id
1320 and status_type not in (5,12,14);
1321 END IF;
1322 END IF;
1323 end if;
1324
1325 x_return_status := FND_API.G_RET_STS_SUCCESS;
1326
1327 exception
1328 when others then
1329
1330 l_token_tbl(1).token_name := 'Parent Wip Entity Id';
1331 l_token_tbl(1).token_value := p_eam_wo_rec.parent_wip_entity_id;
1332
1333 l_out_mesg_token_tbl := l_mesg_token_tbl;
1334 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1335 ( p_message_name => 'EAM_WO_PARENT_WIP_ENTITY_ID'
1336 , p_token_tbl => l_token_tbl
1337 , p_mesg_token_tbl => l_mesg_token_tbl
1338 , x_mesg_token_tbl => l_out_mesg_token_tbl
1339 );
1340 l_mesg_token_tbl := l_out_mesg_token_tbl;
1341
1342 x_return_status := FND_API.G_RET_STS_ERROR;
1343 x_mesg_token_tbl := l_mesg_token_tbl ;
1344 return;
1345
1346 end;
1347
1348
1349 /* While updating parent_wip_entity_id check for any transactions posted on the work order */
1350
1351 begin
1352
1353 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
1354 AND p_old_eam_wo_rec.parent_wip_entity_id <> p_eam_wo_rec.parent_wip_entity_id )
1355 THEN
1356 EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
1357 X_Wip_Id => p_eam_wo_rec.wip_entity_id,
1358 X_Rep_Id => -1,
1359 X_Line_Id => -1,
1360 X_Ent_Type=> 6,
1361 X_Return_Status=>l_trans_exist);
1362
1363 IF(l_trans_exist='F') THEN
1364 raise fnd_api.g_exc_unexpected_error;
1365 END IF;
1366 END IF;
1367
1368 x_return_status := FND_API.G_RET_STS_SUCCESS;
1369
1370 exception
1371 when others then
1372
1373 l_token_tbl(1).token_name := 'Wip Entity Id';
1374 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
1375
1376 l_out_mesg_token_tbl := l_mesg_token_tbl;
1377 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1378 ( p_message_name => 'EAM_WO_TRANSACTIONS_EXIST'
1379 , p_token_tbl => l_token_tbl
1380 , p_mesg_token_tbl => l_mesg_token_tbl
1381 , x_mesg_token_tbl => l_out_mesg_token_tbl
1382 );
1383 l_mesg_token_tbl := l_out_mesg_token_tbl;
1384
1385 x_return_status := FND_API.G_RET_STS_ERROR;
1386 x_mesg_token_tbl := l_mesg_token_tbl ;
1387 return;
1388
1389 end;
1390
1391
1392
1393
1394 -- job_name
1395 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating wip_entity_name . . . '); END IF;
1396
1397 declare
1398 l_count NUMBER;
1399 begin
1400
1401 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
1402
1403 select count(*)
1404 into l_count
1405 from wip_entities
1406 where wip_entity_name = p_eam_wo_rec.wip_entity_name
1407 and organization_id = p_eam_wo_rec.organization_id;
1408
1409 if(l_count > 0) then
1410 raise fnd_api.g_exc_unexpected_error;
1411 end if;
1412
1413 end if;
1414
1415 x_return_status := FND_API.G_RET_STS_SUCCESS;
1416
1417 exception
1418 when fnd_api.g_exc_unexpected_error then
1419
1420 l_token_tbl(1).token_name := 'Wip Entity Name';
1421 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
1422
1423 l_out_mesg_token_tbl := l_mesg_token_tbl;
1424 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1425 ( p_message_name => 'EAM_WO_WIP_ENTITY_NAME'
1426 , p_token_tbl => l_token_tbl
1427 , p_mesg_token_tbl => l_mesg_token_tbl
1428 , x_mesg_token_tbl => l_out_mesg_token_tbl
1429 );
1430 l_mesg_token_tbl := l_out_mesg_token_tbl;
1431
1432 x_return_status := FND_API.G_RET_STS_ERROR;
1433 x_mesg_token_tbl := l_mesg_token_tbl ;
1434 return;
1435
1436 end;
1437
1438
1439 -- job_id
1440 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating wip_entity_id . . . '); END IF;
1441
1442 declare
1443 l_count NUMBER;
1444 begin
1445
1446 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
1447
1448 select count(*)
1449 into l_count
1450 from wip_entities
1451 where wip_entity_id = p_eam_wo_rec.wip_entity_id;
1452
1453 if(l_count > 0) then
1454 raise fnd_api.g_exc_unexpected_error;
1455 end if;
1456 end if;
1457
1458 x_return_status := FND_API.G_RET_STS_SUCCESS;
1459
1460 exception
1461 when fnd_api.g_exc_unexpected_error then
1462
1463 l_token_tbl(1).token_name := 'Wip Entity Id';
1464 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_id;
1465
1466 l_out_mesg_token_tbl := l_mesg_token_tbl;
1467 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1468 ( p_message_name => 'EAM_WO_WIP_ENTITY_ID'
1469 , p_token_tbl => l_token_tbl
1470 , p_mesg_token_tbl => l_mesg_token_tbl
1471 , x_mesg_token_tbl => l_out_mesg_token_tbl
1472 );
1473 l_mesg_token_tbl := l_out_mesg_token_tbl;
1474
1475 x_return_status := FND_API.G_RET_STS_ERROR;
1476 x_mesg_token_tbl := l_mesg_token_tbl ;
1477 return;
1478
1479 end;
1480
1481
1482 -- firm_planned_flag
1483 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating firm_planned_flag . . . '); END IF;
1484
1485 begin
1486
1487 if p_eam_wo_rec.firm_planned_flag not in (wip_constants.yes, wip_constants.no) then
1488
1489 raise fnd_api.g_exc_unexpected_error;
1490
1491 end if;
1492
1493 x_return_status := FND_API.G_RET_STS_SUCCESS;
1494
1495 exception
1496 when fnd_api.g_exc_unexpected_error then
1497
1498 l_token_tbl(1).token_name := 'Firm Planned Flag';
1499 l_token_tbl(1).token_value := p_eam_wo_rec.firm_planned_flag;
1500
1501 l_out_mesg_token_tbl := l_mesg_token_tbl;
1502 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1503 ( p_message_name => 'EAM_WO_FIRM_PLANNED_FLAG'
1504 , p_token_tbl => l_token_tbl
1505 , p_mesg_token_tbl => l_mesg_token_tbl
1506 , x_mesg_token_tbl => l_out_mesg_token_tbl
1507 );
1508 l_mesg_token_tbl := l_out_mesg_token_tbl;
1509
1510 x_return_status := FND_API.G_RET_STS_ERROR;
1511 x_mesg_token_tbl := l_mesg_token_tbl ;
1512 return;
1513
1514 end;
1515
1516
1517
1518 -- issue_zero_cost_flag
1519 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating wip_entity_name . . . '); END IF;
1520
1521 declare
1522 l_count NUMBER;
1523 begin
1524
1525 if upper(p_eam_wo_rec.issue_zero_cost_flag) not in ('Y','N') then
1526
1527 raise fnd_api.g_exc_unexpected_error;
1528
1529 end if;
1530
1531 x_return_status := FND_API.G_RET_STS_SUCCESS;
1532
1533 exception
1534 when fnd_api.g_exc_unexpected_error then
1535
1536 l_token_tbl(1).token_name := 'ISSUE_ZERO_FLAG';
1537 l_token_tbl(1).token_value := p_eam_wo_rec.issue_zero_cost_flag;
1538
1539 l_out_mesg_token_tbl := l_mesg_token_tbl;
1540 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1541 ( p_message_name => 'EAM_WO_ISSUE_ZERO_COST_FLAG'
1542 , p_token_tbl => l_token_tbl
1543 , p_mesg_token_tbl => l_mesg_token_tbl
1544 , x_mesg_token_tbl => l_out_mesg_token_tbl
1545 );
1546 l_mesg_token_tbl := l_out_mesg_token_tbl;
1547
1548 x_return_status := FND_API.G_RET_STS_ERROR;
1549 x_mesg_token_tbl := l_mesg_token_tbl ;
1550 return;
1551
1552 end;
1553
1554
1555
1556 -- schedule_group_id
1557 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating schedule_group_id . . . '); END IF;
1558 begin
1559
1560 if p_eam_wo_rec.schedule_group_id is not null then
1561
1562 select 1
1563 into g_dummy
1564 from wip_schedule_groups_val_v
1565 where schedule_group_id = p_eam_wo_rec.schedule_group_id
1566 and organization_id = p_eam_wo_rec.organization_id;
1567 end if;
1568
1569 x_return_status := FND_API.G_RET_STS_SUCCESS;
1570
1571 exception
1572 when no_data_found then
1573
1574 l_token_tbl(1).token_name := 'Schedule Group Id';
1575 l_token_tbl(1).token_value := p_eam_wo_rec.schedule_group_id;
1576
1577 l_out_mesg_token_tbl := l_mesg_token_tbl;
1578 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1579 ( p_message_name => 'EAM_WO_SCHEDULE_GROUP'
1580 , p_token_tbl => l_token_tbl
1581 , p_mesg_token_tbl => l_mesg_token_tbl
1582 , x_mesg_token_tbl => l_out_mesg_token_tbl
1583 );
1584 l_mesg_token_tbl := l_out_mesg_token_tbl;
1585
1586 x_return_status := FND_API.G_RET_STS_ERROR;
1587 x_mesg_token_tbl := l_mesg_token_tbl ;
1588 return;
1589
1590 end;
1591
1592 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('p_eam_wo_rec.status_type ' || p_eam_wo_rec.status_type); END IF;
1593 --attribute change not allowed for comp_no_chrg,closed,pending-close,failed-close and cancelled
1594 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating attribute change for complete_no_chrg,cancelled,closed,pending-cl,failed-close statuses');END IF;
1595 --start of fix for 3389850
1596
1597 begin
1598 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE )
1599 AND (p_eam_wo_rec.status_type IN (5,7,12,14,15)) --if status is complete-no-chrg,cancelled,closed,pending-close and failed-close
1600 AND (p_eam_wo_rec.status_type=p_old_eam_wo_rec.status_type) --status is same
1601 AND ( p_eam_wo_rec.description<>p_old_eam_wo_rec.description
1602 OR p_eam_wo_rec.asset_number<>p_old_eam_wo_rec.asset_number
1603 OR p_eam_wo_rec.asset_group_id<>p_old_eam_wo_rec.asset_group_id
1604 OR p_eam_wo_rec.rebuild_item_id<>p_old_eam_wo_rec.rebuild_item_id
1605 OR p_eam_wo_rec.rebuild_serial_number<>p_old_eam_wo_rec.rebuild_serial_number
1606 OR p_eam_wo_rec.maintenance_object_id<>p_old_eam_wo_rec.maintenance_object_id
1607 OR p_eam_wo_rec.maintenance_object_type<>p_old_eam_wo_rec.maintenance_object_type
1608 OR p_eam_wo_rec.maintenance_object_source<>p_old_eam_wo_rec.maintenance_object_source
1609 OR p_eam_wo_rec.eam_linear_location_id<>p_old_eam_wo_rec.eam_linear_location_id
1610 OR p_eam_wo_rec.notification_required<>p_old_eam_wo_rec.notification_required
1611 OR p_eam_wo_rec.class_code<>p_old_eam_wo_rec.class_code
1612 OR p_eam_wo_rec.asset_activity_id<>p_old_eam_wo_rec.asset_activity_id
1613 OR p_eam_wo_rec.activity_type<>p_old_eam_wo_rec.activity_type
1614 OR p_eam_wo_rec.activity_source<>p_old_eam_wo_rec.activity_source
1615 OR p_eam_wo_rec.activity_cause<>p_old_eam_wo_rec.activity_cause
1616 OR p_eam_wo_rec.work_order_type<>p_old_eam_wo_rec.work_order_type
1617 OR p_eam_wo_rec.status_type<>p_old_eam_wo_rec.status_type
1618 OR p_eam_wo_rec.job_quantity<>p_old_eam_wo_rec.job_quantity
1619 OR p_eam_wo_rec.date_released<>p_old_eam_wo_rec.date_released
1620 OR p_eam_wo_rec.owning_department<>p_old_eam_wo_rec.owning_department
1621 OR p_eam_wo_rec.priority<>p_old_eam_wo_rec.priority
1622 OR p_eam_wo_rec.requested_start_date<>p_old_eam_wo_rec.requested_start_date
1623 OR p_eam_wo_rec.due_date<>p_old_eam_wo_rec.due_date
1624 OR p_eam_wo_rec.shutdown_type<>p_old_eam_wo_rec.shutdown_type
1625 OR p_eam_wo_rec.firm_planned_flag<>p_old_eam_wo_rec.firm_planned_flag
1626 OR p_eam_wo_rec.tagout_required<>p_old_eam_wo_rec.tagout_required
1627 OR p_eam_wo_rec.plan_maintenance<>p_old_eam_wo_rec.plan_maintenance
1628 OR p_eam_wo_rec.project_id<>p_old_eam_wo_rec.project_id
1629 OR p_eam_wo_rec.task_id<>p_old_eam_wo_rec.task_id
1630 OR p_eam_wo_rec.end_item_unit_number<>p_old_eam_wo_rec.end_item_unit_number
1631 OR p_eam_wo_rec.schedule_group_id<>p_old_eam_wo_rec.schedule_group_id
1632 OR p_eam_wo_rec.bom_revision_date<>p_old_eam_wo_rec.bom_revision_date
1633 OR p_eam_wo_rec.routing_revision_date<>p_old_eam_wo_rec.routing_revision_date
1634 OR p_eam_wo_rec.alternate_bom_designator<>p_old_eam_wo_rec.alternate_bom_designator
1635 OR p_eam_wo_rec.alternate_routing_designator<>p_old_eam_wo_rec.alternate_routing_designator
1636 OR p_eam_wo_rec.bom_revision<>p_old_eam_wo_rec.bom_revision
1637 OR p_eam_wo_rec.routing_revision<>p_old_eam_wo_rec.routing_revision
1638 OR p_eam_wo_rec.parent_wip_entity_id<>p_old_eam_wo_rec.parent_wip_entity_id
1639 OR p_eam_wo_rec.manual_rebuild_flag<>p_old_eam_wo_rec.manual_rebuild_flag
1640 OR p_eam_wo_rec.pm_schedule_id<>p_old_eam_wo_rec.pm_schedule_id
1641 OR p_eam_wo_rec.wip_supply_type<>p_old_eam_wo_rec.wip_supply_type
1642 OR p_eam_wo_rec.material_account<>p_old_eam_wo_rec.material_account
1643 OR p_eam_wo_rec.material_overhead_account<>p_old_eam_wo_rec.material_overhead_account
1644 OR p_eam_wo_rec.resource_account<>p_old_eam_wo_rec.resource_account
1645 OR p_eam_wo_rec.outside_processing_account<>p_old_eam_wo_rec.outside_processing_account
1646 OR p_eam_wo_rec.material_variance_account<>p_old_eam_wo_rec.material_variance_account
1647 OR p_eam_wo_rec.resource_variance_account<>p_old_eam_wo_rec.resource_variance_account
1648 OR p_eam_wo_rec.outside_proc_variance_account<>p_old_eam_wo_rec.outside_proc_variance_account
1649 OR p_eam_wo_rec.std_cost_adjustment_account<>p_old_eam_wo_rec.std_cost_adjustment_account
1650 OR p_eam_wo_rec.overhead_account<>p_old_eam_wo_rec.overhead_account
1651 OR p_eam_wo_rec.overhead_variance_account<>p_old_eam_wo_rec.overhead_variance_account
1652 OR p_eam_wo_rec.scheduled_start_date<>p_old_eam_wo_rec.scheduled_start_date
1653 OR p_eam_wo_rec.scheduled_completion_date<>p_old_eam_wo_rec.scheduled_completion_date
1654 OR p_eam_wo_rec.common_bom_sequence_id<>p_old_eam_wo_rec.common_bom_sequence_id
1655 OR p_eam_wo_rec.common_routing_sequence_id<>p_old_eam_wo_rec.common_routing_sequence_id
1656 OR p_eam_wo_rec.po_creation_time<>p_old_eam_wo_rec.po_creation_time
1657 OR p_eam_wo_rec.gen_object_id<>p_old_eam_wo_rec.gen_object_id
1658 OR p_eam_wo_rec.attribute_category<>p_old_eam_wo_rec.attribute_category
1659 OR p_eam_wo_rec.attribute1<>p_old_eam_wo_rec.attribute1
1660 OR p_eam_wo_rec.attribute2<>p_old_eam_wo_rec.attribute2
1661 OR p_eam_wo_rec.attribute3<>p_old_eam_wo_rec.attribute3
1662 OR p_eam_wo_rec.attribute4<>p_old_eam_wo_rec.attribute4
1663 OR p_eam_wo_rec.attribute5<>p_old_eam_wo_rec.attribute5
1664 OR p_eam_wo_rec.attribute6<>p_old_eam_wo_rec.attribute6
1665 OR p_eam_wo_rec.attribute7<>p_old_eam_wo_rec.attribute7
1666 OR p_eam_wo_rec.attribute8<>p_old_eam_wo_rec.attribute8
1667 OR p_eam_wo_rec.attribute9<>p_old_eam_wo_rec.attribute9
1668 OR p_eam_wo_rec.attribute10<>p_old_eam_wo_rec.attribute10
1669 OR p_eam_wo_rec.attribute11<>p_old_eam_wo_rec.attribute11
1670 OR p_eam_wo_rec.attribute12<>p_old_eam_wo_rec.attribute12
1671 OR p_eam_wo_rec.attribute13<>p_old_eam_wo_rec.attribute13
1672 OR p_eam_wo_rec.attribute14<>p_old_eam_wo_rec.attribute14
1673 OR p_eam_wo_rec.attribute15<>p_old_eam_wo_rec.attribute15
1674 OR p_eam_wo_rec.material_issue_by_mo<>p_old_eam_wo_rec.material_issue_by_mo
1675 OR p_eam_wo_rec.issue_zero_cost_flag<>p_old_eam_wo_rec.issue_zero_cost_flag
1676 ) THEN
1677 raise fnd_api.g_exc_unexpected_error;
1678 END IF;
1679 exception
1680 when fnd_api.g_exc_unexpected_error then
1681 l_token_tbl(1).token_name := 'STATUS_TYPE';
1682 l_token_tbl(1).token_value := p_eam_wo_rec.status_type;
1683
1684 l_out_mesg_token_tbl := l_mesg_token_tbl;
1685 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1686 ( p_message_name => 'EAM_WO_CH_ATTR_DISALLOWED'
1687 , p_token_tbl => l_token_tbl
1688 , p_mesg_token_tbl => l_mesg_token_tbl
1689 , x_mesg_token_tbl => l_out_mesg_token_tbl
1690 );
1691 l_mesg_token_tbl := l_out_mesg_token_tbl;
1692
1693 x_return_status := FND_API.G_RET_STS_ERROR;
1694 x_mesg_token_tbl := l_mesg_token_tbl ;
1695 return;
1696 end;
1697
1698
1699 --end of fix for 3389850
1700
1701 -- status_type
1702 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating status_type . . . '); END IF;
1703
1704 declare
1705
1706 l_count number;
1707 l_parent_status number;
1708
1709 parent_not_released exception;
1710 child_released exception;
1711 ch_rel_par_canc exception;
1712
1713 begin
1714
1715 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE and
1716 p_eam_wo_rec.status_type not in (wip_constants.unreleased, wip_constants.released, wip_constants.hold, wip_constants.draft)) then
1717
1718 raise fnd_api.g_exc_unexpected_error;
1719
1720 elsif (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE) then
1721 if(p_eam_wo_rec.status_type not in (wip_constants.unreleased, wip_constants.released, wip_constants.comp_chrg,wip_constants.comp_nochrg, wip_constants.closed,
1722 wip_constants.hold, wip_constants.cancelled, wip_constants.pend_sched, wip_constants.draft)
1723 OR ( p_eam_wo_rec.status_type in (wip_constants.draft) and p_old_eam_wo_rec.status_type not in (wip_constants.draft))
1724 /* Added the check so that status will not be updated to status Draft */
1725 --fix for 3389850.cannot change status from complete_no_charges to any status other than complete,closed.cannot change to complete_no_charges from status other than
1726 --complete
1727 OR (p_old_eam_wo_rec.status_type=wip_constants.comp_nochrg AND p_eam_wo_rec.status_type NOT IN (wip_constants.comp_chrg,wip_constants.closed,wip_constants.comp_nochrg) )
1728 /* Bug 3431204 - Should be able to link a Complete No charges WO to another
1729 Complete NO Charges WO */
1730 OR (p_eam_wo_rec.status_type=wip_constants.comp_nochrg
1731 AND p_old_eam_wo_rec.status_type NOT IN
1732 (wip_constants.comp_chrg, wip_constants.comp_nochrg,wip_constants.closed,wip_constants.fail_close))) then
1733
1734 raise fnd_api.g_exc_unexpected_error;
1735
1736 end if;
1737
1738 end if;
1739
1740
1741 x_return_status := FND_API.G_RET_STS_SUCCESS;
1742
1743 exception
1744
1745 when fnd_api.g_exc_unexpected_error then
1746
1747 l_token_tbl(1).token_name := 'Status type';
1748 l_token_tbl(1).token_value := p_eam_wo_rec.status_type;
1749
1750 l_out_mesg_token_tbl := l_mesg_token_tbl;
1751 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1752 ( p_message_name => 'EAM_WO_STATUS_TYPE'
1753 , p_token_tbl => l_token_tbl
1754 , p_mesg_token_tbl => l_mesg_token_tbl
1755 , x_mesg_token_tbl => l_out_mesg_token_tbl
1756 );
1757 l_mesg_token_tbl := l_out_mesg_token_tbl;
1758
1759 x_return_status := FND_API.G_RET_STS_ERROR;
1760 x_mesg_token_tbl := l_mesg_token_tbl ;
1761 return;
1762
1763 end;
1764
1765
1766 -- job_quantity
1767 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating job_quantity . . . '); END IF;
1768
1769 begin
1770
1771 if(p_eam_wo_rec.job_quantity <> 1) then
1772 raise fnd_api.g_exc_unexpected_error;
1773 end if;
1774
1775 x_return_status := FND_API.G_RET_STS_SUCCESS;
1776
1777 exception
1778 when fnd_api.g_exc_unexpected_error then
1779
1780 l_token_tbl(1).token_name := 'Job Quantity';
1781 l_token_tbl(1).token_value := p_eam_wo_rec.job_quantity;
1782
1783 l_out_mesg_token_tbl := l_mesg_token_tbl;
1784 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1785 ( p_message_name => 'EAM_WO_JOB_QUANTITY'
1786 , p_token_tbl => l_token_tbl
1787 , p_mesg_token_tbl => l_mesg_token_tbl
1788 , x_mesg_token_tbl => l_out_mesg_token_tbl
1789 );
1790 l_mesg_token_tbl := l_out_mesg_token_tbl;
1791
1792 x_return_status := FND_API.G_RET_STS_ERROR;
1793 x_mesg_token_tbl := l_mesg_token_tbl ;
1794 return;
1795
1796 end;
1797
1798
1799 -- primary_item_id (asset activity)
1800 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating asset_activity_id . . . '); END IF;
1801
1802 declare
1803 l_eam_op_tbl EAM_PROCESS_WO_PUB.EAM_OP_TBL_TYPE;
1804 l_mat_req_exists number;
1805 l_serial_number_control NUMBER := 0;
1806 l_count NUMBER := 0;
1807
1808 ACTIVITY_WO_EXISTS EXCEPTION;
1809 begin
1810 -- # 3436679 code added to prevent the defaulting of the asset activity if user removes it while updating work order
1811 if p_eam_wo_rec.asset_activity_id is not null and p_eam_wo_rec.asset_activity_id <> FND_API.G_MISS_NUM then
1812
1813 select 1
1814 into g_dummy
1815 from mtl_system_items
1816 where organization_id = p_eam_wo_rec.organization_id
1817 and inventory_item_id = p_eam_wo_rec.asset_activity_id
1818 and eam_item_type = 2;
1819
1820 -- asset activity should not allowed to be updated if the wo has any ops or mat reqs.
1821 select count(*) into l_mat_req_exists from wip_requirement_operations
1822 where wip_entity_id = p_eam_wo_rec.wip_entity_id
1823 and organization_id = p_eam_wo_rec.organization_id;
1824
1825 if nvl(p_eam_wo_rec.asset_activity_id,-99999) <> nvl(p_old_eam_wo_rec.asset_activity_id,-99999)
1826 and p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
1827 and (EAM_OP_UTILITY_PVT.NUM_OF_ROW(
1828 p_eam_op_tbl => l_eam_op_tbl
1829 ,p_wip_entity_id => p_eam_wo_rec.wip_entity_id
1830 ,p_organization_id => p_eam_wo_rec.organization_id) = false
1831 or l_mat_req_exists <> 0) then
1832 raise fnd_api.g_exc_unexpected_error;
1833 end if;
1834
1835
1836 end if;
1837
1838 x_return_status := FND_API.G_RET_STS_SUCCESS;
1839
1840 exception
1841 when fnd_api.g_exc_unexpected_error then
1842
1843 l_out_mesg_token_tbl := l_mesg_token_tbl;
1844 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1845 ( p_message_name => 'EAM_CANT_UPDATE_ACTIVITY'
1846 , p_token_tbl => l_token_tbl
1847 , p_mesg_token_tbl => l_mesg_token_tbl
1848 , x_mesg_token_tbl => l_out_mesg_token_tbl
1849 );
1850 l_mesg_token_tbl := l_out_mesg_token_tbl;
1851
1852 x_return_status := FND_API.G_RET_STS_ERROR;
1853 x_mesg_token_tbl := l_mesg_token_tbl ;
1854 return;
1855
1856 when ACTIVITY_WO_EXISTS then
1857
1858 l_out_mesg_token_tbl := l_mesg_token_tbl;
1859 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1860 ( p_message_name => 'EAM_ACTIVITY_WO_EXISTS'
1861 , p_token_tbl => l_token_tbl
1862 , p_mesg_token_tbl => l_mesg_token_tbl
1863 , x_mesg_token_tbl => l_out_mesg_token_tbl
1864 );
1865 l_mesg_token_tbl := l_out_mesg_token_tbl;
1866
1867 x_return_status := FND_API.G_RET_STS_ERROR;
1868 x_mesg_token_tbl := l_mesg_token_tbl ;
1869 return;
1870
1871 when others then
1872
1873 l_token_tbl(1).token_name := 'Asset Activity Id';
1874 l_token_tbl(1).token_value := p_eam_wo_rec.asset_activity_id;
1875
1876 l_out_mesg_token_tbl := l_mesg_token_tbl;
1877 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1878 ( p_message_name => 'EAM_WO_ASSET_ACTIVITY'
1879 , p_token_tbl => l_token_tbl
1880 , p_mesg_token_tbl => l_mesg_token_tbl
1881 , x_mesg_token_tbl => l_out_mesg_token_tbl
1882 );
1883 l_mesg_token_tbl := l_out_mesg_token_tbl;
1884
1885 x_return_status := FND_API.G_RET_STS_ERROR;
1886 x_mesg_token_tbl := l_mesg_token_tbl ;
1887 return;
1888
1889 end;
1890
1891
1892
1893 -- asset activity association
1894
1895 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating asset_activity_association . . . '); END IF;
1896
1897 declare
1898 l_start_date DATE;
1899 l_end_date DATE;
1900
1901 begin
1902 -- # 3436679 code added to prevent the defaulting of the asset activity if user removes it while updating work order
1903 if (p_eam_wo_rec.asset_activity_id is not null and p_eam_wo_rec.asset_activity_id <> FND_API.G_MISS_NUM and p_eam_wo_rec.maintenance_object_source = 1) then
1904
1905 if (p_eam_wo_rec.maintenance_object_type = 3) then
1906
1907 select meaa.start_date_active, meaa.end_date_active
1908 into l_start_date, l_end_date
1909 from mtl_eam_asset_activities meaa, mtl_system_items msi
1910 where meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
1911 and meaa.maintenance_object_type = 3
1912 and nvl(meaa.tmpl_flag, 'N') = 'N'
1913 and meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id
1914 and msi.inventory_item_id = p_eam_wo_rec.asset_activity_id
1915 and msi.organization_id = p_eam_wo_rec.organization_id;
1916
1917 else
1918
1919 if (p_eam_wo_rec.maintenance_object_type = 2) then
1920
1921 select min(meaa.start_date_active), min(meaa.end_date_active)
1922 into l_start_date, l_end_date
1923 from mtl_eam_asset_activities meaa,mtl_system_items msi
1924 where meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
1925 and meaa.maintenance_object_type = 2
1926 and meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id
1927 and msi.organization_id = p_eam_wo_rec.organization_id
1928 and msi.inventory_item_id = p_eam_wo_rec.asset_activity_id
1929 and nvl(meaa.tmpl_flag, 'N') = 'N';
1930 end if;
1931
1932 end if;
1933
1934 if(l_start_date is not null and
1935 l_start_date > nvl(p_eam_wo_rec.requested_start_date, p_eam_wo_rec.due_date)) then
1936 raise l_wo_asset_activity_err;
1937 end if;
1938
1939 if(l_end_date is not null and
1940 l_end_date < nvl(p_eam_wo_rec.due_date, p_eam_wo_rec.requested_start_date)) then
1941 raise l_wo_asset_activity_err;
1942 end if;
1943
1944 end if;
1945
1946 x_return_status := FND_API.G_RET_STS_SUCCESS;
1947
1948 exception
1949 WHEN l_wo_asset_activity_err THEN
1950
1951 l_out_mesg_token_tbl := l_mesg_token_tbl;
1952 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1953 ( p_message_name => 'EAM_WO_ASSET_ACTIVITY_DATES'
1954 , p_token_tbl => l_token_tbl
1955 , p_mesg_token_tbl => l_mesg_token_tbl
1956 , x_mesg_token_tbl => l_out_mesg_token_tbl
1957 );
1958 l_mesg_token_tbl := l_out_mesg_token_tbl;
1959
1960 x_return_status := FND_API.G_RET_STS_ERROR;
1961 x_mesg_token_tbl := l_mesg_token_tbl ;
1962 return;
1963
1964 when others then
1965
1966 l_token_tbl(1).token_name := 'Asset Activity Id';
1967 l_token_tbl(1).token_value := p_eam_wo_rec.asset_activity_id;
1968
1969 l_out_mesg_token_tbl := l_mesg_token_tbl;
1970 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1971 ( p_message_name => 'EAM_WO_ASSET_ACTIVITY_ASSOC'
1972 , p_token_tbl => l_token_tbl
1973 , p_mesg_token_tbl => l_mesg_token_tbl
1974 , x_mesg_token_tbl => l_out_mesg_token_tbl
1975 );
1976 l_mesg_token_tbl := l_out_mesg_token_tbl;
1977
1978 x_return_status := FND_API.G_RET_STS_ERROR;
1979 x_mesg_token_tbl := l_mesg_token_tbl ;
1980 return;
1981
1982 end;
1983
1984
1985 -- wip_supply_type
1986 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating wip_supply_type . . . '); END IF;
1987
1988 begin
1989
1990 if(p_eam_wo_rec.wip_supply_type is not null and p_eam_wo_rec.wip_supply_type not in (wip_constants.push, wip_constants.bulk, wip_constants.based_on_bom)) then
1991 --not a valid supply type
1992
1993 raise fnd_api.g_exc_unexpected_error;
1994
1995 end if;
1996
1997 x_return_status := FND_API.G_RET_STS_SUCCESS;
1998
1999 exception
2000 when fnd_api.g_exc_unexpected_error then
2001
2002 l_token_tbl(1).token_name := 'Wip Supply Type';
2003 l_token_tbl(1).token_value := p_eam_wo_rec.wip_supply_type;
2004
2005 l_out_mesg_token_tbl := l_mesg_token_tbl;
2006 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2007 ( p_message_name => 'EAM_WO_WIP_SUPPLY_TYPE'
2008 , p_token_tbl => l_token_tbl
2009 , p_mesg_token_tbl => l_mesg_token_tbl
2010 , x_mesg_token_tbl => l_out_mesg_token_tbl
2011 );
2012 l_mesg_token_tbl := l_out_mesg_token_tbl;
2013
2014 x_return_status := FND_API.G_RET_STS_ERROR;
2015 x_mesg_token_tbl := l_mesg_token_tbl ;
2016 return;
2017
2018 end;
2019
2020
2021 -- alternate_routing_designator
2022 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating alternate_routing_designator . . . '); END IF;
2023
2024 begin
2025
2026 if p_eam_wo_rec.alternate_routing_designator is not null then
2027
2028 select 1
2029 into g_dummy
2030 from bom_routing_alternates_v
2031 where assembly_item_id = p_eam_wo_rec.asset_activity_id
2032 and alternate_routing_designator = p_eam_wo_rec.alternate_routing_designator
2033 and organization_id = p_eam_wo_rec.organization_id
2034 and routing_type = 1;
2035
2036 end if;
2037
2038 x_return_status := FND_API.G_RET_STS_SUCCESS;
2039
2040 exception
2041 when no_data_found then
2042
2043 l_token_tbl(1).token_name := 'Alternate Routing Designator';
2044 l_token_tbl(1).token_value := p_eam_wo_rec.alternate_routing_designator;
2045
2046 l_out_mesg_token_tbl := l_mesg_token_tbl;
2047 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2048 ( p_message_name => 'EAM_WO_ALTERNATE_ROUTING'
2049 , p_token_tbl => l_token_tbl
2050 , p_mesg_token_tbl => l_mesg_token_tbl
2051 , x_mesg_token_tbl => l_out_mesg_token_tbl
2052 );
2053 l_mesg_token_tbl := l_out_mesg_token_tbl;
2054
2055 x_return_status := FND_API.G_RET_STS_ERROR;
2056 x_mesg_token_tbl := l_mesg_token_tbl ;
2057 return;
2058
2059 end;
2060
2061 -- alternate_bom_designator
2062 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating alternate_bom_designator . . . '); END IF;
2063
2064 begin
2065
2066 if p_eam_wo_rec.alternate_bom_designator is not null then
2067
2068 select 1
2069 into g_dummy
2070 from bom_bill_alternates_v
2071 where assembly_item_id = p_eam_wo_rec.asset_activity_id
2072 and alternate_bom_designator = p_eam_wo_rec.alternate_bom_designator
2073 and organization_id = p_eam_wo_rec.organization_id
2074 and assembly_type = 1;
2075
2076 end if;
2077
2078 x_return_status := FND_API.G_RET_STS_SUCCESS;
2079
2080 exception
2081 when no_data_found then
2082
2083 l_token_tbl(1).token_name := 'Alternate BOM Designator';
2084 l_token_tbl(1).token_value := p_eam_wo_rec.alternate_bom_designator;
2085
2086 l_out_mesg_token_tbl := l_mesg_token_tbl;
2087 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2088 ( p_message_name => 'EAM_WO_ALTERNATE_BOM'
2089 , p_token_tbl => l_token_tbl
2090 , p_mesg_token_tbl => l_mesg_token_tbl
2091 , x_mesg_token_tbl => l_out_mesg_token_tbl
2092 );
2093 l_mesg_token_tbl := l_out_mesg_token_tbl;
2094
2095 x_return_status := FND_API.G_RET_STS_ERROR;
2096 x_mesg_token_tbl := l_mesg_token_tbl ;
2097 return;
2098
2099 end;
2100
2101 -- project_id
2102 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating project_id . . . '); END IF;
2103
2104 declare
2105
2106 l_min_date DATE;
2107
2108 begin
2109
2110 IF p_eam_wo_rec.scheduled_start_date >= sysdate THEN
2111 l_min_date := sysdate;
2112 ELSE
2113 l_min_date := p_eam_wo_rec.scheduled_start_date;
2114 END IF;
2115
2116 IF ((p_eam_wo_rec.project_id IS NOT NULL AND p_old_eam_wo_rec.project_id is null) OR
2117 (p_eam_wo_rec.project_id <> p_old_eam_wo_rec.project_id) OR
2118 (p_eam_wo_rec.status_type = 3 and p_old_eam_wo_rec.status_type in (17,1,6)
2119 and p_eam_wo_rec.project_id is not null
2120 ))
2121 THEN
2122 SELECT distinct mpv.project_id --this query will return multiple rows if the project has tasks
2123 INTO g_dummy
2124 FROM mtl_project_v mpv, pjm_project_parameters_v ppp, mtl_parameters mp
2125 WHERE mpv.project_id = ppp.project_id
2126 AND mpv.project_id = p_eam_wo_rec.project_id
2127 AND ppp.organization_id = p_eam_wo_rec.organization_id
2128 AND ppp.organization_id = mp.organization_id
2129 AND nvl(mp.project_reference_enabled, 2) = wip_constants.yes
2130 /* Commented for bug#5346213 Start
2131 AND (mpv.completion_date IS NULL OR mpv.completion_date >= l_min_date)
2132 AND (ppp.end_date_active IS NULL OR ppp.end_date_active >= l_min_date);
2133 Commented for bug#5346213 End */
2134 /* Added for bug#5346213 Start */
2135 AND (mpv.completion_date IS NULL OR trunc(mpv.completion_date) >= trunc(l_min_date))
2136 AND (ppp.end_date_active IS NULL OR trunc(ppp.end_date_active) >= trunc(l_min_date));
2137 /* Added for bug#5346213 End */
2138
2139 END IF;
2140 x_return_status := FND_API.G_RET_STS_SUCCESS;
2141
2142 exception
2143 when no_data_found then
2144
2145 l_token_tbl(1).token_name := 'Project Id';
2146 l_token_tbl(1).token_value := p_eam_wo_rec.project_id;
2147
2148 l_out_mesg_token_tbl := l_mesg_token_tbl;
2149 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2150 ( p_message_name => 'EAM_WO_PROJECT_ID'
2151 , p_token_tbl => l_token_tbl
2152 , p_mesg_token_tbl => l_mesg_token_tbl
2153 , x_mesg_token_tbl => l_out_mesg_token_tbl
2154 );
2155 l_mesg_token_tbl := l_out_mesg_token_tbl;
2156
2157 x_return_status := FND_API.G_RET_STS_ERROR;
2158 x_mesg_token_tbl := l_mesg_token_tbl ;
2159 return;
2160
2161 end;
2162
2163
2164 -- task_id
2165 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating task_id . . . '); END IF;
2166
2167 declare
2168
2169 l_min_date DATE;
2170
2171 begin
2172 IF (p_eam_wo_rec.task_id IS NOT NULL) THEN
2173 SELECT 1
2174 INTO g_dummy
2175 FROM pjm_tasks_v
2176 WHERE project_id = p_eam_wo_rec.project_id
2177 AND task_id = p_eam_wo_rec.task_id;
2178
2179 IF p_eam_wo_rec.scheduled_start_date >= sysdate THEN
2180 l_min_date := sysdate;
2181 ELSE
2182 l_min_date := p_eam_wo_rec.scheduled_start_date;
2183 END IF;
2184
2185 /* IF p_eam_wo_rec.status_type = 3 and p_old_eam_wo_rec.status_type in (17,1,6) THEN Commented for bug#5346213 */
2186 /* Added for bug#5346213 Start */
2187 IF p_eam_wo_rec.status_type = 3 and ( p_old_eam_wo_rec.status_type in (17,1,6) OR p_old_eam_wo_rec.status_type IS NULL ) THEN
2188 /* Added for bug#5346213 End */
2189 SELECT 1
2190 INTO g_dummy
2191 FROM pjm_tasks_v
2192 WHERE project_id = p_eam_wo_rec.project_id
2193 AND task_id = p_eam_wo_rec.task_id
2194 /* AND (completion_date IS NULL OR completion_date >= l_min_date); Commented for bug#5346213 */
2195 AND (completion_date IS NULL OR trunc(completion_date) >= trunc(l_min_date)); /* Added for bug#5346213 */
2196
2197 END IF;
2198
2199 END IF;
2200 x_return_status := FND_API.G_RET_STS_SUCCESS;
2201
2202 exception
2203 when no_data_found then
2204
2205 l_token_tbl(1).token_name := 'Task Id';
2206 l_token_tbl(1).token_value := p_eam_wo_rec.task_id;
2207
2208 l_out_mesg_token_tbl := l_mesg_token_tbl;
2209 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2210 ( p_message_name => 'EAM_WO_TASK_ID'
2211 , p_token_tbl => l_token_tbl
2212 , p_mesg_token_tbl => l_mesg_token_tbl
2213 , x_mesg_token_tbl => l_out_mesg_token_tbl
2214 );
2215 l_mesg_token_tbl := l_out_mesg_token_tbl;
2216
2217 x_return_status := FND_API.G_RET_STS_ERROR;
2218 x_mesg_token_tbl := l_mesg_token_tbl ;
2219 return;
2220
2221 end;
2222
2223
2224
2225 -- schedule_dates 0
2226
2227 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating PM Suggested dates . . . '); END IF;
2228
2229 begin
2230
2231 if p_eam_wo_rec.pm_suggested_start_date is not null and
2232 p_eam_wo_rec.pm_suggested_end_date is not null then
2233
2234 raise fnd_api.g_exc_unexpected_error;
2235
2236 end if;
2237
2238 x_return_status := FND_API.G_RET_STS_SUCCESS;
2239
2240 exception
2241 when fnd_api.g_exc_unexpected_error then
2242
2243 l_token_tbl(1).token_name := 'Wip Entity Name';
2244 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
2245
2246 l_out_mesg_token_tbl := l_mesg_token_tbl;
2247 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2248 ( p_message_name => 'EAM_WO_TOO_MANY_PM_DATE'
2249 , p_token_tbl => l_token_tbl
2250 , p_mesg_token_tbl => l_mesg_token_tbl
2251 , x_mesg_token_tbl => l_out_mesg_token_tbl
2252 );
2253 l_mesg_token_tbl := l_out_mesg_token_tbl;
2254
2255 x_return_status := FND_API.G_RET_STS_ERROR;
2256 x_mesg_token_tbl := l_mesg_token_tbl ;
2257 return;
2258
2259 end;
2260
2261
2262 -- schedule_dates 1
2263
2264 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating due_date, requested_start_date . . . '); END IF;
2265
2266 begin
2267
2268 if p_eam_wo_rec.due_date is not null and
2269 p_eam_wo_rec.requested_start_date is not null then
2270
2271 raise fnd_api.g_exc_unexpected_error;
2272
2273 end if;
2274
2275 x_return_status := FND_API.G_RET_STS_SUCCESS;
2276
2277 exception
2278 when fnd_api.g_exc_unexpected_error then
2279
2280 l_token_tbl(1).token_name := 'Wip Entity Name';
2281 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
2282
2283 l_out_mesg_token_tbl := l_mesg_token_tbl;
2284 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2285 ( p_message_name => 'EAM_WO_TOO_MANY_DATE'
2286 , p_token_tbl => l_token_tbl
2287 , p_mesg_token_tbl => l_mesg_token_tbl
2288 , x_mesg_token_tbl => l_out_mesg_token_tbl
2289 );
2290 l_mesg_token_tbl := l_out_mesg_token_tbl;
2291
2292 x_return_status := FND_API.G_RET_STS_ERROR;
2293 x_mesg_token_tbl := l_mesg_token_tbl ;
2294 return;
2295
2296 end;
2297
2298
2299 -- schedule_dates 2
2300
2301 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating due_date, requested_start_date . . . '); END IF;
2302
2303 begin
2304
2305 if p_eam_wo_rec.due_date is null and
2306 p_eam_wo_rec.requested_start_date is null then
2307
2308 raise fnd_api.g_exc_unexpected_error;
2309
2310 end if;
2311
2312 x_return_status := FND_API.G_RET_STS_SUCCESS;
2313
2314 exception
2315 when fnd_api.g_exc_unexpected_error then
2316
2317 l_token_tbl(1).token_name := 'Wip Entity Name';
2318 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
2319
2320 l_out_mesg_token_tbl := l_mesg_token_tbl;
2321 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2322 ( p_message_name => 'EAM_WO_NEED_DATE'
2323 , p_token_tbl => l_token_tbl
2324 , p_mesg_token_tbl => l_mesg_token_tbl
2325 , x_mesg_token_tbl => l_out_mesg_token_tbl
2326 );
2327 l_mesg_token_tbl := l_out_mesg_token_tbl;
2328
2329 x_return_status := FND_API.G_RET_STS_ERROR;
2330 x_mesg_token_tbl := l_mesg_token_tbl ;
2331 return;
2332
2333 end;
2334
2335
2336 -- schedule_dates 3
2337 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating schedule_dates . . . '); END IF;
2338
2339 declare
2340 l_rtg_count NUMBER;
2341 l_date_count NUMBER := 0;
2342 begin
2343
2344 if p_eam_wo_rec.requested_start_date is not null then
2345 l_date_count := l_date_count + 1;
2346 end if;
2347
2348 if p_eam_wo_rec.due_date is not null then
2349 l_date_count := l_date_count + 1;
2350 end if;
2351
2352 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE and l_date_count = 0) then
2353 --all job creations must have at least one date
2354 raise fnd_api.g_exc_unexpected_error;
2355 end if;
2356
2357 if p_eam_wo_rec.requested_start_date is not null then
2358
2359 select 1
2360 into g_dummy
2361 from bom_calendar_dates bcd, mtl_parameters mp
2362 where mp.organization_id = p_eam_wo_rec.organization_id
2363 and mp.calendar_code = bcd.calendar_code
2364 and mp.calendar_exception_set_id = bcd.exception_set_id
2365 and bcd.calendar_date = trunc(p_eam_wo_rec.requested_start_date);
2366 end if;
2367
2368 if p_eam_wo_rec.due_date is not null then
2369 select 1
2370 into g_dummy
2371 from bom_calendar_dates bcd, mtl_parameters mp
2372 where mp.organization_id = p_eam_wo_rec.organization_id
2373 and mp.calendar_code = bcd.calendar_code
2374 and mp.calendar_exception_set_id = bcd.exception_set_id
2375 and bcd.calendar_date = trunc(p_eam_wo_rec.due_date);
2376 end if;
2377
2378 x_return_status := FND_API.G_RET_STS_SUCCESS;
2379
2380 exception
2381 when others then
2382
2383 l_token_tbl(1).token_name := 'Scheduled Start Date';
2384 l_token_tbl(1).token_value := p_eam_wo_rec.scheduled_start_date;
2385
2386 l_out_mesg_token_tbl := l_mesg_token_tbl;
2387 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2388 ( p_message_name => 'EAM_WO_SCHEDULE_DATE'
2389 , p_token_tbl => l_token_tbl
2390 , p_mesg_token_tbl => l_mesg_token_tbl
2391 , x_mesg_token_tbl => l_out_mesg_token_tbl
2392 );
2393 l_mesg_token_tbl := l_out_mesg_token_tbl;
2394
2395 x_return_status := FND_API.G_RET_STS_ERROR;
2396 x_mesg_token_tbl := l_mesg_token_tbl ;
2397 return;
2398
2399 end;
2400 --start of fix for 3396136
2401 begin
2402 IF(p_eam_wo_rec.scheduled_start_date IS NOT NULL)
2403 AND (p_eam_wo_rec.scheduled_completion_date IS NOT NULL)
2404 AND (p_eam_wo_rec.scheduled_start_date > p_eam_wo_rec.scheduled_completion_date) THEN
2405 raise fnd_api.g_exc_unexpected_error;
2406 END IF;
2407 exception
2408 when fnd_api.g_exc_unexpected_error then
2409 l_out_mesg_token_tbl := l_mesg_token_tbl;
2410 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2411 ( p_message_name => 'EAM_WO_SCHEDULE_DATE_MORE'
2412 , p_token_tbl => l_token_tbl
2413 , p_mesg_token_tbl => l_mesg_token_tbl
2414 , x_mesg_token_tbl => l_out_mesg_token_tbl
2415 );
2416 l_mesg_token_tbl := l_out_mesg_token_tbl;
2417
2418 x_return_status := FND_API.G_RET_STS_ERROR;
2419 x_mesg_token_tbl := l_mesg_token_tbl ;
2420 return;
2421 end;
2422 --end of fix for 3396136
2423
2424
2425 -- end_item_unit_number
2426 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating end_item_unit_number . . . '); END IF;
2427
2428 declare
2429 is_unit_effective_item boolean;
2430 l_bom_item_id NUMBER;
2431 begin
2432
2433 -- Unit number is required for unit effective assemblies.
2434 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
2435
2436 if(is_unit_effective_item and p_eam_wo_rec.end_item_unit_number is null) then
2437 fnd_message.set_name('PJM', 'UEFF-UNIT NUMBER REQUIRED');
2438 end if;
2439
2440 end if;
2441
2442 -- If the assembly item is unit effective, validate the actual
2443 -- unit number value. The unit number must exist in the same _master_
2444 -- organization as the item. (We already validate that the item
2445 -- is in the organization identified by the ORGANIZATION_ID column.)
2446 if(is_unit_effective_item and p_eam_wo_rec.end_item_unit_number is not null) then
2447 select 1
2448 into g_dummy
2449 from pjm_unit_numbers_lov_v pun,
2450 mtl_parameters mp
2451 where pun.unit_number = p_eam_wo_rec.end_item_unit_number
2452 and mp.organization_id = p_eam_wo_rec.organization_id
2453 and mp.master_organization_id = pun.master_organization_id;
2454 end if;
2455
2456 x_return_status := FND_API.G_RET_STS_SUCCESS;
2457
2458 exception
2459 when too_many_rows then
2460 null; -- the query returning multiple rows is ok
2461 when others then
2462 -- fnd_message.set_name('PJM', 'UEFF-UNIT NUMBER INVALID') ;
2463
2464 l_token_tbl(1).token_name := 'Unit Number';
2465 l_token_tbl(1).token_value := p_eam_wo_rec.end_item_unit_number;
2466
2467 l_out_mesg_token_tbl := l_mesg_token_tbl;
2468 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2469 ( p_message_name => 'EAM_WO_UNIT_NUMBER'
2470 , p_token_tbl => l_token_tbl
2471 , p_mesg_token_tbl => l_mesg_token_tbl
2472 , x_mesg_token_tbl => l_out_mesg_token_tbl
2473 );
2474 l_mesg_token_tbl := l_out_mesg_token_tbl;
2475
2476 x_return_status := FND_API.G_RET_STS_ERROR;
2477 x_mesg_token_tbl := l_mesg_token_tbl ;
2478 return;
2479
2480 end;
2481
2482
2483 -- class_code
2484 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating class_code . . . '); END IF;
2485
2486 declare
2487 l_disable_date date;
2488 WO_CANT_CH_WIPACCT exception;
2489 begin
2490 if (p_eam_wo_rec.class_code is null) then
2491 raise fnd_api.g_exc_unexpected_error;
2492 end if;
2493
2494 if p_eam_wo_rec.class_code is not null then
2495
2496 select disable_date
2497 into l_disable_date
2498 from wip_accounting_classes
2499 where class_code = p_eam_wo_rec.class_code
2500 and class_type = wip_constants.eam
2501 and organization_id = p_eam_wo_rec.organization_id;
2502
2503 if(l_disable_date is not null and
2504 l_disable_date < nvl(p_eam_wo_rec.due_date, p_eam_wo_rec.requested_start_date)) then
2505 raise fnd_api.g_exc_unexpected_error;
2506 end if;
2507
2508 end if;
2509
2510 -- bug no 3905702
2511 if p_old_eam_wo_rec.class_code <> p_eam_wo_rec.class_code then
2512
2513 EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
2514 X_Wip_Id => p_eam_wo_rec.wip_entity_id,
2515 X_Rep_Id => -1,
2516 X_Line_Id => -1,
2517 X_Ent_Type=> 6,
2518 X_Return_Status=>l_trans_exist);
2519
2520 IF(l_trans_exist='F') THEN
2521 raise WO_CANT_CH_WIPACCT;
2522 END IF;
2523 end if;
2524
2525 x_return_status := FND_API.G_RET_STS_SUCCESS;
2526
2527 exception
2528
2529 when WO_CANT_CH_WIPACCT then
2530
2531 l_out_mesg_token_tbl := l_mesg_token_tbl;
2532 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2533 ( p_message_name => 'EAM_WIPACT_CANNOT_CH'
2534 , p_token_tbl => l_token_tbl
2535 , p_mesg_token_tbl => l_mesg_token_tbl
2536 , x_mesg_token_tbl => l_out_mesg_token_tbl
2537 );
2538 l_mesg_token_tbl := l_out_mesg_token_tbl;
2539
2540 x_return_status := FND_API.G_RET_STS_ERROR;
2541 x_mesg_token_tbl := l_mesg_token_tbl ;
2542 return;
2543
2544 when others then
2545
2546 l_token_tbl(1).token_name := 'Class Code';
2547 l_token_tbl(1).token_value := p_eam_wo_rec.class_code;
2548
2549 l_out_mesg_token_tbl := l_mesg_token_tbl;
2550 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2551 ( p_message_name => 'EAM_WO_CLASS_CODE'
2552 , p_token_tbl => l_token_tbl
2553 , p_mesg_token_tbl => l_mesg_token_tbl
2554 , x_mesg_token_tbl => l_out_mesg_token_tbl
2555 );
2556 l_mesg_token_tbl := l_out_mesg_token_tbl;
2557
2558 x_return_status := FND_API.G_RET_STS_ERROR;
2559 x_mesg_token_tbl := l_mesg_token_tbl ;
2560 return;
2561
2562 end;
2563
2564
2565 -- bom_revision
2566 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating bom_revision . . . '); END IF;
2567
2568 declare
2569 l_start_date DATE;
2570 begin
2571
2572 l_start_date := greatest(p_eam_wo_rec.requested_start_date, sysdate);
2573 /*
2574 wip_revisions.bom_revision(p_organization_id => p_eam_wo_rec.organization_id,
2575 p_item_id => p_eam_wo_rec.asset_activity_id,
2576 p_revision => p_eam_wo_rec.bom_revision,
2577 p_revision_date => p_eam_wo_rec.bom_revision_date,
2578 p_start_date => l_start_date);
2579 */
2580 x_return_status := FND_API.G_RET_STS_SUCCESS;
2581
2582 exception
2583 when others then
2584
2585 l_token_tbl(1).token_name := 'BOM Revision';
2586 l_token_tbl(1).token_value := p_eam_wo_rec.bom_revision;
2587
2588 l_out_mesg_token_tbl := l_mesg_token_tbl;
2589 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2590 ( p_message_name => 'EAM_WO_BOM_REVISION'
2591 , p_token_tbl => l_token_tbl
2592 , p_mesg_token_tbl => l_mesg_token_tbl
2593 , x_mesg_token_tbl => l_out_mesg_token_tbl
2594 );
2595 l_mesg_token_tbl := l_out_mesg_token_tbl;
2596
2597 x_return_status := FND_API.G_RET_STS_ERROR;
2598
2599 x_mesg_token_tbl := l_mesg_token_tbl ;
2600 return;
2601
2602 end;
2603
2604
2605 -- routing_revision
2606 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating routing_revision . . . '); END IF;
2607
2608 declare
2609 l_start_date DATE;
2610 l_count NUMBER;
2611 begin
2612
2613 l_start_date := greatest(p_eam_wo_rec.requested_start_date, sysdate);
2614
2615 select count(*)
2616 into l_count
2617 from bom_operational_routings
2618 where assembly_item_id = p_eam_wo_rec.asset_activity_id
2619 and organization_id = p_eam_wo_rec.organization_id
2620 and nvl(alternate_routing_designator, '@@') = nvl(p_eam_wo_rec.alternate_routing_designator, '@@');
2621 /*
2622 if(l_count > 0) then
2623
2624 wip_revisions.routing_revision(p_organization_id => p_eam_wo_rec.organization_id,
2625 p_item_id => p_eam_wo_rec.asset_activity_id,
2626 p_revision => p_eam_wo_rec.routing_revision,
2627 p_revision_date => p_eam_wo_rec.routing_revision_date,
2628 p_start_date => l_start_date);
2629
2630 end if;
2631 */
2632 x_return_status := FND_API.G_RET_STS_SUCCESS;
2633
2634 exception
2635 when others then
2636
2637 l_token_tbl(1).token_name := 'Routing Revision';
2638 l_token_tbl(1).token_value := p_eam_wo_rec.routing_revision;
2639
2640 l_out_mesg_token_tbl := l_mesg_token_tbl;
2641 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2642 ( p_message_name => 'EAM_WO_ROUTING_REVISION'
2643 , p_token_tbl => l_token_tbl
2644 , p_mesg_token_tbl => l_mesg_token_tbl
2645 , x_mesg_token_tbl => l_out_mesg_token_tbl
2646 );
2647 l_mesg_token_tbl := l_out_mesg_token_tbl;
2648
2649 x_return_status := FND_API.G_RET_STS_ERROR;
2650 x_mesg_token_tbl := l_mesg_token_tbl ;
2651 return;
2652
2653 end;
2654
2655
2656 -- manual_rebuild_flag
2657 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating manual_rebuild_flag . . . '); END IF;
2658
2659 begin
2660 if (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE) then
2661 if(p_eam_wo_rec.manual_rebuild_flag is not null and
2662 (p_eam_wo_rec.rebuild_item_id is null or
2663 p_eam_wo_rec.manual_rebuild_flag not in ('Y', 'N'))) then
2664 raise fnd_api.g_exc_unexpected_error;
2665 end if;
2666
2667 if(p_eam_wo_rec.manual_rebuild_flag is null and
2668 p_eam_wo_rec.rebuild_item_id is not null) then
2669 raise fnd_api.g_exc_unexpected_error;
2670 end if;
2671 end if;
2672
2673 x_return_status := FND_API.G_RET_STS_SUCCESS;
2674
2675 exception
2676 when fnd_api.g_exc_unexpected_error then
2677
2678 l_token_tbl(1).token_name := 'Manual Rebuild Flag';
2679 l_token_tbl(1).token_value := p_eam_wo_rec.manual_rebuild_flag;
2680
2681 l_out_mesg_token_tbl := l_mesg_token_tbl;
2682 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2683 ( p_message_name => 'EAM_WO_MANUAL_REBUILD_FLAG'
2684 , p_token_tbl => l_token_tbl
2685 , p_mesg_token_tbl => l_mesg_token_tbl
2686 , x_mesg_token_tbl => l_out_mesg_token_tbl
2687 );
2688 l_mesg_token_tbl := l_out_mesg_token_tbl;
2689
2690 x_return_status := FND_API.G_RET_STS_ERROR;
2691 x_mesg_token_tbl := l_mesg_token_tbl ;
2692 return;
2693
2694 end;
2695
2696 -- owning_department
2697 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating owing_department_id . . . '); END IF;
2698
2699 declare
2700 l_job_date DATE;
2701 l_disable_date DATE;
2702 begin
2703 if p_eam_wo_rec.owning_department is not null then
2704 l_job_date := nvl(p_eam_wo_rec.due_date, nvl(p_eam_wo_rec.requested_start_date, p_eam_wo_rec.scheduled_completion_date));
2705 select disable_date
2706 into l_disable_date
2707 from bom_departments
2708 where department_id = p_eam_wo_rec.owning_department
2709 and organization_id = p_eam_wo_rec.organization_id;
2710
2711 if(l_disable_date is not null and
2712 l_disable_date < l_job_date) then
2713 raise fnd_api.g_exc_unexpected_error;
2714 end if;
2715 end if;
2716
2717 x_return_status := FND_API.G_RET_STS_SUCCESS;
2718
2719 exception
2720 when others then
2721
2722 l_token_tbl(1).token_name := 'Owning Department';
2723 -- l_token_tbl(1).token_value := p_eam_wo_rec.owning_department;
2724
2725 SELECT bd.department_code into l_token_tbl(1).token_value
2726 FROM bom_departments bd
2727 WHERE bd.DEPARTMENT_ID = p_eam_wo_rec.owning_department
2728 AND bd.organization_id = p_eam_wo_rec.organization_id;
2729
2730
2731 l_out_mesg_token_tbl := l_mesg_token_tbl;
2732 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2733 ( p_message_name => 'EAM_WO_OWNING_DEPARTMENT'
2734 , p_token_tbl => l_token_tbl
2735 , p_mesg_token_tbl => l_mesg_token_tbl
2736 , x_mesg_token_tbl => l_out_mesg_token_tbl
2737 );
2738 l_mesg_token_tbl := l_out_mesg_token_tbl;
2739
2740 x_return_status := FND_API.G_RET_STS_ERROR;
2741 x_mesg_token_tbl := l_mesg_token_tbl ;
2742 return;
2743
2744 end;
2745
2746 -- notification_required
2747 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating notification_required . . . '); END IF;
2748
2749 begin
2750 if (p_eam_wo_rec.notification_required is not null and
2751 p_eam_wo_rec.notification_required not in ('Y', 'N')) then
2752 raise fnd_api.g_exc_unexpected_error;
2753 end if;
2754
2755 x_return_status := FND_API.G_RET_STS_SUCCESS;
2756
2757 exception
2758 when fnd_api.g_exc_unexpected_error then
2759
2760 l_token_tbl(1).token_name := 'Notification Required';
2761 l_token_tbl(1).token_value := p_eam_wo_rec.notification_required;
2762
2763 l_out_mesg_token_tbl := l_mesg_token_tbl;
2764 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2765 ( p_message_name => 'EAM_WO_NOTIFICATION_REQUIRED'
2766 , p_token_tbl => l_token_tbl
2767 , p_mesg_token_tbl => l_mesg_token_tbl
2768 , x_mesg_token_tbl => l_out_mesg_token_tbl
2769 );
2770 l_mesg_token_tbl := l_out_mesg_token_tbl;
2771
2772 x_return_status := FND_API.G_RET_STS_ERROR;
2773 x_mesg_token_tbl := l_mesg_token_tbl ;
2774 return;
2775
2776 end;
2777
2778 -- shutdown_type
2779 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating shutdown_type . . . '); END IF;
2780
2781 begin
2782 if p_eam_wo_rec.shutdown_type is not null then
2783 select 1
2784 into g_dummy
2785 from mfg_lookups
2786 where lookup_type = g_shutdown_type
2787 and lookup_code = p_eam_wo_rec.shutdown_type
2788 and enabled_flag = 'Y';
2789 end if;
2790
2791 x_return_status := FND_API.G_RET_STS_SUCCESS;
2792
2793 exception
2794 when no_data_found then
2795
2796 l_token_tbl(1).token_name := 'Shutdown Type';
2797 l_token_tbl(1).token_value := p_eam_wo_rec.shutdown_type;
2798
2799 l_out_mesg_token_tbl := l_mesg_token_tbl;
2800 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2801 ( p_message_name => 'EAM_WO_SHUTDOWN_TYPE'
2802 , p_token_tbl => l_token_tbl
2803 , p_mesg_token_tbl => l_mesg_token_tbl
2804 , x_mesg_token_tbl => l_out_mesg_token_tbl
2805 );
2806 l_mesg_token_tbl := l_out_mesg_token_tbl;
2807
2808 x_return_status := FND_API.G_RET_STS_ERROR;
2809 x_mesg_token_tbl := l_mesg_token_tbl ;
2810 return;
2811
2812 end;
2813
2814 -- tagout_required
2815 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating tagout_required . . . '); END IF;
2816
2817 begin
2818 if (p_eam_wo_rec.tagout_required is not null and
2819 p_eam_wo_rec.tagout_required not in ('Y', 'N')) then
2820 raise fnd_api.g_exc_unexpected_error;
2821 end if;
2822
2823 x_return_status := FND_API.G_RET_STS_SUCCESS;
2824
2825 exception
2826 when fnd_api.g_exc_unexpected_error then
2827
2828 l_token_tbl(1).token_name := 'Tagout Required';
2829 l_token_tbl(1).token_value := p_eam_wo_rec.tagout_required;
2830
2831 l_out_mesg_token_tbl := l_mesg_token_tbl;
2832 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2833 ( p_message_name => 'EAM_WO_TAGOUT_REQUIRED'
2834 , p_token_tbl => l_token_tbl
2835 , p_mesg_token_tbl => l_mesg_token_tbl
2836 , x_mesg_token_tbl => l_out_mesg_token_tbl
2837 );
2838 l_mesg_token_tbl := l_out_mesg_token_tbl;
2839
2840 x_return_status := FND_API.G_RET_STS_ERROR;
2841 x_mesg_token_tbl := l_mesg_token_tbl ;
2842 return;
2843
2844 end;
2845
2846 -- plan_maintenance
2847 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating plan_maintenance . . . '); END IF;
2848
2849 begin
2850 if p_eam_wo_rec.plan_maintenance is not null and
2851 p_eam_wo_rec.plan_maintenance not in ('Y', 'N') then
2852 raise fnd_api.g_exc_unexpected_error;
2853 end if;
2854
2855 x_return_status := FND_API.G_RET_STS_SUCCESS;
2856
2857 exception
2858 when fnd_api.g_exc_unexpected_error then
2859
2860 l_token_tbl(1).token_name := 'Plan Maintenance';
2861 l_token_tbl(1).token_value := p_eam_wo_rec.plan_maintenance;
2862
2863 l_out_mesg_token_tbl := l_mesg_token_tbl;
2864 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2865 ( p_message_name => 'EAM_WO_PLAN_MAINTENANCE'
2866 , p_token_tbl => l_token_tbl
2867 , p_mesg_token_tbl => l_mesg_token_tbl
2868 , x_mesg_token_tbl => l_out_mesg_token_tbl
2869 );
2870 l_mesg_token_tbl := l_out_mesg_token_tbl;
2871
2872 x_return_status := FND_API.G_RET_STS_ERROR;
2873 x_mesg_token_tbl := l_mesg_token_tbl ;
2874 return;
2875
2876 end;
2877
2878 -- work_order_type
2879 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating work_order_type . . . '); END IF;
2880
2881 begin
2882 if p_eam_wo_rec.work_order_type is not null then
2883 select 1
2884 into g_dummy
2885 from mfg_lookups
2886 where lookup_type = g_wo_type
2887 and lookup_code = p_eam_wo_rec.work_order_type
2888 and enabled_flag = 'Y';
2889 end if;
2890
2891 x_return_status := FND_API.G_RET_STS_SUCCESS;
2892
2893 exception
2894 when no_data_found then
2895
2896 l_token_tbl(1).token_name := 'Work Order Type';
2897 l_token_tbl(1).token_value := p_eam_wo_rec.work_order_type;
2898
2899 l_out_mesg_token_tbl := l_mesg_token_tbl;
2900 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2901 ( p_message_name => 'EAM_WO_WORK_ORDER_TYPE'
2902 , p_token_tbl => l_token_tbl
2903 , p_mesg_token_tbl => l_mesg_token_tbl
2904 , x_mesg_token_tbl => l_out_mesg_token_tbl
2905 );
2906 l_mesg_token_tbl := l_out_mesg_token_tbl;
2907
2908 x_return_status := FND_API.G_RET_STS_ERROR;
2909 x_mesg_token_tbl := l_mesg_token_tbl ;
2910 return;
2911
2912 end;
2913
2914 -- activity_type
2915 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating activity_type . . . '); END IF;
2916
2917 begin
2918 if p_eam_wo_rec.activity_type is not null then
2919 select 1
2920 into g_dummy
2921 from mfg_lookups
2922 where lookup_type = g_act_type
2923 and lookup_code = p_eam_wo_rec.activity_type
2924 and enabled_flag = 'Y';
2925 end if;
2926
2927 x_return_status := FND_API.G_RET_STS_SUCCESS;
2928
2929 exception
2930 when no_data_found then
2931
2932 l_token_tbl(1).token_name := 'Activity Type';
2933 l_token_tbl(1).token_value := p_eam_wo_rec.activity_type;
2934
2935 l_out_mesg_token_tbl := l_mesg_token_tbl;
2936 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2937 ( p_message_name => 'EAM_WO_ACTIVITY_TYPE'
2938 , p_token_tbl => l_token_tbl
2939 , p_mesg_token_tbl => l_mesg_token_tbl
2940 , x_mesg_token_tbl => l_out_mesg_token_tbl
2941 );
2942 l_mesg_token_tbl := l_out_mesg_token_tbl;
2943
2944 x_return_status := FND_API.G_RET_STS_ERROR;
2945 x_mesg_token_tbl := l_mesg_token_tbl ;
2946 return;
2947
2948 end;
2949
2950 -- activity_cause
2951 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating activity_cause . . . '); END IF;
2952
2953 begin
2954 if p_eam_wo_rec.activity_cause is not null then
2955 select 1
2956 into g_dummy
2957 from mfg_lookups
2958 where lookup_type = g_act_cause
2959 and lookup_code = p_eam_wo_rec.activity_cause
2960 and enabled_flag = 'Y';
2961 end if;
2962
2963 x_return_status := FND_API.G_RET_STS_SUCCESS;
2964
2965 exception
2966 when no_data_found then
2967
2968 l_token_tbl(1).token_name := 'Activity Cause';
2969 l_token_tbl(1).token_value := p_eam_wo_rec.activity_cause;
2970
2971 l_out_mesg_token_tbl := l_mesg_token_tbl;
2972 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
2973 ( p_message_name => 'EAM_WO_ACTIVITY_CAUSE'
2974 , p_token_tbl => l_token_tbl
2975 , p_mesg_token_tbl => l_mesg_token_tbl
2976 , x_mesg_token_tbl => l_out_mesg_token_tbl
2977 );
2978 l_mesg_token_tbl := l_out_mesg_token_tbl;
2979
2980 x_return_status := FND_API.G_RET_STS_ERROR;
2981 x_mesg_token_tbl := l_mesg_token_tbl ;
2982 return;
2983
2984 end;
2985
2986
2987
2988 -- activity_source
2989 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating activity_source . . . '); END IF;
2990
2991 begin
2992 if p_eam_wo_rec.activity_source is not null then
2993 select 1
2994 into g_dummy
2995 from mfg_lookups
2996 where lookup_type = g_act_source
2997 and lookup_code = p_eam_wo_rec.activity_source
2998 and enabled_flag = 'Y';
2999 end if;
3000
3001 x_return_status := FND_API.G_RET_STS_SUCCESS;
3002
3003 exception
3004 when no_data_found then
3005
3006 l_token_tbl(1).token_name := 'Activity Source';
3007 l_token_tbl(1).token_value := p_eam_wo_rec.activity_source;
3008
3009 l_out_mesg_token_tbl := l_mesg_token_tbl;
3010 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3011 ( p_message_name => 'EAM_WO_ACTIVITY_SOURCE'
3012 , p_token_tbl => l_token_tbl
3013 , p_mesg_token_tbl => l_mesg_token_tbl
3014 , x_mesg_token_tbl => l_out_mesg_token_tbl
3015 );
3016 l_mesg_token_tbl := l_out_mesg_token_tbl;
3017
3018 x_return_status := FND_API.G_RET_STS_ERROR;
3019 x_mesg_token_tbl := l_mesg_token_tbl ;
3020 return;
3021
3022 end;
3023
3024
3025 -- date_released
3026 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating accounting_period . . . '); END IF;
3027
3028 --bug#4425025 - need to validate period only when releasing the first time.
3029 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Old Date_released is : '||nvl(to_char(p_old_eam_wo_rec.date_released),'NULL')); END IF;
3030
3031 declare
3032 l_date_released_calc DATE;
3033 l_min_open_period_date DATE;
3034 begin
3035
3036 if (p_eam_wo_rec.status_type in (WIP_CONSTANTS.HOLD,WIP_CONSTANTS.RELEASED) and
3037 nvl(p_old_eam_wo_rec.status_type,0) not in(WIP_CONSTANTS.RELEASED, WIP_CONSTANTS.HOLD) and
3038 p_old_eam_wo_rec.date_released is null) then
3039
3040 IF (p_eam_wo_rec.scheduled_start_date < sysdate) THEN
3041 select nvl(min(period_start_date),p_eam_wo_rec.scheduled_start_date)
3042 into l_min_open_period_date
3043 from org_acct_periods
3044 where organization_id=p_eam_wo_rec.organization_id
3045 and open_flag = 'Y'
3046 and period_close_date is null;
3047
3048 l_date_released_calc := greatest (l_min_open_period_date,p_eam_wo_rec.scheduled_start_date);
3049 ELSE
3050 l_date_released_calc := sysdate;
3051 END IF;
3052
3053 --date_released will be defaulted just before change_status procedure call in EAMVWOPB.pls.
3054 --hence if date_released is NULL, get the defaulted value but do not stamp defaulted value in work order record
3055 -- as date_released should be populated only when there is no workflow/workflow is approved
3056 IF(p_eam_wo_rec.status_type = WIP_CONSTANTS.RELEASED AND p_eam_wo_rec.date_released IS NOT NULL) THEN
3057 l_date_released_calc := TRUNC(p_eam_wo_rec.date_released);
3058 END IF;
3059
3060 select 1
3061 into g_dummy
3062 from org_acct_periods
3063 where organization_id = p_eam_wo_rec.organization_id
3064 and trunc(l_date_released_calc)
3065 between period_start_date and schedule_close_date
3066 and period_close_date is NULL;
3067
3068 x_return_status := FND_API.G_RET_STS_SUCCESS;
3069
3070 end if;
3071
3072
3073 exception
3074 when no_data_found then
3075 l_token_tbl(1).token_name := 'Date Released';
3076 l_token_tbl(1).token_value := trunc(l_date_released_calc);
3077
3078 l_out_mesg_token_tbl := l_mesg_token_tbl;
3079 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3080 ( p_message_name => 'EAM_WO_NO_ACCT_PERIOD'
3081 , p_token_tbl => l_token_tbl
3082 , p_mesg_token_tbl => l_mesg_token_tbl
3083 , x_mesg_token_tbl => l_out_mesg_token_tbl
3084 );
3085 l_mesg_token_tbl := l_out_mesg_token_tbl;
3086
3087 x_return_status := FND_API.G_RET_STS_ERROR;
3088 x_mesg_token_tbl := l_mesg_token_tbl ;
3089 return;
3090
3091 end;
3092
3093
3094 -- maintenance_object_source
3095
3096 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating maintenance_object_source . . . '); END IF;
3097
3098 begin
3099
3100 if (p_eam_wo_rec.maintenance_object_source is not null) then
3101
3102 select 1
3103 into g_dummy
3104 from mfg_lookups
3105 where lookup_type = g_obj_source
3106 and lookup_code = p_eam_wo_rec.maintenance_object_source;
3107
3108 x_return_status := FND_API.G_RET_STS_SUCCESS;
3109
3110 end if;
3111
3112 exception
3113 when no_data_found then
3114 l_token_tbl(1).token_name := 'Maintenance Object Source';
3115 l_token_tbl(1).token_value := p_eam_wo_rec.maintenance_object_source;
3116
3117 l_out_mesg_token_tbl := l_mesg_token_tbl;
3118 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3119 ( p_message_name => 'EAM_WO_MAINT_OBJECT_SOURCE'
3120 , p_token_tbl => l_token_tbl
3121 , p_mesg_token_tbl => l_mesg_token_tbl
3122 , x_mesg_token_tbl => l_out_mesg_token_tbl
3123 );
3124 l_mesg_token_tbl := l_out_mesg_token_tbl;
3125
3126 x_return_status := FND_API.G_RET_STS_ERROR;
3127 x_mesg_token_tbl := l_mesg_token_tbl ;
3128 return;
3129
3130 end;
3131
3132
3133 -- user_id
3134
3135 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating user_id . . . '); END IF;
3136
3137 begin
3138
3139 if (p_eam_wo_rec.user_id is not null) then
3140
3141 select 1
3142 into g_dummy
3143 from fnd_user
3144 where user_id = p_eam_wo_rec.user_id;
3145
3146 x_return_status := FND_API.G_RET_STS_SUCCESS;
3147
3148 end if;
3149
3150 exception
3151 when no_data_found then
3152 l_token_tbl(1).token_name := 'USER_ID';
3153 l_token_tbl(1).token_value := p_eam_wo_rec.user_id;
3154
3155 l_out_mesg_token_tbl := l_mesg_token_tbl;
3156 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3157 ( p_message_name => 'EAM_WO_USER'
3158 , p_token_tbl => l_token_tbl
3159 , p_mesg_token_tbl => l_mesg_token_tbl
3160 , x_mesg_token_tbl => l_out_mesg_token_tbl
3161 );
3162 l_mesg_token_tbl := l_out_mesg_token_tbl;
3163
3164 x_return_status := FND_API.G_RET_STS_ERROR;
3165 x_mesg_token_tbl := l_mesg_token_tbl ;
3166 return;
3167
3168 end;
3169
3170
3171 -- responsibility_id
3172
3173 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating responsibility_id . . . '); END IF;
3174
3175 begin
3176
3177 /* if (p_eam_wo_rec.responsibility_id is not null) then
3178
3179 select 1
3180 into g_dummy
3181 from fnd_responsibility
3182 where responsibility_id = p_eam_wo_rec.responsibility_id;
3183
3184 x_return_status := FND_API.G_RET_STS_SUCCESS;
3185
3186 end if;*/
3187
3188 -- Fix for 10354583 / 9398568
3189
3190 if (p_eam_wo_rec.responsibility_id is not null) then
3191
3192 if (p_eam_wo_rec.responsibility_id = -1) then
3193 x_return_status := FND_API.G_RET_STS_SUCCESS;
3194 else
3195 select 1
3196 into g_dummy
3197 from fnd_responsibility
3198 where responsibility_id = p_eam_wo_rec.responsibility_id;
3199
3200 x_return_status := FND_API.G_RET_STS_SUCCESS;
3201 end if;
3202 end if;
3203
3204 exception
3205 when no_data_found then
3206 l_token_tbl(1).token_name := 'RESPONSIBILITY_ID';
3207 l_token_tbl(1).token_value := p_eam_wo_rec.responsibility_id;
3208
3209 l_out_mesg_token_tbl := l_mesg_token_tbl;
3210 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3211 ( p_message_name => 'EAM_WO_RESPONSIBILITY'
3212 , p_token_tbl => l_token_tbl
3213 , p_mesg_token_tbl => l_mesg_token_tbl
3214 , x_mesg_token_tbl => l_out_mesg_token_tbl
3215 );
3216 l_mesg_token_tbl := l_out_mesg_token_tbl;
3217
3218 x_return_status := FND_API.G_RET_STS_ERROR;
3219 x_mesg_token_tbl := l_mesg_token_tbl ;
3220 return;
3221
3222 end;
3223
3224 -- user_defined_status_id
3225
3226 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating user_defined_status_id . . . '); END IF;
3227
3228 begin
3229
3230 IF (p_eam_wo_rec.user_defined_status_id IS NOT NULL) AND
3231 (p_eam_wo_rec.user_defined_status_id <> p_old_eam_wo_rec.user_defined_status_id)THEN
3232
3233 SELECT enabled_flag
3234 INTO l_enabled_flag
3235 FROM EAM_WO_STATUSES_B
3236 WHERE status_id = p_eam_wo_rec.user_defined_status_id;
3237
3238 IF l_enabled_flag <> 'Y' THEN
3239 RAISE fnd_api.g_exc_error;
3240 END IF;
3241
3242 END IF;
3243
3244 exception
3245 when fnd_api.g_exc_error then
3246 l_token_tbl(1).token_name := 'USER_DEFINED_STATUS_ID';
3247 l_token_tbl(1).token_value := p_eam_wo_rec.user_defined_status_id;
3248
3249 l_out_mesg_token_tbl := l_mesg_token_tbl;
3250 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3251 ( p_message_name => 'EAM_WO_DIS_USER_DEFINED_STATUS'
3252 , p_token_tbl => l_token_tbl
3253 , p_mesg_token_tbl => l_mesg_token_tbl
3254 , x_mesg_token_tbl => l_out_mesg_token_tbl
3255 );
3256 l_mesg_token_tbl := l_out_mesg_token_tbl;
3257
3258 x_return_status := FND_API.G_RET_STS_ERROR;
3259 x_mesg_token_tbl := l_mesg_token_tbl ;
3260 return;
3261
3262 end;
3263
3264 -- material_issue_by_mo
3265
3266 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating material_issue_by_mo flag . . . '); END IF;
3267
3268 begin
3269
3270 if (p_eam_wo_rec.material_issue_by_mo is null) then
3271 raise fnd_api.g_exc_unexpected_error;
3272 else
3273 x_return_status := FND_API.G_RET_STS_SUCCESS;
3274 end if;
3275
3276
3277
3278 if p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
3279 and p_eam_wo_rec.status_type not in (WIP_CONSTANTS.DRAFT,WIP_CONSTANTS.UNRELEASED) /* Bug no 3349197 */
3280 and not(p_eam_wo_rec.status_type=WIP_CONSTANTS.RELEASED and (p_old_eam_wo_rec.status_type IN (WIP_CONSTANTS.DRAFT,WIP_CONSTANTS.UNRELEASED,WIP_CONSTANTS.CANCELLED))) /*Bug No 3476156*/
3281 and p_eam_wo_rec.material_issue_by_mo <> p_old_eam_wo_rec.material_issue_by_mo then
3282
3283 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN
3284 EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating material_issue_by_mo flag . .wip_entity_id' || p_eam_wo_rec.wip_entity_id);
3285 EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating material_issue_by_mo flag . .org_id' || p_eam_wo_rec.organization_id);
3286 END IF;
3287
3288 if ((p_eam_wo_rec.status_type = WIP_CONSTANTS.HOLD) OR (p_eam_wo_rec.status_type=WIP_CONSTANTS.RELEASED and p_old_eam_wo_rec.status_type=WIP_CONSTANTS.HOLD)) then /*Bug no 3476156*/
3289 -- If material allocation has been done then raise error
3290 EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
3291 X_Wip_Id => p_eam_wo_rec.wip_entity_id,
3292 X_Rep_Id => -1,
3293 X_Line_Id => -1,
3294 X_Ent_Type=> 6 ,
3295 x_return_status =>x_return_status);
3296
3297 if x_return_status<> FND_API.G_RET_STS_SUCCESS then
3298 l_mo_err_flag := '2';
3299 raise fnd_api.g_exc_error;
3300 end if;
3301 else
3302 l_mo_err_flag := '1';
3303 raise fnd_api.g_exc_error;
3304 end if;
3305 end if;
3306 exception
3307 when fnd_api.g_exc_error then
3308 l_out_mesg_token_tbl := l_mesg_token_tbl;
3309
3310 If l_mo_err_flag = '1' Then
3311 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3312 ( p_message_name => 'EAM_WO_MTL_ISS_DISALLOWED'
3313 , p_token_tbl => l_token_tbl
3314 , p_mesg_token_tbl => l_mesg_token_tbl
3315 , x_mesg_token_tbl => l_out_mesg_token_tbl
3316 );
3317 Else
3318 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3319 ( p_message_name => 'EAM_WO_MTL_ALRDY_ISSUED'
3320 , p_token_tbl => l_token_tbl
3321 , p_mesg_token_tbl => l_mesg_token_tbl
3322 , x_mesg_token_tbl => l_out_mesg_token_tbl
3323 );
3324 End if;
3325
3326
3327 l_mesg_token_tbl := l_out_mesg_token_tbl;
3328
3329 x_return_status := FND_API.G_RET_STS_ERROR;
3330 x_mesg_token_tbl := l_mesg_token_tbl ;
3331 return;
3332
3333 when others then
3334
3335 l_out_mesg_token_tbl := l_mesg_token_tbl;
3336 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3337 ( p_message_name => 'EAM_WO_MTL_ISSUE_BY_MO'
3338 , p_token_tbl => l_token_tbl
3339 , p_mesg_token_tbl => l_mesg_token_tbl
3340 , x_mesg_token_tbl => l_out_mesg_token_tbl
3341 );
3342 l_mesg_token_tbl := l_out_mesg_token_tbl;
3343
3344 x_return_status := FND_API.G_RET_STS_ERROR;
3345 x_mesg_token_tbl := l_mesg_token_tbl ;
3346 return;
3347
3348 end;
3349
3350 -- Bug # 4709084 : FAILURE ANALYSIS : Check for failure_code_required..
3351 IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN
3352 EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating failure_code_required . . . ');
3353 END IF;
3354
3355 if (p_eam_wo_rec.failure_code_required is not null and p_eam_wo_rec.failure_code_required not in ('Y', 'N')) then
3356 l_token_tbl(1).token_name := 'failure_code_required';
3357 l_token_tbl(1).token_value := p_eam_wo_rec.failure_code_required;
3358 l_out_mesg_token_tbl := l_mesg_token_tbl;
3359 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3360 ( p_message_name => 'EAM_WO_FAILURE_CODE_REQUIRED'
3361 , p_token_tbl => l_token_tbl
3362 , p_mesg_token_tbl => l_mesg_token_tbl
3363 , x_mesg_token_tbl => l_out_mesg_token_tbl
3364 );
3365 l_mesg_token_tbl := l_out_mesg_token_tbl;
3366 x_return_status := FND_API.G_RET_STS_ERROR;
3367 x_mesg_token_tbl := l_mesg_token_tbl ;
3368 return;
3369 else
3370 x_return_status := FND_API.G_RET_STS_SUCCESS;
3371 end if;
3372
3373 EXCEPTION
3374 WHEN OTHERS THEN
3375
3376 l_token_tbl(1).token_name := 'Validation (Check Attributes)';
3377 l_token_tbl(1).token_value := substrb(SQLERRM,1,200);
3378
3379 l_out_mesg_token_tbl := l_mesg_token_tbl;
3380 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3381 ( p_message_name => NULL
3382 , p_token_tbl => l_token_tbl
3383 , p_mesg_token_tbl => l_mesg_token_tbl
3384 , x_mesg_token_tbl => l_out_mesg_token_tbl
3385 ) ;
3386 l_mesg_token_tbl := l_out_mesg_token_tbl;
3387
3388 -- Return the status and message table.
3389 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3390 x_mesg_token_tbl := l_mesg_token_tbl ;
3391
3392 END Check_Attributes;
3393
3394 /*********************************************************************
3395 * Procedure : Check_Required
3396 * Parameters IN : Work Order column record
3397 * Parameters OUT NOCOPY: Mesg Token Table
3398 * Return_Status
3399 * Purpose :
3400 **********************************************************************/
3401
3402 PROCEDURE Check_Required
3403 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
3404 , x_return_status OUT NOCOPY VARCHAR2
3405 , x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
3406 )
3407 IS
3408 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
3409 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
3410 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
3411 BEGIN
3412
3413 x_return_status := FND_API.G_RET_STS_SUCCESS;
3414
3415 IF p_eam_wo_rec.organization_id IS NULL
3416 THEN
3417 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3418 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3419
3420 l_out_mesg_token_tbl := l_mesg_token_tbl;
3421 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3422 ( p_message_name => 'EAM_WO_ORG_REQUIRED'
3423 , p_token_tbl => l_Token_tbl
3424 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3425 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3426 );
3427 l_mesg_token_tbl := l_out_mesg_token_tbl;
3428
3429 x_return_status := FND_API.G_RET_STS_ERROR;
3430
3431 END IF;
3432
3433 IF (p_eam_wo_rec.asset_number IS NULL) AND
3434 (p_eam_wo_rec.rebuild_item_id IS NULL) AND
3435 (p_eam_wo_rec.maintenance_object_id IS NULL)
3436 THEN
3437 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3438 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3439
3440 l_out_mesg_token_tbl := l_mesg_token_tbl;
3441 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3442 ( p_message_name => 'EAM_WO_MAINT_ASSET_REQUIRED'
3443 , p_token_tbl => l_Token_tbl
3444 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3445 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3446 );
3447 l_mesg_token_tbl := l_out_mesg_token_tbl;
3448
3449 x_return_status := FND_API.G_RET_STS_ERROR;
3450
3451 END IF;
3452
3453
3454 IF p_eam_wo_rec.class_code IS NULL AND p_eam_wo_rec.class_code = FND_API.G_MISS_CHAR
3455 THEN
3456 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3457 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3458
3459 l_out_mesg_token_tbl := l_mesg_token_tbl;
3460 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3461 ( p_message_name => 'EAM_WO_WAC_REQUIRED'
3462 , p_token_tbl => l_Token_tbl
3463 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3464 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3465 );
3466 l_mesg_token_tbl := l_out_mesg_token_tbl;
3467
3468 x_return_status := FND_API.G_RET_STS_ERROR;
3469
3470 END IF;
3471
3472
3473
3474 -- agaurav - Added the check that owning_department is not mandatory
3475 -- - in the statuses DRAFT and UNRELEASED.
3476
3477 IF p_eam_wo_rec.status_type not in (wip_constants.draft, wip_constants.unreleased,wip_constants.cancelled, wip_constants.hold)
3478 THEN
3479 IF p_eam_wo_rec.owning_department IS NULL
3480 THEN
3481 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3482 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3483
3484 l_out_mesg_token_tbl := l_mesg_token_tbl;
3485 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3486 ( p_message_name => 'EAM_WO_DEPT_REQUIRED'
3487 , p_token_tbl => l_Token_tbl
3488 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3489 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3490 );
3491 l_mesg_token_tbl := l_out_mesg_token_tbl;
3492
3493 x_return_status := FND_API.G_RET_STS_ERROR;
3494
3495 END IF;
3496 END IF;
3497
3498
3499 IF p_eam_wo_rec.wip_entity_id IS NULL
3500 THEN
3501 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3502 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3503
3504 l_out_mesg_token_tbl := l_mesg_token_tbl;
3505 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3506 ( p_message_name => 'EAM_WO_WIP_ENTITY_ID_REQUIRED'
3507 , p_token_tbl => l_Token_tbl
3508 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3509 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3510 );
3511 l_mesg_token_tbl := l_out_mesg_token_tbl;
3512
3513 x_return_status := FND_API.G_RET_STS_ERROR;
3514
3515 END IF;
3516
3517 IF p_eam_wo_rec.wip_entity_name IS NULL
3518 THEN
3519 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3520 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3521
3522 l_out_mesg_token_tbl := l_mesg_token_tbl;
3523 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3524 ( p_message_name => 'EAM_WO_WIP_NAME_REQUIRED'
3525 , p_token_tbl => l_Token_tbl
3526 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3527 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3528 );
3529 l_mesg_token_tbl := l_out_mesg_token_tbl;
3530
3531 x_return_status := FND_API.G_RET_STS_ERROR;
3532
3533 END IF;
3534
3535 IF p_eam_wo_rec.status_type IS NULL
3536 THEN
3537 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3538 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3539
3540 l_out_mesg_token_tbl := l_mesg_token_tbl;
3541 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3542 ( p_message_name => 'EAM_WO_STATUS_TYPE_REQUIRED'
3543 , p_token_tbl => l_Token_tbl
3544 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3545 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3546 );
3547 l_mesg_token_tbl := l_out_mesg_token_tbl;
3548
3549 x_return_status := FND_API.G_RET_STS_ERROR;
3550
3551 END IF;
3552
3553
3554 IF p_eam_wo_rec.job_quantity IS NULL
3555 THEN
3556 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3557 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3558
3559 l_out_mesg_token_tbl := l_mesg_token_tbl;
3560 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3561 ( p_message_name => 'EAM_WO_JOB_QTY_REQUIRED'
3562 , p_token_tbl => l_Token_tbl
3563 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3564 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3565 );
3566 l_mesg_token_tbl := l_out_mesg_token_tbl;
3567
3568 x_return_status := FND_API.G_RET_STS_ERROR;
3569
3570 END IF;
3571
3572
3573 IF p_eam_wo_rec.firm_planned_flag IS NULL
3574 THEN
3575 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3576 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3577
3578 l_out_mesg_token_tbl := l_mesg_token_tbl;
3579 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3580 ( p_message_name => 'EAM_WO_FIRM_FLAG_REQUIRED'
3581 , p_token_tbl => l_Token_tbl
3582 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3583 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3584 );
3585 l_mesg_token_tbl := l_out_mesg_token_tbl;
3586
3587 x_return_status := FND_API.G_RET_STS_ERROR;
3588
3589 END IF;
3590
3591 IF p_eam_wo_rec.wip_supply_type IS NULL
3592 THEN
3593 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3594 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3595
3596 l_out_mesg_token_tbl := l_mesg_token_tbl;
3597 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3598 ( p_message_name => 'EAM_WO_SUPPLY_TYPE_REQUIRED'
3599 , p_token_tbl => l_Token_tbl
3600 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3601 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3602 );
3603 l_mesg_token_tbl := l_out_mesg_token_tbl;
3604
3605 x_return_status := FND_API.G_RET_STS_ERROR;
3606
3607 END IF;
3608
3609 IF p_eam_wo_rec.scheduled_start_date IS NULL
3610 THEN
3611 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3612 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3613
3614 l_out_mesg_token_tbl := l_mesg_token_tbl;
3615 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3616 ( p_message_name => 'EAM_WO_START_DATE_REQUIRED'
3617 , p_token_tbl => l_Token_tbl
3618 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3619 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3620 );
3621 l_mesg_token_tbl := l_out_mesg_token_tbl;
3622
3623 x_return_status := FND_API.G_RET_STS_ERROR;
3624
3625 END IF;
3626
3627 IF p_eam_wo_rec.scheduled_completion_date IS NULL
3628 THEN
3629 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3630 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3631
3632 l_out_mesg_token_tbl := l_mesg_token_tbl;
3633 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3634 ( p_message_name => 'EAM_WO_COMPL_DATE_REQUIRED'
3635 , p_token_tbl => l_Token_tbl
3636 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3637 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3638 );
3639 l_mesg_token_tbl := l_out_mesg_token_tbl;
3640
3641 x_return_status := FND_API.G_RET_STS_ERROR;
3642
3643 END IF;
3644
3645 IF p_eam_wo_rec.due_date IS NULL AND p_eam_wo_rec.requested_start_date IS NULL
3646 THEN
3647 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3648 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3649
3650 l_out_mesg_token_tbl := l_mesg_token_tbl;
3651 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3652 ( p_message_name => 'EAM_WO_DATE_REQUIRED'
3653 , p_token_tbl => l_Token_tbl
3654 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3655 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3656 );
3657 l_mesg_token_tbl := l_out_mesg_token_tbl;
3658
3659 x_return_status := FND_API.G_RET_STS_ERROR;
3660
3661 END IF;
3662
3663 IF p_eam_wo_rec.maintenance_object_source IS NULL
3664 THEN
3665 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3666 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3667
3668 l_out_mesg_token_tbl := l_mesg_token_tbl;
3669 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3670 ( p_message_name => 'EAM_WO_MAINT_OBJ_SRC_REQUIRED'
3671 , p_token_tbl => l_Token_tbl
3672 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3673 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3674 );
3675 l_mesg_token_tbl := l_out_mesg_token_tbl;
3676
3677 x_return_status := FND_API.G_RET_STS_ERROR;
3678
3679 END IF;
3680
3681
3682 IF p_eam_wo_rec.maintenance_object_type IS NOT NULL and
3683 p_eam_wo_rec.maintenance_object_id IS NULL
3684 THEN
3685 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3686 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3687
3688 l_out_mesg_token_tbl := l_mesg_token_tbl;
3689 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3690 ( p_message_name => 'EAM_WO_MAINT_OBJ_ID_REQUIRED'
3691 , p_token_tbl => l_Token_tbl
3692 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3693 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3694 );
3695 l_mesg_token_tbl := l_out_mesg_token_tbl;
3696
3697 x_return_status := FND_API.G_RET_STS_ERROR;
3698
3699 END IF;
3700
3701
3702 IF p_eam_wo_rec.maintenance_object_type IS NULL and
3703 p_eam_wo_rec.maintenance_object_id IS NOT NULL
3704 THEN
3705 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3706 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3707
3708 l_out_mesg_token_tbl := l_mesg_token_tbl;
3709 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3710 ( p_message_name => 'EAM_WO_MAINT_OBJ_TYPE_REQUIRED'
3711 , p_token_tbl => l_Token_tbl
3712 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3713 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3714 );
3715 l_mesg_token_tbl := l_out_mesg_token_tbl;
3716
3717 x_return_status := FND_API.G_RET_STS_ERROR;
3718
3719 END IF;
3720
3721
3722 IF (p_eam_wo_rec.user_id IS NULL and
3723 p_eam_wo_rec.responsibility_id IS NOT NULL)
3724 or (p_eam_wo_rec.user_id IS NOT NULL and
3725 p_eam_wo_rec.responsibility_id IS NULL)
3726 THEN
3727 l_token_tbl(1).token_name := 'USER_ID';
3728 l_token_tbl(1).token_value := p_eam_wo_rec.user_id;
3729
3730 l_out_mesg_token_tbl := l_mesg_token_tbl;
3731 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3732 ( p_message_name => 'EAM_WO_USER_RESP_REQUIRED'
3733 , p_token_tbl => l_Token_tbl
3734 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3735 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3736 );
3737 l_mesg_token_tbl := l_out_mesg_token_tbl;
3738
3739 x_return_status := FND_API.G_RET_STS_ERROR;
3740
3741 END IF;
3742
3743 /* Added the validation that rebuild serial number is mandatory in status Released */
3744 IF ( p_eam_wo_rec.status_type in ( WIP_CONSTANTS.RELEASED )
3745 and p_eam_wo_rec.rebuild_serial_number is NULL
3746 and p_eam_wo_rec.asset_group_id is NULL
3747 and p_eam_wo_rec.maintenance_object_type = 3
3748 and p_eam_wo_rec.maintenance_object_source = 1)
3749 THEN
3750 l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
3751 l_token_tbl(1).token_value := p_eam_wo_rec.wip_entity_name;
3752
3753 l_out_mesg_token_tbl := l_mesg_token_tbl;
3754 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
3755 ( p_message_name => 'EAM_WO_REB_SR_NUM_REQUIRED'
3756 , p_token_tbl => l_Token_tbl
3757 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
3758 , x_Mesg_Token_Tbl => l_out_Mesg_Token_Tbl
3759 );
3760 l_mesg_token_tbl := l_out_mesg_token_tbl;
3761
3762 x_return_status := FND_API.G_RET_STS_ERROR;
3763 END IF;
3764
3765
3766
3767 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
3768
3769 END Check_Required;
3770
3771
3772 END EAM_WO_VALIDATE_PVT;