DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PBB_SHD

Source


1 Package Body ben_pbb_shd as
2 /* $Header: bepbbrhi.pkb 115.14 2004/02/03 10:38:48 pbodla ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pbb_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_PER_BNFTS_BAL_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_per_bnfts_bal_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 	per_bnfts_bal_id,
66 	effective_start_date,
67 	effective_end_date,
68 	val,
69 	bnfts_bal_id,
70 	person_id,
71 	business_group_id,
72 	pbb_attribute_category,
73 	pbb_attribute1,
74 	pbb_attribute2,
75 	pbb_attribute3,
76 	pbb_attribute4,
77 	pbb_attribute5,
78 	pbb_attribute6,
79 	pbb_attribute7,
80 	pbb_attribute8,
81 	pbb_attribute9,
82 	pbb_attribute10,
83 	pbb_attribute11,
84 	pbb_attribute12,
85 	pbb_attribute13,
86 	pbb_attribute14,
87 	pbb_attribute15,
88 	pbb_attribute16,
89 	pbb_attribute17,
90 	pbb_attribute18,
91 	pbb_attribute19,
92 	pbb_attribute20,
93 	pbb_attribute21,
94 	pbb_attribute22,
95 	pbb_attribute23,
96 	pbb_attribute24,
97 	pbb_attribute25,
98 	pbb_attribute26,
99 	pbb_attribute27,
100 	pbb_attribute28,
101 	pbb_attribute29,
102 	pbb_attribute30,
103 	object_version_number
104     from	ben_per_bnfts_bal_f
105     where	per_bnfts_bal_id = p_per_bnfts_bal_id
106     and		p_effective_date
107     between	effective_start_date and effective_end_date;
108 --
109   l_proc	varchar2(72)	:= g_package||'api_updating';
110   l_fct_ret	boolean;
111 --
112 Begin
113   hr_utility.set_location('Entering:'||l_proc, 5);
114   --
115   If (p_effective_date is null or
116       p_per_bnfts_bal_id is null or
117       p_object_version_number is null) Then
118     --
119     -- One of the primary key arguments is null therefore we must
120     -- set the returning function value to false
121     --
122     l_fct_ret := false;
123   Else
124     If (p_per_bnfts_bal_id = g_old_rec.per_bnfts_bal_id and
125         p_object_version_number = g_old_rec.object_version_number) Then
126       hr_utility.set_location(l_proc, 10);
127       --
128       -- The g_old_rec is current therefore we must
129       -- set the returning function to true
130       --
131       l_fct_ret := true;
132     Else
133       --
134       -- Select the current row
135       --
136       Open C_Sel1;
137       Fetch C_Sel1 Into g_old_rec;
138       If C_Sel1%notfound Then
139         Close C_Sel1;
140         --
141         -- The primary key is invalid therefore we must error
142         --
143         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
144         fnd_message.raise_error;
145       End If;
146       Close C_Sel1;
147       If (p_object_version_number <> g_old_rec.object_version_number) Then
148         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
149         fnd_message.raise_error;
150       End If;
151       hr_utility.set_location(l_proc, 15);
152       l_fct_ret := true;
153     End If;
154   End If;
155   hr_utility.set_location(' Leaving:'||l_proc, 20);
156   Return (l_fct_ret);
157 --
158 End api_updating;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |--------------------------< find_dt_del_modes >---------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure find_dt_del_modes
164 	(p_effective_date	in  date,
165 	 p_base_key_value	in  number,
166 	 p_zap		 out nocopy boolean,
167 	 p_delete	 out nocopy boolean,
168 	 p_future_change out nocopy boolean,
169 	 p_delete_next_change out nocopy boolean) is
170 --
171   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
172 --
173   l_parent_key_value1	number;
174   --
175   Cursor C_Sel1 Is
176     select  t.bnfts_bal_id
177     from    ben_per_bnfts_bal_f t
178     where   t.per_bnfts_bal_id = p_base_key_value
179     and     p_effective_date
180     between t.effective_start_date and t.effective_end_date;
181 --
182 Begin
183   hr_utility.set_location('Entering:'||l_proc, 5);
184   Open  C_Sel1;
185   Fetch C_Sel1 Into l_parent_key_value1;
186   If C_Sel1%notfound then
187     Close C_Sel1;
188     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
189     fnd_message.set_token('PROCEDURE', l_proc);
190     fnd_message.set_token('STEP','10');
191     fnd_message.raise_error;
192   End If;
193   Close C_Sel1;
194   --
195   -- Call the corresponding datetrack api
196   --
197   dt_api.find_dt_del_modes
198 	(p_effective_date	=> p_effective_date,
199 	 p_base_table_name	=> 'ben_per_bnfts_bal_f',
200 	 p_base_key_column	=> 'per_bnfts_bal_id',
201 	 p_base_key_value	=> p_base_key_value,
202 	 p_parent_table_name1	=> 'ben_bnfts_bal_f',
203 	 p_parent_key_column1	=> 'bnfts_bal_id',
204 	 p_parent_key_value1	=> l_parent_key_value1,
205 	 p_zap			=> p_zap,
206 	 p_delete		=> p_delete,
207 	 p_future_change	=> p_future_change,
208 	 p_delete_next_change	=> p_delete_next_change);
209   --
210   hr_utility.set_location(' Leaving:'||l_proc, 10);
211 End find_dt_del_modes;
212 --
213 -- ----------------------------------------------------------------------------
214 -- |--------------------------< find_dt_upd_modes >---------------------------|
215 -- ----------------------------------------------------------------------------
216 Procedure find_dt_upd_modes
217 	(p_effective_date	in  date,
218 	 p_base_key_value	in  number,
219 	 p_correction	 out nocopy boolean,
220 	 p_update	 out nocopy boolean,
221 	 p_update_override out nocopy boolean,
222 	 p_update_change_insert out nocopy boolean) is
223 --
224   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
225 --
226 Begin
227   hr_utility.set_location('Entering:'||l_proc, 5);
228   --
229   -- Call the corresponding datetrack api
230   --
231   dt_api.find_dt_upd_modes
232 	(p_effective_date	=> p_effective_date,
233 	 p_base_table_name	=> 'ben_per_bnfts_bal_f',
234 	 p_base_key_column	=> 'per_bnfts_bal_id',
235 	 p_base_key_value	=> p_base_key_value,
236 	 p_correction		=> p_correction,
237 	 p_update		=> p_update,
238 	 p_update_override	=> p_update_override,
239 	 p_update_change_insert	=> p_update_change_insert);
240   --
241   hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End find_dt_upd_modes;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |------------------------< upd_effective_end_date >------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure upd_effective_end_date
248 	(p_effective_date		in date,
249 	 p_base_key_value		in number,
250 	 p_new_effective_end_date	in date,
251 	 p_validation_start_date	in date,
252 	 p_validation_end_date		in date,
253          p_object_version_number       out nocopy number) is
254 --
255   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
256   l_object_version_number number;
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- Because we are updating a row we must get the next object
262   -- version number.
263   --
264   l_object_version_number :=
265     dt_api.get_object_version_number
266 	(p_base_table_name	=> 'ben_per_bnfts_bal_f',
267 	 p_base_key_column	=> 'per_bnfts_bal_id',
268 	 p_base_key_value	=> p_base_key_value);
269   --
270   hr_utility.set_location(l_proc, 10);
271   g_api_dml := true;  -- Set the api dml status
272   --
273   -- Update the specified datetrack row setting the effective
274   -- end date to the specified new effective end date.
275   --
276   update  ben_per_bnfts_bal_f t
277   set	  t.effective_end_date	  = p_new_effective_end_date,
278 	  t.object_version_number = l_object_version_number
279   where	  t.per_bnfts_bal_id	  = p_base_key_value
280   and	  p_effective_date
281   between t.effective_start_date and t.effective_end_date;
282   --
283   g_api_dml := false;   -- Unset the api dml status
284   p_object_version_number := l_object_version_number;
285   hr_utility.set_location(' Leaving:'||l_proc, 15);
286 --
287 Exception
288   When Others Then
289     g_api_dml := false;   -- Unset the api dml status
290     Raise;
291 End upd_effective_end_date;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |---------------------------------< lck >----------------------------------|
295 -- ----------------------------------------------------------------------------
296 Procedure lck
297 	(p_effective_date	 in  date,
298 	 p_datetrack_mode	 in  varchar2,
299 	 p_per_bnfts_bal_id	 in  number,
300 	 p_object_version_number in  number,
301 	 p_validation_start_date out nocopy date,
302 	 p_validation_end_date	 out nocopy date) is
303 --
304   l_proc		  varchar2(72) := g_package||'lck';
305   l_validation_start_date date;
306   l_validation_end_date	  date;
307   l_object_invalid 	  exception;
308   l_argument		  varchar2(30);
309   --
310   -- Cursor C_Sel1 selects the current locked row as of session date
311   -- ensuring that the object version numbers match.
312   --
313   Cursor C_Sel1 is
314     select
315 	per_bnfts_bal_id,
316 	effective_start_date,
317 	effective_end_date,
318 	val,
319 	bnfts_bal_id,
320 	person_id,
321 	business_group_id,
322 	pbb_attribute_category,
323 	pbb_attribute1,
324 	pbb_attribute2,
325 	pbb_attribute3,
326 	pbb_attribute4,
327 	pbb_attribute5,
328 	pbb_attribute6,
329 	pbb_attribute7,
330 	pbb_attribute8,
331 	pbb_attribute9,
332 	pbb_attribute10,
333 	pbb_attribute11,
334 	pbb_attribute12,
335 	pbb_attribute13,
336 	pbb_attribute14,
337 	pbb_attribute15,
338 	pbb_attribute16,
339 	pbb_attribute17,
340 	pbb_attribute18,
341 	pbb_attribute19,
342 	pbb_attribute20,
343 	pbb_attribute21,
344 	pbb_attribute22,
345 	pbb_attribute23,
346 	pbb_attribute24,
347 	pbb_attribute25,
348 	pbb_attribute26,
349 	pbb_attribute27,
350 	pbb_attribute28,
351 	pbb_attribute29,
352 	pbb_attribute30,
353 	object_version_number
354     from    ben_per_bnfts_bal_f
355     where   per_bnfts_bal_id         = p_per_bnfts_bal_id
356     and	    p_effective_date
357     between effective_start_date and effective_end_date
358     for update nowait;
359   --
360   --
361   --
362 Begin
363   hr_utility.set_location('Entering:'||l_proc, 5);
364   --
365   -- Ensure that all the mandatory arguments are not null
366   --
367   hr_api.mandatory_arg_error(p_api_name       => l_proc,
368                              p_argument       => 'effective_date',
369                              p_argument_value => p_effective_date);
370   --
371   hr_api.mandatory_arg_error(p_api_name       => l_proc,
372                              p_argument       => 'datetrack_mode',
373                              p_argument_value => p_datetrack_mode);
374   --
375   hr_api.mandatory_arg_error(p_api_name       => l_proc,
376                              p_argument       => 'per_bnfts_bal_id',
377                              p_argument_value => p_per_bnfts_bal_id);
378   --
379   hr_api.mandatory_arg_error(p_api_name       => l_proc,
380                              p_argument       => 'object_version_number',
381                              p_argument_value => p_object_version_number);
382   --
383   -- Check to ensure the datetrack mode is not INSERT.
384   --
385   If (p_datetrack_mode <> 'INSERT') then
386     --
387     -- We must select and lock the current row.
388     --
389     Open  C_Sel1;
390     Fetch C_Sel1 Into g_old_rec;
391     If C_Sel1%notfound then
392       Close C_Sel1;
393       --
394       -- The primary key is invalid therefore we must error
395       --
396       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
397       fnd_message.raise_error;
398     End If;
399     Close C_Sel1;
400     If (p_object_version_number <> g_old_rec.object_version_number) Then
404     hr_utility.set_location(l_proc, 15);
401         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
402         fnd_message.raise_error;
403       End If;
405     --
406     --
407     -- Validate the datetrack mode mode getting the validation start
408     -- and end dates for the specified datetrack operation.
409     --
410     dt_api.validate_dt_mode
411 	(p_effective_date	   => p_effective_date,
412 	 p_datetrack_mode	   => p_datetrack_mode,
413 	 p_base_table_name	   => 'ben_per_bnfts_bal_f',
414 	 p_base_key_column	   => 'per_bnfts_bal_id',
415 	 p_base_key_value 	   => p_per_bnfts_bal_id,
416 	 p_parent_table_name1      => 'ben_bnfts_bal_f',
417 	 p_parent_key_column1      => 'bnfts_bal_id',
418 	 p_parent_key_value1       => g_old_rec.bnfts_bal_id,
419          p_enforce_foreign_locking => ben_person_bnfts_bal_api.g_lock_row,
420 	 p_validation_start_date   => l_validation_start_date,
421  	 p_validation_end_date	   => l_validation_end_date);
422   Else
423     --
424     -- We are doing a datetrack 'INSERT' which is illegal within this
425     -- procedure therefore we must error (note: to lck on insert the
426     -- private procedure ins_lck should be called).
427     --
428     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
429     fnd_message.set_token('PROCEDURE', l_proc);
430     fnd_message.set_token('STEP','20');
431     fnd_message.raise_error;
432   End If;
433   --
434   -- Set the validation start and end date OUT arguments
435   --
436   p_validation_start_date := l_validation_start_date;
437   p_validation_end_date   := l_validation_end_date;
438   --
439   hr_utility.set_location(' Leaving:'||l_proc, 30);
440 --
441 -- We need to trap the ORA LOCK exception
442 --
443 Exception
444   When HR_Api.Object_Locked then
445     --
446     -- The object is locked therefore we need to supply a meaningful
447     -- error message.
448     --
449     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
450     fnd_message.set_token('TABLE_NAME', 'ben_per_bnfts_bal_f');
451     fnd_message.raise_error;
452   When l_object_invalid then
453     --
454     -- The object doesn't exist or is invalid
455     --
456     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
457     fnd_message.set_token('TABLE_NAME', 'ben_per_bnfts_bal_f');
458     fnd_message.raise_error;
459 End lck;
460 --
461 -- ----------------------------------------------------------------------------
462 -- |-----------------------------< convert_args >-----------------------------|
463 -- ----------------------------------------------------------------------------
464 Function convert_args
465 	(
466 	p_per_bnfts_bal_id              in number,
467 	p_effective_start_date          in date,
468 	p_effective_end_date            in date,
469 	p_val                           in number,
470 	p_bnfts_bal_id                  in number,
471 	p_person_id                     in number,
472 	p_business_group_id             in number,
473 	p_pbb_attribute_category        in varchar2,
474 	p_pbb_attribute1                in varchar2,
475 	p_pbb_attribute2                in varchar2,
476 	p_pbb_attribute3                in varchar2,
477 	p_pbb_attribute4                in varchar2,
478 	p_pbb_attribute5                in varchar2,
479 	p_pbb_attribute6                in varchar2,
480 	p_pbb_attribute7                in varchar2,
481 	p_pbb_attribute8                in varchar2,
482 	p_pbb_attribute9                in varchar2,
483 	p_pbb_attribute10               in varchar2,
484 	p_pbb_attribute11               in varchar2,
485 	p_pbb_attribute12               in varchar2,
486 	p_pbb_attribute13               in varchar2,
487 	p_pbb_attribute14               in varchar2,
488 	p_pbb_attribute15               in varchar2,
489 	p_pbb_attribute16               in varchar2,
490 	p_pbb_attribute17               in varchar2,
491 	p_pbb_attribute18               in varchar2,
492 	p_pbb_attribute19               in varchar2,
493 	p_pbb_attribute20               in varchar2,
494 	p_pbb_attribute21               in varchar2,
495 	p_pbb_attribute22               in varchar2,
496 	p_pbb_attribute23               in varchar2,
497 	p_pbb_attribute24               in varchar2,
498 	p_pbb_attribute25               in varchar2,
499 	p_pbb_attribute26               in varchar2,
500 	p_pbb_attribute27               in varchar2,
501 	p_pbb_attribute28               in varchar2,
502 	p_pbb_attribute29               in varchar2,
503 	p_pbb_attribute30               in varchar2,
504 	p_object_version_number         in number
505 	)
506 	Return g_rec_type is
507 --
508   l_rec	  g_rec_type;
509   l_proc  varchar2(72) := g_package||'convert_args';
510 --
511 Begin
512   --
513   hr_utility.set_location('Entering:'||l_proc, 5);
514   --
515   -- Convert arguments into local l_rec structure.
516   --
517   l_rec.per_bnfts_bal_id                 := p_per_bnfts_bal_id;
518   l_rec.effective_start_date             := p_effective_start_date;
519   l_rec.effective_end_date               := p_effective_end_date;
520   l_rec.val                              := p_val;
521   l_rec.bnfts_bal_id                     := p_bnfts_bal_id;
522   l_rec.person_id                        := p_person_id;
523   l_rec.business_group_id                := p_business_group_id;
524   l_rec.pbb_attribute_category           := p_pbb_attribute_category;
525   l_rec.pbb_attribute1                   := p_pbb_attribute1;
529   l_rec.pbb_attribute5                   := p_pbb_attribute5;
526   l_rec.pbb_attribute2                   := p_pbb_attribute2;
527   l_rec.pbb_attribute3                   := p_pbb_attribute3;
528   l_rec.pbb_attribute4                   := p_pbb_attribute4;
530   l_rec.pbb_attribute6                   := p_pbb_attribute6;
531   l_rec.pbb_attribute7                   := p_pbb_attribute7;
532   l_rec.pbb_attribute8                   := p_pbb_attribute8;
533   l_rec.pbb_attribute9                   := p_pbb_attribute9;
534   l_rec.pbb_attribute10                  := p_pbb_attribute10;
535   l_rec.pbb_attribute11                  := p_pbb_attribute11;
536   l_rec.pbb_attribute12                  := p_pbb_attribute12;
537   l_rec.pbb_attribute13                  := p_pbb_attribute13;
538   l_rec.pbb_attribute14                  := p_pbb_attribute14;
539   l_rec.pbb_attribute15                  := p_pbb_attribute15;
540   l_rec.pbb_attribute16                  := p_pbb_attribute16;
541   l_rec.pbb_attribute17                  := p_pbb_attribute17;
542   l_rec.pbb_attribute18                  := p_pbb_attribute18;
543   l_rec.pbb_attribute19                  := p_pbb_attribute19;
544   l_rec.pbb_attribute20                  := p_pbb_attribute20;
545   l_rec.pbb_attribute21                  := p_pbb_attribute21;
546   l_rec.pbb_attribute22                  := p_pbb_attribute22;
547   l_rec.pbb_attribute23                  := p_pbb_attribute23;
548   l_rec.pbb_attribute24                  := p_pbb_attribute24;
549   l_rec.pbb_attribute25                  := p_pbb_attribute25;
550   l_rec.pbb_attribute26                  := p_pbb_attribute26;
551   l_rec.pbb_attribute27                  := p_pbb_attribute27;
552   l_rec.pbb_attribute28                  := p_pbb_attribute28;
553   l_rec.pbb_attribute29                  := p_pbb_attribute29;
554   l_rec.pbb_attribute30                  := p_pbb_attribute30;
555   l_rec.object_version_number            := p_object_version_number;
556   --
557   -- Return the plsql record structure.
558   --
559   hr_utility.set_location(' Leaving:'||l_proc, 10);
560   Return(l_rec);
561 --
562 End convert_args;
563 --
564 end ben_pbb_shd;