DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_APL_SHD

Source


1 Package Body ben_apl_shd as
2 /* $Header: beaplrhi.pkb 120.0.12010000.3 2008/08/25 14:06:41 ppentapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_apl_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_PTD_LMT_F_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_PTD_LMT_F_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_acty_rt_ptd_lmt_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 	acty_rt_ptd_lmt_id,
71 	effective_start_date,
72 	effective_end_date,
73 	acty_base_rt_id,
74         ptd_lmt_id,
75 	business_group_id,
76 	apl_attribute_category,
77 	apl_attribute1,
78 	apl_attribute2,
79 	apl_attribute3,
80 	apl_attribute4,
81 	apl_attribute5,
82 	apl_attribute6,
83 	apl_attribute7,
84 	apl_attribute8,
85 	apl_attribute9,
86 	apl_attribute10,
87 	apl_attribute11,
88 	apl_attribute12,
89 	apl_attribute13,
90 	apl_attribute14,
91 	apl_attribute15,
92 	apl_attribute16,
93 	apl_attribute17,
94 	apl_attribute18,
95 	apl_attribute19,
96 	apl_attribute20,
97 	apl_attribute21,
98 	apl_attribute22,
99 	apl_attribute23,
100 	apl_attribute24,
101 	apl_attribute25,
102 	apl_attribute26,
103 	apl_attribute27,
104 	apl_attribute28,
105 	apl_attribute29,
106 	apl_attribute30,
107 	object_version_number
108     from	ben_acty_rt_ptd_lmt_f
109     where	acty_rt_ptd_lmt_id = p_acty_rt_ptd_lmt_id
110     and		p_effective_date
111     between	effective_start_date and effective_end_date;
112 --
113   l_proc	varchar2(72)	:= g_package||'api_updating';
114   l_fct_ret	boolean;
115 --
116 Begin
117   hr_utility.set_location('Entering:'||l_proc, 5);
118   --
119   If (p_effective_date is null or
120       p_acty_rt_ptd_lmt_id is null or
121       p_object_version_number is null) Then
122     --
123     -- One of the primary key arguments is null therefore we must
124     -- set the returning function value to false
125     --
126     l_fct_ret := false;
127   Else
128     If (p_acty_rt_ptd_lmt_id = g_old_rec.acty_rt_ptd_lmt_id and
129         p_object_version_number = g_old_rec.object_version_number) Then
130       hr_utility.set_location(l_proc, 10);
131       --
132       -- The g_old_rec is current therefore we must
133       -- set the returning function to true
134       --
135       l_fct_ret := true;
136     Else
137       --
138       -- Select the current row
139       --
140       Open C_Sel1;
141       Fetch C_Sel1 Into g_old_rec;
142       If C_Sel1%notfound Then
143         Close C_Sel1;
144         --
145         -- The primary key is invalid therefore we must error
146         --
147         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
148         fnd_message.raise_error;
149       End If;
150       Close C_Sel1;
151       If (p_object_version_number <> g_old_rec.object_version_number) Then
152         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
153         fnd_message.raise_error;
154       End If;
155       hr_utility.set_location(l_proc, 15);
156       l_fct_ret := true;
157     End If;
158   End If;
159   hr_utility.set_location(' Leaving:'||l_proc, 20);
160   Return (l_fct_ret);
161 --
162 End api_updating;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |--------------------------< find_dt_del_modes >---------------------------|
166 -- ----------------------------------------------------------------------------
167 Procedure find_dt_del_modes
168 	(p_effective_date	in  date,
169 	 p_base_key_value	in  number,
170 	 p_zap		 out nocopy boolean,
171 	 p_delete	 out nocopy boolean,
172 	 p_future_change out nocopy boolean,
173 	 p_delete_next_change out nocopy boolean) is
174 --
175   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
176 --
177   l_parent_key_value1	number;
178   l_parent_key_value2	number;
179   --
180   Cursor C_Sel1 Is
181     select  t.acty_base_rt_id ,
182             t.ptd_lmt_id
183     from    ben_acty_rt_ptd_lmt_f t
184     where   t.acty_rt_ptd_lmt_id = p_base_key_value
185     and     p_effective_date
186     between t.effective_start_date and t.effective_end_date;
187 --
188 Begin
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   Open  C_Sel1;
191   Fetch C_Sel1 Into l_parent_key_value1,
192                    l_parent_key_value2;
193   If C_Sel1%notfound then
194     Close C_Sel1;
195     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
196     fnd_message.set_token('PROCEDURE', l_proc);
197     fnd_message.set_token('STEP','10');
198     fnd_message.raise_error;
199   End If;
200   Close C_Sel1;
201   --
202   -- Call the corresponding datetrack api
203   --
204   dt_api.find_dt_del_modes
205 	(p_effective_date	=> p_effective_date,
206 	 p_base_table_name	=> 'ben_acty_rt_ptd_lmt_f',
207 	 p_base_key_column	=> 'acty_rt_ptd_lmt_id',
208 	 p_base_key_value	=> p_base_key_value,
209 	 p_parent_table_name1	=> 'ben_acty_base_rt_f',
210 	 p_parent_key_column1	=> 'acty_base_rt_id',
211 	 p_parent_key_value1	=> l_parent_key_value1,
212          p_parent_table_name2   => 'ben_ptd_lmt_f',
213          p_parent_key_column2   => 'ptd_lmt_id',
214          p_parent_key_value2    => l_parent_key_value2,
215 	 p_zap			=> p_zap,
216 	 p_delete		=> p_delete,
217 	 p_future_change	=> p_future_change,
218 	 p_delete_next_change	=> p_delete_next_change);
219   --
220   hr_utility.set_location(' Leaving:'||l_proc, 10);
221 End find_dt_del_modes;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |--------------------------< find_dt_upd_modes >---------------------------|
225 -- ----------------------------------------------------------------------------
226 Procedure find_dt_upd_modes
227 	(p_effective_date	in  date,
228 	 p_base_key_value	in  number,
229 	 p_correction	 out nocopy boolean,
230 	 p_update	 out nocopy boolean,
231 	 p_update_override out nocopy boolean,
232 	 p_update_change_insert out nocopy boolean) is
233 --
234   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
235 --
236 Begin
237   hr_utility.set_location('Entering:'||l_proc, 5);
238   --
239   -- Call the corresponding datetrack api
240   --
241   dt_api.find_dt_upd_modes
242 	(p_effective_date	=> p_effective_date,
243 	 p_base_table_name	=> 'ben_acty_rt_ptd_lmt_f',
244 	 p_base_key_column	=> 'acty_rt_ptd_lmt_id',
245 	 p_base_key_value	=> p_base_key_value,
246 	 p_correction		=> p_correction,
247 	 p_update		=> p_update,
248 	 p_update_override	=> p_update_override,
249 	 p_update_change_insert	=> p_update_change_insert);
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End find_dt_upd_modes;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |------------------------< upd_effective_end_date >------------------------|
256 -- ----------------------------------------------------------------------------
257 Procedure upd_effective_end_date
258 	(p_effective_date		in date,
259 	 p_base_key_value		in number,
260 	 p_new_effective_end_date	in date,
261 	 p_validation_start_date	in date,
262 	 p_validation_end_date		in date,
263          p_object_version_number       out nocopy number) is
264 --
265   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
266   l_object_version_number number;
267 --
268 Begin
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   --
271   -- Because we are updating a row we must get the next object
272   -- version number.
273   --
274   l_object_version_number :=
275     dt_api.get_object_version_number
276 	(p_base_table_name	=> 'ben_acty_rt_ptd_lmt_f',
277 	 p_base_key_column	=> 'acty_rt_ptd_lmt_id',
278 	 p_base_key_value	=> p_base_key_value);
279   --
280   hr_utility.set_location(l_proc, 10);
281   g_api_dml := true;  -- Set the api dml status
282   --
283   -- Update the specified datetrack row setting the effective
284   -- end date to the specified new effective end date.
285   --
286   update  ben_acty_rt_ptd_lmt_f t
287   set	  t.effective_end_date	  = p_new_effective_end_date,
288 	  t.object_version_number = l_object_version_number
289   where	  t.acty_rt_ptd_lmt_id	  = p_base_key_value
290   and	  p_effective_date
291   between t.effective_start_date and t.effective_end_date;
292   --
293   g_api_dml := false;   -- Unset the api dml status
294   p_object_version_number := l_object_version_number;
295   hr_utility.set_location(' Leaving:'||l_proc, 15);
296 --
297 Exception
298   When Others Then
299     g_api_dml := false;   -- Unset the api dml status
300     Raise;
301 End upd_effective_end_date;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------------< lck >----------------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure lck
307 	(p_effective_date	 in  date,
308 	 p_datetrack_mode	 in  varchar2,
309 	 p_acty_rt_ptd_lmt_id	 in  number,
310 	 p_object_version_number in  number,
311 	 p_validation_start_date out nocopy date,
312 	 p_validation_end_date	 out nocopy date) is
313 --
314   l_proc		  varchar2(72) := g_package||'lck';
315   l_validation_start_date date;
316   l_validation_end_date	  date;
317   l_object_invalid 	  exception;
318   l_argument		  varchar2(30);
319   --
320   -- Cursor C_Sel1 selects the current locked row as of session date
321   -- ensuring that the object version numbers match.
322   --
323   Cursor C_Sel1 is
324     select
325 	acty_rt_ptd_lmt_id,
326 	effective_start_date,
327 	effective_end_date,
328 	acty_base_rt_id,
329         ptd_lmt_id,
330 	business_group_id,
331 	apl_attribute_category,
332 	apl_attribute1,
333 	apl_attribute2,
334 	apl_attribute3,
335 	apl_attribute4,
336 	apl_attribute5,
337 	apl_attribute6,
338 	apl_attribute7,
339 	apl_attribute8,
340 	apl_attribute9,
341 	apl_attribute10,
342 	apl_attribute11,
343 	apl_attribute12,
344 	apl_attribute13,
345 	apl_attribute14,
346 	apl_attribute15,
347 	apl_attribute16,
348 	apl_attribute17,
349 	apl_attribute18,
350 	apl_attribute19,
351 	apl_attribute20,
352 	apl_attribute21,
353 	apl_attribute22,
354 	apl_attribute23,
355 	apl_attribute24,
356 	apl_attribute25,
357 	apl_attribute26,
358 	apl_attribute27,
359 	apl_attribute28,
360 	apl_attribute29,
361 	apl_attribute30,
362 	object_version_number
363     from    ben_acty_rt_ptd_lmt_f
364     where   acty_rt_ptd_lmt_id         = p_acty_rt_ptd_lmt_id
365     and	    p_effective_date
366     between effective_start_date and effective_end_date
367     for update nowait;
368   --
369   --
370   --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374   -- Ensure that all the mandatory arguments are not null
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'effective_date',
378                              p_argument_value => p_effective_date);
379   --
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'datetrack_mode',
382                              p_argument_value => p_datetrack_mode);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'acty_rt_ptd_lmt_id',
386                              p_argument_value => p_acty_rt_ptd_lmt_id);
387   --
388   hr_api.mandatory_arg_error(p_api_name       => l_proc,
389                              p_argument       => 'object_version_number',
390                              p_argument_value => p_object_version_number);
391   --
392   -- Check to ensure the datetrack mode is not INSERT.
393   --
394   If (p_datetrack_mode <> 'INSERT') then
395     --
396     -- We must select and lock the current row.
397     --
398     Open  C_Sel1;
399     Fetch C_Sel1 Into g_old_rec;
400     If C_Sel1%notfound then
401       Close C_Sel1;
402       --
403       -- The primary key is invalid therefore we must error
404       --
405       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
406       fnd_message.raise_error;
407     End If;
408     Close C_Sel1;
409     If (p_object_version_number <> g_old_rec.object_version_number) Then
410         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
411         fnd_message.raise_error;
412       End If;
413     hr_utility.set_location(l_proc, 15);
414     --
415     --
416     -- Validate the datetrack mode mode getting the validation start
417     -- and end dates for the specified datetrack operation.
418     --
419     dt_api.validate_dt_mode
420 	(p_effective_date	   => p_effective_date,
421 	 p_datetrack_mode	   => p_datetrack_mode,
422 	 p_base_table_name	   => 'ben_acty_rt_ptd_lmt_f',
423 	 p_base_key_column	   => 'acty_rt_ptd_lmt_id',
424 	 p_base_key_value 	   => p_acty_rt_ptd_lmt_id,
425 	 p_parent_table_name1      => 'ben_acty_base_rt_f',
426 	 p_parent_key_column1      => 'acty_base_rt_id',
430          p_parent_key_value2       => g_old_rec.ptd_lmt_id,
427 	 p_parent_key_value1       => g_old_rec.acty_base_rt_id,
428          p_parent_table_name2      => 'ben_ptd_lmt_f',
429          p_parent_key_column2      => 'ptd_lmt_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_ptd_lmt_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_ptd_lmt_f');
470     fnd_message.raise_error;
471 End lck;
472 --
473 -- ----------------------------------------------------------------------------
474 -- |-----------------------------< convert_args >-----------------------------|
475 -- ----------------------------------------------------------------------------
476 Function convert_args
477 	(
478 	p_acty_rt_ptd_lmt_id            in number,
479 	p_effective_start_date          in date,
480 	p_effective_end_date            in date,
481 	p_acty_base_rt_id               in number,
482         p_ptd_lmt_id                    in number,
483 	p_business_group_id             in number,
484 	p_apl_attribute_category        in varchar2,
485 	p_apl_attribute1                in varchar2,
486 	p_apl_attribute2                in varchar2,
487 	p_apl_attribute3                in varchar2,
488 	p_apl_attribute4                in varchar2,
489 	p_apl_attribute5                in varchar2,
490 	p_apl_attribute6                in varchar2,
491 	p_apl_attribute7                in varchar2,
492 	p_apl_attribute8                in varchar2,
493 	p_apl_attribute9                in varchar2,
494 	p_apl_attribute10               in varchar2,
495 	p_apl_attribute11               in varchar2,
496 	p_apl_attribute12               in varchar2,
497 	p_apl_attribute13               in varchar2,
498 	p_apl_attribute14               in varchar2,
499 	p_apl_attribute15               in varchar2,
500 	p_apl_attribute16               in varchar2,
501 	p_apl_attribute17               in varchar2,
502 	p_apl_attribute18               in varchar2,
503 	p_apl_attribute19               in varchar2,
504 	p_apl_attribute20               in varchar2,
505 	p_apl_attribute21               in varchar2,
506 	p_apl_attribute22               in varchar2,
507 	p_apl_attribute23               in varchar2,
508 	p_apl_attribute24               in varchar2,
509 	p_apl_attribute25               in varchar2,
510 	p_apl_attribute26               in varchar2,
511 	p_apl_attribute27               in varchar2,
512 	p_apl_attribute28               in varchar2,
513 	p_apl_attribute29               in varchar2,
514 	p_apl_attribute30               in varchar2,
515 	p_object_version_number         in number
516 	)
517 	Return g_rec_type is
518 --
519   l_rec	  g_rec_type;
520   l_proc  varchar2(72) := g_package||'convert_args';
521 --
522 Begin
523   --
524   hr_utility.set_location('Entering:'||l_proc, 5);
525   --
526   -- Convert arguments into local l_rec structure.
527   --
528   l_rec.acty_rt_ptd_lmt_id               := p_acty_rt_ptd_lmt_id;
529   l_rec.effective_start_date             := p_effective_start_date;
530   l_rec.effective_end_date               := p_effective_end_date;
531   l_rec.acty_base_rt_id                  := p_acty_base_rt_id;
532    l_rec.ptd_lmt_id                       := p_ptd_lmt_id;
533   l_rec.business_group_id                := p_business_group_id;
534   l_rec.apl_attribute_category           := p_apl_attribute_category;
535   l_rec.apl_attribute1                   := p_apl_attribute1;
536   l_rec.apl_attribute2                   := p_apl_attribute2;
537   l_rec.apl_attribute3                   := p_apl_attribute3;
538   l_rec.apl_attribute4                   := p_apl_attribute4;
539   l_rec.apl_attribute5                   := p_apl_attribute5;
540   l_rec.apl_attribute6                   := p_apl_attribute6;
541   l_rec.apl_attribute7                   := p_apl_attribute7;
542   l_rec.apl_attribute8                   := p_apl_attribute8;
543   l_rec.apl_attribute9                   := p_apl_attribute9;
544   l_rec.apl_attribute10                  := p_apl_attribute10;
545   l_rec.apl_attribute11                  := p_apl_attribute11;
546   l_rec.apl_attribute12                  := p_apl_attribute12;
547   l_rec.apl_attribute13                  := p_apl_attribute13;
548   l_rec.apl_attribute14                  := p_apl_attribute14;
549   l_rec.apl_attribute15                  := p_apl_attribute15;
550   l_rec.apl_attribute16                  := p_apl_attribute16;
551   l_rec.apl_attribute17                  := p_apl_attribute17;
552   l_rec.apl_attribute18                  := p_apl_attribute18;
553   l_rec.apl_attribute19                  := p_apl_attribute19;
554   l_rec.apl_attribute20                  := p_apl_attribute20;
555   l_rec.apl_attribute21                  := p_apl_attribute21;
556   l_rec.apl_attribute22                  := p_apl_attribute22;
557   l_rec.apl_attribute23                  := p_apl_attribute23;
558   l_rec.apl_attribute24                  := p_apl_attribute24;
559   l_rec.apl_attribute25                  := p_apl_attribute25;
560   l_rec.apl_attribute26                  := p_apl_attribute26;
561   l_rec.apl_attribute27                  := p_apl_attribute27;
562   l_rec.apl_attribute28                  := p_apl_attribute28;
563   l_rec.apl_attribute29                  := p_apl_attribute29;
564   l_rec.apl_attribute30                  := p_apl_attribute30;
565   l_rec.object_version_number            := p_object_version_number;
566   --
567   -- Return the plsql record structure.
568   --
569   hr_utility.set_location(' Leaving:'||l_proc, 10);
570   Return(l_rec);
571 --
572 End convert_args;
573 --
574 end ben_apl_shd;