[Home] [Help]
PACKAGE BODY: APPS.BEN_PEA_SHD
Source
1 Package Body ben_pea_shd as
2 /* $Header: bepearhi.pkb 120.2 2005/08/09 06:07:35 nhunur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pea_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_PRTT_ENRT_ACTN_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_PRTT_ENRT_ACTN_FK2') 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 ElsIf (p_constraint_name = 'BEN_PRTT_ENRT_ACTN_PK') Then
47 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
48 hr_utility.set_message_token('PROCEDURE', l_proc);
49 hr_utility.set_message_token('STEP','15');
50 hr_utility.raise_error;
51 Else
52 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
53 hr_utility.set_message_token('PROCEDURE', l_proc);
54 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
55 hr_utility.raise_error;
56 End If;
57 --
58 hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65 (p_effective_date in date,
66 p_prtt_enrt_actn_id in number,
67 p_object_version_number in number
68 ) Return Boolean Is
69 --
70 --
71 -- Cursor selects the 'current' row from the HR Schema
72 --
73 Cursor C_Sel1 is
74 select
75 prtt_enrt_actn_id,
76 effective_start_date,
77 effective_end_date,
78 cmpltd_dt,
79 due_dt,
80 rqd_flag,
81 prtt_enrt_rslt_id,
82 per_in_ler_id,
83 actn_typ_id,
84 elig_cvrd_dpnt_id,
85 pl_bnf_id,
86 business_group_id,
87 pea_attribute_category,
88 pea_attribute1,
89 pea_attribute2,
90 pea_attribute3,
91 pea_attribute4,
92 pea_attribute5,
93 pea_attribute6,
94 pea_attribute7,
95 pea_attribute8,
96 pea_attribute9,
97 pea_attribute10,
98 pea_attribute11,
99 pea_attribute12,
100 pea_attribute13,
101 pea_attribute14,
102 pea_attribute15,
103 pea_attribute16,
104 pea_attribute17,
105 pea_attribute18,
106 pea_attribute19,
107 pea_attribute20,
108 pea_attribute21,
109 pea_attribute22,
110 pea_attribute23,
111 pea_attribute24,
112 pea_attribute25,
113 pea_attribute26,
114 pea_attribute27,
115 pea_attribute28,
116 pea_attribute29,
117 pea_attribute30,
118 object_version_number
119 from ben_prtt_enrt_actn_f
120 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
121 and p_effective_date
122 between effective_start_date and effective_end_date;
123 --
124 l_proc varchar2(72) := g_package||'api_updating';
125 l_fct_ret boolean;
126 --
127 Begin
128 hr_utility.set_location('Entering:'||l_proc, 5);
129 --
130 If (p_effective_date is null or
131 p_prtt_enrt_actn_id is null or
132 p_object_version_number is null) Then
133 --
134 -- One of the primary key arguments is null therefore we must
135 -- set the returning function value to false
136 --
137 l_fct_ret := false;
138 Else
139 If (p_prtt_enrt_actn_id = g_old_rec.prtt_enrt_actn_id and
140 p_object_version_number = g_old_rec.object_version_number) Then
141 hr_utility.set_location(l_proc, 10);
142 --
143 -- The g_old_rec is current therefore we must
144 -- set the returning function to true
145 --
146 l_fct_ret := true;
147 Else
148 --
149 -- Select the current row
150 --
151 Open C_Sel1;
152 Fetch C_Sel1 Into g_old_rec;
153 If C_Sel1%notfound Then
154 Close C_Sel1;
155 --
156 -- The primary key is invalid therefore we must error
157 --
158 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
159 hr_utility.raise_error;
160 End If;
161 Close C_Sel1;
162 If (p_object_version_number <> g_old_rec.object_version_number) Then
163 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
164 hr_utility.raise_error;
165 End If;
166 hr_utility.set_location(l_proc, 15);
167 l_fct_ret := true;
168 End If;
169 End If;
170 hr_utility.set_location(' Leaving:'||l_proc, 20);
171 Return (l_fct_ret);
172 --
173 End api_updating;
174 --
175 -- ----------------------------------------------------------------------------
176 -- |--------------------------< find_dt_del_modes >---------------------------|
177 -- ----------------------------------------------------------------------------
178 Procedure find_dt_del_modes
179 (p_effective_date in date,
180 p_base_key_value in number,
181 p_zap out nocopy boolean,
182 p_delete out nocopy boolean,
183 p_future_change out nocopy boolean,
184 p_delete_next_change out nocopy boolean) is
185 --
186 l_proc varchar2(72) := g_package||'find_dt_del_modes';
187 --
188 l_parent_key_value1 number;
189 --
190 Cursor C_Sel1 Is
191 select t.prtt_enrt_rslt_id
192 from ben_prtt_enrt_actn_f t
193 where t.prtt_enrt_actn_id = p_base_key_value
194 and p_effective_date
195 between t.effective_start_date and t.effective_end_date;
196 --
197 Begin
198 hr_utility.set_location('Entering:'||l_proc, 5);
199 Open C_Sel1;
200 Fetch C_Sel1 Into l_parent_key_value1;
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_prtt_enrt_actn_f',
215 p_base_key_column => 'prtt_enrt_actn_id',
216 p_base_key_value => p_base_key_value,
217 p_parent_table_name1 => 'ben_prtt_enrt_rslt_f',
218 p_parent_key_column1 => 'prtt_enrt_rslt_id',
219 p_parent_key_value1 => l_parent_key_value1,
220 p_zap => p_zap,
221 p_delete => p_delete,
222 p_future_change => p_future_change,
223 p_delete_next_change => p_delete_next_change);
224 --
225 hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End find_dt_del_modes;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |--------------------------< find_dt_upd_modes >---------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure find_dt_upd_modes
232 (p_effective_date in date,
233 p_base_key_value in number,
234 p_correction out nocopy boolean,
235 p_update out nocopy boolean,
236 p_update_override out nocopy boolean,
237 p_update_change_insert out nocopy boolean) is
238 --
239 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
240 --
241 Begin
242 hr_utility.set_location('Entering:'||l_proc, 5);
243 --
244 -- Call the corresponding datetrack api
245 --
246 dt_api.find_dt_upd_modes
247 (p_effective_date => p_effective_date,
248 p_base_table_name => 'ben_prtt_enrt_actn_f',
249 p_base_key_column => 'prtt_enrt_actn_id',
250 p_base_key_value => p_base_key_value,
251 p_correction => p_correction,
252 p_update => p_update,
253 p_update_override => p_update_override,
254 p_update_change_insert => p_update_change_insert);
255 --
256 hr_utility.set_location(' Leaving:'||l_proc, 10);
257 End find_dt_upd_modes;
258 --
259 -- ----------------------------------------------------------------------------
260 -- |------------------------< upd_effective_end_date >------------------------|
261 -- ----------------------------------------------------------------------------
262 Procedure upd_effective_end_date
263 (p_effective_date in date,
264 p_base_key_value in number,
265 p_new_effective_end_date in date,
266 p_validation_start_date in date,
267 p_validation_end_date in date,
268 p_object_version_number out nocopy number) is
269 --
270 l_proc varchar2(72) := g_package||'upd_effective_end_date';
271 l_object_version_number number;
272 --
273 Begin
274 hr_utility.set_location('Entering:'||l_proc, 5);
275 --
276 -- Because we are updating a row we must get the next object
277 -- version number.
278 --
279 l_object_version_number :=
280 dt_api.get_object_version_number
281 (p_base_table_name => 'ben_prtt_enrt_actn_f',
282 p_base_key_column => 'prtt_enrt_actn_id',
283 p_base_key_value => p_base_key_value);
284 --
285 hr_utility.set_location(l_proc, 10);
286 g_api_dml := true; -- Set the api dml status
287 --
288 -- Update the specified datetrack row setting the effective
289 -- end date to the specified new effective end date.
290 --
291 update ben_prtt_enrt_actn_f t
292 set t.effective_end_date = p_new_effective_end_date,
293 t.object_version_number = l_object_version_number
294 where t.prtt_enrt_actn_id = p_base_key_value
295 and p_effective_date
296 between t.effective_start_date and t.effective_end_date;
297 --
298 g_api_dml := false; -- Unset the api dml status
299 p_object_version_number := l_object_version_number;
300 hr_utility.set_location(' Leaving:'||l_proc, 15);
301 --
302 Exception
303 When Others Then
304 g_api_dml := false; -- Unset the api dml status
305 Raise;
306 End upd_effective_end_date;
307 --
308 -- ----------------------------------------------------------------------------
309 -- |---------------------------------< lck >----------------------------------|
310 -- ----------------------------------------------------------------------------
311 Procedure lck
312 (p_effective_date in date,
313 p_datetrack_mode in varchar2,
314 p_prtt_enrt_actn_id in number,
315 p_object_version_number in number,
316 p_validation_start_date out nocopy date,
317 p_validation_end_date out nocopy date) is
318 --
319 l_proc varchar2(72) := g_package||'lck';
320 l_validation_start_date date;
321 l_validation_end_date date;
322 l_object_invalid exception;
323 l_argument varchar2(30);
324 --
325 -- Cursor C_Sel1 selects the current locked row as of session date
326 -- ensuring that the object version numbers match.
327 --
328 Cursor C_Sel1 is
329 select
330 prtt_enrt_actn_id,
331 effective_start_date,
332 effective_end_date,
333 cmpltd_dt,
334 due_dt,
335 rqd_flag,
336 prtt_enrt_rslt_id,
337 per_in_ler_id,
338 actn_typ_id,
339 elig_cvrd_dpnt_id,
340 pl_bnf_id,
341 business_group_id,
342 pea_attribute_category,
343 pea_attribute1,
344 pea_attribute2,
345 pea_attribute3,
346 pea_attribute4,
347 pea_attribute5,
348 pea_attribute6,
349 pea_attribute7,
350 pea_attribute8,
351 pea_attribute9,
352 pea_attribute10,
353 pea_attribute11,
354 pea_attribute12,
355 pea_attribute13,
356 pea_attribute14,
357 pea_attribute15,
358 pea_attribute16,
359 pea_attribute17,
360 pea_attribute18,
361 pea_attribute19,
362 pea_attribute20,
363 pea_attribute21,
364 pea_attribute22,
365 pea_attribute23,
366 pea_attribute24,
367 pea_attribute25,
368 pea_attribute26,
369 pea_attribute27,
370 pea_attribute28,
371 pea_attribute29,
372 pea_attribute30,
373 object_version_number
374 from ben_prtt_enrt_actn_f
375 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
376 and p_effective_date
377 between effective_start_date and effective_end_date
378 for update nowait;
379 --
380 --
381 --
382 Begin
383 hr_utility.set_location('Entering:'||l_proc, 5);
384 --
385 -- Ensure that all the mandatory arguments are not null
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'effective_date',
389 p_argument_value => p_effective_date);
390 --
391 hr_api.mandatory_arg_error(p_api_name => l_proc,
392 p_argument => 'datetrack_mode',
393 p_argument_value => p_datetrack_mode);
394 --
395 hr_api.mandatory_arg_error(p_api_name => l_proc,
396 p_argument => 'prtt_enrt_actn_id',
397 p_argument_value => p_prtt_enrt_actn_id);
398 --
399 hr_api.mandatory_arg_error(p_api_name => l_proc,
400 p_argument => 'object_version_number',
401 p_argument_value => p_object_version_number);
402 --
406 --
403 -- Check to ensure the datetrack mode is not INSERT.
404 --
405 If (p_datetrack_mode <> 'INSERT') then
407 -- We must select and lock the current row.
408 --
409 Open C_Sel1;
410 Fetch C_Sel1 Into g_old_rec;
411 If C_Sel1%notfound then
412 Close C_Sel1;
413 --
414 -- The primary key is invalid therefore we must error
415 --
416 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
417 hr_utility.raise_error;
418 End If;
419 Close C_Sel1;
420 If (p_object_version_number <> g_old_rec.object_version_number) Then
421 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
422 hr_utility.raise_error;
423 End If;
424 hr_utility.set_location(l_proc, 15);
425 --
426 --
427 -- Validate the datetrack mode mode getting the validation start
428 -- and end dates for the specified datetrack operation.
429 --
430 dt_api.validate_dt_mode
431 (p_effective_date => p_effective_date,
432 p_datetrack_mode => p_datetrack_mode,
433 p_base_table_name => 'ben_prtt_enrt_actn_f',
434 p_base_key_column => 'prtt_enrt_actn_id',
435 p_base_key_value => p_prtt_enrt_actn_id,
436 p_parent_table_name1 => 'ben_prtt_enrt_rslt_f',
437 p_parent_key_column1 => 'prtt_enrt_rslt_id',
438 p_parent_key_value1 => g_old_rec.prtt_enrt_rslt_id,
439 p_child_table_name1 => 'ben_cvrd_dpnt_ctfn_prvdd_f',
440 p_child_key_column1 => 'cvrd_dpnt_ctfn_prvdd_id',
441 p_child_table_name2 => 'ben_pl_bnf_ctfn_prvdd_f',
442 p_child_key_column2 => 'pl_bnf_ctfn_prvdd_id',
443 p_child_table_name3 => 'ben_prtt_enrt_ctfn_prvdd_f',
444 p_child_key_column3 => 'prtt_enrt_ctfn_prvdd_id',
445 p_enforce_foreign_locking => false,
446 p_validation_start_date => l_validation_start_date,
447 p_validation_end_date => l_validation_end_date);
448 Else
449 --
450 -- We are doing a datetrack 'INSERT' which is illegal within this
451 -- procedure therefore we must error (note: to lck on insert the
452 -- private procedure ins_lck should be called).
453 --
454 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
455 hr_utility.set_message_token('PROCEDURE', l_proc);
456 hr_utility.set_message_token('STEP','20');
457 hr_utility.raise_error;
458 End If;
459 --
460 -- Set the validation start and end date OUT arguments
461 --
462 p_validation_start_date := l_validation_start_date;
463 p_validation_end_date := l_validation_end_date;
464 --
465 hr_utility.set_location(' Leaving:'||l_proc, 30);
466 --
467 -- We need to trap the ORA LOCK exception
468 --
469 Exception
470 When HR_Api.Object_Locked then
471 --
472 -- The object is locked therefore we need to supply a meaningful
473 -- error message.
474 --
475 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
476 hr_utility.set_message_token('TABLE_NAME', 'ben_prtt_enrt_actn_f');
477 hr_utility.raise_error;
478 When l_object_invalid then
479 --
480 -- The object doesn't exist or is invalid
481 --
482 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
483 hr_utility.set_message_token('TABLE_NAME', 'ben_prtt_enrt_actn_f');
484 hr_utility.raise_error;
485 End lck;
486 --
487 -- ----------------------------------------------------------------------------
488 -- |-----------------------------< convert_args >-----------------------------|
489 -- ----------------------------------------------------------------------------
490 Function convert_args
491 (
492 p_prtt_enrt_actn_id in number,
493 p_effective_start_date in date,
494 p_effective_end_date in date,
495 p_cmpltd_dt in date,
496 p_due_dt in date,
497 p_rqd_flag in varchar2,
498 p_prtt_enrt_rslt_id in number,
499 p_per_in_ler_id in number,
500 p_actn_typ_id in number,
501 p_elig_cvrd_dpnt_id in number,
502 p_pl_bnf_id in number,
503 p_business_group_id in number,
504 p_pea_attribute_category in varchar2,
505 p_pea_attribute1 in varchar2,
506 p_pea_attribute2 in varchar2,
507 p_pea_attribute3 in varchar2,
508 p_pea_attribute4 in varchar2,
509 p_pea_attribute5 in varchar2,
510 p_pea_attribute6 in varchar2,
511 p_pea_attribute7 in varchar2,
512 p_pea_attribute8 in varchar2,
513 p_pea_attribute9 in varchar2,
514 p_pea_attribute10 in varchar2,
515 p_pea_attribute11 in varchar2,
516 p_pea_attribute12 in varchar2,
517 p_pea_attribute13 in varchar2,
518 p_pea_attribute14 in varchar2,
519 p_pea_attribute15 in varchar2,
520 p_pea_attribute16 in varchar2,
521 p_pea_attribute17 in varchar2,
522 p_pea_attribute18 in varchar2,
523 p_pea_attribute19 in varchar2,
524 p_pea_attribute20 in varchar2,
525 p_pea_attribute21 in varchar2,
529 p_pea_attribute25 in varchar2,
526 p_pea_attribute22 in varchar2,
527 p_pea_attribute23 in varchar2,
528 p_pea_attribute24 in varchar2,
530 p_pea_attribute26 in varchar2,
531 p_pea_attribute27 in varchar2,
532 p_pea_attribute28 in varchar2,
533 p_pea_attribute29 in varchar2,
534 p_pea_attribute30 in varchar2,
535 p_object_version_number in number
536 )
537 Return g_rec_type is
538 --
539 l_rec g_rec_type;
540 l_proc varchar2(72) := g_package||'convert_args';
541 --
542 Begin
543 --
544 hr_utility.set_location('Entering:'||l_proc, 5);
545 --
546 -- Convert arguments into local l_rec structure.
547 --
548 l_rec.prtt_enrt_actn_id := p_prtt_enrt_actn_id;
549 l_rec.effective_start_date := p_effective_start_date;
550 l_rec.effective_end_date := p_effective_end_date;
551 l_rec.cmpltd_dt := p_cmpltd_dt;
552 l_rec.due_dt := p_due_dt;
553 l_rec.rqd_flag := p_rqd_flag;
554 l_rec.prtt_enrt_rslt_id := p_prtt_enrt_rslt_id;
555 l_rec.per_in_ler_id := p_per_in_ler_id;
556 l_rec.actn_typ_id := p_actn_typ_id;
557 l_rec.elig_cvrd_dpnt_id := p_elig_cvrd_dpnt_id;
558 l_rec.pl_bnf_id := p_pl_bnf_id;
559 l_rec.business_group_id := p_business_group_id;
560 l_rec.elig_cvrd_dpnt_id := p_elig_cvrd_dpnt_id;
561 l_rec.pl_bnf_id := p_pl_bnf_id;
562 l_rec.pea_attribute_category := p_pea_attribute_category;
563 l_rec.pea_attribute1 := p_pea_attribute1;
564 l_rec.pea_attribute2 := p_pea_attribute2;
565 l_rec.pea_attribute3 := p_pea_attribute3;
566 l_rec.pea_attribute4 := p_pea_attribute4;
567 l_rec.pea_attribute5 := p_pea_attribute5;
568 l_rec.pea_attribute6 := p_pea_attribute6;
569 l_rec.pea_attribute7 := p_pea_attribute7;
570 l_rec.pea_attribute8 := p_pea_attribute8;
571 l_rec.pea_attribute9 := p_pea_attribute9;
572 l_rec.pea_attribute10 := p_pea_attribute10;
573 l_rec.pea_attribute11 := p_pea_attribute11;
574 l_rec.pea_attribute12 := p_pea_attribute12;
575 l_rec.pea_attribute13 := p_pea_attribute13;
576 l_rec.pea_attribute14 := p_pea_attribute14;
577 l_rec.pea_attribute15 := p_pea_attribute15;
578 l_rec.pea_attribute16 := p_pea_attribute16;
579 l_rec.pea_attribute17 := p_pea_attribute17;
580 l_rec.pea_attribute18 := p_pea_attribute18;
581 l_rec.pea_attribute19 := p_pea_attribute19;
582 l_rec.pea_attribute20 := p_pea_attribute20;
583 l_rec.pea_attribute21 := p_pea_attribute21;
584 l_rec.pea_attribute22 := p_pea_attribute22;
585 l_rec.pea_attribute23 := p_pea_attribute23;
586 l_rec.pea_attribute24 := p_pea_attribute24;
587 l_rec.pea_attribute25 := p_pea_attribute25;
588 l_rec.pea_attribute26 := p_pea_attribute26;
589 l_rec.pea_attribute27 := p_pea_attribute27;
590 l_rec.pea_attribute28 := p_pea_attribute28;
591 l_rec.pea_attribute29 := p_pea_attribute29;
592 l_rec.pea_attribute30 := p_pea_attribute30;
593 l_rec.object_version_number := p_object_version_number;
594 --
595 -- Return the plsql record structure.
596 --
597 hr_utility.set_location(' Leaving:'||l_proc, 10);
598 Return(l_rec);
599 --
600 End convert_args;
601 --
602 end ben_pea_shd;