[Home] [Help]
PACKAGE BODY: APPS.BEN_LBC_SHD
Source
1 Package Body ben_lbc_shd as
2 /* $Header: belbcrhi.pkb 120.0 2005/05/28 03:15:49 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_lbc_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_LER_BNFT_RSTRN_CTFN_F_FK1') Then
37 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38 hr_utility.set_message_token('PROCEDURE', l_proc);
39 hr_utility.set_message_token('STEP','5');
40 hr_utility.raise_error;
41 ElsIf (p_constraint_name = 'BEN_LER_BNFT_RSTRN_CTFN_F_PK') Then
42 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43 hr_utility.set_message_token('PROCEDURE', l_proc);
44 hr_utility.set_message_token('STEP','10');
45 hr_utility.raise_error;
46 Else
47 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
48 hr_utility.set_message_token('PROCEDURE', l_proc);
49 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
50 hr_utility.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_ler_bnft_rstrn_ctfn_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 ler_bnft_rstrn_ctfn_id,
71 effective_start_date,
72 effective_end_date,
73 rqd_flag,
74 enrt_ctfn_typ_cd,
75 ctfn_rqd_when_rl,
76 ler_bnft_rstrn_id,
77 business_group_id,
78 lbc_attribute_category,
79 lbc_attribute1,
80 lbc_attribute2,
81 lbc_attribute3,
82 lbc_attribute4,
83 lbc_attribute5,
84 lbc_attribute6,
85 lbc_attribute7,
86 lbc_attribute8,
87 lbc_attribute9,
88 lbc_attribute10,
89 lbc_attribute11,
90 lbc_attribute12,
91 lbc_attribute13,
92 lbc_attribute14,
93 lbc_attribute15,
94 lbc_attribute16,
95 lbc_attribute17,
96 lbc_attribute18,
97 lbc_attribute19,
98 lbc_attribute20,
99 lbc_attribute21,
100 lbc_attribute22,
101 lbc_attribute23,
102 lbc_attribute24,
103 lbc_attribute25,
104 lbc_attribute26,
105 lbc_attribute27,
106 lbc_attribute28,
107 lbc_attribute29,
108 lbc_attribute30,
109 object_version_number
110 from ben_ler_bnft_rstrn_ctfn_f
111 where ler_bnft_rstrn_ctfn_id = p_ler_bnft_rstrn_ctfn_id
112 and p_effective_date
113 between effective_start_date and effective_end_date;
114 --
115 l_proc varchar2(72) := g_package||'api_updating';
116 l_fct_ret boolean;
117 --
118 Begin
119 hr_utility.set_location('Entering:'||l_proc, 5);
120 --
121 If (p_effective_date is null or
122 p_ler_bnft_rstrn_ctfn_id is null or
123 p_object_version_number is null) Then
124 --
125 -- One of the primary key arguments is null therefore we must
126 -- set the returning function value to false
127 --
128 l_fct_ret := false;
129 Else
130 If (p_ler_bnft_rstrn_ctfn_id = g_old_rec.ler_bnft_rstrn_ctfn_id and
131 p_object_version_number = g_old_rec.object_version_number) Then
132 hr_utility.set_location(l_proc, 10);
133 --
134 -- The g_old_rec is current therefore we must
135 -- set the returning function to true
136 --
137 l_fct_ret := true;
138 Else
139 --
140 -- Select the current row
141 --
142 Open C_Sel1;
143 Fetch C_Sel1 Into g_old_rec;
144 If C_Sel1%notfound Then
145 Close C_Sel1;
146 --
147 -- The primary key is invalid therefore we must error
148 --
149 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
150 hr_utility.raise_error;
151 End If;
152 Close C_Sel1;
153 If (p_object_version_number <> g_old_rec.object_version_number) Then
154 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
155 hr_utility.raise_error;
156 End If;
157 hr_utility.set_location(l_proc, 15);
158 l_fct_ret := true;
159 End If;
160 End If;
161 hr_utility.set_location(' Leaving:'||l_proc, 20);
162 Return (l_fct_ret);
163 --
164 End api_updating;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |--------------------------< find_dt_del_modes >---------------------------|
168 -- ----------------------------------------------------------------------------
169 Procedure find_dt_del_modes
170 (p_effective_date in date,
171 p_base_key_value in number,
172 p_zap out nocopy boolean,
173 p_delete out nocopy boolean,
174 p_future_change out nocopy boolean,
175 p_delete_next_change out nocopy boolean) is
176 --
177 l_proc varchar2(72) := g_package||'find_dt_del_modes';
178 --
179 l_parent_key_value1 number;
180 --
181 Cursor C_Sel1 Is
182 select t.ler_bnft_rstrn_id
183 from ben_ler_bnft_rstrn_ctfn_f t
184 where t.ler_bnft_rstrn_ctfn_id = p_base_key_value
185 and p_effective_date
186 between t.effective_start_date and t.effective_end_date;
187 --
188 Begin
189 hr_utility.set_location('Entering:'||l_proc, 5);
190 Open C_Sel1;
191 Fetch C_Sel1 Into l_parent_key_value1;
192 If C_Sel1%notfound then
193 Close C_Sel1;
194 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
195 hr_utility.set_message_token('PROCEDURE', l_proc);
196 hr_utility.set_message_token('STEP','10');
197 hr_utility.raise_error;
198 End If;
199 Close C_Sel1;
200 --
201 -- Call the corresponding datetrack api
202 --
203 dt_api.find_dt_del_modes
204 (p_effective_date => p_effective_date,
205 p_base_table_name => 'ben_ler_bnft_rstrn_ctfn_f',
206 p_base_key_column => 'ler_bnft_rstrn_ctfn_id',
207 p_base_key_value => p_base_key_value,
208 p_parent_table_name1 => 'ben_ler_bnft_rstrn_f',
209 p_parent_key_column1 => 'ler_bnft_rstrn_id',
210 p_parent_key_value1 => l_parent_key_value1,
211 p_zap => p_zap,
212 p_delete => p_delete,
213 p_future_change => p_future_change,
214 p_delete_next_change => p_delete_next_change);
215 --
216 hr_utility.set_location(' Leaving:'||l_proc, 10);
217 End find_dt_del_modes;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |--------------------------< find_dt_upd_modes >---------------------------|
221 -- ----------------------------------------------------------------------------
222 Procedure find_dt_upd_modes
223 (p_effective_date in date,
224 p_base_key_value in number,
225 p_correction out nocopy boolean,
226 p_update out nocopy boolean,
227 p_update_override out nocopy boolean,
228 p_update_change_insert out nocopy boolean) is
229 --
230 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
231 --
232 Begin
233 hr_utility.set_location('Entering:'||l_proc, 5);
234 --
235 -- Call the corresponding datetrack api
236 --
237 dt_api.find_dt_upd_modes
238 (p_effective_date => p_effective_date,
239 p_base_table_name => 'ben_ler_bnft_rstrn_ctfn_f',
240 p_base_key_column => 'ler_bnft_rstrn_ctfn_id',
241 p_base_key_value => p_base_key_value,
242 p_correction => p_correction,
243 p_update => p_update,
244 p_update_override => p_update_override,
245 p_update_change_insert => p_update_change_insert);
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End find_dt_upd_modes;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |------------------------< upd_effective_end_date >------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure upd_effective_end_date
254 (p_effective_date in date,
255 p_base_key_value in number,
256 p_new_effective_end_date in date,
257 p_validation_start_date in date,
258 p_validation_end_date in date,
259 p_object_version_number out nocopy number) is
260 --
261 l_proc varchar2(72) := g_package||'upd_effective_end_date';
262 l_object_version_number number;
263 --
264 Begin
265 hr_utility.set_location('Entering:'||l_proc, 5);
266 --
267 -- Because we are updating a row we must get the next object
268 -- version number.
269 --
270 l_object_version_number :=
271 dt_api.get_object_version_number
272 (p_base_table_name => 'ben_ler_bnft_rstrn_ctfn_f',
273 p_base_key_column => 'ler_bnft_rstrn_ctfn_id',
274 p_base_key_value => p_base_key_value);
275 --
276 hr_utility.set_location(l_proc, 10);
277 g_api_dml := true; -- Set the api dml status
278 --
279 -- Update the specified datetrack row setting the effective
280 -- end date to the specified new effective end date.
281 --
282 update ben_ler_bnft_rstrn_ctfn_f t
283 set t.effective_end_date = p_new_effective_end_date,
284 t.object_version_number = l_object_version_number
285 where t.ler_bnft_rstrn_ctfn_id = p_base_key_value
286 and p_effective_date
287 between t.effective_start_date and t.effective_end_date;
288 --
289 g_api_dml := false; -- Unset the api dml status
290 p_object_version_number := l_object_version_number;
291 hr_utility.set_location(' Leaving:'||l_proc, 15);
292 --
293 Exception
294 When Others Then
295 g_api_dml := false; -- Unset the api dml status
296 Raise;
297 End upd_effective_end_date;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |---------------------------------< lck >----------------------------------|
301 -- ----------------------------------------------------------------------------
302 Procedure lck
303 (p_effective_date in date,
304 p_datetrack_mode in varchar2,
305 p_ler_bnft_rstrn_ctfn_id in number,
306 p_object_version_number in number,
310 l_proc varchar2(72) := g_package||'lck';
307 p_validation_start_date out nocopy date,
308 p_validation_end_date out nocopy date) is
309 --
311 l_validation_start_date date;
312 l_validation_end_date date;
313 l_object_invalid exception;
314 l_argument varchar2(30);
315 --
316 -- Cursor C_Sel1 selects the current locked row as of session date
317 -- ensuring that the object version numbers match.
318 --
319 Cursor C_Sel1 is
320 select
321 ler_bnft_rstrn_ctfn_id,
322 effective_start_date,
323 effective_end_date,
324 rqd_flag,
325 enrt_ctfn_typ_cd,
326 ctfn_rqd_when_rl,
327 ler_bnft_rstrn_id,
328 business_group_id,
329 lbc_attribute_category,
330 lbc_attribute1,
331 lbc_attribute2,
332 lbc_attribute3,
333 lbc_attribute4,
334 lbc_attribute5,
335 lbc_attribute6,
336 lbc_attribute7,
337 lbc_attribute8,
338 lbc_attribute9,
339 lbc_attribute10,
340 lbc_attribute11,
341 lbc_attribute12,
342 lbc_attribute13,
343 lbc_attribute14,
344 lbc_attribute15,
345 lbc_attribute16,
346 lbc_attribute17,
347 lbc_attribute18,
348 lbc_attribute19,
349 lbc_attribute20,
350 lbc_attribute21,
351 lbc_attribute22,
352 lbc_attribute23,
353 lbc_attribute24,
354 lbc_attribute25,
355 lbc_attribute26,
356 lbc_attribute27,
357 lbc_attribute28,
358 lbc_attribute29,
359 lbc_attribute30,
360 object_version_number
361 from ben_ler_bnft_rstrn_ctfn_f
362 where ler_bnft_rstrn_ctfn_id = p_ler_bnft_rstrn_ctfn_id
363 and p_effective_date
364 between effective_start_date and effective_end_date
365 for update nowait;
366 --
367 --
368 --
369 Begin
370 hr_utility.set_location('Entering:'||l_proc, 5);
371 --
372 -- Ensure that all the mandatory arguments are not null
373 --
374 hr_api.mandatory_arg_error(p_api_name => l_proc,
375 p_argument => 'effective_date',
376 p_argument_value => p_effective_date);
377 --
378 hr_api.mandatory_arg_error(p_api_name => l_proc,
379 p_argument => 'datetrack_mode',
380 p_argument_value => p_datetrack_mode);
381 --
382 hr_api.mandatory_arg_error(p_api_name => l_proc,
383 p_argument => 'ler_bnft_rstrn_ctfn_id',
384 p_argument_value => p_ler_bnft_rstrn_ctfn_id);
385 --
386 hr_api.mandatory_arg_error(p_api_name => l_proc,
387 p_argument => 'object_version_number',
388 p_argument_value => p_object_version_number);
389 --
390 -- Check to ensure the datetrack mode is not INSERT.
391 --
392 If (p_datetrack_mode <> 'INSERT') then
393 --
394 -- We must select and lock the current row.
395 --
396 Open C_Sel1;
397 Fetch C_Sel1 Into g_old_rec;
398 If C_Sel1%notfound then
399 Close C_Sel1;
400 --
401 -- The primary key is invalid therefore we must error
402 --
403 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
404 hr_utility.raise_error;
405 End If;
406 Close C_Sel1;
407 If (p_object_version_number <> g_old_rec.object_version_number) Then
408 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
409 hr_utility.raise_error;
410 End If;
411 hr_utility.set_location(l_proc, 15);
412 --
413 --
414 -- Validate the datetrack mode mode getting the validation start
415 -- and end dates for the specified datetrack operation.
416 --
417 dt_api.validate_dt_mode
418 (p_effective_date => p_effective_date,
419 p_datetrack_mode => p_datetrack_mode,
420 p_base_table_name => 'ben_ler_bnft_rstrn_ctfn_f',
421 p_base_key_column => 'ler_bnft_rstrn_ctfn_id',
422 p_base_key_value => p_ler_bnft_rstrn_ctfn_id,
423 p_parent_table_name1 => 'ben_ler_bnft_rstrn_f',
424 p_parent_key_column1 => 'ler_bnft_rstrn_id',
425 p_parent_key_value1 => g_old_rec.ler_bnft_rstrn_id,
426 p_enforce_foreign_locking => true,
427 p_validation_start_date => l_validation_start_date,
428 p_validation_end_date => l_validation_end_date);
429 Else
430 --
431 -- We are doing a datetrack 'INSERT' which is illegal within this
432 -- procedure therefore we must error (note: to lck on insert the
433 -- private procedure ins_lck should be called).
434 --
435 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
436 hr_utility.set_message_token('PROCEDURE', l_proc);
437 hr_utility.set_message_token('STEP','20');
438 hr_utility.raise_error;
439 End If;
440 --
441 -- Set the validation start and end date OUT arguments
442 --
443 p_validation_start_date := l_validation_start_date;
444 p_validation_end_date := l_validation_end_date;
445 --
446 hr_utility.set_location(' Leaving:'||l_proc, 30);
447 --
448 -- We need to trap the ORA LOCK exception
449 --
450 Exception
451 When HR_Api.Object_Locked then
452 --
456 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
453 -- The object is locked therefore we need to supply a meaningful
454 -- error message.
455 --
457 hr_utility.set_message_token('TABLE_NAME', 'ben_ler_bnft_rstrn_ctfn_f');
458 hr_utility.raise_error;
459 When l_object_invalid then
460 --
461 -- The object doesn't exist or is invalid
462 --
463 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
464 hr_utility.set_message_token('TABLE_NAME', 'ben_ler_bnft_rstrn_ctfn_f');
465 hr_utility.raise_error;
466 End lck;
467 --
468 -- ----------------------------------------------------------------------------
469 -- |-----------------------------< convert_args >-----------------------------|
470 -- ----------------------------------------------------------------------------
471 Function convert_args
472 (
473 p_ler_bnft_rstrn_ctfn_id in number,
474 p_effective_start_date in date,
475 p_effective_end_date in date,
476 p_rqd_flag in varchar2,
477 p_enrt_ctfn_typ_cd in varchar2,
478 p_ctfn_rqd_when_rl in number,
479 p_ler_bnft_rstrn_id in number,
480 p_business_group_id in number,
481 p_lbc_attribute_category in varchar2,
482 p_lbc_attribute1 in varchar2,
483 p_lbc_attribute2 in varchar2,
484 p_lbc_attribute3 in varchar2,
485 p_lbc_attribute4 in varchar2,
486 p_lbc_attribute5 in varchar2,
487 p_lbc_attribute6 in varchar2,
488 p_lbc_attribute7 in varchar2,
489 p_lbc_attribute8 in varchar2,
490 p_lbc_attribute9 in varchar2,
491 p_lbc_attribute10 in varchar2,
492 p_lbc_attribute11 in varchar2,
493 p_lbc_attribute12 in varchar2,
494 p_lbc_attribute13 in varchar2,
495 p_lbc_attribute14 in varchar2,
496 p_lbc_attribute15 in varchar2,
497 p_lbc_attribute16 in varchar2,
498 p_lbc_attribute17 in varchar2,
499 p_lbc_attribute18 in varchar2,
500 p_lbc_attribute19 in varchar2,
501 p_lbc_attribute20 in varchar2,
502 p_lbc_attribute21 in varchar2,
503 p_lbc_attribute22 in varchar2,
504 p_lbc_attribute23 in varchar2,
505 p_lbc_attribute24 in varchar2,
506 p_lbc_attribute25 in varchar2,
507 p_lbc_attribute26 in varchar2,
508 p_lbc_attribute27 in varchar2,
509 p_lbc_attribute28 in varchar2,
510 p_lbc_attribute29 in varchar2,
511 p_lbc_attribute30 in varchar2,
512 p_object_version_number in number
513 )
514 Return g_rec_type is
515 --
516 l_rec g_rec_type;
517 l_proc varchar2(72) := g_package||'convert_args';
518 --
519 Begin
520 --
521 hr_utility.set_location('Entering:'||l_proc, 5);
522 --
523 -- Convert arguments into local l_rec structure.
524 --
525 l_rec.ler_bnft_rstrn_ctfn_id := p_ler_bnft_rstrn_ctfn_id;
526 l_rec.effective_start_date := p_effective_start_date;
527 l_rec.effective_end_date := p_effective_end_date;
528 l_rec.rqd_flag := p_rqd_flag;
529 l_rec.enrt_ctfn_typ_cd := p_enrt_ctfn_typ_cd;
530 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl;
531 l_rec.ler_bnft_rstrn_id := p_ler_bnft_rstrn_id;
532 l_rec.business_group_id := p_business_group_id;
533 l_rec.lbc_attribute_category := p_lbc_attribute_category;
534 l_rec.lbc_attribute1 := p_lbc_attribute1;
535 l_rec.lbc_attribute2 := p_lbc_attribute2;
536 l_rec.lbc_attribute3 := p_lbc_attribute3;
537 l_rec.lbc_attribute4 := p_lbc_attribute4;
538 l_rec.lbc_attribute5 := p_lbc_attribute5;
539 l_rec.lbc_attribute6 := p_lbc_attribute6;
540 l_rec.lbc_attribute7 := p_lbc_attribute7;
541 l_rec.lbc_attribute8 := p_lbc_attribute8;
542 l_rec.lbc_attribute9 := p_lbc_attribute9;
543 l_rec.lbc_attribute10 := p_lbc_attribute10;
544 l_rec.lbc_attribute11 := p_lbc_attribute11;
545 l_rec.lbc_attribute12 := p_lbc_attribute12;
546 l_rec.lbc_attribute13 := p_lbc_attribute13;
547 l_rec.lbc_attribute14 := p_lbc_attribute14;
548 l_rec.lbc_attribute15 := p_lbc_attribute15;
549 l_rec.lbc_attribute16 := p_lbc_attribute16;
550 l_rec.lbc_attribute17 := p_lbc_attribute17;
551 l_rec.lbc_attribute18 := p_lbc_attribute18;
552 l_rec.lbc_attribute19 := p_lbc_attribute19;
553 l_rec.lbc_attribute20 := p_lbc_attribute20;
554 l_rec.lbc_attribute21 := p_lbc_attribute21;
555 l_rec.lbc_attribute22 := p_lbc_attribute22;
556 l_rec.lbc_attribute23 := p_lbc_attribute23;
557 l_rec.lbc_attribute24 := p_lbc_attribute24;
558 l_rec.lbc_attribute25 := p_lbc_attribute25;
559 l_rec.lbc_attribute26 := p_lbc_attribute26;
560 l_rec.lbc_attribute27 := p_lbc_attribute27;
561 l_rec.lbc_attribute28 := p_lbc_attribute28;
562 l_rec.lbc_attribute29 := p_lbc_attribute29;
563 l_rec.lbc_attribute30 := p_lbc_attribute30;
564 l_rec.object_version_number := p_object_version_number;
565 --
566 -- Return the plsql record structure.
567 --
568 hr_utility.set_location(' Leaving:'||l_proc, 10);
569 Return(l_rec);
570 --
571 End convert_args;
572 --
573 end ben_lbc_shd;