[Home] [Help]
PACKAGE BODY: APPS.BEN_AVR_SHD
Source
1 Package Body ben_avr_shd as
2 /* $Header: beavrrhi.pkb 120.0.12010000.2 2008/08/05 14:04:44 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_avr_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15 l_proc varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18 hr_utility.set_location('Entering:'||l_proc, 5);
19 --
20 Return (nvl(g_api_dml, false));
21 --
22 hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29 (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31 l_proc varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34 hr_utility.set_location('Entering:'||l_proc, 5);
35 --
36 If (p_constraint_name = 'BEN_ACTY_VRBL_RT_PK') Then
37 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38 fnd_message.set_token('PROCEDURE', l_proc);
39 fnd_message.set_token('STEP','5');
40 fnd_message.raise_error;
41 Else
42 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
43 fnd_message.set_token('PROCEDURE', l_proc);
44 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
45 fnd_message.raise_error;
46 End If;
47 --
48 hr_utility.set_location(' Leaving:'||l_proc, 10);
49 End constraint_error;
50 --
51 -- ----------------------------------------------------------------------------
52 -- |-----------------------------< api_updating >-----------------------------|
53 -- ----------------------------------------------------------------------------
54 Function api_updating
55 (p_effective_date in date,
56 p_acty_vrbl_rt_id in number,
57 p_object_version_number in number
58 ) Return Boolean Is
59 --
60 --
61 -- Cursor selects the 'current' row from the HR Schema
62 --
63 Cursor C_Sel1 is
64 select
65 acty_vrbl_rt_id,
66 effective_start_date,
67 effective_end_date,
68 acty_base_rt_id,
69 vrbl_rt_prfl_id,
70 ordr_num,
71 business_group_id,
72 avr_attribute_category,
73 avr_attribute1,
74 avr_attribute2,
75 avr_attribute3,
76 avr_attribute4,
77 avr_attribute5,
78 avr_attribute6,
79 avr_attribute7,
80 avr_attribute8,
81 avr_attribute9,
82 avr_attribute10,
83 avr_attribute11,
84 avr_attribute12,
85 avr_attribute13,
86 avr_attribute14,
87 avr_attribute15,
88 avr_attribute16,
89 avr_attribute17,
90 avr_attribute18,
91 avr_attribute19,
92 avr_attribute20,
93 avr_attribute21,
94 avr_attribute22,
95 avr_attribute23,
96 avr_attribute24,
97 avr_attribute25,
98 avr_attribute26,
99 avr_attribute27,
100 avr_attribute28,
101 avr_attribute29,
102 avr_attribute30,
103 object_version_number
104 from ben_acty_vrbl_rt_f
105 where acty_vrbl_rt_id = p_acty_vrbl_rt_id
106 and p_effective_date
107 between effective_start_date and effective_end_date;
108 --
109 l_proc varchar2(72) := g_package||'api_updating';
110 l_fct_ret boolean;
111 --
112 Begin
113 hr_utility.set_location('Entering:'||l_proc, 5);
114 --
115 If (p_effective_date is null or
116 p_acty_vrbl_rt_id is null or
117 p_object_version_number is null) Then
118 --
119 -- One of the primary key arguments is null therefore we must
120 -- set the returning function value to false
121 --
122 l_fct_ret := false;
123 Else
124 If (p_acty_vrbl_rt_id = g_old_rec.acty_vrbl_rt_id and
125 p_object_version_number = g_old_rec.object_version_number) Then
126 hr_utility.set_location(l_proc, 10);
127 --
128 -- The g_old_rec is current therefore we must
129 -- set the returning function to true
130 --
131 l_fct_ret := true;
132 Else
133 --
134 -- Select the current row
135 --
136 Open C_Sel1;
137 Fetch C_Sel1 Into g_old_rec;
138 If C_Sel1%notfound Then
139 Close C_Sel1;
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
144 fnd_message.raise_error;
145 End If;
146 Close C_Sel1;
147 If (p_object_version_number <> g_old_rec.object_version_number) Then
148 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
149 fnd_message.raise_error;
150 End If;
151 hr_utility.set_location(l_proc, 15);
152 l_fct_ret := true;
153 End If;
154 End If;
155 hr_utility.set_location(' Leaving:'||l_proc, 20);
156 Return (l_fct_ret);
157 --
158 End api_updating;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |--------------------------< find_dt_del_modes >---------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure find_dt_del_modes
164 (p_effective_date in date,
165 p_base_key_value in number,
166 p_zap out nocopy boolean,
167 p_delete out nocopy boolean,
168 p_future_change out nocopy boolean,
169 p_delete_next_change out nocopy boolean) is
170 --
171 l_proc varchar2(72) := g_package||'find_dt_del_modes';
172 --
173 l_parent_key_value1 number;
174 l_parent_key_value2 number;
175 l_parent_key_value3 number;
176 --
177 Cursor C_Sel1 Is
178 select t.acty_base_rt_id,
179 t.vrbl_rt_prfl_id
180 from ben_acty_vrbl_rt_f t
181 where t.acty_vrbl_rt_id = p_base_key_value
182 and p_effective_date
183 between t.effective_start_date and t.effective_end_date;
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 Open C_Sel1;
188 Fetch C_Sel1 Into l_parent_key_value1,
189 l_parent_key_value2;
190 If C_Sel1%notfound then
191 Close C_Sel1;
192 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
193 fnd_message.set_token('PROCEDURE', l_proc);
194 fnd_message.set_token('STEP','10');
195 fnd_message.raise_error;
196 End If;
197 Close C_Sel1;
198 --
199 -- Call the corresponding datetrack api
200 --
201 dt_api.find_dt_del_modes
202 (p_effective_date => p_effective_date,
203 p_base_table_name => 'ben_acty_vrbl_rt_f',
204 p_base_key_column => 'acty_vrbl_rt_id',
205 p_base_key_value => p_base_key_value,
206 p_parent_table_name1 => 'ben_acty_base_rt_f',
207 p_parent_key_column1 => 'acty_base_rt_id',
208 p_parent_key_value1 => l_parent_key_value1,
209 p_parent_table_name2 => 'ben_vrbl_rt_prfl_f',
210 p_parent_key_column2 => 'vrbl_rt_prfl_id',
211 p_parent_key_value2 => l_parent_key_value2,
212 p_zap => p_zap,
213 p_delete => p_delete,
214 p_future_change => p_future_change,
215 p_delete_next_change => p_delete_next_change);
216 --
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End find_dt_del_modes;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |--------------------------< find_dt_upd_modes >---------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure find_dt_upd_modes
224 (p_effective_date in date,
225 p_base_key_value in number,
226 p_correction out nocopy boolean,
227 p_update out nocopy boolean,
228 p_update_override out nocopy boolean,
229 p_update_change_insert out nocopy boolean) is
230 --
231 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
232 --
233 Begin
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 --
236 -- Call the corresponding datetrack api
237 --
238 dt_api.find_dt_upd_modes
239 (p_effective_date => p_effective_date,
240 p_base_table_name => 'ben_acty_vrbl_rt_f',
241 p_base_key_column => 'acty_vrbl_rt_id',
242 p_base_key_value => p_base_key_value,
243 p_correction => p_correction,
244 p_update => p_update,
245 p_update_override => p_update_override,
246 p_update_change_insert => p_update_change_insert);
247 --
248 hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End find_dt_upd_modes;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |------------------------< upd_effective_end_date >------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure upd_effective_end_date
255 (p_effective_date in date,
256 p_base_key_value in number,
257 p_new_effective_end_date in date,
258 p_validation_start_date in date,
259 p_validation_end_date in date,
260 p_object_version_number out nocopy number) is
261 --
262 l_proc varchar2(72) := g_package||'upd_effective_end_date';
263 l_object_version_number number;
264 --
265 Begin
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 -- Because we are updating a row we must get the next object
269 -- version number.
270 --
271 l_object_version_number :=
272 dt_api.get_object_version_number
273 (p_base_table_name => 'ben_acty_vrbl_rt_f',
274 p_base_key_column => 'acty_vrbl_rt_id',
275 p_base_key_value => p_base_key_value);
276 --
277 hr_utility.set_location(l_proc, 10);
278 g_api_dml := true; -- Set the api dml status
279 --
280 -- Update the specified datetrack row setting the effective
281 -- end date to the specified new effective end date.
282 --
283 update ben_acty_vrbl_rt_f t
284 set t.effective_end_date = p_new_effective_end_date,
285 t.object_version_number = l_object_version_number
286 where t.acty_vrbl_rt_id = p_base_key_value
287 and p_effective_date
288 between t.effective_start_date and t.effective_end_date;
289 --
290 g_api_dml := false; -- Unset the api dml status
291 p_object_version_number := l_object_version_number;
292 hr_utility.set_location(' Leaving:'||l_proc, 15);
293 --
294 Exception
295 When Others Then
296 g_api_dml := false; -- Unset the api dml status
297 Raise;
298 End upd_effective_end_date;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< lck >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure lck
304 (p_effective_date in date,
305 p_datetrack_mode in varchar2,
306 p_acty_vrbl_rt_id in number,
307 p_object_version_number in number,
308 p_validation_start_date out nocopy date,
309 p_validation_end_date out nocopy date) is
310 --
311 l_proc varchar2(72) := g_package||'lck';
312 l_validation_start_date date;
313 l_validation_end_date date;
314 l_object_invalid exception;
315 l_argument varchar2(30);
316 --
317 -- Cursor C_Sel1 selects the current locked row as of session date
318 -- ensuring that the object version numbers match.
319 --
320 Cursor C_Sel1 is
321 select
322 acty_vrbl_rt_id,
323 effective_start_date,
324 effective_end_date,
325 acty_base_rt_id,
326 vrbl_rt_prfl_id,
327 ordr_num,
328 business_group_id,
329 avr_attribute_category,
330 avr_attribute1,
331 avr_attribute2,
332 avr_attribute3,
333 avr_attribute4,
334 avr_attribute5,
335 avr_attribute6,
336 avr_attribute7,
337 avr_attribute8,
338 avr_attribute9,
339 avr_attribute10,
340 avr_attribute11,
341 avr_attribute12,
342 avr_attribute13,
343 avr_attribute14,
344 avr_attribute15,
345 avr_attribute16,
346 avr_attribute17,
347 avr_attribute18,
348 avr_attribute19,
349 avr_attribute20,
350 avr_attribute21,
351 avr_attribute22,
352 avr_attribute23,
353 avr_attribute24,
354 avr_attribute25,
355 avr_attribute26,
356 avr_attribute27,
357 avr_attribute28,
358 avr_attribute29,
359 avr_attribute30,
360 object_version_number
361 from ben_acty_vrbl_rt_f
362 where acty_vrbl_rt_id = p_acty_vrbl_rt_id
363 and p_effective_date
364 between effective_start_date and effective_end_date
365 for update nowait;
366 --
367 --
368 --
369 Begin
370 hr_utility.set_location('Entering:'||l_proc, 5);
371 --
372 -- Ensure that all the mandatory arguments are not null
373 --
374 hr_api.mandatory_arg_error(p_api_name => l_proc,
375 p_argument => 'effective_date',
376 p_argument_value => p_effective_date);
377 --
378 hr_api.mandatory_arg_error(p_api_name => l_proc,
379 p_argument => 'datetrack_mode',
380 p_argument_value => p_datetrack_mode);
381 --
382 hr_api.mandatory_arg_error(p_api_name => l_proc,
383 p_argument => 'acty_vrbl_rt_id',
384 p_argument_value => p_acty_vrbl_rt_id);
385 --
386 hr_api.mandatory_arg_error(p_api_name => l_proc,
387 p_argument => 'object_version_number',
388 p_argument_value => p_object_version_number);
389 --
390 -- Check to ensure the datetrack mode is not INSERT.
391 --
392 If (p_datetrack_mode <> 'INSERT') then
393 --
394 -- We must select and lock the current row.
395 --
396 Open C_Sel1;
397 Fetch C_Sel1 Into g_old_rec;
398 If C_Sel1%notfound then
399 Close C_Sel1;
400 --
401 -- The primary key is invalid therefore we must error
402 --
403 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
404 fnd_message.raise_error;
405 End If;
406 Close C_Sel1;
407 If (p_object_version_number <> g_old_rec.object_version_number) Then
408 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
409 fnd_message.raise_error;
410 End If;
411 hr_utility.set_location(l_proc, 15);
412 --
413 --
414 -- Validate the datetrack mode mode getting the validation start
415 -- and end dates for the specified datetrack operation.
416 --
417 dt_api.validate_dt_mode
418 (p_effective_date => p_effective_date,
419 p_datetrack_mode => p_datetrack_mode,
420 p_base_table_name => 'ben_acty_vrbl_rt_f',
421 p_base_key_column => 'acty_vrbl_rt_id',
425 p_parent_key_value1 => g_old_rec.acty_base_rt_id,
422 p_base_key_value => p_acty_vrbl_rt_id,
423 p_parent_table_name1 => 'ben_acty_base_rt_f',
424 p_parent_key_column1 => 'acty_base_rt_id',
426 p_parent_table_name2 => 'ben_vrbl_rt_prfl_f',
427 p_parent_key_column2 => 'vrbl_rt_prfl_id',
428 p_parent_key_value2 => g_old_rec.vrbl_rt_prfl_id,
429 p_enforce_foreign_locking => false, --true,
430 p_validation_start_date => l_validation_start_date,
431 p_validation_end_date => l_validation_end_date);
432 Else
433 --
434 -- We are doing a datetrack 'INSERT' which is illegal within this
435 -- procedure therefore we must error (note: to lck on insert the
436 -- private procedure ins_lck should be called).
437 --
438 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
439 fnd_message.set_token('PROCEDURE', l_proc);
440 fnd_message.set_token('STEP','20');
441 fnd_message.raise_error;
442 End If;
443 --
444 -- Set the validation start and end date OUT arguments
445 --
446 p_validation_start_date := l_validation_start_date;
447 p_validation_end_date := l_validation_end_date;
448 --
449 hr_utility.set_location(' Leaving:'||l_proc, 30);
450 --
451 -- We need to trap the ORA LOCK exception
452 --
453 Exception
454 When HR_Api.Object_Locked then
455 --
456 -- The object is locked therefore we need to supply a meaningful
457 -- error message.
458 --
459 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
460 fnd_message.set_token('TABLE_NAME', 'ben_acty_vrbl_rt_f');
461 fnd_message.raise_error;
462 When l_object_invalid then
463 --
464 -- The object doesn't exist or is invalid
465 --
466 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
467 fnd_message.set_token('TABLE_NAME', 'ben_acty_vrbl_rt_f');
468 fnd_message.raise_error;
469 End lck;
470 --
471 -- ----------------------------------------------------------------------------
472 -- |-----------------------------< convert_args >-----------------------------|
473 -- ----------------------------------------------------------------------------
474 Function convert_args
475 (
476 p_acty_vrbl_rt_id in number,
477 p_effective_start_date in date,
478 p_effective_end_date in date,
479 p_acty_base_rt_id in number,
480 p_vrbl_rt_prfl_id in number,
481 p_ordr_num in number,
482 p_business_group_id in number,
483 p_avr_attribute_category in varchar2,
484 p_avr_attribute1 in varchar2,
485 p_avr_attribute2 in varchar2,
486 p_avr_attribute3 in varchar2,
487 p_avr_attribute4 in varchar2,
488 p_avr_attribute5 in varchar2,
489 p_avr_attribute6 in varchar2,
490 p_avr_attribute7 in varchar2,
491 p_avr_attribute8 in varchar2,
492 p_avr_attribute9 in varchar2,
493 p_avr_attribute10 in varchar2,
494 p_avr_attribute11 in varchar2,
495 p_avr_attribute12 in varchar2,
496 p_avr_attribute13 in varchar2,
497 p_avr_attribute14 in varchar2,
498 p_avr_attribute15 in varchar2,
499 p_avr_attribute16 in varchar2,
500 p_avr_attribute17 in varchar2,
501 p_avr_attribute18 in varchar2,
502 p_avr_attribute19 in varchar2,
503 p_avr_attribute20 in varchar2,
504 p_avr_attribute21 in varchar2,
505 p_avr_attribute22 in varchar2,
506 p_avr_attribute23 in varchar2,
507 p_avr_attribute24 in varchar2,
508 p_avr_attribute25 in varchar2,
509 p_avr_attribute26 in varchar2,
510 p_avr_attribute27 in varchar2,
511 p_avr_attribute28 in varchar2,
512 p_avr_attribute29 in varchar2,
513 p_avr_attribute30 in varchar2,
514 p_object_version_number in number
515 )
516 Return g_rec_type is
517 --
518 l_rec g_rec_type;
519 l_proc varchar2(72) := g_package||'convert_args';
520 --
521 Begin
522 --
523 hr_utility.set_location('Entering:'||l_proc, 5);
524 --
525 -- Convert arguments into local l_rec structure.
526 --
527 l_rec.acty_vrbl_rt_id := p_acty_vrbl_rt_id;
528 l_rec.effective_start_date := p_effective_start_date;
529 l_rec.effective_end_date := p_effective_end_date;
530 l_rec.acty_base_rt_id := p_acty_base_rt_id;
531 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
532 l_rec.ordr_num := p_ordr_num;
533 l_rec.business_group_id := p_business_group_id;
534 l_rec.avr_attribute_category := p_avr_attribute_category;
535 l_rec.avr_attribute1 := p_avr_attribute1;
536 l_rec.avr_attribute2 := p_avr_attribute2;
537 l_rec.avr_attribute3 := p_avr_attribute3;
538 l_rec.avr_attribute4 := p_avr_attribute4;
539 l_rec.avr_attribute5 := p_avr_attribute5;
540 l_rec.avr_attribute6 := p_avr_attribute6;
541 l_rec.avr_attribute7 := p_avr_attribute7;
542 l_rec.avr_attribute8 := p_avr_attribute8;
543 l_rec.avr_attribute9 := p_avr_attribute9;
544 l_rec.avr_attribute10 := p_avr_attribute10;
545 l_rec.avr_attribute11 := p_avr_attribute11;
546 l_rec.avr_attribute12 := p_avr_attribute12;
547 l_rec.avr_attribute13 := p_avr_attribute13;
548 l_rec.avr_attribute14 := p_avr_attribute14;
549 l_rec.avr_attribute15 := p_avr_attribute15;
550 l_rec.avr_attribute16 := p_avr_attribute16;
551 l_rec.avr_attribute17 := p_avr_attribute17;
552 l_rec.avr_attribute18 := p_avr_attribute18;
553 l_rec.avr_attribute19 := p_avr_attribute19;
554 l_rec.avr_attribute20 := p_avr_attribute20;
555 l_rec.avr_attribute21 := p_avr_attribute21;
556 l_rec.avr_attribute22 := p_avr_attribute22;
557 l_rec.avr_attribute23 := p_avr_attribute23;
558 l_rec.avr_attribute24 := p_avr_attribute24;
559 l_rec.avr_attribute25 := p_avr_attribute25;
560 l_rec.avr_attribute26 := p_avr_attribute26;
561 l_rec.avr_attribute27 := p_avr_attribute27;
562 l_rec.avr_attribute28 := p_avr_attribute28;
563 l_rec.avr_attribute29 := p_avr_attribute29;
564 l_rec.avr_attribute30 := p_avr_attribute30;
565 l_rec.object_version_number := p_object_version_number;
566 --
567 -- Return the plsql record structure.
568 --
569 hr_utility.set_location(' Leaving:'||l_proc, 10);
570 Return(l_rec);
571 --
572 End convert_args;
573 --
574 end ben_avr_shd;