[Home] [Help]
PACKAGE BODY: APPS.BEN_VRR_SHD
Source
1 Package Body ben_vrr_shd as
2 /* $Header: bevrrrhi.pkb 120.0.12010000.2 2008/08/05 15:46:13 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_vrr_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_VARBL_RT_RL_FK1') 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 ElsIf (p_constraint_name = 'BEN_VARBL_RT_RL_PK') Then
42 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43 fnd_message.set_token('PROCEDURE', l_proc);
44 fnd_message.set_token('STEP','10');
45 fnd_message.raise_error;
46 Else
47 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48 fnd_message.set_token('PROCEDURE', l_proc);
49 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50 fnd_message.raise_error;
51 End If;
52 --
53 hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60 (p_effective_date in date,
61 p_vrbl_rt_rl_id in number,
62 p_object_version_number in number
63 ) Return Boolean Is
64 --
65 --
66 -- Cursor selects the 'current' row from the HR Schema
67 --
68 Cursor C_Sel1 is
69 select
70 vrbl_rt_rl_id,
71 effective_start_date,
72 effective_end_date,
73 drvbl_fctr_apls_flag,
74 rt_trtmt_cd,
75 business_group_id,
76 formula_id,
77 acty_base_rt_id,
78 ordr_to_aply_num,
79 vrr_attribute_category,
80 vrr_attribute1,
81 vrr_attribute2,
82 vrr_attribute3,
83 vrr_attribute4,
84 vrr_attribute5,
85 vrr_attribute6,
86 vrr_attribute7,
87 vrr_attribute8,
88 vrr_attribute9,
89 vrr_attribute10,
90 vrr_attribute11,
91 vrr_attribute12,
92 vrr_attribute13,
93 vrr_attribute14,
94 vrr_attribute15,
95 vrr_attribute16,
96 vrr_attribute17,
97 vrr_attribute18,
98 vrr_attribute19,
99 vrr_attribute20,
100 vrr_attribute21,
101 vrr_attribute22,
102 vrr_attribute23,
103 vrr_attribute24,
104 vrr_attribute25,
105 vrr_attribute26,
106 vrr_attribute27,
107 vrr_attribute28,
108 vrr_attribute29,
109 vrr_attribute30,
110 object_version_number
111 from ben_vrbl_rt_rl_f
112 where vrbl_rt_rl_id = p_vrbl_rt_rl_id
113 and p_effective_date
114 between effective_start_date and effective_end_date;
115 --
116 l_proc varchar2(72) := g_package||'api_updating';
117 l_fct_ret boolean;
118 --
119 Begin
120 hr_utility.set_location('Entering:'||l_proc, 5);
121 --
122 If (p_effective_date is null or
123 p_vrbl_rt_rl_id is null or
124 p_object_version_number is null) Then
125 --
126 -- One of the primary key arguments is null therefore we must
127 -- set the returning function value to false
128 --
129 l_fct_ret := false;
130 Else
131 If (p_vrbl_rt_rl_id = g_old_rec.vrbl_rt_rl_id and
132 p_object_version_number = g_old_rec.object_version_number) Then
133 hr_utility.set_location(l_proc, 10);
134 --
135 -- The g_old_rec is current therefore we must
136 -- set the returning function to true
137 --
138 l_fct_ret := true;
139 Else
140 --
141 -- Select the current row
142 --
143 Open C_Sel1;
144 Fetch C_Sel1 Into g_old_rec;
145 If C_Sel1%notfound Then
146 Close C_Sel1;
147 --
148 -- The primary key is invalid therefore we must error
149 --
150 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
151 fnd_message.raise_error;
152 End If;
153 Close C_Sel1;
154 If (p_object_version_number <> g_old_rec.object_version_number) Then
155 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
156 fnd_message.raise_error;
157 End If;
158 hr_utility.set_location(l_proc, 15);
159 l_fct_ret := true;
160 End If;
161 End If;
162 hr_utility.set_location(' Leaving:'||l_proc, 20);
163 Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |--------------------------< find_dt_del_modes >---------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 (p_effective_date in date,
172 p_base_key_value in number,
173 p_zap out nocopy boolean,
174 p_delete out nocopy boolean,
175 p_future_change out nocopy boolean,
176 p_delete_next_change out nocopy boolean) is
177 --
178 l_proc varchar2(72) := g_package||'find_dt_del_modes';
179 --
180 l_parent_key_value1 number;
181 l_parent_key_value2 number;
182 --
183 Cursor C_Sel1 Is
184 select
185 t.acty_base_rt_id
186 from ben_vrbl_rt_rl_f t
187 where t.vrbl_rt_rl_id = p_base_key_value
188 and p_effective_date
189 between t.effective_start_date and t.effective_end_date;
190 --
191 Begin
192 hr_utility.set_location('Entering:'||l_proc, 5);
193 Open C_Sel1;
194 Fetch C_Sel1 Into
195 l_parent_key_value2;
196 If C_Sel1%notfound then
197 Close C_Sel1;
198 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
199 fnd_message.set_token('PROCEDURE', l_proc);
200 fnd_message.set_token('STEP','10');
201 fnd_message.raise_error;
202 End If;
203 Close C_Sel1;
204 --
205 -- Call the corresponding datetrack api
206 --
207 dt_api.find_dt_del_modes
208 (p_effective_date => p_effective_date,
209 p_base_table_name => 'ben_vrbl_rt_rl_f',
210 p_base_key_column => 'vrbl_rt_rl_id',
211 p_base_key_value => p_base_key_value,
212 p_parent_table_name1 => 'ben_actl_prem_f',
213 --p_parent_key_column1 => 'actl_prem_id',
214 p_parent_key_value1 => l_parent_key_value1,
215 p_parent_table_name2 => 'ben_acty_base_rt_f',
216 p_parent_key_column2 => 'acty_base_rt_id',
217 p_parent_key_value2 => l_parent_key_value2,
218 p_zap => p_zap,
219 p_delete => p_delete,
220 p_future_change => p_future_change,
221 p_delete_next_change => p_delete_next_change);
222 --
223 hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End find_dt_del_modes;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |--------------------------< find_dt_upd_modes >---------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure find_dt_upd_modes
230 (p_effective_date in date,
231 p_base_key_value in number,
232 p_correction out nocopy boolean,
233 p_update out nocopy boolean,
234 p_update_override out nocopy boolean,
235 p_update_change_insert out nocopy boolean) is
236 --
237 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
238 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242 -- Call the corresponding datetrack api
243 --
244 dt_api.find_dt_upd_modes
245 (p_effective_date => p_effective_date,
246 p_base_table_name => 'ben_vrbl_rt_rl_f',
247 p_base_key_column => 'vrbl_rt_rl_id',
248 p_base_key_value => p_base_key_value,
249 p_correction => p_correction,
250 p_update => p_update,
251 p_update_override => p_update_override,
252 p_update_change_insert => p_update_change_insert);
253 --
254 hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End find_dt_upd_modes;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |------------------------< upd_effective_end_date >------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure upd_effective_end_date
261 (p_effective_date in date,
262 p_base_key_value in number,
263 p_new_effective_end_date in date,
264 p_validation_start_date in date,
265 p_validation_end_date in date,
266 p_object_version_number out nocopy number) is
267 --
268 l_proc varchar2(72) := g_package||'upd_effective_end_date';
269 l_object_version_number number;
270 --
271 Begin
272 hr_utility.set_location('Entering:'||l_proc, 5);
273 --
274 -- Because we are updating a row we must get the next object
275 -- version number.
276 --
277 l_object_version_number :=
278 dt_api.get_object_version_number
279 (p_base_table_name => 'ben_vrbl_rt_rl_f',
280 p_base_key_column => 'vrbl_rt_rl_id',
281 p_base_key_value => p_base_key_value);
282 --
283 hr_utility.set_location(l_proc, 10);
284 g_api_dml := true; -- Set the api dml status
285 --
286 -- Update the specified datetrack row setting the effective
287 -- end date to the specified new effective end date.
288 --
289 update ben_vrbl_rt_rl_f t
290 set t.effective_end_date = p_new_effective_end_date,
291 t.object_version_number = l_object_version_number
292 where t.vrbl_rt_rl_id = p_base_key_value
293 and p_effective_date
294 between t.effective_start_date and t.effective_end_date;
295 --
296 g_api_dml := false; -- Unset the api dml status
297 p_object_version_number := l_object_version_number;
298 hr_utility.set_location(' Leaving:'||l_proc, 15);
299 --
300 Exception
301 When Others Then
302 g_api_dml := false; -- Unset the api dml status
303 Raise;
304 End upd_effective_end_date;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< lck >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure lck
310 (p_effective_date in date,
311 p_datetrack_mode in varchar2,
312 p_vrbl_rt_rl_id in number,
313 p_object_version_number in number,
314 p_validation_start_date out nocopy date,
315 p_validation_end_date out nocopy date) is
316 --
317 l_proc varchar2(72) := g_package||'lck';
318 l_validation_start_date date;
319 l_validation_end_date date;
320 l_object_invalid exception;
321 l_argument varchar2(30);
322 --
323 -- Cursor C_Sel1 selects the current locked row as of session date
324 -- ensuring that the object version numbers match.
325 --
326 Cursor C_Sel1 is
327 select
328 vrbl_rt_rl_id,
329 effective_start_date,
330 effective_end_date,
331 drvbl_fctr_apls_flag,
332 rt_trtmt_cd,
333 business_group_id,
334 formula_id,
335 acty_base_rt_id,
336 ordr_to_aply_num,
337 vrr_attribute_category,
338 vrr_attribute1,
339 vrr_attribute2,
340 vrr_attribute3,
341 vrr_attribute4,
342 vrr_attribute5,
343 vrr_attribute6,
344 vrr_attribute7,
345 vrr_attribute8,
346 vrr_attribute9,
347 vrr_attribute10,
348 vrr_attribute11,
349 vrr_attribute12,
350 vrr_attribute13,
351 vrr_attribute14,
352 vrr_attribute15,
353 vrr_attribute16,
354 vrr_attribute17,
355 vrr_attribute18,
356 vrr_attribute19,
357 vrr_attribute20,
358 vrr_attribute21,
359 vrr_attribute22,
360 vrr_attribute23,
361 vrr_attribute24,
362 vrr_attribute25,
363 vrr_attribute26,
364 vrr_attribute27,
365 vrr_attribute28,
366 vrr_attribute29,
367 vrr_attribute30,
368 object_version_number
369 from ben_vrbl_rt_rl_f
370 where vrbl_rt_rl_id = p_vrbl_rt_rl_id
371 and p_effective_date
372 between effective_start_date and effective_end_date
373 for update nowait;
374 --
375 --
376 --
377 Begin
378 hr_utility.set_location('Entering:'||l_proc, 5);
379 --
380 -- Ensure that all the mandatory arguments are not null
381 --
382 hr_api.mandatory_arg_error(p_api_name => l_proc,
383 p_argument => 'effective_date',
384 p_argument_value => p_effective_date);
385 --
386 hr_api.mandatory_arg_error(p_api_name => l_proc,
387 p_argument => 'datetrack_mode',
388 p_argument_value => p_datetrack_mode);
389 --
390 hr_api.mandatory_arg_error(p_api_name => l_proc,
391 p_argument => 'vrbl_rt_rl_id',
392 p_argument_value => p_vrbl_rt_rl_id);
393 --
394 hr_api.mandatory_arg_error(p_api_name => l_proc,
395 p_argument => 'object_version_number',
396 p_argument_value => p_object_version_number);
397 --
398 -- Check to ensure the datetrack mode is not INSERT.
399 --
400 If (p_datetrack_mode <> 'INSERT') then
404 Open C_Sel1;
401 --
402 -- We must select and lock the current row.
403 --
405 Fetch C_Sel1 Into g_old_rec;
406 If C_Sel1%notfound then
407 Close C_Sel1;
408 --
409 -- The primary key is invalid therefore we must error
410 --
411 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
412 fnd_message.raise_error;
413 End If;
414 Close C_Sel1;
415 If (p_object_version_number <> g_old_rec.object_version_number) Then
416 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
417 fnd_message.raise_error;
418 End If;
419 hr_utility.set_location(l_proc, 15);
420 --
421 --
422 -- Validate the datetrack mode mode getting the validation start
423 -- and end dates for the specified datetrack operation.
424 --
425 dt_api.validate_dt_mode
426 (p_effective_date => p_effective_date,
427 p_datetrack_mode => p_datetrack_mode,
428 p_base_table_name => 'ben_vrbl_rt_rl_f',
429 p_base_key_column => 'vrbl_rt_rl_id',
430 p_base_key_value => p_vrbl_rt_rl_id,
431 p_parent_table_name1 => 'ben_actl_prem_f',
432 --p_parent_key_column1 => 'actl_prem_id',
433 -- p_parent_key_value1 => g_old_rec.actl_prem_id,
434 p_parent_table_name2 => 'ben_acty_base_rt_f',
435 p_parent_key_column2 => 'acty_base_rt_id',
436 p_parent_key_value2 => g_old_rec.acty_base_rt_id,
437 p_enforce_foreign_locking => false , --true,
438 p_validation_start_date => l_validation_start_date,
439 p_validation_end_date => l_validation_end_date);
440 Else
441 --
442 -- We are doing a datetrack 'INSERT' which is illegal within this
443 -- procedure therefore we must error (note: to lck on insert the
444 -- private procedure ins_lck should be called).
445 --
446 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
447 fnd_message.set_token('PROCEDURE', l_proc);
448 fnd_message.set_token('STEP','20');
449 fnd_message.raise_error;
450 End If;
451 --
452 -- Set the validation start and end date OUT arguments
453 --
454 p_validation_start_date := l_validation_start_date;
455 p_validation_end_date := l_validation_end_date;
456 --
457 hr_utility.set_location(' Leaving:'||l_proc, 30);
458 --
459 -- We need to trap the ORA LOCK exception
460 --
461 Exception
462 When HR_Api.Object_Locked then
463 --
464 -- The object is locked therefore we need to supply a meaningful
465 -- error message.
466 --
467 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
468 fnd_message.set_token('TABLE_NAME', 'ben_vrbl_rt_rl_f');
469 fnd_message.raise_error;
470 When l_object_invalid then
471 --
472 -- The object doesn't exist or is invalid
473 --
474 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
475 fnd_message.set_token('TABLE_NAME', 'ben_vrbl_rt_rl_f');
476 fnd_message.raise_error;
477 End lck;
478 --
479 -- ----------------------------------------------------------------------------
480 -- |-----------------------------< convert_args >-----------------------------|
481 -- ----------------------------------------------------------------------------
482 Function convert_args
483 (
484 p_vrbl_rt_rl_id in number,
485 p_effective_start_date in date,
486 p_effective_end_date in date,
487 p_drvbl_fctr_apls_flag in varchar2,
488 p_rt_trtmt_cd in varchar2,
489 p_business_group_id in number,
490 p_formula_id in number,
491 p_acty_base_rt_id in number,
492 p_ordr_to_aply_num in number,
493 p_vrr_attribute_category in varchar2,
494 p_vrr_attribute1 in varchar2,
495 p_vrr_attribute2 in varchar2,
496 p_vrr_attribute3 in varchar2,
497 p_vrr_attribute4 in varchar2,
498 p_vrr_attribute5 in varchar2,
499 p_vrr_attribute6 in varchar2,
500 p_vrr_attribute7 in varchar2,
501 p_vrr_attribute8 in varchar2,
502 p_vrr_attribute9 in varchar2,
503 p_vrr_attribute10 in varchar2,
504 p_vrr_attribute11 in varchar2,
505 p_vrr_attribute12 in varchar2,
506 p_vrr_attribute13 in varchar2,
507 p_vrr_attribute14 in varchar2,
508 p_vrr_attribute15 in varchar2,
509 p_vrr_attribute16 in varchar2,
510 p_vrr_attribute17 in varchar2,
511 p_vrr_attribute18 in varchar2,
512 p_vrr_attribute19 in varchar2,
513 p_vrr_attribute20 in varchar2,
514 p_vrr_attribute21 in varchar2,
515 p_vrr_attribute22 in varchar2,
516 p_vrr_attribute23 in varchar2,
517 p_vrr_attribute24 in varchar2,
518 p_vrr_attribute25 in varchar2,
519 p_vrr_attribute26 in varchar2,
520 p_vrr_attribute27 in varchar2,
521 p_vrr_attribute28 in varchar2,
522 p_vrr_attribute29 in varchar2,
523 p_vrr_attribute30 in varchar2,
524 p_object_version_number in number
525 )
526 Return g_rec_type is
527 --
528 l_rec g_rec_type;
529 l_proc varchar2(72) := g_package||'convert_args';
530 --
531 Begin
532 --
533 hr_utility.set_location('Entering:'||l_proc, 5);
534 --
535 -- Convert arguments into local l_rec structure.
536 --
537 l_rec.vrbl_rt_rl_id := p_vrbl_rt_rl_id;
538 l_rec.effective_start_date := p_effective_start_date;
539 l_rec.effective_end_date := p_effective_end_date;
540 l_rec.drvbl_fctr_apls_flag := p_drvbl_fctr_apls_flag;
541 l_rec.rt_trtmt_cd := p_rt_trtmt_cd;
542 l_rec.business_group_id := p_business_group_id;
543 l_rec.formula_id := p_formula_id;
544 l_rec.acty_base_rt_id := p_acty_base_rt_id;
545 l_rec.ordr_to_aply_num := p_ordr_to_aply_num;
546 l_rec.vrr_attribute_category := p_vrr_attribute_category;
547 l_rec.vrr_attribute1 := p_vrr_attribute1;
548 l_rec.vrr_attribute2 := p_vrr_attribute2;
549 l_rec.vrr_attribute3 := p_vrr_attribute3;
550 l_rec.vrr_attribute4 := p_vrr_attribute4;
551 l_rec.vrr_attribute5 := p_vrr_attribute5;
552 l_rec.vrr_attribute6 := p_vrr_attribute6;
553 l_rec.vrr_attribute7 := p_vrr_attribute7;
554 l_rec.vrr_attribute8 := p_vrr_attribute8;
555 l_rec.vrr_attribute9 := p_vrr_attribute9;
556 l_rec.vrr_attribute10 := p_vrr_attribute10;
557 l_rec.vrr_attribute11 := p_vrr_attribute11;
558 l_rec.vrr_attribute12 := p_vrr_attribute12;
559 l_rec.vrr_attribute13 := p_vrr_attribute13;
560 l_rec.vrr_attribute14 := p_vrr_attribute14;
561 l_rec.vrr_attribute15 := p_vrr_attribute15;
562 l_rec.vrr_attribute16 := p_vrr_attribute16;
563 l_rec.vrr_attribute17 := p_vrr_attribute17;
564 l_rec.vrr_attribute18 := p_vrr_attribute18;
565 l_rec.vrr_attribute19 := p_vrr_attribute19;
566 l_rec.vrr_attribute20 := p_vrr_attribute20;
567 l_rec.vrr_attribute21 := p_vrr_attribute21;
568 l_rec.vrr_attribute22 := p_vrr_attribute22;
569 l_rec.vrr_attribute23 := p_vrr_attribute23;
570 l_rec.vrr_attribute24 := p_vrr_attribute24;
571 l_rec.vrr_attribute25 := p_vrr_attribute25;
572 l_rec.vrr_attribute26 := p_vrr_attribute26;
573 l_rec.vrr_attribute27 := p_vrr_attribute27;
574 l_rec.vrr_attribute28 := p_vrr_attribute28;
575 l_rec.vrr_attribute29 := p_vrr_attribute29;
576 l_rec.vrr_attribute30 := p_vrr_attribute30;
577 l_rec.object_version_number := p_object_version_number;
578 --
579 -- Return the plsql record structure.
580 --
581 hr_utility.set_location(' Leaving:'||l_proc, 10);
582 Return(l_rec);
583 --
584 End convert_args;
585 --
586 end ben_vrr_shd;