[Home] [Help]
PACKAGE BODY: APPS.BEN_PCX_SHD
Source
1 Package Body ben_pcx_shd as
2 /* $Header: bepcxrhi.pkb 120.0 2005/05/28 10:21:17 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pcx_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_BNF_CTFN_FK1') 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_PL_BNF_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_pl_bnf_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_bnf_ctfn_id,
71 effective_start_date,
72 effective_end_date,
73 pl_id,
74 bnf_ctfn_typ_cd,
75 lack_ctfn_sspnd_enrt_flag,
76 pfd_flag,
77 rqd_flag,
78 ctfn_rqd_when_rl,
79 bnf_typ_cd,
80 rlshp_typ_cd,
81 object_version_number,
82 business_group_id,
83 pcx_attribute_category,
84 pcx_attribute1,
85 pcx_attribute2,
86 pcx_attribute3,
87 pcx_attribute4,
88 pcx_attribute5,
89 pcx_attribute6,
90 pcx_attribute7,
91 pcx_attribute8,
92 pcx_attribute9,
93 pcx_attribute10,
94 pcx_attribute11,
95 pcx_attribute12,
96 pcx_attribute13,
97 pcx_attribute14,
98 pcx_attribute15,
99 pcx_attribute16,
100 pcx_attribute17,
101 pcx_attribute18,
102 pcx_attribute19,
103 pcx_attribute20,
104 pcx_attribute21,
105 pcx_attribute22,
106 pcx_attribute23,
107 pcx_attribute24,
108 pcx_attribute25,
109 pcx_attribute26,
110 pcx_attribute27,
111 pcx_attribute28,
112 pcx_attribute29,
113 pcx_attribute30
114 from ben_pl_bnf_ctfn_f
115 where pl_bnf_ctfn_id = p_pl_bnf_ctfn_id
116 and p_effective_date
117 between effective_start_date and effective_end_date;
118 --
119 l_proc varchar2(72) := g_package||'api_updating';
120 l_fct_ret boolean;
121 --
122 Begin
123 hr_utility.set_location('Entering:'||l_proc, 5);
124 --
125 If (p_effective_date is null or
126 p_pl_bnf_ctfn_id is null or
127 p_object_version_number is null) Then
128 --
129 -- One of the primary key arguments is null therefore we must
130 -- set the returning function value to false
131 --
132 l_fct_ret := false;
133 Else
134 If (p_pl_bnf_ctfn_id = g_old_rec.pl_bnf_ctfn_id and
135 p_object_version_number = g_old_rec.object_version_number) Then
136 hr_utility.set_location(l_proc, 10);
137 --
138 -- The g_old_rec is current therefore we must
139 -- set the returning function to true
140 --
141 l_fct_ret := true;
142 Else
143 --
144 -- Select the current row
145 --
146 Open C_Sel1;
147 Fetch C_Sel1 Into g_old_rec;
148 If C_Sel1%notfound Then
149 Close C_Sel1;
150 --
151 -- The primary key is invalid therefore we must error
152 --
153 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
154 fnd_message.raise_error;
155 End If;
156 Close C_Sel1;
157 If (p_object_version_number <> g_old_rec.object_version_number) Then
158 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
159 fnd_message.raise_error;
160 End If;
161 hr_utility.set_location(l_proc, 15);
162 l_fct_ret := true;
163 End If;
164 End If;
165 hr_utility.set_location(' Leaving:'||l_proc, 20);
166 Return (l_fct_ret);
167 --
168 End api_updating;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |--------------------------< find_dt_del_modes >---------------------------|
172 -- ----------------------------------------------------------------------------
173 Procedure find_dt_del_modes
174 (p_effective_date in date,
175 p_base_key_value in number,
176 p_zap out nocopy boolean,
177 p_delete out nocopy boolean,
178 p_future_change out nocopy boolean,
179 p_delete_next_change out nocopy boolean) is
180 --
181 l_proc varchar2(72) := g_package||'find_dt_del_modes';
182 --
183 l_parent_key_value1 number;
184 --
185 Cursor C_Sel1 Is
186 select t.pl_id
187 from ben_pl_bnf_ctfn_f t
188 where t.pl_bnf_ctfn_id = p_base_key_value
189 and p_effective_date
190 between t.effective_start_date and t.effective_end_date;
191 --
192 Begin
193 hr_utility.set_location('Entering:'||l_proc, 5);
194 Open C_Sel1;
195 Fetch C_Sel1 Into l_parent_key_value1;
196 If C_Sel1%notfound then
197 Close C_Sel1;
198 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
199 fnd_message.set_token('PROCEDURE', l_proc);
200 fnd_message.set_token('STEP','10');
201 fnd_message.raise_error;
202 End If;
203 Close C_Sel1;
204 --
205 -- Call the corresponding datetrack api
206 --
207 dt_api.find_dt_del_modes
208 (p_effective_date => p_effective_date,
209 p_base_table_name => 'ben_pl_bnf_ctfn_f',
210 p_base_key_column => 'pl_bnf_ctfn_id',
211 p_base_key_value => p_base_key_value,
212 p_parent_table_name1 => 'ben_pl_f',
213 p_parent_key_column1 => 'pl_id',
214 p_parent_key_value1 => l_parent_key_value1,
215 p_zap => p_zap,
216 p_delete => p_delete,
217 p_future_change => p_future_change,
218 p_delete_next_change => p_delete_next_change);
219 --
220 hr_utility.set_location(' Leaving:'||l_proc, 10);
221 End find_dt_del_modes;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |--------------------------< find_dt_upd_modes >---------------------------|
225 -- ----------------------------------------------------------------------------
226 Procedure find_dt_upd_modes
227 (p_effective_date in date,
228 p_base_key_value in number,
229 p_correction out nocopy boolean,
230 p_update out nocopy boolean,
231 p_update_override out nocopy boolean,
232 p_update_change_insert out nocopy boolean) is
233 --
234 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
235 --
236 Begin
237 hr_utility.set_location('Entering:'||l_proc, 5);
238 --
239 -- Call the corresponding datetrack api
240 --
241 dt_api.find_dt_upd_modes
242 (p_effective_date => p_effective_date,
243 p_base_table_name => 'ben_pl_bnf_ctfn_f',
244 p_base_key_column => 'pl_bnf_ctfn_id',
245 p_base_key_value => p_base_key_value,
246 p_correction => p_correction,
247 p_update => p_update,
248 p_update_override => p_update_override,
249 p_update_change_insert => p_update_change_insert);
250 --
251 hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End find_dt_upd_modes;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |------------------------< upd_effective_end_date >------------------------|
256 -- ----------------------------------------------------------------------------
257 Procedure upd_effective_end_date
258 (p_effective_date in date,
259 p_base_key_value in number,
260 p_new_effective_end_date in date,
261 p_validation_start_date in date,
262 p_validation_end_date in date,
263 p_object_version_number out nocopy number) is
264 --
265 l_proc varchar2(72) := g_package||'upd_effective_end_date';
266 l_object_version_number number;
267 --
268 Begin
269 hr_utility.set_location('Entering:'||l_proc, 5);
270 --
271 -- Because we are updating a row we must get the next object
272 -- version number.
273 --
274 l_object_version_number :=
275 dt_api.get_object_version_number
276 (p_base_table_name => 'ben_pl_bnf_ctfn_f',
277 p_base_key_column => 'pl_bnf_ctfn_id',
278 p_base_key_value => p_base_key_value);
279 --
280 hr_utility.set_location(l_proc, 10);
281 g_api_dml := true; -- Set the api dml status
282 --
283 -- Update the specified datetrack row setting the effective
284 -- end date to the specified new effective end date.
285 --
286 update ben_pl_bnf_ctfn_f t
287 set t.effective_end_date = p_new_effective_end_date,
288 t.object_version_number = l_object_version_number
289 where t.pl_bnf_ctfn_id = p_base_key_value
290 and p_effective_date
291 between t.effective_start_date and t.effective_end_date;
292 --
293 g_api_dml := false; -- Unset the api dml status
294 p_object_version_number := l_object_version_number;
295 hr_utility.set_location(' Leaving:'||l_proc, 15);
296 --
297 Exception
298 When Others Then
299 g_api_dml := false; -- Unset the api dml status
300 Raise;
301 End upd_effective_end_date;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------------< lck >----------------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure lck
307 (p_effective_date in date,
308 p_datetrack_mode in varchar2,
309 p_pl_bnf_ctfn_id in number,
310 p_object_version_number in number,
311 p_validation_start_date out nocopy date,
312 p_validation_end_date out nocopy date) is
313 --
314 l_proc varchar2(72) := g_package||'lck';
315 l_validation_start_date date;
316 l_validation_end_date date;
317 l_object_invalid exception;
318 l_argument varchar2(30);
319 --
320 -- Cursor C_Sel1 selects the current locked row as of session date
321 -- ensuring that the object version numbers match.
322 --
323 Cursor C_Sel1 is
324 select
325 pl_bnf_ctfn_id,
326 effective_start_date,
327 effective_end_date,
328 pl_id,
329 bnf_ctfn_typ_cd,
330 lack_ctfn_sspnd_enrt_flag,
331 pfd_flag,
332 rqd_flag,
333 ctfn_rqd_when_rl,
334 bnf_typ_cd,
335 rlshp_typ_cd,
336 object_version_number,
337 business_group_id,
338 pcx_attribute_category,
339 pcx_attribute1,
340 pcx_attribute2,
341 pcx_attribute3,
342 pcx_attribute4,
343 pcx_attribute5,
344 pcx_attribute6,
345 pcx_attribute7,
346 pcx_attribute8,
347 pcx_attribute9,
348 pcx_attribute10,
349 pcx_attribute11,
350 pcx_attribute12,
351 pcx_attribute13,
352 pcx_attribute14,
353 pcx_attribute15,
354 pcx_attribute16,
355 pcx_attribute17,
356 pcx_attribute18,
357 pcx_attribute19,
358 pcx_attribute20,
359 pcx_attribute21,
360 pcx_attribute22,
361 pcx_attribute23,
362 pcx_attribute24,
363 pcx_attribute25,
364 pcx_attribute26,
365 pcx_attribute27,
366 pcx_attribute28,
367 pcx_attribute29,
368 pcx_attribute30
369 from ben_pl_bnf_ctfn_f
370 where pl_bnf_ctfn_id = p_pl_bnf_ctfn_id
371 and p_effective_date
372 between effective_start_date and effective_end_date
373 for update nowait;
374 --
375 --
376 --
377 Begin
378 hr_utility.set_location('Entering:'||l_proc, 5);
379 --
380 -- Ensure that all the mandatory arguments are not null
381 --
382 hr_api.mandatory_arg_error(p_api_name => l_proc,
383 p_argument => 'effective_date',
384 p_argument_value => p_effective_date);
385 --
386 hr_api.mandatory_arg_error(p_api_name => l_proc,
387 p_argument => 'datetrack_mode',
388 p_argument_value => p_datetrack_mode);
389 --
390 hr_api.mandatory_arg_error(p_api_name => l_proc,
391 p_argument => 'pl_bnf_ctfn_id',
392 p_argument_value => p_pl_bnf_ctfn_id);
393 --
394 hr_api.mandatory_arg_error(p_api_name => l_proc,
395 p_argument => 'object_version_number',
396 p_argument_value => p_object_version_number);
397 --
398 -- Check to ensure the datetrack mode is not INSERT.
399 --
400 If (p_datetrack_mode <> 'INSERT') then
401 --
402 -- We must select and lock the current row.
403 --
404 Open C_Sel1;
405 Fetch C_Sel1 Into g_old_rec;
406 If C_Sel1%notfound then
407 Close C_Sel1;
408 --
409 -- The primary key is invalid therefore we must error
410 --
411 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
412 fnd_message.raise_error;
413 End If;
414 Close C_Sel1;
415 If (p_object_version_number <> g_old_rec.object_version_number) Then
416 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
417 fnd_message.raise_error;
418 End If;
419 hr_utility.set_location(l_proc, 15);
420 --
421 --
422 -- Validate the datetrack mode mode getting the validation start
423 -- and end dates for the specified datetrack operation.
424 --
425 dt_api.validate_dt_mode
426 (p_effective_date => p_effective_date,
427 p_datetrack_mode => p_datetrack_mode,
428 p_base_table_name => 'ben_pl_bnf_ctfn_f',
429 p_base_key_column => 'pl_bnf_ctfn_id',
430 p_base_key_value => p_pl_bnf_ctfn_id,
431 p_parent_table_name1 => 'ben_pl_f',
432 p_parent_key_column1 => 'pl_id',
433 p_parent_key_value1 => g_old_rec.pl_id,
434 p_enforce_foreign_locking => true,
435 p_validation_start_date => l_validation_start_date,
439 -- We are doing a datetrack 'INSERT' which is illegal within this
436 p_validation_end_date => l_validation_end_date);
437 Else
438 --
440 -- procedure therefore we must error (note: to lck on insert the
441 -- private procedure ins_lck should be called).
442 --
443 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
444 fnd_message.set_token('PROCEDURE', l_proc);
445 fnd_message.set_token('STEP','20');
446 fnd_message.raise_error;
447 End If;
448 --
449 -- Set the validation start and end date OUT arguments
450 --
451 p_validation_start_date := l_validation_start_date;
452 p_validation_end_date := l_validation_end_date;
453 --
454 hr_utility.set_location(' Leaving:'||l_proc, 30);
455 --
456 -- We need to trap the ORA LOCK exception
457 --
458 Exception
459 When HR_Api.Object_Locked then
460 --
461 -- The object is locked therefore we need to supply a meaningful
462 -- error message.
463 --
464 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
465 fnd_message.set_token('TABLE_NAME', 'ben_pl_bnf_ctfn_f');
466 fnd_message.raise_error;
467 When l_object_invalid then
468 --
469 -- The object doesn't exist or is invalid
470 --
471 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
472 fnd_message.set_token('TABLE_NAME', 'ben_pl_bnf_ctfn_f');
473 fnd_message.raise_error;
474 End lck;
475 --
476 -- ----------------------------------------------------------------------------
477 -- |-----------------------------< convert_args >-----------------------------|
478 -- ----------------------------------------------------------------------------
479 Function convert_args
480 (
481 p_pl_bnf_ctfn_id in number,
482 p_effective_start_date in date,
483 p_effective_end_date in date,
484 p_pl_id in number,
485 p_bnf_ctfn_typ_cd in varchar2,
486 p_lack_ctfn_sspnd_enrt_flag in varchar2,
487 p_pfd_flag in varchar2,
488 p_rqd_flag in varchar2,
489 p_ctfn_rqd_when_rl in number,
490 p_bnf_typ_cd in varchar2,
491 p_rlshp_typ_cd in varchar2,
492 p_object_version_number in number,
493 p_business_group_id in number,
494 p_pcx_attribute_category in varchar2,
495 p_pcx_attribute1 in varchar2,
496 p_pcx_attribute2 in varchar2,
497 p_pcx_attribute3 in varchar2,
498 p_pcx_attribute4 in varchar2,
499 p_pcx_attribute5 in varchar2,
500 p_pcx_attribute6 in varchar2,
501 p_pcx_attribute7 in varchar2,
502 p_pcx_attribute8 in varchar2,
503 p_pcx_attribute9 in varchar2,
504 p_pcx_attribute10 in varchar2,
505 p_pcx_attribute11 in varchar2,
506 p_pcx_attribute12 in varchar2,
507 p_pcx_attribute13 in varchar2,
508 p_pcx_attribute14 in varchar2,
509 p_pcx_attribute15 in varchar2,
510 p_pcx_attribute16 in varchar2,
511 p_pcx_attribute17 in varchar2,
512 p_pcx_attribute18 in varchar2,
513 p_pcx_attribute19 in varchar2,
514 p_pcx_attribute20 in varchar2,
515 p_pcx_attribute21 in varchar2,
516 p_pcx_attribute22 in varchar2,
517 p_pcx_attribute23 in varchar2,
518 p_pcx_attribute24 in varchar2,
519 p_pcx_attribute25 in varchar2,
520 p_pcx_attribute26 in varchar2,
521 p_pcx_attribute27 in varchar2,
522 p_pcx_attribute28 in varchar2,
523 p_pcx_attribute29 in varchar2,
524 p_pcx_attribute30 in varchar2
525 )
526 Return g_rec_type is
527 --
528 l_rec g_rec_type;
529 l_proc varchar2(72) := g_package||'convert_args';
530 --
531 Begin
532 --
533 hr_utility.set_location('Entering:'||l_proc, 5);
534 --
535 -- Convert arguments into local l_rec structure.
536 --
537 l_rec.pl_bnf_ctfn_id := p_pl_bnf_ctfn_id;
538 l_rec.effective_start_date := p_effective_start_date;
539 l_rec.effective_end_date := p_effective_end_date;
540 l_rec.pl_id := p_pl_id;
541 l_rec.bnf_ctfn_typ_cd := p_bnf_ctfn_typ_cd;
542 l_rec.lack_ctfn_sspnd_enrt_flag := p_lack_ctfn_sspnd_enrt_flag;
543 l_rec.pfd_flag := p_pfd_flag;
544 l_rec.rqd_flag := p_rqd_flag;
545 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl;
546 l_rec.bnf_typ_cd := p_bnf_typ_cd;
547 l_rec.rlshp_typ_cd := p_rlshp_typ_cd;
548 l_rec.object_version_number := p_object_version_number;
549 l_rec.business_group_id := p_business_group_id;
550 l_rec.pcx_attribute_category := p_pcx_attribute_category;
551 l_rec.pcx_attribute1 := p_pcx_attribute1;
552 l_rec.pcx_attribute2 := p_pcx_attribute2;
553 l_rec.pcx_attribute3 := p_pcx_attribute3;
554 l_rec.pcx_attribute4 := p_pcx_attribute4;
555 l_rec.pcx_attribute5 := p_pcx_attribute5;
556 l_rec.pcx_attribute6 := p_pcx_attribute6;
557 l_rec.pcx_attribute7 := p_pcx_attribute7;
558 l_rec.pcx_attribute8 := p_pcx_attribute8;
559 l_rec.pcx_attribute9 := p_pcx_attribute9;
560 l_rec.pcx_attribute10 := p_pcx_attribute10;
561 l_rec.pcx_attribute11 := p_pcx_attribute11;
562 l_rec.pcx_attribute12 := p_pcx_attribute12;
563 l_rec.pcx_attribute13 := p_pcx_attribute13;
564 l_rec.pcx_attribute14 := p_pcx_attribute14;
565 l_rec.pcx_attribute15 := p_pcx_attribute15;
566 l_rec.pcx_attribute16 := p_pcx_attribute16;
567 l_rec.pcx_attribute17 := p_pcx_attribute17;
568 l_rec.pcx_attribute18 := p_pcx_attribute18;
569 l_rec.pcx_attribute19 := p_pcx_attribute19;
570 l_rec.pcx_attribute20 := p_pcx_attribute20;
571 l_rec.pcx_attribute21 := p_pcx_attribute21;
572 l_rec.pcx_attribute22 := p_pcx_attribute22;
573 l_rec.pcx_attribute23 := p_pcx_attribute23;
574 l_rec.pcx_attribute24 := p_pcx_attribute24;
575 l_rec.pcx_attribute25 := p_pcx_attribute25;
576 l_rec.pcx_attribute26 := p_pcx_attribute26;
577 l_rec.pcx_attribute27 := p_pcx_attribute27;
578 l_rec.pcx_attribute28 := p_pcx_attribute28;
579 l_rec.pcx_attribute29 := p_pcx_attribute29;
580 l_rec.pcx_attribute30 := p_pcx_attribute30;
581 --
582 -- Return the plsql record structure.
583 --
584 hr_utility.set_location(' Leaving:'||l_proc, 10);
585 Return(l_rec);
586 --
587 End convert_args;
588 --
589 end ben_pcx_shd;