DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_APV_SHD

Source


1 Package Body ben_apv_shd as
2 /* $Header: beapvrhi.pkb 120.0.12010000.2 2008/08/05 14:03:38 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_apv_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_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_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_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_id,
71 	effective_start_date,
72 	effective_end_date,
73 	actl_prem_id,
74 	vrbl_rt_prfl_id,
75         ordr_num,
76 	business_group_id,
77 	apv_attribute_category,
78 	apv_attribute1,
79 	apv_attribute2,
80 	apv_attribute3,
81 	apv_attribute4,
82 	apv_attribute5,
83 	apv_attribute6,
84 	apv_attribute7,
85 	apv_attribute8,
86 	apv_attribute9,
87 	apv_attribute10,
88 	apv_attribute11,
89 	apv_attribute12,
90 	apv_attribute13,
91 	apv_attribute14,
92 	apv_attribute15,
93 	apv_attribute16,
94 	apv_attribute17,
95 	apv_attribute18,
96 	apv_attribute19,
97 	apv_attribute20,
98 	apv_attribute21,
99 	apv_attribute22,
100 	apv_attribute23,
101 	apv_attribute24,
102 	apv_attribute25,
103 	apv_attribute26,
104 	apv_attribute27,
105 	apv_attribute28,
106 	apv_attribute29,
107 	apv_attribute30,
108 	object_version_number
109     from	ben_actl_prem_vrbl_rt_f
110     where	actl_prem_vrbl_rt_id = p_actl_prem_vrbl_rt_id
111     and		p_effective_date
112     between	effective_start_date and effective_end_date;
113 --
114   l_proc	varchar2(72)	:= g_package||'api_updating';
115   l_fct_ret	boolean;
116 --
117 Begin
118   hr_utility.set_location('Entering:'||l_proc, 5);
119   --
120   If (p_effective_date is null or
121       p_actl_prem_vrbl_rt_id is null or
122       p_object_version_number is null) Then
123     --
124     -- One of the primary key arguments is null therefore we must
125     -- set the returning function value to false
126     --
127     l_fct_ret := false;
128   Else
129     If (p_actl_prem_vrbl_rt_id = g_old_rec.actl_prem_vrbl_rt_id and
130         p_object_version_number = g_old_rec.object_version_number) Then
131       hr_utility.set_location(l_proc, 10);
132       --
133       -- The g_old_rec is current therefore we must
134       -- set the returning function to true
135       --
136       l_fct_ret := true;
137     Else
138       --
139       -- Select the current row
140       --
141       Open C_Sel1;
142       Fetch C_Sel1 Into g_old_rec;
143       If C_Sel1%notfound Then
144         Close C_Sel1;
145         --
146         -- The primary key is invalid therefore we must error
147         --
148         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149         fnd_message.raise_error;
150       End If;
151       Close C_Sel1;
152       If (p_object_version_number <> g_old_rec.object_version_number) Then
153         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154         fnd_message.raise_error;
155       End If;
156       hr_utility.set_location(l_proc, 15);
157       l_fct_ret := true;
158     End If;
159   End If;
160   hr_utility.set_location(' Leaving:'||l_proc, 20);
161   Return (l_fct_ret);
162 --
163 End api_updating;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |--------------------------< find_dt_del_modes >---------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure find_dt_del_modes
169 	(p_effective_date	in  date,
170 	 p_base_key_value	in  number,
171 	 p_zap		 out nocopy boolean,
172 	 p_delete	 out nocopy boolean,
173 	 p_future_change out nocopy boolean,
174 	 p_delete_next_change out nocopy boolean) is
175 --
176   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
177 --
178   l_parent_key_value1	number;
179   l_parent_key_value2	number;
180   --
181   Cursor C_Sel1 Is
182     select  t.vrbl_rt_prfl_id,
183 	    t.actl_prem_id
184     from    ben_actl_prem_vrbl_rt_f t
185     where   t.actl_prem_vrbl_rt_id = p_base_key_value
186     and     p_effective_date
187     between t.effective_start_date and t.effective_end_date;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   Open  C_Sel1;
192   Fetch C_Sel1 Into l_parent_key_value1,
193 		    l_parent_key_value2;
194   If C_Sel1%notfound then
195     Close C_Sel1;
196     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
197     fnd_message.set_token('PROCEDURE', l_proc);
198     fnd_message.set_token('STEP','10');
199     fnd_message.raise_error;
200   End If;
201   Close C_Sel1;
202   --
203   -- Call the corresponding datetrack api
204   --
205   dt_api.find_dt_del_modes
206 	(p_effective_date	=> p_effective_date,
207 	 p_base_table_name	=> 'ben_actl_prem_vrbl_rt_f',
208 	 p_base_key_column	=> 'actl_prem_vrbl_rt_id',
209 	 p_base_key_value	=> p_base_key_value,
210 	 p_parent_table_name1	=> 'ben_vrbl_rt_prfl_f',
211 	 p_parent_key_column1	=> 'vrbl_rt_prfl_id',
212 	 p_parent_key_value1	=> l_parent_key_value1,
213 	 p_parent_table_name2	=> 'ben_actl_prem_f',
214 	 p_parent_key_column2	=> 'actl_prem_id',
215 	 p_parent_key_value2	=> l_parent_key_value2,
216 	 p_zap			=> p_zap,
217 	 p_delete		=> p_delete,
218 	 p_future_change	=> p_future_change,
219 	 p_delete_next_change	=> p_delete_next_change);
220   --
221   hr_utility.set_location(' Leaving:'||l_proc, 10);
222 End find_dt_del_modes;
223 --
224 -- ----------------------------------------------------------------------------
225 -- |--------------------------< find_dt_upd_modes >---------------------------|
226 -- ----------------------------------------------------------------------------
227 Procedure find_dt_upd_modes
228 	(p_effective_date	in  date,
229 	 p_base_key_value	in  number,
230 	 p_correction	 out nocopy boolean,
231 	 p_update	 out nocopy boolean,
232 	 p_update_override out nocopy boolean,
233 	 p_update_change_insert out nocopy boolean) is
234 --
235   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
236 --
237 Begin
238   hr_utility.set_location('Entering:'||l_proc, 5);
239   --
240   -- Call the corresponding datetrack api
241   --
242   dt_api.find_dt_upd_modes
243 	(p_effective_date	=> p_effective_date,
244 	 p_base_table_name	=> 'ben_actl_prem_vrbl_rt_f',
245 	 p_base_key_column	=> 'actl_prem_vrbl_rt_id',
246 	 p_base_key_value	=> p_base_key_value,
247 	 p_correction		=> p_correction,
248 	 p_update		=> p_update,
249 	 p_update_override	=> p_update_override,
250 	 p_update_change_insert	=> p_update_change_insert);
251   --
252   hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End find_dt_upd_modes;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |------------------------< upd_effective_end_date >------------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure upd_effective_end_date
259 	(p_effective_date		in date,
260 	 p_base_key_value		in number,
261 	 p_new_effective_end_date	in date,
262 	 p_validation_start_date	in date,
263 	 p_validation_end_date		in date,
264          p_object_version_number       out nocopy number) is
265 --
266   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
267   l_object_version_number number;
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   -- Because we are updating a row we must get the next object
273   -- version number.
274   --
275   l_object_version_number :=
276     dt_api.get_object_version_number
277 	(p_base_table_name	=> 'ben_actl_prem_vrbl_rt_f',
278 	 p_base_key_column	=> 'actl_prem_vrbl_rt_id',
279 	 p_base_key_value	=> p_base_key_value);
280   --
281   hr_utility.set_location(l_proc, 10);
282   g_api_dml := true;  -- Set the api dml status
283   --
284   -- Update the specified datetrack row setting the effective
285   -- end date to the specified new effective end date.
286   --
287   update  ben_actl_prem_vrbl_rt_f t
288   set	  t.effective_end_date	  = p_new_effective_end_date,
289 	  t.object_version_number = l_object_version_number
290   where	  t.actl_prem_vrbl_rt_id	  = p_base_key_value
291   and	  p_effective_date
292   between t.effective_start_date and t.effective_end_date;
293   --
294   g_api_dml := false;   -- Unset the api dml status
295   p_object_version_number := l_object_version_number;
296   hr_utility.set_location(' Leaving:'||l_proc, 15);
297 --
298 Exception
299   When Others Then
300     g_api_dml := false;   -- Unset the api dml status
301     Raise;
302 End upd_effective_end_date;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< lck >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure lck
308 	(p_effective_date	 in  date,
309 	 p_datetrack_mode	 in  varchar2,
310 	 p_actl_prem_vrbl_rt_id	 in  number,
311 	 p_object_version_number in  number,
312 	 p_validation_start_date out nocopy date,
313 	 p_validation_end_date	 out nocopy date) is
314 --
315   l_proc		  varchar2(72) := g_package||'lck';
316   l_validation_start_date date;
317   l_validation_end_date	  date;
318   l_object_invalid 	  exception;
319   l_argument		  varchar2(30);
320   --
321   -- Cursor C_Sel1 selects the current locked row as of session date
322   -- ensuring that the object version numbers match.
323   --
324   Cursor C_Sel1 is
325     select
326 	actl_prem_vrbl_rt_id,
327 	effective_start_date,
328 	effective_end_date,
329 	actl_prem_id,
330 	vrbl_rt_prfl_id,
331         ordr_num,
332 	business_group_id,
333 	apv_attribute_category,
334 	apv_attribute1,
335 	apv_attribute2,
336 	apv_attribute3,
337 	apv_attribute4,
338 	apv_attribute5,
339 	apv_attribute6,
340 	apv_attribute7,
341 	apv_attribute8,
342 	apv_attribute9,
343 	apv_attribute10,
344 	apv_attribute11,
345 	apv_attribute12,
346 	apv_attribute13,
347 	apv_attribute14,
348 	apv_attribute15,
349 	apv_attribute16,
350 	apv_attribute17,
351 	apv_attribute18,
352 	apv_attribute19,
353 	apv_attribute20,
354 	apv_attribute21,
355 	apv_attribute22,
356 	apv_attribute23,
357 	apv_attribute24,
358 	apv_attribute25,
359 	apv_attribute26,
360 	apv_attribute27,
361 	apv_attribute28,
362 	apv_attribute29,
363 	apv_attribute30,
364 	object_version_number
365     from    ben_actl_prem_vrbl_rt_f
366     where   actl_prem_vrbl_rt_id         = p_actl_prem_vrbl_rt_id
367     and	    p_effective_date
368     between effective_start_date and effective_end_date
369     for update nowait;
370   --
371   --
372   --
373 Begin
374   hr_utility.set_location('Entering:'||l_proc, 5);
375   --
376   -- Ensure that all the mandatory arguments are not null
377   --
378   hr_api.mandatory_arg_error(p_api_name       => l_proc,
379                              p_argument       => 'effective_date',
380                              p_argument_value => p_effective_date);
381   --
382   hr_api.mandatory_arg_error(p_api_name       => l_proc,
383                              p_argument       => 'datetrack_mode',
384                              p_argument_value => p_datetrack_mode);
385   --
386   hr_api.mandatory_arg_error(p_api_name       => l_proc,
387                              p_argument       => 'actl_prem_vrbl_rt_id',
388                              p_argument_value => p_actl_prem_vrbl_rt_id);
389   --
390   hr_api.mandatory_arg_error(p_api_name       => l_proc,
391                              p_argument       => 'object_version_number',
392                              p_argument_value => p_object_version_number);
393   --
394   -- Check to ensure the datetrack mode is not INSERT.
395   --
396   If (p_datetrack_mode <> 'INSERT') then
397     --
398     -- We must select and lock the current row.
399     --
400     Open  C_Sel1;
401     Fetch C_Sel1 Into g_old_rec;
402     If C_Sel1%notfound then
403       Close C_Sel1;
404       --
405       -- The primary key is invalid therefore we must error
406       --
407       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
408       fnd_message.raise_error;
409     End If;
410     Close C_Sel1;
411     If (p_object_version_number <> g_old_rec.object_version_number) Then
412         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
413         fnd_message.raise_error;
414       End If;
415     hr_utility.set_location(l_proc, 15);
416     --
417     --
418     -- Validate the datetrack mode mode getting the validation start
419     -- and end dates for the specified datetrack operation.
420     --
421     dt_api.validate_dt_mode
422 	(p_effective_date	   => p_effective_date,
423 	 p_datetrack_mode	   => p_datetrack_mode,
424 	 p_base_table_name	   => 'ben_actl_prem_vrbl_rt_f',
425 	 p_base_key_column	   => 'actl_prem_vrbl_rt_id',
426 	 p_base_key_value 	   => p_actl_prem_vrbl_rt_id,
427 	 p_parent_table_name1      => 'ben_vrbl_rt_prfl_f',
428 	 p_parent_key_column1      => 'vrbl_rt_prfl_id',
432 	 p_parent_key_value2       => g_old_rec.actl_prem_id,
429 	 p_parent_key_value1       => g_old_rec.vrbl_rt_prfl_id,
430 	 p_parent_table_name2      => 'ben_actl_prem_f',
431 	 p_parent_key_column2      => 'actl_prem_id',
433          p_enforce_foreign_locking => false, --true,
434 	 p_validation_start_date   => l_validation_start_date,
435  	 p_validation_end_date	   => l_validation_end_date);
436   Else
437     --
438     -- We are doing a datetrack 'INSERT' which is illegal within this
439     -- procedure therefore we must error (note: to lck on insert the
440     -- private procedure ins_lck should be called).
441     --
442     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
443     fnd_message.set_token('PROCEDURE', l_proc);
444     fnd_message.set_token('STEP','20');
445     fnd_message.raise_error;
446   End If;
447   --
448   -- Set the validation start and end date OUT arguments
449   --
450   p_validation_start_date := l_validation_start_date;
451   p_validation_end_date   := l_validation_end_date;
452   --
453   hr_utility.set_location(' Leaving:'||l_proc, 30);
454 --
455 -- We need to trap the ORA LOCK exception
456 --
457 Exception
458   When HR_Api.Object_Locked then
459     --
460     -- The object is locked therefore we need to supply a meaningful
461     -- error message.
462     --
463     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
464     fnd_message.set_token('TABLE_NAME', 'ben_actl_prem_vrbl_rt_f');
465     fnd_message.raise_error;
466   When l_object_invalid then
467     --
468     -- The object doesn't exist or is invalid
469     --
470     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
471     fnd_message.set_token('TABLE_NAME', 'ben_actl_prem_vrbl_rt_f');
472     fnd_message.raise_error;
473 End lck;
474 --
475 -- ----------------------------------------------------------------------------
476 -- |-----------------------------< convert_args >-----------------------------|
477 -- ----------------------------------------------------------------------------
478 Function convert_args
479 	(
480 	p_actl_prem_vrbl_rt_id          in number,
481 	p_effective_start_date          in date,
482 	p_effective_end_date            in date,
483 	p_actl_prem_id                  in number,
484 	p_vrbl_rt_prfl_id               in number,
485         p_ordr_num                      in number,
486 	p_business_group_id             in number,
487 	p_apv_attribute_category        in varchar2,
488 	p_apv_attribute1                in varchar2,
489 	p_apv_attribute2                in varchar2,
490 	p_apv_attribute3                in varchar2,
491 	p_apv_attribute4                in varchar2,
492 	p_apv_attribute5                in varchar2,
493 	p_apv_attribute6                in varchar2,
494 	p_apv_attribute7                in varchar2,
495 	p_apv_attribute8                in varchar2,
496 	p_apv_attribute9                in varchar2,
497 	p_apv_attribute10               in varchar2,
498 	p_apv_attribute11               in varchar2,
499 	p_apv_attribute12               in varchar2,
500 	p_apv_attribute13               in varchar2,
501 	p_apv_attribute14               in varchar2,
502 	p_apv_attribute15               in varchar2,
503 	p_apv_attribute16               in varchar2,
504 	p_apv_attribute17               in varchar2,
505 	p_apv_attribute18               in varchar2,
506 	p_apv_attribute19               in varchar2,
507 	p_apv_attribute20               in varchar2,
508 	p_apv_attribute21               in varchar2,
509 	p_apv_attribute22               in varchar2,
510 	p_apv_attribute23               in varchar2,
511 	p_apv_attribute24               in varchar2,
512 	p_apv_attribute25               in varchar2,
513 	p_apv_attribute26               in varchar2,
514 	p_apv_attribute27               in varchar2,
515 	p_apv_attribute28               in varchar2,
516 	p_apv_attribute29               in varchar2,
517 	p_apv_attribute30               in varchar2,
518 	p_object_version_number         in number
519 	)
520 	Return g_rec_type is
521 --
522   l_rec	  g_rec_type;
523   l_proc  varchar2(72) := g_package||'convert_args';
524 --
525 Begin
526   --
527   hr_utility.set_location('Entering:'||l_proc, 5);
528   --
529   -- Convert arguments into local l_rec structure.
530   --
531   l_rec.actl_prem_vrbl_rt_id             := p_actl_prem_vrbl_rt_id;
532   l_rec.effective_start_date             := p_effective_start_date;
533   l_rec.effective_end_date               := p_effective_end_date;
534   l_rec.actl_prem_id                     := p_actl_prem_id;
535   l_rec.vrbl_rt_prfl_id                  := p_vrbl_rt_prfl_id;
536   l_rec.ordr_num                         := p_ordr_num;
537   l_rec.business_group_id                := p_business_group_id;
538   l_rec.apv_attribute_category           := p_apv_attribute_category;
539   l_rec.apv_attribute1                   := p_apv_attribute1;
540   l_rec.apv_attribute2                   := p_apv_attribute2;
541   l_rec.apv_attribute3                   := p_apv_attribute3;
542   l_rec.apv_attribute4                   := p_apv_attribute4;
543   l_rec.apv_attribute5                   := p_apv_attribute5;
544   l_rec.apv_attribute6                   := p_apv_attribute6;
545   l_rec.apv_attribute7                   := p_apv_attribute7;
546   l_rec.apv_attribute8                   := p_apv_attribute8;
547   l_rec.apv_attribute9                   := p_apv_attribute9;
548   l_rec.apv_attribute10                  := p_apv_attribute10;
549   l_rec.apv_attribute11                  := p_apv_attribute11;
550   l_rec.apv_attribute12                  := p_apv_attribute12;
551   l_rec.apv_attribute13                  := p_apv_attribute13;
552   l_rec.apv_attribute14                  := p_apv_attribute14;
553   l_rec.apv_attribute15                  := p_apv_attribute15;
554   l_rec.apv_attribute16                  := p_apv_attribute16;
555   l_rec.apv_attribute17                  := p_apv_attribute17;
556   l_rec.apv_attribute18                  := p_apv_attribute18;
557   l_rec.apv_attribute19                  := p_apv_attribute19;
558   l_rec.apv_attribute20                  := p_apv_attribute20;
559   l_rec.apv_attribute21                  := p_apv_attribute21;
560   l_rec.apv_attribute22                  := p_apv_attribute22;
561   l_rec.apv_attribute23                  := p_apv_attribute23;
562   l_rec.apv_attribute24                  := p_apv_attribute24;
563   l_rec.apv_attribute25                  := p_apv_attribute25;
564   l_rec.apv_attribute26                  := p_apv_attribute26;
565   l_rec.apv_attribute27                  := p_apv_attribute27;
566   l_rec.apv_attribute28                  := p_apv_attribute28;
567   l_rec.apv_attribute29                  := p_apv_attribute29;
568   l_rec.apv_attribute30                  := p_apv_attribute30;
569   l_rec.object_version_number            := p_object_version_number;
570   --
571   -- Return the plsql record structure.
572   --
573   hr_utility.set_location(' Leaving:'||l_proc, 10);
574   Return(l_rec);
575 --
576 End convert_args;
577 --
578 end ben_apv_shd;