DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PDL_SHD

Source


1 Package Body ben_pdl_shd as
2 /* $Header: bepdlrhi.pkb 120.0 2005/05/28 10:27:02 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pdl_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_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_PTD_LMT_F_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   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_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 	ptd_lmt_id,
71 	effective_start_date,
72 	effective_end_date,
73 	name,
74 	mx_comp_to_cnsdr,
75 	mx_val,
76 	mx_pct_val,
77 	ptd_lmt_calc_rl,
78 	lmt_det_cd,
79 	comp_lvl_fctr_id,
80 	balance_type_id,
81 	business_group_id,
82 	pdl_attribute_category,
83 	pdl_attribute1,
84 	pdl_attribute2,
85 	pdl_attribute3,
86 	pdl_attribute4,
87 	pdl_attribute5,
88 	pdl_attribute6,
89 	pdl_attribute7,
90 	pdl_attribute8,
91 	pdl_attribute9,
92 	pdl_attribute10,
93 	pdl_attribute11,
94 	pdl_attribute12,
95 	pdl_attribute13,
96 	pdl_attribute14,
97 	pdl_attribute15,
98 	pdl_attribute16,
99 	pdl_attribute17,
100 	pdl_attribute18,
101 	pdl_attribute19,
102 	pdl_attribute20,
103 	pdl_attribute21,
104 	pdl_attribute22,
105 	pdl_attribute23,
106 	pdl_attribute24,
107 	pdl_attribute25,
108 	pdl_attribute26,
109 	pdl_attribute27,
110 	pdl_attribute28,
111 	pdl_attribute29,
112 	pdl_attribute30,
113 	object_version_number
114     from	ben_ptd_lmt_f
115     where	ptd_lmt_id = p_ptd_lmt_id
116     and		p_effective_date
117     between	effective_start_date and effective_end_date;
118 --
119   l_proc	varchar2(72)	:= g_package||'api_updating';
120   l_fct_ret	boolean;
121 --
122 Begin
123   hr_utility.set_location('Entering:'||l_proc, 5);
124   --
125   If (p_effective_date is null or
126       p_ptd_lmt_id is null or
127       p_object_version_number is null) Then
128     --
129     -- One of the primary key arguments is null therefore we must
130     -- set the returning function value to false
131     --
132     l_fct_ret := false;
133   Else
134     If (p_ptd_lmt_id = g_old_rec.ptd_lmt_id and
135         p_object_version_number = g_old_rec.object_version_number) Then
136       hr_utility.set_location(l_proc, 10);
137       --
138       -- The g_old_rec is current therefore we must
139       -- set the returning function to true
140       --
141       l_fct_ret := true;
142     Else
143       --
144       -- Select the current row
145       --
146       Open C_Sel1;
147       Fetch C_Sel1 Into g_old_rec;
148       If C_Sel1%notfound Then
149         Close C_Sel1;
150         --
151         -- The primary key is invalid therefore we must error
152         --
156       Close C_Sel1;
153         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
154         fnd_message.raise_error;
155       End If;
157       If (p_object_version_number <> g_old_rec.object_version_number) Then
158         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
159         fnd_message.raise_error;
160       End If;
161       hr_utility.set_location(l_proc, 15);
162       l_fct_ret := true;
163     End If;
164   End If;
165   hr_utility.set_location(' Leaving:'||l_proc, 20);
166   Return (l_fct_ret);
167 --
168 End api_updating;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |--------------------------< find_dt_del_modes >---------------------------|
172 -- ----------------------------------------------------------------------------
173 Procedure find_dt_del_modes
174 	(p_effective_date	in  date,
175 	 p_base_key_value	in  number,
176 	 p_zap		 out nocopy boolean,
177 	 p_delete	 out nocopy boolean,
178 	 p_future_change out nocopy boolean,
179 	 p_delete_next_change out nocopy boolean) is
180 --
181   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
182 --
183   --
184   --
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188     --
189   --
190   -- Call the corresponding datetrack api
191   --
192   dt_api.find_dt_del_modes
193 	(p_effective_date	=> p_effective_date,
194 	 p_base_table_name	=> 'ben_ptd_lmt_f',
195 	 p_base_key_column	=> 'ptd_lmt_id',
196 	 p_base_key_value	=> p_base_key_value,
197 	 p_zap			=> p_zap,
198 	 p_delete		=> p_delete,
199 	 p_future_change	=> p_future_change,
200 	 p_delete_next_change	=> p_delete_next_change);
201   --
202   hr_utility.set_location(' Leaving:'||l_proc, 10);
203 End find_dt_del_modes;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |--------------------------< find_dt_upd_modes >---------------------------|
207 -- ----------------------------------------------------------------------------
208 Procedure find_dt_upd_modes
209 	(p_effective_date	in  date,
210 	 p_base_key_value	in  number,
211 	 p_correction	 out nocopy boolean,
212 	 p_update	 out nocopy boolean,
213 	 p_update_override out nocopy boolean,
214 	 p_update_change_insert out nocopy boolean) is
215 --
216   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
217 --
218 Begin
219   hr_utility.set_location('Entering:'||l_proc, 5);
220   --
221   -- Call the corresponding datetrack api
222   --
223   dt_api.find_dt_upd_modes
224 	(p_effective_date	=> p_effective_date,
225 	 p_base_table_name	=> 'ben_ptd_lmt_f',
226 	 p_base_key_column	=> 'ptd_lmt_id',
227 	 p_base_key_value	=> p_base_key_value,
228 	 p_correction		=> p_correction,
229 	 p_update		=> p_update,
230 	 p_update_override	=> p_update_override,
231 	 p_update_change_insert	=> p_update_change_insert);
232   --
233   hr_utility.set_location(' Leaving:'||l_proc, 10);
234 End find_dt_upd_modes;
235 --
236 -- ----------------------------------------------------------------------------
237 -- |------------------------< upd_effective_end_date >------------------------|
238 -- ----------------------------------------------------------------------------
239 Procedure upd_effective_end_date
240 	(p_effective_date		in date,
241 	 p_base_key_value		in number,
242 	 p_new_effective_end_date	in date,
243 	 p_validation_start_date	in date,
244 	 p_validation_end_date		in date,
245          p_object_version_number       out nocopy number) is
246 --
247   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
248   l_object_version_number number;
249 --
250 Begin
251   hr_utility.set_location('Entering:'||l_proc, 5);
252   --
253   -- Because we are updating a row we must get the next object
254   -- version number.
255   --
256   l_object_version_number :=
257     dt_api.get_object_version_number
258 	(p_base_table_name	=> 'ben_ptd_lmt_f',
259 	 p_base_key_column	=> 'ptd_lmt_id',
260 	 p_base_key_value	=> p_base_key_value);
261   --
262   hr_utility.set_location(l_proc, 10);
263   g_api_dml := true;  -- Set the api dml status
264   --
265   -- Update the specified datetrack row setting the effective
266   -- end date to the specified new effective end date.
267   --
268   update  ben_ptd_lmt_f t
269   set	  t.effective_end_date	  = p_new_effective_end_date,
270 	  t.object_version_number = l_object_version_number
271   where	  t.ptd_lmt_id	  = p_base_key_value
272   and	  p_effective_date
273   between t.effective_start_date and t.effective_end_date;
274   --
275   g_api_dml := false;   -- Unset the api dml status
276   p_object_version_number := l_object_version_number;
277   hr_utility.set_location(' Leaving:'||l_proc, 15);
278 --
279 Exception
280   When Others Then
281     g_api_dml := false;   -- Unset the api dml status
282     Raise;
283 End upd_effective_end_date;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------------< lck >----------------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure lck
289 	(p_effective_date	 in  date,
290 	 p_datetrack_mode	 in  varchar2,
291 	 p_ptd_lmt_id	 in  number,
292 	 p_object_version_number in  number,
293 	 p_validation_start_date out nocopy date,
294 	 p_validation_end_date	 out nocopy date) is
295 --
296   l_proc		  varchar2(72) := g_package||'lck';
297   l_validation_start_date date;
298   l_validation_end_date	  date;
299   l_object_invalid 	  exception;
300   l_argument		  varchar2(30);
301   --
305   Cursor C_Sel1 is
302   -- Cursor C_Sel1 selects the current locked row as of session date
303   -- ensuring that the object version numbers match.
304   --
306     select
307 	ptd_lmt_id,
308 	effective_start_date,
309 	effective_end_date,
310 	name,
311 	mx_comp_to_cnsdr,
312 	mx_val,
313 	mx_pct_val,
314 	ptd_lmt_calc_rl,
315 	lmt_det_cd,
316 	comp_lvl_fctr_id,
317 	balance_type_id,
318 	business_group_id,
319 	pdl_attribute_category,
320 	pdl_attribute1,
321 	pdl_attribute2,
322 	pdl_attribute3,
323 	pdl_attribute4,
324 	pdl_attribute5,
325 	pdl_attribute6,
326 	pdl_attribute7,
327 	pdl_attribute8,
328 	pdl_attribute9,
329 	pdl_attribute10,
330 	pdl_attribute11,
331 	pdl_attribute12,
332 	pdl_attribute13,
333 	pdl_attribute14,
334 	pdl_attribute15,
335 	pdl_attribute16,
336 	pdl_attribute17,
337 	pdl_attribute18,
338 	pdl_attribute19,
339 	pdl_attribute20,
340 	pdl_attribute21,
341 	pdl_attribute22,
342 	pdl_attribute23,
343 	pdl_attribute24,
344 	pdl_attribute25,
345 	pdl_attribute26,
346 	pdl_attribute27,
347 	pdl_attribute28,
348 	pdl_attribute29,
349 	pdl_attribute30,
350 	object_version_number
351     from    ben_ptd_lmt_f
352     where   ptd_lmt_id         = p_ptd_lmt_id
353     and	    p_effective_date
354     between effective_start_date and effective_end_date
355     for update nowait;
356   --
357   --
358   --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- Ensure that all the mandatory arguments are not null
363   --
364   hr_api.mandatory_arg_error(p_api_name       => l_proc,
365                              p_argument       => 'effective_date',
366                              p_argument_value => p_effective_date);
367   --
368   hr_api.mandatory_arg_error(p_api_name       => l_proc,
369                              p_argument       => 'datetrack_mode',
370                              p_argument_value => p_datetrack_mode);
371   --
372   hr_api.mandatory_arg_error(p_api_name       => l_proc,
373                              p_argument       => 'ptd_lmt_id',
374                              p_argument_value => p_ptd_lmt_id);
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'object_version_number',
378                              p_argument_value => p_object_version_number);
379   --
380   -- Check to ensure the datetrack mode is not INSERT.
381   --
382   If (p_datetrack_mode <> 'INSERT') then
383     --
384     -- We must select and lock the current row.
385     --
386     Open  C_Sel1;
387     Fetch C_Sel1 Into g_old_rec;
388     If C_Sel1%notfound then
389       Close C_Sel1;
390       --
391       -- The primary key is invalid therefore we must error
392       --
393       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
394       fnd_message.raise_error;
395     End If;
396     Close C_Sel1;
397     If (p_object_version_number <> g_old_rec.object_version_number) Then
398         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
399         fnd_message.raise_error;
400       End If;
401     hr_utility.set_location(l_proc, 15);
402     --
403     --
404     -- Validate the datetrack mode mode getting the validation start
405     -- and end dates for the specified datetrack operation.
406     --
407     dt_api.validate_dt_mode
408 	(p_effective_date	   => p_effective_date,
409 	 p_datetrack_mode	   => p_datetrack_mode,
410 	 p_base_table_name	   => 'ben_ptd_lmt_f',
411 	 p_base_key_column	   => 'ptd_lmt_id',
412 	 p_base_key_value 	   => p_ptd_lmt_id,
413 	 p_child_table_name1       => 'ben_acty_rt_ptd_lmt_f',
414 	 p_child_key_column1       => 'acty_rt_ptd_lmt_id',
415          p_enforce_foreign_locking => true,
416 	 p_validation_start_date   => l_validation_start_date,
417  	 p_validation_end_date	   => l_validation_end_date);
418   Else
419     --
420     -- We are doing a datetrack 'INSERT' which is illegal within this
421     -- procedure therefore we must error (note: to lck on insert the
422     -- private procedure ins_lck should be called).
423     --
424     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
425     fnd_message.set_token('PROCEDURE', l_proc);
426     fnd_message.set_token('STEP','20');
427     fnd_message.raise_error;
428   End If;
429   --
430   -- Set the validation start and end date OUT arguments
431   --
432   p_validation_start_date := l_validation_start_date;
433   p_validation_end_date   := l_validation_end_date;
434   --
435   hr_utility.set_location(' Leaving:'||l_proc, 30);
436 --
437 -- We need to trap the ORA LOCK exception
438 --
439 Exception
440   When HR_Api.Object_Locked then
441     --
442     -- The object is locked therefore we need to supply a meaningful
443     -- error message.
444     --
445     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
446     fnd_message.set_token('TABLE_NAME', 'ben_ptd_lmt_f');
447     fnd_message.raise_error;
448   When l_object_invalid then
449     --
450     -- The object doesn't exist or is invalid
451     --
452     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
453     fnd_message.set_token('TABLE_NAME', 'ben_ptd_lmt_f');
454     fnd_message.raise_error;
455 End lck;
456 --
457 -- ----------------------------------------------------------------------------
458 -- |-----------------------------< convert_args >-----------------------------|
459 -- ----------------------------------------------------------------------------
460 Function convert_args
461 	(
462 	p_ptd_lmt_id                    in number,
463 	p_effective_start_date          in date,
464 	p_effective_end_date            in date,
465 	p_name                          in varchar2,
466 	p_mx_comp_to_cnsdr              in number,
467 	p_mx_val                        in number,
468 	p_mx_pct_val                    in number,
469 	p_ptd_lmt_calc_rl               in number,
470 	p_lmt_det_cd                    in varchar2,
471 	p_comp_lvl_fctr_id              in number,
472 	p_balance_type_id               in number,
473 	p_business_group_id             in number,
474 	p_pdl_attribute_category        in varchar2,
475 	p_pdl_attribute1                in varchar2,
476 	p_pdl_attribute2                in varchar2,
477 	p_pdl_attribute3                in varchar2,
478 	p_pdl_attribute4                in varchar2,
479 	p_pdl_attribute5                in varchar2,
480 	p_pdl_attribute6                in varchar2,
481 	p_pdl_attribute7                in varchar2,
482 	p_pdl_attribute8                in varchar2,
483 	p_pdl_attribute9                in varchar2,
484 	p_pdl_attribute10               in varchar2,
485 	p_pdl_attribute11               in varchar2,
486 	p_pdl_attribute12               in varchar2,
487 	p_pdl_attribute13               in varchar2,
488 	p_pdl_attribute14               in varchar2,
489 	p_pdl_attribute15               in varchar2,
490 	p_pdl_attribute16               in varchar2,
491 	p_pdl_attribute17               in varchar2,
492 	p_pdl_attribute18               in varchar2,
493 	p_pdl_attribute19               in varchar2,
494 	p_pdl_attribute20               in varchar2,
495 	p_pdl_attribute21               in varchar2,
496 	p_pdl_attribute22               in varchar2,
497 	p_pdl_attribute23               in varchar2,
498 	p_pdl_attribute24               in varchar2,
499 	p_pdl_attribute25               in varchar2,
500 	p_pdl_attribute26               in varchar2,
501 	p_pdl_attribute27               in varchar2,
502 	p_pdl_attribute28               in varchar2,
503 	p_pdl_attribute29               in varchar2,
504 	p_pdl_attribute30               in varchar2,
505 	p_object_version_number         in number
506 	)
507 	Return g_rec_type is
508 --
509   l_rec	  g_rec_type;
510   l_proc  varchar2(72) := g_package||'convert_args';
511 --
512 Begin
513   --
514   hr_utility.set_location('Entering:'||l_proc, 5);
515   --
516   -- Convert arguments into local l_rec structure.
517   --
518   l_rec.ptd_lmt_id                       := p_ptd_lmt_id;
519   l_rec.effective_start_date             := p_effective_start_date;
520   l_rec.effective_end_date               := p_effective_end_date;
521   l_rec.name                             := p_name;
522   l_rec.mx_comp_to_cnsdr                 := p_mx_comp_to_cnsdr;
523   l_rec.mx_val                           := p_mx_val;
524   l_rec.mx_pct_val                       := p_mx_pct_val;
525   l_rec.ptd_lmt_calc_rl                  := p_ptd_lmt_calc_rl;
526   l_rec.lmt_det_cd                       := p_lmt_det_cd;
527   l_rec.comp_lvl_fctr_id                 := p_comp_lvl_fctr_id;
528   l_rec.balance_type_id                  := p_balance_type_id;
529   l_rec.business_group_id                := p_business_group_id;
530   l_rec.pdl_attribute_category           := p_pdl_attribute_category;
531   l_rec.pdl_attribute1                   := p_pdl_attribute1;
532   l_rec.pdl_attribute2                   := p_pdl_attribute2;
533   l_rec.pdl_attribute3                   := p_pdl_attribute3;
534   l_rec.pdl_attribute4                   := p_pdl_attribute4;
535   l_rec.pdl_attribute5                   := p_pdl_attribute5;
536   l_rec.pdl_attribute6                   := p_pdl_attribute6;
537   l_rec.pdl_attribute7                   := p_pdl_attribute7;
538   l_rec.pdl_attribute8                   := p_pdl_attribute8;
539   l_rec.pdl_attribute9                   := p_pdl_attribute9;
540   l_rec.pdl_attribute10                  := p_pdl_attribute10;
541   l_rec.pdl_attribute11                  := p_pdl_attribute11;
542   l_rec.pdl_attribute12                  := p_pdl_attribute12;
543   l_rec.pdl_attribute13                  := p_pdl_attribute13;
544   l_rec.pdl_attribute14                  := p_pdl_attribute14;
545   l_rec.pdl_attribute15                  := p_pdl_attribute15;
546   l_rec.pdl_attribute16                  := p_pdl_attribute16;
547   l_rec.pdl_attribute17                  := p_pdl_attribute17;
548   l_rec.pdl_attribute18                  := p_pdl_attribute18;
549   l_rec.pdl_attribute19                  := p_pdl_attribute19;
550   l_rec.pdl_attribute20                  := p_pdl_attribute20;
551   l_rec.pdl_attribute21                  := p_pdl_attribute21;
552   l_rec.pdl_attribute22                  := p_pdl_attribute22;
553   l_rec.pdl_attribute23                  := p_pdl_attribute23;
554   l_rec.pdl_attribute24                  := p_pdl_attribute24;
555   l_rec.pdl_attribute25                  := p_pdl_attribute25;
556   l_rec.pdl_attribute26                  := p_pdl_attribute26;
557   l_rec.pdl_attribute27                  := p_pdl_attribute27;
558   l_rec.pdl_attribute28                  := p_pdl_attribute28;
559   l_rec.pdl_attribute29                  := p_pdl_attribute29;
560   l_rec.pdl_attribute30                  := p_pdl_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_pdl_shd;