[Home] [Help]
PACKAGE BODY: APPS.BEN_PGC_SHD
Source
1 Package Body ben_pgc_shd as
2 /* $Header: bepgcrhi.pkb 115.12 2003/01/01 00:01:25 mmudigon ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pgc_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_PGM_CTFN_FK2') 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_PGM_CTFN_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_pgm_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 pgm_dpnt_cvg_ctfn_id,
71 effective_start_date,
72 effective_end_date,
73 business_group_id,
74 pgm_id,
75 lack_ctfn_sspnd_enrt_flag,
76 ctfn_rqd_when_rl,
77 pfd_flag,
78 dpnt_cvg_ctfn_typ_cd,
79 rqd_flag,
80 rlshp_typ_cd,
81 pgc_attribute_category,
82 pgc_attribute1,
83 pgc_attribute2,
84 pgc_attribute3,
85 pgc_attribute4,
86 pgc_attribute5,
87 pgc_attribute6,
88 pgc_attribute7,
89 pgc_attribute8,
90 pgc_attribute9,
91 pgc_attribute10,
92 pgc_attribute11,
93 pgc_attribute12,
94 pgc_attribute13,
95 pgc_attribute14,
96 pgc_attribute15,
97 pgc_attribute16,
98 pgc_attribute17,
99 pgc_attribute18,
100 pgc_attribute19,
101 pgc_attribute20,
102 pgc_attribute21,
103 pgc_attribute22,
104 pgc_attribute23,
105 pgc_attribute24,
106 pgc_attribute25,
107 pgc_attribute26,
108 pgc_attribute27,
109 pgc_attribute28,
110 pgc_attribute29,
111 pgc_attribute30,
112 object_version_number
113 from ben_pgm_dpnt_cvg_ctfn_f
114 where pgm_dpnt_cvg_ctfn_id = p_pgm_dpnt_cvg_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_pgm_dpnt_cvg_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_pgm_dpnt_cvg_ctfn_id = g_old_rec.pgm_dpnt_cvg_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 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
153 fnd_message.raise_error;
154 End If;
155 Close C_Sel1;
156 If (p_object_version_number <> g_old_rec.object_version_number) Then
157 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
158 fnd_message.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 --
185 Cursor C_Sel1 Is
186 select t.ctfn_rqd_when_rl,
187 t.pgm_id
188 from ben_pgm_dpnt_cvg_ctfn_f t
189 where t.pgm_dpnt_cvg_ctfn_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 l_parent_key_value2;
198 If C_Sel1%notfound then
199 Close C_Sel1;
200 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
201 fnd_message.set_token('PROCEDURE', l_proc);
202 fnd_message.set_token('STEP','10');
203 fnd_message.raise_error;
204 End If;
205 Close C_Sel1;
206 --
207 -- Call the corresponding datetrack api
208 --
209 dt_api.find_dt_del_modes
210 (p_effective_date => p_effective_date,
211 p_base_table_name => 'ben_pgm_dpnt_cvg_ctfn_f',
212 p_base_key_column => 'pgm_dpnt_cvg_ctfn_id',
213 p_base_key_value => p_base_key_value,
214 p_parent_table_name1 => 'ff_formulas_f',
215 p_parent_key_column1 => 'formula_id',
216 p_parent_key_value1 => l_parent_key_value1,
217 p_parent_table_name2 => 'ben_pgm_f',
218 p_parent_key_column2 => 'pgm_id',
219 p_parent_key_value2 => l_parent_key_value2,
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_pgm_dpnt_cvg_ctfn_f',
249 p_base_key_column => 'pgm_dpnt_cvg_ctfn_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_pgm_dpnt_cvg_ctfn_f',
282 p_base_key_column => 'pgm_dpnt_cvg_ctfn_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_pgm_dpnt_cvg_ctfn_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.pgm_dpnt_cvg_ctfn_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_pgm_dpnt_cvg_ctfn_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 pgm_dpnt_cvg_ctfn_id,
331 effective_start_date,
332 effective_end_date,
333 business_group_id,
334 pgm_id,
335 lack_ctfn_sspnd_enrt_flag,
336 ctfn_rqd_when_rl,
337 pfd_flag,
338 dpnt_cvg_ctfn_typ_cd,
339 rqd_flag,
340 rlshp_typ_cd,
341 pgc_attribute_category,
342 pgc_attribute1,
343 pgc_attribute2,
344 pgc_attribute3,
345 pgc_attribute4,
346 pgc_attribute5,
347 pgc_attribute6,
348 pgc_attribute7,
349 pgc_attribute8,
350 pgc_attribute9,
351 pgc_attribute10,
352 pgc_attribute11,
353 pgc_attribute12,
354 pgc_attribute13,
355 pgc_attribute14,
356 pgc_attribute15,
357 pgc_attribute16,
358 pgc_attribute17,
359 pgc_attribute18,
360 pgc_attribute19,
361 pgc_attribute20,
362 pgc_attribute21,
363 pgc_attribute22,
364 pgc_attribute23,
365 pgc_attribute24,
366 pgc_attribute25,
367 pgc_attribute26,
368 pgc_attribute27,
369 pgc_attribute28,
370 pgc_attribute29,
371 pgc_attribute30,
372 object_version_number
373 from ben_pgm_dpnt_cvg_ctfn_f
374 where pgm_dpnt_cvg_ctfn_id = p_pgm_dpnt_cvg_ctfn_id
375 and p_effective_date
376 between effective_start_date and effective_end_date
377 for update nowait;
378 --
379 --
380 --
381 Begin
382 hr_utility.set_location('Entering:'||l_proc, 5);
383 --
384 -- Ensure that all the mandatory arguments are not null
385 --
386 hr_api.mandatory_arg_error(p_api_name => l_proc,
387 p_argument => 'effective_date',
388 p_argument_value => p_effective_date);
389 --
390 hr_api.mandatory_arg_error(p_api_name => l_proc,
391 p_argument => 'datetrack_mode',
392 p_argument_value => p_datetrack_mode);
393 --
394 hr_api.mandatory_arg_error(p_api_name => l_proc,
395 p_argument => 'pgm_dpnt_cvg_ctfn_id',
396 p_argument_value => p_pgm_dpnt_cvg_ctfn_id);
397 --
398 hr_api.mandatory_arg_error(p_api_name => l_proc,
399 p_argument => 'object_version_number',
400 p_argument_value => p_object_version_number);
401 --
402 -- Check to ensure the datetrack mode is not INSERT.
403 --
404 If (p_datetrack_mode <> 'INSERT') then
405 --
406 -- We must select and lock the current row.
407 --
408 Open C_Sel1;
409 Fetch C_Sel1 Into g_old_rec;
410 If C_Sel1%notfound then
411 Close C_Sel1;
412 --
413 -- The primary key is invalid therefore we must error
414 --
415 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
416 fnd_message.raise_error;
417 End If;
418 Close C_Sel1;
419 If (p_object_version_number <> g_old_rec.object_version_number) Then
420 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
421 fnd_message.raise_error;
422 End If;
423 hr_utility.set_location(l_proc, 15);
424 --
425 --
426 -- Validate the datetrack mode mode getting the validation start
427 -- and end dates for the specified datetrack operation.
428 --
429 dt_api.validate_dt_mode
430 (p_effective_date => p_effective_date,
431 p_datetrack_mode => p_datetrack_mode,
432 p_base_table_name => 'ben_pgm_dpnt_cvg_ctfn_f',
433 p_base_key_column => 'pgm_dpnt_cvg_ctfn_id',
434 p_base_key_value => p_pgm_dpnt_cvg_ctfn_id,
435 p_parent_table_name1 => 'ff_formulas_f',
436 p_parent_key_column1 => 'formula_id',
437 p_parent_key_value1 => g_old_rec.ctfn_rqd_when_rl,
438 p_parent_table_name2 => 'ben_pgm_f',
439 p_parent_key_column2 => 'pgm_id',
440 p_parent_key_value2 => g_old_rec.pgm_id,
441 p_enforce_foreign_locking => true,
442 p_validation_start_date => l_validation_start_date,
446 -- We are doing a datetrack 'INSERT' which is illegal within this
443 p_validation_end_date => l_validation_end_date);
444 Else
445 --
447 -- procedure therefore we must error (note: to lck on insert the
448 -- private procedure ins_lck should be called).
449 --
450 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
451 fnd_message.set_token('PROCEDURE', l_proc);
452 fnd_message.set_token('STEP','20');
453 fnd_message.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 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
472 fnd_message.set_token('TABLE_NAME', 'ben_pgm_dpnt_cvg_ctfn_f');
473 fnd_message.raise_error;
474 When l_object_invalid then
475 --
476 -- The object doesn't exist or is invalid
477 --
478 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
479 fnd_message.set_token('TABLE_NAME', 'ben_pgm_dpnt_cvg_ctfn_f');
480 fnd_message.raise_error;
481 End lck;
482 --
483 -- ----------------------------------------------------------------------------
484 -- |-----------------------------< convert_args >-----------------------------|
485 -- ----------------------------------------------------------------------------
486 Function convert_args
487 (
488 p_pgm_dpnt_cvg_ctfn_id in number,
489 p_effective_start_date in date,
490 p_effective_end_date in date,
491 p_business_group_id in number,
492 p_pgm_id in number,
493 p_lack_ctfn_sspnd_enrt_flag in varchar2,
494 p_ctfn_rqd_when_rl in number,
495 p_pfd_flag in varchar2,
496 p_dpnt_cvg_ctfn_typ_cd in varchar2,
497 p_rqd_flag in varchar2,
498 p_rlshp_typ_cd in varchar2,
499 p_pgc_attribute_category in varchar2,
500 p_pgc_attribute1 in varchar2,
501 p_pgc_attribute2 in varchar2,
502 p_pgc_attribute3 in varchar2,
503 p_pgc_attribute4 in varchar2,
504 p_pgc_attribute5 in varchar2,
505 p_pgc_attribute6 in varchar2,
506 p_pgc_attribute7 in varchar2,
507 p_pgc_attribute8 in varchar2,
508 p_pgc_attribute9 in varchar2,
509 p_pgc_attribute10 in varchar2,
510 p_pgc_attribute11 in varchar2,
511 p_pgc_attribute12 in varchar2,
512 p_pgc_attribute13 in varchar2,
513 p_pgc_attribute14 in varchar2,
514 p_pgc_attribute15 in varchar2,
515 p_pgc_attribute16 in varchar2,
516 p_pgc_attribute17 in varchar2,
517 p_pgc_attribute18 in varchar2,
518 p_pgc_attribute19 in varchar2,
519 p_pgc_attribute20 in varchar2,
520 p_pgc_attribute21 in varchar2,
521 p_pgc_attribute22 in varchar2,
522 p_pgc_attribute23 in varchar2,
523 p_pgc_attribute24 in varchar2,
524 p_pgc_attribute25 in varchar2,
525 p_pgc_attribute26 in varchar2,
526 p_pgc_attribute27 in varchar2,
527 p_pgc_attribute28 in varchar2,
528 p_pgc_attribute29 in varchar2,
529 p_pgc_attribute30 in varchar2,
530 p_object_version_number in number
531 )
532 Return g_rec_type is
533 --
534 l_rec g_rec_type;
535 l_proc varchar2(72) := g_package||'convert_args';
536 --
537 Begin
538 --
539 hr_utility.set_location('Entering:'||l_proc, 5);
540 --
541 -- Convert arguments into local l_rec structure.
542 --
543 l_rec.pgm_dpnt_cvg_ctfn_id := p_pgm_dpnt_cvg_ctfn_id;
544 l_rec.effective_start_date := p_effective_start_date;
545 l_rec.effective_end_date := p_effective_end_date;
546 l_rec.business_group_id := p_business_group_id;
547 l_rec.pgm_id := p_pgm_id;
548 l_rec.lack_ctfn_sspnd_enrt_flag := p_lack_ctfn_sspnd_enrt_flag;
549 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl;
550 l_rec.pfd_flag := p_pfd_flag;
551 l_rec.dpnt_cvg_ctfn_typ_cd := p_dpnt_cvg_ctfn_typ_cd;
552 l_rec.rqd_flag := p_rqd_flag;
553 l_rec.rlshp_typ_cd := p_rlshp_typ_cd;
554 l_rec.pgc_attribute_category := p_pgc_attribute_category;
555 l_rec.pgc_attribute1 := p_pgc_attribute1;
556 l_rec.pgc_attribute2 := p_pgc_attribute2;
557 l_rec.pgc_attribute3 := p_pgc_attribute3;
558 l_rec.pgc_attribute4 := p_pgc_attribute4;
559 l_rec.pgc_attribute5 := p_pgc_attribute5;
560 l_rec.pgc_attribute6 := p_pgc_attribute6;
561 l_rec.pgc_attribute7 := p_pgc_attribute7;
562 l_rec.pgc_attribute8 := p_pgc_attribute8;
563 l_rec.pgc_attribute9 := p_pgc_attribute9;
564 l_rec.pgc_attribute10 := p_pgc_attribute10;
565 l_rec.pgc_attribute11 := p_pgc_attribute11;
566 l_rec.pgc_attribute12 := p_pgc_attribute12;
567 l_rec.pgc_attribute13 := p_pgc_attribute13;
568 l_rec.pgc_attribute14 := p_pgc_attribute14;
569 l_rec.pgc_attribute15 := p_pgc_attribute15;
570 l_rec.pgc_attribute16 := p_pgc_attribute16;
571 l_rec.pgc_attribute17 := p_pgc_attribute17;
572 l_rec.pgc_attribute18 := p_pgc_attribute18;
573 l_rec.pgc_attribute19 := p_pgc_attribute19;
574 l_rec.pgc_attribute20 := p_pgc_attribute20;
575 l_rec.pgc_attribute21 := p_pgc_attribute21;
576 l_rec.pgc_attribute22 := p_pgc_attribute22;
577 l_rec.pgc_attribute23 := p_pgc_attribute23;
578 l_rec.pgc_attribute24 := p_pgc_attribute24;
579 l_rec.pgc_attribute25 := p_pgc_attribute25;
580 l_rec.pgc_attribute26 := p_pgc_attribute26;
581 l_rec.pgc_attribute27 := p_pgc_attribute27;
582 l_rec.pgc_attribute28 := p_pgc_attribute28;
583 l_rec.pgc_attribute29 := p_pgc_attribute29;
584 l_rec.pgc_attribute30 := p_pgc_attribute30;
585 l_rec.object_version_number := p_object_version_number;
586 --
587 -- Return the plsql record structure.
588 --
589 hr_utility.set_location(' Leaving:'||l_proc, 10);
590 Return(l_rec);
591 --
592 End convert_args;
593 --
594 end ben_pgc_shd;