[Home] [Help]
PACKAGE BODY: APPS.IA_AME_REQUEST_PKG
Source
1 PACKAGE BODY IA_AME_REQUEST_PKG AS
2 /* $Header: IAAMREQB.pls 115.11 2004/05/20 22:16:08 yyoon noship $ */
3
4 /* Commented out due to the approach with Value Set
5 FUNCTION GetLOVApprovers
6 (RequesterId IN NUMBER,
7 ResponsibilityId IN NUMBER,
8 LOVType IN VARCHAR2,
9 BookTypeCode IN VARCHAR2,
10 CompanyCode IN VARCHAR2,
11 CostCenter IN VARCHAR2,
12 ApproverTypesTable OUT NOCOPY AME_UTIL.stringList,
13 ApproverIdsTable OUT NOCOPY AME_UTIL.stringList)
14 -- ApproversTable OUT NOCOPY AME_UTIL.approversTable)
15 return BOOLEAN
16 IS
17
18 * When the approvers LOVs on FWK pages are clicked, FWK calls the AME API, 'IA_AME_REQUEST_PKG.GetLOVApprovers'
19 * with the following parameters provided in order to initiate the process of getting a list of approvers
20 * pertinent to the setup
21 *
22 *
23
24 approverTypesList AME_UTIL.stringList;
25 approverIdsList AME_UTIL.stringList;
26
27 approvalMethod VARCHAR2(15) := NULL;
28 approvalGroupId NUMBER(15) := -1;
29
30 newAmeLovId NUMBER := -1;
31
32 debugInfo VARCHAR2(255) := NULL;
33
34 localException EXCEPTION;
35
36 callingProgram VARCHAR2(80) := 'GetLOVApprovers';
37
38 BEGIN
39
40 -- initialize error message stack.
41 FA_SRVR_MSG.init_server_message;
42 IA_WF_UTIL_PKG.InitializeDebugMessage;
43
44 -----------------------------------------------------
45 debugInfo := 'Validate the input values';
46 -----------------------------------------------------
47 if (RequesterId is NULL or
48 ResponsibilityId is NULL or
49 LOVType is NULL or
50 BookTypeCode is NULL) then
51
52 raise localException;
53
54 end if;
55
56
57 *
58 * The AME LOV API inserts the passed on parameters into iAssets LOV interim table named 'IA_AME_LOV_T' with a new sequence
59 * for unique identifier,'ame_lov_id' generated.
60 * The reason why we need this interim table and a unique identifier are as follows:
61 * Firstly, AME requires one single identifier to uniquely identify a record.
62 * There could be a workaround for this by having a combination of request_id, book_type_code, company_code and cost_center.
63 * This, however, will lead to too much complexity of implementing and maintaining the code in AME setups in the future.
64 * Secondly, FWK pages will not save a record of the request details table at the stage
65 * from which AME needs a value of unique identifier such as request_detail_id.
66 *
67
68 -----------------------------------------------------
69 debugInfo := 'Generate a new sequence id';
70 -----------------------------------------------------
71 SELECT IA_AME_LOV_T_S.nextval
72 INTO newAmeLovId
73 FROM dual;
74
75 -----------------------------------------------------
76 debugInfo := 'Insert parameters into IA_AME_LOV_T';
77 -----------------------------------------------------
78 INSERT INTO IA_AME_LOV_T
79 (ame_lov_id,
80 requester_id,
81 book_type_code,
82 company_code,
83 cost_center,
84 created_by,
85 creation_date,
86 last_updated_by,
87 last_update_date)
88 VALUES (newAmeLovId,
89 RequesterId,
90 BookTypeCode,
91 CompanyCode,
92 CostCenter,
93 -1,
94 SYSDATE,
95 -1,
96 SYSDATE);
97
98 -----------------------------------------------------
99 debugInfo := 'Call AME_ENGIN.initializePlsqlContext to initialize';
100 -----------------------------------------------------
101 AME_ENGINE.initializePlsqlContext(ameApplicationIdIn => null,
102 fndApplicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
103 transactionTypeIdIn => IA_WF_UTIL_PKG.AME_LOV_TransactionType,
104 transactionIdIn => newAmeLovId);
105
106 *
107 * This step figures out what approval method to use based on the approval rule assigned to its responsibility.
108 *
109 -----------------------------------------------------
110 debugInfo := 'Determining what approval method to use';
111 -----------------------------------------------------
112
113 approvalMethod := IA_WF_UTIL_PKG.GetApprovalMethod(IA_WF_UTIL_PKG.GetRuleID,
114 BookTypeCode);
115
116 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, debugInfo, approvalMethod);
117
118 -- approvalMethod := IA_WF_UTIL_PKG.ApprovalMethodHierarchy; -- DEBUG !!
119
120 *
121 * Being based on the approval method, the AME LOV API will then determine which AME approval group to use
122 *
123 -----------------------------------------------------
124 debugInfo := 'Get corresponding approval group ID';
125 -----------------------------------------------------
126 -- Call Management-hierarchy based approval group
127 if (approvalMethod = IA_WF_UTIL_PKG.ApprovalMethodHierarchy) then
128
129 if (LOVType = IA_WF_UTIL_PKG.LOVTypeReleasing) then
130 approvalGroupId := AME_APPROVAL_GROUP_PKG.getId(nameIn=>IA_WF_UTIL_PKG.HierarchyBasedRelGroup);
131 elsif (LOVType = IA_WF_UTIL_PKG.LOVTypeDestination) then
132 approvalGroupId := AME_APPROVAL_GROUP_PKG.getId(nameIn=>IA_WF_UTIL_PKG.HierarchyBasedRecGroup);
133 end if;
134
135 elsif (approvalMethod = IA_WF_UTIL_PKG.ApprovalMethodCostCenter) then
136 -- Call Cost-center based approval group
137 approvalGroupId := AME_APPROVAL_GROUP_PKG.getId(nameIn=>IA_WF_UTIL_PKG.CostCenterBasedGroup);
138
139 else
140
141 raise localException;
142
143 end if;
144
145 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, debugInfo, approvalGroupId);
146
147 approverTypesList := AME_UTIL.emptyStringList;
148 approverIdsList := AME_UTIL.emptyStringList;
149
150 -----------------------------------------------------
151 debugInfo := 'Call corresponding approval group';
152 -----------------------------------------------------
153 if (approvalMethod in (IA_WF_UTIL_PKG.ApprovalMethodHierarchy
154 ,IA_WF_UTIL_PKG.ApprovalMethodCostCenter) ) then
155
156 AME_APPROVAL_GROUP_PKG.getRuntimeGroupMembers(groupIdIn => approvalGroupId,
157 parameterNamesOut => approverTypesList,
158 parametersOut => approverIdsList);
159
160 ApproverTypesTable := approverTypesList;
161 ApproverIdsTable := approverIdsList;
162
163 if (IA_WF_UTIL_PKG.DebugModeEnabled) then
164
165 if (approverIdsList.count > 0) then
166
167 -----------------------------------------------------------------------
168 debugInfo := 'Number of Managers: ' || approverIdsList.count;
169 -----------------------------------------------------------------------
170 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'approverIdsList', debugInfo);
171
172 for i in 1 .. approverIdsList.count loop
173
174 -----------------------------------------------------------------------
175 debugInfo := 'Managers(' || i || ').type = ' || approverTypesList(i);
176 -----------------------------------------------------------------------
177 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'approverIdsList', debugInfo);
178
179 -----------------------------------------------------------------------
180 debugInfo := 'Managers(' || i || ').person_id = ' || approverIdsList(i);
181 -----------------------------------------------------------------------
182 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'approverIdsList', debugInfo);
183
184 end loop;
185
186 end if; -- if (approverIdsList.count > 0)
187
188 end if; -- if DebugModeEnabled
189
190 end if; -- if approvalMethod is either ManagementHierarchyBased or CostCenterBased
191
192
193 -- back to main
194
195 return TRUE;
196
197 EXCEPTION
198 WHEN OTHERS THEN
199 FA_SRVR_MSG.add_message(
200 calling_fn => callingProgram||':'||debugInfo);
201 FA_SRVR_MSG.Add_SQL_Error(
202 calling_fn => callingProgram);
203 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, debugInfo, 'Error');
204
205 return FALSE;
206
207 END GetLOVApprovers;
208 */
209
210 /*
211 FUNCTION GetNextApprover
212 (RequestId IN NUMBER,
213 Approver OUT NOCOPY AME_UTIL.approverRecord)
214 return BOOLEAN
215 IS
216
217 approverTypesList AME_UTIL.stringList;
218 approverIdsList AME_UTIL.stringList;
219
220 approverRecord AME_UTIL.approverRecord;
221
222
223 debugInfo VARCHAR2(255) := NULL;
224
225 localException EXCEPTION;
226
227 callingProgram VARCHAR2(80) := 'GetNextApprover(RequestId, Approver)';
228
229 BEGIN
230
231 -- initialize error message stack.
232 -- FA_SRVR_MSG.init_server_message;
233 -- IA_WF_UTIL_PKG.InitializeDebugMessage;
234
235 *
236 * This step calls AME_API.getNextApprover.
237 *
238 -----------------------------------------------------
239 debugInfo := 'Calling AME_API.getNextApprover(RequestId, Approver)';
240 -----------------------------------------------------
241 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
242
243 AME_API.getNextApprover(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
244 transactionTypeIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
245 transactionIdIn => RequestId,
246 nextApproverOut => approverRecord);
247
248 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'after', debugInfo);
249
250 Approver := approverRecord;
251
252 return TRUE;
253
254 EXCEPTION
255 WHEN OTHERS THEN
256 FA_SRVR_MSG.add_message(
257 calling_fn => callingProgram||':'||debugInfo);
258 FA_SRVR_MSG.Add_SQL_Error(
259 calling_fn => callingProgram);
260 return FALSE;
261
262 END GetNextApprover;
263 */
264
265
266
267 FUNCTION GetNextApprover
268 (RequestId IN NUMBER,
269 ChainPhase IN OUT NOCOPY VARCHAR2,
270 Approver OUT NOCOPY AME_UTIL.approverRecord,
271 NoMoreApproverFlag OUT NOCOPY VARCHAR2)
272 return BOOLEAN
273 IS
274
275 approverRecord AME_UTIL.approverRecord;
276
277 l_book_type_code VARCHAR2(30);
278 l_responsibility_id NUMBER(15);
279 l_releasing_approver_id NUMBER(15);
280 l_receiving_approver_id NUMBER(15);
281 l_rule_id NUMBER(15);
282 l_approval_type VARCHAR2(30);
283 l_approval_method VARCHAR2(30);
284 l_error_message VARCHAR2(2000);
285
286 l_dummy NUMBER(15);
287
288 l_chainPhase VARCHAR2(30);
289
290 debugInfo VARCHAR2(255) := NULL;
291
292 localException EXCEPTION;
293
294 callingProgram VARCHAR2(80) := 'GetNextApprover(long format)';
295
296 BEGIN
297
298 -- initialize error message stack.
299 -- FA_SRVR_MSG.init_server_message;
300 -- IA_WF_UTIL_PKG.InitializeDebugMessage;
301
302 l_chainPhase := ChainPhase;
303 NoMoreApproverFlag := 'N';
304
305
306 -----------------------------------------------------
307 debugInfo := 'Retrieve book type code from IA_REQUEST_HEADERS';
308 -----------------------------------------------------
309 begin
310
311 select book_type_code
312 ,responsibility_id
313 ,releasing_approver_id
314 ,receiving_approver_id
315 into l_book_type_code
316 ,l_responsibility_id
317 ,l_releasing_approver_id
318 ,l_receiving_approver_id
319 from ia_request_headers
320 where request_id=RequestId;
321
322 exception
323 when others then
324 FND_MESSAGE.set_name('IA', 'IA_NO_REQUEST_FOUND'); -- Error: Unable to find request id, REQUEST_ID
325 FND_MESSAGE.set_token('REQUEST_ID', RequestId);
326 l_error_message := FND_MESSAGE.Get;
327 raise localException;
328 end;
329
330 -----------------------------------------------------
331 debugInfo := 'Validate Responsibility ID';
332 -----------------------------------------------------
333 begin
334
335 select responsibility_id
336 into l_dummy
337 from fnd_responsibility
338 where responsibility_id=l_responsibility_id
339 and application_id=IA_WF_UTIL_PKG.GetApplicationID;
340
341 exception
342 when others then
343 FND_MESSAGE.set_name('IA', 'IA_NO_RESPONSIBILITY_FOUND'); -- Error: Unable to find responsibility id, RESPONSIBILITY_ID
344 FND_MESSAGE.set_token('RESPONSIBILITY_ID', l_responsibility_id);
345 l_error_message := FND_MESSAGE.Get;
346 raise localException;
347 end;
348
349 -----------------------------------------------------
350 debugInfo := 'Get Rule ID';
351 -----------------------------------------------------
352 begin
353
354 l_rule_id := IA_WF_UTIL_PKG.GetRuleID(p_responsibility_id => l_responsibility_id);
355
356 exception
357 when others then
358 FND_MESSAGE.set_name('IA', 'IA_NO_RULE_ASSIGNED');
359 -- Error: No rule has been defined for responsibility id, RESPONSIBILITY_ID
360 FND_MESSAGE.set_token('RESPONSIBILITY_ID', l_responsibility_id);
361 l_error_message := FND_MESSAGE.Get;
362 raise localException;
363 end;
364
365 -----------------------------------------------------
366 debugInfo := 'Initialize rule setup';
367 -----------------------------------------------------
368 if (not IA_WF_UTIL_PKG.ResetRuleSetup(p_rule_id => l_rule_id,
369 p_book_type_code => l_book_type_code) ) then
370 FND_MESSAGE.set_name('IA', 'IA_RULE_RETRIEVAL_ERROR'); -- Error: Unable to find rule id, RULE_ID
371 FND_MESSAGE.set_token('RULE_ID', l_rule_id);
372 l_error_message := FND_MESSAGE.Get;
373 raise localException;
374 end if;
375
376 -----------------------------------------------------
377 debugInfo := 'Get Approval Type';
378 -----------------------------------------------------
379 l_approval_type := IA_WF_UTIL_PKG.GetApprovalType(p_rule_id => l_rule_id,
380 p_book_type_code => l_book_type_code);
381
382 -----------------------------------------------------
383 debugInfo := 'Get Approval Method';
384 -----------------------------------------------------
385 l_approval_method := IA_WF_UTIL_PKG.GetApprovalMethod(p_rule_id => l_rule_id,
386 p_book_type_code => l_book_type_code);
387
388
389 if ( l_approval_method = IA_WF_UTIL_PKG.ApprovalMethodHierarchy ) then
390
391 /*
392 * This step calls AME_API.getNextApprover.
393 */
394 -----------------------------------------------------
395 debugInfo := 'Calling AME_API.getNextApprover(long format)';
396 -----------------------------------------------------
397 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
398
399
400 if (l_chainPhase is NULL or l_chainPhase = IA_WF_UTIL_PKG.ApprovalTypeReleasing) then
401
402 -----------------------------------------------------
403 debugInfo := 'Calling AME_API.getNextApprover for releasing chain';
404 -----------------------------------------------------
405 AME_API.getNextApprover(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
406 transactionTypeIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
407 transactionIdIn => RequestId,
408 nextApproverOut => approverRecord);
409
410 if (approverRecord.person_id is NULL) then
411 l_chainPhase := IA_WF_UTIL_PKG.ApprovalTypeDestination;
412 end if;
413
414 end if;
415
416 if (l_chainPhase = IA_WF_UTIL_PKG.ApprovalTypeDestination) then
417
418 -----------------------------------------------------
419 debugInfo := 'Calling AME_API.getNextApprover for receiving chain';
420 -----------------------------------------------------
421 AME_API.getNextApprover(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
422 transactionTypeIn => IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType,
423 transactionIdIn => RequestId,
424 nextApproverOut => approverRecord);
425
426 if (approverRecord.person_id is NULL) then
427 NoMoreApproverFlag := 'Y';
428 end if;
429
430 end if;
431
432 else
433
434 -- The following logic will be executed when approval method is COST_CENTER.
435
436 NoMoreApproverFlag := WF_ENGINE.GetItemAttrText(itemtype => IA_WF_UTIL_PKG.WF_TransactionType
437 ,itemkey => RequestId
438 ,aname => 'NO_MORE_APPROVER_FLAG');
439
440 -- if (NoMoreApproverFlag is null or NoMoreApproverFlag = 'N') then
441 if (ChainPhase = IA_WF_UTIL_PKG.ApprovalTypeReleasing ) then
442
443 if (l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeAll or
444 l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeReleasing) then
445
446 if (l_chainPhase is NULL or l_chainPhase = IA_WF_UTIL_PKG.ApprovalTypeReleasing) then
447 approverRecord.person_id := l_releasing_approver_id;
448 l_chainPhase := IA_WF_UTIL_PKG.ApprovalTypeDestination;
449 end if;
450
451 if (l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeReleasing) then
452 NoMoreApproverFlag := 'Y';
453 else
454 NoMoreApproverFlag := 'S';
455 end if;
456
457 end if;
458
459 elsif (NoMoreApproverFlag='Y') then
460
461 approverRecord.person_id := null;
462 l_chainPhase := IA_WF_UTIL_PKG.ApprovalTypeDestination;
463 NoMoreApproverFlag := 'Y';
464
465 else
466
467 if (l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeAll or
468 l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeDestination) then
469
470 approverRecord.person_id := l_receiving_approver_id;
471 l_chainPhase := IA_WF_UTIL_PKG.ApprovalTypeDestination;
472 NoMoreApproverFlag := 'Y';
473
474 end if;
475
476 end if;
477
478 WF_ENGINE.SetItemAttrText(itemtype => IA_WF_UTIL_PKG.WF_TransactionType,
479 itemkey => RequestId,
480 aname => 'NO_MORE_APPROVER_FLAG',
481 avalue => NoMoreApproverFlag);
482
483 end if;
484
485 -- return out parameters
486 ChainPhase := l_chainPhase;
487 Approver := approverRecord;
488
489 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'after', debugInfo);
490
491
492 return TRUE;
493
494 EXCEPTION
495 WHEN OTHERS THEN
496 FA_SRVR_MSG.add_message(
497 calling_fn => callingProgram||':'||debugInfo);
498 FA_SRVR_MSG.Add_SQL_Error(
499 calling_fn => callingProgram);
500 return FALSE;
501
502 END GetNextApprover;
503
504 FUNCTION GetAllApprovers
505 (RequestId IN NUMBER,
506 ReleasingApprovers OUT NOCOPY AME_UTIL.approversTable,
507 ReceivingApprovers OUT NOCOPY AME_UTIL.approversTable)
508 return BOOLEAN
509 IS
510
511 approverTypesList AME_UTIL.stringList;
512 approverIdsList AME_UTIL.stringList;
513
514 releasingApproverRec AME_UTIL.approverRecord;
515 receivingApproverRec AME_UTIL.approverRecord;
516
517 l_book_type_code VARCHAR2(30);
518 l_responsibility_id NUMBER(15);
519 l_releasing_approver_id NUMBER(15);
520 l_receiving_approver_id NUMBER(15);
521 l_rule_id NUMBER(15);
522 l_approval_type VARCHAR2(30);
523 l_approval_method VARCHAR2(30);
524 l_error_message VARCHAR2(2000);
525
526
527 l_dummy NUMBER(15);
528
529 debugInfo VARCHAR2(255) := NULL;
530
531 localException EXCEPTION;
532
533 callingProgram VARCHAR2(80) := 'GetAllApprovers';
534
535 BEGIN
536
537 -----------------------------------------------------
538 debugInfo := 'Retrieve book type code from IA_REQUEST_HEADERS';
539 -----------------------------------------------------
540 begin
541
542 select book_type_code
543 ,responsibility_id
544 ,releasing_approver_id
545 ,receiving_approver_id
546 into l_book_type_code
547 ,l_responsibility_id
548 ,l_releasing_approver_id
549 ,l_receiving_approver_id
550 from ia_request_headers
551 where request_id=RequestId;
552
553 exception
554 when others then
555 FND_MESSAGE.set_name('IA', 'IA_NO_REQUEST_FOUND'); -- Error: Unable to find request id, REQUEST_ID
556 FND_MESSAGE.set_token('REQUEST_ID', RequestId);
557 l_error_message := FND_MESSAGE.Get;
558 raise localException;
559 end;
560
561 -----------------------------------------------------
562 debugInfo := 'Validate Responsibility ID';
563 -----------------------------------------------------
564 begin
565
566 select responsibility_id
567 into l_dummy
568 from fnd_responsibility
569 where responsibility_id=l_responsibility_id
570 and application_id=IA_WF_UTIL_PKG.GetApplicationID;
571
572 exception
573 when others then
574 FND_MESSAGE.set_name('IA', 'IA_NO_RESPONSIBILITY_FOUND'); -- Error: Unable to find responsibility id, RESPONSIBILITY_ID
575 FND_MESSAGE.set_token('RESPONSIBILITY_ID', l_responsibility_id);
576 l_error_message := FND_MESSAGE.Get;
577 raise localException;
578 end;
579
580 -----------------------------------------------------
581 debugInfo := 'Get Rule ID';
582 -----------------------------------------------------
583 begin
584
585 l_rule_id := IA_WF_UTIL_PKG.GetRuleID(p_responsibility_id => l_responsibility_id);
586
587 exception
588 when others then
589 FND_MESSAGE.set_name('IA', 'IA_NO_RULE_ASSIGNED'); -- Error: No rule has been defined for responsibility id, RESPONSIBILITY_ID.
590 FND_MESSAGE.set_token('RESPONSIBILITY_ID', l_responsibility_id);
591 l_error_message := FND_MESSAGE.Get;
592 raise localException;
593 end;
594
595 -----------------------------------------------------
596 debugInfo := 'Initialize rule setup';
597 -----------------------------------------------------
598 if (not IA_WF_UTIL_PKG.ResetRuleSetup(p_rule_id => l_rule_id,
599 p_book_type_code => l_book_type_code) ) then
600 FND_MESSAGE.set_name('IA', 'IA_RULE_RETRIEVAL_ERROR'); -- Error: Unable to find rule id, RULE_ID
601 FND_MESSAGE.set_token('RULE_ID', l_rule_id);
602 l_error_message := FND_MESSAGE.Get;
603 raise localException;
604 end if;
605
606 -----------------------------------------------------
607 debugInfo := 'Get Approval Type';
608 -----------------------------------------------------
609 l_approval_type := IA_WF_UTIL_PKG.GetApprovalType(p_rule_id => l_rule_id,
610 p_book_type_code => l_book_type_code);
611
612 -----------------------------------------------------
613 debugInfo := 'Get Approval Method';
614 -----------------------------------------------------
615 l_approval_method := IA_WF_UTIL_PKG.GetApprovalMethod(p_rule_id => l_rule_id,
616 p_book_type_code => l_book_type_code);
617
618
619 /*
620 * This step calls AME_API.getAllApprovers only when Approval method is HIERARCHY.
621 */
622
623 -- if ( l_approval_method = IA_WF_UTIL_PKG.ApprovalMethodHierarchy ) then
624
625 -----------------------------------------------------
626 debugInfo := 'Calling AME_API.getAllApprovers';
627 -----------------------------------------------------
628 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
629
630 if (l_releasing_approver_id is NOT NULL
631 and (l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeAll or l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeReleasing)) then
632 AME_API.getAllApprovers(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
633 transactionTypeIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
634 transactionIdIn => RequestId,
635 ApproversOut => ReleasingApprovers);
636 end if;
637
638 if (l_receiving_approver_id is NOT NULL
639 and (l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeAll or l_approval_type = IA_WF_UTIL_PKG.ApprovalTypeDestination)) then
640 AME_API.getAllApprovers(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
641 transactionTypeIn => IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType,
642 transactionIdIn => RequestId,
643 ApproversOut => ReceivingApprovers);
644 end if;
645
646 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'after', debugInfo);
647
648 /*
649 else
650
651 -- The following logic will be executed when approval method is COST_CENTER.
652
653 releasingApproverRec.person_id := l_releasing_approver_id;
654 receivingApproverRec.person_id := l_receiving_approver_id;
655
656 ReleasingApprovers(1) := releasingApproverRec;
657 ReceivingApprovers(1) := receivingApproverRec;
658
659 end if;
660 */
661
662
663 return TRUE;
664
665 EXCEPTION
666 WHEN OTHERS THEN
667 FA_SRVR_MSG.add_message(
668 calling_fn => l_error_message);
669 FA_SRVR_MSG.add_message(
670 calling_fn => callingProgram||':'||debugInfo);
671 FA_SRVR_MSG.Add_SQL_Error(
672 calling_fn => callingProgram);
673 return FALSE;
674
675 END GetAllApprovers;
676
677 FUNCTION UpdateApprovalStatus
678 (RequestId IN NUMBER,
679 ChainPhase IN VARCHAR2,
680 Approver IN AME_UTIL.approverRecord DEFAULT AME_UTIL.emptyApproverRecord,
681 Forwardee IN AME_UTIL.approverRecord DEFAULT AME_UTIL.emptyApproverRecord)
682 return BOOLEAN
683 IS
684
685 l_transactionType VARCHAR2(255) := IA_WF_UTIL_PKG.AME_RELEASE_TransactionType;
686
687 debugInfo VARCHAR2(255) := NULL;
688
689 localException EXCEPTION;
690
691 callingProgram VARCHAR2(80) := 'UpdateApprovalStatus';
692
693 BEGIN
694
695 /*
696 * This step calls AME_API.getNextApprover.
697 */
698 -----------------------------------------------------
699 debugInfo := 'Calling AME_API.UpdateApprovalStatus';
700 -----------------------------------------------------
701 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
702
703 if (ChainPhase = IA_WF_UTIL_PKG.ApprovalTypeReleasing) then
704 l_transactionType := IA_WF_UTIL_PKG.AME_RELEASE_TransactionType;
705 else
706 l_transactionType := IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType;
707 end if;
708
709 AME_API.updateApprovalStatus(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
710 transactionTypeIn => l_transactionType,
711 transactionIdIn => RequestId,
712 approverIn => Approver,
713 forwardeeIn => Forwardee);
714
715 /*
716 AME_API.updateApprovalStatus2(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
717 transactionIdIn => l_transactionType,
718 approvalStatusIn => ame_util.noResponseStatus,
719 approverPersonIdIn => l_forward_from_id,
720 approverUserIdIn => NULL,
721 transactionTypeIn => p_item_type,
722 forwardeeIn => l_recApprover);
723 */
724
725 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'after', debugInfo);
726
727 return TRUE;
728
729 EXCEPTION
730 WHEN OTHERS THEN
731 FA_SRVR_MSG.add_message(
732 calling_fn => callingProgram||':'||debugInfo);
733 FA_SRVR_MSG.Add_SQL_Error(
734 calling_fn => callingProgram);
735 return FALSE;
736
737 END UpdateApprovalStatus;
738
739 FUNCTION InitializePlsqlContext
740 (RequestId IN NUMBER)
741 return BOOLEAN
742 IS
743
744 debugInfo VARCHAR2(255) := NULL;
745
746 localException EXCEPTION;
747
748 callingProgram VARCHAR2(80) := 'InitializePlsqlContext';
749
750 BEGIN
751
752 /*
753 * This step calls AME_ENGINE.InitializePlsqlContext.
754 */
755 -----------------------------------------------------
756 debugInfo := 'Calling AME_ENGINE.initializePlsqlContext';
757 -----------------------------------------------------
758 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
759
760 /*
761 AME_ENGINE.initializePlsqlContext(ameApplicationIdIn => null,
762 fndApplicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
763 transactionTypeIdIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
764 transactionIdIn => RequestId);
765
766 AME_ENGINE.initializePlsqlContext(ameApplicationIdIn => null,
767 fndApplicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
768 transactionTypeIdIn => IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType,
769 transactionIdIn => RequestId);
770 */
771
772 return TRUE;
773
774 EXCEPTION
775 WHEN OTHERS THEN
776 FA_SRVR_MSG.add_message(
777 calling_fn => callingProgram||':'||debugInfo);
778 FA_SRVR_MSG.Add_SQL_Error(
779 calling_fn => callingProgram);
780 return FALSE;
781
782 END InitializePlsqlContext;
783
784 FUNCTION InitializeAME
785 (RequestId IN NUMBER)
786 return BOOLEAN
787 IS
788
789 debugInfo VARCHAR2(255) := NULL;
790
791 localException EXCEPTION;
792
793 callingProgram VARCHAR2(80) := 'InitializeAME';
794
795 BEGIN
796
797 /*
798 * This step calls AME_API.clearAllApprovals.
799 */
800 -----------------------------------------------------
801 debugInfo := 'Calling AME_ENGINE.initializePlsqlContext';
802 -----------------------------------------------------
803 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
804
805 AME_ENGINE.initializePlsqlContext(ameApplicationIdIn => null,
806 fndApplicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
807 transactionTypeIdIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
808 transactionIdIn => RequestId);
809
810 AME_ENGINE.initializePlsqlContext(ameApplicationIdIn => null,
811 fndApplicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
812 transactionTypeIdIn => IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType,
813 transactionIdIn => RequestId);
814
815 -----------------------------------------------------
816 debugInfo := 'Calling AME_API.clearAllApprovals';
817 -----------------------------------------------------
818 IA_WF_UTIL_PKG.AddDebugMessage(callingProgram, 'before', debugInfo);
819
820 AME_API.clearAllApprovals(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
821 transactionTypeIn => IA_WF_UTIL_PKG.AME_RELEASE_TransactionType,
822 transactionIdIn => RequestId);
823
824 AME_API.clearAllApprovals(applicationIdIn => IA_WF_UTIL_PKG.GetApplicationID,
825 transactionTypeIn => IA_WF_UTIL_PKG.AME_RECEIVE_TransactionType,
826 transactionIdIn => RequestId);
827
828
829 return TRUE;
830
831 EXCEPTION
832 WHEN OTHERS THEN
833 FA_SRVR_MSG.add_message(
834 calling_fn => callingProgram||':'||debugInfo);
835 FA_SRVR_MSG.Add_SQL_Error(
836 calling_fn => callingProgram);
837 return FALSE;
838
839 END InitializeAME;
840
841 END IA_AME_REQUEST_PKG;