[Home] [Help]
PACKAGE BODY: APPS.BEN_PND_SHD
Source
1 Package Body ben_pnd_shd as
2 /* $Header: bepndrhi.pkb 120.1 2008/02/05 09:52:24 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pnd_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_DPNT_CVG_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_DPNT_CVG_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_dpnt_cvg_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_dpnt_cvg_ctfn_id,
74 pfd_flag,
71 effective_start_date,
72 effective_end_date,
73 pl_id,
75 ctfn_rqd_when_rl,
76 lack_ctfn_sspnd_enrt_flag,
77 dpnt_cvg_ctfn_typ_cd,
78 rqd_flag,
79 rlshp_typ_cd,
80 business_group_id,
81 pnd_attribute_category,
82 pnd_attribute1,
83 pnd_attribute2,
84 pnd_attribute3,
85 pnd_attribute4,
86 pnd_attribute5,
87 pnd_attribute6,
88 pnd_attribute7,
89 pnd_attribute8,
90 pnd_attribute9,
91 pnd_attribute10,
92 pnd_attribute11,
93 pnd_attribute12,
94 pnd_attribute13,
95 pnd_attribute14,
96 pnd_attribute15,
97 pnd_attribute16,
98 pnd_attribute17,
99 pnd_attribute18,
100 pnd_attribute19,
101 pnd_attribute20,
102 pnd_attribute21,
103 pnd_attribute22,
104 pnd_attribute23,
105 pnd_attribute24,
106 pnd_attribute25,
107 pnd_attribute26,
108 pnd_attribute27,
109 pnd_attribute28,
110 pnd_attribute29,
111 pnd_attribute30,
112 request_id,
113 program_application_id,
114 program_id,
115 program_update_date,
116 object_version_number
117 from ben_pl_dpnt_cvg_ctfn_f
118 where pl_dpnt_cvg_ctfn_id = p_pl_dpnt_cvg_ctfn_id
119 and p_effective_date
120 between effective_start_date and effective_end_date;
121 --
122 l_proc varchar2(72) := g_package||'api_updating';
123 l_fct_ret boolean;
124 --
125 Begin
126 hr_utility.set_location('Entering:'||l_proc, 5);
127 --
128 If (p_effective_date is null or
129 p_pl_dpnt_cvg_ctfn_id is null or
130 p_object_version_number is null) Then
131 --
132 -- One of the primary key arguments is null therefore we must
133 -- set the returning function value to false
134 --
135 l_fct_ret := false;
136 Else
137 If (p_pl_dpnt_cvg_ctfn_id = g_old_rec.pl_dpnt_cvg_ctfn_id and
138 p_object_version_number = g_old_rec.object_version_number) Then
139 hr_utility.set_location(l_proc, 10);
140 --
141 -- The g_old_rec is current therefore we must
142 -- set the returning function to true
143 --
144 l_fct_ret := true;
145 Else
146 --
147 -- Select the current row
148 --
149 Open C_Sel1;
150 Fetch C_Sel1 Into g_old_rec;
151 If C_Sel1%notfound Then
152 Close C_Sel1;
153 --
154 -- The primary key is invalid therefore we must error
155 --
156 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
157 hr_utility.raise_error;
158 End If;
159 Close C_Sel1;
160 If (p_object_version_number <> g_old_rec.object_version_number) Then
161 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
162 hr_utility.raise_error;
163 End If;
164 hr_utility.set_location(l_proc, 15);
165 l_fct_ret := true;
166 End If;
167 End If;
168 hr_utility.set_location(' Leaving:'||l_proc, 20);
169 Return (l_fct_ret);
170 --
171 End api_updating;
172 --
173 -- ----------------------------------------------------------------------------
174 -- |--------------------------< find_dt_del_modes >---------------------------|
175 -- ----------------------------------------------------------------------------
176 Procedure find_dt_del_modes
177 (p_effective_date in date,
178 p_base_key_value in number,
179 p_zap out nocopy boolean,
180 p_delete out nocopy boolean,
181 p_future_change out nocopy boolean,
182 p_delete_next_change out nocopy boolean) is
183 --
184 l_proc varchar2(72) := g_package||'find_dt_del_modes';
185 --
186 l_parent_key_value1 number;
187 --
188 Cursor C_Sel1 Is
189 select t.pl_id
190 from ben_pl_dpnt_cvg_ctfn_f t
191 where t.pl_dpnt_cvg_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 If C_Sel1%notfound then
200 Close C_Sel1;
201 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
202 hr_utility.set_message_token('PROCEDURE', l_proc);
203 hr_utility.set_message_token('STEP','10');
204 hr_utility.raise_error;
205 End If;
206 Close C_Sel1;
207 --
208 -- Call the corresponding datetrack api
209 --
210 dt_api.find_dt_del_modes
211 (p_effective_date => p_effective_date,
212 p_base_table_name => 'ben_pl_dpnt_cvg_ctfn_f',
213 p_base_key_column => 'pl_dpnt_cvg_ctfn_id',
214 p_base_key_value => p_base_key_value,
215 p_parent_table_name1 => 'ben_pl_f',
216 p_parent_key_column1 => 'pl_id',
217 p_parent_key_value1 => l_parent_key_value1,
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 --
242 -- Call the corresponding datetrack api
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
243 --
244 dt_api.find_dt_upd_modes
245 (p_effective_date => p_effective_date,
246 p_base_table_name => 'ben_pl_dpnt_cvg_ctfn_f',
247 p_base_key_column => 'pl_dpnt_cvg_ctfn_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_pl_dpnt_cvg_ctfn_f',
280 p_base_key_column => 'pl_dpnt_cvg_ctfn_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_pl_dpnt_cvg_ctfn_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.pl_dpnt_cvg_ctfn_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_pl_dpnt_cvg_ctfn_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 pl_dpnt_cvg_ctfn_id,
329 effective_start_date,
330 effective_end_date,
331 pl_id,
332 pfd_flag,
333 ctfn_rqd_when_rl,
334 lack_ctfn_sspnd_enrt_flag,
335 dpnt_cvg_ctfn_typ_cd,
336 rqd_flag,
337 rlshp_typ_cd,
338 business_group_id,
339 pnd_attribute_category,
340 pnd_attribute1,
341 pnd_attribute2,
342 pnd_attribute3,
343 pnd_attribute4,
344 pnd_attribute5,
345 pnd_attribute6,
346 pnd_attribute7,
347 pnd_attribute8,
348 pnd_attribute9,
349 pnd_attribute10,
350 pnd_attribute11,
351 pnd_attribute12,
352 pnd_attribute13,
353 pnd_attribute14,
354 pnd_attribute15,
355 pnd_attribute16,
356 pnd_attribute17,
357 pnd_attribute18,
358 pnd_attribute19,
359 pnd_attribute20,
360 pnd_attribute21,
361 pnd_attribute22,
362 pnd_attribute23,
363 pnd_attribute24,
364 pnd_attribute25,
365 pnd_attribute26,
366 pnd_attribute27,
367 pnd_attribute28,
368 pnd_attribute29,
369 pnd_attribute30,
370 request_id,
371 program_application_id,
372 program_id,
373 program_update_date,
374 object_version_number
375 from ben_pl_dpnt_cvg_ctfn_f
376 where pl_dpnt_cvg_ctfn_id = p_pl_dpnt_cvg_ctfn_id
377 and p_effective_date
378 between effective_start_date and effective_end_date
379 for update nowait;
380 --
381 --
382 --
383 Begin
384 hr_utility.set_location('Entering:'||l_proc, 5);
385 --
386 -- Ensure that all the mandatory arguments are not null
387 --
388 hr_api.mandatory_arg_error(p_api_name => l_proc,
389 p_argument => 'effective_date',
390 p_argument_value => p_effective_date);
391 --
392 hr_api.mandatory_arg_error(p_api_name => l_proc,
393 p_argument => 'datetrack_mode',
394 p_argument_value => p_datetrack_mode);
395 --
396 hr_api.mandatory_arg_error(p_api_name => l_proc,
397 p_argument => 'pl_dpnt_cvg_ctfn_id',
401 p_argument => 'object_version_number',
398 p_argument_value => p_pl_dpnt_cvg_ctfn_id);
399 --
400 hr_api.mandatory_arg_error(p_api_name => l_proc,
402 p_argument_value => p_object_version_number);
403 --
404 -- Check to ensure the datetrack mode is not INSERT.
405 --
406 If (p_datetrack_mode <> 'INSERT') then
407 --
408 -- We must select and lock the current row.
409 --
410 Open C_Sel1;
411 Fetch C_Sel1 Into g_old_rec;
412 If C_Sel1%notfound then
413 Close C_Sel1;
414 --
415 -- The primary key is invalid therefore we must error
416 --
417 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
418 hr_utility.raise_error;
419 End If;
420 Close C_Sel1;
421 If (p_object_version_number <> g_old_rec.object_version_number) Then
422 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
423 hr_utility.raise_error;
424 End If;
425 hr_utility.set_location(l_proc, 15);
426 --
427 --
428 -- Validate the datetrack mode mode getting the validation start
429 -- and end dates for the specified datetrack operation.
430 --
431 dt_api.validate_dt_mode
432 (p_effective_date => p_effective_date,
433 p_datetrack_mode => p_datetrack_mode,
434 p_base_table_name => 'ben_pl_dpnt_cvg_ctfn_f',
435 p_base_key_column => 'pl_dpnt_cvg_ctfn_id',
436 p_base_key_value => p_pl_dpnt_cvg_ctfn_id,
437 p_parent_table_name1 => 'ben_pl_f',
438 p_parent_key_column1 => 'pl_id',
439 p_parent_key_value1 => g_old_rec.pl_id,
440 p_enforce_foreign_locking => false , --true,
441 p_validation_start_date => l_validation_start_date,
442 p_validation_end_date => l_validation_end_date);
443 Else
444 --
445 -- We are doing a datetrack 'INSERT' which is illegal within this
446 -- procedure therefore we must error (note: to lck on insert the
447 -- private procedure ins_lck should be called).
448 --
449 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
450 hr_utility.set_message_token('PROCEDURE', l_proc);
451 hr_utility.set_message_token('STEP','20');
452 hr_utility.raise_error;
453 End If;
454 --
455 -- Set the validation start and end date OUT arguments
456 --
457 p_validation_start_date := l_validation_start_date;
458 p_validation_end_date := l_validation_end_date;
459 --
460 hr_utility.set_location(' Leaving:'||l_proc, 30);
461 --
462 -- We need to trap the ORA LOCK exception
463 --
464 Exception
465 When HR_Api.Object_Locked then
466 --
467 -- The object is locked therefore we need to supply a meaningful
468 -- error message.
469 --
470 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
471 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_dpnt_cvg_ctfn_f');
472 hr_utility.raise_error;
473 When l_object_invalid then
474 --
475 -- The object doesn't exist or is invalid
476 --
477 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
478 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_dpnt_cvg_ctfn_f');
479 hr_utility.raise_error;
480 End lck;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |-----------------------------< convert_args >-----------------------------|
484 -- ----------------------------------------------------------------------------
485 Function convert_args
486 (
487 p_pl_dpnt_cvg_ctfn_id in number,
488 p_effective_start_date in date,
489 p_effective_end_date in date,
490 p_pl_id in number,
491 p_pfd_flag in varchar2,
492 p_ctfn_rqd_when_rl in number,
493 p_lack_ctfn_sspnd_enrt_flag in varchar2,
494 p_dpnt_cvg_ctfn_typ_cd in varchar2,
495 p_rqd_flag in varchar2,
496 p_rlshp_typ_cd in varchar2,
497 p_business_group_id in number,
498 p_pnd_attribute_category in varchar2,
499 p_pnd_attribute1 in varchar2,
500 p_pnd_attribute2 in varchar2,
501 p_pnd_attribute3 in varchar2,
502 p_pnd_attribute4 in varchar2,
503 p_pnd_attribute5 in varchar2,
504 p_pnd_attribute6 in varchar2,
505 p_pnd_attribute7 in varchar2,
506 p_pnd_attribute8 in varchar2,
507 p_pnd_attribute9 in varchar2,
508 p_pnd_attribute10 in varchar2,
509 p_pnd_attribute11 in varchar2,
510 p_pnd_attribute12 in varchar2,
511 p_pnd_attribute13 in varchar2,
512 p_pnd_attribute14 in varchar2,
513 p_pnd_attribute15 in varchar2,
514 p_pnd_attribute16 in varchar2,
515 p_pnd_attribute17 in varchar2,
516 p_pnd_attribute18 in varchar2,
517 p_pnd_attribute19 in varchar2,
518 p_pnd_attribute20 in varchar2,
519 p_pnd_attribute21 in varchar2,
520 p_pnd_attribute22 in varchar2,
521 p_pnd_attribute23 in varchar2,
522 p_pnd_attribute24 in varchar2,
523 p_pnd_attribute25 in varchar2,
524 p_pnd_attribute26 in varchar2,
525 p_pnd_attribute27 in varchar2,
526 p_pnd_attribute28 in varchar2,
527 p_pnd_attribute29 in varchar2,
528 p_pnd_attribute30 in varchar2,
529 p_request_id in number,
530 p_program_application_id in number,
531 p_program_id in number,
535 Return g_rec_type is
532 p_program_update_date in date,
533 p_object_version_number in number
534 )
536 --
537 l_rec g_rec_type;
538 l_proc varchar2(72) := g_package||'convert_args';
539 --
540 Begin
541 --
542 hr_utility.set_location('Entering:'||l_proc, 5);
543 --
544 -- Convert arguments into local l_rec structure.
545 --
546 l_rec.pl_dpnt_cvg_ctfn_id := p_pl_dpnt_cvg_ctfn_id;
547 l_rec.effective_start_date := p_effective_start_date;
548 l_rec.effective_end_date := p_effective_end_date;
549 l_rec.pl_id := p_pl_id;
550 l_rec.pfd_flag := p_pfd_flag;
551 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl;
552 l_rec.lack_ctfn_sspnd_enrt_flag := p_lack_ctfn_sspnd_enrt_flag;
553 l_rec.dpnt_cvg_ctfn_typ_cd := p_dpnt_cvg_ctfn_typ_cd;
554 l_rec.rqd_flag := p_rqd_flag;
555 l_rec.rlshp_typ_cd := p_rlshp_typ_cd;
556 l_rec.business_group_id := p_business_group_id;
557 l_rec.pnd_attribute_category := p_pnd_attribute_category;
558 l_rec.pnd_attribute1 := p_pnd_attribute1;
559 l_rec.pnd_attribute2 := p_pnd_attribute2;
560 l_rec.pnd_attribute3 := p_pnd_attribute3;
561 l_rec.pnd_attribute4 := p_pnd_attribute4;
562 l_rec.pnd_attribute5 := p_pnd_attribute5;
563 l_rec.pnd_attribute6 := p_pnd_attribute6;
564 l_rec.pnd_attribute7 := p_pnd_attribute7;
565 l_rec.pnd_attribute8 := p_pnd_attribute8;
566 l_rec.pnd_attribute9 := p_pnd_attribute9;
567 l_rec.pnd_attribute10 := p_pnd_attribute10;
568 l_rec.pnd_attribute11 := p_pnd_attribute11;
569 l_rec.pnd_attribute12 := p_pnd_attribute12;
570 l_rec.pnd_attribute13 := p_pnd_attribute13;
571 l_rec.pnd_attribute14 := p_pnd_attribute14;
572 l_rec.pnd_attribute15 := p_pnd_attribute15;
573 l_rec.pnd_attribute16 := p_pnd_attribute16;
574 l_rec.pnd_attribute17 := p_pnd_attribute17;
575 l_rec.pnd_attribute18 := p_pnd_attribute18;
576 l_rec.pnd_attribute19 := p_pnd_attribute19;
577 l_rec.pnd_attribute20 := p_pnd_attribute20;
578 l_rec.pnd_attribute21 := p_pnd_attribute21;
579 l_rec.pnd_attribute22 := p_pnd_attribute22;
580 l_rec.pnd_attribute23 := p_pnd_attribute23;
581 l_rec.pnd_attribute24 := p_pnd_attribute24;
582 l_rec.pnd_attribute25 := p_pnd_attribute25;
583 l_rec.pnd_attribute26 := p_pnd_attribute26;
584 l_rec.pnd_attribute27 := p_pnd_attribute27;
585 l_rec.pnd_attribute28 := p_pnd_attribute28;
586 l_rec.pnd_attribute29 := p_pnd_attribute29;
587 l_rec.pnd_attribute30 := p_pnd_attribute30;
588 l_rec.request_id := p_request_id;
589 l_rec.program_application_id := p_program_application_id;
590 l_rec.program_id := p_program_id;
591 l_rec.program_update_date := p_program_update_date;
592 l_rec.object_version_number := p_object_version_number;
593 --
594 -- Return the plsql record structure.
595 --
596 hr_utility.set_location(' Leaving:'||l_proc, 10);
597 Return(l_rec);
598 --
599 End convert_args;
600 --
601 end ben_pnd_shd;