DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_AVA_SHD

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_ava_shd as
2 /* $Header: beavarhi.pkb 120.1 2008/08/18 09:15:26 pvelvano noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ava_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_ACTL_PREM_VRBL_RT_RL_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_ACTL_PREM_VRBL_RT_RL_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   Else
47     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50     fnd_message.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_actl_prem_vrbl_rt_rl_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 	actl_prem_vrbl_rt_rl_id,
71 	effective_start_date,
72 	effective_end_date,
73 	actl_prem_id,
74 	formula_id,
75 	ordr_to_aply_num,
76 	rt_trtmt_cd,
77 	business_group_id,
78 	ava_attribute_category,
79 	ava_attribute1,
80 	ava_attribute2,
81 	ava_attribute3,
82 	ava_attribute4,
83 	ava_attribute5,
84 	ava_attribute6,
85 	ava_attribute7,
86 	ava_attribute8,
87 	ava_attribute9,
88 	ava_attribute10,
89 	ava_attribute11,
90 	ava_attribute12,
91 	ava_attribute13,
92 	ava_attribute14,
93 	ava_attribute15,
94 	ava_attribute16,
95 	ava_attribute17,
96 	ava_attribute18,
97 	ava_attribute19,
98 	ava_attribute20,
99 	ava_attribute21,
100 	ava_attribute22,
101 	ava_attribute23,
102 	ava_attribute24,
103 	ava_attribute25,
104 	ava_attribute26,
105 	ava_attribute27,
106 	ava_attribute28,
107 	ava_attribute29,
108 	ava_attribute30,
109 	object_version_number
110     from	ben_actl_prem_vrbl_rt_rl_f
111     where	actl_prem_vrbl_rt_rl_id = p_actl_prem_vrbl_rt_rl_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_actl_prem_vrbl_rt_rl_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_actl_prem_vrbl_rt_rl_id = g_old_rec.actl_prem_vrbl_rt_rl_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       --
143       Fetch C_Sel1 Into g_old_rec;
140       -- Select the current row
141       --
142       Open C_Sel1;
144       If C_Sel1%notfound Then
145         Close C_Sel1;
146         --
147         -- The primary key is invalid therefore we must error
148         --
149         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
150         fnd_message.raise_error;
151       End If;
152       Close C_Sel1;
153       If (p_object_version_number <> g_old_rec.object_version_number) Then
154         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
155         fnd_message.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.actl_prem_id
183     from    ben_actl_prem_vrbl_rt_rl_f t
184     where   t.actl_prem_vrbl_rt_rl_id = p_base_key_value
188 Begin
185     and     p_effective_date
186     between t.effective_start_date and t.effective_end_date;
187 --
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     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
195     fnd_message.set_token('PROCEDURE', l_proc);
196     fnd_message.set_token('STEP','10');
197     fnd_message.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_actl_prem_vrbl_rt_rl_f',
206 	 p_base_key_column	=> 'actl_prem_vrbl_rt_rl_id',
207 	 p_base_key_value	=> p_base_key_value,
208 	 p_parent_table_name1	=> 'ben_actl_prem_f',
209 	 p_parent_key_column1	=> 'actl_prem_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_actl_prem_vrbl_rt_rl_f',
240 	 p_base_key_column	=> 'actl_prem_vrbl_rt_rl_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_actl_prem_vrbl_rt_rl_f',
273 	 p_base_key_column	=> 'actl_prem_vrbl_rt_rl_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_actl_prem_vrbl_rt_rl_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.actl_prem_vrbl_rt_rl_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_actl_prem_vrbl_rt_rl_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 	actl_prem_vrbl_rt_rl_id,
322 	effective_start_date,
323 	effective_end_date,
324 	actl_prem_id,
325 	formula_id,
326 	ordr_to_aply_num,
330 	ava_attribute1,
327 	rt_trtmt_cd,
328 	business_group_id,
329 	ava_attribute_category,
331 	ava_attribute2,
332 	ava_attribute3,
333 	ava_attribute4,
334 	ava_attribute5,
335 	ava_attribute6,
336 	ava_attribute7,
337 	ava_attribute8,
338 	ava_attribute9,
339 	ava_attribute10,
340 	ava_attribute11,
341 	ava_attribute12,
342 	ava_attribute13,
343 	ava_attribute14,
344 	ava_attribute15,
345 	ava_attribute16,
346 	ava_attribute17,
347 	ava_attribute18,
348 	ava_attribute19,
349 	ava_attribute20,
350 	ava_attribute21,
351 	ava_attribute22,
352 	ava_attribute23,
353 	ava_attribute24,
354 	ava_attribute25,
355 	ava_attribute26,
356 	ava_attribute27,
357 	ava_attribute28,
358 	ava_attribute29,
359 	ava_attribute30,
360 	object_version_number
361     from    ben_actl_prem_vrbl_rt_rl_f
362     where   actl_prem_vrbl_rt_rl_id         = p_actl_prem_vrbl_rt_rl_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       => 'actl_prem_vrbl_rt_rl_id',
384                              p_argument_value => p_actl_prem_vrbl_rt_rl_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       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
404       fnd_message.raise_error;
405     End If;
406     Close C_Sel1;
407     If (p_object_version_number <> g_old_rec.object_version_number) Then
408         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
409         fnd_message.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_actl_prem_vrbl_rt_rl_f',
421 	 p_base_key_column	   => 'actl_prem_vrbl_rt_rl_id',
422 	 p_base_key_value 	   => p_actl_prem_vrbl_rt_rl_id,
423 	 p_parent_table_name1      => 'ben_actl_prem_f',
424 	 p_parent_key_column1      => 'actl_prem_id',
425 	 p_parent_key_value1       => g_old_rec.actl_prem_id,
426          p_enforce_foreign_locking => false, --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     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
436     fnd_message.set_token('PROCEDURE', l_proc);
437     fnd_message.set_token('STEP','20');
438     fnd_message.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     --
453     -- The object is locked therefore we need to supply a meaningful
454     -- error message.
455     --
456     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
457     fnd_message.set_token('TABLE_NAME', 'ben_actl_prem_vrbl_rt_rl_f');
458     fnd_message.raise_error;
459   When l_object_invalid then
460     --
461     -- The object doesn't exist or is invalid
462     --
463     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
464     fnd_message.set_token('TABLE_NAME', 'ben_actl_prem_vrbl_rt_rl_f');
465     fnd_message.raise_error;
466 End lck;
467 --
468 -- ----------------------------------------------------------------------------
469 -- |-----------------------------< convert_args >-----------------------------|
470 -- ----------------------------------------------------------------------------
471 Function convert_args
472 	(
473 	p_actl_prem_vrbl_rt_rl_id       in number,
474 	p_effective_start_date          in date,
475 	p_effective_end_date            in date,
476 	p_actl_prem_id                  in number,
477 	p_formula_id                    in number,
478 	p_ordr_to_aply_num              in number,
482 	p_ava_attribute1                in varchar2,
479 	p_rt_trtmt_cd                   in varchar2,
480 	p_business_group_id             in number,
481 	p_ava_attribute_category        in varchar2,
483 	p_ava_attribute2                in varchar2,
484 	p_ava_attribute3                in varchar2,
485 	p_ava_attribute4                in varchar2,
486 	p_ava_attribute5                in varchar2,
487 	p_ava_attribute6                in varchar2,
488 	p_ava_attribute7                in varchar2,
489 	p_ava_attribute8                in varchar2,
490 	p_ava_attribute9                in varchar2,
491 	p_ava_attribute10               in varchar2,
492 	p_ava_attribute11               in varchar2,
493 	p_ava_attribute12               in varchar2,
494 	p_ava_attribute13               in varchar2,
495 	p_ava_attribute14               in varchar2,
496 	p_ava_attribute15               in varchar2,
497 	p_ava_attribute16               in varchar2,
498 	p_ava_attribute17               in varchar2,
499 	p_ava_attribute18               in varchar2,
500 	p_ava_attribute19               in varchar2,
501 	p_ava_attribute20               in varchar2,
502 	p_ava_attribute21               in varchar2,
503 	p_ava_attribute22               in varchar2,
504 	p_ava_attribute23               in varchar2,
505 	p_ava_attribute24               in varchar2,
506 	p_ava_attribute25               in varchar2,
507 	p_ava_attribute26               in varchar2,
508 	p_ava_attribute27               in varchar2,
509 	p_ava_attribute28               in varchar2,
510 	p_ava_attribute29               in varchar2,
511 	p_ava_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.actl_prem_vrbl_rt_rl_id          := p_actl_prem_vrbl_rt_rl_id;
526   l_rec.effective_start_date             := p_effective_start_date;
527   l_rec.effective_end_date               := p_effective_end_date;
528   l_rec.actl_prem_id                     := p_actl_prem_id;
529   l_rec.formula_id                       := p_formula_id;
530   l_rec.ordr_to_aply_num                 := p_ordr_to_aply_num;
531   l_rec.rt_trtmt_cd                      := p_rt_trtmt_cd;
532   l_rec.business_group_id                := p_business_group_id;
533   l_rec.ava_attribute_category           := p_ava_attribute_category;
534   l_rec.ava_attribute1                   := p_ava_attribute1;
535   l_rec.ava_attribute2                   := p_ava_attribute2;
536   l_rec.ava_attribute3                   := p_ava_attribute3;
537   l_rec.ava_attribute4                   := p_ava_attribute4;
538   l_rec.ava_attribute5                   := p_ava_attribute5;
539   l_rec.ava_attribute6                   := p_ava_attribute6;
540   l_rec.ava_attribute7                   := p_ava_attribute7;
541   l_rec.ava_attribute8                   := p_ava_attribute8;
542   l_rec.ava_attribute9                   := p_ava_attribute9;
543   l_rec.ava_attribute10                  := p_ava_attribute10;
544   l_rec.ava_attribute11                  := p_ava_attribute11;
545   l_rec.ava_attribute12                  := p_ava_attribute12;
546   l_rec.ava_attribute13                  := p_ava_attribute13;
547   l_rec.ava_attribute14                  := p_ava_attribute14;
548   l_rec.ava_attribute15                  := p_ava_attribute15;
549   l_rec.ava_attribute16                  := p_ava_attribute16;
550   l_rec.ava_attribute17                  := p_ava_attribute17;
551   l_rec.ava_attribute18                  := p_ava_attribute18;
552   l_rec.ava_attribute19                  := p_ava_attribute19;
553   l_rec.ava_attribute20                  := p_ava_attribute20;
554   l_rec.ava_attribute21                  := p_ava_attribute21;
555   l_rec.ava_attribute22                  := p_ava_attribute22;
556   l_rec.ava_attribute23                  := p_ava_attribute23;
557   l_rec.ava_attribute24                  := p_ava_attribute24;
558   l_rec.ava_attribute25                  := p_ava_attribute25;
559   l_rec.ava_attribute26                  := p_ava_attribute26;
560   l_rec.ava_attribute27                  := p_ava_attribute27;
561   l_rec.ava_attribute28                  := p_ava_attribute28;
562   l_rec.ava_attribute29                  := p_ava_attribute29;
563   l_rec.ava_attribute30                  := p_ava_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_ava_shd;