[Home] [Help]
PACKAGE BODY: APPS.BEN_EPZ_SHD
Source
1 Package Body ben_epz_shd as
2 /* $Header: beepzrhi.pkb 120.1 2006/02/26 23:58:04 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_epz_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_PSTL_CD_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_PSTL_CD_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 ElsIf (p_constraint_name = 'BEN_ELIG_PSTL_CD_FK2') 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','15');
50 fnd_message.raise_error;
51 -- Deleted lines for constraint_name = 'BEN_ELIG_ZIP_PSTL_CD_PRTE_UK'
52 -- The constraint has been dropped from the table 'BEN_ELIG_PSTL_CD_R_RNG_PRTE_F'
53 Else
54 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
55 fnd_message.set_token('PROCEDURE', l_proc);
56 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
57 fnd_message.raise_error;
58 End If;
59 --
60 hr_utility.set_location(' Leaving:'||l_proc, 10);
61 End constraint_error;
62 --
63 -- ----------------------------------------------------------------------------
64 -- |-----------------------------< api_updating >-----------------------------|
65 -- ----------------------------------------------------------------------------
66 Function api_updating
67 (p_effective_date in date,
68 p_elig_pstl_cd_r_rng_prte_id in number,
69 p_object_version_number in number
70 ) Return Boolean Is
71 --
72 --
73 -- Cursor selects the 'current' row from the HR Schema
74 --
75 Cursor C_Sel1 is
76 select
77 elig_pstl_cd_r_rng_prte_id,
78 effective_start_date,
79 effective_end_date,
80 ordr_num,
81 excld_flag,
82 pstl_zip_rng_id,
83 eligy_prfl_id,
84 business_group_id,
85 epz_attribute_category,
86 epz_attribute1,
87 epz_attribute2,
88 epz_attribute3,
89 epz_attribute4,
90 epz_attribute5,
91 epz_attribute6,
92 epz_attribute7,
93 epz_attribute8,
94 epz_attribute9,
95 epz_attribute10,
96 epz_attribute11,
97 epz_attribute12,
98 epz_attribute13,
99 epz_attribute14,
100 epz_attribute15,
101 epz_attribute16,
102 epz_attribute17,
103 epz_attribute18,
104 epz_attribute19,
105 epz_attribute20,
106 epz_attribute21,
107 epz_attribute22,
108 epz_attribute23,
109 epz_attribute24,
110 epz_attribute25,
111 epz_attribute26,
112 epz_attribute27,
113 epz_attribute28,
114 epz_attribute29,
115 epz_attribute30,
116 object_version_number,
117 criteria_score,
118 criteria_weight
119 from ben_elig_pstl_cd_r_rng_prte_f
120 where elig_pstl_cd_r_rng_prte_id = p_elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_id = g_old_rec.elig_pstl_cd_r_rng_prte_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.eligy_prfl_id,
193 t.pstl_zip_rng_id
194 from ben_elig_pstl_cd_r_rng_prte_f t
195 where t.elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_f',
218 p_base_key_column => 'elig_pstl_cd_r_rng_prte_id',
219 p_base_key_value => p_base_key_value,
220 p_parent_table_name1 => 'ben_eligy_prfl_f',
221 p_parent_key_column1 => 'eligy_prfl_id',
222 p_parent_key_value1 => l_parent_key_value1,
223 p_parent_table_name2 => 'ben_pstl_zip_rng_f',
224 p_parent_key_column2 => 'pstl_zip_rng_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_elig_pstl_cd_r_rng_prte_f',
255 p_base_key_column => 'elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_f',
288 p_base_key_column => 'elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_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.elig_pstl_cd_r_rng_prte_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_elig_pstl_cd_r_rng_prte_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 elig_pstl_cd_r_rng_prte_id,
337 effective_start_date,
338 effective_end_date,
339 ordr_num,
340 excld_flag,
341 pstl_zip_rng_id,
342 eligy_prfl_id,
343 business_group_id,
344 epz_attribute_category,
345 epz_attribute1,
346 epz_attribute2,
347 epz_attribute3,
348 epz_attribute4,
349 epz_attribute5,
350 epz_attribute6,
351 epz_attribute7,
352 epz_attribute8,
353 epz_attribute9,
354 epz_attribute10,
355 epz_attribute11,
356 epz_attribute12,
357 epz_attribute13,
358 epz_attribute14,
359 epz_attribute15,
360 epz_attribute16,
361 epz_attribute17,
362 epz_attribute18,
363 epz_attribute19,
364 epz_attribute20,
365 epz_attribute21,
366 epz_attribute22,
367 epz_attribute23,
368 epz_attribute24,
369 epz_attribute25,
370 epz_attribute26,
371 epz_attribute27,
372 epz_attribute28,
373 epz_attribute29,
374 epz_attribute30,
375 object_version_number ,
376 criteria_score,
377 criteria_weight
378 from ben_elig_pstl_cd_r_rng_prte_f
379 where elig_pstl_cd_r_rng_prte_id = p_elig_pstl_cd_r_rng_prte_id
380 and p_effective_date
381 between effective_start_date and effective_end_date
382 for update nowait;
383 --
384 --
385 --
386 Begin
387 hr_utility.set_location('Entering:'||l_proc, 5);
388 --
389 -- Ensure that all the mandatory arguments are not null
390 --
391 hr_api.mandatory_arg_error(p_api_name => l_proc,
392 p_argument => 'effective_date',
393 p_argument_value => p_effective_date);
394 --
395 hr_api.mandatory_arg_error(p_api_name => l_proc,
399 hr_api.mandatory_arg_error(p_api_name => l_proc,
396 p_argument => 'datetrack_mode',
397 p_argument_value => p_datetrack_mode);
398 --
400 p_argument => 'elig_pstl_cd_r_rng_prte_id',
401 p_argument_value => p_elig_pstl_cd_r_rng_prte_id);
402 --
403 hr_api.mandatory_arg_error(p_api_name => l_proc,
404 p_argument => 'object_version_number',
405 p_argument_value => p_object_version_number);
406 --
407 -- Check to ensure the datetrack mode is not INSERT.
408 --
409 If (p_datetrack_mode <> 'INSERT') then
410 --
411 -- We must select and lock the current row.
412 --
413 Open C_Sel1;
414 Fetch C_Sel1 Into g_old_rec;
415 If C_Sel1%notfound then
416 Close C_Sel1;
417 --
418 -- The primary key is invalid therefore we must error
419 --
420 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
421 fnd_message.raise_error;
422 End If;
423 Close C_Sel1;
424 If (p_object_version_number <> g_old_rec.object_version_number) Then
425 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
426 fnd_message.raise_error;
427 End If;
428 hr_utility.set_location(l_proc, 15);
429 --
430 --
431 -- Validate the datetrack mode mode getting the validation start
432 -- and end dates for the specified datetrack operation.
433 --
434 dt_api.validate_dt_mode
435 (p_effective_date => p_effective_date,
436 p_datetrack_mode => p_datetrack_mode,
437 p_base_table_name => 'ben_elig_pstl_cd_r_rng_prte_f',
438 p_base_key_column => 'elig_pstl_cd_r_rng_prte_id',
439 p_base_key_value => p_elig_pstl_cd_r_rng_prte_id,
440 p_parent_table_name1 => 'ben_eligy_prfl_f',
441 p_parent_key_column1 => 'eligy_prfl_id',
442 p_parent_key_value1 => g_old_rec.eligy_prfl_id,
443 p_parent_table_name2 => 'ben_pstl_zip_rng_f',
444 p_parent_key_column2 => 'pstl_zip_rng_id',
445 p_parent_key_value2 => g_old_rec.pstl_zip_rng_id,
446 p_enforce_foreign_locking => true,
447 p_validation_start_date => l_validation_start_date,
448 p_validation_end_date => l_validation_end_date);
449 Else
450 --
451 -- We are doing a datetrack 'INSERT' which is illegal within this
452 -- procedure therefore we must error (note: to lck on insert the
453 -- private procedure ins_lck should be called).
454 --
455 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
456 fnd_message.set_token('PROCEDURE', l_proc);
457 fnd_message.set_token('STEP','20');
458 fnd_message.raise_error;
459 End If;
460 --
461 -- Set the validation start and end date OUT arguments
462 --
463 p_validation_start_date := l_validation_start_date;
464 p_validation_end_date := l_validation_end_date;
465 --
466 hr_utility.set_location(' Leaving:'||l_proc, 30);
467 --
468 -- We need to trap the ORA LOCK exception
469 --
470 Exception
471 When HR_Api.Object_Locked then
472 --
473 -- The object is locked therefore we need to supply a meaningful
474 -- error message.
475 --
476 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
477 fnd_message.set_token('TABLE_NAME', 'ben_elig_pstl_cd_r_rng_prte_f');
478 fnd_message.raise_error;
479 When l_object_invalid then
480 --
481 -- The object doesn't exist or is invalid
482 --
483 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
484 fnd_message.set_token('TABLE_NAME', 'ben_elig_pstl_cd_r_rng_prte_f');
485 fnd_message.raise_error;
486 End lck;
487 --
488 -- ----------------------------------------------------------------------------
489 -- |-----------------------------< convert_args >-----------------------------|
490 -- ----------------------------------------------------------------------------
491 Function convert_args
492 (
493 p_elig_pstl_cd_r_rng_prte_id in number,
494 p_effective_start_date in date,
495 p_effective_end_date in date,
496 p_ordr_num in number,
497 p_excld_flag in varchar2,
498 p_pstl_zip_rng_id in number,
499 p_eligy_prfl_id in number,
500 p_business_group_id in number,
501 p_epz_attribute_category in varchar2,
502 p_epz_attribute1 in varchar2,
503 p_epz_attribute2 in varchar2,
504 p_epz_attribute3 in varchar2,
505 p_epz_attribute4 in varchar2,
506 p_epz_attribute5 in varchar2,
507 p_epz_attribute6 in varchar2,
508 p_epz_attribute7 in varchar2,
509 p_epz_attribute8 in varchar2,
510 p_epz_attribute9 in varchar2,
511 p_epz_attribute10 in varchar2,
512 p_epz_attribute11 in varchar2,
513 p_epz_attribute12 in varchar2,
514 p_epz_attribute13 in varchar2,
515 p_epz_attribute14 in varchar2,
516 p_epz_attribute15 in varchar2,
517 p_epz_attribute16 in varchar2,
518 p_epz_attribute17 in varchar2,
519 p_epz_attribute18 in varchar2,
520 p_epz_attribute19 in varchar2,
521 p_epz_attribute20 in varchar2,
522 p_epz_attribute21 in varchar2,
523 p_epz_attribute22 in varchar2,
524 p_epz_attribute23 in varchar2,
525 p_epz_attribute24 in varchar2,
526 p_epz_attribute25 in varchar2,
527 p_epz_attribute26 in varchar2,
528 p_epz_attribute27 in varchar2,
529 p_epz_attribute28 in varchar2,
530 p_epz_attribute29 in varchar2,
531 p_epz_attribute30 in varchar2,
532 p_object_version_number in number ,
533 p_criteria_score in number ,
534 p_criteria_weight in number
535 )
536 Return g_rec_type is
537 --
538 l_rec g_rec_type;
539 l_proc varchar2(72) := g_package||'convert_args';
540 --
541 Begin
542 --
543 hr_utility.set_location('Entering:'||l_proc, 5);
544 --
545 -- Convert arguments into local l_rec structure.
546 --
547 l_rec.elig_pstl_cd_r_rng_prte_id := p_elig_pstl_cd_r_rng_prte_id;
548 l_rec.effective_start_date := p_effective_start_date;
549 l_rec.effective_end_date := p_effective_end_date;
550 l_rec.ordr_num := p_ordr_num;
551 l_rec.excld_flag := p_excld_flag;
552 l_rec.pstl_zip_rng_id := p_pstl_zip_rng_id;
553 l_rec.eligy_prfl_id := p_eligy_prfl_id;
554 l_rec.business_group_id := p_business_group_id;
555 l_rec.epz_attribute_category := p_epz_attribute_category;
556 l_rec.epz_attribute1 := p_epz_attribute1;
557 l_rec.epz_attribute2 := p_epz_attribute2;
558 l_rec.epz_attribute3 := p_epz_attribute3;
559 l_rec.epz_attribute4 := p_epz_attribute4;
560 l_rec.epz_attribute5 := p_epz_attribute5;
561 l_rec.epz_attribute6 := p_epz_attribute6;
562 l_rec.epz_attribute7 := p_epz_attribute7;
563 l_rec.epz_attribute8 := p_epz_attribute8;
564 l_rec.epz_attribute9 := p_epz_attribute9;
565 l_rec.epz_attribute10 := p_epz_attribute10;
566 l_rec.epz_attribute11 := p_epz_attribute11;
567 l_rec.epz_attribute12 := p_epz_attribute12;
568 l_rec.epz_attribute13 := p_epz_attribute13;
569 l_rec.epz_attribute14 := p_epz_attribute14;
570 l_rec.epz_attribute15 := p_epz_attribute15;
571 l_rec.epz_attribute16 := p_epz_attribute16;
572 l_rec.epz_attribute17 := p_epz_attribute17;
573 l_rec.epz_attribute18 := p_epz_attribute18;
574 l_rec.epz_attribute19 := p_epz_attribute19;
575 l_rec.epz_attribute20 := p_epz_attribute20;
576 l_rec.epz_attribute21 := p_epz_attribute21;
577 l_rec.epz_attribute22 := p_epz_attribute22;
578 l_rec.epz_attribute23 := p_epz_attribute23;
579 l_rec.epz_attribute24 := p_epz_attribute24;
580 l_rec.epz_attribute25 := p_epz_attribute25;
581 l_rec.epz_attribute26 := p_epz_attribute26;
582 l_rec.epz_attribute27 := p_epz_attribute27;
583 l_rec.epz_attribute28 := p_epz_attribute28;
584 l_rec.epz_attribute29 := p_epz_attribute29;
585 l_rec.epz_attribute30 := p_epz_attribute30;
586 l_rec.object_version_number := p_object_version_number;
587 l_rec.criteria_score := p_criteria_score;
588 l_rec.criteria_weight := p_criteria_weight;
589 --
590 -- Return the plsql record structure.
591 --
592 hr_utility.set_location(' Leaving:'||l_proc, 10);
593 Return(l_rec);
594 --
595 End convert_args;
596 --
597 end ben_epz_shd;