[Home] [Help]
PACKAGE BODY: APPS.EAM_COMPLETION
Source
1 PACKAGE BODY eam_completion AS
2 /* $Header: EAMWCMPB.pls 120.7 2006/06/02 07:16:11 kmurthy noship $*/
3
4
5
6 FUNCTION IS_WORKFLOW_ENABLED
7 (p_maint_obj_source IN NUMBER,
8 p_organization_id IN NUMBER
9 ) RETURN VARCHAR2
10 IS
11 l_workflow_enabled VARCHAR2(1);
12 BEGIN
13
14 BEGIN
15 SELECT enable_workflow
16 INTO l_workflow_enabled
17 FROM EAM_ENABLE_WORKFLOW
18 WHERE MAINTENANCE_OBJECT_SOURCE =p_maint_obj_source;
19 EXCEPTION
20 WHEN NO_DATA_FOUND THEN
21 l_workflow_enabled := 'N';
22 END;
23
24 --IF EAM workorder,check if workflow is enabled for this organization or not
25 IF(l_workflow_enabled ='Y' AND p_maint_obj_source=1) THEN
26 BEGIN
27 SELECT eam_wo_workflow_enabled
28 INTO l_workflow_enabled
29 FROM WIP_EAM_PARAMETERS
30 WHERE organization_id =p_organization_id;
31 EXCEPTION
32 WHEN NO_DATA_FOUND THEN
33 l_workflow_enabled := 'N';
34 END;
35 END IF; --check for workflow enabled at org level
36
37 RETURN l_workflow_enabled;
38
39 END IS_WORKFLOW_ENABLED;
40
41
42
43 -- Bug 2803819-dgupta: This qa_enable API is now redundant and should be
44 -- removed in next cleanup.
45 PROCEDURE qa_enable(qa_id NUMBER,
46 errCode OUT NOCOPY NUMBER,
47 errMsg OUT NOCOPY VARCHAR2) IS
48
49 i_msg_data VARCHAR2(250);
50 i_return_status VARCHAR2(250);
51 i_msg_count NUMBER;
52
53 BEGIN
54 errCode := 0; --initial to success
55 QA_RESULT_GRP.ENABLE(p_api_version => 1.0,
56 p_init_msg_list => 'F',
57 p_commit => 'F',
58 p_validation_level => 0,
59 p_collection_id => qa_id,
60 p_return_status => i_return_status,
61 p_msg_count => i_msg_count,
62 p_msg_data => i_msg_data);
63 if (i_return_status <> 'S') then
64 if (i_msg_count = -1) then
65 fnd_message.set_name('QA','QA_ACTION_FAILED');
66 else
67 fnd_message.set_name('QA', i_msg_data);
68 end if; -- end message count check
69 errCode := 1; --fail
70 errMsg := fnd_message.get;
71 return;
72 end if; -- end error check
73
74 END qa_enable;
75
76 PROCEDURE process_lot_serial(
77 s_subinventory VARCHAR2,
78 s_locator_id VARCHAR2,
79 s_lot_serial_tbl Lot_Serial_Tbl_Type,
80 s_org_id NUMBER,
81 s_wip_entity_id NUMBER,
82 s_qa_collection_id NUMBER,
83 s_rebuild_item_id NUMBER,
84 s_acct_period_id NUMBER,
85 s_user_id NUMBER,
86 s_transaction_type NUMBER,
87 s_project_id NUMBER,
88 s_task_id NUMBER,
89 s_commit VARCHAR2,
90 errCode OUT NOCOPY NUMBER,
91 errMsg OUT NOCOPY VARCHAR2,
92 x_statement OUT NOCOPY NUMBER) IS
93
94 i_transaction_header_id NUMBER;
95 i_transaction_temp_id NUMBER;
96 i_serial_transaction_temp_id NUMBER;
97 i_transaction_temp_id_s NUMBER;
98 i_transaction_quantity NUMBER;
99 i_primary_quantity NUMBER;
100 i_transaction_action_id NUMBER;
101 i_transaction_type_id NUMBER;
102 i_transaction_source_type_id NUMBER;
103 i_project_id NUMBER;
104 i_task_id NUMBER;
105 i_revision VARCHAR2(3) := null;
106 item wma_common.Item;
107 l_statement NUMBER := 0;
108 l_revision_control_code NUMBER := 1;
109 l_transaction_quantity NUMBER;
110 l_initial_msg_count NUMBER := 0;
111
112 BEGIN
113
114 -- prepare the data to insert into MTL_MATERIAL_TRANSACTIONS_TEMP,
115 -- MTL_SERIAL_NUMBERS_TEMP, and MTL_TRANSACTION_LOTS_TEMP
116 select mtl_material_transactions_s.nextval into i_transaction_header_id
117 from dual;
118
119 l_statement := 1;
120 x_statement := l_statement;
121
122 -- get the item info
123 item := wma_derive.getItem(s_rebuild_item_id, s_org_id, s_locator_id);
124 if (item.invItemID is null) then
125 fnd_message.set_name ('EAM', 'EAM_ITEM_DOES_NOT_EXIST');
126 errCode := 1;
127 errMsg := fnd_message.get;
128 return;
129 end if; -- end item info check
130
131 l_statement := 2;
132 x_statement := l_statement;
133
134
135 begin
136 select nvl(revision_qty_control_code,1)
137 into l_revision_control_code
138 from mtl_system_items
139 where inventory_item_id = s_rebuild_item_id
140 and organization_id = s_org_id;
141
142 exception
143 when others then
144 null;
145 end;
146
147 if (l_revision_control_code = 2) then
148
149 -- get bom_revision
150 bom_revisions.get_revision (examine_type => 'ALL',
151 org_id => s_org_id,
152 item_id => s_rebuild_item_id,
153 rev_date => sysdate,
154 itm_rev => i_revision);
155 end if;
156
157 -- get transaction source type id
158 i_transaction_source_type_id := inv_reservation_global.g_source_type_wip;
159
160 l_statement := 3;
161 x_statement := l_statement;
162
163 -- set i_transaction_quantity and i_primary_quantity to be the sum of all
164 -- quantities in the lot_serial_tbl
165 -- also verify all quantities are greater than 0
166 i_transaction_quantity := 0;
167 FOR i IN 1..s_lot_serial_tbl.COUNT LOOP
168 IF s_lot_serial_tbl(i).quantity is null or s_lot_serial_tbl(i).quantity < 1 THEN
169 errCode := 1;
170 fnd_message.set_name('EAM', 'EAM_NEGATIVE_TXN_QUANTITY');
171 errMsg := fnd_message.get;
172 return;
173 ELSE
174 i_transaction_quantity := i_transaction_quantity + s_lot_serial_tbl(i).quantity;
175 END IF;
176 END LOOP;
177 i_primary_quantity := i_transaction_quantity;
178
179 -- prepare the rest data
180 if(s_transaction_type = 1) then -- Complete Transaction
181 i_transaction_action_id := WIP_CONSTANTS.CPLASSY_ACTION;
182 i_transaction_type_id := WIP_CONSTANTS.CPLASSY_TYPE;
183 elsif(s_transaction_type = 2) then -- Uncomplete Transaction
184 i_transaction_quantity := - i_transaction_quantity;
185 i_primary_quantity := - i_primary_quantity;
186 i_transaction_action_id := WIP_CONSTANTS.RETASSY_ACTION;
187 i_transaction_type_id := WIP_CONSTANTS.RETASSY_TYPE;
188 else
189 fnd_message.set_name('EAM','EAM_INVALID_TRANSACTION_TYPE');
190 errCode := 1;
191 errMsg := fnd_message.get;
192 return;
193 end if; -- end prepare data
194
195 l_statement := 4;
196 x_statement := l_statement;
197
198 -- call inventory API to insert data to mtl_material_transactions_temp
199 -- the spec file is INVTRXUS.pls
200
201 errCode := inv_trx_util_pub.insert_line_trx(
202 p_trx_hdr_id => i_transaction_header_id,
203 p_item_id => s_rebuild_item_id,
204 p_revision => i_revision,
205 p_org_id => s_org_id,
206 p_trx_action_id => i_transaction_action_id,
207 p_subinv_code => s_subinventory,
208 p_locator_id => s_locator_id,
209 p_trx_type_id => i_transaction_type_id,
210 p_trx_src_type_id => i_transaction_source_type_id,
211 p_trx_qty => i_transaction_quantity,
212 p_pri_qty => i_primary_quantity,
213 p_uom => item.primaryUOMCode,
214 p_date => sysdate,
215 p_user_id => s_user_id,
216 p_trx_src_id => s_wip_entity_id,
217 x_trx_tmp_id => i_transaction_temp_id,
218 x_proc_msg => errMsg);
219
220 l_statement := 5;
221 x_statement := l_statement;
222
223 if (errCode <> 0) then
224 return;
225 end if;
226
227 FOR i IN 1..s_lot_serial_tbl.COUNT LOOP
228
229 if(s_transaction_type = 1) then -- Complete Transaction
230 l_transaction_quantity := s_lot_serial_tbl(i).quantity;
231 else -- Uncomplete Transaction
232 l_transaction_quantity := - s_lot_serial_tbl(i).quantity;
233 end if;
234
235 -- Check whether the item is under lot or serial control or not
236 -- If it is, insert the data to coresponding tables
237 if(item.lotControlCode = WIP_CONSTANTS.LOT) then
238
239 -- the item is under lot control
240
241 -- call inventory API to insert data to mtl_transaction_lots_temp
242 -- the spec file is INVTRXUS.pls
243 errCode := inv_trx_util_pub.insert_lot_trx(
244 p_trx_tmp_id => i_transaction_temp_id,
245 p_user_id => s_user_id,
246 p_lot_number => s_lot_serial_tbl(i).lot_number,
247 p_trx_qty => l_transaction_quantity,
248 p_pri_qty => l_transaction_quantity,
249 x_ser_trx_id => i_serial_transaction_temp_id,
250 x_proc_msg => errMsg);
251
252 if (errCode <> 0) then
253 return;
254 end if;
255
256 else
257 null;
258 end if; -- end lot control check
259
260 -- Check if the item is under serial control or not
261 if(item.serialNumberControlCode in (WIP_CONSTANTS.FULL_SN,
262 WIP_CONSTANTS.DYN_RCV_SN)) then
263 -- item is under serial control
264
265 -- Check if the item is under lot control or not
266 if(item.lotControlCode = WIP_CONSTANTS.LOT) then
267
268 -- under lot control
269 i_transaction_temp_id_s := i_serial_transaction_temp_id;
270 else
271 i_transaction_temp_id_s := i_transaction_temp_id;
272 end if; -- end lot control check
273
274
275 -- call inventory API to insert data to mtl_serial_numbers_temp
276 -- the spec file is INVTRXUS.pls
277 errCode := inv_trx_util_pub.insert_ser_trx(
278 p_trx_tmp_id => i_transaction_temp_id_s,
279 p_user_id => s_user_id,
280 p_fm_ser_num => s_lot_serial_tbl(i).serial_number,
281 p_to_ser_num => s_lot_serial_tbl(i).serial_number,
282 x_proc_msg => errMsg);
283 if (errCode <> 0) then
284 return;
285 end if;
286
287 else
288 null;
289 end if; -- end serial control check
290
291 end LOOP;
292
293 l_statement := 6;
294 x_statement := l_statement;
295
296 l_initial_msg_count := FND_MSG_PUB.count_msg;
297 -- Call Inventory API to process to item
298 -- the spec file is INVTRXWS.pls
299 errCode := inv_lpn_trx_pub.process_lpn_trx(
300 p_trx_hdr_id => i_transaction_header_id,
301 p_commit => s_commit,
302 x_proc_msg => errMsg);
303 /* Added as a FIX for the Issue 1 of bug:2881879 */
304 if(FND_MSG_PUB.count_msg> 0) then
305 if(l_initial_msg_count = 0 and errCode = 0) then
306 FND_MSG_PUB.Delete_msg;
307 end if;
308 end if;
309 /* Added for bug no :2911698
310 Since the error message is not getting added into the message stack
311 */
312 if(errCode <> 0 and errMsg is not null) then
313 eam_execution_jsp.add_message(p_app_short_name => 'EAM',p_msg_name =>
314 'EAM_RET_MAT_PROCESS_MESSAGE',p_token1=> 'ERRMESSAGE',
315 p_value1 => errMsg);
316 end if;
317
318 l_statement := 7;
319 x_statement := l_statement;
320
321 END process_lot_serial;
322
323
324 PROCEDURE process_item(
325 s_inventory_item_tbl EAM_WorkOrderTransactions_PUB.Inventory_Item_Tbl_Type,
326 s_org_id NUMBER,
327 s_wip_entity_id NUMBER,
328 s_qa_collection_id NUMBER,
329 s_rebuild_item_id NUMBER,
330 s_acct_period_id NUMBER,
331 s_user_id NUMBER,
332 s_transaction_type NUMBER,
333 s_project_id NUMBER,
334 s_task_id NUMBER,
335 s_commit VARCHAR2,
336 errCode OUT NOCOPY NUMBER,
337 errMsg OUT NOCOPY VARCHAR2,
338 x_statement OUT NOCOPY NUMBER) IS
339 l_subinventory VARCHAR2(30);
340 l_locator VARCHAR2(30);
341 l_lot_serial_rec Lot_Serial_Rec_Type;
342 l_lot_serial_tbl Lot_Serial_Tbl_Type;
343 BEGIN
344 IF s_inventory_item_tbl.COUNT = 0 THEN
345 RETURN;
346 END IF;
347
348 l_subinventory := s_inventory_item_tbl(1).subinventory;
349 l_locator := s_inventory_item_tbl(1).locator;
350 l_lot_serial_rec.lot_number := s_inventory_item_tbl(1).lot_number;
351 l_lot_serial_rec.serial_number := s_inventory_item_tbl(1).serial_number;
352 l_lot_serial_rec.quantity := s_inventory_item_tbl(1).quantity;
353 l_lot_serial_tbl(1) := l_lot_serial_rec;
354
355 FOR i in 2..(s_inventory_item_tbl.COUNT+1) LOOP
356 IF (i > s_inventory_item_tbl.COUNT
357 OR s_inventory_item_tbl(i).subinventory <> l_subinventory
358 OR s_inventory_item_tbl(i).locator <> l_locator) THEN
359
360 process_lot_serial(l_subinventory,
361 l_locator,
362 l_lot_serial_tbl,
363 s_org_id,
364 s_wip_entity_id,
365 s_qa_collection_id,
366 s_rebuild_item_id,
367 s_acct_period_id,
368 s_user_id,
369 s_transaction_type,
370 s_project_id,
371 s_task_id,
372 s_commit,
373 errCode,
374 errMsg,
375 x_statement);
376 if (errCode <> 0) then
377 return;
378 end if;
379 l_lot_serial_tbl.DELETE;
380 END IF;
381 IF (i <= s_inventory_item_tbl.COUNT) THEN
382 l_subinventory := s_inventory_item_tbl(i).subinventory;
383 l_locator := s_inventory_item_tbl(i).locator;
384 l_lot_serial_rec.lot_number := s_inventory_item_tbl(i).lot_number;
385 l_lot_serial_rec.serial_number := s_inventory_item_tbl(i).serial_number;
386 l_lot_serial_rec.quantity := s_inventory_item_tbl(i).quantity;
387 l_lot_serial_tbl(l_lot_serial_tbl.COUNT+1) := l_lot_serial_rec;
388 END IF;
389 END LOOP;
390
391 END process_item;
392
393 -- Added three arguments as part of bug 3448770 fix
394 PROCEDURE process_shutdown(s_asset_group_id NUMBER,
395 s_organization_id NUMBER,
396 s_asset_number VARCHAR2,
397 s_start_date DATE,
398 s_end_date DATE,
399 s_user_id NUMBER,
400 s_maintenance_object_type NUMBER,
401 s_maintenance_object_id NUMBER,
402 s_wip_entity_id NUMBER DEFAULT NULL ) IS
403
404 i_asset_status_id NUMBER;
405 BEGIN
406 -- get the asset_status_id from eam_asset_status_history_s sequence
407 SELECT eam_asset_status_history_s.nextval INTO i_asset_status_id FROM dual;
408
409 -- Enhancement Bug 3852846
410 UPDATE eam_asset_status_history
411 SET enable_flag = 'N'
412 , last_update_date = SYSDATE
413 , last_updated_by = FND_GLOBAL.user_id
414 , last_update_login = FND_GLOBAL.login_id
415 WHERE organization_id = s_organization_id
416 AND wip_entity_id = s_wip_entity_id
417 AND operation_seq_num IS NULL
418 AND (enable_flag is NULL OR enable_flag = 'Y');
419
420 INSERT INTO eam_asset_status_history(asset_status_id,
421 organization_id,
422 asset_group_id,
423 asset_number,
424 start_date,
425 end_date,
426 wip_entity_id, -- Fix for Bug 3448770
427 maintenance_object_type,
428 maintenance_object_id,
429 created_by,
430 creation_date,
431 last_updated_by,
432 last_update_date,
433 enable_flag) -- Enhancement Bug 3852846
434 VALUES (i_asset_status_id,
435 s_organization_id,
436 s_asset_group_id,
437 s_asset_number,
438 s_start_date,
439 s_end_date,
440 s_wip_entity_id, -- Fix for Bug 3448770
441 s_maintenance_object_type,
442 s_maintenance_object_id,
443 s_user_id,
444 sysdate,
445 s_user_id,
446 sysdate,
447 'Y'); -- Enhancement Bug 3852846
448
449 END process_shutdown;
450
451 PROCEDURE lock_row(
452 p_wip_entity_id IN NUMBER,
453 p_organization_id IN NUMBER,
454 p_rebuild_item_id IN NUMBER,
455 p_parent_wip_entity_id IN NUMBER,
456 p_asset_number IN VARCHAR2,
457 p_asset_group_id IN NUMBER,
458 p_manual_rebuild_flag IN VARCHAR2,
459 p_asset_activity_id IN NUMBER,
460 p_status_type IN NUMBER,
461 x_return_status OUT NOCOPY NUMBER,
462 x_msg_count OUT NOCOPY NUMBER,
463 x_msg_data OUT NOCOPY VARCHAR2) IS
464
465 l_api_name CONSTANT VARCHAR2(30) := 'lock_row';
466 l_api_version CONSTANT NUMBER := 1.0;
467 l_full_name CONSTANT VARCHAR2(60) := 'eam_completion' || '.' ||
468 l_api_name;
469
470 CURSOR C IS
471 SELECT wip_entity_id, organization_id, rebuild_item_id,
472 rebuild_serial_number, parent_wip_entity_id, asset_number,
473 asset_group_id, manual_rebuild_flag, primary_item_id, status_type,
474 completion_subinventory, completion_locator_id, lot_number,
475 project_id, task_id
476 FROM wip_discrete_jobs
477 WHERE wip_entity_id = P_WIP_ENTITY_ID
478 FOR UPDATE OF status_type NOWAIT;
479 Recinfo C%ROWTYPE;
480
481 BEGIN
482
483 -- Standard Start of API savepoint
484 SAVEPOINT apiname_apitype;
485
486 /*Standard call to check for call compatibility.
487 IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version,
488 l_api_name, g_pkg_name) THEN
489 RAISE fnd_api.g_exc_unexpected_error;
490 END IF;
491
492 -- Initialize message list if p_init_msg_list is set to TRUE.
493 IF fnd_api.to_boolean(p_init_msg_list) THEN
494 fnd_msg_pub.initialize;
495 END IF;*/
496
497 -- Initialize API return status to success
498 x_return_status := 0;
499
500 -- API body
501
502 OPEN C;
503 FETCH C INTO Recinfo;
504 if (C%NOTFOUND) then
505 CLOSE C;
506 FND_MESSAGE.Set_Name('EAM', 'FORM_RECORD_DELETED');
507 APP_EXCEPTION.Raise_Exception;
508 end if;
509 CLOSE C;
510 if (
511 (p_wip_entity_id is null or
512 Recinfo.wip_entity_id = p_wip_entity_id)
513 AND (p_organization_id is null or
514 Recinfo.organization_id = p_organization_id)
515 AND (p_rebuild_item_id is null or
516 Recinfo.rebuild_item_id = p_rebuild_item_id)
517 AND (p_parent_wip_entity_id is null or
518 Recinfo.parent_wip_entity_id = p_parent_wip_entity_id)
519 AND (p_asset_number is null
520 or Recinfo.asset_number = p_asset_number)
521 AND (p_asset_group_id is null or
522 Recinfo.asset_group_id = p_asset_group_id)
523 AND (p_manual_rebuild_flag is null or
524 Recinfo.manual_rebuild_flag = p_manual_rebuild_flag)
525 AND (p_asset_activity_id is null or
526 Recinfo.primary_item_id = p_asset_activity_id)
527 AND (p_status_type is null or
528 Recinfo.status_type = p_status_type)
529 ) then
530 return;
531 else
532 FND_MESSAGE.Set_Name('EAM', 'FORM_RECORD_CHANGED');
533 APP_EXCEPTION.Raise_Exception;
534 end if;
535
536
537 -- Standard call to get message count and if count is 1, get message info.
538 fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
539
540 EXCEPTION
541 WHEN fnd_api.g_exc_error THEN
542 ROLLBACK TO apiname_apitype;
543 x_return_status := 1;
544 fnd_msg_pub.count_and_get(p_count => x_msg_count,
545 p_data => x_msg_data);
546
547 WHEN fnd_api.g_exc_unexpected_error THEN
548 ROLLBACK TO apiname_apitype;
549 x_return_status := 1;
550 fnd_msg_pub.count_and_get(
551 p_count => x_msg_count
552 ,p_data => x_msg_data);
553
554 WHEN OTHERS THEN
555 ROLLBACK TO apiname_apitype;
556 x_return_status := 1;
557
558 IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
559 fnd_msg_pub.add_exc_msg('eam_completion', l_api_name);
560 END IF;
561
562 fnd_msg_pub.count_and_get(p_count => x_msg_count,
563 p_data => x_msg_data);
564
565
566 END Lock_Row;
567
568 PROCEDURE complete_work_order_form(
569 x_wip_entity_id IN NUMBER,
570 x_rebuild_jobs IN VARCHAR2,
571 x_transaction_type IN NUMBER,
572 x_transaction_date IN DATE,
573 x_user_id IN NUMBER := fnd_global.user_id,
574 x_request_id IN NUMBER := null,
575 x_application_id IN NUMBER := null,
576 x_program_id IN NUMBER := null,
577 x_reconcil_code IN VARCHAR2 := null,
578 x_actual_start_date IN DATE,
579 x_actual_end_date IN DATE,
580 x_actual_duration IN NUMBER,
581 x_subinventory IN VARCHAR2 := null,
582 x_locator_id IN NUMBER := null,
583 x_lot_number IN VARCHAR2 := null,
584 x_serial_number IN VARCHAR2 := null,
585 x_reference IN VARCHAR2 := null,
586 x_qa_collection_id IN NUMBER := null,
587 x_shutdown_start_date IN DATE := null,
588 x_shutdown_end_date IN DATE := null,
589 x_attribute_category IN VARCHAR2 := null,
590 x_attribute1 IN VARCHAR2 := null,
591 x_attribute2 IN VARCHAR2 := null,
592 x_attribute3 IN VARCHAR2 := null,
593 x_attribute4 IN VARCHAR2 := null,
594 x_attribute5 IN VARCHAR2 := null,
595 x_attribute6 IN VARCHAR2 := null,
596 x_attribute7 IN VARCHAR2 := null,
597 x_attribute8 IN VARCHAR2 := null,
598 x_attribute9 IN VARCHAR2 := null,
599 x_attribute10 IN VARCHAR2 := null,
600 x_attribute11 IN VARCHAR2 := null,
601 x_attribute12 IN VARCHAR2 := null,
602 x_attribute13 IN VARCHAR2 := null,
603 x_attribute14 IN VARCHAR2 := null,
604 x_attribute15 IN VARCHAR2 := null,
605 errCode OUT NOCOPY NUMBER,
606 errMsg OUT NOCOPY VARCHAR2) IS
607 l_inventory_item_rec EAM_WorkOrderTransactions_PUB.Inventory_Item_Rec_Type;
608 l_inventory_item_tbl EAM_WorkOrderTransactions_PUB.Inventory_Item_Tbl_Type;
609 BEGIN
610 l_inventory_item_rec.subinventory := x_subinventory;
611 l_inventory_item_rec.locator := x_locator_id;
612 l_inventory_item_rec.lot_number := x_lot_number;
613 l_inventory_item_rec.serial_number := x_serial_number;
614 l_inventory_item_rec.quantity := 1;
615 l_inventory_item_tbl(1) := l_inventory_item_rec;
616
617 complete_work_order_generic(x_wip_entity_id => x_wip_entity_id,
618 x_rebuild_jobs => x_rebuild_jobs,
619 x_transaction_type => x_transaction_type,
620 x_transaction_date => x_transaction_date,
621 x_user_id => x_user_id,
622 x_request_id => x_request_id,
623 x_application_id => x_application_id,
624 x_program_id => x_program_id,
625 x_reconcil_code => x_reconcil_code,
626 x_actual_start_date => x_actual_start_date,
627 x_actual_end_date => x_actual_end_date,
628 x_actual_duration => x_actual_duration,
629 x_inventory_item_info => l_inventory_item_tbl,
630 x_reference => x_reference,
631 x_qa_collection_id => x_qa_collection_id,
632 x_shutdown_start_date => x_shutdown_start_date,
633 x_shutdown_end_date => x_shutdown_end_date,
634 x_attribute_category => x_attribute_category,
635 x_attribute1 => x_attribute1,
636 x_attribute2 => x_attribute2,
637 x_attribute3 => x_attribute3,
638 x_attribute4 => x_attribute4,
639 x_attribute5 => x_attribute5,
640 x_attribute6 => x_attribute6,
641 x_attribute7 => x_attribute7,
642 x_attribute8 => x_attribute8,
643 x_attribute9 => x_attribute9,
644 x_attribute10 => x_attribute10,
645 x_attribute11 => x_attribute11,
646 x_attribute12 => x_attribute12,
647 x_attribute13 => x_attribute13,
648 x_attribute14 => x_attribute14,
649 x_attribute15 => x_attribute15,
650 errCode => errCode,
651 errMsg => errMsg);
652
653 END complete_work_order_form;
654
655 /* Added for bug# 3238163 */
656 PROCEDURE complete_work_order_commit(
657 x_wip_entity_id IN NUMBER,
658 x_rebuild_jobs IN VARCHAR2,
659 x_transaction_type IN NUMBER,
660 x_transaction_date IN DATE,
661 x_user_id IN NUMBER := fnd_global.user_id,
662 x_request_id IN NUMBER := null,
663 x_application_id IN NUMBER := null,
664 x_program_id IN NUMBER := null,
665 x_reconcil_code IN VARCHAR2 := null,
666 x_commit IN VARCHAR2 := fnd_api.g_false,
667 x_actual_start_date IN DATE,
668 x_actual_end_date IN DATE,
669 x_actual_duration IN NUMBER,
670 x_subinventory IN VARCHAR2 := null,
671 x_locator_id IN NUMBER := null,
672 x_lot_number IN VARCHAR2 := null,
673 x_serial_number IN VARCHAR2 := null,
674 x_reference IN VARCHAR2 := null,
675 x_qa_collection_id IN NUMBER := null,
676 x_shutdown_start_date IN DATE := null,
677 x_shutdown_end_date IN DATE := null,
678 x_attribute_category IN VARCHAR2 := null,
679 x_attribute1 IN VARCHAR2 := null,
680 x_attribute2 IN VARCHAR2 := null,
681 x_attribute3 IN VARCHAR2 := null,
682 x_attribute4 IN VARCHAR2 := null,
683 x_attribute5 IN VARCHAR2 := null,
684 x_attribute6 IN VARCHAR2 := null,
685 x_attribute7 IN VARCHAR2 := null,
686 x_attribute8 IN VARCHAR2 := null,
687 x_attribute9 IN VARCHAR2 := null,
688 x_attribute10 IN VARCHAR2 := null,
689 x_attribute11 IN VARCHAR2 := null,
690 x_attribute12 IN VARCHAR2 := null,
691 x_attribute13 IN VARCHAR2 := null,
692 x_attribute14 IN VARCHAR2 := null,
693 x_attribute15 IN VARCHAR2 := null,
694 errCode OUT NOCOPY NUMBER,
695 errMsg OUT NOCOPY VARCHAR2) IS
696 l_inventory_item_rec EAM_WorkOrderTransactions_PUB.Inventory_Item_Rec_Type;
697 l_inventory_item_tbl EAM_WorkOrderTransactions_PUB.Inventory_Item_Tbl_Type;
698 BEGIN
699 l_inventory_item_rec.subinventory := x_subinventory;
700 l_inventory_item_rec.locator := x_locator_id;
701 l_inventory_item_rec.lot_number := x_lot_number;
702 l_inventory_item_rec.serial_number := x_serial_number;
703 l_inventory_item_rec.quantity := 1;
704 l_inventory_item_tbl(1) := l_inventory_item_rec;
705
706 complete_work_order_generic(x_wip_entity_id => x_wip_entity_id,
707 x_rebuild_jobs => x_rebuild_jobs,
708 x_transaction_type => x_transaction_type,
709 x_transaction_date => x_transaction_date,
710 x_user_id => x_user_id,
711 x_request_id => x_request_id,
712 x_application_id => x_application_id,
713 x_program_id => x_program_id,
714 x_reconcil_code => x_reconcil_code,
715 x_commit => x_commit,
716 x_actual_start_date => x_actual_start_date,
717 x_actual_end_date => x_actual_end_date,
718 x_actual_duration => x_actual_duration,
719 x_inventory_item_info => l_inventory_item_tbl,
720 x_reference => x_reference,
721 x_qa_collection_id => x_qa_collection_id,
722 x_shutdown_start_date => x_shutdown_start_date,
723 x_shutdown_end_date => x_shutdown_end_date,
724 x_attribute_category => x_attribute_category,
725 x_attribute1 => x_attribute1,
726 x_attribute2 => x_attribute2,
727 x_attribute3 => x_attribute3,
728 x_attribute4 => x_attribute4,
729 x_attribute5 => x_attribute5,
730 x_attribute6 => x_attribute6,
731 x_attribute7 => x_attribute7,
732 x_attribute8 => x_attribute8,
733 x_attribute9 => x_attribute9,
734 x_attribute10 => x_attribute10,
735 x_attribute11 => x_attribute11,
736 x_attribute12 => x_attribute12,
737 x_attribute13 => x_attribute13,
738 x_attribute14 => x_attribute14,
739 x_attribute15 => x_attribute15,
740 errCode => errCode,
741 errMsg => errMsg);
742
743 END complete_work_order_commit;
744
745 -- Procedure called via JSP
746
747 PROCEDURE complete_work_order(
748 x_wip_entity_id IN NUMBER,
749 x_rebuild_jobs IN VARCHAR2,
750 x_transaction_type IN NUMBER,
751 x_transaction_date IN DATE,
752 x_user_id IN NUMBER := fnd_global.user_id,
753 x_request_id IN NUMBER := null,
754 x_application_id IN NUMBER := null,
755 x_program_id IN NUMBER := null,
756 x_reconcil_code IN VARCHAR2 := null,
757 x_actual_start_date IN DATE,
758 x_actual_end_date IN DATE,
759 x_actual_duration IN NUMBER,
760 x_subinventory IN VARCHAR2 := null,
761 x_locator_id IN NUMBER := null,
762 x_lot_number IN VARCHAR2 := null,
763 x_serial_number IN VARCHAR2 := null,
764 x_reference IN VARCHAR2 := null,
765 x_qa_collection_id IN NUMBER := null,
766 x_shutdown_start_date IN DATE := null,
767 x_shutdown_end_date IN DATE := null,
768 x_commit IN VARCHAR2 := fnd_api.g_false,
769 x_attribute_category IN VARCHAR2 := null,
770 x_attribute1 IN VARCHAR2 := null,
771 x_attribute2 IN VARCHAR2 := null,
772 x_attribute3 IN VARCHAR2 := null,
773 x_attribute4 IN VARCHAR2 := null,
774 x_attribute5 IN VARCHAR2 := null,
775 x_attribute6 IN VARCHAR2 := null,
776 x_attribute7 IN VARCHAR2 := null,
777 x_attribute8 IN VARCHAR2 := null,
778 x_attribute9 IN VARCHAR2 := null,
779 x_attribute10 IN VARCHAR2 := null,
780 x_attribute11 IN VARCHAR2 := null,
781 x_attribute12 IN VARCHAR2 := null,
782 x_attribute13 IN VARCHAR2 := null,
783 x_attribute14 IN VARCHAR2 := null,
784 x_attribute15 IN VARCHAR2 := null,
785 errCode OUT NOCOPY NUMBER,
786 errMsg OUT NOCOPY VARCHAR2) IS
787
788
789 l_inventory_item_rec EAM_WorkOrderTransactions_PUB.Inventory_Item_Rec_Type;
790 l_inventory_item_tbl EAM_WorkOrderTransactions_PUB.Inventory_Item_Tbl_Type;
791 BEGIN
792 l_inventory_item_rec.subinventory := x_subinventory;
793 l_inventory_item_rec.locator := x_locator_id;
794 l_inventory_item_rec.lot_number := x_lot_number;
795 l_inventory_item_rec.serial_number := x_serial_number;
796 l_inventory_item_rec.quantity := 1;
797 l_inventory_item_tbl(1) := l_inventory_item_rec;
798
799 complete_work_order_generic(x_wip_entity_id => x_wip_entity_id,
800 x_rebuild_jobs => x_rebuild_jobs,
801 x_transaction_type => x_transaction_type,
802 x_transaction_date => x_transaction_date,
803 x_user_id => x_user_id,
804 x_request_id => x_request_id,
805 x_application_id => x_application_id,
806 x_program_id => x_program_id,
807 x_reconcil_code => x_reconcil_code,
808 x_actual_start_date => x_actual_start_date,
809 x_actual_end_date => x_actual_end_date,
810 x_actual_duration => x_actual_duration,
811 x_inventory_item_info => l_inventory_item_tbl,
812 x_reference => x_reference,
813 x_qa_collection_id => x_qa_collection_id,
814 x_shutdown_start_date => x_shutdown_start_date,
815 x_shutdown_end_date => x_shutdown_end_date,
816 x_attribute_category => x_attribute_category,
817 x_attribute1 => x_attribute1,
818 x_attribute2 => x_attribute2,
819 x_attribute3 => x_attribute3,
820 x_attribute4 => x_attribute4,
821 x_attribute5 => x_attribute5,
822 x_attribute6 => x_attribute6,
823 x_attribute7 => x_attribute7,
824 x_attribute8 => x_attribute8,
825 x_attribute9 => x_attribute9,
826 x_attribute10 => x_attribute10,
827 x_attribute11 => x_attribute11,
828 x_attribute12 => x_attribute12,
829 x_attribute13 => x_attribute13,
830 x_attribute14 => x_attribute14,
831 x_attribute15 => x_attribute15,
832 errCode => errCode,
833 errMsg => errMsg);
834
835 END complete_work_order;
836
837
838
839 /***************************************************************************
840 *
841 * This procedure will be used to complete and uncomplete EAM work order
842 *
843 * PARAMETER:
844 *
845 * x_wip_entity_id Work Order ID
846 * x_rebuild_jobs A flag used to determine work order type
847 * (N:Regular EAM work order/ Y:Rebuild work order)
848 * x_transaction_type The type of transaction (Complete(1) / Uncomplete(2))
849 * x_transaction_date The date of transaction
850 * x_user_id User ID
851 * x_request_id, For concurrent processing
852 * x_appplication_id, For concurrent processing
853 * x_program_id For concurrent processing
854 * x_reconcil_code This parameter was predefined in FND_LOOKUP_VALUES
855 * where lookup_type = 'WIP_EAM_RECONCILIATION_CODE'
856 * x_subinventory For rebuild work order with material issue only
857 * x_locator_id For rebuild work order with material issue only
858 * x_lot_number For rebuild work order with material issue only
859 * x_serial_number For rebuild work order with material issue only
860 * x_reference For regular EAM work order only
861 * x_qa_collection_id For regular EAM work order only
862 * (null if the the work order is not under QA control)
863 * x_shutdown_start_date Shutdown information for regular EAM
864 * x_shutdown_end_date Shutdown information for regular EAM
865 * x_commit default to fnd_api.g_true
866 * whether to commit the changes to DB
867 * x_attribute_category For descriptive flex field
868 * x_attribute1-15 For descriptive flex field
869 * errCode OUT 0 if procedure success, 1 otherwise
870 * errMsg OUT NOCOPY The informative error message
871 *
872 ***************************************************************************/
873
874 PROCEDURE complete_work_order_generic(
875 x_wip_entity_id IN NUMBER,
876 x_rebuild_jobs IN VARCHAR2,
877 x_transaction_type IN NUMBER,
878 x_transaction_date IN DATE,
879 x_user_id IN NUMBER := fnd_global.user_id,
880 x_request_id IN NUMBER := null,
881 x_application_id IN NUMBER := null,
882 x_program_id IN NUMBER := null,
883 x_reconcil_code IN VARCHAR2 := null,
884 x_actual_start_date IN DATE,
885 x_actual_end_date IN DATE,
886 x_actual_duration IN NUMBER,
887 x_inventory_item_info IN EAM_WorkOrderTransactions_PUB.Inventory_Item_Tbl_Type := INVENTORY_ITEM_NULL,
888 x_reference IN VARCHAR2 := null,
889 x_qa_collection_id IN NUMBER := null,
890 x_shutdown_start_date IN DATE := null,
891 x_shutdown_end_date IN DATE := null,
892 x_commit IN VARCHAR2 := fnd_api.g_false,
893 x_attribute_category IN VARCHAR2 := null,
894 x_attribute1 IN VARCHAR2 := null,
895 x_attribute2 IN VARCHAR2 := null,
896 x_attribute3 IN VARCHAR2 := null,
897 x_attribute4 IN VARCHAR2 := null,
898 x_attribute5 IN VARCHAR2 := null,
899 x_attribute6 IN VARCHAR2 := null,
900 x_attribute7 IN VARCHAR2 := null,
901 x_attribute8 IN VARCHAR2 := null,
902 x_attribute9 IN VARCHAR2 := null,
903 x_attribute10 IN VARCHAR2 := null,
904 x_attribute11 IN VARCHAR2 := null,
905 x_attribute12 IN VARCHAR2 := null,
906 x_attribute13 IN VARCHAR2 := null,
907 x_attribute14 IN VARCHAR2 := null,
908 x_attribute15 IN VARCHAR2 := null,
909 errCode OUT NOCOPY NUMBER,
910 errMsg OUT NOCOPY VARCHAR2) IS
911
912
913 i_asset_number VARCHAR2(30);
914 i_manual_rebuild_flag VARCHAR2(1);
915 i_acct_period_id NUMBER;
916 i_asset_group_id NUMBER;
917 i_asset_activity_id NUMBER;
918 i_org_id NUMBER;
919 i_parent_wip_entity_id NUMBER;
920 i_parent_status_type NUMBER; -- used for uncomplete transaction
921 i_project_id NUMBER;
922 i_rebuild_item_id NUMBER;
923 i_rebuild_serial_number VARCHAR2(30);
924 i_status_type NUMBER; -- status of work order
925 i_task_id NUMBER;
926 i_transaction_id NUMBER;
927 msg_count NUMBER;
928 i_work_request_status NUMBER;
929 i_completion_date DATE;
930 i_program_update_date DATE;
931 l_statement NUMBER := 0;
932 x_statement NUMBER := 0;
933 l_valid NUMBER := 0;
934 l_subinventory VARCHAR2(30) := null;
935 l_locator NUMBER := null;
936 l_lot_number VARCHAR2(80) := null;
937 i_maintenance_source_id NUMBER; -- added as part of bug #2774571 to check whether the work order is of 'EAM' or 'CMRO'
938
939 -- this boolean need to pass to invttmtx.tdatechk
940 i_open_past_period BOOLEAN;
941
942 /* --replaced with select statement for bug #2414513.
943 | -- Cursor to hold all child jobs information
944 | cursor child_jobs_cursor(c_wip_entity_id NUMBER) is
945 | select we.wip_entity_name, wdj.status_type
946 | from wip_discrete_jobs wdj, wip_entities we
947 | where wdj.wip_entity_id = we.wip_entity_id
948 | and wdj.parent_wip_entity_id = c_wip_entity_id
949 | and wdj.manual_rebuild_flag = 'Y';
950 |
951 | -- Aggregate variable to hold each child job information
952 | child_job child_jobs_cursor%ROWTYPE;
953 */
954 child_job_var VARCHAR2(2):='0';
955 network_child_job_var VARCHAR2(2):='0'; -- Bug no 3049128 added as part to check for Work Order Completion as part of Work Order Linking Project
956 network_parent_job_var VARCHAR2(2):='0'; -- Bug no 3049128 added as part to check for Work Order Completion as part of Work Order Linking Project
957 sibling_parent_job_var VARCHAR2(2):='0';
958
959 i_maintenance_object_type NUMBER; -- Fix for Bug 3448770
960 i_maintenance_object_id NUMBER; -- Fix for Bug 3448770
961 l_wip_entity_name VARCHAR2(240);
962 l_workflow_enabled VARCHAR2(1);
963 l_approval_required BOOLEAN;
964 l_workflow_name VARCHAR2(200);
965 l_workflow_process VARCHAR2(200);
966 l_status_pending_event VARCHAR2(240);
967 l_status_changed_event VARCHAR2(240);
968 l_new_eam_status NUMBER;
969 l_new_system_status NUMBER;
970 l_old_eam_status NUMBER;
971 l_old_system_status NUMBER;
972 l_workflow_type NUMBER;
973 l_event_name VARCHAR2(240);
974 l_parameter_list wf_parameter_list_t;
975 l_event_key VARCHAR2(200);
976 l_wf_event_seq NUMBER;
977 l_cost_estimate NUMBER;
978
979
980 BEGIN
981
982 SAVEPOINT job_comp;
983 errCode := 0; -- initial to success
984 msg_count := 0;
985 i_open_past_period := FALSE;
986
987 l_statement := 15;
988 x_statement := l_statement;
989
990 -- Validate all required information
991 if(x_wip_entity_id = null or x_rebuild_jobs = null
992 or x_transaction_type = null or x_transaction_date = null
993 or x_actual_start_date = null or x_actual_end_date = null
994 or x_actual_duration = null) then
995 ROLLBACK TO job_comp;
996 fnd_message.set_name('EAM','EAM_WORK_ORDER_MISSING_INFO');
997 errCode := 1;
998 errMsg := fnd_message.get;
999 return;
1000 end if; -- end validate data
1001
1002 l_statement := 25;
1003 x_statement := l_statement;
1004
1005 -- get transaction_id from sequence eam_job_completion_txns_s
1006 select eam_job_completion_txns_s.nextval into i_transaction_id from dual;
1007
1008 if(x_request_id is not null and x_application_id is not null and
1009 x_program_id is not null) then
1010 i_program_update_date := sysdate;
1011 else
1012 i_program_update_date := null;
1013 end if; -- end concurrent program check
1014
1015 l_statement := 35;
1016 x_statement := l_statement;
1017
1018 -- get some value from wip_discrete_jobs table
1019 select wdj.parent_wip_entity_id,
1020 wdj.asset_group_id,
1021 wdj.asset_number,
1022 wdj.primary_item_id,
1023 wdj.manual_rebuild_flag,
1024 wdj.rebuild_item_id,
1025 wdj.rebuild_serial_number,
1026 wdj.project_id,
1027 wdj.task_id,
1028 wdj.organization_id,
1029 wdj.maintenance_object_source, -- added as part of bug #2774571 to check whether the work order is of 'EAM' or 'CMRO'
1030 wdj.maintenance_object_type, -- Fix for Bug 3448770
1031 wdj.maintenance_object_id,
1032 wdj.status_type,
1033 ewod.user_defined_status_id,
1034 ewod.workflow_type,
1035 we.wip_entity_name
1036 into i_parent_wip_entity_id,
1037 i_asset_group_id,
1038 i_asset_number,
1039 i_asset_activity_id,
1040 i_manual_rebuild_flag,
1041 i_rebuild_item_id,
1042 i_rebuild_serial_number,
1043 i_project_id,
1044 i_task_id,
1045 i_org_id,
1046 i_maintenance_source_id, -- added as part of bug #2774571 to check whether the work order is of 'EAM' or 'CMRO'
1047 i_maintenance_object_type, -- Fix for Bug 3448770
1048 i_maintenance_object_id,
1049 l_old_system_status,
1050 l_old_eam_status,
1051 l_workflow_type,
1052 l_wip_entity_name
1053 from wip_discrete_jobs wdj,eam_work_order_details ewod,wip_entities we
1054 where wdj.wip_entity_id = x_wip_entity_id
1055 AND wdj.wip_entity_id = ewod.wip_entity_id(+)
1056 AND wdj.wip_entity_id = we.wip_entity_id;
1057
1058 l_workflow_enabled:=Is_Workflow_enabled(i_maintenance_source_id,i_org_id);
1059 l_status_changed_event := 'oracle.apps.eam.workorder.status.changed';
1060 l_status_pending_event := 'oracle.apps.eam.workorder.status.change.pending';
1061
1062 l_statement := 45;
1063 x_statement := l_statement;
1064
1065 --fix for bug # 2446276 ----------------------------------------
1066 if(x_transaction_type = 2) then
1067 if(x_rebuild_jobs <> 'Y') then
1068 l_valid := EAM_WORKORDER_UTIL_PKG.check_released_onhold_allowed(
1069 'N',
1070 i_org_id,
1071 i_asset_group_id,
1072 i_asset_number,
1073 i_asset_activity_id);
1074 else
1075 l_valid := EAM_WORKORDER_UTIL_PKG.check_released_onhold_allowed(
1076 'Y',
1077 i_org_id,
1078 i_rebuild_item_id,
1079 i_rebuild_serial_number,
1080 i_asset_activity_id);
1081 end if;
1082 if l_valid = 1 then
1083 FND_MESSAGE.SET_NAME('EAM', 'EAM_WO_NO_UNCOMPLETE');
1084 errCode := 2;
1085 errMsg := fnd_message.get;
1086 return;
1087 end if;
1088 end if; /* end if for fix 2446276 */
1089
1090 -- get acct_period_id from routine invttmtx.tdatechk
1091 -- this routine will return the value via acct_period_id OUT variable
1092 -- open_past_period is an IN OUT boolean
1093 invttmtx.tdatechk(i_org_id,x_transaction_date,i_acct_period_id,
1094 i_open_past_period);
1095
1096 -- Check whether the transaction type is Complete or Uncomplete
1097 If (x_transaction_type = 1) then -- Complete Transaction
1098 -- Bug no 3049128 added as part to check for Work Order Completion as part of Work Order Linking Project
1099
1100 begin
1101 SELECT '1'
1102 INTO network_child_job_var
1103 FROM dual
1104 WHERE EXISTS (SELECT '1'
1105 FROM wip_discrete_jobs
1106 WHERE wip_entity_id IN
1107 (
1108 SELECT DISTINCT child_object_id
1109 FROM eam_wo_relationships
1110 WHERE parent_relationship_type =1
1111 START WITH parent_object_id = x_wip_entity_id AND parent_relationship_type = 1
1112 CONNECT BY parent_object_id = prior child_object_id AND parent_relationship_type = 1
1113 )
1114 AND status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
1115 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED,WIP_CONSTANTS.CANCELLED, WIP_CONSTANTS.PEND_CLOSE)
1116
1117 );
1118
1119 if (network_child_job_var = '1') then --In the network Work Order has Uncompleted Child Work Orders
1120 ROLLBACK TO job_comp;
1121 fnd_message.set_name('EAM','EAM_NETWRK_CHILD_JOB_NOT_COMP');
1122 errCode := 1;
1123 errMsg := 'EAM_NETWRK_CHILD_JOB_NOT_COMP';
1124 return;
1125 else
1126 null;
1127 end if;
1128 exception
1129 WHEN OTHERS THEN
1130 null;
1131 end;
1132 -- end of Bug fix 3049128
1133
1134 -- Bug no 3735589
1135 begin
1136 SELECT '1'
1137 INTO sibling_parent_job_var
1138 FROM dual
1139 WHERE EXISTS (SELECT '1'
1140 FROM wip_discrete_jobs
1141 WHERE wip_entity_id IN
1142 (
1143 SELECT DISTINCT parent_object_id
1144 FROM eam_wo_relationships
1145 WHERE parent_relationship_type =2 and
1146 child_object_id = x_wip_entity_id
1147 )
1148 AND status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
1149 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED)
1150
1151 );
1152
1153 if (sibling_parent_job_var = '1') then
1154 ROLLBACK TO job_comp;
1155 fnd_message.set_name('EAM','EAM_NETWRK_SIB_JOB_NOT_COM');
1156 errCode := 1;
1157 errMsg := 'EAM_NETWRK_SIB_JOB_NOT_COM';
1158 return;
1159 else
1160 null;
1161 end if;
1162 exception
1163 WHEN OTHERS THEN
1164 null;
1165 end;
1166 -- end of bug fix 3735589
1167
1168
1169
1170 IF(l_workflow_enabled='Y' AND x_transaction_type=2
1171 AND (WF_EVENT.TEST(l_status_pending_event) <> 'NONE') )THEN
1172 EAM_WORKFLOW_DETAILS_PUB.Eam_Wf_Is_Approval_Required(p_old_wo_rec => NULL,
1173 p_new_wo_rec => NULL,
1174 p_wip_entity_id => x_wip_entity_id,
1175 p_new_system_status => 3,
1176 p_new_wo_status => 3,
1177 p_old_system_status => l_old_system_status,
1178 p_old_wo_status => l_old_eam_status,
1179 x_approval_required => l_approval_required,
1180 x_workflow_name => l_workflow_name,
1181 x_workflow_process => l_workflow_process
1182 );
1183
1184 IF(l_approval_required) THEN
1185 UPDATE EAM_WORK_ORDER_DETAILS
1186 SET user_defined_status_id=3,
1187 pending_flag='Y',
1188 last_update_date=SYSDATE,
1189 last_update_login=FND_GLOBAL.login_id,
1190 last_updated_by=FND_GLOBAL.user_id
1191 WHERE wip_entity_id= x_wip_entity_id;
1192
1193
1194
1195 --Find the total estimated cost of workorder
1196 BEGIN
1197 SELECT NVL((SUM(system_estimated_mat_cost) + SUM(system_estimated_lab_cost) + SUM(system_estimated_eqp_cost)),0)
1198 INTO l_cost_estimate
1199 FROM WIP_EAM_PERIOD_BALANCES
1200 WHERE wip_entity_id =x_wip_entity_id;
1201 EXCEPTION
1202 WHEN NO_DATA_FOUND THEN
1203 l_cost_estimate := 0;
1204 END;
1205
1206
1207 SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
1208 INTO l_wf_event_seq
1209 FROM DUAL;
1210
1211 l_parameter_list := wf_parameter_list_t();
1212 l_event_name := l_status_pending_event;
1213
1214 l_event_key := TO_CHAR(l_wf_event_seq);
1215 WF_CORE.CONTEXT('Enterprise Asset Management...','Work Order Released change event','Building parameter list');
1216
1217
1218 INSERT INTO EAM_WO_WORKFLOWS
1219 (WIP_ENTITY_ID,WF_ITEM_TYPE,WF_ITEM_KEY,LAST_UPDATE_DATE,LAST_UPDATED_BY,
1220 CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN)
1221 VALUES
1222 (x_wip_entity_id,l_workflow_name,l_event_key,SYSDATE,FND_GLOBAL.user_id,
1223 SYSDATE,FND_GLOBAL.user_id,FND_GLOBAL.login_id
1224 );
1225
1226
1227 -- Add Parameters
1228 Wf_Event.AddParameterToList(p_name =>'WIP_ENTITY_ID',
1229 p_value => TO_CHAR(x_wip_entity_id),
1230 p_parameterlist => l_parameter_list);
1231 Wf_Event.AddParameterToList(p_name =>'WIP_ENTITY_NAME',
1232 p_value =>l_wip_entity_name,
1233 p_parameterlist => l_parameter_list);
1234 Wf_Event.AddParameterToList(p_name =>'ORGANIZATION_ID',
1235 p_value => TO_CHAR(i_org_id),
1236 p_parameterlist => l_parameter_list);
1237 Wf_Event.AddParameterToList(p_name =>'NEW_WO_STATUS',
1238 p_value =>'3' ,
1239 p_parameterlist => l_parameter_list);
1240 Wf_Event.AddParameterToList(p_name =>'OLD_SYSTEM_STATUS',
1241 p_value => TO_CHAR(l_old_system_status),
1242 p_parameterlist => l_parameter_list);
1243 Wf_Event.AddParameterToList(p_name =>'OLD_WO_STATUS',
1244 p_value => TO_CHAR(l_old_eam_status),
1245 p_parameterlist => l_parameter_list);
1246 Wf_Event.AddParameterToList(p_name =>'NEW_SYSTEM_STATUS',
1247 p_value => '3',
1248 p_parameterlist => l_parameter_list);
1249 Wf_Event.AddParameterToList(p_name =>'WORKFLOW_TYPE',
1250 p_value => TO_CHAR(l_workflow_type),
1251 p_parameterlist => l_parameter_list);
1252 Wf_Event.AddParameterToList(p_name =>'REQUESTOR',
1253 p_value =>FND_GLOBAL.USER_NAME ,
1254 p_parameterlist => l_parameter_list);
1255 Wf_Event.AddParameterToList(p_name =>'WORKFLOW_NAME',
1256 p_value => l_workflow_name,
1257 p_parameterlist => l_parameter_list);
1258 Wf_Event.AddParameterToList(p_name =>'WORKFLOW_PROCESS',
1259 p_value => l_workflow_process,
1260 p_parameterlist => l_parameter_list);
1261 Wf_Event.AddParameterToList(p_name =>'ESTIMATED_COST',
1262 p_value => TO_CHAR(l_cost_estimate),
1263 p_parameterlist => l_parameter_list);
1264 Wf_Core.Context('Enterprise Asset Management...','Work Order Released Event','Raising event');
1265
1266 Wf_Event.Raise( p_event_name => l_event_name,
1267 p_event_key => l_event_key,
1268 p_parameters => l_parameter_list);
1269 l_parameter_list.DELETE;
1270 WF_CORE.CONTEXT('Enterprise Asset Management...','Work Order Released Event','After raising event');
1271
1272
1273
1274 IF(i_maintenance_source_id =1) THEN --update text index for EAM workorders
1275 EAM_TEXT_UTIL.PROCESS_WO_EVENT
1276 (
1277 p_event => 'UPDATE',
1278 p_wip_entity_id =>x_wip_entity_id,
1279 p_organization_id =>i_org_id,
1280 p_last_update_date => SYSDATE,
1281 p_last_updated_by => FND_GLOBAL.user_id,
1282 p_last_update_login =>FND_GLOBAL.login_id
1283 );
1284 END IF;
1285
1286 RETURN;
1287 END IF;
1288 END IF; -- end of check for workflow enabled
1289
1290
1291
1292
1293 -- Check the type of Work Order
1294 if (x_rebuild_jobs = 'Y') then -- Rebuild Work Order
1295
1296 -- Check whether there is material issue or not
1297 /* Bug 3637201 - manual rebuild wo on out of stores serials should also be completed to subinv */
1298
1299 /* Subinventory check is added for bug no :2911698 */
1300 if ((i_manual_rebuild_flag = 'N' and x_inventory_item_info(1).subinventory is not null)
1301 or (I_MANUAL_REBUILD_FLAG <> 'N' and i_parent_wip_entity_id is null and
1302 x_inventory_item_info(1).subinventory is not null)) then -- there is material issue
1303
1304 l_statement := 55;
1305 x_statement := l_statement;
1306
1307 -- return item back to inventory
1308 process_item(s_inventory_item_tbl => x_inventory_item_info,
1309 s_org_id => i_org_id,
1310 s_wip_entity_id => x_wip_entity_id,
1311 s_qa_collection_id => x_qa_collection_id,
1312 s_rebuild_item_id => i_rebuild_item_id,
1313 s_acct_period_id => i_acct_period_id,
1314 s_user_id => x_user_id,
1315 s_transaction_type => x_transaction_type,
1316 s_project_id => i_project_id,
1317 s_task_id => i_task_id,
1318 s_commit => x_commit,
1319 errCode => errCode,
1320 errMsg => errMsg,
1321 x_statement => l_statement);
1322
1323 l_statement := 65;
1324 x_statement := l_statement;
1325
1326 -- Check if there is an error to return item or not
1327 if(errCode <> 0) then
1328 ROLLBACK TO job_comp;
1329 return;
1330 end if; -- end errCode check
1331
1332 end if; -- end material issue check
1333
1334 elsif (x_rebuild_jobs = 'N') then -- Regular EAM Work Order
1335
1336
1337 -- Replaced the above cursor loop and cursor with the following query.
1338 -- for bug #2414513.
1339 begin
1340 SELECT '1'
1341 INTO child_job_var
1342 FROM dual
1343 WHERE EXISTS (SELECT '1'
1344 FROM wip_discrete_jobs wdj, wip_entities we
1345 WHERE wdj.wip_entity_id = we.wip_entity_id
1346 AND wdj.parent_wip_entity_id = x_wip_entity_id
1347 AND wdj.manual_rebuild_flag = 'Y'
1348 AND wdj.status_type NOT IN (WIP_CONSTANTS.COMP_CHRG,
1349 WIP_CONSTANTS.COMP_NOCHRG,WIP_CONSTANTS.CLOSED));
1350 if (child_job_var = '1') then
1351 ROLLBACK TO job_comp;
1352 fnd_message.set_name('EAM','EAM_CHILD_JOB_NOT_COMPLETE');
1353 errCode := 1;
1354 errMsg := fnd_message.get;
1355 return;
1356 else
1357 null;
1358 end if;
1359 exception
1360 WHEN OTHERS THEN
1361 null;
1362 end;
1363
1364 else
1365 ROLLBACK TO job_comp;
1366 fnd_message.set_name('EAM','EAM_INVALID_WORK_ORDER_TYPE');
1367 errCode := 1;
1368 errMsg := fnd_message.get;
1369 return;
1370 end if; -- end work order check
1371
1372 /* Bug # 5165813 : Allow shutdown info for rebuild wo also.
1373 Hence moved out of IF block mentioned above */
1374
1375 -- Check whether the user provide Shutdown Information or not
1376 -- If the user provide shutdown information, insert the data to
1377 -- eam_asset_status_history table for history purpose
1378 if(x_shutdown_start_date is not null and
1379 x_shutdown_end_date is not null) then
1380 process_shutdown(s_asset_group_id => i_asset_group_id,
1381 s_organization_id => i_org_id,
1382 s_asset_number => i_asset_number,
1383 s_start_date => x_shutdown_start_date,
1384 s_end_date => x_shutdown_end_date,
1385 s_user_id => x_user_id,
1386 s_maintenance_object_type => i_maintenance_object_type, -- Fix for Bug 3448770
1387 s_maintenance_object_id => i_maintenance_object_id,
1388 s_wip_entity_id => x_wip_entity_id);
1389
1390 end if; -- end shutdown check
1391
1392
1393
1394
1395 -- initial the rest important variable
1396 i_status_type := WIP_CONSTANTS.COMP_CHRG;
1397 i_completion_date := x_actual_end_date;
1398 i_work_request_status := 6; -- Work request complete
1399
1400 elsif (x_transaction_type = 2) then -- Uncomplete Transaction
1401 -- Check the type of Work Order
1402 if (x_rebuild_jobs = 'Y') then -- Rebuild Work Order
1403
1404 -- Check whether there is material issue or not
1405 /* Bug 3637201 */
1406 /* Subinventory check is added for bug no :2911698 */
1407 if ((i_manual_rebuild_flag = 'N' and x_inventory_item_info(1).subinventory is not null) or
1408 (I_MANUAL_REBUILD_FLAG <> 'N' and i_parent_wip_entity_id is null and
1409 x_inventory_item_info(1).subinventory is not null)) then -- there is material issue
1410 l_statement := 50;
1411 -- get item back from inventory
1412 process_item(s_inventory_item_tbl => x_inventory_item_info,
1413 s_org_id => i_org_id,
1414 s_wip_entity_id => x_wip_entity_id,
1415 s_qa_collection_id => x_qa_collection_id,
1416 s_rebuild_item_id => i_rebuild_item_id,
1417 s_acct_period_id => i_acct_period_id,
1418 s_user_id => x_user_id,
1419 s_transaction_type => x_transaction_type,
1420 s_project_id => i_project_id,
1421 s_task_id => i_task_id,
1422 s_commit => x_commit,
1423 errCode => errCode,
1424 errMsg => errMsg,
1425 x_statement => l_statement);
1426
1427 -- Check if there is an error to return item or not
1428 if(errCode <> 0) then
1429 ROLLBACK TO job_comp;
1430 return;
1431 end if; --end errCode check
1432 else
1433 -- get parent work order status
1434 begin -- Handled the exception for bug#2762312
1435 select status_type into i_parent_status_type
1436 from wip_discrete_jobs
1437 where wip_entity_id = i_parent_wip_entity_id;
1438 exception
1439 when NO_DATA_FOUND then
1440 null;
1441 end;
1442
1443 -- Check whether parent job already completed or not
1444 if(i_parent_status_type = WIP_CONSTANTS.COMP_CHRG) then
1445 ROLLBACK TO job_comp;
1446 fnd_message.set_name('EAM','EAM_PARENT_JOB_COMPLETED');
1447 errCode := 1;
1448 errMsg := fnd_message.get;
1449 return;
1450 else
1451 null;
1452 end if; --end parent job check
1453 end if;
1454
1455 elsif (x_rebuild_jobs = 'N') then -- Regular EAM Work Order
1456 null;
1457
1458 else
1459 ROLLBACK TO job_comp;
1460 fnd_message.set_name('EAM','EAM_INVALID_WORK_ORDER_TYPE');
1461 errCode := 1;
1462 errMsg := fnd_message.get;
1463 return;
1464 end if; --end work order check
1465
1466 /* Bug # 5165813 : Allow shutdown info for rebuild wo also.
1467 Hence moved out of IF block mentioned above */
1468 UPDATE eam_asset_status_history
1469 SET enable_flag = 'N'
1470 , last_update_date = SYSDATE
1471 , last_updated_by = FND_GLOBAL.user_id
1472 , last_update_login = FND_GLOBAL.login_id
1473 WHERE organization_id = i_org_id
1474 AND wip_entity_id = x_wip_entity_id
1475 AND operation_seq_num IS NULL
1476 AND (enable_flag = 'Y' OR enable_flag IS null);
1477
1478
1479 -- Update Meter ... Placed here as part of bug #2774571
1480 /*
1481 Last service info needs to be uncompleted for both the work orders.
1482 */
1483 if(i_maintenance_source_id = 1) then -- added to check whether work order is of 'EAM' or 'CRMO'.'EAM=1'
1484 eam_pm_utils.update_pm_when_uncomplete(i_org_id, x_wip_entity_id);
1485 end if; -- end of source entity check
1486
1487 -- initial the rest important variable
1488 i_status_type := WIP_CONSTANTS.RELEASED;
1489 i_completion_date := null;
1490 i_work_request_status := 4; -- Work request in process
1491
1492 else -- Other Transactions
1493 ROLLBACK TO job_comp;
1494 fnd_message.set_name('EAM','EAM_INVALID_TRANSACTION_TYPE');
1495 errCode := 1;
1496 errMsg := fnd_message.get;
1497 return;
1498 end if; -- end transaction type check
1499
1500 l_statement := 75;
1501 x_statement := l_statement;
1502
1503 if (x_inventory_item_info.COUNT = 1) then
1504 l_subinventory := x_inventory_item_info(1).subinventory;
1505 l_locator := x_inventory_item_info(1).locator;
1506 l_lot_number := x_inventory_item_info(1).lot_number;
1507 end if;
1508
1509 -- insert all information to eam_job_completion_txns table for tracking
1510 -- history
1511 -- check for the type of work order to insert the values appropriately
1512 -- The check is added as part of bug #2774571
1513 if(x_rebuild_jobs = 'N') then -- for normal work order
1514 insert into eam_job_completion_txns (transaction_id,
1515 transaction_date,
1516 transaction_type,
1517 wip_entity_id,
1518 organization_id,
1519 parent_wip_entity_id,
1520 reference,
1521 reconciliation_code,
1522 acct_period_id,
1523 qa_collection_id,
1524 asset_group_id,
1525 asset_number,
1526 asset_activity_id,
1527 actual_start_date,
1528 actual_end_date,
1529 actual_duration,
1530 created_by,
1531 creation_date,
1532 last_updated_by,
1533 last_update_date,
1534 last_update_login,
1535 request_id,
1536 program_application_id,
1537 program_id,
1538 program_update_date,
1539 completion_subinventory,
1540 completion_locator_id,
1541 lot_number,
1542 attribute_category,
1543 attribute1,
1544 attribute2,
1545 attribute3,
1546 attribute4,
1547 attribute5,
1548 attribute6,
1549 attribute7,
1550 attribute8,
1551 attribute9,
1552 attribute10,
1553 attribute11,
1554 attribute12,
1555 attribute13,
1556 attribute14,
1557 attribute15
1558 )
1559 values (i_transaction_id,
1560 x_transaction_date,
1561 x_transaction_type,
1562 x_wip_entity_id,
1563 i_org_id,
1564 i_parent_wip_entity_id,
1565 x_reference,
1566 x_reconcil_code,
1567 i_acct_period_id,
1568 x_qa_collection_id,
1569 i_asset_group_id,
1570 i_asset_number,
1571 i_asset_activity_id,
1572 x_actual_start_date,
1573 x_actual_end_date,
1574 x_actual_duration,
1575 x_user_id,
1576 sysdate,
1577 x_user_id,
1578 sysdate,
1579 x_user_id,
1580 x_request_id,
1581 x_application_id,
1582 x_program_id,
1583 i_program_update_date,
1584 l_subinventory,
1585 l_locator,
1586 l_lot_number,
1587 x_attribute_category,
1588 x_attribute1,
1589 x_attribute2,
1590 x_attribute3,
1591 x_attribute4,
1592 x_attribute5,
1593 x_attribute6,
1594 x_attribute7,
1595 x_attribute8,
1596 x_attribute9,
1597 x_attribute10,
1598 x_attribute11,
1599 x_attribute12,
1600 x_attribute13,
1601 x_attribute14,
1602 x_attribute15
1603 );
1604 else -- rebuild work orders.
1605 insert into eam_job_completion_txns (transaction_id,
1606 transaction_date,
1607 transaction_type,
1608 wip_entity_id,
1609 organization_id,
1610 parent_wip_entity_id,
1611 reference,
1612 reconciliation_code,
1613 acct_period_id,
1614 qa_collection_id,
1615 asset_group_id,
1616 asset_number,
1617 asset_activity_id,
1618 actual_start_date,
1619 actual_end_date,
1620 actual_duration,
1621 created_by,
1622 creation_date,
1623 last_updated_by,
1624 last_update_date,
1625 last_update_login,
1626 request_id,
1627 program_application_id,
1628 program_id,
1629 program_update_date,
1630 completion_subinventory,
1631 completion_locator_id,
1632 lot_number,
1633 attribute_category,
1634 attribute1,
1635 attribute2,
1636 attribute3,
1637 attribute4,
1638 attribute5,
1639 attribute6,
1640 attribute7,
1641 attribute8,
1642 attribute9,
1643 attribute10,
1644 attribute11,
1645 attribute12,
1646 attribute13,
1647 attribute14,
1648 attribute15
1649 )
1650 values (i_transaction_id,
1651 x_transaction_date,
1652 x_transaction_type,
1653 x_wip_entity_id,
1654 i_org_id,
1655 i_parent_wip_entity_id,
1656 x_reference,
1657 x_reconcil_code,
1658 i_acct_period_id,
1659 x_qa_collection_id,
1660 i_rebuild_item_id, -- changed from asset_group_id to rebuild_item_id
1661 i_rebuild_serial_number, -- changed from asset_serial_number to rebuild_serial_number
1662 i_asset_activity_id,
1663 x_actual_start_date,
1664 x_actual_end_date,
1665 x_actual_duration,
1666 x_user_id,
1667 sysdate,
1668 x_user_id,
1669 sysdate,
1670 x_user_id,
1671 x_request_id,
1672 x_application_id,
1673 x_program_id,
1674 i_program_update_date,
1675 l_subinventory,
1676 l_locator,
1677 l_lot_number,
1678 x_attribute_category,
1679 x_attribute1,
1680 x_attribute2,
1681 x_attribute3,
1682 x_attribute4,
1683 x_attribute5,
1684 x_attribute6,
1685 x_attribute7,
1686 x_attribute8,
1687 x_attribute9,
1688 x_attribute10,
1689 x_attribute11,
1690 x_attribute12,
1691 x_attribute13,
1692 x_attribute14,
1693 x_attribute15
1694 );
1695 end if; -- end insert check
1696 l_statement := 85;
1697 x_statement := l_statement;
1698
1699 -- Update wip_discrete_jobs table
1700 update wip_discrete_jobs
1701 set last_update_date = sysdate,
1702 last_updated_by = x_user_id,
1703 last_update_login = x_user_id,
1704 status_type = i_status_type,
1705 date_completed = i_completion_date,
1706 request_id = x_request_id,
1707 program_application_id = x_application_id,
1708 program_id = x_program_id,
1709 program_update_date = i_program_update_date
1710 where wip_entity_id = x_wip_entity_id and
1711 organization_id = i_org_id;
1712
1713
1714 --Update Eam_Work_Order_Details with user_defined_status_id
1715 UPDATE EAM_WORK_ORDER_DETAILS
1716 SET last_update_date = sysdate,
1717 last_updated_by = x_user_id,
1718 last_update_login = x_user_id,
1719 user_defined_status_id=i_status_type
1720 WHERE wip_entity_id = x_wip_entity_id;
1721
1722 l_statement := 95;
1723 x_statement := l_statement;
1724
1725 -- Update wip_eam_work_requests table
1726 update wip_eam_work_requests
1727 set work_request_status_id = i_work_request_status,
1728 last_update_date = sysdate,
1729 last_updated_by = x_user_id,
1730 last_update_login = fnd_global.login_id
1731 where wip_entity_id = x_wip_entity_id;
1732
1733 l_statement := 105;
1734 x_statement := l_statement;
1735
1736
1737 --Raise status changed event when a workorder is completed/uncompleted
1738
1739 IF(l_workflow_enabled='Y' AND (WF_EVENT.TEST(l_status_changed_event) <> 'NONE') --if status change event enabled
1740 ) THEN
1741
1742 SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
1743 INTO l_wf_event_seq
1744 FROM DUAL;
1745
1746 l_parameter_list := wf_parameter_list_t();
1747 l_event_name := l_status_changed_event;
1748
1749 l_event_key := TO_CHAR(l_wf_event_seq);
1750 WF_CORE.CONTEXT('Enterprise Asset Management...','Work Order Status change event','Building parameter list');
1751 -- Add Parameters
1752 Wf_Event.AddParameterToList(p_name =>'WIP_ENTITY_ID',
1753 p_value => TO_CHAR(x_wip_entity_id),
1754 p_parameterlist => l_parameter_list);
1755 Wf_Event.AddParameterToList(p_name =>'WIP_ENTITY_NAME',
1756 p_value =>l_wip_entity_name,
1757 p_parameterlist => l_parameter_list);
1758 Wf_Event.AddParameterToList(p_name =>'ORGANIZATION_ID',
1759 p_value => TO_CHAR(i_org_id),
1760 p_parameterlist => l_parameter_list);
1761 Wf_Event.AddParameterToList(p_name =>'NEW_SYSTEM_STATUS',
1762 p_value => TO_CHAR(i_status_type),
1763 p_parameterlist => l_parameter_list);
1764 Wf_Event.AddParameterToList(p_name =>'NEW_WO_STATUS',
1765 p_value => TO_CHAR(i_status_type),
1766 p_parameterlist => l_parameter_list);
1767 Wf_Event.AddParameterToList(p_name =>'OLD_SYSTEM_STATUS',
1768 p_value => TO_CHAR(l_old_system_status),
1769 p_parameterlist => l_parameter_list);
1770 Wf_Event.AddParameterToList(p_name =>'OLD_WO_STATUS',
1771 p_value => TO_CHAR(l_old_eam_status),
1772 p_parameterlist => l_parameter_list);
1773 Wf_Event.AddParameterToList(p_name =>'WORKFLOW_TYPE',
1774 p_value => TO_CHAR(l_workflow_type),
1775 p_parameterlist => l_parameter_list);
1776 Wf_Event.AddParameterToList(p_name =>'REQUESTOR',
1777 p_value =>FND_GLOBAL.USER_NAME ,
1778 p_parameterlist => l_parameter_list);
1779 Wf_Core.Context('Enterprise Asset Management...','Work Order Staus Changed Event','Raising event');
1780
1781 Wf_Event.Raise( p_event_name => l_event_name,
1782 p_event_key => l_event_key,
1783 p_parameters => l_parameter_list);
1784 l_parameter_list.DELETE;
1785 WF_CORE.CONTEXT('Enterprise Asset Management...','Work Order Status Changed Event','After raising event');
1786 END IF; --end of check for status change event
1787
1788
1789 IF(i_maintenance_source_id =1) THEN --update text index for EAM workorders
1790
1791 EAM_TEXT_UTIL.PROCESS_WO_EVENT
1792 (
1793 p_event => 'UPDATE',
1794 p_wip_entity_id =>x_wip_entity_id,
1795 p_organization_id =>i_org_id,
1796 p_last_update_date => SYSDATE,
1797 p_last_updated_by => FND_GLOBAL.user_id,
1798 p_last_update_login =>FND_GLOBAL.login_id
1799 );
1800
1801 END IF; --end of check for EAM workorders
1802
1803
1804 if (x_commit = fnd_api.g_true) then
1805 COMMIT; -- commit all changes
1806 end if;
1807
1808 END complete_work_order_generic;
1809
1810 END eam_completion;