[Home] [Help]
PACKAGE BODY: APPS.BEN_EPY_SHD
Source
1 Package Body ben_epy_shd as
2 /* $Header: beepyrhi.pkb 120.1 2006/02/27 00:45:06 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_epy_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_ELIG_PYRL_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_ELIG_PYRL_FK2') 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','5');
45 fnd_message.raise_error;
46 ElsIf (p_constraint_name = 'BEN_ELIG_PYRL_TO_PRTE_PK') Then
47 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
48 fnd_message.set_token('PROCEDURE', l_proc);
49 fnd_message.set_token('STEP','10');
50 fnd_message.raise_error;
51 Else
52 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
53 fnd_message.set_token('PROCEDURE', l_proc);
54 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
55 fnd_message.raise_error;
56 End If;
57 --
58 hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65 (p_effective_date in date,
66 p_elig_pyrl_prte_id in number,
67 p_object_version_number in number
68 ) Return Boolean Is
69 --
70 --
71 -- Cursor selects the 'current' row from the HR Schema
72 --
73 Cursor C_Sel1 is
74 select
75 elig_pyrl_prte_id,
76 effective_start_date,
77 effective_end_date,
78 business_group_id,
79 payroll_id,
80 excld_flag,
81 ordr_num,
82 eligy_prfl_id,
83 epy_attribute_category,
84 epy_attribute1,
85 epy_attribute2,
86 epy_attribute3,
87 epy_attribute4,
88 epy_attribute5,
89 epy_attribute6,
90 epy_attribute7,
91 epy_attribute8,
92 epy_attribute9,
93 epy_attribute10,
94 epy_attribute11,
95 epy_attribute12,
96 epy_attribute13,
97 epy_attribute14,
98 epy_attribute15,
99 epy_attribute16,
100 epy_attribute17,
101 epy_attribute18,
102 epy_attribute19,
103 epy_attribute20,
104 epy_attribute21,
105 epy_attribute22,
106 epy_attribute23,
107 epy_attribute24,
108 epy_attribute25,
109 epy_attribute26,
110 epy_attribute27,
111 epy_attribute28,
112 epy_attribute29,
113 epy_attribute30,
114 object_version_number,
115 criteria_score,
116 criteria_weight
117 from ben_elig_pyrl_prte_f
118 where elig_pyrl_prte_id = p_elig_pyrl_prte_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_elig_pyrl_prte_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_elig_pyrl_prte_id = g_old_rec.elig_pyrl_prte_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 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
157 fnd_message.raise_error;
158 End If;
159 Close C_Sel1;
160 If (p_object_version_number <> g_old_rec.object_version_number) Then
161 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
162 fnd_message.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.eligy_prfl_id
190 from ben_elig_pyrl_prte_f t
191 where t.elig_pyrl_prte_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 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
202 fnd_message.set_token('PROCEDURE', l_proc);
203 fnd_message.set_token('STEP','10');
204 fnd_message.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_elig_pyrl_prte_f',
213 p_base_key_column => 'elig_pyrl_prte_id',
214 p_base_key_value => p_base_key_value,
215 p_parent_table_name1 => 'ben_eligy_prfl_f',
216 p_parent_key_column1 => 'eligy_prfl_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 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242 -- Call the corresponding datetrack api
243 --
244 dt_api.find_dt_upd_modes
245 (p_effective_date => p_effective_date,
246 p_base_table_name => 'ben_elig_pyrl_prte_f',
247 p_base_key_column => 'elig_pyrl_prte_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_elig_pyrl_prte_f',
280 p_base_key_column => 'elig_pyrl_prte_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_elig_pyrl_prte_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.elig_pyrl_prte_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_elig_pyrl_prte_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 elig_pyrl_prte_id,
329 effective_start_date,
330 effective_end_date,
331 business_group_id,
332 payroll_id,
333 excld_flag,
334 ordr_num,
335 eligy_prfl_id,
336 epy_attribute_category,
337 epy_attribute1,
338 epy_attribute2,
339 epy_attribute3,
340 epy_attribute4,
341 epy_attribute5,
342 epy_attribute6,
343 epy_attribute7,
344 epy_attribute8,
345 epy_attribute9,
346 epy_attribute10,
347 epy_attribute11,
348 epy_attribute12,
349 epy_attribute13,
350 epy_attribute14,
351 epy_attribute15,
352 epy_attribute16,
353 epy_attribute17,
354 epy_attribute18,
355 epy_attribute19,
356 epy_attribute20,
357 epy_attribute21,
358 epy_attribute22,
359 epy_attribute23,
360 epy_attribute24,
361 epy_attribute25,
362 epy_attribute26,
363 epy_attribute27,
364 epy_attribute28,
365 epy_attribute29,
366 epy_attribute30,
367 object_version_number ,
368 criteria_score,
369 criteria_weight
370 from ben_elig_pyrl_prte_f
371 where elig_pyrl_prte_id = p_elig_pyrl_prte_id
372 and p_effective_date
373 between effective_start_date and effective_end_date
374 for update nowait;
375 --
376 --
377 --
378 Begin
379 hr_utility.set_location('Entering:'||l_proc, 5);
380 --
381 -- Ensure that all the mandatory arguments are not null
382 --
383 hr_api.mandatory_arg_error(p_api_name => l_proc,
384 p_argument => 'effective_date',
385 p_argument_value => p_effective_date);
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'datetrack_mode',
389 p_argument_value => p_datetrack_mode);
390 --
391 hr_api.mandatory_arg_error(p_api_name => l_proc,
392 p_argument => 'elig_pyrl_prte_id',
393 p_argument_value => p_elig_pyrl_prte_id);
394 --
395 hr_api.mandatory_arg_error(p_api_name => l_proc,
399 -- Check to ensure the datetrack mode is not INSERT.
396 p_argument => 'object_version_number',
397 p_argument_value => p_object_version_number);
398 --
400 --
401 If (p_datetrack_mode <> 'INSERT') then
402 --
403 -- We must select and lock the current row.
404 --
405 Open C_Sel1;
406 Fetch C_Sel1 Into g_old_rec;
407 If C_Sel1%notfound then
408 Close C_Sel1;
409 --
410 -- The primary key is invalid therefore we must error
411 --
412 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
413 fnd_message.raise_error;
414 End If;
415 Close C_Sel1;
416 If (p_object_version_number <> g_old_rec.object_version_number) Then
417 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
418 fnd_message.raise_error;
419 End If;
420 hr_utility.set_location(l_proc, 15);
421 --
422 --
423 -- Validate the datetrack mode mode getting the validation start
424 -- and end dates for the specified datetrack operation.
425 --
426 dt_api.validate_dt_mode
427 (p_effective_date => p_effective_date,
428 p_datetrack_mode => p_datetrack_mode,
429 p_base_table_name => 'ben_elig_pyrl_prte_f',
430 p_base_key_column => 'elig_pyrl_prte_id',
431 p_base_key_value => p_elig_pyrl_prte_id,
432 p_parent_table_name1 => 'ben_eligy_prfl_f',
433 p_parent_key_column1 => 'eligy_prfl_id',
434 p_parent_key_value1 => g_old_rec.eligy_prfl_id,
435 p_enforce_foreign_locking => true,
436 p_validation_start_date => l_validation_start_date,
437 p_validation_end_date => l_validation_end_date);
438 Else
439 --
440 -- We are doing a datetrack 'INSERT' which is illegal within this
441 -- procedure therefore we must error (note: to lck on insert the
442 -- private procedure ins_lck should be called).
443 --
444 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
445 fnd_message.set_token('PROCEDURE', l_proc);
446 fnd_message.set_token('STEP','20');
447 fnd_message.raise_error;
448 End If;
449 --
450 -- Set the validation start and end date OUT arguments
451 --
452 p_validation_start_date := l_validation_start_date;
453 p_validation_end_date := l_validation_end_date;
454 --
455 hr_utility.set_location(' Leaving:'||l_proc, 30);
456 --
457 -- We need to trap the ORA LOCK exception
458 --
459 Exception
460 When HR_Api.Object_Locked then
461 --
462 -- The object is locked therefore we need to supply a meaningful
463 -- error message.
464 --
465 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
466 fnd_message.set_token('TABLE_NAME', 'ben_elig_pyrl_prte_f');
467 fnd_message.raise_error;
468 When l_object_invalid then
469 --
470 -- The object doesn't exist or is invalid
471 --
472 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
473 fnd_message.set_token('TABLE_NAME', 'ben_elig_pyrl_prte_f');
474 fnd_message.raise_error;
475 End lck;
476 --
477 -- ----------------------------------------------------------------------------
478 -- |-----------------------------< convert_args >-----------------------------|
479 -- ----------------------------------------------------------------------------
480 Function convert_args
481 (
482 p_elig_pyrl_prte_id in number,
483 p_effective_start_date in date,
484 p_effective_end_date in date,
485 p_business_group_id in number,
486 p_payroll_id in number,
487 p_excld_flag in varchar2,
488 p_ordr_num in number,
489 p_eligy_prfl_id in number,
490 p_epy_attribute_category in varchar2,
491 p_epy_attribute1 in varchar2,
492 p_epy_attribute2 in varchar2,
493 p_epy_attribute3 in varchar2,
494 p_epy_attribute4 in varchar2,
495 p_epy_attribute5 in varchar2,
496 p_epy_attribute6 in varchar2,
497 p_epy_attribute7 in varchar2,
498 p_epy_attribute8 in varchar2,
499 p_epy_attribute9 in varchar2,
500 p_epy_attribute10 in varchar2,
501 p_epy_attribute11 in varchar2,
502 p_epy_attribute12 in varchar2,
503 p_epy_attribute13 in varchar2,
504 p_epy_attribute14 in varchar2,
505 p_epy_attribute15 in varchar2,
506 p_epy_attribute16 in varchar2,
507 p_epy_attribute17 in varchar2,
508 p_epy_attribute18 in varchar2,
509 p_epy_attribute19 in varchar2,
510 p_epy_attribute20 in varchar2,
511 p_epy_attribute21 in varchar2,
512 p_epy_attribute22 in varchar2,
513 p_epy_attribute23 in varchar2,
514 p_epy_attribute24 in varchar2,
515 p_epy_attribute25 in varchar2,
516 p_epy_attribute26 in varchar2,
517 p_epy_attribute27 in varchar2,
518 p_epy_attribute28 in varchar2,
519 p_epy_attribute29 in varchar2,
520 p_epy_attribute30 in varchar2,
521 p_object_version_number in number ,
522 p_criteria_score in number ,
523 p_criteria_weight in number
524 )
525 Return g_rec_type is
526 --
527 l_rec g_rec_type;
528 l_proc varchar2(72) := g_package||'convert_args';
529 --
530 Begin
531 --
532 hr_utility.set_location('Entering:'||l_proc, 5);
533 --
534 -- Convert arguments into local l_rec structure.
535 --
536 l_rec.elig_pyrl_prte_id := p_elig_pyrl_prte_id;
537 l_rec.effective_start_date := p_effective_start_date;
538 l_rec.effective_end_date := p_effective_end_date;
539 l_rec.business_group_id := p_business_group_id;
540 l_rec.payroll_id := p_payroll_id;
541 l_rec.excld_flag := p_excld_flag;
542 l_rec.ordr_num := p_ordr_num;
543 l_rec.eligy_prfl_id := p_eligy_prfl_id;
544 l_rec.epy_attribute_category := p_epy_attribute_category;
545 l_rec.epy_attribute1 := p_epy_attribute1;
546 l_rec.epy_attribute2 := p_epy_attribute2;
547 l_rec.epy_attribute3 := p_epy_attribute3;
548 l_rec.epy_attribute4 := p_epy_attribute4;
549 l_rec.epy_attribute5 := p_epy_attribute5;
550 l_rec.epy_attribute6 := p_epy_attribute6;
551 l_rec.epy_attribute7 := p_epy_attribute7;
552 l_rec.epy_attribute8 := p_epy_attribute8;
553 l_rec.epy_attribute9 := p_epy_attribute9;
554 l_rec.epy_attribute10 := p_epy_attribute10;
555 l_rec.epy_attribute11 := p_epy_attribute11;
556 l_rec.epy_attribute12 := p_epy_attribute12;
557 l_rec.epy_attribute13 := p_epy_attribute13;
558 l_rec.epy_attribute14 := p_epy_attribute14;
559 l_rec.epy_attribute15 := p_epy_attribute15;
560 l_rec.epy_attribute16 := p_epy_attribute16;
561 l_rec.epy_attribute17 := p_epy_attribute17;
562 l_rec.epy_attribute18 := p_epy_attribute18;
563 l_rec.epy_attribute19 := p_epy_attribute19;
564 l_rec.epy_attribute20 := p_epy_attribute20;
565 l_rec.epy_attribute21 := p_epy_attribute21;
566 l_rec.epy_attribute22 := p_epy_attribute22;
567 l_rec.epy_attribute23 := p_epy_attribute23;
568 l_rec.epy_attribute24 := p_epy_attribute24;
569 l_rec.epy_attribute25 := p_epy_attribute25;
570 l_rec.epy_attribute26 := p_epy_attribute26;
571 l_rec.epy_attribute27 := p_epy_attribute27;
572 l_rec.epy_attribute28 := p_epy_attribute28;
573 l_rec.epy_attribute29 := p_epy_attribute29;
574 l_rec.epy_attribute30 := p_epy_attribute30;
575 l_rec.object_version_number := p_object_version_number;
576 l_rec.criteria_score := p_criteria_score;
577 l_rec.criteria_weight := p_criteria_weight;
578 --
579 -- Return the plsql record structure.
580 --
581 hr_utility.set_location(' Leaving:'||l_proc, 10);
582 Return(l_rec);
583 --
584 End convert_args;
585 --
586 end ben_epy_shd;