DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BVR_SHD

Source


1 Package Body ben_bvr_shd as
2 /* $Header: bebvrrhi.pkb 120.0 2005/05/28 00:54:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bvr_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_BNFT_VRBL_RT_PK') 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   Else
42     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
45     hr_utility.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_bnft_vrbl_rt_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 	bnft_vrbl_rt_id,
66 	effective_start_date,
67 	effective_end_date,
68 	cvg_amt_calc_mthd_id,
69 	vrbl_rt_prfl_id,
70 	business_group_id,
71 	bvr_attribute_category,
72 	bvr_attribute1,
73 	bvr_attribute2,
74 	bvr_attribute3,
75 	bvr_attribute4,
76 	bvr_attribute5,
77 	bvr_attribute6,
78 	bvr_attribute7,
79 	bvr_attribute8,
80 	bvr_attribute9,
81 	bvr_attribute10,
82 	bvr_attribute11,
83 	bvr_attribute12,
84 	bvr_attribute13,
85 	bvr_attribute14,
86 	bvr_attribute15,
87 	bvr_attribute16,
88 	bvr_attribute17,
89 	bvr_attribute18,
90 	bvr_attribute19,
91 	bvr_attribute20,
92 	bvr_attribute21,
93 	bvr_attribute22,
94 	bvr_attribute23,
95 	bvr_attribute24,
96 	bvr_attribute25,
97 	bvr_attribute26,
98 	bvr_attribute27,
99 	bvr_attribute28,
100 	bvr_attribute29,
101 	bvr_attribute30,
102 	object_version_number,
103 	ordr_num
104     from	ben_bnft_vrbl_rt_f
105     where	bnft_vrbl_rt_id = p_bnft_vrbl_rt_id
106     and		p_effective_date
107     between	effective_start_date and effective_end_date;
108 --
109   l_proc	varchar2(72)	:= g_package||'api_updating';
110   l_fct_ret	boolean;
111 --
112 Begin
113   hr_utility.set_location('Entering:'||l_proc, 5);
114   --
115   If (p_effective_date is null or
116       p_bnft_vrbl_rt_id is null or
117       p_object_version_number is null) Then
118     --
119     -- One of the primary key arguments is null therefore we must
120     -- set the returning function value to false
121     --
122     l_fct_ret := false;
123   Else
124     If (p_bnft_vrbl_rt_id = g_old_rec.bnft_vrbl_rt_id and
125         p_object_version_number = g_old_rec.object_version_number) Then
126       hr_utility.set_location(l_proc, 10);
127       --
128       -- The g_old_rec is current therefore we must
129       -- set the returning function to true
130       --
131       l_fct_ret := true;
132     Else
133       --
134       -- Select the current row
135       --
136       Open C_Sel1;
137       Fetch C_Sel1 Into g_old_rec;
138       If C_Sel1%notfound Then
139         Close C_Sel1;
140         --
141         -- The primary key is invalid therefore we must error
142         --
143         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
144         hr_utility.raise_error;
145       End If;
146       Close C_Sel1;
147       If (p_object_version_number <> g_old_rec.object_version_number) Then
148         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
149         hr_utility.raise_error;
150       End If;
151       hr_utility.set_location(l_proc, 15);
152       l_fct_ret := true;
153     End If;
154   End If;
155   hr_utility.set_location(' Leaving:'||l_proc, 20);
156   Return (l_fct_ret);
157 --
158 End api_updating;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |--------------------------< find_dt_del_modes >---------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure find_dt_del_modes
164 	(p_effective_date	in  date,
165 	 p_base_key_value	in  number,
166 	 p_zap		 out nocopy boolean,
167 	 p_delete	 out nocopy boolean,
168 	 p_future_change out nocopy boolean,
169 	 p_delete_next_change out nocopy boolean) is
170 --
171   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
172 --
173   l_parent_key_value1	number;
174   l_parent_key_value2	number;
175   --
176   Cursor C_Sel1 Is
177     select  t.vrbl_rt_prfl_id,
178 	    t.cvg_amt_calc_mthd_id
179     from    ben_bnft_vrbl_rt_f t
180     where   t.bnft_vrbl_rt_id = p_base_key_value
181     and     p_effective_date
182     between t.effective_start_date and t.effective_end_date;
183 --
184 Begin
185   hr_utility.set_location('Entering:'||l_proc, 5);
186   Open  C_Sel1;
187   Fetch C_Sel1 Into l_parent_key_value1,
188 		    l_parent_key_value2;
189   If C_Sel1%notfound then
190     Close C_Sel1;
191     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
192     hr_utility.set_message_token('PROCEDURE', l_proc);
193     hr_utility.set_message_token('STEP','10');
194     hr_utility.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_bnft_vrbl_rt_f',
203 	 p_base_key_column	=> 'bnft_vrbl_rt_id',
204 	 p_base_key_value	=> p_base_key_value,
205 	 p_parent_table_name1	=> 'ben_vrbl_rt_prfl_f',
206 	 p_parent_key_column1	=> 'vrbl_rt_prfl_id',
207 	 p_parent_key_value1	=> l_parent_key_value1,
208 	 p_parent_table_name2	=> 'ben_cvg_amt_calc_mthd_f',
209 	 p_parent_key_column2	=> 'cvg_amt_calc_mthd_id',
210 	 p_parent_key_value2	=> l_parent_key_value2,
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_bnft_vrbl_rt_f',
240 	 p_base_key_column	=> 'bnft_vrbl_rt_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_bnft_vrbl_rt_f',
273 	 p_base_key_column	=> 'bnft_vrbl_rt_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_bnft_vrbl_rt_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.bnft_vrbl_rt_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_bnft_vrbl_rt_id	 in  number,
306 	 p_object_version_number in  number,
307 	 p_validation_start_date out nocopy date,
308 	 p_validation_end_date	 out nocopy date) is
309 --
310   l_proc		  varchar2(72) := g_package||'lck';
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 	bnft_vrbl_rt_id,
322 	effective_start_date,
323 	effective_end_date,
324 	cvg_amt_calc_mthd_id,
325 	vrbl_rt_prfl_id,
326 	business_group_id,
327 	bvr_attribute_category,
328 	bvr_attribute1,
329 	bvr_attribute2,
330 	bvr_attribute3,
331 	bvr_attribute4,
332 	bvr_attribute5,
333 	bvr_attribute6,
334 	bvr_attribute7,
335 	bvr_attribute8,
336 	bvr_attribute9,
337 	bvr_attribute10,
338 	bvr_attribute11,
339 	bvr_attribute12,
340 	bvr_attribute13,
341 	bvr_attribute14,
342 	bvr_attribute15,
343 	bvr_attribute16,
344 	bvr_attribute17,
345 	bvr_attribute18,
346 	bvr_attribute19,
347 	bvr_attribute20,
348 	bvr_attribute21,
349 	bvr_attribute22,
350 	bvr_attribute23,
351 	bvr_attribute24,
352 	bvr_attribute25,
353 	bvr_attribute26,
354 	bvr_attribute27,
355 	bvr_attribute28,
356 	bvr_attribute29,
357 	bvr_attribute30,
358 	object_version_number,
359 	ordr_num
360     from    ben_bnft_vrbl_rt_f
361     where   bnft_vrbl_rt_id         = p_bnft_vrbl_rt_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       => 'bnft_vrbl_rt_id',
383                              p_argument_value => p_bnft_vrbl_rt_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       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
403       hr_utility.raise_error;
404     End If;
405     Close C_Sel1;
406     If (p_object_version_number <> g_old_rec.object_version_number) Then
407         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
408         hr_utility.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_bnft_vrbl_rt_f',
420 	 p_base_key_column	   => 'bnft_vrbl_rt_id',
421 	 p_base_key_value 	   => p_bnft_vrbl_rt_id,
422 	 p_parent_table_name1      => 'ben_vrbl_rt_prfl_f',
423 	 p_parent_key_column1      => 'vrbl_rt_prfl_id',
424 	 p_parent_key_value1       => g_old_rec.vrbl_rt_prfl_id,
425 	 p_parent_table_name2      => 'ben_cvg_amt_calc_mthd_f',
426 	 p_parent_key_column2      => 'cvg_amt_calc_mthd_id',
427 	 p_parent_key_value2       => g_old_rec.cvg_amt_calc_mthd_id,
428          p_enforce_foreign_locking => true,
429 	 p_validation_start_date   => l_validation_start_date,
430  	 p_validation_end_date	   => l_validation_end_date);
431   Else
432     --
433     -- We are doing a datetrack 'INSERT' which is illegal within this
434     -- procedure therefore we must error (note: to lck on insert the
435     -- private procedure ins_lck should be called).
436     --
437     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
438     hr_utility.set_message_token('PROCEDURE', l_proc);
439     hr_utility.set_message_token('STEP','20');
440     hr_utility.raise_error;
441   End If;
442   --
443   -- Set the validation start and end date OUT arguments
444   --
445   p_validation_start_date := l_validation_start_date;
446   p_validation_end_date   := l_validation_end_date;
447   --
448   hr_utility.set_location(' Leaving:'||l_proc, 30);
449 --
450 -- We need to trap the ORA LOCK exception
451 --
452 Exception
453   When HR_Api.Object_Locked then
454     --
455     -- The object is locked therefore we need to supply a meaningful
456     -- error message.
457     --
458     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
459     hr_utility.set_message_token('TABLE_NAME', 'ben_bnft_vrbl_rt_f');
460     hr_utility.raise_error;
461   When l_object_invalid then
462     --
463     -- The object doesn't exist or is invalid
464     --
465     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
466     hr_utility.set_message_token('TABLE_NAME', 'ben_bnft_vrbl_rt_f');
467     hr_utility.raise_error;
468 End lck;
469 --
470 -- ----------------------------------------------------------------------------
471 -- |-----------------------------< convert_args >-----------------------------|
472 -- ----------------------------------------------------------------------------
473 Function convert_args
474 	(
475 	p_bnft_vrbl_rt_id               in number,
476 	p_effective_start_date          in date,
477 	p_effective_end_date            in date,
478 	p_cvg_amt_calc_mthd_id          in number,
479 	p_vrbl_rt_prfl_id               in number,
480 	p_business_group_id             in number,
481 	p_bvr_attribute_category        in varchar2,
482 	p_bvr_attribute1                in varchar2,
483 	p_bvr_attribute2                in varchar2,
484 	p_bvr_attribute3                in varchar2,
485 	p_bvr_attribute4                in varchar2,
486 	p_bvr_attribute5                in varchar2,
487 	p_bvr_attribute6                in varchar2,
488 	p_bvr_attribute7                in varchar2,
489 	p_bvr_attribute8                in varchar2,
490 	p_bvr_attribute9                in varchar2,
491 	p_bvr_attribute10               in varchar2,
492 	p_bvr_attribute11               in varchar2,
493 	p_bvr_attribute12               in varchar2,
494 	p_bvr_attribute13               in varchar2,
495 	p_bvr_attribute14               in varchar2,
496 	p_bvr_attribute15               in varchar2,
497 	p_bvr_attribute16               in varchar2,
498 	p_bvr_attribute17               in varchar2,
499 	p_bvr_attribute18               in varchar2,
500 	p_bvr_attribute19               in varchar2,
501 	p_bvr_attribute20               in varchar2,
502 	p_bvr_attribute21               in varchar2,
503 	p_bvr_attribute22               in varchar2,
504 	p_bvr_attribute23               in varchar2,
505 	p_bvr_attribute24               in varchar2,
506 	p_bvr_attribute25               in varchar2,
507 	p_bvr_attribute26               in varchar2,
508 	p_bvr_attribute27               in varchar2,
509 	p_bvr_attribute28               in varchar2,
510 	p_bvr_attribute29               in varchar2,
511 	p_bvr_attribute30               in varchar2,
512 	p_object_version_number         in number,
513 	p_ordr_num                      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.bnft_vrbl_rt_id                  := p_bnft_vrbl_rt_id;
527   l_rec.effective_start_date             := p_effective_start_date;
528   l_rec.effective_end_date               := p_effective_end_date;
529   l_rec.cvg_amt_calc_mthd_id             := p_cvg_amt_calc_mthd_id;
530   l_rec.vrbl_rt_prfl_id                  := p_vrbl_rt_prfl_id;
531   l_rec.business_group_id                := p_business_group_id;
532   l_rec.bvr_attribute_category           := p_bvr_attribute_category;
533   l_rec.bvr_attribute1                   := p_bvr_attribute1;
534   l_rec.bvr_attribute2                   := p_bvr_attribute2;
535   l_rec.bvr_attribute3                   := p_bvr_attribute3;
536   l_rec.bvr_attribute4                   := p_bvr_attribute4;
537   l_rec.bvr_attribute5                   := p_bvr_attribute5;
538   l_rec.bvr_attribute6                   := p_bvr_attribute6;
539   l_rec.bvr_attribute7                   := p_bvr_attribute7;
540   l_rec.bvr_attribute8                   := p_bvr_attribute8;
541   l_rec.bvr_attribute9                   := p_bvr_attribute9;
542   l_rec.bvr_attribute10                  := p_bvr_attribute10;
543   l_rec.bvr_attribute11                  := p_bvr_attribute11;
544   l_rec.bvr_attribute12                  := p_bvr_attribute12;
545   l_rec.bvr_attribute13                  := p_bvr_attribute13;
546   l_rec.bvr_attribute14                  := p_bvr_attribute14;
547   l_rec.bvr_attribute15                  := p_bvr_attribute15;
548   l_rec.bvr_attribute16                  := p_bvr_attribute16;
549   l_rec.bvr_attribute17                  := p_bvr_attribute17;
550   l_rec.bvr_attribute18                  := p_bvr_attribute18;
551   l_rec.bvr_attribute19                  := p_bvr_attribute19;
552   l_rec.bvr_attribute20                  := p_bvr_attribute20;
553   l_rec.bvr_attribute21                  := p_bvr_attribute21;
554   l_rec.bvr_attribute22                  := p_bvr_attribute22;
555   l_rec.bvr_attribute23                  := p_bvr_attribute23;
556   l_rec.bvr_attribute24                  := p_bvr_attribute24;
557   l_rec.bvr_attribute25                  := p_bvr_attribute25;
558   l_rec.bvr_attribute26                  := p_bvr_attribute26;
559   l_rec.bvr_attribute27                  := p_bvr_attribute27;
560   l_rec.bvr_attribute28                  := p_bvr_attribute28;
561   l_rec.bvr_attribute29                  := p_bvr_attribute29;
562   l_rec.bvr_attribute30                  := p_bvr_attribute30;
563   l_rec.object_version_number            := p_object_version_number;
564   l_rec.ordr_num                         := p_ordr_num;
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_bvr_shd;