[Home] [Help]
PACKAGE BODY: APPS.BEN_PCT_SHD
Source
1 Package Body ben_pct_shd as
2 /* $Header: bepctrhi.pkb 120.0 2005/05/28 10:18:14 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pct_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_PL_GD_R_SVC_CTFN_FK1') 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 ElsIf (p_constraint_name = 'BEN_PL_GD_R_SVC_CTFN_PK') Then
42 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43 hr_utility.set_message_token('PROCEDURE', l_proc);
44 hr_utility.set_message_token('STEP','10');
45 hr_utility.raise_error;
46 Else
47 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
48 hr_utility.set_message_token('PROCEDURE', l_proc);
49 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
50 hr_utility.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_pl_gd_r_svc_ctfn_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 pl_gd_r_svc_ctfn_id,
71 effective_start_date,
72 effective_end_date,
73 business_group_id,
74 pl_gd_or_svc_id,
75 pfd_flag,
76 lack_ctfn_deny_rmbmt_flag,
77 rmbmt_ctfn_typ_cd,
78 lack_ctfn_deny_rmbmt_rl,
79 pct_attribute_category,
80 pct_attribute1,
81 pct_attribute2,
82 pct_attribute3,
83 pct_attribute4,
84 pct_attribute5,
85 pct_attribute6,
86 pct_attribute7,
87 pct_attribute8,
88 pct_attribute9,
89 pct_attribute10,
90 pct_attribute11,
91 pct_attribute12,
92 pct_attribute13,
93 pct_attribute14,
94 pct_attribute15,
95 pct_attribute16,
96 pct_attribute17,
97 pct_attribute18,
98 pct_attribute19,
99 pct_attribute20,
100 pct_attribute21,
101 pct_attribute22,
102 pct_attribute23,
103 pct_attribute24,
104 pct_attribute25,
105 pct_attribute26,
106 pct_attribute27,
107 pct_attribute28,
108 pct_attribute29,
109 pct_attribute30,
110 object_version_number ,
111 ctfn_rqd_when_rl ,
112 rqd_flag
113 from ben_pl_gd_r_svc_ctfn_f
114 where pl_gd_r_svc_ctfn_id = p_pl_gd_r_svc_ctfn_id
115 and p_effective_date
116 between effective_start_date and effective_end_date;
117 --
118 l_proc varchar2(72) := g_package||'api_updating';
119 l_fct_ret boolean;
120 --
121 Begin
122 hr_utility.set_location('Entering:'||l_proc, 5);
123 --
124 If (p_effective_date is null or
125 p_pl_gd_r_svc_ctfn_id is null or
126 p_object_version_number is null) Then
127 --
128 -- One of the primary key arguments is null therefore we must
129 -- set the returning function value to false
130 --
131 l_fct_ret := false;
132 Else
133 If (p_pl_gd_r_svc_ctfn_id = g_old_rec.pl_gd_r_svc_ctfn_id and
134 p_object_version_number = g_old_rec.object_version_number) Then
135 hr_utility.set_location(l_proc, 10);
136 --
137 -- The g_old_rec is current therefore we must
138 -- set the returning function to true
139 --
140 l_fct_ret := true;
141 Else
142 --
143 -- Select the current row
144 --
145 Open C_Sel1;
146 Fetch C_Sel1 Into g_old_rec;
147 If C_Sel1%notfound Then
148 Close C_Sel1;
149 --
150 -- The primary key is invalid therefore we must error
151 --
152 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
153 hr_utility.raise_error;
154 End If;
155 Close C_Sel1;
156 If (p_object_version_number <> g_old_rec.object_version_number) Then
157 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
158 hr_utility.raise_error;
159 End If;
160 hr_utility.set_location(l_proc, 15);
161 l_fct_ret := true;
162 End If;
163 End If;
164 hr_utility.set_location(' Leaving:'||l_proc, 20);
165 Return (l_fct_ret);
166 --
167 End api_updating;
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) is
179 --
180 l_proc varchar2(72) := g_package||'find_dt_del_modes';
181 --
182 l_parent_key_value1 number;
183 l_parent_key_value2 number;
184 l_parent_key_value3 number;
185 --
186 Cursor C_Sel1 Is
187 select t.lack_ctfn_deny_rmbmt_rl,
188 t.pl_gd_or_svc_id
189 --t.pl_id
190 from ben_pl_gd_r_svc_ctfn_f t
191 where t.pl_gd_r_svc_ctfn_id = p_base_key_value
192 and p_effective_date
193 between t.effective_start_date and t.effective_end_date;
194 --
195 Begin
196 hr_utility.set_location('Entering:'||l_proc, 5);
197 Open C_Sel1;
198 Fetch C_Sel1 Into l_parent_key_value1,
199 l_parent_key_value2;
200 -- l_parent_key_value3;
201 If C_Sel1%notfound then
202 Close C_Sel1;
203 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
204 hr_utility.set_message_token('PROCEDURE', l_proc);
205 hr_utility.set_message_token('STEP','10');
206 hr_utility.raise_error;
207 End If;
208 Close C_Sel1;
209 --
210 -- Call the corresponding datetrack api
211 --
212 dt_api.find_dt_del_modes
213 (p_effective_date => p_effective_date,
214 p_base_table_name => 'ben_pl_gd_r_svc_ctfn_f',
215 p_base_key_column => 'pl_gd_r_svc_ctfn_id',
216 p_base_key_value => p_base_key_value,
217 p_parent_table_name1 => 'ff_formulas_f',
218 p_parent_key_column1 => 'formula_id',
219 p_parent_key_value1 => l_parent_key_value1,
220 p_parent_table_name2 => 'ben_pl_gd_or_svc_f',
221 p_parent_key_column2 => 'pl_gd_or_svc_id',
222 p_parent_key_value2 => l_parent_key_value2,
223 -- p_parent_table_name3 => 'ben_pl_f',
224 -- p_parent_key_column3 => 'pl_id',
225 -- p_parent_key_value3 => l_parent_key_value3,
226 p_zap => p_zap,
227 p_delete => p_delete,
228 p_future_change => p_future_change,
229 p_delete_next_change => p_delete_next_change);
230 --
231 hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End find_dt_del_modes;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |--------------------------< find_dt_upd_modes >---------------------------|
236 -- ----------------------------------------------------------------------------
237 Procedure find_dt_upd_modes
238 (p_effective_date in date,
239 p_base_key_value in number,
240 p_correction out nocopy boolean,
241 p_update out nocopy boolean,
242 p_update_override out nocopy boolean,
243 p_update_change_insert out nocopy boolean) is
244 --
245 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
246 --
247 Begin
248 hr_utility.set_location('Entering:'||l_proc, 5);
249 --
250 -- Call the corresponding datetrack api
251 --
252 dt_api.find_dt_upd_modes
253 (p_effective_date => p_effective_date,
254 p_base_table_name => 'ben_pl_gd_r_svc_ctfn_f',
255 p_base_key_column => 'pl_gd_r_svc_ctfn_id',
256 p_base_key_value => p_base_key_value,
257 p_correction => p_correction,
258 p_update => p_update,
259 p_update_override => p_update_override,
260 p_update_change_insert => p_update_change_insert);
261 --
262 hr_utility.set_location(' Leaving:'||l_proc, 10);
263 End find_dt_upd_modes;
264 --
265 -- ----------------------------------------------------------------------------
266 -- |------------------------< upd_effective_end_date >------------------------|
267 -- ----------------------------------------------------------------------------
268 Procedure upd_effective_end_date
269 (p_effective_date in date,
270 p_base_key_value in number,
271 p_new_effective_end_date in date,
272 p_validation_start_date in date,
273 p_validation_end_date in date,
274 p_object_version_number out nocopy number) is
275 --
276 l_proc varchar2(72) := g_package||'upd_effective_end_date';
277 l_object_version_number number;
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Because we are updating a row we must get the next object
283 -- version number.
284 --
285 l_object_version_number :=
286 dt_api.get_object_version_number
287 (p_base_table_name => 'ben_pl_gd_r_svc_ctfn_f',
288 p_base_key_column => 'pl_gd_r_svc_ctfn_id',
289 p_base_key_value => p_base_key_value);
290 --
291 hr_utility.set_location(l_proc, 10);
292 g_api_dml := true; -- Set the api dml status
293 --
294 -- Update the specified datetrack row setting the effective
295 -- end date to the specified new effective end date.
296 --
297 update ben_pl_gd_r_svc_ctfn_f t
298 set t.effective_end_date = p_new_effective_end_date,
299 t.object_version_number = l_object_version_number
300 where t.pl_gd_r_svc_ctfn_id = p_base_key_value
301 and p_effective_date
302 between t.effective_start_date and t.effective_end_date;
303 --
304 g_api_dml := false; -- Unset the api dml status
305 p_object_version_number := l_object_version_number;
306 hr_utility.set_location(' Leaving:'||l_proc, 15);
307 --
308 Exception
309 When Others Then
310 g_api_dml := false; -- Unset the api dml status
311 Raise;
312 End upd_effective_end_date;
313 --
314 -- ----------------------------------------------------------------------------
315 -- |---------------------------------< lck >----------------------------------|
316 -- ----------------------------------------------------------------------------
317 Procedure lck
318 (p_effective_date in date,
319 p_datetrack_mode in varchar2,
320 p_pl_gd_r_svc_ctfn_id in number,
321 p_object_version_number in number,
322 p_validation_start_date out nocopy date,
323 p_validation_end_date out nocopy date) is
324 --
325 l_proc varchar2(72) := g_package||'lck';
326 l_validation_start_date date;
327 l_validation_end_date date;
328 l_object_invalid exception;
329 l_argument varchar2(30);
330 --
331 -- Cursor C_Sel1 selects the current locked row as of session date
332 -- ensuring that the object version numbers match.
333 --
334 Cursor C_Sel1 is
335 select
336 pl_gd_r_svc_ctfn_id,
337 effective_start_date,
338 effective_end_date,
339 business_group_id,
340 pl_gd_or_svc_id,
341 pfd_flag,
342 lack_ctfn_deny_rmbmt_flag,
343 rmbmt_ctfn_typ_cd,
344 lack_ctfn_deny_rmbmt_rl,
345 pct_attribute_category,
346 pct_attribute1,
347 pct_attribute2,
348 pct_attribute3,
349 pct_attribute4,
350 pct_attribute5,
351 pct_attribute6,
352 pct_attribute7,
353 pct_attribute8,
354 pct_attribute9,
355 pct_attribute10,
356 pct_attribute11,
357 pct_attribute12,
358 pct_attribute13,
359 pct_attribute14,
360 pct_attribute15,
361 pct_attribute16,
362 pct_attribute17,
363 pct_attribute18,
364 pct_attribute19,
365 pct_attribute20,
366 pct_attribute21,
367 pct_attribute22,
368 pct_attribute23,
369 pct_attribute24,
370 pct_attribute25,
371 pct_attribute26,
372 pct_attribute27,
373 pct_attribute28,
374 pct_attribute29,
375 pct_attribute30,
376 object_version_number ,
377 ctfn_rqd_when_rl ,
378 rqd_flag
379 from ben_pl_gd_r_svc_ctfn_f
380 where pl_gd_r_svc_ctfn_id = p_pl_gd_r_svc_ctfn_id
381 and p_effective_date
382 between effective_start_date and effective_end_date
383 for update nowait;
384 --
385 --
386 --
387 Begin
388 hr_utility.set_location('Entering:'||l_proc, 5);
389 --
390 -- Ensure that all the mandatory arguments are not null
391 --
392 hr_api.mandatory_arg_error(p_api_name => l_proc,
393 p_argument => 'effective_date',
394 p_argument_value => p_effective_date);
395 --
396 hr_api.mandatory_arg_error(p_api_name => l_proc,
397 p_argument => 'datetrack_mode',
398 p_argument_value => p_datetrack_mode);
399 --
400 hr_api.mandatory_arg_error(p_api_name => l_proc,
401 p_argument => 'pl_gd_r_svc_ctfn_id',
402 p_argument_value => p_pl_gd_r_svc_ctfn_id);
403 --
404 hr_api.mandatory_arg_error(p_api_name => l_proc,
405 p_argument => 'object_version_number',
406 p_argument_value => p_object_version_number);
407 --
408 -- Check to ensure the datetrack mode is not INSERT.
409 --
410 If (p_datetrack_mode <> 'INSERT') then
411 --
412 -- We must select and lock the current row.
413 --
414 Open C_Sel1;
415 Fetch C_Sel1 Into g_old_rec;
416 If C_Sel1%notfound then
417 Close C_Sel1;
418 --
419 -- The primary key is invalid therefore we must error
420 --
421 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
422 hr_utility.raise_error;
423 End If;
424 Close C_Sel1;
425 If (p_object_version_number <> g_old_rec.object_version_number) Then
426 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
427 hr_utility.raise_error;
428 End If;
429 hr_utility.set_location(l_proc, 15);
430 --
431 --
435 dt_api.validate_dt_mode
432 -- Validate the datetrack mode mode getting the validation start
433 -- and end dates for the specified datetrack operation.
434 --
436 (p_effective_date => p_effective_date,
437 p_datetrack_mode => p_datetrack_mode,
438 p_base_table_name => 'ben_pl_gd_r_svc_ctfn_f',
439 p_base_key_column => 'pl_gd_r_svc_ctfn_id',
440 p_base_key_value => p_pl_gd_r_svc_ctfn_id,
441 p_parent_table_name1 => 'ff_formulas_f',
442 p_parent_key_column1 => 'formula_id',
443 p_parent_key_value1 => g_old_rec.lack_ctfn_deny_rmbmt_rl,
444 p_parent_table_name2 => 'ben_pl_gd_or_svc_f',
445 p_parent_key_column2 => 'pl_gd_or_svc_id',
446 p_parent_key_value2 => g_old_rec.pl_gd_or_svc_id,
447 -- p_parent_table_name3 => 'Ben_pl_f',
448 --p_parent_key_column3 => 'pl_id',
449 --p_parent_key_value3 => g_old_rec.pl_id,
450 p_enforce_foreign_locking => true,
451 p_validation_start_date => l_validation_start_date,
452 p_validation_end_date => l_validation_end_date);
453 Else
454 --
455 -- We are doing a datetrack 'INSERT' which is illegal within this
456 -- procedure therefore we must error (note: to lck on insert the
457 -- private procedure ins_lck should be called).
458 --
459 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
460 hr_utility.set_message_token('PROCEDURE', l_proc);
461 hr_utility.set_message_token('STEP','20');
462 hr_utility.raise_error;
463 End If;
464 --
465 -- Set the validation start and end date OUT arguments
466 --
467 p_validation_start_date := l_validation_start_date;
468 p_validation_end_date := l_validation_end_date;
469 --
470 hr_utility.set_location(' Leaving:'||l_proc, 30);
471 --
472 -- We need to trap the ORA LOCK exception
473 --
474 Exception
475 When HR_Api.Object_Locked then
476 --
477 -- The object is locked therefore we need to supply a meaningful
478 -- error message.
479 --
480 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
481 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_gd_r_svc_ctfn_f');
482 hr_utility.raise_error;
483 When l_object_invalid then
484 --
485 -- The object doesn't exist or is invalid
486 --
487 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
488 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_gd_r_svc_ctfn_f');
489 hr_utility.raise_error;
490 End lck;
491 --
492 -- ----------------------------------------------------------------------------
493 -- |-----------------------------< convert_args >-----------------------------|
494 -- ----------------------------------------------------------------------------
495 Function convert_args
496 (
497 p_pl_gd_r_svc_ctfn_id in number,
498 p_effective_start_date in date,
499 p_effective_end_date in date,
500 p_business_group_id in number,
501 p_pl_gd_or_svc_id in number,
502 p_pfd_flag in varchar2,
503 p_lack_ctfn_deny_rmbmt_flag in varchar2,
504 p_rmbmt_ctfn_typ_cd in varchar2,
505 p_lack_ctfn_deny_rmbmt_rl in number,
506 p_pct_attribute_category in varchar2,
507 p_pct_attribute1 in varchar2,
508 p_pct_attribute2 in varchar2,
509 p_pct_attribute3 in varchar2,
510 p_pct_attribute4 in varchar2,
511 p_pct_attribute5 in varchar2,
512 p_pct_attribute6 in varchar2,
513 p_pct_attribute7 in varchar2,
514 p_pct_attribute8 in varchar2,
515 p_pct_attribute9 in varchar2,
516 p_pct_attribute10 in varchar2,
517 p_pct_attribute11 in varchar2,
518 p_pct_attribute12 in varchar2,
519 p_pct_attribute13 in varchar2,
520 p_pct_attribute14 in varchar2,
521 p_pct_attribute15 in varchar2,
522 p_pct_attribute16 in varchar2,
523 p_pct_attribute17 in varchar2,
524 p_pct_attribute18 in varchar2,
525 p_pct_attribute19 in varchar2,
526 p_pct_attribute20 in varchar2,
527 p_pct_attribute21 in varchar2,
528 p_pct_attribute22 in varchar2,
529 p_pct_attribute23 in varchar2,
530 p_pct_attribute24 in varchar2,
531 p_pct_attribute25 in varchar2,
532 p_pct_attribute26 in varchar2,
533 p_pct_attribute27 in varchar2,
534 p_pct_attribute28 in varchar2,
535 p_pct_attribute29 in varchar2,
536 p_pct_attribute30 in varchar2,
537 p_object_version_number in number ,
538 p_ctfn_rqd_when_rl in number ,
539 p_rqd_flag in varchar2
540 )
541
542 Return g_rec_type is
543 --
544 l_rec g_rec_type;
545 l_proc varchar2(72) := g_package||'convert_args';
546 --
547 Begin
548 --
549 hr_utility.set_location('Entering:'||l_proc, 5);
550 --
551 -- Convert arguments into local l_rec structure.
552 --
553 l_rec.pl_gd_r_svc_ctfn_id := p_pl_gd_r_svc_ctfn_id;
554 l_rec.effective_start_date := p_effective_start_date;
555 l_rec.effective_end_date := p_effective_end_date;
556 l_rec.business_group_id := p_business_group_id;
557 l_rec.pl_gd_or_svc_id := p_pl_gd_or_svc_id;
558 l_rec.pfd_flag := p_pfd_flag;
559 l_rec.lack_ctfn_deny_rmbmt_flag := p_lack_ctfn_deny_rmbmt_flag;
560 l_rec.rmbmt_ctfn_typ_cd := p_rmbmt_ctfn_typ_cd;
561 l_rec.lack_ctfn_deny_rmbmt_rl := p_lack_ctfn_deny_rmbmt_rl;
562 l_rec.pct_attribute_category := p_pct_attribute_category;
563 l_rec.pct_attribute1 := p_pct_attribute1;
564 l_rec.pct_attribute2 := p_pct_attribute2;
565 l_rec.pct_attribute3 := p_pct_attribute3;
566 l_rec.pct_attribute4 := p_pct_attribute4;
567 l_rec.pct_attribute5 := p_pct_attribute5;
568 l_rec.pct_attribute6 := p_pct_attribute6;
569 l_rec.pct_attribute7 := p_pct_attribute7;
570 l_rec.pct_attribute8 := p_pct_attribute8;
571 l_rec.pct_attribute9 := p_pct_attribute9;
572 l_rec.pct_attribute10 := p_pct_attribute10;
573 l_rec.pct_attribute11 := p_pct_attribute11;
574 l_rec.pct_attribute12 := p_pct_attribute12;
575 l_rec.pct_attribute13 := p_pct_attribute13;
576 l_rec.pct_attribute14 := p_pct_attribute14;
577 l_rec.pct_attribute15 := p_pct_attribute15;
578 l_rec.pct_attribute16 := p_pct_attribute16;
579 l_rec.pct_attribute17 := p_pct_attribute17;
580 l_rec.pct_attribute18 := p_pct_attribute18;
581 l_rec.pct_attribute19 := p_pct_attribute19;
582 l_rec.pct_attribute20 := p_pct_attribute20;
583 l_rec.pct_attribute21 := p_pct_attribute21;
584 l_rec.pct_attribute22 := p_pct_attribute22;
585 l_rec.pct_attribute23 := p_pct_attribute23;
586 l_rec.pct_attribute24 := p_pct_attribute24;
587 l_rec.pct_attribute25 := p_pct_attribute25;
588 l_rec.pct_attribute26 := p_pct_attribute26;
589 l_rec.pct_attribute27 := p_pct_attribute27;
590 l_rec.pct_attribute28 := p_pct_attribute28;
591 l_rec.pct_attribute29 := p_pct_attribute29;
592 l_rec.pct_attribute30 := p_pct_attribute30;
593 l_rec.object_version_number := p_object_version_number;
594 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl ;
595 l_rec.rqd_flag := p_rqd_flag ;
596 --
597 -- Return the plsql record structure.
598 --
599 hr_utility.set_location(' Leaving:'||l_proc, 10);
600 Return(l_rec);
601 --
602 End convert_args;
603 --
604 end ben_pct_shd;