[Home] [Help]
PACKAGE BODY: APPS.AME_API6
Source
1 package body ame_api6 as
2 /* $Header: ameeapi6.pkb 120.1 2006/07/22 12:36:15 pvelugul noship $ */
3 ambiguousApproverException exception;
4 ambiguousApproverMessage constant ame_util.longestStringType :=
5 ame_util.getMessage(applicationShortNameIn =>'PER',
6 messageNameIn => 'AME_400249_API_APR_REC_NULL');
7 procedure getApprovers(applicationIdIn in number
8 ,transactionTypeIn in varchar2
9 ,transactionIdIn in varchar2
10 ,approversOut out nocopy ame_util.approversTable2) as
11 ameApplicationId integer;
12 tempIndex integer;
13 cursor approversCursor (applicationIdIn in integer
14 ,transactionIdIn in varchar2) is
15 select atah.row_timestamp row_timestamp
16 ,atah.item_class item_class
17 ,atah.item_id item_id
18 ,atah.name name
19 ,atah.order_number order_number
20 ,atah.approver_category category
21 ,atah.user_comments user_comment
22 ,atah.status status
23 ,atah.authority
24 ,atah.occurrence
25 ,atah.action_type_id
26 ,atah.group_or_chain_id
27 ,atah.api_insertion
28 ,atah.member_order_number
29 from ame_trans_approval_history atah
30 where atah.date_cleared is null
31 and atah.transaction_id = transactionIdIn
32 and atah.application_id = applicationIdIn
33 and atah.trans_history_id =
34 (
35 select max(b.trans_history_id)
36 from ame_trans_approval_history b
37 where atah.transaction_id = b.transaction_id
38 and atah.application_id = b.application_id
39 and atah.name = b.name
40 and atah.approver_category = b.approver_category
41 and atah.item_class = b.item_class
42 and atah.item_id = b.item_id
43 and atah.action_type_id = b.action_type_id
44 and atah.authority = b.authority
45 and atah.group_or_chain_id = b.group_or_chain_id
46 and atah.occurrence = b.occurrence
47 and b.date_cleared is null);
48 begin
49 --+
50 -- get the ame application id.
51 --+
52 tempIndex := 0;
53 ameApplicationId :=
54 ame_admin_pkg.getApplicationId
55 (fndAppIdIn => applicationIdIn
56 ,transactionTypeIdIn => transactionTypeIn);
57 for approver in approversCursor(applicationIdIn => ameApplicationId
58 ,transactionIdIn => transactionIdIn) loop
59 tempIndex := tempIndex + 1;
60 approversOut(tempIndex).name := approver.name;
61 approversOut(tempIndex).display_name := ame_approver_type_pkg.getApproverDisplayName
62 (nameIn => approver.name);
63 approversOut(tempIndex).item_class := approver.item_class;
64 approversOut(tempIndex).item_id := approver.item_id;
65 approversOut(tempIndex).approver_category := approver.category;
66 approversOut(tempIndex).authority := approver.authority;
67 approversOut(tempIndex).approval_status := approver.status;
68 approversOut(tempIndex).action_type_id := approver.action_type_id;
69 approversOut(tempIndex).group_or_chain_id := approver.group_or_chain_id;
70 approversOut(tempIndex).occurrence := approver.occurrence;
71 approversOut(tempIndex).approver_order_number := approver.order_number;
72 approversOut(tempIndex).api_insertion := approver.api_insertion;
73 approversOut(tempIndex).member_order_number := approver.member_order_number;
74 ame_approver_type_pkg.getApproverOrigSystemAndId
75 (nameIn => approver.name
76 ,origSystemOut => approversOut(tempIndex).orig_system
77 ,origSystemIdOut => approversOut(tempIndex).orig_system_id);
78 /*
79 The old approver list does not maintain source. Calling applications requiring
80 source data must get it by calling getNextApprover or getAllApprovers.
81 */
82 approversOut(tempIndex).source := null;
83 end loop;
84 exception
85 when others then
86 ame_util.runtimeException(packageNameIn => 'ame_api6',
87 routineNameIn => 'getApprovers',
88 exceptionNumberIn => sqlcode,
89 exceptionStringIn => sqlerrm);
90 approversOut.delete;
91 raise;
92 end getApprovers;
93 procedure updateApprovalStatus(applicationIdIn in number,
94 transactionTypeIn in varchar2,
95 transactionIdIn in varchar2,
96 approverIn in ame_util.approverRecord2,
97 notificationIn in ame_util2.notificationRecord
98 default ame_util2.emptyNotificationRecord,
99 forwardeeIn in ame_util.approverRecord2 default
100 ame_util.emptyApproverRecord2,
101 updateItemIn in boolean default false) as
102 errorCode integer;
103 errorMessage ame_util.longStringType;
104 begin
105 /* Validate the input approver. */
106 if(approverIn.name is null) then
107 raise ambiguousApproverException;
108 end if;
109 ame_engine.updateApprovalStatus(applicationIdIn => applicationIdIn,
110 transactionTypeIn => transactionTypeIn,
111 transactionIdIn => transactionIdIn,
112 approverIn => approverIn,
113 notificationIn => notificationIn,
114 forwardeeIn => forwardeeIn,
115 updateItemIn => updateItemIn);
116 exception
117 when ambiguousApproverException then
118 errorCode := -20001;
119 errorMessage := ambiguousApproverMessage;
120 ame_util.runtimeException(packageNameIn => 'ame_api2',
121 routineNameIn => 'updateApprovalStatus',
122 exceptionNumberIn => errorCode,
123 exceptionStringIn => errorMessage);
124 raise_application_error(errorCode,
125 errorMessage);
126 when others then
127 ame_util.runtimeException(packageNameIn => 'ame_api2',
128 routineNameIn => 'updateApprovalStatus',
129 exceptionNumberIn => sqlcode,
133 procedure updateApprovalStatus2(applicationIdIn in number,
130 exceptionStringIn => sqlerrm);
131 raise;
132 end updateApprovalStatus;
134 transactionTypeIn in varchar2,
135 transactionIdIn in varchar2,
136 approvalStatusIn in varchar2,
137 approverNameIn in varchar2,
138 itemClassIn in varchar2 default null,
139 itemIdIn in varchar2 default null,
140 actionTypeIdIn in number default null,
141 groupOrChainIdIn in number default null,
142 occurrenceIn in number default null,
143 notificationIn in ame_util2.notificationRecord
144 default ame_util2.emptyNotificationRecord,
145 forwardeeIn in ame_util.approverRecord2
146 default ame_util.emptyApproverRecord2,
147 updateItemIn in boolean default false) as
148 approver ame_util.approverRecord2;
149 errorCode integer;
150 errorMessage ame_util.longStringType;
151 nullApproverException exception;
152 begin
153 /* No locking needed here as it is done in updateApprovalStatus */
154 if approverNameIn is not null then
155 approver.name := approverNameIn;
156 else
157 raise nullApproverException;
158 end if;
159 approver.item_class := itemClassIn ;
160 approver.item_id := itemIdIn ;
161 approver.approval_status := approvalStatusIn;
162 approver.action_type_id :=actionTypeIdIn ;
163 approver.group_or_chain_id := groupOrChainIdIn;
164 approver.occurrence := occurrenceIn;
165 ame_approver_type_pkg.getOrigSystemIdAndDisplayName(nameIn =>approver.name,
166 origSystemOut => approver.orig_system,
167 origSystemIdOut => approver.orig_system_id,
168 displayNameOut => approver.display_name);
169 ame_engine.updateApprovalStatus(applicationIdIn => applicationIdIn,
170 transactionIdIn => transactionIdIn,
171 approverIn => approver,
172 transactionTypeIn => transactionTypeIn,
173 notificationIn => notificationIn,
174 forwardeeIn => forwardeeIn,
175 updateItemIn => updateItemIn);
176 exception
177 when nullApproverException then
178 errorCode := -20001;
179 errorMessage :=
180 ame_util.getMessage(applicationShortNameIn =>'PER',
181 messageNameIn => 'AME_400248_API_USR_PER_NULL');
182 ame_util.runtimeException(packageNameIn => 'ame_api2',
183 routineNameIn => 'updateApprovalStatus2',
184 exceptionNumberIn => errorCode,
185 exceptionStringIn => errorMessage);
186 raise_application_error(errorCode,
187 errorMessage);
188 when others then
189 ame_util.runtimeException(packageNameIn => 'ame_api2',
190 routineNameIn => 'updateApprovalStatus2',
191 exceptionNumberIn => sqlcode,
192 exceptionStringIn => sqlerrm);
193 raise;
194 end updateApprovalStatus2;
195 end ame_api6;