DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ABC_SHD

Source


1 Package Body ben_abc_shd as
2 /* $Header: beabcrhi.pkb 120.0.12010000.2 2008/08/05 13:53:10 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_abc_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_base_rt_ctfn_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   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_acty_base_rt_ctfn_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 	acty_base_rt_ctfn_id,
66 	effective_start_date,
67 	effective_end_date,
68 	enrt_ctfn_typ_cd,
69 	ctfn_rqd_when_rl,
70 	rqd_flag,
71 	acty_base_rt_id,
72 	business_group_id,
73 	abc_attribute_category,
74 	abc_attribute1,
75 	abc_attribute2,
76 	abc_attribute3,
77 	abc_attribute4,
78 	abc_attribute5,
79 	abc_attribute6,
80 	abc_attribute7,
81 	abc_attribute8,
82 	abc_attribute9,
83 	abc_attribute10,
84 	abc_attribute11,
85 	abc_attribute12,
86 	abc_attribute13,
87 	abc_attribute14,
88 	abc_attribute15,
89 	abc_attribute16,
90 	abc_attribute17,
91 	abc_attribute18,
92 	abc_attribute19,
93 	abc_attribute20,
94 	abc_attribute21,
95 	abc_attribute22,
96 	abc_attribute23,
97 	abc_attribute24,
98 	abc_attribute25,
99 	abc_attribute26,
100 	abc_attribute27,
101 	abc_attribute28,
102 	abc_attribute29,
103 	abc_attribute30,
104 	object_version_number
105     from	ben_acty_base_rt_ctfn_f
106     where	acty_base_rt_ctfn_id = p_acty_base_rt_ctfn_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_acty_base_rt_ctfn_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_acty_base_rt_ctfn_id = g_old_rec.acty_base_rt_ctfn_id and
126         p_object_version_number = g_old_rec.object_version_number) Then
127       --
128       hr_utility.set_location(l_proc, 10);
129       --
130       -- The g_old_rec is current therefore we must
131       -- set the returning function to true
132       --
133       l_fct_ret := true;
134     Else
135       --
136       -- Select the current row
137       --
138       Open C_Sel1;
139       Fetch C_Sel1 Into g_old_rec;
140       If C_Sel1%notfound Then
141         Close C_Sel1;
142         --
143         -- The primary key is invalid therefore we must error
144         --
145         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
146         fnd_message.raise_error;
147       End If;
148       Close C_Sel1;
149       If (p_object_version_number <> g_old_rec.object_version_number) Then
150         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
151         fnd_message.raise_error;
152       End If;
153       hr_utility.set_location(l_proc, 15);
154       l_fct_ret := true;
155     End If;
156   End If;
157   hr_utility.set_location(' Leaving:'||l_proc, 20);
158   Return (l_fct_ret);
159 --
160 End api_updating;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |--------------------------< find_dt_del_modes >---------------------------|
164 -- ----------------------------------------------------------------------------
165 Procedure find_dt_del_modes
166 	(p_effective_date	in  date,
167 	 p_base_key_value	in  number,
168 	 p_zap		 out nocopy boolean,
169 	 p_delete	 out nocopy boolean,
170 	 p_future_change out nocopy boolean,
171 	 p_delete_next_change out nocopy boolean) is
172 --
173   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
174 --
175   l_parent_key_value1	number;
176   l_parent_key_value2   number;
177   --
178   Cursor C_Sel1 Is
179     select  t.acty_base_rt_id
180     from    ben_acty_base_rt_ctfn_f t
181     where   t.acty_base_rt_ctfn_id = p_base_key_value
182     and     p_effective_date
183     between t.effective_start_date and t.effective_end_date;
184 --
185 Begin
186   hr_utility.set_location('Entering:'||l_proc, 5);
187   Open  C_Sel1;
188   Fetch C_Sel1 Into l_parent_key_value1 ;
189   If C_Sel1%notfound then
190     Close C_Sel1;
191     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
192     fnd_message.set_token('PROCEDURE', l_proc);
193     fnd_message.set_token('STEP','10');
194     fnd_message.raise_error;
195   End If;
196   Close C_Sel1;
197   --
198   -- Call the corresponding datetrack api
199   --
200   dt_api.find_dt_del_modes
201 	(p_effective_date	=> p_effective_date,
202 	 p_base_table_name	=> 'ben_acty_base_rt_ctfn_f',
203 	 p_base_key_column	=> 'acty_base_rt_ctfn_id',
204 	 p_base_key_value	=> p_base_key_value,
205 	 p_parent_table_name1	=> 'ben_acty_base_rt_f',
206 	 p_parent_key_column1	=> 'acty_base_rt_id',
207 	 p_parent_key_value1	=> l_parent_key_value1,
208 	 p_zap			=> p_zap,
209 	 p_delete		=> p_delete,
210 	 p_future_change	=> p_future_change,
211 	 p_delete_next_change	=> p_delete_next_change);
212   --
213   hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End find_dt_del_modes;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< find_dt_upd_modes >---------------------------|
218 -- ----------------------------------------------------------------------------
219 Procedure find_dt_upd_modes
220 	(p_effective_date	in  date,
221 	 p_base_key_value	in  number,
222 	 p_correction	 out nocopy boolean,
223 	 p_update	 out nocopy boolean,
224 	 p_update_override out nocopy boolean,
225 	 p_update_change_insert out nocopy boolean) is
226 --
227   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
228 --
229 Begin
230   hr_utility.set_location('Entering:'||l_proc, 5);
231   --
232   -- Call the corresponding datetrack api
233   --
234   dt_api.find_dt_upd_modes
235 	(p_effective_date	=> p_effective_date,
236 	 p_base_table_name	=> 'ben_acty_base_rt_ctfn_f',
237 	 p_base_key_column	=> 'acty_base_rt_ctfn_id',
238 	 p_base_key_value	=> p_base_key_value,
239 	 p_correction		=> p_correction,
240 	 p_update		=> p_update,
241 	 p_update_override	=> p_update_override,
242 	 p_update_change_insert	=> p_update_change_insert);
243   --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End find_dt_upd_modes;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |------------------------< upd_effective_end_date >------------------------|
249 -- ----------------------------------------------------------------------------
250 Procedure upd_effective_end_date
251 	(p_effective_date		in date,
252 	 p_base_key_value		in number,
253 	 p_new_effective_end_date	in date,
254 	 p_validation_start_date	in date,
255 	 p_validation_end_date		in date,
256          p_object_version_number       out nocopy number) is
257 --
258   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
259   l_object_version_number number;
260 --
261 Begin
262   hr_utility.set_location('Entering:'||l_proc, 5);
263   --
264   -- Because we are updating a row we must get the next object
265   -- version number.
266   --
267   l_object_version_number :=
268     dt_api.get_object_version_number
269 	(p_base_table_name	=> 'ben_acty_base_rt_ctfn_f',
270 	 p_base_key_column	=> 'acty_base_rt_ctfn_id',
271 	 p_base_key_value	=> p_base_key_value);
272   --
273   hr_utility.set_location(l_proc, 10);
274   g_api_dml := true;  -- Set the api dml status
275   --
276   -- Update the specified datetrack row setting the effective
277   -- end date to the specified new effective end date.
278   --
279   update  ben_acty_base_rt_ctfn_f t
280   set	  t.effective_end_date	  = p_new_effective_end_date,
281 	  t.object_version_number = l_object_version_number
282   where	  t.acty_base_rt_ctfn_id	  = p_base_key_value
283   and	  p_effective_date
284   between t.effective_start_date and t.effective_end_date;
285   --
286   g_api_dml := false;   -- Unset the api dml status
287   p_object_version_number := l_object_version_number;
288   hr_utility.set_location(' Leaving:'||l_proc, 15);
289 --
290 Exception
291   When Others Then
292     g_api_dml := false;   -- Unset the api dml status
293     Raise;
294 End upd_effective_end_date;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------------< lck >----------------------------------|
298 -- ----------------------------------------------------------------------------
299 Procedure lck
300 	(p_effective_date	 in  date,
301 	 p_datetrack_mode	 in  varchar2,
302 	 p_acty_base_rt_ctfn_id	 in  number,
303 	 p_object_version_number in  number,
304 	 p_validation_start_date out nocopy date,
305 	 p_validation_end_date	 out nocopy date) is
306 --
307   l_proc		  varchar2(72) := g_package||'lck';
308   l_validation_start_date date;
309   l_validation_end_date	  date;
310   l_object_invalid 	  exception;
311   l_argument		  varchar2(30);
312   --
313   -- Cursor C_Sel1 selects the current locked row as of session date
314   -- ensuring that the object version numbers match.
315   --
316   Cursor C_Sel1 is
317     select
318 	acty_base_rt_ctfn_id,
319 	effective_start_date,
320 	effective_end_date,
321 	enrt_ctfn_typ_cd,
322 	ctfn_rqd_when_rl,
323 	rqd_flag,
324 	acty_base_rt_id,
325 	business_group_id,
326 	abc_attribute_category,
327 	abc_attribute1,
328 	abc_attribute2,
329 	abc_attribute3,
330 	abc_attribute4,
331 	abc_attribute5,
332 	abc_attribute6,
333 	abc_attribute7,
334 	abc_attribute8,
335 	abc_attribute9,
336 	abc_attribute10,
337 	abc_attribute11,
338 	abc_attribute12,
339 	abc_attribute13,
340 	abc_attribute14,
341 	abc_attribute15,
342 	abc_attribute16,
343 	abc_attribute17,
344 	abc_attribute18,
345 	abc_attribute19,
346 	abc_attribute20,
347 	abc_attribute21,
348 	abc_attribute22,
349 	abc_attribute23,
350 	abc_attribute24,
351 	abc_attribute25,
352 	abc_attribute26,
353 	abc_attribute27,
354 	abc_attribute28,
355 	abc_attribute29,
356 	abc_attribute30,
357 	object_version_number
358     from    ben_acty_base_rt_ctfn_f
359     where   acty_base_rt_ctfn_id         = p_acty_base_rt_ctfn_id
360     and	    p_effective_date
361     between effective_start_date and effective_end_date
362     for update nowait;
363   --
364   --
365   --
366 Begin
367   hr_utility.set_location('Entering:'||l_proc, 5);
368   --
369   -- Ensure that all the mandatory arguments are not null
370   --
371   hr_api.mandatory_arg_error(p_api_name       => l_proc,
372                              p_argument       => 'effective_date',
373                              p_argument_value => p_effective_date);
374   --
375   hr_api.mandatory_arg_error(p_api_name       => l_proc,
376                              p_argument       => 'datetrack_mode',
377                              p_argument_value => p_datetrack_mode);
378   --
379   hr_api.mandatory_arg_error(p_api_name       => l_proc,
380                              p_argument       => 'acty_base_rt_ctfn_id',
381                              p_argument_value => p_acty_base_rt_ctfn_id);
382   --
383   hr_api.mandatory_arg_error(p_api_name       => l_proc,
384                              p_argument       => 'object_version_number',
385                              p_argument_value => p_object_version_number);
386   --
387   -- Check to ensure the datetrack mode is not INSERT.
388   --
389   If (p_datetrack_mode <> 'INSERT') then
390     --
391     -- We must select and lock the current row.
392     --
393     Open  C_Sel1;
394     Fetch C_Sel1 Into g_old_rec;
395     If C_Sel1%notfound then
396       Close C_Sel1;
397       --
398       -- The primary key is invalid therefore we must error
399       --
400       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
401       fnd_message.raise_error;
402     End If;
403     Close C_Sel1;
404     If (p_object_version_number <> g_old_rec.object_version_number) Then
405         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
406         fnd_message.raise_error;
407       End If;
408     hr_utility.set_location(l_proc, 15);
409     --
410     --
411     -- Validate the datetrack mode mode getting the validation start
412     -- and end dates for the specified datetrack operation.
413     --
414     dt_api.validate_dt_mode
415 	(p_effective_date	   => p_effective_date,
416 	 p_datetrack_mode	   => p_datetrack_mode,
417 	 p_base_table_name	   => 'ben_acty_base_rt_ctfn_f',
418 	 p_base_key_column	   => 'acty_base_rt_ctfn_id',
419 	 p_base_key_value 	   => p_acty_base_rt_ctfn_id,
420 	 p_parent_table_name1      => 'ben_acty_base_rt_f',
421 	 p_parent_key_column1      => 'acty_base_rt_id',
422 	 p_parent_key_value1       => g_old_rec.acty_base_rt_id,
423          p_enforce_foreign_locking => false , --true,
424 	 p_validation_start_date   => l_validation_start_date,
425  	 p_validation_end_date	   => l_validation_end_date);
426   Else
427     --
428     -- We are doing a datetrack 'INSERT' which is illegal within this
429     -- procedure therefore we must error (note: to lck on insert the
433     fnd_message.set_token('PROCEDURE', l_proc);
430     -- private procedure ins_lck should be called).
431     --
432     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
434     fnd_message.set_token('STEP','20');
435     fnd_message.raise_error;
436   End If;
437   --
438   -- Set the validation start and end date OUT arguments
439   --
440   p_validation_start_date := l_validation_start_date;
441   p_validation_end_date   := l_validation_end_date;
442   --
443   hr_utility.set_location(' Leaving:'||l_proc, 30);
444 --
445 -- We need to trap the ORA LOCK exception
446 --
447 Exception
448   When HR_Api.Object_Locked then
449     --
450     -- The object is locked therefore we need to supply a meaningful
451     -- error message.
452     --
453     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
454     fnd_message.set_token('TABLE_NAME', 'ben_acty_base_rt_ctfn_f');
455     fnd_message.raise_error;
456   When l_object_invalid then
457     --
458     -- The object doesn't exist or is invalid
459     --
460     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
461     fnd_message.set_token('TABLE_NAME', 'ben_acty_base_rt_ctfn_f');
462     fnd_message.raise_error;
463 End lck;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |-----------------------------< convert_args >-----------------------------|
467 -- ----------------------------------------------------------------------------
468 Function convert_args
469 	(
470 	p_acty_base_rt_ctfn_id                  in number,
471 	p_effective_start_date          in date,
472 	p_effective_end_date            in date,
473 	p_enrt_ctfn_typ_cd              in varchar2,
474 	p_ctfn_rqd_when_rl              in number,
475 	p_rqd_flag                      in varchar2,
476 	p_acty_base_rt_id                         in number,
477 	p_business_group_id             in number,
478 	p_abc_attribute_category        in varchar2,
479 	p_abc_attribute1                in varchar2,
480 	p_abc_attribute2                in varchar2,
481 	p_abc_attribute3                in varchar2,
482 	p_abc_attribute4                in varchar2,
483 	p_abc_attribute5                in varchar2,
484 	p_abc_attribute6                in varchar2,
485 	p_abc_attribute7                in varchar2,
486 	p_abc_attribute8                in varchar2,
487 	p_abc_attribute9                in varchar2,
488 	p_abc_attribute10               in varchar2,
489 	p_abc_attribute11               in varchar2,
490 	p_abc_attribute12               in varchar2,
491 	p_abc_attribute13               in varchar2,
492 	p_abc_attribute14               in varchar2,
493 	p_abc_attribute15               in varchar2,
494 	p_abc_attribute16               in varchar2,
495 	p_abc_attribute17               in varchar2,
496 	p_abc_attribute18               in varchar2,
497 	p_abc_attribute19               in varchar2,
498 	p_abc_attribute20               in varchar2,
499 	p_abc_attribute21               in varchar2,
500 	p_abc_attribute22               in varchar2,
501 	p_abc_attribute23               in varchar2,
502 	p_abc_attribute24               in varchar2,
503 	p_abc_attribute25               in varchar2,
504 	p_abc_attribute26               in varchar2,
505 	p_abc_attribute27               in varchar2,
506 	p_abc_attribute28               in varchar2,
507 	p_abc_attribute29               in varchar2,
508 	p_abc_attribute30               in varchar2,
509 	p_object_version_number         in number
510 	)
511 	Return g_rec_type is
512 --
513   l_rec	  g_rec_type;
514   l_proc  varchar2(72) := g_package||'convert_args';
515 --
516 Begin
517   --
518   hr_utility.set_location('Entering:'||l_proc, 5);
519   --
520   -- Convert arguments into local l_rec structure.
521   --
522   l_rec.acty_base_rt_ctfn_id                     := p_acty_base_rt_ctfn_id;
523   l_rec.effective_start_date             := p_effective_start_date;
524   l_rec.effective_end_date               := p_effective_end_date;
525   l_rec.enrt_ctfn_typ_cd                 := p_enrt_ctfn_typ_cd;
526   l_rec.ctfn_rqd_when_rl                 := p_ctfn_rqd_when_rl;
527   l_rec.rqd_flag                         := p_rqd_flag;
528   l_rec.acty_base_rt_id                            := p_acty_base_rt_id;
529   l_rec.business_group_id                := p_business_group_id;
530   l_rec.abc_attribute_category           := p_abc_attribute_category;
531   l_rec.abc_attribute1                   := p_abc_attribute1;
532   l_rec.abc_attribute2                   := p_abc_attribute2;
533   l_rec.abc_attribute3                   := p_abc_attribute3;
534   l_rec.abc_attribute4                   := p_abc_attribute4;
535   l_rec.abc_attribute5                   := p_abc_attribute5;
536   l_rec.abc_attribute6                   := p_abc_attribute6;
537   l_rec.abc_attribute7                   := p_abc_attribute7;
538   l_rec.abc_attribute8                   := p_abc_attribute8;
539   l_rec.abc_attribute9                   := p_abc_attribute9;
540   l_rec.abc_attribute10                  := p_abc_attribute10;
541   l_rec.abc_attribute11                  := p_abc_attribute11;
542   l_rec.abc_attribute12                  := p_abc_attribute12;
543   l_rec.abc_attribute13                  := p_abc_attribute13;
544   l_rec.abc_attribute14                  := p_abc_attribute14;
545   l_rec.abc_attribute15                  := p_abc_attribute15;
546   l_rec.abc_attribute16                  := p_abc_attribute16;
547   l_rec.abc_attribute17                  := p_abc_attribute17;
548   l_rec.abc_attribute18                  := p_abc_attribute18;
549   l_rec.abc_attribute19                  := p_abc_attribute19;
550   l_rec.abc_attribute20                  := p_abc_attribute20;
551   l_rec.abc_attribute21                  := p_abc_attribute21;
552   l_rec.abc_attribute22                  := p_abc_attribute22;
553   l_rec.abc_attribute23                  := p_abc_attribute23;
554   l_rec.abc_attribute24                  := p_abc_attribute24;
555   l_rec.abc_attribute25                  := p_abc_attribute25;
556   l_rec.abc_attribute26                  := p_abc_attribute26;
557   l_rec.abc_attribute27                  := p_abc_attribute27;
558   l_rec.abc_attribute28                  := p_abc_attribute28;
559   l_rec.abc_attribute29                  := p_abc_attribute29;
560   l_rec.abc_attribute30                  := p_abc_attribute30;
561   l_rec.object_version_number            := p_object_version_number;
562   --
563   -- Return the plsql record structure.
564   --
565   hr_utility.set_location(' Leaving:'||l_proc, 10);
566   Return(l_rec);
567 --
568 End convert_args;
569 --
570 end ben_abc_shd;