[Home] [Help]
PACKAGE BODY: APPS.AME_ACA_SHD
Source
1 Package Body ame_aca_shd as
2 /* $Header: amacarhi.pkb 120.4 2006/10/05 15:53:53 pvelugul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ame_aca_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14 (p_constraint_name in all_constraints.constraint_name%TYPE
15 ) Is
16 --
17 l_proc varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20 --
21 If (p_constraint_name = 'AME_CALLING_APPS_PK') Then
22 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23 fnd_message.set_token('PROCEDURE', l_proc);
24 fnd_message.set_token('STEP','5');
25 fnd_message.raise_error;
26 Else
27 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28 fnd_message.set_token('PROCEDURE', l_proc);
29 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30 fnd_message.raise_error;
31 End If;
32 --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39 (p_effective_date in date
40 ,p_application_id in number
41 ,p_object_version_number in number
42 ) Return Boolean Is
43 --
44 -- Cursor selects the 'current' row from the HR Schema
45 --
46 Cursor C_Sel1 is
47 select
48 fnd_application_id
49 ,application_name
50 ,transaction_type_id
51 ,application_id
52 ,line_item_id_query
53 ,start_date
54 ,end_date
55 ,security_group_id
56 ,object_version_number
57 from ame_calling_apps
58 where application_id = p_application_id
59 and p_effective_date
60 between start_date
61 and nvl(end_date - ame_util.oneSecond,p_effective_date);
62 --
63 l_fct_ret boolean;
64 --
65 Begin
66 --
67 If (p_effective_date is null or
68 p_application_id is null or
69 p_object_version_number is null) Then
70 --
71 -- One of the primary key arguments is null therefore we must
72 -- set the returning function value to false
73 --
74 l_fct_ret := false;
75 Else
76 If (p_application_id =
77 ame_aca_shd.g_old_rec.application_id and
78 p_object_version_number =
79 ame_aca_shd.g_old_rec.object_version_number) Then
80 --
81 -- The g_old_rec is current therefore we must
82 -- set the returning function to true
83 --
84 l_fct_ret := true;
85 Else
86 --
87 -- Select the current row
88 --
89 Open C_Sel1;
90 Fetch C_Sel1 Into ame_aca_shd.g_old_rec;
91 If C_Sel1%notfound Then
92 Close C_Sel1;
93 --
94 -- The primary key is invalid therefore we must error
95 --
96 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
97 fnd_message.raise_error;
98 End If;
99 Close C_Sel1;
100 If (p_object_version_number
101 <> ame_aca_shd.g_old_rec.object_version_number) Then
102 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
103 fnd_message.raise_error;
104 End If;
105 l_fct_ret := true;
106 End If;
107 End If;
108 Return (l_fct_ret);
109 --
110 End api_updating;
111 --
112 -- ----------------------------------------------------------------------------
113 -- |----------------------------< upd_end_date >------------------------------|
114 -- ----------------------------------------------------------------------------
115 Procedure upd_end_date
116 (p_effective_date in date
117 ,p_application_id in number
118 ,p_new_end_date in date
119 ,p_object_version_number out nocopy number
120 ) is
121 --
122 l_proc varchar2(72) := g_package||'upd_end_date';
123 l_current_user_id integer;
124 l_object_version_number number;
125 --
126 Begin
127 hr_utility.set_location('Entering:'||l_proc, 5);
128 --
129 l_current_user_id := fnd_global.user_id;
130 --
131 -- Because we are updating a row we must get the next object
132 -- version number.
133 --
134 l_object_version_number :=
135 ame_aca_shd.get_object_version_number
136 (p_application_id => p_application_id
137 );
138 --
139 hr_utility.set_location(l_proc, 10);
140 --
141 --
142 -- Update the specified datetrack row setting the effective
143 -- end date to the specified new effective end date.
144 --
145 update ame_calling_apps t
146 set t.end_date = p_new_end_date
147 ,t.last_updated_by = l_current_user_id
148 ,t.last_update_date = p_new_end_date
149 ,t.last_update_login = l_current_user_id
150 , t.object_version_number = l_object_version_number
151 where t.application_id = p_application_id
152 and p_effective_date
153 between t.start_date and nvl(t.end_date - ame_util.oneSecond,p_effective_date)
154 ;
155 --
156 --
157 p_object_version_number := l_object_version_number;
158 hr_utility.set_location(' Leaving:'||l_proc, 15);
159 --
160 End upd_end_date;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |---------------------------------< lck >----------------------------------|
164 -- ----------------------------------------------------------------------------
165 Procedure lck
166 (p_effective_date in date
167 ,p_datetrack_mode in varchar2
168 ,p_application_id in number
169 ,p_object_version_number in number
170 ,p_validation_start_date out nocopy date
171 ,p_validation_end_date out nocopy date
172 ) is
173 --
174 l_proc varchar2(72) := g_package||'lck';
175 l_validation_start_date date;
176 l_validation_end_date date;
177 l_argument varchar2(30);
178 --
179 -- Cursor C_Sel1 selects the current locked row as of session date
180 -- ensuring that the object version numbers match.
181 --
182 Cursor C_Sel1 is
183 select
184 fnd_application_id
185 ,application_name
186 ,transaction_type_id
187 ,application_id
188 ,line_item_id_query
189 ,start_date
190 ,end_date
191 ,security_group_id
192 ,object_version_number
193 from ame_calling_apps
194 where application_id = p_application_id
195 and p_effective_date
196 between start_date and nvl(end_date - ame_util.oneSecond, p_effective_date)
197 for update nowait;
198 --
199 --
200 --
201 Begin
202 hr_utility.set_location('Entering:'||l_proc, 5);
203 --
204 -- Ensure that all the mandatory arguments are not null
205 --
206 hr_api.mandatory_arg_error(p_api_name => l_proc
207 ,p_argument => 'effective_date'
208 ,p_argument_value => p_effective_date
209 );
210 --
211 hr_api.mandatory_arg_error(p_api_name => l_proc
212 ,p_argument => 'datetrack_mode'
213 ,p_argument_value => p_datetrack_mode
214 );
215 --
216 hr_api.mandatory_arg_error(p_api_name => l_proc
217 ,p_argument => 'application_id'
218 ,p_argument_value => p_application_id
219 );
220 --
221 hr_api.mandatory_arg_error(p_api_name => l_proc
222 ,p_argument => 'object_version_number'
223 ,p_argument_value => p_object_version_number
224 );
225 --
226 -- Check to ensure the datetrack mode is not INSERT.
227 --
228 If (p_datetrack_mode <> hr_api.g_insert) then
229 --
230 -- We must select and lock the current row.
231 --
232 Open C_Sel1;
233 Fetch C_Sel1 Into ame_aca_shd.g_old_rec;
234 If C_Sel1%notfound then
235 Close C_Sel1;
236 --
237 -- The primary key is invalid therefore we must error
238 --
239 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
240 fnd_message.raise_error;
241 End If;
242 Close C_Sel1;
243 If (p_object_version_number
244 <> ame_aca_shd.g_old_rec.object_version_number) Then
245 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
246 fnd_message.raise_error;
247 End If;
248 --
249 --
250 --
251 Else
252 --
253 -- We are doing a datetrack 'INSERT' which is illegal within this
254 -- procedure therefore we must error (note: to lck on insert the
255 -- private procedure ins_lck should be called).
256 --
257 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
258 fnd_message.set_token('PROCEDURE', l_proc);
259 fnd_message.set_token('STEP','20');
260 fnd_message.raise_error;
261 End If;
262 --
263 -- Set the validation start and end date OUT arguments
264 --
265 if (p_datetrack_mode = hr_api.g_update) then
266 p_validation_start_date := p_effective_date;
267 p_validation_end_date := ame_aca_shd.g_old_rec.end_date;
268 elsif (p_datetrack_mode = hr_api.g_delete) then
269 p_validation_start_date := p_effective_date;
270 p_validation_end_date := p_effective_date;
271 end if;
272 --
273 hr_utility.set_location(' Leaving:'||l_proc, 30);
274 --
275 -- We need to trap the ORA LOCK exception
276 --
277 Exception
278 When HR_Api.Object_Locked then
279 --
280 -- The object is locked therefore we need to supply a meaningful
281 -- error message.
282 --
283 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
284 fnd_message.set_token('TABLE_NAME', 'ame_calling_apps');
285 fnd_message.raise_error;
286 End lck;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |-----------------------------< convert_args >-----------------------------|
290 -- ----------------------------------------------------------------------------
291 Function convert_args
292 (p_fnd_application_id in number
293 ,p_application_name in varchar2
294 ,p_transaction_type_id in varchar2
295 ,p_application_id in number
296 ,p_line_item_id_query in varchar2
297 ,p_start_date in date
298 ,p_end_date in date
299 ,p_security_group_id in number
300 ,p_object_version_number in number
301 )
302 Return g_rec_type is
303 --
304 l_rec g_rec_type;
305 --
306 Begin
307 --
308 -- Convert arguments into local l_rec structure.
309 --
310 l_rec.fnd_application_id := p_fnd_application_id;
311 l_rec.application_name := p_application_name;
312 l_rec.transaction_type_id := p_transaction_type_id;
313 l_rec.application_id := p_application_id;
314 l_rec.line_item_id_query := p_line_item_id_query;
315 l_rec.start_date := p_start_date;
316 l_rec.end_date := p_end_date;
317 l_rec.security_group_id := p_security_group_id;
318 l_rec.object_version_number := p_object_version_number;
319 --
320 -- Return the plsql record structure.
321 --
322 Return(l_rec);
326 -- ----------------------------------------------------------------------------
323 --
324 End convert_args;
325 --
327 -- |------------------------< get_object_version_number >----------------------|
328 -- ----------------------------------------------------------------------------
329 Function get_object_version_number
330 (p_application_id in number
331 )
332 Return number is
333 --
334 l_ovn number;
335 --
336 Begin
337 --
338 -- get the next ovn
339 --
340 select nvl(max(t.object_version_number),0) + 1
341 into l_ovn
342 from ame_calling_apps t
343 where t.application_id = p_application_id;
344 --
345 -- Return the new object_version_number.
346 --
347 Return(l_ovn);
348 --
349 End get_object_version_number;
350 --
351 --
352 end ame_aca_shd;