1 PACKAGE BODY EAM_WO_DEFAULT_PVT AS
2 /* $Header: EAMVWODB.pls 120.23 2007/03/20 12:42:27 amourya ship $ */
3 /***************************************************************************
4 --
5 -- Copyright (c) 2002 Oracle Corporation, Redwood Shores, CA, USA
6 -- All rights reserved.
7 --
8 -- FILENAME
9 --
10 -- EAMVWODB.pls
11 --
12 -- DESCRIPTION
13 --
14 -- Spec of package EAM_WO_DEFAULT_PVT
15 --
16 -- NOTES
17 --
18 -- HISTORY
19 --
20 -- 30-JUN-2002 Kenichi Nagumo Initial Creation
21 -- 15-May-2005 Anju Gupta Changes for IB/Transactable Assets
22 ***************************************************************************/
23 G_PKG_NAME CONSTANT VARCHAR2(30) := 'EAM_WO_DEFAULT_PVT';
24
25 /********************************************************************
26 * Function : get_wip_entity_id
27 * Return : NUMBER
28 * Purpose : Function will return wip_entity_id
29 *
30 **********************************************************************/
31
32
33 FUNCTION get_wip_entity_id
34 RETURN NUMBER
35 IS
36 l_wip_entity_id NUMBER := NULL;
37 BEGIN
38
39 SELECT wip_entities_s.nextval
40 INTO l_wip_entity_id
41 FROM dual;
42
43 RETURN l_wip_entity_id;
44
45 EXCEPTION
46 WHEN OTHERS THEN
47 RETURN NULL;
48
49 END get_wip_entity_id;
50
51
52
53 /********************************************************************
54 * Function : get_wip_entity_name_prefix
55 * Return : VARCHAR2
56 * Purpose : Function will return wip_entity_name_prefix
57 *
58 **********************************************************************/
59
60 FUNCTION get_wip_entity_name_prefix
61 ( p_organization_id IN NUMBER
62 )
63 RETURN VARCHAR2
64 IS
65 l_wip_entity_name_prefix VARCHAR2(30) := NULL;
66 BEGIN
67
68 SELECT work_order_prefix
69 INTO l_wip_entity_name_prefix
70 FROM wip_eam_parameters
71 WHERE organization_id = p_organization_id;
72
73 RETURN l_wip_entity_name_prefix;
74
75 EXCEPTION
76 WHEN OTHERS THEN
77 RETURN NULL;
78
79 END get_wip_entity_name_prefix;
80
81
82
83 /********************************************************************
84 * Function : get_wip_entity_name
85 * Return : VARCHAR2
86 * Purpose : Function will return new work order name
87 *
88 **********************************************************************/
89
90 FUNCTION get_wip_entity_name(p_org_id NUMBER,p_plan_maintenance VARCHAR2)
91 RETURN VARCHAR2
92 IS
93 l_wip_entity_name VARCHAR2(240) := NULL;
94 l_wip_entity_count NUMBER :=0;
95 l_wip_entity_name_prefix VARCHAR2(30) := NULL;
96 BEGIN
97
98 IF nvl(p_plan_maintenance,'N') <> 'Y' THEN
99 l_wip_entity_name_prefix :=get_wip_entity_name_prefix(p_org_id);
100 END IF;
101 LOOP
102 SELECT wip_job_number_s.nextval
103 INTO l_wip_entity_name
104 FROM dual;
105
106 l_wip_entity_name := l_wip_entity_name_prefix || l_wip_entity_name;
107
108 select count(*) into l_wip_entity_count from wip_entities
109 where organization_id = p_org_id and wip_entity_name =l_wip_entity_name
110 and rownum <= 1;
111
112 EXIT WHEN l_wip_entity_count=0;
113 END LOOP;
114
115 RETURN l_wip_entity_name;
116 EXCEPTION
117 WHEN OTHERS THEN
118 RETURN NULL;
119 END get_wip_entity_name;
120
121
122
123
124 /********************************************************************
125 * Procedure : get_flex_eam_wo
126 **********************************************************************/
127
128
129 PROCEDURE get_flex_eam_wo
130 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
131 , x_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
132 )
133 IS
134 BEGIN
135
136 -- In the future call Flex APIs for defaults
137 x_eam_wo_rec := p_eam_wo_rec;
138
139 IF p_eam_wo_rec.attribute_category =FND_API.G_MISS_CHAR THEN
140 x_eam_wo_rec.attribute_category := NULL;
141 END IF;
142
143 IF p_eam_wo_rec.attribute1 = FND_API.G_MISS_CHAR THEN
144 x_eam_wo_rec.attribute1 := NULL;
145 END IF;
146
147 IF p_eam_wo_rec.attribute2 = FND_API.G_MISS_CHAR THEN
148 x_eam_wo_rec.attribute2 := NULL;
149 END IF;
150
151 IF p_eam_wo_rec.attribute3 = FND_API.G_MISS_CHAR THEN
152 x_eam_wo_rec.attribute3 := NULL;
153 END IF;
154
155 IF p_eam_wo_rec.attribute4 = FND_API.G_MISS_CHAR THEN
156 x_eam_wo_rec.attribute4 := NULL;
157 END IF;
158
159 IF p_eam_wo_rec.attribute5 = FND_API.G_MISS_CHAR THEN
160 x_eam_wo_rec.attribute5 := NULL;
161 END IF;
162
163 IF p_eam_wo_rec.attribute6 = FND_API.G_MISS_CHAR THEN
164 x_eam_wo_rec.attribute6 := NULL;
165 END IF;
166
167 IF p_eam_wo_rec.attribute7 = FND_API.G_MISS_CHAR THEN
168 x_eam_wo_rec.attribute7 := NULL;
169 END IF;
170
171 IF p_eam_wo_rec.attribute8 = FND_API.G_MISS_CHAR THEN
172 x_eam_wo_rec.attribute8 := NULL;
173 END IF;
174
175 IF p_eam_wo_rec.attribute9 = FND_API.G_MISS_CHAR THEN
176 x_eam_wo_rec.attribute9 := NULL;
177 END IF;
178
179 IF p_eam_wo_rec.attribute10 = FND_API.G_MISS_CHAR THEN
180 x_eam_wo_rec.attribute10 := NULL;
181 END IF;
182
183 IF p_eam_wo_rec.attribute11 = FND_API.G_MISS_CHAR THEN
184 x_eam_wo_rec.attribute11 := NULL;
185 END IF;
186
187 IF p_eam_wo_rec.attribute12 = FND_API.G_MISS_CHAR THEN
188 x_eam_wo_rec.attribute12 := NULL;
189 END IF;
190
191 IF p_eam_wo_rec.attribute13 = FND_API.G_MISS_CHAR THEN
192 x_eam_wo_rec.attribute13 := NULL;
193 END IF;
194
195 IF p_eam_wo_rec.attribute14 = FND_API.G_MISS_CHAR THEN
196 x_eam_wo_rec.attribute14 := NULL;
197 END IF;
198
199 IF p_eam_wo_rec.attribute15 = FND_API.G_MISS_CHAR THEN
200 x_eam_wo_rec.attribute15 := NULL;
201 END IF;
202
203 END get_flex_eam_wo;
204
205
206 /*********************************************************************
207 * Procedure : Attribute_Defaulting
208 * Parameters IN : Work Order record
209 * Parameters OUT NOCOPY: Work Order record after defaulting
210 * Mesg_Token_Table
211 * Return_Status
212 * Purpose : Attribute Defaulting will default the necessary null
213 * attribute with appropriate values.
214 **********************************************************************/
215
216 PROCEDURE Attribute_Defaulting
217 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
218 , p_old_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
219 , x_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
220 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
221 , x_return_status OUT NOCOPY VARCHAR2
222 )
223 IS
224 l_err_text VARCHAR2(2000) := NULL;
225 l_return_status VARCHAR2(2);
226 l_msg_count NUMBER;
227 l_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
228 l_out_Mesg_Token_Tbl EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type;
229 l_out_eam_wo_rec EAM_PROCESS_WO_PUB.eam_wo_rec_type;
230 l_Token_Tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
231 l_job_type NUMBER := 1;
232
233 l_owning_department NUMBER;
234 l_priority NUMBER;
235 l_material_account NUMBER;
236 l_material_overhead_account NUMBER;
237 l_resource_account NUMBER;
238 l_outside_processing_account NUMBER;
239 l_material_variance_account NUMBER;
240 l_resource_variance_account NUMBER;
241 l_osp_var_account NUMBER;
242 l_std_cost_adjustment_account NUMBER;
243 l_overhead_account NUMBER;
244 l_overhead_variance_account NUMBER;
245 l_issue_zero_cost_flag VARCHAR2(1);
246
247 l_class_code VARCHAR2(10);
248 l_activity_cause VARCHAR2(30);
249 l_activity_type VARCHAR2(30);
250 l_activity_source VARCHAR2(30);
251 l_shutdown_type VARCHAR2(30);
252 l_notification_required VARCHAR2(1);
253 l_tagout_required VARCHAR2(1);
254 l_auto_firm_flag VARCHAR2(10);
255 l_activity_description VARCHAR2(240);
256
257
258 l_old_eam_wo_rec EAM_PROCESS_WO_PUB.eam_wo_rec_type;
259 l_auto_firm_create_flag VARCHAR2(1);
260
261 BEGIN
262
263
264 EAM_WO_UTILITY_PVT.Query_Row(
265 p_wip_entity_id => p_eam_wo_rec.wip_entity_id
266 , p_organization_id => p_eam_wo_rec.organization_id
267 , x_eam_wo_rec => l_old_eam_wo_rec
268 , x_Return_status => l_return_status
269 );
270
271
272 x_eam_wo_rec := p_eam_wo_rec;
273 x_return_status := FND_API.G_RET_STS_SUCCESS;
274
275 IF p_eam_wo_rec.wip_entity_id IS NULL OR
276 p_eam_wo_rec.wip_entity_id = FND_API.G_MISS_NUM
277 THEN
278 x_eam_wo_rec.wip_entity_id :=get_wip_entity_id;
279
280 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new wip_entity_id : ' || to_char(x_eam_wo_rec.wip_entity_id)); END IF;
281
282 END IF;
283
284 IF p_eam_wo_rec.wip_entity_name IS NULL OR
285 p_eam_wo_rec.wip_entity_name = FND_API.G_MISS_CHAR
286 THEN
287 x_eam_wo_rec.wip_entity_name := get_wip_entity_name(p_eam_wo_rec.organization_id,p_eam_wo_rec.plan_maintenance);
288
289
290
291 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new wip_entity_name : ' || x_eam_wo_rec.wip_entity_name); END IF;
292
293 END IF;
294
295 -- Finding out whether Asset or Rebuild WO
296 IF p_eam_wo_rec.maintenance_object_type = 2 THEN
297 -- Rebuild
298 l_job_type := 2;
299 ELSIF p_eam_wo_rec.maintenance_object_type = 3 THEN
300 IF p_eam_wo_rec.rebuild_item_id is not null THEN
301 l_job_type :=2;
302 ELSE
303 l_job_type :=1;
304 END IF;
305 END IF;
306
307
308 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
309 AND p_eam_wo_rec.class_code is null )
310 THEN
311 WIP_EAM_UTILS.DEFAULT_ACC_CLASS(
312 p_org_id => p_eam_wo_rec.organization_id,
313 p_job_type => l_job_type,
314 p_serial_number => nvl(p_eam_wo_rec.rebuild_serial_number, p_eam_wo_rec.asset_number),
315 p_asset_group_id => nvl(p_eam_wo_rec.rebuild_item_id, p_eam_wo_rec.asset_group_id),
316 p_parent_wo_id => p_eam_wo_rec.parent_wip_entity_id,
317 p_asset_activity_id => p_eam_wo_rec.asset_activity_id,
318 p_project_id => p_eam_wo_rec.project_id,
319 p_task_id => p_eam_wo_rec.task_id,
320 x_class_code => l_class_code,
321 x_return_status => l_return_status,
322 x_msg_data => l_err_text
323 );
324
325 IF l_class_code IS NOT NULL AND
326 l_class_code <> FND_API.G_MISS_CHAR
327 THEN
328 -- Default the WIP ACC Class
329 x_eam_wo_rec.class_code := l_class_code;
330
331 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new class_code : ' || x_eam_wo_rec.class_code); END IF;
332 END IF;
333
334 END IF;
335
336 IF p_eam_wo_rec.asset_activity_id is not null THEN
337
338 /* Defaulting logic of work order description from activity description for bug# 3418828 */
339
340 IF ( p_eam_wo_rec.description IS NULL
341 and p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE )
342 THEN
343 begin
344 SELECT description
345 INTO l_activity_description
346 FROM MTL_SYSTEM_ITEMS_KFV MSI, MTL_PARAMETERS MP
347 WHERE MSI.inventory_item_id = p_eam_wo_rec.asset_activity_id
348 AND MSI.organization_id = MP.ORGANIZATION_ID
349 AND MP.MAINT_ORGANIZATION_ID = p_eam_wo_rec.organization_id
350 AND rownum = 1;
351
352 x_eam_wo_rec.description := l_activity_description;
353
354 EXCEPTION
355 WHEN OTHERS THEN
356 NULL;
357 end;
358 END IF;
359
360 /* end of fix */
361
362 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE /*OR
363 (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND
364 NVL(p_eam_wo_rec.asset_activity_id,-1) <> NVL(l_old_eam_wo_rec.asset_activity_id,-1)) commented for BUG#5609642 */ ) THEN --default if new workorder or activity is changed
365
366 WIP_EAMWORKORDER_PVT.Get_EAM_Act_Cause_Default
367 (p_api_version => 1,
368 p_init_msg_list => FND_API.G_FALSE,
369 p_commit => FND_API.G_FALSE,
370 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
371 x_return_status => l_return_status,
372 x_msg_count => l_msg_count,
373 x_msg_data => l_err_text,
374 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
375 p_organization_id => p_eam_wo_rec.organization_id,
376 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
377 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
378 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
379 x_activity_cause_code => l_activity_cause
380 );
381
382 IF l_activity_cause IS NOT NULL AND
383 l_activity_cause <> FND_API.G_MISS_CHAR AND
384 p_eam_wo_rec.activity_cause IS NULL /* Added for BUG#5609642 */
385 THEN
386 x_eam_wo_rec.activity_cause := l_activity_cause;
387
388 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new activity_cause : ' || x_eam_wo_rec.activity_cause); END IF;
389 END IF;
390
391 WIP_EAMWORKORDER_PVT.Get_EAM_Act_Type_Default
392 (p_api_version => 1,
393 p_init_msg_list => FND_API.G_FALSE,
394 p_commit => FND_API.G_FALSE,
395 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
396 x_return_status => l_return_status,
397 x_msg_count => l_msg_count,
398 x_msg_data => l_err_text,
399 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
400 p_organization_id => p_eam_wo_rec.organization_id,
401 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
402 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
403 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
404 x_activity_type_code => l_activity_type
405 );
406
407 IF l_activity_type IS NOT NULL AND
408 l_activity_type <> FND_API.G_MISS_CHAR AND
409 p_eam_wo_rec.activity_source IS NULL /* Added for BUG#5609642 */
410 THEN
411 x_eam_wo_rec.activity_type := l_activity_type;
412 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new activity_type : ' || x_eam_wo_rec.activity_type); END IF;
413 END IF;
414
415 WIP_EAMWORKORDER_PVT.Get_EAM_Act_Source_Default
416 (p_api_version => 1,
417 p_init_msg_list => FND_API.G_FALSE,
418 p_commit => FND_API.G_FALSE,
419 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
420 x_return_status => l_return_status,
421 x_msg_count => l_msg_count,
422 x_msg_data => l_err_text,
423 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
424 p_organization_id => p_eam_wo_rec.organization_id,
425 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
426 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
427 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
428 x_activity_source_code => l_activity_source
429 );
430
431 IF l_activity_source IS NOT NULL AND
432 l_activity_source <> FND_API.G_MISS_CHAR AND
433 p_eam_wo_rec.activity_source IS NULL /* Added for BUG#5609642 */
434 THEN
435 x_eam_wo_rec.activity_source := l_activity_source;
436 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new activity_source : ' || x_eam_wo_rec.activity_source); END IF;
437 END IF;
438
439 WIP_EAMWORKORDER_PVT.Get_EAM_Shutdown_Default
440 (p_api_version => 1,
441 p_init_msg_list => FND_API.G_FALSE,
442 p_commit => FND_API.G_FALSE,
443 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
444 x_return_status => l_return_status,
445 x_msg_count => l_msg_count,
446 x_msg_data => l_err_text,
447 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
448 p_organization_id => p_eam_wo_rec.organization_id,
449 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
450 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
451 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
452 x_shutdown_type_code => l_shutdown_type
453 );
454
455 IF l_shutdown_type IS NOT NULL AND
456 l_shutdown_type <> FND_API.G_MISS_CHAR AND
457 p_eam_wo_rec.shutdown_type IS NULL /* Added for BUG#5609642 */
458 THEN
459 x_eam_wo_rec.shutdown_type := l_shutdown_type;
460 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new shutdown_type : ' || x_eam_wo_rec.shutdown_type); END IF;
461 END IF;
462
463 WIP_EAMWORKORDER_PVT.Get_EAM_Notification_Default
464 (p_api_version => 1,
465 p_init_msg_list => FND_API.G_FALSE,
466 p_commit => FND_API.G_FALSE,
467 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
468 x_return_status => l_return_status,
469 x_msg_count => l_msg_count,
470 x_msg_data => l_err_text,
471 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
472 p_organization_id => p_eam_wo_rec.organization_id,
473 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
474 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
475 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
476 x_notification_flag => l_notification_required
477 );
478
479 IF l_notification_required IS NOT NULL AND
480 l_notification_required <> FND_API.G_MISS_CHAR AND
481 p_eam_wo_rec.notification_required IS NULL /* Added for BUG#5609642 */
482 THEN
483 x_eam_wo_rec.notification_required := l_notification_required;
484 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new notification_required : ' || x_eam_wo_rec.notification_required); END IF;
485 END IF;
486
487 WIP_EAMWORKORDER_PVT.Get_EAM_Tagout_Default
488 (p_api_version => 1,
489 p_init_msg_list => FND_API.G_FALSE,
490 p_commit => FND_API.G_FALSE,
491 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
492 x_return_status => l_return_status,
493 x_msg_count => l_msg_count,
494 x_msg_data => l_err_text,
495 p_primary_item_id => p_eam_wo_rec.asset_activity_id,
496 p_organization_id => p_eam_wo_rec.organization_id,
497 p_maintenance_object_type => p_eam_wo_rec.maintenance_object_type,
498 p_maintenance_object_id => p_eam_wo_rec.maintenance_object_id,
499 p_rebuild_item_id => p_eam_wo_rec.rebuild_item_id,
500 x_tagout_required => l_tagout_required
501 );
502
503 IF l_tagout_required IS NOT NULL AND
504 l_tagout_required <> FND_API.G_MISS_CHAR AND
505 p_eam_wo_rec.tagout_required IS NULL /* Added for BUG#5609642 */
506 THEN
507 x_eam_wo_rec.tagout_required := l_tagout_required;
508 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('new tagout_default : ' || x_eam_wo_rec.tagout_required); END IF;
509 END IF;
510 END IF; --end of check for activity changed or workorder created
511 END IF; -- End if for 'IF asset_activity_id_id is not null'
512
513
514
515 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting owning department, priority, etc'); END IF;
516
517 -- Defaulting Owning Dept, Priority.
518
519 IF p_eam_wo_rec.asset_activity_id IS NOT NULL AND p_eam_wo_rec.asset_activity_id <> FND_API.G_MISS_NUM
520 THEN
521 -- WO with Activity
522
523 IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE /* OR
524 (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND
525 NVL(p_eam_wo_rec.asset_activity_id,-1) <> NVL(l_old_eam_wo_rec.asset_activity_id,-1))Commented for BUG#5609642 */ ) THEN --default if new workorder or activity is changed
526 BEGIN
527
528 IF p_eam_wo_rec.maintenance_object_type = 3
529 THEN
530 -- Asset or Serialized Rebuild with activity
531 SELECT
532 nvl(p_eam_wo_rec.owning_department, nvl(eomd.owning_department_id, eomd_asset.owning_department_id))
533 , nvl(p_eam_wo_rec.priority, meaa.priority_code)
534 INTO
535 l_owning_department
536 , l_priority
537 FROM
538 mtl_eam_asset_activities meaa
539 , eam_org_maint_defaults eomd
540 , eam_org_maint_defaults eomd_asset
541 WHERE
542 meaa.maintenance_object_type = 3
543 AND eomd.object_type (+) = 60
544 AND eomd.object_id (+) = meaa.activity_association_id
545 AND eomd_asset.object_type (+) = 50
546 AND eomd_asset.organization_id (+) = p_eam_wo_rec.organization_id
547 AND eomd_asset.object_id (+) = meaa.maintenance_object_id
548 AND meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
549 AND eomd.organization_id (+) = p_eam_wo_rec.organization_id
550 AND meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id;
551
552
553 IF l_owning_department IS NOT NULL AND
554 l_owning_department <> FND_API.G_MISS_NUM AND
555 p_eam_wo_rec.owning_department IS NULL /* Added for BUG#5609642 */
556 THEN
557 x_eam_wo_rec.owning_department := l_owning_department;
558 END IF;
559
560 IF x_eam_wo_rec.owning_department IS NULL THEN
561 select default_department_id into x_eam_wo_rec.owning_department
562 from WIP_EAM_PARAMETERS
563 where organization_id = p_eam_wo_rec.organization_id;
564 END IF;
565
566 IF l_priority IS NOT NULL AND
567 l_priority <> FND_API.G_MISS_NUM AND
568 p_eam_wo_rec.priority IS NULL /* Added for BUG#5609642 */
569 THEN
570 x_eam_wo_rec.priority := l_priority;
571 END IF;
572
573 ELSE
574 -- Rebuild with activity
575
576 IF p_eam_wo_rec.maintenance_object_type = 2 THEN
577 -- Non Serialized rebuild
578 SELECT
579 nvl(p_eam_wo_rec.owning_department, eomd.owning_department_id)
580 , nvl(p_eam_wo_rec.priority, meaa.priority_code)
581 INTO
582 l_owning_department
583 , l_priority
584 FROM
585 mtl_eam_asset_activities meaa,
586 eam_org_maint_defaults eomd
587 WHERE
588 meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
589 AND eomd.object_type (+) = 40
590 and eomd.organization_id (+) = p_eam_wo_rec.organization_id
591 and eomd.object_id (+) = meaa.activity_association_id
592 AND meaa.maintenance_object_type = 2
593 and meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id;
594
595 IF l_owning_department IS NOT NULL AND
596 l_owning_department <> FND_API.G_MISS_NUM AND
597 p_eam_wo_rec.owning_department IS NULL /* Added for BUG#5609642 */
598 THEN
599 x_eam_wo_rec.owning_department := l_owning_department;
600 END IF;
601
602 IF x_eam_wo_rec.owning_department IS NULL THEN
603 select default_department_id into x_eam_wo_rec.owning_department
604 from WIP_EAM_PARAMETERS
605 where organization_id = p_eam_wo_rec.organization_id;
606 END IF;
607
608 IF l_priority IS NOT NULL AND
609 l_priority <> FND_API.G_MISS_NUM AND
610 p_eam_wo_rec.priority IS NULL /* Added for BUG#5609642 */
611 THEN
612 x_eam_wo_rec.priority := l_priority;
613 END IF;
614
615 END IF;
616 END IF;
617
618 EXCEPTION
619 WHEN NO_DATA_FOUND THEN
620
621 l_out_mesg_token_tbl := l_mesg_token_tbl;
622 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
623 ( p_message_name => 'EAM_WO_ASSET_ACTIVITY_ASSOC'
624 , p_token_tbl => l_token_tbl
625 , p_mesg_token_tbl => l_mesg_token_tbl
626 , x_mesg_token_tbl => l_out_mesg_token_tbl
627 );
628 l_mesg_token_tbl := l_out_mesg_token_tbl;
629
630 x_return_status := FND_API.G_RET_STS_ERROR;
631 x_mesg_token_tbl := l_mesg_token_tbl ;
632
633 WHEN OTHERS THEN
634 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
635 ( p_message_name => NULL
636 , p_message_text => G_PKG_NAME || SQLERRM
637 , x_mesg_token_Tbl => x_mesg_token_tbl
638 );
639
640 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
641 END;
642 END IF; --end of check for activity changed/workorder created
643
644 ELSIF x_eam_wo_rec.owning_department IS NULL and (p_eam_wo_rec.maintenance_object_type = 3)
645 -- Asset/Serialized rebuild WO without Activity
646
647 THEN
648 SELECT
649 p_eam_wo_rec.priority
650 , nvl(p_eam_wo_rec.owning_department, eomd.owning_department_id)
651 INTO
652 l_priority
653 , l_owning_department
654 FROM
655 csi_item_instances cii,
656 eam_org_maint_defaults eomd
657 WHERE
658 cii.instance_id = p_eam_wo_rec.maintenance_object_id
659 and eomd.object_type (+) = 50
660 and eomd.object_id (+) = cii.instance_id
661 and eomd.organization_id (+) = p_eam_wo_rec.organization_id;
662
663 IF l_owning_department IS NOT NULL AND
664 l_owning_department <> FND_API.G_MISS_NUM THEN
665 x_eam_wo_rec.owning_department := l_owning_department;
666 END IF;
667
668 IF l_priority IS NOT NULL AND
669 l_priority <> FND_API.G_MISS_NUM AND
670 p_eam_wo_rec.priority IS NULL /* Added for BUG#5609642 */
671 THEN
672 x_eam_wo_rec.priority := l_priority;
673 END IF;
674
675 IF x_eam_wo_rec.owning_department IS NULL THEN
676 select default_department_id into x_eam_wo_rec.owning_department
677 from WIP_EAM_PARAMETERS
678 where organization_id = p_eam_wo_rec.organization_id;
679 END IF;
680 END IF;
681
682
683 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting accounts'); END IF;
684
685
686 -- Defaulting Accounts
687 BEGIN
688 SELECT
689 material_account
690 , material_overhead_account
691 , resource_account
692 , outside_processing_account
693 , material_variance_account
694 , resource_variance_account
695 , outside_proc_variance_account
696 , std_cost_adjustment_account
697 , overhead_account
698 , overhead_variance_account
699 INTO
700 l_material_account
701 , l_material_overhead_account
702 , l_resource_account
703 , l_outside_processing_account
704 , l_material_variance_account
705 , l_resource_variance_account
706 , l_osp_var_account
707 , l_std_cost_adjustment_account
708 , l_overhead_account
709 , l_overhead_variance_account
710 FROM wip_accounting_classes
711 WHERE
712 class_code = x_eam_wo_rec.class_code
713 AND organization_id = p_eam_wo_rec.organization_id;
714
715 x_eam_wo_rec.material_account := l_material_account;
716 x_eam_wo_rec.material_overhead_account := l_material_overhead_account;
717 x_eam_wo_rec.resource_account := l_resource_account;
718 x_eam_wo_rec.outside_processing_account := l_outside_processing_account;
719 x_eam_wo_rec.material_variance_account := l_material_variance_account;
720 x_eam_wo_rec.resource_variance_account := l_resource_variance_account;
721 x_eam_wo_rec.outside_proc_variance_account := l_osp_var_account;
722 x_eam_wo_rec.std_cost_adjustment_account := l_std_cost_adjustment_account;
723 x_eam_wo_rec.overhead_account := l_overhead_account;
724 x_eam_wo_rec.overhead_variance_account := l_overhead_variance_account;
725
726 EXCEPTION
727 WHEN NO_DATA_FOUND THEN
728
729 l_out_mesg_token_tbl := l_mesg_token_tbl;
730 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
731 ( p_message_name => 'EAM_WO_CLASS_CODE'
732 , p_token_tbl => l_token_tbl
733 , p_mesg_token_tbl => l_mesg_token_tbl
734 , x_mesg_token_tbl => l_out_mesg_token_tbl
735 );
736 l_mesg_token_tbl := l_out_mesg_token_tbl;
737
738 x_return_status := FND_API.G_RET_STS_ERROR;
739 x_mesg_token_tbl := l_mesg_token_tbl ;
740
741 WHEN OTHERS THEN
742 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
743 ( p_message_name => NULL
744 , p_message_text => G_PKG_NAME || SQLERRM
745 , x_mesg_token_Tbl => x_mesg_token_tbl
746 );
747
748 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
749 END;
750 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting USER_DEFINED_STATUS_ID'); END IF;
751
752 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting USER_DEFINED_STATUS_ID'); END IF;
753
754 --Default the User_Defined_Status_Id if it is not passed when creating a workorder. OR if system status is modified and neither the user_defined_status nor the pending flag are modfied
755 --Then also set the User_defined_status to the seeded status mapped to the System status
756 IF( p_eam_wo_rec.user_defined_status_id IS NULL --create and user_defined_staus not provided
757 OR
758 ( p_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE --workorder updated
759 AND (p_eam_wo_rec.status_type <> p_old_eam_wo_rec.status_type) --system status updated
760 --netiher the user_defined_status nor the pending flag are modfied
761 AND NOT((p_eam_wo_rec.user_defined_status_id <> p_old_eam_wo_rec.user_defined_status_id) OR (NVL(p_eam_wo_rec.pending_flag,'N') <> NVL(p_old_eam_wo_rec.pending_flag,'N')))
762 )
763 )THEN
764 x_eam_wo_rec.user_defined_status_id := p_eam_wo_rec.status_type; --set the user_defined_status_id to status_type since status_id for seeded statuses will be same as status_type
765
766 END IF; --end of check for defaulting user_defined_status
767
768 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting ISSUE_ZERO_COST_FLAG'); END IF;
769
770 -- Defaulting ISSUE_ZERO_COST_FLAG
771 IF p_eam_wo_rec.issue_zero_cost_flag IS NULL OR
772 p_eam_wo_rec.issue_zero_cost_flag = FND_API.G_MISS_CHAR
773 THEN
774 SELECT
775 nvl(issue_zero_cost_flag,'N')
776 INTO x_eam_wo_rec.issue_zero_cost_flag
777 FROM wip_eam_parameters
778 WHERE organization_id = p_eam_wo_rec.organization_id;
779
780 END IF;
781
782 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('PO creation time'); END IF;
783
784 -- Defaulting PO creation time
785 IF p_eam_wo_rec.po_creation_time IS NULL OR
786 p_eam_wo_rec.po_creation_time = FND_API.G_MISS_NUM
787 THEN
788 SELECT
789 po_creation_time
790 INTO x_eam_wo_rec.po_creation_time
791 FROM wip_parameters
792 WHERE organization_id = p_eam_wo_rec.organization_id;
793
794 END IF;
795
796 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting firm planned flag'); END IF;
797
798 -- Defaulting Firm Planned Flag
799
800 IF p_eam_wo_rec.firm_planned_flag IS NULL OR
801 p_eam_wo_rec.firm_planned_flag = FND_API.G_MISS_NUM
802 THEN
803 x_eam_wo_rec.firm_planned_flag := 2;
804
805 -- Defaulting Firm Planned Flag when auto firm flag on create checked.
806 IF p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
807 THEN
808 select nvl(auto_firm_on_create,'N') into l_auto_firm_create_flag
809 from wip_eam_parameters
810 where organization_id = p_eam_wo_rec.organization_id;
811 IF l_auto_firm_create_flag = 'Y' THEN
812 x_eam_wo_rec.firm_planned_flag := 1;
813 END IF;
814 END IF;
815
816 END IF;
817
818
819 -- If updating a WO to relesed status and auto_firm_flag is
820 -- turned on, then firm the WO. Also if WO is created directly
821 -- in released status and auto firm is ON.
822 IF (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE
823 and p_eam_wo_rec.status_type = 3 and
824 l_old_eam_wo_rec.status_type in (1,6,17)
825 ) OR
826 (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
827 and p_eam_wo_rec.status_type = 3
828 )
829 THEN
830 select nvl(auto_firm_flag,'N') into l_auto_firm_flag
831 from wip_eam_parameters
832 where organization_id = p_eam_wo_rec.organization_id;
833 IF l_auto_firm_flag = 'Y' THEN
834 x_eam_wo_rec.firm_planned_flag := 1;
835 END IF;
836 END IF;
837
838
839 -- If updating a WO to relesaed status and auto_firm_flag is
840 -- turned on, then set the WO scheduled dates to the old values
841 -- . Otherwise, the date encompassment error will be thrown up.
842 IF (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE
843 and p_eam_wo_rec.status_type = 3
844 and l_old_eam_wo_rec.status_type in (1,6,17)
845 and l_auto_firm_flag = 'Y'
846 )
847 THEN
848
849 x_eam_wo_rec.scheduled_start_date := l_old_eam_wo_rec.scheduled_start_date;
850 x_eam_wo_rec.scheduled_completion_date := l_old_eam_wo_rec.scheduled_completion_date;
851
852 END IF;
853
854
855 -- Defaulting Manual Rebuild Flag
856
857 IF p_eam_wo_rec.rebuild_item_id is not null AND
858 (p_eam_wo_rec.manual_rebuild_flag IS NULL OR
859 p_eam_wo_rec.manual_rebuild_flag = FND_API.G_MISS_CHAR)
860 THEN
861 x_eam_wo_rec.manual_rebuild_flag := 'Y';
862
863 END IF;
864
865
866 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting scheduled start date and completion date from the PM Suggested Dates'); END IF;
867
868 -- Defaulting Scheduled Dates from the PM Suggested Dates
869
870 IF (p_eam_wo_rec.pm_suggested_start_date IS NOT NULL AND
871 p_eam_wo_rec.pm_suggested_start_date <> FND_API.G_MISS_DATE) OR
872 (p_eam_wo_rec.pm_suggested_end_date IS NOT NULL AND
873 p_eam_wo_rec.pm_suggested_end_date <> FND_API.G_MISS_DATE)
874 THEN
875 x_eam_wo_rec.requested_start_date := p_eam_wo_rec.pm_suggested_start_date;
876 x_eam_wo_rec.due_date := p_eam_wo_rec.pm_suggested_end_date;
877
878 END IF;
879
880 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting scheduled start date and completion date'); END IF;
881
882
883 -- Defaulting Requested Start Date
884
885 IF p_eam_wo_rec.scheduled_start_date IS NOT NULL AND
886 p_eam_wo_rec.scheduled_start_date <> FND_API.G_MISS_DATE AND
887 p_eam_wo_rec.requested_start_date IS NULL AND
888 p_eam_wo_rec.due_date IS NULL and
889 x_eam_wo_rec.requested_start_date IS NULL and
890 x_eam_wo_rec.due_date IS NULL
891 THEN
892 x_eam_wo_rec.requested_start_date := p_eam_wo_rec.scheduled_start_date;
893
894 END IF;
895
896 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Defaulting material_issue_by_mo flag'); END IF;
897
898 -- Defaulting the MATERIAL_ISSUE_BY_MO flag
899
900 IF p_eam_wo_rec.material_issue_by_mo IS NULL OR
901 p_eam_wo_rec.material_issue_by_mo = FND_API.G_MISS_CHAR
902 THEN
903 select nvl(material_issue_by_mo,'N')
904 into x_eam_wo_rec.material_issue_by_mo
905 from wip_eam_parameters
906 where organization_id = p_eam_wo_rec.organization_id;
907 END IF;
908
909 -- Defaulting the job_quantity
910
911 IF p_eam_wo_rec.job_quantity IS NULL OR
912 p_eam_wo_rec.job_quantity = FND_API.G_MISS_NUM
913 THEN
914 x_eam_wo_rec.job_quantity := 1;
915 END IF;
916
917 -- Defaulting the wip_supply_type
918
919 IF p_eam_wo_rec.wip_supply_type IS NULL OR
920 p_eam_wo_rec.wip_supply_type = FND_API.G_MISS_NUM
921 THEN
922 x_eam_wo_rec.wip_supply_type := 7;
923 END IF;
924
925
926 -- Defaulting the FAILURE_CODE_REQUIRED flag .. bug # 4709084
927
928 IF p_eam_wo_rec.failure_code_required IS NULL OR
929 p_eam_wo_rec.failure_code_required = FND_API.G_MISS_CHAR
930 THEN
931 x_eam_wo_rec.failure_code_required := 'N';
932 END IF;
933
934
935 l_out_eam_wo_rec := x_eam_wo_rec;
936 get_flex_eam_wo
937 ( p_eam_wo_rec => x_eam_wo_rec
938 , x_eam_wo_rec => l_out_eam_wo_rec
939 );
940 x_eam_wo_rec := l_out_eam_wo_rec;
941
942
943 EXCEPTION
944 WHEN OTHERS THEN
945 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
946 ( p_message_name => NULL
947 , p_message_text => G_PKG_NAME || SQLERRM
948 , x_mesg_token_Tbl => x_mesg_token_tbl
949 );
950
951 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
952
953 END Attribute_Defaulting;
954
955
956
957
958 PROCEDURE Conditional_Defaulting
959 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
960 , x_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
961 , x_mesg_token_tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
962 , x_return_status OUT NOCOPY VARCHAR2
963 )
964 IS
965
966 l_serial_number varchar2(30);
967 l_inventory_item_id number;
968 l_eam_item_type number;
969
970 BEGIN
971
972 x_eam_wo_rec := p_eam_wo_rec;
973 x_return_status := FND_API.G_RET_STS_SUCCESS;
974
975
976 if (p_eam_wo_rec.maintenance_object_type = 3 and p_eam_wo_rec.maintenance_object_source = 1) then
977
978 select cii.serial_number
979 , cii.inventory_item_id
980 , msi.eam_item_type
981 into l_serial_number
982 , l_inventory_item_id
983 , l_eam_item_type
984 from csi_item_instances cii, mtl_system_items msi
985 where cii.last_vld_organization_id = msi.organization_id
986 and cii.inventory_item_id = msi.inventory_item_id
987 and cii.instance_id = p_eam_wo_rec.maintenance_object_id;
988
989 if l_eam_item_type = 1 then
990 x_eam_wo_rec.asset_number := l_serial_number;
991 else
992 x_eam_wo_rec.rebuild_serial_number := l_serial_number;
993 end if;
994
995 elsif (p_eam_wo_rec.maintenance_object_type = 2) then
996
997 select inventory_item_id
998 into x_eam_wo_rec.rebuild_item_id
999 from mtl_system_items msi, mtl_parameters mp
1000 where msi.organization_id = mp.organization_id
1001 and mp.maint_organization_id = p_eam_wo_rec.organization_id
1002 and msi.inventory_item_id = p_eam_wo_rec.maintenance_object_id
1003 and rownum = 1;
1004
1005 end if;
1006
1007 EXCEPTION
1008 WHEN OTHERS THEN
1009
1010 EAM_ERROR_MESSAGE_PVT.Add_Error_Token
1011 ( p_message_name => NULL
1012 , p_message_text => G_PKG_NAME || SQLERRM
1013 , x_mesg_token_Tbl => x_mesg_token_tbl
1014 );
1015
1016 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1017
1018 END Conditional_Defaulting;
1019
1020
1021
1022 /******************************************************************
1023 * Procedure : Populate_Null_Columns
1024 * Parameters IN : Work Order column record
1025 * Old Work Order Column Record
1026 * Parameters OUT NOCOPY: Work Order column record after populating
1027 * Purpose : This procedure will look at the columns that the user
1028 * has not filled in and will assign those columns a
1029 * value from the old record.
1030 * This procedure is not called for CREATE
1031 ********************************************************************/
1032 PROCEDURE Populate_Null_Columns
1033 ( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
1034 , p_old_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
1035 , x_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
1036 )
1037 IS
1038 BEGIN
1039 x_eam_wo_rec := p_eam_wo_rec;
1040 x_eam_wo_rec := p_eam_wo_rec;
1041
1042 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Processing null columns prior update'); END IF;
1043
1044
1045 IF p_eam_wo_rec.wip_entity_name IS NULL OR
1046 p_eam_wo_rec.wip_entity_name = FND_API.G_MISS_CHAR
1047 THEN
1048 x_eam_wo_rec.wip_entity_name := p_old_eam_wo_rec.wip_entity_name;
1049 END IF;
1050
1051 IF p_eam_wo_rec.description IS NULL
1052 THEN
1053 x_eam_wo_rec.description := p_old_eam_wo_rec.description;
1054 END IF;
1055
1056 IF p_eam_wo_rec.description = FND_API.G_MISS_CHAR
1057 THEN
1058 x_eam_wo_rec.description := NULL;
1059 END IF;
1060
1061 IF p_eam_wo_rec.asset_number IS NULL
1062 THEN
1063 x_eam_wo_rec.asset_number := p_old_eam_wo_rec.asset_number;
1064 END IF;
1065
1066 IF p_eam_wo_rec.asset_group_id IS NULL
1067 THEN
1068 x_eam_wo_rec.asset_group_id := p_old_eam_wo_rec.asset_group_id;
1069 END IF;
1070
1071 IF p_eam_wo_rec.rebuild_serial_number IS NULL
1072 THEN
1073 x_eam_wo_rec.rebuild_serial_number := p_old_eam_wo_rec.rebuild_serial_number;
1074 END IF;
1075
1076 IF p_eam_wo_rec.eam_linear_location_id IS NULL OR
1077 p_eam_wo_rec.eam_linear_location_id = FND_API.G_MISS_NUM
1078 THEN
1079 x_eam_wo_rec.eam_linear_location_id := p_old_eam_wo_rec.eam_linear_location_id;
1080 END IF;
1081
1082 IF p_eam_wo_rec.rebuild_item_id IS NULL
1083 THEN
1084 x_eam_wo_rec.rebuild_item_id := p_old_eam_wo_rec.rebuild_item_id;
1085 END IF;
1086
1087 --if FND_API.G_MISS_xx is passed then set values to NULL
1088 IF p_eam_wo_rec.asset_number = FND_API.G_MISS_CHAR
1089 THEN
1090 x_eam_wo_rec.asset_number := NULL;
1091 END IF;
1092
1093 IF p_eam_wo_rec.rebuild_serial_number = FND_API.G_MISS_CHAR
1094 THEN
1095 x_eam_wo_rec.rebuild_serial_number := NULL;
1096 END IF;
1097
1098 IF p_eam_wo_rec.asset_group_id = FND_API.G_MISS_NUM
1099 THEN
1100 x_eam_wo_rec.asset_group_id := NULL;
1101 END IF;
1102
1103 IF p_eam_wo_rec.rebuild_item_id = FND_API.G_MISS_NUM
1104 THEN
1105 x_eam_wo_rec.rebuild_item_id := NULL;
1106 END IF;
1107
1108 IF p_eam_wo_rec.class_code IS NULL OR
1109 p_eam_wo_rec.class_code = FND_API.G_MISS_CHAR
1110 THEN
1111 x_eam_wo_rec.class_code := p_old_eam_wo_rec.class_code;
1112 END IF;
1113
1114 IF p_eam_wo_rec.asset_activity_id IS NULL --OR p_eam_wo_rec.asset_activity_id = FND_API.G_MISS_NUM
1115 THEN
1116 x_eam_wo_rec.asset_activity_id := p_old_eam_wo_rec.asset_activity_id;
1117 END IF;
1118
1119 IF p_eam_wo_rec.asset_activity_id = FND_API.G_MISS_NUM THEN
1120 x_eam_wo_rec.asset_activity_id := NULL;
1121 END IF;
1122
1123
1124 IF p_eam_wo_rec.activity_type IS NULL
1125 THEN
1126 x_eam_wo_rec.activity_type := p_old_eam_wo_rec.activity_type;
1127 END IF;
1128
1129 IF p_eam_wo_rec.activity_type = FND_API.G_MISS_CHAR
1130 THEN
1131 x_eam_wo_rec.activity_type := NULL;
1132 END IF;
1133
1134 IF p_eam_wo_rec.activity_cause IS NULL
1135 THEN
1136 x_eam_wo_rec.activity_cause := p_old_eam_wo_rec.activity_cause;
1137 END IF;
1138
1139 IF p_eam_wo_rec.activity_cause = FND_API.G_MISS_CHAR
1140 THEN
1141 x_eam_wo_rec.activity_cause := NULL;
1142 END IF;
1143
1144 IF p_eam_wo_rec.activity_source IS NULL
1145 THEN
1146 x_eam_wo_rec.activity_source := p_old_eam_wo_rec.activity_source;
1147 END IF;
1148
1149 IF p_eam_wo_rec.activity_source = FND_API.G_MISS_CHAR
1150 THEN
1151 x_eam_wo_rec.activity_source := NULL;
1152 END IF;
1153
1154 IF p_eam_wo_rec.status_type IS NULL OR
1155 p_eam_wo_rec.status_type = FND_API.G_MISS_NUM
1156 THEN
1157 x_eam_wo_rec.status_type := p_old_eam_wo_rec.status_type;
1158 END IF;
1159
1160 IF p_eam_wo_rec.user_defined_status_id IS NULL OR
1161 p_eam_wo_rec.user_defined_status_id = FND_API.G_MISS_NUM
1162 THEN
1163 x_eam_wo_rec.user_defined_status_id := p_old_eam_wo_rec.user_defined_status_id;
1164 END IF;
1165
1166 IF p_eam_wo_rec.job_quantity IS NULL OR
1167 p_eam_wo_rec.job_quantity = FND_API.G_MISS_NUM
1168 THEN
1169 x_eam_wo_rec.job_quantity := p_old_eam_wo_rec.job_quantity;
1170 END IF;
1171
1172 IF p_eam_wo_rec.date_released IS NULL OR
1173 p_eam_wo_rec.date_released = FND_API.G_MISS_DATE
1174 THEN
1175 x_eam_wo_rec.date_released := p_old_eam_wo_rec.date_released;
1176 END IF;
1177
1178 IF p_eam_wo_rec.owning_department IS NULL OR
1179 p_eam_wo_rec.owning_department = FND_API.G_MISS_NUM
1180 THEN
1181 x_eam_wo_rec.owning_department := p_old_eam_wo_rec.owning_department;
1182 END IF;
1183
1184 IF p_eam_wo_rec.priority IS NULL
1185 THEN
1186 x_eam_wo_rec.priority := p_old_eam_wo_rec.priority;
1187 END IF;
1188
1189 IF p_eam_wo_rec.priority = FND_API.G_MISS_NUM
1190 THEN
1191 x_eam_wo_rec.priority := NULL;
1192 END IF;
1193
1194 IF p_eam_wo_rec.work_order_type IS NULL
1195 THEN
1196 x_eam_wo_rec.work_order_type := p_old_eam_wo_rec.work_order_type;
1197 END IF;
1198
1199 IF p_eam_wo_rec.work_order_type = FND_API.G_MISS_CHAR
1200 THEN
1201 x_eam_wo_rec.work_order_type := NULL;
1202 END IF;
1203
1204 -- Requested Start Date and Due date will have to be handled
1205 -- together since only one of them can be not null
1206 IF (p_eam_wo_rec.requested_start_date IS NULL OR
1207 p_eam_wo_rec.requested_start_date = FND_API.G_MISS_DATE) AND
1208 (p_eam_wo_rec.due_date IS NULL OR
1209 p_eam_wo_rec.due_date = FND_API.G_MISS_DATE)
1210 THEN
1211 x_eam_wo_rec.requested_start_date := p_old_eam_wo_rec.requested_start_date;
1212 x_eam_wo_rec.due_date := p_old_eam_wo_rec.due_date;
1213 END IF;
1214
1215
1216 /*
1217 -- PM Suggested Start Date and PM Suggested End date will have to be handled
1218 -- together since only one of them can be not null
1219 IF (p_eam_wo_rec.pm_suggested_start_date IS NULL OR
1220 p_eam_wo_rec.pm_suggested_start_date = FND_API.G_MISS_DATE) AND
1221 (p_eam_wo_rec.pm_suggested_end_date IS NULL OR
1222 p_eam_wo_rec.pm_suggested_end_date = FND_API.G_MISS_DATE)
1223 THEN
1224 x_eam_wo_rec.pm_suggested_start_date := p_old_eam_wo_rec.pm_suggested_start_date;
1225 x_eam_wo_rec.pm_suggested_end_date := p_old_eam_wo_rec.pm_suggested_end_date;
1226 END IF;
1227 */
1228
1229
1230 IF p_eam_wo_rec.pm_base_meter_reading IS NULL OR
1231 p_eam_wo_rec.pm_base_meter_reading = FND_API.G_MISS_NUM
1232 THEN
1233 x_eam_wo_rec.pm_base_meter_reading := p_old_eam_wo_rec.pm_base_meter_reading;
1234 END IF;
1235
1236 IF p_eam_wo_rec.pm_base_meter IS NULL OR
1237 p_eam_wo_rec.pm_base_meter = FND_API.G_MISS_NUM
1238 THEN
1239 x_eam_wo_rec.pm_base_meter := p_old_eam_wo_rec.pm_base_meter;
1240 END IF;
1241
1242
1243 IF p_eam_wo_rec.shutdown_type IS NULL
1244 THEN
1245 x_eam_wo_rec.shutdown_type := p_old_eam_wo_rec.shutdown_type;
1246 END IF;
1247
1248 IF p_eam_wo_rec.shutdown_type = FND_API.G_MISS_CHAR
1249 THEN
1250 x_eam_wo_rec.shutdown_type := NULL;
1251 END IF;
1252
1253 IF p_eam_wo_rec.firm_planned_flag IS NULL OR
1254 p_eam_wo_rec.firm_planned_flag = FND_API.G_MISS_NUM
1255 THEN
1256 x_eam_wo_rec.firm_planned_flag := p_old_eam_wo_rec.firm_planned_flag;
1257 END IF;
1258
1259 IF p_eam_wo_rec.issue_zero_cost_flag IS NULL OR
1260 p_eam_wo_rec.issue_zero_cost_flag = FND_API.G_MISS_CHAR
1261 THEN
1262 x_eam_wo_rec.issue_zero_cost_flag := p_old_eam_wo_rec.issue_zero_cost_flag;
1263 END IF;
1264
1265 IF p_eam_wo_rec.notification_required IS NULL OR
1266 p_eam_wo_rec.notification_required = FND_API.G_MISS_CHAR
1267 THEN
1268 x_eam_wo_rec.notification_required := p_old_eam_wo_rec.notification_required;
1269 END IF;
1270
1271 IF p_eam_wo_rec.tagout_required IS NULL OR
1272 p_eam_wo_rec.tagout_required = FND_API.G_MISS_CHAR
1273 THEN
1274 x_eam_wo_rec.tagout_required := p_old_eam_wo_rec.tagout_required;
1275 END IF;
1276
1277 IF p_eam_wo_rec.plan_maintenance IS NULL OR
1278 p_eam_wo_rec.plan_maintenance = FND_API.G_MISS_CHAR
1279 THEN
1280 x_eam_wo_rec.plan_maintenance := p_old_eam_wo_rec.plan_maintenance;
1281 END IF;
1282
1283 /* commented for bug 5346446
1284 IF p_eam_wo_rec.project_id IS NULL OR
1285 p_eam_wo_rec.project_id = FND_API.G_MISS_NUM
1286 THEN
1287 x_eam_wo_rec.project_id := p_old_eam_wo_rec.project_id;
1288 END IF;
1289
1290 IF p_eam_wo_rec.task_id IS NULL OR
1291 p_eam_wo_rec.task_id = FND_API.G_MISS_NUM
1292 THEN
1293 x_eam_wo_rec.task_id := p_old_eam_wo_rec.task_id;
1294 END IF;*/
1295
1296 /* Added for bug#5346446 Start */
1297 IF p_eam_wo_rec.project_id IS NULL THEN
1298 x_eam_wo_rec.project_id := p_old_eam_wo_rec.project_id;
1299 ELSIF p_eam_wo_rec.project_id = FND_API.G_MISS_NUM THEN
1300 x_eam_wo_rec.project_id := NULL;
1301 END IF;
1302
1303 IF p_eam_wo_rec.task_id IS NULL THEN
1304 x_eam_wo_rec.task_id := p_old_eam_wo_rec.task_id;
1305 ELSIF p_eam_wo_rec.task_id = FND_API.G_MISS_NUM THEN
1306 x_eam_wo_rec.task_id := NULL;
1307 END IF;
1308 /* Added for bug#5346446 End */
1309
1310 IF p_eam_wo_rec.end_item_unit_number IS NULL OR
1311 p_eam_wo_rec.end_item_unit_number = FND_API.G_MISS_NUM
1312 THEN
1313 x_eam_wo_rec.end_item_unit_number := p_old_eam_wo_rec.end_item_unit_number;
1314 END IF;
1315
1316 IF p_eam_wo_rec.schedule_group_id IS NULL OR
1317 p_eam_wo_rec.schedule_group_id = FND_API.G_MISS_NUM
1318 THEN
1319
1320 x_eam_wo_rec.schedule_group_id := p_old_eam_wo_rec.schedule_group_id;
1321 END IF;
1322
1323 IF p_eam_wo_rec.bom_revision_date IS NULL OR
1324 p_eam_wo_rec.bom_revision_date = FND_API.G_MISS_DATE
1325 THEN
1326 x_eam_wo_rec.bom_revision_date := p_old_eam_wo_rec.bom_revision_date;
1327 END IF;
1328
1329 IF p_eam_wo_rec.routing_revision_date IS NULL OR
1330 p_eam_wo_rec.routing_revision_date = FND_API.G_MISS_DATE
1331 THEN
1332 x_eam_wo_rec.routing_revision_date := p_old_eam_wo_rec.routing_revision_date;
1333 END IF;
1334
1335
1336 IF p_eam_wo_rec.alternate_routing_designator IS NULL OR
1337 p_eam_wo_rec.alternate_routing_designator = FND_API.G_MISS_NUM
1338 THEN
1339 x_eam_wo_rec.alternate_routing_designator := p_old_eam_wo_rec.alternate_routing_designator;
1340 END IF;
1341
1342 IF p_eam_wo_rec.alternate_bom_designator IS NULL OR
1343 p_eam_wo_rec.alternate_bom_designator = FND_API.G_MISS_NUM
1344 THEN
1345 x_eam_wo_rec.alternate_bom_designator := p_old_eam_wo_rec.alternate_bom_designator;
1346 END IF;
1347
1348 IF p_eam_wo_rec.routing_revision IS NULL OR
1349 p_eam_wo_rec.routing_revision = FND_API.G_MISS_CHAR
1350 THEN
1351 x_eam_wo_rec.routing_revision := p_old_eam_wo_rec.routing_revision;
1352 END IF;
1353
1354 IF p_eam_wo_rec.bom_revision IS NULL OR
1355 p_eam_wo_rec.bom_revision = FND_API.G_MISS_CHAR
1356 THEN
1357 x_eam_wo_rec.bom_revision := p_old_eam_wo_rec.bom_revision;
1358 END IF;
1359
1360 IF p_eam_wo_rec.manual_rebuild_flag IS NULL OR
1361 p_eam_wo_rec.manual_rebuild_flag = FND_API.G_MISS_CHAR
1362 THEN
1363 x_eam_wo_rec.manual_rebuild_flag := p_old_eam_wo_rec.manual_rebuild_flag;
1364 END IF;
1365
1366 IF p_eam_wo_rec.material_account IS NULL OR
1367 p_eam_wo_rec.material_account = FND_API.G_MISS_NUM
1368 THEN
1369 x_eam_wo_rec.material_account := p_old_eam_wo_rec.material_account;
1370 END IF;
1371
1372 IF p_eam_wo_rec.material_overhead_account IS NULL OR
1373 p_eam_wo_rec.material_overhead_account = FND_API.G_MISS_NUM
1374 THEN
1375 x_eam_wo_rec.material_overhead_account := p_old_eam_wo_rec.material_overhead_account;
1376 END IF;
1377
1378 IF p_eam_wo_rec.resource_account IS NULL OR
1379 p_eam_wo_rec.resource_account = FND_API.G_MISS_NUM
1380 THEN
1381 x_eam_wo_rec.resource_account := p_old_eam_wo_rec.resource_account;
1382 END IF;
1383
1384 IF p_eam_wo_rec.outside_processing_account IS NULL OR
1385 p_eam_wo_rec.outside_processing_account = FND_API.G_MISS_NUM
1386 THEN
1387 x_eam_wo_rec.outside_processing_account := p_old_eam_wo_rec.outside_processing_account;
1388 END IF;
1389
1390 IF p_eam_wo_rec.material_variance_account IS NULL OR
1391 p_eam_wo_rec.material_variance_account = FND_API.G_MISS_NUM
1392 THEN
1393 x_eam_wo_rec.material_variance_account := p_old_eam_wo_rec.material_variance_account;
1394 END IF;
1395
1396 IF p_eam_wo_rec.resource_variance_account IS NULL OR
1397 p_eam_wo_rec.resource_variance_account = FND_API.G_MISS_NUM
1398 THEN
1399 x_eam_wo_rec.resource_variance_account := p_old_eam_wo_rec.resource_variance_account;
1400 END IF;
1401
1402 IF p_eam_wo_rec.outside_proc_variance_account IS NULL OR
1403 p_eam_wo_rec.outside_proc_variance_account = FND_API.G_MISS_NUM
1404 THEN
1405 x_eam_wo_rec.outside_proc_variance_account := p_old_eam_wo_rec.outside_proc_variance_account;
1406 END IF;
1407
1408 IF p_eam_wo_rec.std_cost_adjustment_account IS NULL OR
1409 p_eam_wo_rec.std_cost_adjustment_account = FND_API.G_MISS_NUM
1410 THEN
1411 x_eam_wo_rec.std_cost_adjustment_account := p_old_eam_wo_rec.std_cost_adjustment_account;
1412 END IF;
1413
1414 IF p_eam_wo_rec.overhead_account IS NULL OR
1415 p_eam_wo_rec.overhead_account = FND_API.G_MISS_NUM
1416 THEN
1417 x_eam_wo_rec.overhead_account := p_old_eam_wo_rec.overhead_account;
1418 END IF;
1419
1420 IF p_eam_wo_rec.overhead_variance_account IS NULL OR
1421 p_eam_wo_rec.overhead_variance_account = FND_API.G_MISS_NUM
1422 THEN
1423 x_eam_wo_rec.overhead_variance_account := p_old_eam_wo_rec.overhead_variance_account;
1424 END IF;
1425
1426 IF p_eam_wo_rec.scheduled_start_date IS NULL OR
1427 p_eam_wo_rec.scheduled_start_date = FND_API.G_MISS_DATE
1428 THEN
1429 x_eam_wo_rec.scheduled_start_date := p_old_eam_wo_rec.scheduled_start_date;
1430 END IF;
1431
1432 IF p_eam_wo_rec.scheduled_completion_date IS NULL OR
1433 p_eam_wo_rec.scheduled_completion_date = FND_API.G_MISS_DATE
1434 THEN
1435 x_eam_wo_rec.scheduled_completion_date := p_old_eam_wo_rec.scheduled_completion_date;
1436 END IF;
1437
1438 IF p_eam_wo_rec.common_bom_sequence_id IS NULL OR
1439 p_eam_wo_rec.common_bom_sequence_id = FND_API.G_MISS_NUM
1440 THEN
1441 x_eam_wo_rec.common_bom_sequence_id := p_old_eam_wo_rec.common_bom_sequence_id;
1442 END IF;
1443
1444 IF p_eam_wo_rec.common_routing_sequence_id IS NULL OR
1445 p_eam_wo_rec.common_routing_sequence_id = FND_API.G_MISS_NUM
1446 THEN
1447 x_eam_wo_rec.common_routing_sequence_id := p_old_eam_wo_rec.common_routing_sequence_id;
1448 END IF;
1449
1450 IF p_eam_wo_rec.source_line_id IS NULL OR
1451 p_eam_wo_rec.source_line_id = FND_API.G_MISS_NUM
1452 THEN
1453 x_eam_wo_rec.source_line_id := p_old_eam_wo_rec.source_line_id;
1454 END IF;
1455
1456 IF p_eam_wo_rec.source_code IS NULL OR
1457 p_eam_wo_rec.source_code = FND_API.G_MISS_CHAR
1458 THEN
1459 x_eam_wo_rec.source_code := p_old_eam_wo_rec.source_code;
1460 END IF;
1461
1462 IF p_eam_wo_rec.gen_object_id IS NULL OR
1463 p_eam_wo_rec.gen_object_id = FND_API.G_MISS_NUM
1464 THEN
1465 x_eam_wo_rec.gen_object_id := p_old_eam_wo_rec.gen_object_id;
1466 END IF;
1467
1468 IF p_eam_wo_rec.maintenance_object_id IS NULL OR
1469 p_eam_wo_rec.maintenance_object_id = FND_API.G_MISS_NUM
1470 THEN
1471 x_eam_wo_rec.maintenance_object_id := p_old_eam_wo_rec.maintenance_object_id;
1472 END IF;
1473
1474 IF p_eam_wo_rec.maintenance_object_type IS NULL OR
1475 p_eam_wo_rec.maintenance_object_type = FND_API.G_MISS_NUM
1476 THEN
1477 x_eam_wo_rec.maintenance_object_type := p_old_eam_wo_rec.maintenance_object_type;
1478 END IF;
1479
1480 IF p_eam_wo_rec.maintenance_object_source IS NULL OR
1481 p_eam_wo_rec.maintenance_object_source = FND_API.G_MISS_NUM
1482 THEN
1483 x_eam_wo_rec.maintenance_object_source := p_old_eam_wo_rec.maintenance_object_source;
1484 END IF;
1485
1486 --
1487 -- Populate Null or missng flex field columns
1488 --
1489 IF p_eam_wo_rec.attribute_category IS NULL
1490 THEN
1491 x_eam_wo_rec.attribute_category := p_old_eam_wo_rec.attribute_category;
1492
1493 END IF;
1494
1495 IF p_eam_wo_rec.attribute_category = FND_API.G_MISS_CHAR
1496 THEN
1497 x_eam_wo_rec.attribute_category := NULL;
1498 END IF;
1499
1500 IF p_eam_wo_rec.attribute1 IS NULL
1501 THEN
1502 x_eam_wo_rec.attribute1 := p_old_eam_wo_rec.attribute1;
1503 END IF;
1504
1505 IF p_eam_wo_rec.attribute1 = FND_API.G_MISS_CHAR
1506 THEN
1507 x_eam_wo_rec.attribute1 := NULL;
1508 END IF;
1509
1510 IF p_eam_wo_rec.attribute2 IS NULL
1511 THEN
1512 x_eam_wo_rec.attribute2 := p_old_eam_wo_rec.attribute2;
1513 END IF;
1514
1515 IF p_eam_wo_rec.attribute2 = FND_API.G_MISS_CHAR
1516 THEN
1517 x_eam_wo_rec.attribute2 := NULL;
1518 END IF;
1519
1520 IF p_eam_wo_rec.attribute3 IS NULL
1521 THEN
1522 x_eam_wo_rec.attribute3 := p_old_eam_wo_rec.attribute3;
1523 END IF;
1524
1525 IF p_eam_wo_rec.attribute3 = FND_API.G_MISS_CHAR
1526 THEN
1527 x_eam_wo_rec.attribute3 := NULL;
1528 END IF;
1529
1530 IF p_eam_wo_rec.attribute4 IS NULL
1531 THEN
1532 x_eam_wo_rec.attribute4 := p_old_eam_wo_rec.attribute4;
1533 END IF;
1534
1535 IF p_eam_wo_rec.attribute4 = FND_API.G_MISS_CHAR
1536 THEN
1537 x_eam_wo_rec.attribute4 := NULL;
1538 END IF;
1539
1540 IF p_eam_wo_rec.attribute5 IS NULL
1541 THEN
1542 x_eam_wo_rec.attribute5 := p_old_eam_wo_rec.attribute5;
1543 END IF;
1544
1545 IF p_eam_wo_rec.attribute5 = FND_API.G_MISS_CHAR
1546 THEN
1547 x_eam_wo_rec.attribute5 := NULL;
1548 END IF;
1549
1550 IF p_eam_wo_rec.attribute6 IS NULL
1551 THEN
1552 x_eam_wo_rec.attribute6 := p_old_eam_wo_rec.attribute6;
1553 END IF;
1554
1555 IF p_eam_wo_rec.attribute6 = FND_API.G_MISS_CHAR
1556 THEN
1557 x_eam_wo_rec.attribute6 := NULL;
1558 END IF;
1559
1560 IF p_eam_wo_rec.attribute7 IS NULL
1561 THEN
1562 x_eam_wo_rec.attribute7 := p_old_eam_wo_rec.attribute7;
1563 END IF;
1564
1565 IF p_eam_wo_rec.attribute7 = FND_API.G_MISS_CHAR
1566 THEN
1567 x_eam_wo_rec.attribute7 := NULL;
1568 END IF;
1569
1570 IF p_eam_wo_rec.attribute8 IS NULL
1571 THEN
1572 x_eam_wo_rec.attribute8 := p_old_eam_wo_rec.attribute8;
1573 END IF;
1574
1575 IF p_eam_wo_rec.attribute8 = FND_API.G_MISS_CHAR
1576 THEN
1577 x_eam_wo_rec.attribute8 := NULL;
1578 END IF;
1579
1580 IF p_eam_wo_rec.attribute9 IS NULL
1581 THEN
1582 x_eam_wo_rec.attribute9 := p_old_eam_wo_rec.attribute9;
1583 END IF;
1584
1585 IF p_eam_wo_rec.attribute9 = FND_API.G_MISS_CHAR
1586 THEN
1587 x_eam_wo_rec.attribute9 := NULL;
1588 END IF;
1589
1590 IF p_eam_wo_rec.attribute10 IS NULL
1591 THEN
1592 x_eam_wo_rec.attribute10 := p_old_eam_wo_rec.attribute10;
1593 END IF;
1594
1595 IF p_eam_wo_rec.attribute10 = FND_API.G_MISS_CHAR
1596 THEN
1597 x_eam_wo_rec.attribute10 := NULL;
1598 END IF;
1599
1600 IF p_eam_wo_rec.attribute11 IS NULL
1601 THEN
1602 x_eam_wo_rec.attribute11 := p_old_eam_wo_rec.attribute11;
1603 END IF;
1604
1605 IF p_eam_wo_rec.attribute11 = FND_API.G_MISS_CHAR
1606 THEN
1607 x_eam_wo_rec.attribute11 := NULL;
1608 END IF;
1609
1610 IF p_eam_wo_rec.attribute12 IS NULL
1611 THEN
1612 x_eam_wo_rec.attribute12 := p_old_eam_wo_rec.attribute12;
1613 END IF;
1614
1615 IF p_eam_wo_rec.attribute12 = FND_API.G_MISS_CHAR
1616 THEN
1617 x_eam_wo_rec.attribute12 := NULL;
1618 END IF;
1619
1620 IF p_eam_wo_rec.attribute13 IS NULL
1621 THEN
1622 x_eam_wo_rec.attribute13 := p_old_eam_wo_rec.attribute13;
1623 END IF;
1624
1625 IF p_eam_wo_rec.attribute13 = FND_API.G_MISS_CHAR
1626 THEN
1627 x_eam_wo_rec.attribute13 := NULL;
1628 END IF;
1629
1630 IF p_eam_wo_rec.attribute14 IS NULL
1631 THEN
1632 x_eam_wo_rec.attribute14 := p_old_eam_wo_rec.attribute14;
1633 END IF;
1634
1635 IF p_eam_wo_rec.attribute14 = FND_API.G_MISS_CHAR
1636 THEN
1637 x_eam_wo_rec.attribute14 := NULL;
1638 END IF;
1639
1640 IF p_eam_wo_rec.attribute15 IS NULL
1641 THEN
1642 x_eam_wo_rec.attribute15 := p_old_eam_wo_rec.attribute15;
1643 END IF;
1644
1645 IF p_eam_wo_rec.attribute15 = FND_API.G_MISS_CHAR
1646 THEN
1647 x_eam_wo_rec.attribute15 := NULL;
1648 END IF;
1649
1650 -- MATERIAL_ISSUE_BY_MO flag
1651 IF p_eam_wo_rec.material_issue_by_mo = FND_API.G_MISS_CHAR OR
1652 p_eam_wo_rec.material_issue_by_mo IS NULL
1653 THEN
1654 x_eam_wo_rec.material_issue_by_mo := p_old_eam_wo_rec.material_issue_by_mo;
1655 END IF;
1656
1657 IF p_eam_wo_rec.pending_flag = FND_API.G_MISS_CHAR OR
1658 p_eam_wo_rec.pending_flag IS NULL
1659 THEN
1660 x_eam_wo_rec.pending_flag := p_old_eam_wo_rec.pending_flag;
1661 END IF;
1662
1663 IF p_eam_wo_rec.material_shortage_check_date = FND_API.G_MISS_DATE OR
1664 p_eam_wo_rec.material_shortage_check_date IS NULL
1665 THEN
1666 x_eam_wo_rec.material_shortage_check_date := p_old_eam_wo_rec.material_shortage_check_date;
1667 END IF;
1668
1669 IF p_eam_wo_rec.material_shortage_flag = FND_API.G_MISS_NUM OR
1670 p_eam_wo_rec.material_shortage_flag IS NULL
1671 THEN
1672 x_eam_wo_rec.material_shortage_flag := p_old_eam_wo_rec.material_shortage_flag;
1673 END IF;
1674
1675 IF p_eam_wo_rec.workflow_type = FND_API.G_MISS_NUM OR
1676 p_eam_wo_rec.workflow_type IS NULL
1677 THEN
1678 x_eam_wo_rec.workflow_type := p_old_eam_wo_rec.workflow_type;
1679 END IF;
1680
1681 IF p_eam_wo_rec.warranty_claim_status = FND_API.G_MISS_NUM OR
1682 p_eam_wo_rec.warranty_claim_status IS NULL
1683 THEN
1684 x_eam_wo_rec.warranty_claim_status := p_old_eam_wo_rec.warranty_claim_status;
1685 END IF;
1686
1687 IF p_eam_wo_rec.cycle_id = FND_API.G_MISS_NUM OR
1688 p_eam_wo_rec.cycle_id IS NULL
1689 THEN
1690 x_eam_wo_rec.cycle_id := p_old_eam_wo_rec.cycle_id;
1691 END IF;
1692
1693 IF p_eam_wo_rec.seq_id = FND_API.G_MISS_NUM OR
1694 p_eam_wo_rec.seq_id IS NULL
1695 THEN
1696 x_eam_wo_rec.seq_id := p_old_eam_wo_rec.seq_id;
1697 END IF;
1698
1699 IF p_eam_wo_rec.ds_scheduled_flag = FND_API.G_MISS_CHAR OR
1700 p_eam_wo_rec.ds_scheduled_flag IS NULL
1701 THEN
1702 x_eam_wo_rec.ds_scheduled_flag := p_old_eam_wo_rec.ds_scheduled_flag;
1703 END IF;
1704
1705 IF p_eam_wo_rec.assignment_complete = FND_API.G_MISS_CHAR OR
1706 p_eam_wo_rec.assignment_complete IS NULL
1707 THEN
1708 x_eam_wo_rec.assignment_complete := p_old_eam_wo_rec.assignment_complete;
1709 END IF;
1710
1711 IF p_eam_wo_rec.warranty_active = FND_API.G_MISS_NUM OR
1712 p_eam_wo_rec.warranty_active IS NULL
1713 THEN
1714 x_eam_wo_rec.warranty_active := p_old_eam_wo_rec.warranty_active;
1715 END IF;
1716
1717 -- Bug # 4709084 : Failure Analysis project.
1718
1719 IF p_eam_wo_rec.failure_code_required IS NULL
1720 THEN
1721 x_eam_wo_rec.failure_code_required := p_old_eam_wo_rec.failure_code_required;
1722 END IF;
1723
1724 IF p_eam_wo_rec.failure_code_required = FND_API.G_MISS_CHAR
1725 THEN
1726 x_eam_wo_rec.failure_code_required := 'N'; -- As NULL Is same as 'N'
1727 END IF;
1728
1729
1730 IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Done processing null columns prior update'); END IF;
1731
1732 END Populate_Null_Columns;
1733
1734 END EAM_WO_DEFAULT_PVT;