[Home] [Help]
PACKAGE BODY: APPS.BEN_DCR_SHD
Source
1 Package Body ben_dcr_shd as
2 /* $Header: bedcrrhi.pkb 115.8 2002/12/10 15:17:20 bmanyam ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_dcr_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_DP_CVG_R_RLSP_FK1') Then
37 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38 fnd_message.set_token('PROCEDURE', l_proc);
39 fnd_message.raise_error;
40 ElsIf (p_constraint_name = 'BEN_DP_CVG_R_RLSP_FK2') Then
41 fnd_message.set_token('PROCEDURE', l_proc);
42 fnd_message.set_token('STEP','10');
43 fnd_message.raise_error;
44 ElsIf (p_constraint_name = 'BEN_DP_CVG_R_RLSP_PK') Then
45 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
46 fnd_message.raise_error;
47 Else
48 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
49 fnd_message.set_token('PROCEDURE', l_proc);
50 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
51 fnd_message.raise_error;
52 End If;
53 --
54 hr_utility.set_location(' Leaving:'||l_proc, 10);
55 End constraint_error;
56 --
57 -- ----------------------------------------------------------------------------
58 -- |-----------------------------< api_updating >-----------------------------|
59 -- ----------------------------------------------------------------------------
60 Function api_updating
61 (p_effective_date in date,
62 p_dpnt_cvg_rqd_rlshp_id in number,
63 p_object_version_number in number
64 ) Return Boolean Is
65 --
66 --
67 -- Cursor selects the 'current' row from the HR Schema
68 --
69 Cursor C_Sel1 is
70 select
71 dpnt_cvg_rqd_rlshp_id,
72 effective_start_date,
73 effective_end_date,
74 business_group_id,
75 per_relshp_typ_cd,
76 cvg_strt_dt_cd,
77 cvg_thru_dt_rl,
78 cvg_thru_dt_cd,
79 cvg_strt_dt_rl,
80 dpnt_cvg_eligy_prfl_id,
81 dcr_attribute_category,
82 dcr_attribute1,
83 dcr_attribute2,
84 dcr_attribute3,
85 dcr_attribute4,
86 dcr_attribute5,
87 dcr_attribute6,
88 dcr_attribute7,
89 dcr_attribute8,
90 dcr_attribute9,
91 dcr_attribute10,
92 dcr_attribute11,
93 dcr_attribute12,
94 dcr_attribute13,
95 dcr_attribute14,
96 dcr_attribute15,
97 dcr_attribute16,
98 dcr_attribute17,
99 dcr_attribute18,
100 dcr_attribute19,
101 dcr_attribute20,
102 dcr_attribute21,
103 dcr_attribute22,
104 dcr_attribute23,
105 dcr_attribute24,
106 dcr_attribute25,
107 dcr_attribute26,
108 dcr_attribute27,
109 dcr_attribute28,
110 dcr_attribute29,
111 dcr_attribute30,
112 object_version_number
113 from ben_dpnt_cvg_rqd_rlshp_f
114 where dpnt_cvg_rqd_rlshp_id = p_dpnt_cvg_rqd_rlshp_id
115 and p_effective_date
116 between effective_start_date and effective_end_date;
117 --
118 l_proc varchar2(72) := g_package||'api_updating';
119 l_fct_ret boolean;
120 --
121 Begin
122 hr_utility.set_location('Entering:'||l_proc, 5);
123 --
124 If (p_effective_date is null or
125 p_dpnt_cvg_rqd_rlshp_id is null or
126 p_object_version_number is null) Then
127 --
128 -- One of the primary key arguments is null therefore we must
129 -- set the returning function value to false
130 --
131 l_fct_ret := false;
132 Else
133 If (p_dpnt_cvg_rqd_rlshp_id = g_old_rec.dpnt_cvg_rqd_rlshp_id and
134 p_object_version_number = g_old_rec.object_version_number) Then
135 hr_utility.set_location(l_proc, 10);
136 --
137 -- The g_old_rec is current therefore we must
138 -- set the returning function to true
139 --
140 l_fct_ret := true;
141 Else
142 --
143 -- Select the current row
144 --
145 Open C_Sel1;
146 Fetch C_Sel1 Into g_old_rec;
147 If C_Sel1%notfound Then
148 Close C_Sel1;
149 --
150 -- The primary key is invalid therefore we must error
151 --
152 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
153 fnd_message.raise_error;
154 End If;
155 Close C_Sel1;
156 If (p_object_version_number <> g_old_rec.object_version_number) Then
157 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
158 fnd_message.raise_error;
159 End If;
160 hr_utility.set_location(l_proc, 15);
161 l_fct_ret := true;
162 End If;
163 End If;
164 hr_utility.set_location(' Leaving:'||l_proc, 20);
165 Return (l_fct_ret);
166 --
167 End api_updating;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |--------------------------< find_dt_del_modes >---------------------------|
171 -- ----------------------------------------------------------------------------
172 Procedure find_dt_del_modes
173 (p_effective_date in date,
174 p_base_key_value in number,
175 p_zap out nocopy boolean,
176 p_delete out nocopy boolean,
177 p_future_change out nocopy boolean,
178 p_delete_next_change out nocopy boolean) is
179 --
180 l_proc varchar2(72) := g_package||'find_dt_del_modes';
181 --
182 l_parent_key_value1 number;
183 --
184 Cursor C_Sel1 Is
185 select t.dpnt_cvg_eligy_prfl_id
186 from ben_dpnt_cvg_rqd_rlshp_f t
187 where t.dpnt_cvg_rqd_rlshp_id = p_base_key_value
188 and p_effective_date
189 between t.effective_start_date and t.effective_end_date;
190 --
191 Begin
192 hr_utility.set_location('Entering:'||l_proc, 5);
193 Open C_Sel1;
194 Fetch C_Sel1 Into l_parent_key_value1;
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_dpnt_cvg_rqd_rlshp_f',
209 p_base_key_column => 'dpnt_cvg_rqd_rlshp_id',
210 p_base_key_value => p_base_key_value,
211 p_parent_table_name1 => 'ben_dpnt_cvg_eligy_prfl_f',
212 p_parent_key_column1 => 'dpnt_cvg_eligy_prfl_id',
213 p_parent_key_value1 => l_parent_key_value1,
214 p_zap => p_zap,
215 p_delete => p_delete,
216 p_future_change => p_future_change,
217 p_delete_next_change => p_delete_next_change);
218 --
219 hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End find_dt_del_modes;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |--------------------------< find_dt_upd_modes >---------------------------|
224 -- ----------------------------------------------------------------------------
225 Procedure find_dt_upd_modes
226 (p_effective_date in date,
227 p_base_key_value in number,
228 p_correction out nocopy boolean,
229 p_update out nocopy boolean,
230 p_update_override out nocopy boolean,
231 p_update_change_insert out nocopy boolean) is
232 --
233 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
234 --
235 Begin
236 hr_utility.set_location('Entering:'||l_proc, 5);
237 --
238 -- Call the corresponding datetrack api
239 --
240 dt_api.find_dt_upd_modes
241 (p_effective_date => p_effective_date,
242 p_base_table_name => 'ben_dpnt_cvg_rqd_rlshp_f',
243 p_base_key_column => 'dpnt_cvg_rqd_rlshp_id',
244 p_base_key_value => p_base_key_value,
245 p_correction => p_correction,
246 p_update => p_update,
247 p_update_override => p_update_override,
248 p_update_change_insert => p_update_change_insert);
249 --
250 hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End find_dt_upd_modes;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |------------------------< upd_effective_end_date >------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure upd_effective_end_date
257 (p_effective_date in date,
258 p_base_key_value in number,
259 p_new_effective_end_date in date,
260 p_validation_start_date in date,
261 p_validation_end_date in date,
262 p_object_version_number out nocopy number) is
263 --
264 l_proc varchar2(72) := g_package||'upd_effective_end_date';
265 l_object_version_number number;
266 --
267 Begin
268 hr_utility.set_location('Entering:'||l_proc, 5);
269 --
270 -- Because we are updating a row we must get the next object
271 -- version number.
272 --
273 l_object_version_number :=
274 dt_api.get_object_version_number
275 (p_base_table_name => 'ben_dpnt_cvg_rqd_rlshp_f',
276 p_base_key_column => 'dpnt_cvg_rqd_rlshp_id',
277 p_base_key_value => p_base_key_value);
278 --
279 hr_utility.set_location(l_proc, 10);
280 g_api_dml := true; -- Set the api dml status
281 --
282 -- Update the specified datetrack row setting the effective
283 -- end date to the specified new effective end date.
284 --
285 update ben_dpnt_cvg_rqd_rlshp_f t
286 set t.effective_end_date = p_new_effective_end_date,
287 t.object_version_number = l_object_version_number
288 where t.dpnt_cvg_rqd_rlshp_id = p_base_key_value
289 and p_effective_date
290 between t.effective_start_date and t.effective_end_date;
291 --
292 g_api_dml := false; -- Unset the api dml status
293 p_object_version_number := l_object_version_number;
294 hr_utility.set_location(' Leaving:'||l_proc, 15);
295 --
296 Exception
297 When Others Then
298 g_api_dml := false; -- Unset the api dml status
299 Raise;
300 End upd_effective_end_date;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< lck >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure lck
306 (p_effective_date in date,
307 p_datetrack_mode in varchar2,
308 p_dpnt_cvg_rqd_rlshp_id in number,
309 p_object_version_number in number,
310 p_validation_start_date out nocopy date,
311 p_validation_end_date out nocopy date) is
312 --
313 l_proc varchar2(72) := g_package||'lck';
314 l_validation_start_date date;
315 l_validation_end_date date;
316 l_object_invalid exception;
317 l_argument varchar2(30);
318 --
319 -- Cursor C_Sel1 selects the current locked row as of session date
320 -- ensuring that the object version numbers match.
321 --
322 Cursor C_Sel1 is
323 select
324 dpnt_cvg_rqd_rlshp_id,
325 effective_start_date,
326 effective_end_date,
327 business_group_id,
328 per_relshp_typ_cd,
329 cvg_strt_dt_cd,
330 cvg_thru_dt_rl,
331 cvg_thru_dt_cd,
332 cvg_strt_dt_rl,
333 dpnt_cvg_eligy_prfl_id,
334 dcr_attribute_category,
335 dcr_attribute1,
336 dcr_attribute2,
337 dcr_attribute3,
338 dcr_attribute4,
339 dcr_attribute5,
340 dcr_attribute6,
341 dcr_attribute7,
342 dcr_attribute8,
343 dcr_attribute9,
344 dcr_attribute10,
345 dcr_attribute11,
346 dcr_attribute12,
347 dcr_attribute13,
348 dcr_attribute14,
349 dcr_attribute15,
350 dcr_attribute16,
351 dcr_attribute17,
352 dcr_attribute18,
353 dcr_attribute19,
354 dcr_attribute20,
355 dcr_attribute21,
356 dcr_attribute22,
357 dcr_attribute23,
358 dcr_attribute24,
359 dcr_attribute25,
360 dcr_attribute26,
361 dcr_attribute27,
362 dcr_attribute28,
363 dcr_attribute29,
364 dcr_attribute30,
365 object_version_number
366 from ben_dpnt_cvg_rqd_rlshp_f
367 where dpnt_cvg_rqd_rlshp_id = p_dpnt_cvg_rqd_rlshp_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',
384 p_argument => 'datetrack_mode',
381 p_argument_value => p_effective_date);
382 --
383 hr_api.mandatory_arg_error(p_api_name => l_proc,
385 p_argument_value => p_datetrack_mode);
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'dpnt_cvg_rqd_rlshp_id',
389 p_argument_value => p_dpnt_cvg_rqd_rlshp_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
398 --
399 -- We must select and lock the current row.
400 --
401 Open C_Sel1;
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_dpnt_cvg_rqd_rlshp_f',
426 p_base_key_column => 'dpnt_cvg_rqd_rlshp_id',
427 p_base_key_value => p_dpnt_cvg_rqd_rlshp_id,
428 p_parent_table_name1 => 'ben_dpnt_cvg_eligy_prfl_f',
429 p_parent_key_column1 => 'dpnt_cvg_eligy_prfl_id',
430 p_parent_key_value1 => g_old_rec.dpnt_cvg_eligy_prfl_id,
431 p_enforce_foreign_locking => true,
432 p_validation_start_date => l_validation_start_date,
433 p_validation_end_date => l_validation_end_date);
434 Else
435 --
436 -- We are doing a datetrack 'INSERT' which is illegal within this
437 -- procedure therefore we must error (note: to lck on insert the
438 -- private procedure ins_lck should be called).
439 --
440 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
441 fnd_message.set_token('PROCEDURE', l_proc);
442 fnd_message.set_token('STEP','20');
443 fnd_message.raise_error;
444 End If;
445 --
446 -- Set the validation start and end date OUT arguments
447 --
448 p_validation_start_date := l_validation_start_date;
449 p_validation_end_date := l_validation_end_date;
450 --
451 hr_utility.set_location(' Leaving:'||l_proc, 30);
452 --
453 -- We need to trap the ORA LOCK exception
454 --
455 Exception
456 When HR_Api.Object_Locked then
457 --
458 -- The object is locked therefore we need to supply a meaningful
459 -- error message.
460 --
461 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
462 fnd_message.set_token('TABLE_NAME', 'ben_dpnt_cvg_rqd_rlshp_f');
463 fnd_message.raise_error;
464 When l_object_invalid then
465 --
466 -- The object doesn't exist or is invalid
467 --
468 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
469 fnd_message.set_token('TABLE_NAME', 'ben_dpnt_cvg_rqd_rlshp_f');
470 fnd_message.raise_error;
471 End lck;
472 --
473 -- ----------------------------------------------------------------------------
474 -- |-----------------------------< convert_args >-----------------------------|
475 -- ----------------------------------------------------------------------------
476 Function convert_args
477 (
478 p_dpnt_cvg_rqd_rlshp_id in number,
479 p_effective_start_date in date,
480 p_effective_end_date in date,
481 p_business_group_id in number,
482 p_per_relshp_typ_cd in varchar2,
483 p_cvg_strt_dt_cd in varchar2,
484 p_cvg_thru_dt_rl in number,
485 p_cvg_thru_dt_cd in varchar2,
486 p_cvg_strt_dt_rl in number,
487 p_dpnt_cvg_eligy_prfl_id in number,
488 p_dcr_attribute_category in varchar2,
489 p_dcr_attribute1 in varchar2,
490 p_dcr_attribute2 in varchar2,
491 p_dcr_attribute3 in varchar2,
492 p_dcr_attribute4 in varchar2,
493 p_dcr_attribute5 in varchar2,
494 p_dcr_attribute6 in varchar2,
495 p_dcr_attribute7 in varchar2,
496 p_dcr_attribute8 in varchar2,
497 p_dcr_attribute9 in varchar2,
498 p_dcr_attribute10 in varchar2,
499 p_dcr_attribute11 in varchar2,
500 p_dcr_attribute12 in varchar2,
501 p_dcr_attribute13 in varchar2,
502 p_dcr_attribute14 in varchar2,
503 p_dcr_attribute15 in varchar2,
504 p_dcr_attribute16 in varchar2,
508 p_dcr_attribute20 in varchar2,
505 p_dcr_attribute17 in varchar2,
506 p_dcr_attribute18 in varchar2,
507 p_dcr_attribute19 in varchar2,
509 p_dcr_attribute21 in varchar2,
510 p_dcr_attribute22 in varchar2,
511 p_dcr_attribute23 in varchar2,
512 p_dcr_attribute24 in varchar2,
513 p_dcr_attribute25 in varchar2,
514 p_dcr_attribute26 in varchar2,
515 p_dcr_attribute27 in varchar2,
516 p_dcr_attribute28 in varchar2,
517 p_dcr_attribute29 in varchar2,
518 p_dcr_attribute30 in varchar2,
519 p_object_version_number in number
520 )
521 Return g_rec_type is
522 --
523 l_rec g_rec_type;
524 l_proc varchar2(72) := g_package||'convert_args';
525 --
526 Begin
527 --
528 hr_utility.set_location('Entering:'||l_proc, 5);
529 --
530 -- Convert arguments into local l_rec structure.
531 --
532 l_rec.dpnt_cvg_rqd_rlshp_id := p_dpnt_cvg_rqd_rlshp_id;
533 l_rec.effective_start_date := p_effective_start_date;
534 l_rec.effective_end_date := p_effective_end_date;
535 l_rec.business_group_id := p_business_group_id;
536 l_rec.per_relshp_typ_cd := p_per_relshp_typ_cd;
537 l_rec.cvg_strt_dt_cd := p_cvg_strt_dt_cd;
538 l_rec.cvg_thru_dt_rl := p_cvg_thru_dt_rl;
539 l_rec.cvg_thru_dt_cd := p_cvg_thru_dt_cd;
540 l_rec.cvg_strt_dt_rl := p_cvg_strt_dt_rl;
541 l_rec.dpnt_cvg_eligy_prfl_id := p_dpnt_cvg_eligy_prfl_id;
542 l_rec.dcr_attribute_category := p_dcr_attribute_category;
543 l_rec.dcr_attribute1 := p_dcr_attribute1;
544 l_rec.dcr_attribute2 := p_dcr_attribute2;
545 l_rec.dcr_attribute3 := p_dcr_attribute3;
546 l_rec.dcr_attribute4 := p_dcr_attribute4;
547 l_rec.dcr_attribute5 := p_dcr_attribute5;
548 l_rec.dcr_attribute6 := p_dcr_attribute6;
549 l_rec.dcr_attribute7 := p_dcr_attribute7;
550 l_rec.dcr_attribute8 := p_dcr_attribute8;
551 l_rec.dcr_attribute9 := p_dcr_attribute9;
552 l_rec.dcr_attribute10 := p_dcr_attribute10;
553 l_rec.dcr_attribute11 := p_dcr_attribute11;
554 l_rec.dcr_attribute12 := p_dcr_attribute12;
555 l_rec.dcr_attribute13 := p_dcr_attribute13;
556 l_rec.dcr_attribute14 := p_dcr_attribute14;
557 l_rec.dcr_attribute15 := p_dcr_attribute15;
558 l_rec.dcr_attribute16 := p_dcr_attribute16;
559 l_rec.dcr_attribute17 := p_dcr_attribute17;
560 l_rec.dcr_attribute18 := p_dcr_attribute18;
561 l_rec.dcr_attribute19 := p_dcr_attribute19;
562 l_rec.dcr_attribute20 := p_dcr_attribute20;
563 l_rec.dcr_attribute21 := p_dcr_attribute21;
564 l_rec.dcr_attribute22 := p_dcr_attribute22;
565 l_rec.dcr_attribute23 := p_dcr_attribute23;
566 l_rec.dcr_attribute24 := p_dcr_attribute24;
567 l_rec.dcr_attribute25 := p_dcr_attribute25;
568 l_rec.dcr_attribute26 := p_dcr_attribute26;
569 l_rec.dcr_attribute27 := p_dcr_attribute27;
570 l_rec.dcr_attribute28 := p_dcr_attribute28;
571 l_rec.dcr_attribute29 := p_dcr_attribute29;
572 l_rec.dcr_attribute30 := p_dcr_attribute30;
573 l_rec.object_version_number := p_object_version_number;
574 --
575 -- Return the plsql record structure.
576 --
577 hr_utility.set_location(' Leaving:'||l_proc, 10);
578 Return(l_rec);
579 --
580 End convert_args;
581 --
582 end ben_dcr_shd;