DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_APC_SHD

Source


1 Package Body ben_apc_shd as
2 /* $Header: beapcrhi.pkb 120.1 2008/01/10 09:29:11 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_apc_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
15   l_proc 	varchar2(72) := g_package||'return_api_dml_status';
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
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_ACRS_PTIP_CVG_PK') 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   Else
42     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
45     fnd_message.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_acrs_ptip_cvg_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 	acrs_ptip_cvg_id,
66 	effective_start_date,
67 	effective_end_date,
68         name,
69 	mx_cvg_alwd_amt,
70 	mn_cvg_alwd_amt,
71         pgm_id,
72 	business_group_id,
73 	apc_attribute_category,
74 	apc_attribute1,
75 	apc_attribute2,
76 	apc_attribute3,
77 	apc_attribute4,
78 	apc_attribute5,
79 	apc_attribute6,
80 	apc_attribute7,
81 	apc_attribute8,
82 	apc_attribute9,
83 	apc_attribute10,
84 	apc_attribute11,
85 	apc_attribute12,
86 	apc_attribute13,
87 	apc_attribute14,
88 	apc_attribute15,
89 	apc_attribute16,
90 	apc_attribute17,
91 	apc_attribute18,
92 	apc_attribute19,
93 	apc_attribute20,
94 	apc_attribute21,
95 	apc_attribute22,
96 	apc_attribute23,
97 	apc_attribute24,
98 	apc_attribute25,
99 	apc_attribute26,
100 	apc_attribute27,
101 	apc_attribute28,
102 	apc_attribute29,
103 	apc_attribute30,
104 	object_version_number
105     from	ben_acrs_ptip_cvg_f
106     where	acrs_ptip_cvg_id = p_acrs_ptip_cvg_id
107     and		p_effective_date
108     between	effective_start_date and effective_end_date;
109 --
110   l_proc	varchar2(72)	:= g_package||'api_updating';
111   l_fct_ret	boolean;
112 --
113 Begin
114   hr_utility.set_location('Entering:'||l_proc, 5);
115   --
116   If (p_effective_date is null or
117       p_acrs_ptip_cvg_id is null or
118       p_object_version_number is null) Then
119     --
120     -- One of the primary key arguments is null therefore we must
121     -- set the returning function value to false
122     --
123     l_fct_ret := false;
124   Else
125     If (p_acrs_ptip_cvg_id = g_old_rec.acrs_ptip_cvg_id and
126         p_object_version_number = g_old_rec.object_version_number) Then
127       hr_utility.set_location(l_proc, 10);
128       --
129       -- The g_old_rec is current therefore we must
130       -- set the returning function to true
131       --
132       l_fct_ret := true;
133     Else
134       --
135       -- Select the current row
136       --
137       Open C_Sel1;
138       Fetch C_Sel1 Into g_old_rec;
139       If C_Sel1%notfound Then
140         Close C_Sel1;
141         --
142         -- The primary key is invalid therefore we must error
143         --
144         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
145         fnd_message.raise_error;
146       End If;
147       Close C_Sel1;
148       If (p_object_version_number <> g_old_rec.object_version_number) Then
149         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
150         fnd_message.raise_error;
151       End If;
152       hr_utility.set_location(l_proc, 15);
153       l_fct_ret := true;
154     End If;
155   End If;
156   hr_utility.set_location(' Leaving:'||l_proc, 20);
157   Return (l_fct_ret);
158 --
159 End api_updating;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |--------------------------< find_dt_del_modes >---------------------------|
163 -- ----------------------------------------------------------------------------
164 Procedure find_dt_del_modes
165 	(p_effective_date	in  date,
166 	 p_base_key_value	in  number,
167 	 p_zap		 out nocopy boolean,
168 	 p_delete	 out nocopy boolean,
169 	 p_future_change out nocopy boolean,
170 	 p_delete_next_change out nocopy boolean) is
171 --
175   --
172   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
173 --
174   --
176 --
177 Begin
178   hr_utility.set_location('Entering:'||l_proc, 5);
179     --
180   --
181   -- Call the corresponding datetrack api
182   --
183   dt_api.find_dt_del_modes
184 	(p_effective_date	=> p_effective_date,
185 	 p_base_table_name	=> 'ben_acrs_ptip_cvg_f',
186 	 p_base_key_column	=> 'acrs_ptip_cvg_id',
187 	 p_base_key_value	=> p_base_key_value,
188 	 p_zap			=> p_zap,
189 	 p_delete		=> p_delete,
190 	 p_future_change	=> p_future_change,
191 	 p_delete_next_change	=> p_delete_next_change);
192   --
193   hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End find_dt_del_modes;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |--------------------------< find_dt_upd_modes >---------------------------|
198 -- ----------------------------------------------------------------------------
199 Procedure find_dt_upd_modes
200 	(p_effective_date	in  date,
201 	 p_base_key_value	in  number,
202 	 p_correction	 out nocopy boolean,
203 	 p_update	 out nocopy boolean,
204 	 p_update_override out nocopy boolean,
205 	 p_update_change_insert out nocopy boolean) is
206 --
207   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
208 --
209 Begin
210   hr_utility.set_location('Entering:'||l_proc, 5);
211   --
212   -- Call the corresponding datetrack api
213   --
214   dt_api.find_dt_upd_modes
215 	(p_effective_date	=> p_effective_date,
216 	 p_base_table_name	=> 'ben_acrs_ptip_cvg_f',
217 	 p_base_key_column	=> 'acrs_ptip_cvg_id',
218 	 p_base_key_value	=> p_base_key_value,
219 	 p_correction		=> p_correction,
220 	 p_update		=> p_update,
221 	 p_update_override	=> p_update_override,
222 	 p_update_change_insert	=> p_update_change_insert);
223   --
224   hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End find_dt_upd_modes;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |------------------------< upd_effective_end_date >------------------------|
229 -- ----------------------------------------------------------------------------
230 Procedure upd_effective_end_date
231 	(p_effective_date		in date,
232 	 p_base_key_value		in number,
233 	 p_new_effective_end_date	in date,
234 	 p_validation_start_date	in date,
235 	 p_validation_end_date		in date,
236          p_object_version_number       out nocopy number) is
237 --
238   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
239   l_object_version_number number;
240 --
241 Begin
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   -- Because we are updating a row we must get the next object
245   -- version number.
246   --
247   l_object_version_number :=
248     dt_api.get_object_version_number
249 	(p_base_table_name	=> 'ben_acrs_ptip_cvg_f',
250 	 p_base_key_column	=> 'acrs_ptip_cvg_id',
251 	 p_base_key_value	=> p_base_key_value);
252   --
253   hr_utility.set_location(l_proc, 10);
254   g_api_dml := true;  -- Set the api dml status
255   --
256   -- Update the specified datetrack row setting the effective
257   -- end date to the specified new effective end date.
258   --
259   update  ben_acrs_ptip_cvg_f t
260   set	  t.effective_end_date	  = p_new_effective_end_date,
261 	  t.object_version_number = l_object_version_number
262   where	  t.acrs_ptip_cvg_id	  = p_base_key_value
263   and	  p_effective_date
264   between t.effective_start_date and t.effective_end_date;
265   --
266   g_api_dml := false;   -- Unset the api dml status
267   p_object_version_number := l_object_version_number;
268   hr_utility.set_location(' Leaving:'||l_proc, 15);
269 --
270 Exception
271   When Others Then
272     g_api_dml := false;   -- Unset the api dml status
273     Raise;
274 End upd_effective_end_date;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |---------------------------------< lck >----------------------------------|
278 -- ----------------------------------------------------------------------------
279 Procedure lck
280 	(p_effective_date	 in  date,
281 	 p_datetrack_mode	 in  varchar2,
282 	 p_acrs_ptip_cvg_id	 in  number,
283 	 p_object_version_number in  number,
284 	 p_validation_start_date out nocopy date,
285 	 p_validation_end_date	 out nocopy date) is
286 --
287   l_proc		  varchar2(72) := g_package||'lck';
288   l_validation_start_date date;
289   l_validation_end_date	  date;
290   l_object_invalid 	  exception;
291   l_argument		  varchar2(30);
292   --
293   -- Cursor C_Sel1 selects the current locked row as of session date
294   -- ensuring that the object version numbers match.
295   --
296   Cursor C_Sel1 is
297     select
298 	acrs_ptip_cvg_id,
299 	effective_start_date,
300 	effective_end_date,
301         name,
302 	mx_cvg_alwd_amt,
303 	mn_cvg_alwd_amt,
304         pgm_id,
305 	business_group_id,
306 	apc_attribute_category,
307 	apc_attribute1,
308 	apc_attribute2,
309 	apc_attribute3,
310 	apc_attribute4,
311 	apc_attribute5,
312 	apc_attribute6,
313 	apc_attribute7,
314 	apc_attribute8,
315 	apc_attribute9,
316 	apc_attribute10,
317 	apc_attribute11,
318 	apc_attribute12,
319 	apc_attribute13,
320 	apc_attribute14,
321 	apc_attribute15,
322 	apc_attribute16,
323 	apc_attribute17,
324 	apc_attribute18,
325 	apc_attribute19,
326 	apc_attribute20,
327 	apc_attribute21,
328 	apc_attribute22,
329 	apc_attribute23,
330 	apc_attribute24,
331 	apc_attribute25,
335 	apc_attribute29,
332 	apc_attribute26,
333 	apc_attribute27,
334 	apc_attribute28,
336 	apc_attribute30,
337 	object_version_number
338     from    ben_acrs_ptip_cvg_f
339     where   acrs_ptip_cvg_id         = p_acrs_ptip_cvg_id
340     and	    p_effective_date
341     between effective_start_date and effective_end_date
342     for update nowait;
343   --
344   --
345   --
346 Begin
347   hr_utility.set_location('Entering:'||l_proc, 5);
348   --
349   -- Ensure that all the mandatory arguments are not null
350   --
351   hr_api.mandatory_arg_error(p_api_name       => l_proc,
352                              p_argument       => 'effective_date',
353                              p_argument_value => p_effective_date);
354   --
355   hr_api.mandatory_arg_error(p_api_name       => l_proc,
356                              p_argument       => 'datetrack_mode',
357                              p_argument_value => p_datetrack_mode);
358   --
359   hr_api.mandatory_arg_error(p_api_name       => l_proc,
360                              p_argument       => 'acrs_ptip_cvg_id',
361                              p_argument_value => p_acrs_ptip_cvg_id);
362   --
363   hr_api.mandatory_arg_error(p_api_name       => l_proc,
364                              p_argument       => 'object_version_number',
365                              p_argument_value => p_object_version_number);
366   --
367   -- Check to ensure the datetrack mode is not INSERT.
368   --
369   If (p_datetrack_mode <> 'INSERT') then
370     --
371     -- We must select and lock the current row.
372     --
373     Open  C_Sel1;
374     Fetch C_Sel1 Into g_old_rec;
375     If C_Sel1%notfound then
376       Close C_Sel1;
377       --
378       -- The primary key is invalid therefore we must error
379       --
380       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
381       fnd_message.raise_error;
382     End If;
383     Close C_Sel1;
384     If (p_object_version_number <> g_old_rec.object_version_number) Then
385         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
386         fnd_message.raise_error;
387       End If;
388     hr_utility.set_location(l_proc, 15);
389     --
390     --
391     -- Validate the datetrack mode mode getting the validation start
392     -- and end dates for the specified datetrack operation.
393     --
394     dt_api.validate_dt_mode
395 	(p_effective_date	   => p_effective_date,
396 	 p_datetrack_mode	   => p_datetrack_mode,
397 	 p_base_table_name	   => 'ben_acrs_ptip_cvg_f',
398 	 p_base_key_column	   => 'acrs_ptip_cvg_id',
399 	 p_base_key_value 	   => p_acrs_ptip_cvg_id,
400 
401          p_enforce_foreign_locking => false , --true,
402 	 p_validation_start_date   => l_validation_start_date,
403  	 p_validation_end_date	   => l_validation_end_date);
404   Else
405     --
406     -- We are doing a datetrack 'INSERT' which is illegal within this
407     -- procedure therefore we must error (note: to lck on insert the
408     -- private procedure ins_lck should be called).
409     --
410     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
411     fnd_message.set_token('PROCEDURE', l_proc);
412     fnd_message.set_token('STEP','20');
413     fnd_message.raise_error;
414   End If;
415   --
416   -- Set the validation start and end date OUT arguments
417   --
418   p_validation_start_date := l_validation_start_date;
419   p_validation_end_date   := l_validation_end_date;
420   --
421   hr_utility.set_location(' Leaving:'||l_proc, 30);
422 --
423 -- We need to trap the ORA LOCK exception
424 --
425 Exception
426   When HR_Api.Object_Locked then
427     --
428     -- The object is locked therefore we need to supply a meaningful
429     -- error message.
430     --
431     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
432     fnd_message.set_token('TABLE_NAME', 'ben_acrs_ptip_cvg_f');
433     fnd_message.raise_error;
434   When l_object_invalid then
435     --
436     -- The object doesn't exist or is invalid
437     --
438     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
439     fnd_message.set_token('TABLE_NAME', 'ben_acrs_ptip_cvg_f');
440     fnd_message.raise_error;
441 End lck;
442 --
443 -- ----------------------------------------------------------------------------
444 -- |-----------------------------< convert_args >-----------------------------|
445 -- ----------------------------------------------------------------------------
446 Function convert_args
447 	(
448 	p_acrs_ptip_cvg_id              in number,
449 	p_effective_start_date          in date,
450 	p_effective_end_date            in date,
451         p_name                          in varchar2,
452 	p_mx_cvg_alwd_amt               in number,
453 	p_mn_cvg_alwd_amt               in number,
454         p_pgm_id                        in number,
455 	p_business_group_id             in number,
456 	p_apc_attribute_category        in varchar2,
457 	p_apc_attribute1                in varchar2,
458 	p_apc_attribute2                in varchar2,
459 	p_apc_attribute3                in varchar2,
460 	p_apc_attribute4                in varchar2,
461 	p_apc_attribute5                in varchar2,
462 	p_apc_attribute6                in varchar2,
463 	p_apc_attribute7                in varchar2,
464 	p_apc_attribute8                in varchar2,
465 	p_apc_attribute9                in varchar2,
466 	p_apc_attribute10               in varchar2,
467 	p_apc_attribute11               in varchar2,
468 	p_apc_attribute12               in varchar2,
469 	p_apc_attribute13               in varchar2,
470 	p_apc_attribute14               in varchar2,
471 	p_apc_attribute15               in varchar2,
475 	p_apc_attribute19               in varchar2,
472 	p_apc_attribute16               in varchar2,
473 	p_apc_attribute17               in varchar2,
474 	p_apc_attribute18               in varchar2,
476 	p_apc_attribute20               in varchar2,
477 	p_apc_attribute21               in varchar2,
478 	p_apc_attribute22               in varchar2,
479 	p_apc_attribute23               in varchar2,
480 	p_apc_attribute24               in varchar2,
481 	p_apc_attribute25               in varchar2,
482 	p_apc_attribute26               in varchar2,
483 	p_apc_attribute27               in varchar2,
484 	p_apc_attribute28               in varchar2,
485 	p_apc_attribute29               in varchar2,
486 	p_apc_attribute30               in varchar2,
487 	p_object_version_number         in number
488 	)
489 	Return g_rec_type is
490 --
491   l_rec	  g_rec_type;
492   l_proc  varchar2(72) := g_package||'convert_args';
493 --
494 Begin
495   --
496   hr_utility.set_location('Entering:'||l_proc, 5);
497   --
498   -- Convert arguments into local l_rec structure.
499   --
500   l_rec.acrs_ptip_cvg_id                 := p_acrs_ptip_cvg_id;
501   l_rec.effective_start_date             := p_effective_start_date;
502   l_rec.effective_end_date               := p_effective_end_date;
503   l_rec.name                             := p_name;
504   l_rec.mx_cvg_alwd_amt                  := p_mx_cvg_alwd_amt;
505   l_rec.mn_cvg_alwd_amt                  := p_mn_cvg_alwd_amt;
506   l_rec.pgm_id                           := p_pgm_id;
507   l_rec.business_group_id                := p_business_group_id;
508   l_rec.apc_attribute_category           := p_apc_attribute_category;
509   l_rec.apc_attribute1                   := p_apc_attribute1;
510   l_rec.apc_attribute2                   := p_apc_attribute2;
511   l_rec.apc_attribute3                   := p_apc_attribute3;
512   l_rec.apc_attribute4                   := p_apc_attribute4;
513   l_rec.apc_attribute5                   := p_apc_attribute5;
514   l_rec.apc_attribute6                   := p_apc_attribute6;
515   l_rec.apc_attribute7                   := p_apc_attribute7;
516   l_rec.apc_attribute8                   := p_apc_attribute8;
517   l_rec.apc_attribute9                   := p_apc_attribute9;
518   l_rec.apc_attribute10                  := p_apc_attribute10;
519   l_rec.apc_attribute11                  := p_apc_attribute11;
520   l_rec.apc_attribute12                  := p_apc_attribute12;
521   l_rec.apc_attribute13                  := p_apc_attribute13;
522   l_rec.apc_attribute14                  := p_apc_attribute14;
523   l_rec.apc_attribute15                  := p_apc_attribute15;
524   l_rec.apc_attribute16                  := p_apc_attribute16;
525   l_rec.apc_attribute17                  := p_apc_attribute17;
526   l_rec.apc_attribute18                  := p_apc_attribute18;
527   l_rec.apc_attribute19                  := p_apc_attribute19;
528   l_rec.apc_attribute20                  := p_apc_attribute20;
529   l_rec.apc_attribute21                  := p_apc_attribute21;
530   l_rec.apc_attribute22                  := p_apc_attribute22;
531   l_rec.apc_attribute23                  := p_apc_attribute23;
532   l_rec.apc_attribute24                  := p_apc_attribute24;
533   l_rec.apc_attribute25                  := p_apc_attribute25;
534   l_rec.apc_attribute26                  := p_apc_attribute26;
535   l_rec.apc_attribute27                  := p_apc_attribute27;
536   l_rec.apc_attribute28                  := p_apc_attribute28;
537   l_rec.apc_attribute29                  := p_apc_attribute29;
538   l_rec.apc_attribute30                  := p_apc_attribute30;
539   l_rec.object_version_number            := p_object_version_number;
540   --
541   -- Return the plsql record structure.
542   --
543   hr_utility.set_location(' Leaving:'||l_proc, 10);
544   Return(l_rec);
545 --
546 End convert_args;
547 --
548 end ben_apc_shd;