[Home] [Help]
PACKAGE BODY: APPS.BEN_VMR_SHD
Source
1 Package Body ben_vmr_shd as
2 /* $Header: bevmrrhi.pkb 120.0.12010000.2 2008/08/05 15:37:25 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_vmr_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_VRBL_MTCHG_RT_PK') Then
37 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38 hr_utility.set_message_token('PROCEDURE', l_proc);
39 hr_utility.set_message_token('STEP','5');
40 hr_utility.raise_error;
41 Else
42 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
43 hr_utility.set_message_token('PROCEDURE', l_proc);
44 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
45 hr_utility.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_vrbl_mtchg_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 vrbl_mtchg_rt_id,
66 effective_end_date,
67 effective_start_date,
68 no_mx_pct_of_py_num_flag,
69 to_pct_val,
70 no_mx_amt_of_py_num_flag,
71 mx_pct_of_py_num,
72 no_mx_mtch_amt_flag,
73 ordr_num,
74 pct_val,
75 mx_mtch_amt,
76 mx_amt_of_py_num,
77 mn_mtch_amt,
78 mtchg_rt_calc_rl,
79 cntnu_mtch_aftr_max_rl_flag,
80 from_pct_val,
81 vrbl_rt_prfl_id,
82 business_group_id,
83 vmr_attribute_category,
84 vmr_attribute1,
85 vmr_attribute2,
86 vmr_attribute3,
87 vmr_attribute4,
88 vmr_attribute5,
89 vmr_attribute6,
90 vmr_attribute7,
91 vmr_attribute8,
92 vmr_attribute9,
93 vmr_attribute10,
94 vmr_attribute11,
95 vmr_attribute12,
96 vmr_attribute13,
97 vmr_attribute14,
98 vmr_attribute15,
99 vmr_attribute16,
100 vmr_attribute17,
101 vmr_attribute18,
102 vmr_attribute19,
103 vmr_attribute20,
104 vmr_attribute21,
105 vmr_attribute22,
106 vmr_attribute23,
107 vmr_attribute24,
108 vmr_attribute25,
109 vmr_attribute26,
110 vmr_attribute27,
111 vmr_attribute28,
112 vmr_attribute29,
113 vmr_attribute30,
114 object_version_number
115 from ben_vrbl_mtchg_rt_f
116 where vrbl_mtchg_rt_id = p_vrbl_mtchg_rt_id
117 and p_effective_date
118 between effective_start_date and effective_end_date;
119 --
120 l_proc varchar2(72) := g_package||'api_updating';
121 l_fct_ret boolean;
122 --
123 Begin
124 hr_utility.set_location('Entering:'||l_proc, 5);
125 --
126 If (p_effective_date is null or
127 p_vrbl_mtchg_rt_id is null or
128 p_object_version_number is null) Then
129 --
130 -- One of the primary key arguments is null therefore we must
131 -- set the returning function value to false
132 --
133 l_fct_ret := false;
134 Else
135 If (p_vrbl_mtchg_rt_id = g_old_rec.vrbl_mtchg_rt_id and
136 p_object_version_number = g_old_rec.object_version_number) Then
137 hr_utility.set_location(l_proc, 10);
138 --
139 -- The g_old_rec is current therefore we must
140 -- set the returning function to true
141 --
142 l_fct_ret := true;
143 Else
144 --
145 -- Select the current row
146 --
147 Open C_Sel1;
148 Fetch C_Sel1 Into g_old_rec;
149 If C_Sel1%notfound Then
150 Close C_Sel1;
151 --
152 -- The primary key is invalid therefore we must error
153 --
154 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
155 hr_utility.raise_error;
156 End If;
157 Close C_Sel1;
158 If (p_object_version_number <> g_old_rec.object_version_number) Then
159 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
160 hr_utility.raise_error;
161 End If;
162 hr_utility.set_location(l_proc, 15);
163 l_fct_ret := true;
164 End If;
165 End If;
166 hr_utility.set_location(' Leaving:'||l_proc, 20);
167 Return (l_fct_ret);
168 --
169 End api_updating;
170 --
171 -- ----------------------------------------------------------------------------
172 -- |--------------------------< find_dt_del_modes >---------------------------|
173 -- ----------------------------------------------------------------------------
174 Procedure find_dt_del_modes
175 (p_effective_date in date,
176 p_base_key_value in number,
177 p_zap out nocopy boolean,
178 p_delete out nocopy boolean,
179 p_future_change out nocopy boolean,
180 p_delete_next_change out nocopy boolean) is
181 --
182 l_proc varchar2(72) := g_package||'find_dt_del_modes';
183 --
184 l_parent_key_value1 number;
185 --
186 Cursor C_Sel1 Is
187 select t.vrbl_rt_prfl_id
188 from ben_vrbl_mtchg_rt_f t
189 where t.vrbl_mtchg_rt_id = p_base_key_value
190 and p_effective_date
191 between t.effective_start_date and t.effective_end_date;
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 Open C_Sel1;
196 Fetch C_Sel1 Into l_parent_key_value1;
197 If C_Sel1%notfound then
198 Close C_Sel1;
199 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
200 hr_utility.set_message_token('PROCEDURE', l_proc);
201 hr_utility.set_message_token('STEP','10');
202 hr_utility.raise_error;
203 End If;
204 Close C_Sel1;
205 --
206 -- Call the corresponding datetrack api
207 --
208 dt_api.find_dt_del_modes
209 (p_effective_date => p_effective_date,
210 p_base_table_name => 'ben_vrbl_mtchg_rt_f',
211 p_base_key_column => 'vrbl_mtchg_rt_id',
212 p_base_key_value => p_base_key_value,
213 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
214 p_parent_key_column1 => 'vrbl_rt_prfl_id',
215 p_parent_key_value1 => l_parent_key_value1,
216 p_zap => p_zap,
217 p_delete => p_delete,
218 p_future_change => p_future_change,
219 p_delete_next_change => p_delete_next_change);
220 --
221 hr_utility.set_location(' Leaving:'||l_proc, 10);
222 End find_dt_del_modes;
223 --
224 -- ----------------------------------------------------------------------------
225 -- |--------------------------< find_dt_upd_modes >---------------------------|
226 -- ----------------------------------------------------------------------------
227 Procedure find_dt_upd_modes
228 (p_effective_date in date,
229 p_base_key_value in number,
230 p_correction out nocopy boolean,
231 p_update out nocopy boolean,
232 p_update_override out nocopy boolean,
233 p_update_change_insert out nocopy boolean) is
234 --
235 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
236 --
237 Begin
238 hr_utility.set_location('Entering:'||l_proc, 5);
239 --
240 -- Call the corresponding datetrack api
241 --
242 dt_api.find_dt_upd_modes
243 (p_effective_date => p_effective_date,
244 p_base_table_name => 'ben_vrbl_mtchg_rt_f',
245 p_base_key_column => 'vrbl_mtchg_rt_id',
246 p_base_key_value => p_base_key_value,
247 p_correction => p_correction,
248 p_update => p_update,
249 p_update_override => p_update_override,
250 p_update_change_insert => p_update_change_insert);
251 --
252 hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End find_dt_upd_modes;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |------------------------< upd_effective_end_date >------------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure upd_effective_end_date
259 (p_effective_date in date,
260 p_base_key_value in number,
261 p_new_effective_end_date in date,
262 p_validation_start_date in date,
263 p_validation_end_date in date,
264 p_object_version_number out nocopy number) is
265 --
266 l_proc varchar2(72) := g_package||'upd_effective_end_date';
267 l_object_version_number number;
268 --
269 Begin
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 --
272 -- Because we are updating a row we must get the next object
273 -- version number.
274 --
275 l_object_version_number :=
276 dt_api.get_object_version_number
277 (p_base_table_name => 'ben_vrbl_mtchg_rt_f',
278 p_base_key_column => 'vrbl_mtchg_rt_id',
279 p_base_key_value => p_base_key_value);
280 --
281 hr_utility.set_location(l_proc, 10);
282 g_api_dml := true; -- Set the api dml status
283 --
284 -- Update the specified datetrack row setting the effective
285 -- end date to the specified new effective end date.
286 --
287 update ben_vrbl_mtchg_rt_f t
288 set t.effective_end_date = p_new_effective_end_date,
289 t.object_version_number = l_object_version_number
290 where t.vrbl_mtchg_rt_id = p_base_key_value
291 and p_effective_date
292 between t.effective_start_date and t.effective_end_date;
293 --
294 g_api_dml := false; -- Unset the api dml status
295 p_object_version_number := l_object_version_number;
296 hr_utility.set_location(' Leaving:'||l_proc, 15);
297 --
298 Exception
299 When Others Then
300 g_api_dml := false; -- Unset the api dml status
301 Raise;
302 End upd_effective_end_date;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< lck >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure lck
308 (p_effective_date in date,
309 p_datetrack_mode in varchar2,
310 p_vrbl_mtchg_rt_id in number,
311 p_object_version_number in number,
312 p_validation_start_date out nocopy date,
313 p_validation_end_date out nocopy date) is
314 --
315 l_proc varchar2(72) := g_package||'lck';
316 l_validation_start_date date;
317 l_validation_end_date date;
318 l_object_invalid exception;
319 l_argument varchar2(30);
320 --
321 -- Cursor C_Sel1 selects the current locked row as of session date
322 -- ensuring that the object version numbers match.
323 --
324 Cursor C_Sel1 is
325 select
326 vrbl_mtchg_rt_id,
327 effective_end_date,
328 effective_start_date,
329 no_mx_pct_of_py_num_flag,
330 to_pct_val,
331 no_mx_amt_of_py_num_flag,
332 mx_pct_of_py_num,
333 no_mx_mtch_amt_flag,
334 ordr_num,
335 pct_val,
336 mx_mtch_amt,
337 mx_amt_of_py_num,
338 mn_mtch_amt,
339 mtchg_rt_calc_rl,
340 cntnu_mtch_aftr_max_rl_flag,
341 from_pct_val,
342 vrbl_rt_prfl_id,
343 business_group_id,
344 vmr_attribute_category,
345 vmr_attribute1,
346 vmr_attribute2,
347 vmr_attribute3,
348 vmr_attribute4,
349 vmr_attribute5,
350 vmr_attribute6,
351 vmr_attribute7,
352 vmr_attribute8,
353 vmr_attribute9,
354 vmr_attribute10,
355 vmr_attribute11,
356 vmr_attribute12,
357 vmr_attribute13,
358 vmr_attribute14,
359 vmr_attribute15,
360 vmr_attribute16,
361 vmr_attribute17,
362 vmr_attribute18,
363 vmr_attribute19,
364 vmr_attribute20,
365 vmr_attribute21,
366 vmr_attribute22,
367 vmr_attribute23,
368 vmr_attribute24,
369 vmr_attribute25,
370 vmr_attribute26,
371 vmr_attribute27,
372 vmr_attribute28,
373 vmr_attribute29,
374 vmr_attribute30,
375 object_version_number
376 from ben_vrbl_mtchg_rt_f
377 where vrbl_mtchg_rt_id = p_vrbl_mtchg_rt_id
378 and p_effective_date
379 between effective_start_date and effective_end_date
380 for update nowait;
381 --
382 --
383 --
384 Begin
385 hr_utility.set_location('Entering:'||l_proc, 5);
386 --
387 -- Ensure that all the mandatory arguments are not null
388 --
389 hr_api.mandatory_arg_error(p_api_name => l_proc,
390 p_argument => 'effective_date',
391 p_argument_value => p_effective_date);
392 --
393 hr_api.mandatory_arg_error(p_api_name => l_proc,
394 p_argument => 'datetrack_mode',
395 p_argument_value => p_datetrack_mode);
396 --
397 hr_api.mandatory_arg_error(p_api_name => l_proc,
398 p_argument => 'vrbl_mtchg_rt_id',
399 p_argument_value => p_vrbl_mtchg_rt_id);
400 --
401 hr_api.mandatory_arg_error(p_api_name => l_proc,
402 p_argument => 'object_version_number',
403 p_argument_value => p_object_version_number);
404 --
405 -- Check to ensure the datetrack mode is not INSERT.
406 --
407 If (p_datetrack_mode <> 'INSERT') then
408 --
409 -- We must select and lock the current row.
410 --
411 Open C_Sel1;
412 Fetch C_Sel1 Into g_old_rec;
413 If C_Sel1%notfound then
414 Close C_Sel1;
415 --
416 -- The primary key is invalid therefore we must error
417 --
418 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
419 hr_utility.raise_error;
420 End If;
421 Close C_Sel1;
422 If (p_object_version_number <> g_old_rec.object_version_number) Then
426 hr_utility.set_location(l_proc, 15);
423 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
424 hr_utility.raise_error;
425 End If;
427 --
428 --
429 -- Validate the datetrack mode mode getting the validation start
430 -- and end dates for the specified datetrack operation.
431 --
432 dt_api.validate_dt_mode
433 (p_effective_date => p_effective_date,
434 p_datetrack_mode => p_datetrack_mode,
435 p_base_table_name => 'ben_vrbl_mtchg_rt_f',
436 p_base_key_column => 'vrbl_mtchg_rt_id',
437 p_base_key_value => p_vrbl_mtchg_rt_id,
438 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
439 p_parent_key_column1 => 'vrbl_rt_prfl_id',
440 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
441 p_enforce_foreign_locking => false , --true,
442 p_validation_start_date => l_validation_start_date,
443 p_validation_end_date => l_validation_end_date);
444 Else
445 --
446 -- We are doing a datetrack 'INSERT' which is illegal within this
447 -- procedure therefore we must error (note: to lck on insert the
448 -- private procedure ins_lck should be called).
449 --
450 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
451 hr_utility.set_message_token('PROCEDURE', l_proc);
452 hr_utility.set_message_token('STEP','20');
453 hr_utility.raise_error;
454 End If;
455 --
456 -- Set the validation start and end date OUT arguments
457 --
458 p_validation_start_date := l_validation_start_date;
459 p_validation_end_date := l_validation_end_date;
460 --
461 hr_utility.set_location(' Leaving:'||l_proc, 30);
462 --
463 -- We need to trap the ORA LOCK exception
464 --
465 Exception
466 When HR_Api.Object_Locked then
467 --
468 -- The object is locked therefore we need to supply a meaningful
469 -- error message.
470 --
471 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
472 hr_utility.set_message_token('TABLE_NAME', 'ben_vrbl_mtchg_rt_f');
473 hr_utility.raise_error;
474 When l_object_invalid then
475 --
476 -- The object doesn't exist or is invalid
477 --
478 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
479 hr_utility.set_message_token('TABLE_NAME', 'ben_vrbl_mtchg_rt_f');
480 hr_utility.raise_error;
481 End lck;
482 --
483 -- ----------------------------------------------------------------------------
484 -- |-----------------------------< convert_args >-----------------------------|
485 -- ----------------------------------------------------------------------------
486 Function convert_args
487 (
488 p_vrbl_mtchg_rt_id in number,
489 p_effective_end_date in date,
490 p_effective_start_date in date,
491 p_no_mx_pct_of_py_num_flag in varchar2,
492 p_to_pct_val in number,
493 p_no_mx_amt_of_py_num_flag in varchar2,
494 p_mx_pct_of_py_num in number,
495 p_no_mx_mtch_amt_flag in varchar2,
496 p_ordr_num in number,
497 p_pct_val in number,
498 p_mx_mtch_amt in number,
499 p_mx_amt_of_py_num in number,
500 p_mn_mtch_amt in number,
501 p_mtchg_rt_calc_rl in number,
502 p_cntnu_mtch_aftr_max_rl_flag in varchar2,
503 p_from_pct_val in number,
504 p_vrbl_rt_prfl_id in number,
505 p_business_group_id in number,
506 p_vmr_attribute_category in varchar2,
507 p_vmr_attribute1 in varchar2,
508 p_vmr_attribute2 in varchar2,
509 p_vmr_attribute3 in varchar2,
510 p_vmr_attribute4 in varchar2,
511 p_vmr_attribute5 in varchar2,
512 p_vmr_attribute6 in varchar2,
513 p_vmr_attribute7 in varchar2,
514 p_vmr_attribute8 in varchar2,
515 p_vmr_attribute9 in varchar2,
516 p_vmr_attribute10 in varchar2,
517 p_vmr_attribute11 in varchar2,
518 p_vmr_attribute12 in varchar2,
519 p_vmr_attribute13 in varchar2,
520 p_vmr_attribute14 in varchar2,
521 p_vmr_attribute15 in varchar2,
522 p_vmr_attribute16 in varchar2,
523 p_vmr_attribute17 in varchar2,
524 p_vmr_attribute18 in varchar2,
525 p_vmr_attribute19 in varchar2,
526 p_vmr_attribute20 in varchar2,
527 p_vmr_attribute21 in varchar2,
528 p_vmr_attribute22 in varchar2,
529 p_vmr_attribute23 in varchar2,
530 p_vmr_attribute24 in varchar2,
531 p_vmr_attribute25 in varchar2,
532 p_vmr_attribute26 in varchar2,
533 p_vmr_attribute27 in varchar2,
534 p_vmr_attribute28 in varchar2,
535 p_vmr_attribute29 in varchar2,
536 p_vmr_attribute30 in varchar2,
537 p_object_version_number in number
538 )
539 Return g_rec_type is
540 --
541 l_rec g_rec_type;
542 l_proc varchar2(72) := g_package||'convert_args';
543 --
544 Begin
545 --
546 hr_utility.set_location('Entering:'||l_proc, 5);
547 --
548 -- Convert arguments into local l_rec structure.
549 --
550 l_rec.vrbl_mtchg_rt_id := p_vrbl_mtchg_rt_id;
551 l_rec.effective_end_date := p_effective_end_date;
552 l_rec.effective_start_date := p_effective_start_date;
553 l_rec.no_mx_pct_of_py_num_flag := p_no_mx_pct_of_py_num_flag;
554 l_rec.to_pct_val := p_to_pct_val;
555 l_rec.no_mx_amt_of_py_num_flag := p_no_mx_amt_of_py_num_flag;
556 l_rec.mx_pct_of_py_num := p_mx_pct_of_py_num;
557 l_rec.no_mx_mtch_amt_flag := p_no_mx_mtch_amt_flag;
558 l_rec.ordr_num := p_ordr_num;
559 l_rec.pct_val := p_pct_val;
560 l_rec.mx_mtch_amt := p_mx_mtch_amt;
561 l_rec.mx_amt_of_py_num := p_mx_amt_of_py_num;
562 l_rec.mn_mtch_amt := p_mn_mtch_amt;
563 l_rec.mtchg_rt_calc_rl := p_mtchg_rt_calc_rl;
564 l_rec.cntnu_mtch_aftr_max_rl_flag := p_cntnu_mtch_aftr_max_rl_flag;
565 l_rec.from_pct_val := p_from_pct_val;
566 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
567 l_rec.business_group_id := p_business_group_id;
568 l_rec.vmr_attribute_category := p_vmr_attribute_category;
569 l_rec.vmr_attribute1 := p_vmr_attribute1;
570 l_rec.vmr_attribute2 := p_vmr_attribute2;
571 l_rec.vmr_attribute3 := p_vmr_attribute3;
572 l_rec.vmr_attribute4 := p_vmr_attribute4;
573 l_rec.vmr_attribute5 := p_vmr_attribute5;
574 l_rec.vmr_attribute6 := p_vmr_attribute6;
575 l_rec.vmr_attribute7 := p_vmr_attribute7;
576 l_rec.vmr_attribute8 := p_vmr_attribute8;
577 l_rec.vmr_attribute9 := p_vmr_attribute9;
578 l_rec.vmr_attribute10 := p_vmr_attribute10;
579 l_rec.vmr_attribute11 := p_vmr_attribute11;
580 l_rec.vmr_attribute12 := p_vmr_attribute12;
581 l_rec.vmr_attribute13 := p_vmr_attribute13;
582 l_rec.vmr_attribute14 := p_vmr_attribute14;
583 l_rec.vmr_attribute15 := p_vmr_attribute15;
584 l_rec.vmr_attribute16 := p_vmr_attribute16;
585 l_rec.vmr_attribute17 := p_vmr_attribute17;
586 l_rec.vmr_attribute18 := p_vmr_attribute18;
587 l_rec.vmr_attribute19 := p_vmr_attribute19;
588 l_rec.vmr_attribute20 := p_vmr_attribute20;
589 l_rec.vmr_attribute21 := p_vmr_attribute21;
590 l_rec.vmr_attribute22 := p_vmr_attribute22;
591 l_rec.vmr_attribute23 := p_vmr_attribute23;
592 l_rec.vmr_attribute24 := p_vmr_attribute24;
593 l_rec.vmr_attribute25 := p_vmr_attribute25;
594 l_rec.vmr_attribute26 := p_vmr_attribute26;
595 l_rec.vmr_attribute27 := p_vmr_attribute27;
596 l_rec.vmr_attribute28 := p_vmr_attribute28;
597 l_rec.vmr_attribute29 := p_vmr_attribute29;
598 l_rec.vmr_attribute30 := p_vmr_attribute30;
599 l_rec.object_version_number := p_object_version_number;
600 --
601 -- Return the plsql record structure.
602 --
603 hr_utility.set_location(' Leaving:'||l_proc, 10);
604 Return(l_rec);
605 --
606 End convert_args;
607 --
608 end ben_vmr_shd;