DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ADS_SHD

Source


1 Package Body ben_ads_shd as
2 /* $Header: beadsrhi.pkb 120.0.12010000.3 2008/08/25 14:01:51 ppentapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ads_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_ACTY_RT_DED_SCHED_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_ACTY_RT_DED_SCHED_FK2') 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   ElsIf (p_constraint_name = 'BEN_ACTY_RT_DED_SCHED_F_PK') Then
47     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('STEP','15');
50     fnd_message.raise_error;
51   Else
52     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
53     fnd_message.set_token('PROCEDURE', l_proc);
54     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
55     fnd_message.raise_error;
56   End If;
57   --
58   hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65   (p_effective_date		in date,
66    p_acty_rt_ded_sched_id		in number,
67    p_object_version_number	in number
68   ) Return Boolean Is
69 --
70   --
71   -- Cursor selects the 'current' row from the HR Schema
72   --
73   Cursor C_Sel1 is
74     select
75 	acty_rt_ded_sched_id,
76 	effective_start_date,
77 	effective_end_date,
78 	business_group_id,
79 	ded_sched_py_freq_id,
80 	acty_base_rt_id,
81 	ded_sched_rl,
82 	ded_sched_cd,
83 	ads_attribute_category,
84 	ads_attribute1,
85 	ads_attribute2,
86 	ads_attribute3,
87 	ads_attribute4,
88 	ads_attribute5,
89 	ads_attribute6,
90 	ads_attribute7,
91 	ads_attribute8,
92 	ads_attribute9,
93 	ads_attribute10,
94 	ads_attribute11,
95 	ads_attribute12,
96 	ads_attribute13,
97 	ads_attribute14,
98 	ads_attribute15,
99 	ads_attribute16,
100 	ads_attribute17,
101 	ads_attribute18,
102 	ads_attribute19,
103 	ads_attribute20,
104 	ads_attribute21,
105 	ads_attribute22,
106 	ads_attribute23,
107 	ads_attribute24,
108 	ads_attribute25,
109 	ads_attribute26,
110 	ads_attribute27,
111 	ads_attribute28,
112 	ads_attribute29,
113 	ads_attribute30,
114 	object_version_number
115     from	ben_acty_rt_ded_sched_f
116     where	acty_rt_ded_sched_id = p_acty_rt_ded_sched_id
117     and		p_effective_date
118     between	effective_start_date and effective_end_date;
119 --
120   l_proc	varchar2(72)	:= g_package||'api_updating';
121   l_fct_ret	boolean;
122 --
123 Begin
124   hr_utility.set_location('Entering:'||l_proc, 5);
125   --
126   If (p_effective_date is null or
127       p_acty_rt_ded_sched_id is null or
128       p_object_version_number is null) Then
129     --
130     -- One of the primary key arguments is null therefore we must
131     -- set the returning function value to false
132     --
133     l_fct_ret := false;
134   Else
135     If (p_acty_rt_ded_sched_id = g_old_rec.acty_rt_ded_sched_id and
136         p_object_version_number = g_old_rec.object_version_number) Then
137       hr_utility.set_location(l_proc, 10);
138       --
139       -- The g_old_rec is current therefore we must
140       -- set the returning function to true
141       --
142       l_fct_ret := true;
143     Else
144       --
145       -- Select the current row
146       --
147       Open C_Sel1;
148       Fetch C_Sel1 Into g_old_rec;
149       If C_Sel1%notfound Then
150         Close C_Sel1;
151         --
152         -- The primary key is invalid therefore we must error
153         --
154         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
155         fnd_message.raise_error;
156       End If;
157       Close C_Sel1;
158       If (p_object_version_number <> g_old_rec.object_version_number) Then
159         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
160         fnd_message.raise_error;
161       End If;
162       hr_utility.set_location(l_proc, 15);
163       l_fct_ret := true;
164     End If;
165   End If;
166   hr_utility.set_location(' Leaving:'||l_proc, 20);
167   Return (l_fct_ret);
168 --
169 End api_updating;
170 --
171 -- ----------------------------------------------------------------------------
172 -- |--------------------------< find_dt_del_modes >---------------------------|
173 -- ----------------------------------------------------------------------------
174 Procedure find_dt_del_modes
175 	(p_effective_date	in  date,
176 	 p_base_key_value	in  number,
177 	 p_zap		 out nocopy boolean,
178 	 p_delete	 out nocopy boolean,
179 	 p_future_change out nocopy boolean,
180 	 p_delete_next_change out nocopy boolean) is
181 --
182   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
183 --
184   l_parent_key_value1	number;
185   --
186   Cursor C_Sel1 Is
187     select  t.acty_base_rt_id
188     from    ben_acty_rt_ded_sched_f t
189     where   t.acty_rt_ded_sched_id = p_base_key_value
190     and     p_effective_date
191     between t.effective_start_date and t.effective_end_date;
192 --
193 Begin
194   hr_utility.set_location('Entering:'||l_proc, 5);
195   Open  C_Sel1;
196   Fetch C_Sel1 Into l_parent_key_value1;
197   If C_Sel1%notfound then
198     Close C_Sel1;
199     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
200     fnd_message.set_token('PROCEDURE', l_proc);
201     fnd_message.set_token('STEP','10');
202     fnd_message.raise_error;
203   End If;
204   Close C_Sel1;
205   --
206   -- Call the corresponding datetrack api
207   --
208   dt_api.find_dt_del_modes
209 	(p_effective_date	=> p_effective_date,
210 	 p_base_table_name	=> 'ben_acty_rt_ded_sched_f',
211 	 p_base_key_column	=> 'acty_rt_ded_sched_id',
212 	 p_base_key_value	=> p_base_key_value,
213 	 p_parent_table_name1	=> 'ben_acty_base_rt_f',
214 	 p_parent_key_column1	=> 'acty_base_rt_id',
215 	 p_parent_key_value1	=> l_parent_key_value1,
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_acty_rt_ded_sched_f',
245 	 p_base_key_column	=> 'acty_rt_ded_sched_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_acty_rt_ded_sched_f',
278 	 p_base_key_column	=> 'acty_rt_ded_sched_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_acty_rt_ded_sched_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.acty_rt_ded_sched_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_acty_rt_ded_sched_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 	acty_rt_ded_sched_id,
327 	effective_start_date,
328 	effective_end_date,
329 	business_group_id,
330 	ded_sched_py_freq_id,
331 	acty_base_rt_id,
332 	ded_sched_rl,
333 	ded_sched_cd,
334 	ads_attribute_category,
335 	ads_attribute1,
336 	ads_attribute2,
337 	ads_attribute3,
338 	ads_attribute4,
339 	ads_attribute5,
340 	ads_attribute6,
341 	ads_attribute7,
342 	ads_attribute8,
343 	ads_attribute9,
344 	ads_attribute10,
345 	ads_attribute11,
346 	ads_attribute12,
347 	ads_attribute13,
348 	ads_attribute14,
349 	ads_attribute15,
350 	ads_attribute16,
351 	ads_attribute17,
352 	ads_attribute18,
353 	ads_attribute19,
354 	ads_attribute20,
355 	ads_attribute21,
356 	ads_attribute22,
357 	ads_attribute23,
358 	ads_attribute24,
359 	ads_attribute25,
360 	ads_attribute26,
361 	ads_attribute27,
362 	ads_attribute28,
363 	ads_attribute29,
364 	ads_attribute30,
365 	object_version_number
366     from    ben_acty_rt_ded_sched_f
367     where   acty_rt_ded_sched_id         = p_acty_rt_ded_sched_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',
381                              p_argument_value => p_effective_date);
382   --
383   hr_api.mandatory_arg_error(p_api_name       => l_proc,
384                              p_argument       => 'datetrack_mode',
385                              p_argument_value => p_datetrack_mode);
386   --
387   hr_api.mandatory_arg_error(p_api_name       => l_proc,
388                              p_argument       => 'acty_rt_ded_sched_id',
389                              p_argument_value => p_acty_rt_ded_sched_id);
393                              p_argument_value => p_object_version_number);
390   --
391   hr_api.mandatory_arg_error(p_api_name       => l_proc,
392                              p_argument       => '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_acty_rt_ded_sched_f',
426 	 p_base_key_column	   => 'acty_rt_ded_sched_id',
427 	 p_base_key_value 	   => p_acty_rt_ded_sched_id,
428 	 p_parent_table_name1      => 'ben_acty_base_rt_f',
429 	 p_parent_key_column1      => 'acty_base_rt_id',
430 	 p_parent_key_value1       => g_old_rec.acty_base_rt_id,
431          p_enforce_foreign_locking => false , --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_acty_rt_ded_sched_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_acty_rt_ded_sched_f');
470     fnd_message.raise_error;
471 End lck;
472 --
473 -- ----------------------------------------------------------------------------
474 -- |-----------------------------< convert_args >-----------------------------|
475 -- ----------------------------------------------------------------------------
476 Function convert_args
477 	(
478 	p_acty_rt_ded_sched_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_ded_sched_py_freq_id          in number,
483 	p_acty_base_rt_id               in number,
484 	p_ded_sched_rl                  in number,
485 	p_ded_sched_cd                  in varchar2,
486 	p_ads_attribute_category        in varchar2,
487 	p_ads_attribute1                in varchar2,
488 	p_ads_attribute2                in varchar2,
489 	p_ads_attribute3                in varchar2,
490 	p_ads_attribute4                in varchar2,
491 	p_ads_attribute5                in varchar2,
492 	p_ads_attribute6                in varchar2,
493 	p_ads_attribute7                in varchar2,
494 	p_ads_attribute8                in varchar2,
495 	p_ads_attribute9                in varchar2,
496 	p_ads_attribute10               in varchar2,
497 	p_ads_attribute11               in varchar2,
498 	p_ads_attribute12               in varchar2,
499 	p_ads_attribute13               in varchar2,
500 	p_ads_attribute14               in varchar2,
501 	p_ads_attribute15               in varchar2,
502 	p_ads_attribute16               in varchar2,
503 	p_ads_attribute17               in varchar2,
504 	p_ads_attribute18               in varchar2,
505 	p_ads_attribute19               in varchar2,
506 	p_ads_attribute20               in varchar2,
507 	p_ads_attribute21               in varchar2,
508 	p_ads_attribute22               in varchar2,
509 	p_ads_attribute23               in varchar2,
510 	p_ads_attribute24               in varchar2,
511 	p_ads_attribute25               in varchar2,
512 	p_ads_attribute26               in varchar2,
513 	p_ads_attribute27               in varchar2,
514 	p_ads_attribute28               in varchar2,
515 	p_ads_attribute29               in varchar2,
516 	p_ads_attribute30               in varchar2,
517 	p_object_version_number         in number
518 	)
519 	Return g_rec_type is
520 --
521   l_rec	  g_rec_type;
522   l_proc  varchar2(72) := g_package||'convert_args';
523 --
524 Begin
525   --
526   hr_utility.set_location('Entering:'||l_proc, 5);
527   --
528   -- Convert arguments into local l_rec structure.
529   --
530   l_rec.acty_rt_ded_sched_id             := p_acty_rt_ded_sched_id;
531   l_rec.effective_start_date             := p_effective_start_date;
532   l_rec.effective_end_date               := p_effective_end_date;
533   l_rec.business_group_id                := p_business_group_id;
534   l_rec.ded_sched_py_freq_id             := p_ded_sched_py_freq_id;
535   l_rec.acty_base_rt_id                  := p_acty_base_rt_id;
536   l_rec.ded_sched_rl                     := p_ded_sched_rl;
537   l_rec.ded_sched_cd                     := p_ded_sched_cd;
538   l_rec.ads_attribute_category           := p_ads_attribute_category;
539   l_rec.ads_attribute1                   := p_ads_attribute1;
540   l_rec.ads_attribute2                   := p_ads_attribute2;
541   l_rec.ads_attribute3                   := p_ads_attribute3;
542   l_rec.ads_attribute4                   := p_ads_attribute4;
543   l_rec.ads_attribute5                   := p_ads_attribute5;
544   l_rec.ads_attribute6                   := p_ads_attribute6;
545   l_rec.ads_attribute7                   := p_ads_attribute7;
546   l_rec.ads_attribute8                   := p_ads_attribute8;
547   l_rec.ads_attribute9                   := p_ads_attribute9;
548   l_rec.ads_attribute10                  := p_ads_attribute10;
549   l_rec.ads_attribute11                  := p_ads_attribute11;
550   l_rec.ads_attribute12                  := p_ads_attribute12;
551   l_rec.ads_attribute13                  := p_ads_attribute13;
552   l_rec.ads_attribute14                  := p_ads_attribute14;
553   l_rec.ads_attribute15                  := p_ads_attribute15;
554   l_rec.ads_attribute16                  := p_ads_attribute16;
555   l_rec.ads_attribute17                  := p_ads_attribute17;
556   l_rec.ads_attribute18                  := p_ads_attribute18;
557   l_rec.ads_attribute19                  := p_ads_attribute19;
558   l_rec.ads_attribute20                  := p_ads_attribute20;
559   l_rec.ads_attribute21                  := p_ads_attribute21;
560   l_rec.ads_attribute22                  := p_ads_attribute22;
561   l_rec.ads_attribute23                  := p_ads_attribute23;
562   l_rec.ads_attribute24                  := p_ads_attribute24;
563   l_rec.ads_attribute25                  := p_ads_attribute25;
564   l_rec.ads_attribute26                  := p_ads_attribute26;
565   l_rec.ads_attribute27                  := p_ads_attribute27;
566   l_rec.ads_attribute28                  := p_ads_attribute28;
567   l_rec.ads_attribute29                  := p_ads_attribute29;
568   l_rec.ads_attribute30                  := p_ads_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_ads_shd;