[Home] [Help]
PACKAGE BODY: APPS.BEN_PCM_SHD
Source
1 Package Body ben_pcm_shd as
2 /* $Header: bepcmrhi.pkb 115.13 2002/12/16 11:58:35 vsethi ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pcm_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_PER_CM_F_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_PER_CM_F_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_per_cm_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 per_cm_id,
71 effective_start_date,
72 effective_end_date,
73 lf_evt_ocrd_dt,
74 rqstbl_untl_dt,
75 ler_id,
76 per_in_ler_id,
77 prtt_enrt_actn_id,
78 person_id,
79 bnf_person_id,
80 dpnt_person_id,
81 cm_typ_id,
82 business_group_id,
83 pcm_attribute_category,
84 pcm_attribute1,
85 pcm_attribute2,
86 pcm_attribute3,
87 pcm_attribute4,
88 pcm_attribute5,
89 pcm_attribute6,
90 pcm_attribute7,
91 pcm_attribute8,
92 pcm_attribute9,
93 pcm_attribute10,
94 pcm_attribute11,
95 pcm_attribute12,
96 pcm_attribute13,
97 pcm_attribute14,
98 pcm_attribute15,
99 pcm_attribute16,
100 pcm_attribute17,
101 pcm_attribute18,
102 pcm_attribute19,
103 pcm_attribute20,
104 pcm_attribute21,
105 pcm_attribute22,
106 pcm_attribute23,
107 pcm_attribute24,
108 pcm_attribute25,
109 pcm_attribute26,
110 pcm_attribute27,
111 pcm_attribute28,
112 pcm_attribute29,
113 pcm_attribute30,
114 request_id,
115 program_application_id,
116 program_id,
117 program_update_date,
118 object_version_number
119 from ben_per_cm_f
120 where per_cm_id = p_per_cm_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_per_cm_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_per_cm_id = g_old_rec.per_cm_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 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
159 fnd_message.raise_error;
160 End If;
161 Close C_Sel1;
162 If (p_object_version_number <> g_old_rec.object_version_number) Then
163 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
164 fnd_message.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 l_parent_key_value2 number;
190 --
191 Cursor C_Sel1 Is
192 select t.cm_typ_id,
193 t.prtt_enrt_actn_id
194 from ben_per_cm_f t
195 where t.per_cm_id = p_base_key_value
196 and p_effective_date
197 between t.effective_start_date and t.effective_end_date;
198 --
199 Begin
200 hr_utility.set_location('Entering:'||l_proc, 5);
201 Open C_Sel1;
202 Fetch C_Sel1 Into l_parent_key_value1,
203 l_parent_key_value2;
204 If C_Sel1%notfound then
205 Close C_Sel1;
206 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
207 fnd_message.set_token('PROCEDURE', l_proc);
208 fnd_message.set_token('STEP','10');
209 fnd_message.raise_error;
210 End If;
211 Close C_Sel1;
212 --
213 -- Call the corresponding datetrack api
214 --
215 dt_api.find_dt_del_modes
216 (p_effective_date => p_effective_date,
217 p_base_table_name => 'ben_per_cm_f',
218 p_base_key_column => 'per_cm_id',
219 p_base_key_value => p_base_key_value,
220 p_parent_table_name1 => 'ben_cm_typ_f',
221 p_parent_key_column1 => 'cm_typ_id',
222 p_parent_key_value1 => l_parent_key_value1,
223 p_parent_table_name2 => 'ben_prtt_enrt_actn_f',
224 p_parent_key_column2 => 'prtt_enrt_actn_id',
225 p_parent_key_value2 => l_parent_key_value2,
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_per_cm_f',
255 p_base_key_column => 'per_cm_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_per_cm_f',
288 p_base_key_column => 'per_cm_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_per_cm_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.per_cm_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_per_cm_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 per_cm_id,
337 effective_start_date,
338 effective_end_date,
339 lf_evt_ocrd_dt,
340 rqstbl_untl_dt,
341 ler_id,
342 per_in_ler_id,
343 prtt_enrt_actn_id,
344 person_id,
345 bnf_person_id,
346 dpnt_person_id,
347 cm_typ_id,
348 business_group_id,
349 pcm_attribute_category,
350 pcm_attribute1,
351 pcm_attribute2,
352 pcm_attribute3,
353 pcm_attribute4,
354 pcm_attribute5,
355 pcm_attribute6,
356 pcm_attribute7,
357 pcm_attribute8,
358 pcm_attribute9,
359 pcm_attribute10,
360 pcm_attribute11,
361 pcm_attribute12,
362 pcm_attribute13,
363 pcm_attribute14,
364 pcm_attribute15,
365 pcm_attribute16,
366 pcm_attribute17,
367 pcm_attribute18,
368 pcm_attribute19,
369 pcm_attribute20,
370 pcm_attribute21,
371 pcm_attribute22,
372 pcm_attribute23,
373 pcm_attribute24,
374 pcm_attribute25,
375 pcm_attribute26,
376 pcm_attribute27,
377 pcm_attribute28,
378 pcm_attribute29,
379 pcm_attribute30,
380 request_id,
381 program_application_id,
382 program_id,
383 program_update_date,
384 object_version_number
385 from ben_per_cm_f
386 where per_cm_id = p_per_cm_id
387 and p_effective_date
388 between effective_start_date and effective_end_date
389 for update nowait;
390 --
391 --
392 --
393 Begin
394 hr_utility.set_location('Entering:'||l_proc, 5);
395 --
396 -- Ensure that all the mandatory arguments are not null
397 --
398 hr_api.mandatory_arg_error(p_api_name => l_proc,
399 p_argument => 'effective_date',
403 p_argument => 'datetrack_mode',
400 p_argument_value => p_effective_date);
401 --
402 hr_api.mandatory_arg_error(p_api_name => l_proc,
404 p_argument_value => p_datetrack_mode);
405 --
406 hr_api.mandatory_arg_error(p_api_name => l_proc,
407 p_argument => 'per_cm_id',
408 p_argument_value => p_per_cm_id);
409 --
410 hr_api.mandatory_arg_error(p_api_name => l_proc,
411 p_argument => 'object_version_number',
412 p_argument_value => p_object_version_number);
413 --
414 -- Check to ensure the datetrack mode is not INSERT.
415 --
416 If (p_datetrack_mode <> 'INSERT') then
417 --
418 -- We must select and lock the current row.
419 --
420 Open C_Sel1;
421 Fetch C_Sel1 Into g_old_rec;
422 If C_Sel1%notfound then
423 Close C_Sel1;
424 --
425 -- The primary key is invalid therefore we must error
426 --
427 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
428 fnd_message.raise_error;
429 End If;
430 Close C_Sel1;
431 If (p_object_version_number <> g_old_rec.object_version_number) Then
432 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
433 fnd_message.raise_error;
434 End If;
435 hr_utility.set_location(l_proc, 15);
436 --
437 --
438 -- Validate the datetrack mode mode getting the validation start
439 -- and end dates for the specified datetrack operation.
440 --
441 dt_api.validate_dt_mode
442 (p_effective_date => p_effective_date,
443 p_datetrack_mode => p_datetrack_mode,
444 p_base_table_name => 'ben_per_cm_f',
445 p_base_key_column => 'per_cm_id',
446 p_base_key_value => p_per_cm_id,
447 p_parent_table_name1 => 'ben_cm_typ_f',
448 p_parent_key_column1 => 'cm_typ_id',
449 p_parent_key_value1 => g_old_rec.cm_typ_id,
450 p_parent_table_name2 => 'ben_prtt_enrt_actn_f',
451 p_parent_key_column2 => 'prtt_enrt_actn_id',
452 p_parent_key_value2 => g_old_rec.prtt_enrt_actn_id,
453 p_child_table_name1 => 'ben_per_cm_prvdd_f',
454 p_child_key_column1 => 'per_cm_prvdd_id',
455 p_child_table_name2 => 'ben_per_cm_trgr_f',
456 p_child_key_column2 => 'per_cm_trgr_id',
457 p_child_table_name3 => 'ben_per_cm_usg_f',
458 p_child_key_column3 => 'per_cm_usg_id',
459 p_enforce_foreign_locking => false,
460 p_validation_start_date => l_validation_start_date,
461 p_validation_end_date => l_validation_end_date);
462 Else
463 --
464 -- We are doing a datetrack 'INSERT' which is illegal within this
465 -- procedure therefore we must error (note: to lck on insert the
466 -- private procedure ins_lck should be called).
467 --
468 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
469 fnd_message.set_token('PROCEDURE', l_proc);
470 fnd_message.set_token('STEP','20');
471 fnd_message.raise_error;
472 End If;
473 --
474 -- Set the validation start and end date OUT arguments
475 --
476 p_validation_start_date := l_validation_start_date;
477 p_validation_end_date := l_validation_end_date;
478 --
479 hr_utility.set_location(' Leaving:'||l_proc, 30);
480 --
481 -- We need to trap the ORA LOCK exception
482 --
483 Exception
484 When HR_Api.Object_Locked then
485 --
486 -- The object is locked therefore we need to supply a meaningful
487 -- error message.
488 --
489 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
490 fnd_message.set_token('TABLE_NAME', 'ben_per_cm_f');
491 fnd_message.raise_error;
492 When l_object_invalid then
493 --
494 -- The object doesn't exist or is invalid
495 --
496 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
497 fnd_message.set_token('TABLE_NAME', 'ben_per_cm_f');
498 fnd_message.raise_error;
499 End lck;
500 --
501 -- ----------------------------------------------------------------------------
502 -- |-----------------------------< convert_args >-----------------------------|
503 -- ----------------------------------------------------------------------------
504 Function convert_args
505 (
506 p_per_cm_id in number,
507 p_effective_start_date in date,
508 p_effective_end_date in date,
509 p_lf_evt_ocrd_dt in date,
510 p_rqstbl_untl_dt in date,
511 p_ler_id in number,
512 p_per_in_ler_id in number,
513 p_prtt_enrt_actn_id in number,
514 p_person_id in number,
515 p_bnf_person_id in number,
516 p_dpnt_person_id in number,
517 p_cm_typ_id in number,
518 p_business_group_id in number,
519 p_pcm_attribute_category in varchar2,
520 p_pcm_attribute1 in varchar2,
521 p_pcm_attribute2 in varchar2,
522 p_pcm_attribute3 in varchar2,
523 p_pcm_attribute4 in varchar2,
524 p_pcm_attribute5 in varchar2,
525 p_pcm_attribute6 in varchar2,
526 p_pcm_attribute7 in varchar2,
527 p_pcm_attribute8 in varchar2,
528 p_pcm_attribute9 in varchar2,
532 p_pcm_attribute13 in varchar2,
529 p_pcm_attribute10 in varchar2,
530 p_pcm_attribute11 in varchar2,
531 p_pcm_attribute12 in varchar2,
533 p_pcm_attribute14 in varchar2,
534 p_pcm_attribute15 in varchar2,
535 p_pcm_attribute16 in varchar2,
536 p_pcm_attribute17 in varchar2,
537 p_pcm_attribute18 in varchar2,
538 p_pcm_attribute19 in varchar2,
539 p_pcm_attribute20 in varchar2,
540 p_pcm_attribute21 in varchar2,
541 p_pcm_attribute22 in varchar2,
542 p_pcm_attribute23 in varchar2,
543 p_pcm_attribute24 in varchar2,
544 p_pcm_attribute25 in varchar2,
545 p_pcm_attribute26 in varchar2,
546 p_pcm_attribute27 in varchar2,
547 p_pcm_attribute28 in varchar2,
548 p_pcm_attribute29 in varchar2,
549 p_pcm_attribute30 in varchar2,
550 p_request_id in number,
551 p_program_application_id in number,
552 p_program_id in number,
553 p_program_update_date in date,
554 p_object_version_number in number
555 )
556 Return g_rec_type is
557 --
558 l_rec g_rec_type;
559 l_proc varchar2(72) := g_package||'convert_args';
560 --
561 Begin
562 --
563 hr_utility.set_location('Entering:'||l_proc, 5);
564 --
565 -- Convert arguments into local l_rec structure.
566 --
567 l_rec.per_cm_id := p_per_cm_id;
568 l_rec.effective_start_date := p_effective_start_date;
569 l_rec.effective_end_date := p_effective_end_date;
570 l_rec.lf_evt_ocrd_dt := p_lf_evt_ocrd_dt;
571 l_rec.rqstbl_untl_dt := p_rqstbl_untl_dt;
572 l_rec.ler_id := p_ler_id;
573 l_rec.per_in_ler_id := p_per_in_ler_id;
574 l_rec.prtt_enrt_actn_id := p_prtt_enrt_actn_id;
575 l_rec.person_id := p_person_id;
576 l_rec.bnf_person_id := p_bnf_person_id;
577 l_rec.dpnt_person_id := p_dpnt_person_id;
578 l_rec.cm_typ_id := p_cm_typ_id;
579 l_rec.business_group_id := p_business_group_id;
580 l_rec.pcm_attribute_category := p_pcm_attribute_category;
581 l_rec.pcm_attribute1 := p_pcm_attribute1;
582 l_rec.pcm_attribute2 := p_pcm_attribute2;
583 l_rec.pcm_attribute3 := p_pcm_attribute3;
584 l_rec.pcm_attribute4 := p_pcm_attribute4;
585 l_rec.pcm_attribute5 := p_pcm_attribute5;
586 l_rec.pcm_attribute6 := p_pcm_attribute6;
587 l_rec.pcm_attribute7 := p_pcm_attribute7;
588 l_rec.pcm_attribute8 := p_pcm_attribute8;
589 l_rec.pcm_attribute9 := p_pcm_attribute9;
590 l_rec.pcm_attribute10 := p_pcm_attribute10;
591 l_rec.pcm_attribute11 := p_pcm_attribute11;
592 l_rec.pcm_attribute12 := p_pcm_attribute12;
593 l_rec.pcm_attribute13 := p_pcm_attribute13;
594 l_rec.pcm_attribute14 := p_pcm_attribute14;
595 l_rec.pcm_attribute15 := p_pcm_attribute15;
596 l_rec.pcm_attribute16 := p_pcm_attribute16;
597 l_rec.pcm_attribute17 := p_pcm_attribute17;
598 l_rec.pcm_attribute18 := p_pcm_attribute18;
599 l_rec.pcm_attribute19 := p_pcm_attribute19;
600 l_rec.pcm_attribute20 := p_pcm_attribute20;
601 l_rec.pcm_attribute21 := p_pcm_attribute21;
602 l_rec.pcm_attribute22 := p_pcm_attribute22;
603 l_rec.pcm_attribute23 := p_pcm_attribute23;
604 l_rec.pcm_attribute24 := p_pcm_attribute24;
605 l_rec.pcm_attribute25 := p_pcm_attribute25;
606 l_rec.pcm_attribute26 := p_pcm_attribute26;
607 l_rec.pcm_attribute27 := p_pcm_attribute27;
608 l_rec.pcm_attribute28 := p_pcm_attribute28;
609 l_rec.pcm_attribute29 := p_pcm_attribute29;
610 l_rec.pcm_attribute30 := p_pcm_attribute30;
611 l_rec.request_id := p_request_id;
612 l_rec.program_application_id := p_program_application_id;
613 l_rec.program_id := p_program_id;
614 l_rec.program_update_date := p_program_update_date;
615 l_rec.object_version_number := p_object_version_number;
616 --
617 -- Return the plsql record structure.
618 --
619 hr_utility.set_location(' Leaving:'||l_proc, 10);
620 Return(l_rec);
621 --
622 End convert_args;
623 --
624 end ben_pcm_shd;