[Home] [Help]
PACKAGE BODY: APPS.PAY_CAL_SHD
Source
1 Package Body pay_cal_shd as
2 /* $Header: pycalrhi.pkb 120.1 2005/11/11 07:06:15 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_cal_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15 Begin
16 --
17 Return (nvl(g_api_dml, false));
18 --
19 End return_api_dml_status;
20 --
21 -- ----------------------------------------------------------------------------
22 -- |---------------------------< constraint_error >---------------------------|
23 -- ----------------------------------------------------------------------------
24 Procedure constraint_error
25 (p_constraint_name in all_constraints.constraint_name%TYPE
26 ) Is
27 --
28 l_proc varchar2(72) := g_package||'constraint_error';
29 --
30 Begin
31 --
32 If (p_constraint_name = 'PAY_COST_ALLOCATIONS_F_FK1') Then
33 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
34 fnd_message.set_token('PROCEDURE', l_proc);
35 fnd_message.set_token('STEP','5');
36 fnd_message.raise_error;
37 ElsIf (p_constraint_name = 'PAY_COST_ALLOCATIONS_F_FK2') Then
38 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
39 fnd_message.set_token('PROCEDURE', l_proc);
40 fnd_message.set_token('STEP','10');
41 fnd_message.raise_error;
42 ElsIf (p_constraint_name = 'PAY_COST_ALLOCATIONS_F_PK') Then
43 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
44 fnd_message.set_token('PROCEDURE', l_proc);
45 fnd_message.set_token('STEP','15');
46 fnd_message.raise_error;
47 Else
48 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
49 fnd_message.set_token('PROCEDURE', l_proc);
50 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
51 fnd_message.raise_error;
52 End If;
53 --
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60 (p_effective_date in date
61 ,p_cost_allocation_id in number
62 ,p_object_version_number in number
63 ) Return Boolean Is
64 --
65 -- Cursor selects the 'current' row from the HR Schema
66 --
67 Cursor C_Sel1 is
68 select
69 cost_allocation_id
70 ,effective_start_date
71 ,effective_end_date
72 ,business_group_id
73 ,cost_allocation_keyflex_id
74 ,assignment_id
75 ,proportion
76 ,request_id
77 ,program_application_id
78 ,program_id
79 ,program_update_date
80 ,object_version_number
81 from pay_cost_allocations_f
82 where cost_allocation_id = p_cost_allocation_id
83 and p_effective_date
84 between effective_start_date and effective_end_date;
85 --
86 l_fct_ret boolean;
87 --
88 Begin
89 --
90 If (p_effective_date is null or
91 p_cost_allocation_id is null or
92 p_object_version_number is null) Then
93 --
94 -- One of the primary key arguments is null therefore we must
95 -- set the returning function value to false
96 --
97 l_fct_ret := false;
98 Else
99 If (p_cost_allocation_id =
100 pay_cal_shd.g_old_rec.cost_allocation_id and
101 p_object_version_number =
102 pay_cal_shd.g_old_rec.object_version_number
103 ) Then
104 --
105 -- The g_old_rec is current therefore we must
106 -- set the returning function to true
107 --
108 l_fct_ret := true;
109 Else
110 --
111 -- Select the current row
112 --
113 Open C_Sel1;
114 Fetch C_Sel1 Into pay_cal_shd.g_old_rec;
115 If C_Sel1%notfound Then
116 Close C_Sel1;
117 --
118 -- The primary key is invalid therefore we must error
119 --
120 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
121 fnd_message.raise_error;
122 End If;
123 Close C_Sel1;
124 If (p_object_version_number
125 <> pay_cal_shd.g_old_rec.object_version_number) Then
126 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
127 fnd_message.raise_error;
128 End If;
129 l_fct_ret := true;
130 End If;
131 End If;
132 Return (l_fct_ret);
133 --
134 End api_updating;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |---------------------------< find_dt_upd_modes >--------------------------|
138 -- ----------------------------------------------------------------------------
139 Procedure find_dt_upd_modes
140 (p_effective_date in date
141 ,p_base_key_value in number
142 ,p_correction out nocopy boolean
143 ,p_update out nocopy boolean
144 ,p_update_override out nocopy boolean
145 ,p_update_change_insert out nocopy boolean
146 ) is
147 --
148 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
149 --
150 Begin
151 hr_utility.set_location('Entering:'||l_proc, 5);
152 --
153 -- Call the corresponding datetrack api
154 --
155 dt_api.find_dt_upd_modes
156 (p_effective_date => p_effective_date
157 ,p_base_table_name => 'pay_cost_allocations_f'
158 ,p_base_key_column => 'cost_allocation_id'
159 ,p_base_key_value => p_base_key_value
160 ,p_correction => p_correction
161 ,p_update => p_update
162 ,p_update_override => p_update_override
163 ,p_update_change_insert => p_update_change_insert
164 );
165 --
166 hr_utility.set_location(' Leaving:'||l_proc, 10);
167 End find_dt_upd_modes;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |---------------------------< find_dt_del_modes >--------------------------|
171 -- ----------------------------------------------------------------------------
172 Procedure find_dt_del_modes
173 (p_effective_date in date
174 ,p_base_key_value in number
175 ,p_zap out nocopy boolean
176 ,p_delete out nocopy boolean
177 ,p_future_change out nocopy boolean
178 ,p_delete_next_change out nocopy boolean
179 ) is
180 --
181 l_proc varchar2(72) := g_package||'find_dt_del_modes';
182 --
183 --
184 Begin
185 hr_utility.set_location('Entering:'||l_proc, 5);
186 --
187 -- Call the corresponding datetrack api
188 --
189 dt_api.find_dt_del_modes
190 (p_effective_date => p_effective_date
191 ,p_base_table_name => 'pay_cost_allocations_f'
192 ,p_base_key_column => 'cost_allocation_id'
193 ,p_base_key_value => p_base_key_value
194 ,p_zap => p_zap
195 ,p_delete => p_delete
196 ,p_future_change => p_future_change
197 ,p_delete_next_change => p_delete_next_change
198 );
199 --
200 hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End find_dt_del_modes;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |-----------------------< upd_effective_end_date >-------------------------|
205 -- ----------------------------------------------------------------------------
206 Procedure upd_effective_end_date
207 (p_effective_date in date
208 ,p_base_key_value in number
209 ,p_new_effective_end_date in date
210 ,p_validation_start_date in date
211 ,p_validation_end_date in date
212 ,p_object_version_number out nocopy number
213 ) is
214 --
215 l_proc varchar2(72) := g_package||'upd_effective_end_date';
216 l_object_version_number number;
217 --
218 Begin
219 hr_utility.set_location('Entering:'||l_proc, 5);
220 --
221 -- Because we are updating a row we must get the next object
222 -- version number.
223 --
224 l_object_version_number :=
225 dt_api.get_object_version_number
226 (p_base_table_name => 'pay_cost_allocations_f'
227 ,p_base_key_column => 'cost_allocation_id'
228 ,p_base_key_value => p_base_key_value
229 );
230 --
231 hr_utility.set_location(l_proc, 10);
232
233 hr_utility.set_location('p_effective_date:'|| p_effective_date, 10);
234 hr_utility.set_location('p_base_key_value:'|| p_base_key_value, 10);
235 hr_utility.set_location('p_new_effective_end_date:'|| p_new_effective_end_date, 10);
236 hr_utility.set_location('p_validation_start_date:'|| p_validation_start_date, 10);
237 hr_utility.set_location('p_validation_end_date:'|| p_validation_end_date, 10);
238 hr_utility.set_location('p_object_version_number:'|| p_object_version_number, 10);
239 hr_utility.set_location('l_object_version_number:'|| l_object_version_number, 10);
240
241 pay_cal_shd.g_api_dml := true; -- Set the api dml status
242 --
243 -- Update the specified datetrack row setting the effective
244 -- end date to the specified new effective end date.
245 --
246
247 update pay_cost_allocations_f t
248 set t.effective_end_date = p_new_effective_end_date
249 , t.object_version_number = l_object_version_number
250 where t.cost_allocation_id = p_base_key_value
251 and p_effective_date
252 between t.effective_start_date and t.effective_end_date;
253 --
254 hr_utility.set_location('after Update:', 20);
255
256 pay_cal_shd.g_api_dml := false; -- Unset the api dml status
257 p_object_version_number := l_object_version_number;
258 hr_utility.set_location(' Leaving:'||l_proc, 15);
259 --
260 Exception
261 When Others Then
262 pay_cal_shd.g_api_dml := false; -- Unset the api dml status
263 Raise;
264 --
265 End upd_effective_end_date;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< lck >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure lck
271 (p_effective_date in date
272 ,p_datetrack_mode in varchar2
273 ,p_cost_allocation_id in number
274 ,p_object_version_number in number
275 ,p_validation_start_date out nocopy date
276 ,p_validation_end_date out nocopy date
277 ) is
278 --
279 l_proc varchar2(72) := g_package||'lck';
280 l_validation_start_date date;
281 l_validation_end_date date;
282 l_argument varchar2(30);
283 --
284 -- Cursor C_Sel1 selects the current locked row as of session date
285 -- ensuring that the object version numbers match.
286 --
287 Cursor C_Sel1 is
288 select
289 cost_allocation_id
290 ,effective_start_date
291 ,effective_end_date
292 ,business_group_id
293 ,cost_allocation_keyflex_id
294 ,assignment_id
295 ,proportion
296 ,request_id
297 ,program_application_id
298 ,program_id
299 ,program_update_date
300 ,object_version_number
301 from pay_cost_allocations_f
302 where cost_allocation_id = p_cost_allocation_id
303 and p_effective_date
304 between effective_start_date and effective_end_date
305 for update nowait;
306 --
307 --
308 --
309 Begin
310 hr_utility.set_location('Entering:'||l_proc, 5);
311 --
312 -- Ensure that all the mandatory arguments are not null
313 --
314 hr_api.mandatory_arg_error(p_api_name => l_proc
315 ,p_argument => 'effective_date'
316 ,p_argument_value => p_effective_date
317 );
318 --
319 hr_api.mandatory_arg_error(p_api_name => l_proc
320 ,p_argument => 'datetrack_mode'
321 ,p_argument_value => p_datetrack_mode
322 );
323 --
324 hr_api.mandatory_arg_error(p_api_name => l_proc
325 ,p_argument => 'cost_allocation_id'
326 ,p_argument_value => p_cost_allocation_id
327 );
328 --
329 hr_api.mandatory_arg_error(p_api_name => l_proc
330 ,p_argument => 'object_version_number'
331 ,p_argument_value => p_object_version_number
332 );
333 --
334 -- Check to ensure the datetrack mode is not INSERT.
335 --
336 If (p_datetrack_mode <> hr_api.g_insert) then
337 --
338 -- We must select and lock the current row.
339 --
340 Open C_Sel1;
341 Fetch C_Sel1 Into pay_cal_shd.g_old_rec;
342 If C_Sel1%notfound then
343 Close C_Sel1;
344 --
345 -- The primary key is invalid therefore we must error
346 --
347 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
348 fnd_message.raise_error;
349 End If;
350 Close C_Sel1;
351 If (p_object_version_number
352 <> pay_cal_shd.g_old_rec.object_version_number) Then
353 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
354 fnd_message.raise_error;
355 End If;
356 --
357 --
358 -- Validate the datetrack mode mode getting the validation start
359 -- and end dates for the specified datetrack operation.
360 --
361 dt_api.validate_dt_mode
362 (p_effective_date => p_effective_date
363 ,p_datetrack_mode => p_datetrack_mode
364 ,p_base_table_name => 'pay_cost_allocations_f'
365 ,p_base_key_column => 'cost_allocation_id'
366 ,p_base_key_value => p_cost_allocation_id
367 ,p_enforce_foreign_locking => true
368 ,p_validation_start_date => l_validation_start_date
369 ,p_validation_end_date => l_validation_end_date
370 );
371 Else
372 --
373 -- We are doing a datetrack 'INSERT' which is illegal within this
374 -- procedure therefore we must error (note: to lck on insert the
375 -- private procedure ins_lck should be called).
376 --
377 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
378 fnd_message.set_token('PROCEDURE', l_proc);
379 fnd_message.set_token('STEP','20');
380 fnd_message.raise_error;
381 End If;
382 --
383 -- Set the validation start and end date OUT arguments
384 --
385 p_validation_start_date := l_validation_start_date;
386 p_validation_end_date := l_validation_end_date;
387 --
388 hr_utility.set_location(' Leaving:'||l_proc, 30);
389 --
390 -- We need to trap the ORA LOCK exception
391 --
392 Exception
393 When HR_Api.Object_Locked then
394 --
395 -- The object is locked therefore we need to supply a meaningful
396 -- error message.
397 --
398 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
399 fnd_message.set_token('TABLE_NAME', 'pay_cost_allocations_f');
400 fnd_message.raise_error;
401 End lck;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |-----------------------------< convert_args >-----------------------------|
405 -- ----------------------------------------------------------------------------
406 Function convert_args
407 (p_cost_allocation_id in number
408 ,p_effective_start_date in date
409 ,p_effective_end_date in date
410 ,p_business_group_id in number
411 ,p_cost_allocation_keyflex_id in number
412 ,p_assignment_id in number
413 ,p_proportion in number
414 ,p_request_id in number
415 ,p_program_application_id in number
416 ,p_program_id in number
417 ,p_program_update_date in date
418 ,p_object_version_number in number
419 )
420 Return g_rec_type is
421 --
422 l_rec g_rec_type;
423 --
424 Begin
425 --
426 -- Convert arguments into local l_rec structure.
427 --
428 l_rec.cost_allocation_id := p_cost_allocation_id;
429 l_rec.effective_start_date := p_effective_start_date;
430 l_rec.effective_end_date := p_effective_end_date;
431 l_rec.business_group_id := p_business_group_id;
432 l_rec.cost_allocation_keyflex_id := p_cost_allocation_keyflex_id;
433 l_rec.assignment_id := p_assignment_id;
434 l_rec.proportion := p_proportion;
435 l_rec.request_id := p_request_id;
436 l_rec.program_application_id := p_program_application_id;
437 l_rec.program_id := p_program_id;
438 l_rec.program_update_date := p_program_update_date;
439 l_rec.object_version_number := p_object_version_number;
440 --
441 -- Return the plsql record structure.
442 --
443 Return(l_rec);
444 --
445 End convert_args;
446 --
447 end pay_cal_shd;