[Home] [Help]
PACKAGE BODY: APPS.BEN_ELV_SHD
Source
1 Package Body ben_elv_shd as
2 /* $Header: beelvrhi.pkb 120.2 2006/02/26 23:52:55 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
9 --
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_elv_shd.'; -- Global package name
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_LVG_RSN_PRTE_PK') 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 Else
42 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
43 fnd_message.set_token('PROCEDURE', l_proc);
44 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
45 fnd_message.raise_error;
46 End If;
47 --
48 hr_utility.set_location(' Leaving:'||l_proc, 10);
49 End constraint_error;
50 --
51 -- ----------------------------------------------------------------------------
52 -- |-----------------------------< api_updating >-----------------------------|
53 -- ----------------------------------------------------------------------------
54 Function api_updating
55 (p_effective_date in date,
56 p_elig_lvg_rsn_prte_id in number,
57 p_object_version_number in number
58 ) Return Boolean Is
59 --
60 --
61 -- Cursor selects the 'current' row from the HR Schema
62 --
63 Cursor C_Sel1 is
64 select
65 elig_lvg_rsn_prte_id,
66 effective_start_date,
67 effective_end_date,
68 excld_flag,
69 ordr_num,
70 lvg_rsn_cd,
71 eligy_prfl_id,
72 business_group_id,
73 elv_attribute_category,
74 elv_attribute1,
75 elv_attribute2,
76 elv_attribute3,
77 elv_attribute4,
78 elv_attribute5,
79 elv_attribute6,
80 elv_attribute7,
81 elv_attribute8,
82 elv_attribute9,
83 elv_attribute10,
84 elv_attribute11,
85 elv_attribute12,
86 elv_attribute13,
87 elv_attribute14,
88 elv_attribute15,
89 elv_attribute16,
90 elv_attribute17,
91 elv_attribute18,
92 elv_attribute19,
93 elv_attribute20,
94 elv_attribute21,
95 elv_attribute22,
96 elv_attribute23,
97 elv_attribute24,
98 elv_attribute25,
99 elv_attribute26,
100 elv_attribute27,
101 elv_attribute28,
102 elv_attribute29,
103 elv_attribute30,
104 object_version_number,
105 criteria_score,
106 criteria_weight
107 from ben_elig_lvg_rsn_prte_f
108 where elig_lvg_rsn_prte_id = p_elig_lvg_rsn_prte_id
109 and p_effective_date
110 between effective_start_date and effective_end_date;
111 --
112 l_proc varchar2(72) := g_package||'api_updating';
113 l_fct_ret boolean;
114 --
115 Begin
116 hr_utility.set_location('Entering:'||l_proc, 5);
117 --
118 If (p_effective_date is null or
119 p_elig_lvg_rsn_prte_id is null or
120 p_object_version_number is null) Then
121 --
122 -- One of the primary key arguments is null therefore we must
123 -- set the returning function value to false
124 --
125 l_fct_ret := false;
126 Else
127 If (p_elig_lvg_rsn_prte_id = g_old_rec.elig_lvg_rsn_prte_id and
128 p_object_version_number = g_old_rec.object_version_number) Then
129 hr_utility.set_location(l_proc, 10);
130 --
131 -- The g_old_rec is current therefore we must
132 -- set the returning function to true
133 --
134 l_fct_ret := true;
135 Else
136 --
137 -- Select the current row
138 --
139 Open C_Sel1;
140 Fetch C_Sel1 Into g_old_rec;
141 If C_Sel1%notfound Then
142 Close C_Sel1;
143 --
144 -- The primary key is invalid therefore we must error
145 --
146 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
147 fnd_message.raise_error;
148 End If;
149 Close C_Sel1;
150 If (p_object_version_number <> g_old_rec.object_version_number) Then
151 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
152 fnd_message.raise_error;
153 End If;
154 hr_utility.set_location(l_proc, 15);
155 l_fct_ret := true;
156 End If;
157 End If;
158 hr_utility.set_location(' Leaving:'||l_proc, 20);
159 Return (l_fct_ret);
160 --
161 End api_updating;
162 --
163 -- ----------------------------------------------------------------------------
164 -- |--------------------------< find_dt_del_modes >---------------------------|
168 p_base_key_value in number,
165 -- ----------------------------------------------------------------------------
166 Procedure find_dt_del_modes
167 (p_effective_date in date,
169 p_zap out nocopy boolean,
170 p_delete out nocopy boolean,
171 p_future_change out nocopy boolean,
172 p_delete_next_change out nocopy boolean) is
173 --
174 l_proc varchar2(72) := g_package||'find_dt_del_modes';
175 --
176 l_parent_key_value1 number;
177 --
178 Cursor C_Sel1 Is
179 select t.eligy_prfl_id
180 from ben_elig_lvg_rsn_prte_f t
181 where t.elig_lvg_rsn_prte_id = p_base_key_value
182 and p_effective_date
183 between t.effective_start_date and t.effective_end_date;
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 Open C_Sel1;
188 Fetch C_Sel1 Into l_parent_key_value1;
189 If C_Sel1%notfound then
190 Close C_Sel1;
191 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
192 fnd_message.set_token('PROCEDURE', l_proc);
193 fnd_message.set_token('STEP','10');
194 fnd_message.raise_error;
195 End If;
196 Close C_Sel1;
197 --
198 -- Call the corresponding datetrack api
199 --
200 dt_api.find_dt_del_modes
201 (p_effective_date => p_effective_date,
202 p_base_table_name => 'ben_elig_lvg_rsn_prte_f',
203 p_base_key_column => 'elig_lvg_rsn_prte_id',
204 p_base_key_value => p_base_key_value,
205 p_parent_table_name1 => 'ben_eligy_prfl_f',
206 p_parent_key_column1 => 'eligy_prfl_id',
207 p_parent_key_value1 => l_parent_key_value1,
208 p_zap => p_zap,
209 p_delete => p_delete,
210 p_future_change => p_future_change,
211 p_delete_next_change => p_delete_next_change);
212 --
213 hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End find_dt_del_modes;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< find_dt_upd_modes >---------------------------|
218 -- ----------------------------------------------------------------------------
219 Procedure find_dt_upd_modes
220 (p_effective_date in date,
221 p_base_key_value in number,
222 p_correction out nocopy boolean,
223 p_update out nocopy boolean,
224 p_update_override out nocopy boolean,
225 p_update_change_insert out nocopy boolean) is
226 --
227 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
228 --
229 Begin
230 hr_utility.set_location('Entering:'||l_proc, 5);
231 --
232 -- Call the corresponding datetrack api
233 --
234 dt_api.find_dt_upd_modes
235 (p_effective_date => p_effective_date,
236 p_base_table_name => 'ben_elig_lvg_rsn_prte_f',
237 p_base_key_column => 'elig_lvg_rsn_prte_id',
238 p_base_key_value => p_base_key_value,
239 p_correction => p_correction,
240 p_update => p_update,
241 p_update_override => p_update_override,
242 p_update_change_insert => p_update_change_insert);
243 --
244 hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End find_dt_upd_modes;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |------------------------< upd_effective_end_date >------------------------|
249 -- ----------------------------------------------------------------------------
250 Procedure upd_effective_end_date
251 (p_effective_date in date,
252 p_base_key_value in number,
253 p_new_effective_end_date in date,
254 p_validation_start_date in date,
255 p_validation_end_date in date,
256 p_object_version_number out nocopy number) is
257 --
258 l_proc varchar2(72) := g_package||'upd_effective_end_date';
259 l_object_version_number number;
260 --
261 Begin
262 hr_utility.set_location('Entering:'||l_proc, 5);
263 --
264 -- Because we are updating a row we must get the next object
265 -- version number.
266 --
267 l_object_version_number :=
268 dt_api.get_object_version_number
269 (p_base_table_name => 'ben_elig_lvg_rsn_prte_f',
270 p_base_key_column => 'elig_lvg_rsn_prte_id',
271 p_base_key_value => p_base_key_value);
272 --
273 hr_utility.set_location(l_proc, 10);
274 g_api_dml := true; -- Set the api dml status
275 --
276 -- Update the specified datetrack row setting the effective
277 -- end date to the specified new effective end date.
278 --
279 update ben_elig_lvg_rsn_prte_f t
280 set t.effective_end_date = p_new_effective_end_date,
281 t.object_version_number = l_object_version_number
282 where t.elig_lvg_rsn_prte_id = p_base_key_value
283 and p_effective_date
284 between t.effective_start_date and t.effective_end_date;
285 --
286 g_api_dml := false; -- Unset the api dml status
287 p_object_version_number := l_object_version_number;
288 hr_utility.set_location(' Leaving:'||l_proc, 15);
289 --
290 Exception
291 When Others Then
292 g_api_dml := false; -- Unset the api dml status
293 Raise;
294 End upd_effective_end_date;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------------< lck >----------------------------------|
298 -- ----------------------------------------------------------------------------
299 Procedure lck
300 (p_effective_date in date,
301 p_datetrack_mode in varchar2,
302 p_elig_lvg_rsn_prte_id in number,
303 p_object_version_number in number,
304 p_validation_start_date out nocopy date,
305 p_validation_end_date out nocopy date) is
306 --
307 l_proc varchar2(72) := g_package||'lck';
308 l_validation_start_date date;
309 l_validation_end_date date;
313 -- Cursor C_Sel1 selects the current locked row as of session date
310 l_object_invalid exception;
311 l_argument varchar2(30);
312 --
314 -- ensuring that the object version numbers match.
315 --
316 Cursor C_Sel1 is
317 select
318 elig_lvg_rsn_prte_id,
319 effective_start_date,
320 effective_end_date,
321 excld_flag,
322 ordr_num,
323 lvg_rsn_cd,
324 eligy_prfl_id,
325 business_group_id,
326 elv_attribute_category,
327 elv_attribute1,
328 elv_attribute2,
329 elv_attribute3,
330 elv_attribute4,
331 elv_attribute5,
332 elv_attribute6,
333 elv_attribute7,
334 elv_attribute8,
335 elv_attribute9,
336 elv_attribute10,
337 elv_attribute11,
338 elv_attribute12,
339 elv_attribute13,
340 elv_attribute14,
341 elv_attribute15,
342 elv_attribute16,
343 elv_attribute17,
344 elv_attribute18,
345 elv_attribute19,
346 elv_attribute20,
347 elv_attribute21,
348 elv_attribute22,
349 elv_attribute23,
350 elv_attribute24,
351 elv_attribute25,
352 elv_attribute26,
353 elv_attribute27,
354 elv_attribute28,
355 elv_attribute29,
356 elv_attribute30,
357 object_version_number,
358 criteria_score,
359 criteria_weight
360 from ben_elig_lvg_rsn_prte_f
361 where elig_lvg_rsn_prte_id = p_elig_lvg_rsn_prte_id
362 and p_effective_date
363 between effective_start_date and effective_end_date
364 for update nowait;
365 --
366 --
367 --
368 Begin
369 hr_utility.set_location('Entering:'||l_proc, 5);
370 --
371 -- Ensure that all the mandatory arguments are not null
372 --
373 hr_api.mandatory_arg_error(p_api_name => l_proc,
374 p_argument => 'effective_date',
375 p_argument_value => p_effective_date);
376 --
377 hr_api.mandatory_arg_error(p_api_name => l_proc,
378 p_argument => 'datetrack_mode',
379 p_argument_value => p_datetrack_mode);
380 --
381 hr_api.mandatory_arg_error(p_api_name => l_proc,
382 p_argument => 'elig_lvg_rsn_prte_id',
383 p_argument_value => p_elig_lvg_rsn_prte_id);
384 --
385 hr_api.mandatory_arg_error(p_api_name => l_proc,
386 p_argument => 'object_version_number',
387 p_argument_value => p_object_version_number);
388 --
389 -- Check to ensure the datetrack mode is not INSERT.
390 --
391 If (p_datetrack_mode <> 'INSERT') then
392 --
393 -- We must select and lock the current row.
394 --
395 Open C_Sel1;
396 Fetch C_Sel1 Into g_old_rec;
397 If C_Sel1%notfound then
398 Close C_Sel1;
399 --
400 -- The primary key is invalid therefore we must error
401 --
402 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
403 fnd_message.raise_error;
404 End If;
405 Close C_Sel1;
406 If (p_object_version_number <> g_old_rec.object_version_number) Then
407 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
408 fnd_message.raise_error;
409 End If;
410 hr_utility.set_location(l_proc, 15);
411 --
412 --
413 -- Validate the datetrack mode mode getting the validation start
414 -- and end dates for the specified datetrack operation.
415 --
416 dt_api.validate_dt_mode
417 (p_effective_date => p_effective_date,
418 p_datetrack_mode => p_datetrack_mode,
419 p_base_table_name => 'ben_elig_lvg_rsn_prte_f',
420 p_base_key_column => 'elig_lvg_rsn_prte_id',
421 p_base_key_value => p_elig_lvg_rsn_prte_id,
422 p_parent_table_name1 => 'ben_eligy_prfl_f',
423 p_parent_key_column1 => 'eligy_prfl_id',
424 p_parent_key_value1 => g_old_rec.eligy_prfl_id,
425 p_enforce_foreign_locking => true,
426 p_validation_start_date => l_validation_start_date,
427 p_validation_end_date => l_validation_end_date);
428 Else
429 --
430 -- We are doing a datetrack 'INSERT' which is illegal within this
431 -- procedure therefore we must error (note: to lck on insert the
432 -- private procedure ins_lck should be called).
433 --
434 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
435 fnd_message.set_token('PROCEDURE', l_proc);
436 fnd_message.set_token('STEP','20');
437 fnd_message.raise_error;
438 End If;
439 --
440 -- Set the validation start and end date OUT arguments
441 --
442 p_validation_start_date := l_validation_start_date;
443 p_validation_end_date := l_validation_end_date;
444 --
445 hr_utility.set_location(' Leaving:'||l_proc, 30);
446 --
447 -- We need to trap the ORA LOCK exception
448 --
449 Exception
450 When HR_Api.Object_Locked then
451 --
452 -- The object is locked therefore we need to supply a meaningful
453 -- error message.
454 --
455 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
456 fnd_message.set_token('TABLE_NAME', 'ben_elig_lvg_rsn_prte_f');
457 fnd_message.raise_error;
458 When l_object_invalid then
459 --
460 -- The object doesn't exist or is invalid
461 --
462 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
463 fnd_message.set_token('TABLE_NAME', 'ben_elig_lvg_rsn_prte_f');
464 fnd_message.raise_error;
465 End lck;
466 --
470 Function convert_args
467 -- ----------------------------------------------------------------------------
468 -- |-----------------------------< convert_args >-----------------------------|
469 -- ----------------------------------------------------------------------------
471 (
472 p_elig_lvg_rsn_prte_id in number,
473 p_effective_start_date in date,
474 p_effective_end_date in date,
475 p_excld_flag in varchar2,
476 p_ordr_num in number,
477 p_lvg_rsn_cd in varchar2,
478 p_eligy_prfl_id in number,
479 p_business_group_id in number,
480 p_elv_attribute_category in varchar2,
481 p_elv_attribute1 in varchar2,
482 p_elv_attribute2 in varchar2,
483 p_elv_attribute3 in varchar2,
484 p_elv_attribute4 in varchar2,
485 p_elv_attribute5 in varchar2,
486 p_elv_attribute6 in varchar2,
487 p_elv_attribute7 in varchar2,
488 p_elv_attribute8 in varchar2,
489 p_elv_attribute9 in varchar2,
490 p_elv_attribute10 in varchar2,
491 p_elv_attribute11 in varchar2,
492 p_elv_attribute12 in varchar2,
493 p_elv_attribute13 in varchar2,
494 p_elv_attribute14 in varchar2,
495 p_elv_attribute15 in varchar2,
496 p_elv_attribute16 in varchar2,
497 p_elv_attribute17 in varchar2,
498 p_elv_attribute18 in varchar2,
499 p_elv_attribute19 in varchar2,
500 p_elv_attribute20 in varchar2,
501 p_elv_attribute21 in varchar2,
502 p_elv_attribute22 in varchar2,
503 p_elv_attribute23 in varchar2,
504 p_elv_attribute24 in varchar2,
505 p_elv_attribute25 in varchar2,
506 p_elv_attribute26 in varchar2,
507 p_elv_attribute27 in varchar2,
508 p_elv_attribute28 in varchar2,
509 p_elv_attribute29 in varchar2,
510 p_elv_attribute30 in varchar2,
511 p_object_version_number in number ,
512 p_criteria_score in number ,
513 p_criteria_weight in number
514 )
515 Return g_rec_type is
516 --
517 l_rec g_rec_type;
518 l_proc varchar2(72) := g_package||'convert_args';
519 --
520 Begin
521 --
522 hr_utility.set_location('Entering:'||l_proc, 5);
523 --
524 -- Convert arguments into local l_rec structure.
525 --
526 l_rec.elig_lvg_rsn_prte_id := p_elig_lvg_rsn_prte_id;
527 l_rec.effective_start_date := p_effective_start_date;
528 l_rec.effective_end_date := p_effective_end_date;
529 l_rec.excld_flag := p_excld_flag;
530 l_rec.ordr_num := p_ordr_num;
531 l_rec.lvg_rsn_cd := p_lvg_rsn_cd;
532 l_rec.eligy_prfl_id := p_eligy_prfl_id;
533 l_rec.business_group_id := p_business_group_id;
534 l_rec.elv_attribute_category := p_elv_attribute_category;
535 l_rec.elv_attribute1 := p_elv_attribute1;
536 l_rec.elv_attribute2 := p_elv_attribute2;
537 l_rec.elv_attribute3 := p_elv_attribute3;
538 l_rec.elv_attribute4 := p_elv_attribute4;
539 l_rec.elv_attribute5 := p_elv_attribute5;
540 l_rec.elv_attribute6 := p_elv_attribute6;
541 l_rec.elv_attribute7 := p_elv_attribute7;
542 l_rec.elv_attribute8 := p_elv_attribute8;
543 l_rec.elv_attribute9 := p_elv_attribute9;
544 l_rec.elv_attribute10 := p_elv_attribute10;
545 l_rec.elv_attribute11 := p_elv_attribute11;
546 l_rec.elv_attribute12 := p_elv_attribute12;
547 l_rec.elv_attribute13 := p_elv_attribute13;
548 l_rec.elv_attribute14 := p_elv_attribute14;
549 l_rec.elv_attribute15 := p_elv_attribute15;
550 l_rec.elv_attribute16 := p_elv_attribute16;
551 l_rec.elv_attribute17 := p_elv_attribute17;
552 l_rec.elv_attribute18 := p_elv_attribute18;
553 l_rec.elv_attribute19 := p_elv_attribute19;
554 l_rec.elv_attribute20 := p_elv_attribute20;
555 l_rec.elv_attribute21 := p_elv_attribute21;
556 l_rec.elv_attribute22 := p_elv_attribute22;
557 l_rec.elv_attribute23 := p_elv_attribute23;
558 l_rec.elv_attribute24 := p_elv_attribute24;
559 l_rec.elv_attribute25 := p_elv_attribute25;
560 l_rec.elv_attribute26 := p_elv_attribute26;
561 l_rec.elv_attribute27 := p_elv_attribute27;
562 l_rec.elv_attribute28 := p_elv_attribute28;
563 l_rec.elv_attribute29 := p_elv_attribute29;
564 l_rec.elv_attribute30 := p_elv_attribute30;
565 l_rec.object_version_number := p_object_version_number;
566 l_rec.criteria_score := p_criteria_score;
567 l_rec.criteria_weight := p_criteria_weight;
568 --
569 -- Return the plsql record structure.
570 --
571 hr_utility.set_location(' Leaving:'||l_proc, 10);
572 Return(l_rec);
573 --
574 End convert_args;
575 --
576 end ben_elv_shd;