[Home] [Help]
PACKAGE BODY: APPS.BEN_PET_SHD
Source
1 Package Body ben_pet_shd as
2 /* $Header: bepetrhi.pkb 120.1 2006/03/07 23:43:30 abparekh noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_pet_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_POPL_ENRT_TYP_CYCL_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_POPL_ENRT_TYP_CYCL_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_popl_enrt_typ_cycl_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 popl_enrt_typ_cycl_id,
71 effective_start_date,
72 effective_end_date,
73 business_group_id,
74 enrt_typ_cycl_cd,
75 pl_id,
76 pgm_id,
77 pet_attribute_category,
78 pet_attribute1,
79 pet_attribute2,
80 pet_attribute3,
81 pet_attribute4,
82 pet_attribute5,
83 pet_attribute6,
84 pet_attribute7,
85 pet_attribute8,
86 pet_attribute9,
87 pet_attribute10,
88 pet_attribute11,
89 pet_attribute12,
90 pet_attribute13,
91 pet_attribute14,
92 pet_attribute15,
93 pet_attribute16,
94 pet_attribute17,
95 pet_attribute18,
96 pet_attribute19,
97 pet_attribute20,
98 pet_attribute21,
99 pet_attribute22,
100 pet_attribute23,
101 pet_attribute24,
102 pet_attribute25,
103 pet_attribute26,
104 pet_attribute27,
105 pet_attribute28,
106 pet_attribute29,
107 pet_attribute30,
108 object_version_number
109 from ben_popl_enrt_typ_cycl_f
110 where popl_enrt_typ_cycl_id = p_popl_enrt_typ_cycl_id
111 and p_effective_date
112 between effective_start_date and effective_end_date;
113 --
114 l_proc varchar2(72) := g_package||'api_updating';
115 l_fct_ret boolean;
116 --
117 Begin
118 hr_utility.set_location('Entering:'||l_proc, 5);
119 --
120 If (p_effective_date is null or
121 p_popl_enrt_typ_cycl_id is null or
122 p_object_version_number is null) Then
123 --
124 -- One of the primary key arguments is null therefore we must
125 -- set the returning function value to false
126 --
127 l_fct_ret := false;
128 Else
129 If (p_popl_enrt_typ_cycl_id = g_old_rec.popl_enrt_typ_cycl_id and
130 p_object_version_number = g_old_rec.object_version_number) Then
131 hr_utility.set_location(l_proc, 10);
132 --
133 -- The g_old_rec is current therefore we must
134 -- set the returning function to true
135 --
136 l_fct_ret := true;
137 Else
138 --
139 -- Select the current row
140 --
141 Open C_Sel1;
142 Fetch C_Sel1 Into g_old_rec;
143 If C_Sel1%notfound Then
144 Close C_Sel1;
145 --
146 -- The primary key is invalid therefore we must error
147 --
148 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149 fnd_message.raise_error;
150 End If;
151 Close C_Sel1;
152 If (p_object_version_number <> g_old_rec.object_version_number) Then
153 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154 fnd_message.raise_error;
155 End If;
156 hr_utility.set_location(l_proc, 15);
157 l_fct_ret := true;
158 End If;
159 End If;
160 hr_utility.set_location(' Leaving:'||l_proc, 20);
161 Return (l_fct_ret);
162 --
163 End api_updating;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |--------------------------< find_dt_del_modes >---------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure find_dt_del_modes
169 (p_effective_date in date,
170 p_base_key_value in number,
171 p_zap out nocopy boolean,
172 p_delete out nocopy boolean,
173 p_future_change out nocopy boolean,
174 p_delete_next_change out nocopy boolean) is
175 --
176 l_proc varchar2(72) := g_package||'find_dt_del_modes';
177 --
178 l_parent_key_value1 number;
179 l_parent_key_value2 number;
180 l_parent_key_value3 number;
181 --
182 Cursor C_Sel1 Is
183 select t.pl_id,
184 t.pgm_id
185 from ben_popl_enrt_typ_cycl_f t
186 where t.popl_enrt_typ_cycl_id = p_base_key_value
187 and p_effective_date
188 between t.effective_start_date and t.effective_end_date;
189 --
190 Begin
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 Open C_Sel1;
193 Fetch C_Sel1 Into l_parent_key_value1,
194 l_parent_key_value2;
195 If C_Sel1%notfound then
196 Close C_Sel1;
197 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
198 fnd_message.set_token('PROCEDURE', l_proc);
199 fnd_message.set_token('STEP','10');
200 fnd_message.raise_error;
201 End If;
202 Close C_Sel1;
203 --
204 -- Call the corresponding datetrack api
205 --
206 dt_api.find_dt_del_modes
207 (p_effective_date => p_effective_date,
208 p_base_table_name => 'ben_popl_enrt_typ_cycl_f',
209 p_base_key_column => 'popl_enrt_typ_cycl_id',
210 p_base_key_value => p_base_key_value,
211 p_parent_table_name1 => 'ben_pl_f',
212 p_parent_key_column1 => 'pl_id',
213 p_parent_key_value1 => l_parent_key_value1,
214 p_parent_table_name2 => 'ben_pgm_f',
215 p_parent_key_column2 => 'pgm_id',
216 p_parent_key_value2 => l_parent_key_value2,
217 p_zap => p_zap,
218 p_delete => p_delete,
219 p_future_change => p_future_change,
220 p_delete_next_change => p_delete_next_change);
221 --
222 hr_utility.set_location(' Leaving:'||l_proc, 10);
223 End find_dt_del_modes;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |--------------------------< find_dt_upd_modes >---------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure find_dt_upd_modes
229 (p_effective_date in date,
230 p_base_key_value in number,
231 p_correction out nocopy boolean,
232 p_update out nocopy boolean,
233 p_update_override out nocopy boolean,
234 p_update_change_insert out nocopy boolean) is
235 --
236 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
237 --
238 Begin
239 hr_utility.set_location('Entering:'||l_proc, 5);
240 --
241 -- Call the corresponding datetrack api
242 --
243 dt_api.find_dt_upd_modes
244 (p_effective_date => p_effective_date,
245 p_base_table_name => 'ben_popl_enrt_typ_cycl_f',
246 p_base_key_column => 'popl_enrt_typ_cycl_id',
247 p_base_key_value => p_base_key_value,
248 p_correction => p_correction,
249 p_update => p_update,
250 p_update_override => p_update_override,
251 p_update_change_insert => p_update_change_insert);
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End find_dt_upd_modes;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |------------------------< upd_effective_end_date >------------------------|
258 -- ----------------------------------------------------------------------------
259 Procedure upd_effective_end_date
260 (p_effective_date in date,
261 p_base_key_value in number,
262 p_new_effective_end_date in date,
263 p_validation_start_date in date,
264 p_validation_end_date in date,
265 p_object_version_number out nocopy number) is
266 --
267 l_proc varchar2(72) := g_package||'upd_effective_end_date';
268 l_object_version_number number;
269 --
270 Begin
271 hr_utility.set_location('Entering:'||l_proc, 5);
272 --
273 -- Because we are updating a row we must get the next object
274 -- version number.
275 --
276 l_object_version_number :=
277 dt_api.get_object_version_number
278 (p_base_table_name => 'ben_popl_enrt_typ_cycl_f',
279 p_base_key_column => 'popl_enrt_typ_cycl_id',
280 p_base_key_value => p_base_key_value);
281 --
282 hr_utility.set_location(l_proc, 10);
283 g_api_dml := true; -- Set the api dml status
284 --
285 -- Update the specified datetrack row setting the effective
286 -- end date to the specified new effective end date.
287 --
288 update ben_popl_enrt_typ_cycl_f t
289 set t.effective_end_date = p_new_effective_end_date,
290 t.object_version_number = l_object_version_number
291 where t.popl_enrt_typ_cycl_id = p_base_key_value
292 and p_effective_date
293 between t.effective_start_date and t.effective_end_date;
294 --
295 g_api_dml := false; -- Unset the api dml status
296 p_object_version_number := l_object_version_number;
297 hr_utility.set_location(' Leaving:'||l_proc, 15);
298 --
299 Exception
300 When Others Then
301 g_api_dml := false; -- Unset the api dml status
302 Raise;
303 End upd_effective_end_date;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< lck >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure lck
309 (p_effective_date in date,
310 p_datetrack_mode in varchar2,
311 p_popl_enrt_typ_cycl_id in number,
312 p_object_version_number in number,
313 p_validation_start_date out nocopy date,
314 p_validation_end_date out nocopy date) is
315 --
316 l_proc varchar2(72) := g_package||'lck';
317 l_validation_start_date date;
318 l_validation_end_date date;
319 l_object_invalid exception;
320 l_argument varchar2(30);
321 --
322 -- Cursor C_Sel1 selects the current locked row as of session date
323 -- ensuring that the object version numbers match.
324 --
325 Cursor C_Sel1 is
326 select
327 popl_enrt_typ_cycl_id,
328 effective_start_date,
329 effective_end_date,
330 business_group_id,
331 enrt_typ_cycl_cd,
332 pl_id,
333 pgm_id,
334 pet_attribute_category,
335 pet_attribute1,
336 pet_attribute2,
337 pet_attribute3,
338 pet_attribute4,
339 pet_attribute5,
340 pet_attribute6,
341 pet_attribute7,
342 pet_attribute8,
343 pet_attribute9,
344 pet_attribute10,
345 pet_attribute11,
346 pet_attribute12,
347 pet_attribute13,
348 pet_attribute14,
349 pet_attribute15,
350 pet_attribute16,
351 pet_attribute17,
352 pet_attribute18,
353 pet_attribute19,
354 pet_attribute20,
355 pet_attribute21,
356 pet_attribute22,
357 pet_attribute23,
358 pet_attribute24,
359 pet_attribute25,
360 pet_attribute26,
361 pet_attribute27,
362 pet_attribute28,
363 pet_attribute29,
364 pet_attribute30,
365 object_version_number
366 from ben_popl_enrt_typ_cycl_f
367 where popl_enrt_typ_cycl_id = p_popl_enrt_typ_cycl_id
368 and p_effective_date
369 between effective_start_date and effective_end_date
370 for update nowait;
371 --
372 --
373 --
374 Begin
375 hr_utility.set_location('Entering:'||l_proc, 5);
376 --
377 -- Ensure that all the mandatory arguments are not null
378 --
379 hr_api.mandatory_arg_error(p_api_name => l_proc,
380 p_argument => 'effective_date',
381 p_argument_value => p_effective_date);
382 --
383 hr_api.mandatory_arg_error(p_api_name => l_proc,
384 p_argument => 'datetrack_mode',
385 p_argument_value => p_datetrack_mode);
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'popl_enrt_typ_cycl_id',
389 p_argument_value => p_popl_enrt_typ_cycl_id);
390 --
391 hr_api.mandatory_arg_error(p_api_name => l_proc,
392 p_argument => 'object_version_number',
393 p_argument_value => p_object_version_number);
394 --
395 -- Check to ensure the datetrack mode is not INSERT.
396 --
397 If (p_datetrack_mode <> 'INSERT') then
401 Open C_Sel1;
398 --
399 -- We must select and lock the current row.
400 --
402 Fetch C_Sel1 Into g_old_rec;
403 If C_Sel1%notfound then
404 Close C_Sel1;
405 --
406 -- The primary key is invalid therefore we must error
407 --
408 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
409 fnd_message.raise_error;
410 End If;
411 Close C_Sel1;
412 If (p_object_version_number <> g_old_rec.object_version_number) Then
413 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
414 fnd_message.raise_error;
415 End If;
416 hr_utility.set_location(l_proc, 15);
417 --
418 --
419 -- Validate the datetrack mode mode getting the validation start
420 -- and end dates for the specified datetrack operation.
421 --
422 dt_api.validate_dt_mode
423 (p_effective_date => p_effective_date,
424 p_datetrack_mode => p_datetrack_mode,
425 p_base_table_name => 'ben_popl_enrt_typ_cycl_f',
426 p_base_key_column => 'popl_enrt_typ_cycl_id',
427 p_base_key_value => p_popl_enrt_typ_cycl_id,
428 p_parent_table_name2 => 'ben_pl_f',
429 p_parent_key_column2 => 'pl_id',
430 p_parent_key_value2 => g_old_rec.pl_id,
431 p_parent_table_name3 => 'ben_pgm_f',
432 p_parent_key_column3 => 'pgm_id',
433 p_parent_key_value3 => g_old_rec.pgm_id,
434 p_child_table_name1 => 'ben_lee_rsn_f',
435 p_child_key_column1 => 'lee_rsn_id',
436 p_enforce_foreign_locking => true,
437 p_validation_start_date => l_validation_start_date,
438 p_validation_end_date => l_validation_end_date);
439 Else
440 --
441 -- We are doing a datetrack 'INSERT' which is illegal within this
442 -- procedure therefore we must error (note: to lck on insert the
443 -- private procedure ins_lck should be called).
444 --
445 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
446 fnd_message.set_token('PROCEDURE', l_proc);
447 fnd_message.set_token('STEP','20');
448 fnd_message.raise_error;
449 End If;
450 --
451 -- Set the validation start and end date OUT arguments
452 --
453 p_validation_start_date := l_validation_start_date;
454 p_validation_end_date := l_validation_end_date;
455 --
456 hr_utility.set_location(' Leaving:'||l_proc, 30);
457 --
458 -- We need to trap the ORA LOCK exception
459 --
460 Exception
461 When HR_Api.Object_Locked then
462 --
463 -- The object is locked therefore we need to supply a meaningful
464 -- error message.
465 --
466 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
467 fnd_message.set_token('TABLE_NAME', 'ben_popl_enrt_typ_cycl_f');
468 fnd_message.raise_error;
469 When l_object_invalid then
470 --
471 -- The object doesn't exist or is invalid
472 --
473 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
474 fnd_message.set_token('TABLE_NAME', 'ben_popl_enrt_typ_cycl_f');
475 fnd_message.raise_error;
476 End lck;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |-----------------------------< convert_args >-----------------------------|
480 -- ----------------------------------------------------------------------------
481 Function convert_args
482 (
483 p_popl_enrt_typ_cycl_id in number,
484 p_effective_start_date in date,
485 p_effective_end_date in date,
486 p_business_group_id in number,
487 p_enrt_typ_cycl_cd in varchar2,
488 p_pl_id in number,
489 p_pgm_id in number,
490 p_pet_attribute_category in varchar2,
491 p_pet_attribute1 in varchar2,
492 p_pet_attribute2 in varchar2,
493 p_pet_attribute3 in varchar2,
494 p_pet_attribute4 in varchar2,
495 p_pet_attribute5 in varchar2,
496 p_pet_attribute6 in varchar2,
497 p_pet_attribute7 in varchar2,
498 p_pet_attribute8 in varchar2,
499 p_pet_attribute9 in varchar2,
500 p_pet_attribute10 in varchar2,
501 p_pet_attribute11 in varchar2,
502 p_pet_attribute12 in varchar2,
503 p_pet_attribute13 in varchar2,
504 p_pet_attribute14 in varchar2,
505 p_pet_attribute15 in varchar2,
506 p_pet_attribute16 in varchar2,
507 p_pet_attribute17 in varchar2,
508 p_pet_attribute18 in varchar2,
509 p_pet_attribute19 in varchar2,
510 p_pet_attribute20 in varchar2,
511 p_pet_attribute21 in varchar2,
512 p_pet_attribute22 in varchar2,
513 p_pet_attribute23 in varchar2,
514 p_pet_attribute24 in varchar2,
515 p_pet_attribute25 in varchar2,
516 p_pet_attribute26 in varchar2,
517 p_pet_attribute27 in varchar2,
518 p_pet_attribute28 in varchar2,
519 p_pet_attribute29 in varchar2,
520 p_pet_attribute30 in varchar2,
521 p_object_version_number in number
522 )
526 l_proc varchar2(72) := g_package||'convert_args';
523 Return g_rec_type is
524 --
525 l_rec g_rec_type;
527 --
528 Begin
529 --
530 hr_utility.set_location('Entering:'||l_proc, 5);
531 --
532 -- Convert arguments into local l_rec structure.
533 --
534 l_rec.popl_enrt_typ_cycl_id := p_popl_enrt_typ_cycl_id;
535 l_rec.effective_start_date := p_effective_start_date;
536 l_rec.effective_end_date := p_effective_end_date;
537 l_rec.business_group_id := p_business_group_id;
538 l_rec.enrt_typ_cycl_cd := p_enrt_typ_cycl_cd;
539 l_rec.pl_id := p_pl_id;
540 l_rec.pgm_id := p_pgm_id;
541 l_rec.pet_attribute_category := p_pet_attribute_category;
542 l_rec.pet_attribute1 := p_pet_attribute1;
543 l_rec.pet_attribute2 := p_pet_attribute2;
544 l_rec.pet_attribute3 := p_pet_attribute3;
545 l_rec.pet_attribute4 := p_pet_attribute4;
546 l_rec.pet_attribute5 := p_pet_attribute5;
547 l_rec.pet_attribute6 := p_pet_attribute6;
548 l_rec.pet_attribute7 := p_pet_attribute7;
549 l_rec.pet_attribute8 := p_pet_attribute8;
550 l_rec.pet_attribute9 := p_pet_attribute9;
551 l_rec.pet_attribute10 := p_pet_attribute10;
552 l_rec.pet_attribute11 := p_pet_attribute11;
553 l_rec.pet_attribute12 := p_pet_attribute12;
554 l_rec.pet_attribute13 := p_pet_attribute13;
555 l_rec.pet_attribute14 := p_pet_attribute14;
556 l_rec.pet_attribute15 := p_pet_attribute15;
557 l_rec.pet_attribute16 := p_pet_attribute16;
558 l_rec.pet_attribute17 := p_pet_attribute17;
559 l_rec.pet_attribute18 := p_pet_attribute18;
560 l_rec.pet_attribute19 := p_pet_attribute19;
561 l_rec.pet_attribute20 := p_pet_attribute20;
562 l_rec.pet_attribute21 := p_pet_attribute21;
563 l_rec.pet_attribute22 := p_pet_attribute22;
564 l_rec.pet_attribute23 := p_pet_attribute23;
565 l_rec.pet_attribute24 := p_pet_attribute24;
566 l_rec.pet_attribute25 := p_pet_attribute25;
567 l_rec.pet_attribute26 := p_pet_attribute26;
568 l_rec.pet_attribute27 := p_pet_attribute27;
569 l_rec.pet_attribute28 := p_pet_attribute28;
570 l_rec.pet_attribute29 := p_pet_attribute29;
571 l_rec.pet_attribute30 := p_pet_attribute30;
572 l_rec.object_version_number := p_object_version_number;
573 --
574 -- Return the plsql record structure.
575 --
576 hr_utility.set_location(' Leaving:'||l_proc, 10);
577 Return(l_rec);
578 --
579 End convert_args;
580 --
581 end ben_pet_shd;