DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PON_SHD

Source


1 Package Body ben_pon_shd as
2 /* $Header: beponrhi.pkb 120.0 2005/05/28 10:56:29 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pon_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_PL_TYP_OPT_TYP_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_PL_TYP_OPT_TYP_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_pl_typ_opt_typ_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 	pl_typ_opt_typ_id,
71 	effective_start_date,
72 	effective_end_date,
73 	pl_typ_opt_typ_cd,
74 	opt_id,
75 	pl_typ_id,
76 	business_group_id,
77 	legislation_code,
78 	legislation_subgroup,
79 	pon_attribute_category,
80 	pon_attribute1,
81 	pon_attribute2,
82 	pon_attribute3,
83 	pon_attribute4,
84 	pon_attribute5,
85 	pon_attribute6,
86 	pon_attribute7,
87 	pon_attribute8,
88 	pon_attribute9,
89 	pon_attribute10,
90 	pon_attribute11,
91 	pon_attribute12,
92 	pon_attribute13,
93 	pon_attribute14,
94 	pon_attribute15,
95 	pon_attribute16,
96 	pon_attribute17,
97 	pon_attribute18,
98 	pon_attribute19,
99 	pon_attribute20,
100 	pon_attribute21,
101 	pon_attribute22,
102 	pon_attribute23,
103 	pon_attribute24,
104 	pon_attribute25,
105 	pon_attribute26,
106 	pon_attribute27,
107 	pon_attribute28,
108 	pon_attribute29,
109 	pon_attribute30,
110 	object_version_number
111     from	ben_pl_typ_opt_typ_f
112     where	pl_typ_opt_typ_id = p_pl_typ_opt_typ_id
113     and		p_effective_date
114     between	effective_start_date and effective_end_date;
115 --
116   l_proc	varchar2(72)	:= g_package||'api_updating';
117   l_fct_ret	boolean;
118 --
119 Begin
120   hr_utility.set_location('Entering:'||l_proc, 5);
121   --
122   If (p_effective_date is null or
123       p_pl_typ_opt_typ_id is null or
124       p_object_version_number is null) Then
125     --
126     -- One of the primary key arguments is null therefore we must
127     -- set the returning function value to false
128     --
129     l_fct_ret := false;
130   Else
131     If (p_pl_typ_opt_typ_id = g_old_rec.pl_typ_opt_typ_id and
132         p_object_version_number = g_old_rec.object_version_number) Then
133       hr_utility.set_location(l_proc, 10);
134       --
135       -- The g_old_rec is current therefore we must
136       -- set the returning function to true
137       --
138       l_fct_ret := true;
139     Else
140       --
141       -- Select the current row
142       --
143       Open C_Sel1;
144       Fetch C_Sel1 Into g_old_rec;
145       If C_Sel1%notfound Then
146         Close C_Sel1;
147         --
148         -- The primary key is invalid therefore we must error
149         --
150         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
151         fnd_message.raise_error;
152       End If;
153       Close C_Sel1;
154       If (p_object_version_number <> g_old_rec.object_version_number) Then
155         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
156         fnd_message.raise_error;
157       End If;
158       hr_utility.set_location(l_proc, 15);
159       l_fct_ret := true;
160     End If;
161   End If;
162   hr_utility.set_location(' Leaving:'||l_proc, 20);
163   Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |--------------------------< find_dt_del_modes >---------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 	(p_effective_date	in  date,
172 	 p_base_key_value	in  number,
173 	 p_zap		 out nocopy boolean,
174 	 p_delete	 out nocopy boolean,
175 	 p_future_change out nocopy boolean,
176 	 p_delete_next_change out nocopy boolean) is
177 --
178   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
179 --
180   l_parent_key_value1	number;
181   l_parent_key_value2	number;
182   --
183   Cursor C_Sel1 Is
184     select  t.opt_id,
185 	    t.pl_typ_id
186     from    ben_pl_typ_opt_typ_f t
187     where   t.pl_typ_opt_typ_id = p_base_key_value
188     and     p_effective_date
189     between t.effective_start_date and t.effective_end_date;
190 --
191 Begin
192   hr_utility.set_location('Entering:'||l_proc, 5);
193   Open  C_Sel1;
194   Fetch C_Sel1 Into l_parent_key_value1,
195 		    l_parent_key_value2;
196   If C_Sel1%notfound then
197     Close C_Sel1;
198     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
199     fnd_message.set_token('PROCEDURE', l_proc);
200     fnd_message.set_token('STEP','10');
201     fnd_message.raise_error;
202   End If;
203   Close C_Sel1;
204   --
205   -- Call the corresponding datetrack api
206   --
207   dt_api.find_dt_del_modes
208 	(p_effective_date	=> p_effective_date,
209 	 p_base_table_name	=> 'ben_pl_typ_opt_typ_f',
210 	 p_base_key_column	=> 'pl_typ_opt_typ_id',
211 	 p_base_key_value	=> p_base_key_value,
212 	 p_parent_table_name1	=> 'ben_opt_f',
213 	 p_parent_key_column1	=> 'opt_id',
214 	 p_parent_key_value1	=> l_parent_key_value1,
215 	 p_parent_table_name2	=> 'ben_pl_typ_f',
216 	 p_parent_key_column2	=> 'pl_typ_id',
217 	 p_parent_key_value2	=> l_parent_key_value2,
218 	 p_zap			=> p_zap,
219 	 p_delete		=> p_delete,
220 	 p_future_change	=> p_future_change,
221 	 p_delete_next_change	=> p_delete_next_change);
222   --
223   hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End find_dt_del_modes;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |--------------------------< find_dt_upd_modes >---------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure find_dt_upd_modes
230 	(p_effective_date	in  date,
231 	 p_base_key_value	in  number,
232 	 p_correction	 out nocopy boolean,
233 	 p_update	 out nocopy boolean,
234 	 p_update_override out nocopy boolean,
235 	 p_update_change_insert out nocopy boolean) is
236 --
237   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241   --
242   -- Call the corresponding datetrack api
243   --
244   dt_api.find_dt_upd_modes
245 	(p_effective_date	=> p_effective_date,
246 	 p_base_table_name	=> 'ben_pl_typ_opt_typ_f',
247 	 p_base_key_column	=> 'pl_typ_opt_typ_id',
248 	 p_base_key_value	=> p_base_key_value,
249 	 p_correction		=> p_correction,
250 	 p_update		=> p_update,
251 	 p_update_override	=> p_update_override,
252 	 p_update_change_insert	=> p_update_change_insert);
253   --
254   hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End find_dt_upd_modes;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |------------------------< upd_effective_end_date >------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure upd_effective_end_date
261 	(p_effective_date		in date,
262 	 p_base_key_value		in number,
263 	 p_new_effective_end_date	in date,
264 	 p_validation_start_date	in date,
265 	 p_validation_end_date		in date,
266          p_object_version_number       out nocopy number) is
267 --
268   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
269   l_object_version_number number;
270 --
271 Begin
272   hr_utility.set_location('Entering:'||l_proc, 5);
273   --
274   -- Because we are updating a row we must get the next object
275   -- version number.
276   --
277   l_object_version_number :=
278     dt_api.get_object_version_number
279 	(p_base_table_name	=> 'ben_pl_typ_opt_typ_f',
280 	 p_base_key_column	=> 'pl_typ_opt_typ_id',
281 	 p_base_key_value	=> p_base_key_value);
282   --
283   hr_utility.set_location(l_proc, 10);
284   g_api_dml := true;  -- Set the api dml status
285   --
286   -- Update the specified datetrack row setting the effective
287   -- end date to the specified new effective end date.
288   --
289   update  ben_pl_typ_opt_typ_f t
290   set	  t.effective_end_date	  = p_new_effective_end_date,
291 	  t.object_version_number = l_object_version_number
292   where	  t.pl_typ_opt_typ_id	  = p_base_key_value
293   and	  p_effective_date
294   between t.effective_start_date and t.effective_end_date;
295   --
296   g_api_dml := false;   -- Unset the api dml status
297   p_object_version_number := l_object_version_number;
298   hr_utility.set_location(' Leaving:'||l_proc, 15);
299 --
300 Exception
301   When Others Then
302     g_api_dml := false;   -- Unset the api dml status
303     Raise;
304 End upd_effective_end_date;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< lck >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure lck
310 	(p_effective_date	 in  date,
311 	 p_datetrack_mode	 in  varchar2,
312 	 p_pl_typ_opt_typ_id	 in  number,
313 	 p_object_version_number in  number,
314 	 p_validation_start_date out nocopy date,
315 	 p_validation_end_date	 out nocopy date) is
316 --
317   l_proc		  varchar2(72) := g_package||'lck';
318   l_validation_start_date date;
319   l_validation_end_date	  date;
320   l_object_invalid 	  exception;
321   l_argument		  varchar2(30);
322   --
323   -- Cursor C_Sel1 selects the current locked row as of session date
324   -- ensuring that the object version numbers match.
325   --
326   Cursor C_Sel1 is
327     select
328 	pl_typ_opt_typ_id,
329 	effective_start_date,
330 	effective_end_date,
331 	pl_typ_opt_typ_cd,
332 	opt_id,
333 	pl_typ_id,
334 	business_group_id,
335 	legislation_code,
336 	legislation_subgroup,
337 	pon_attribute_category,
338 	pon_attribute1,
339 	pon_attribute2,
340 	pon_attribute3,
341 	pon_attribute4,
342 	pon_attribute5,
343 	pon_attribute6,
344 	pon_attribute7,
345 	pon_attribute8,
346 	pon_attribute9,
347 	pon_attribute10,
348 	pon_attribute11,
349 	pon_attribute12,
350 	pon_attribute13,
351 	pon_attribute14,
352 	pon_attribute15,
353 	pon_attribute16,
354 	pon_attribute17,
355 	pon_attribute18,
356 	pon_attribute19,
357 	pon_attribute20,
358 	pon_attribute21,
359 	pon_attribute22,
360 	pon_attribute23,
361 	pon_attribute24,
362 	pon_attribute25,
363 	pon_attribute26,
364 	pon_attribute27,
365 	pon_attribute28,
366 	pon_attribute29,
367 	pon_attribute30,
368 	object_version_number
369     from    ben_pl_typ_opt_typ_f
370     where   pl_typ_opt_typ_id         = p_pl_typ_opt_typ_id
371     and	    p_effective_date
372     between effective_start_date and effective_end_date
373     for update nowait;
374   --
375   --
376   --
377 Begin
378   hr_utility.set_location('Entering:'||l_proc, 5);
379   --
380   -- Ensure that all the mandatory arguments are not null
381   --
382   hr_api.mandatory_arg_error(p_api_name       => l_proc,
383                              p_argument       => 'effective_date',
384                              p_argument_value => p_effective_date);
385   --
386   hr_api.mandatory_arg_error(p_api_name       => l_proc,
387                              p_argument       => 'datetrack_mode',
388                              p_argument_value => p_datetrack_mode);
389   --
390   hr_api.mandatory_arg_error(p_api_name       => l_proc,
391                              p_argument       => 'pl_typ_opt_typ_id',
392                              p_argument_value => p_pl_typ_opt_typ_id);
393   --
394   hr_api.mandatory_arg_error(p_api_name       => l_proc,
395                              p_argument       => 'object_version_number',
396                              p_argument_value => p_object_version_number);
397   --
398   -- Check to ensure the datetrack mode is not INSERT.
399   --
400   If (p_datetrack_mode <> 'INSERT') then
401     --
402     -- We must select and lock the current row.
403     --
404     Open  C_Sel1;
405     Fetch C_Sel1 Into g_old_rec;
406     If C_Sel1%notfound then
407       Close C_Sel1;
408       --
409       -- The primary key is invalid therefore we must error
410       --
411       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
412       fnd_message.raise_error;
413     End If;
414     Close C_Sel1;
415     If (p_object_version_number <> g_old_rec.object_version_number) Then
416         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
417         fnd_message.raise_error;
418       End If;
419     hr_utility.set_location(l_proc, 15);
420     --
421     --
422     -- Validate the datetrack mode mode getting the validation start
423     -- and end dates for the specified datetrack operation.
424     --
425     dt_api.validate_dt_mode
426 	(p_effective_date	   => p_effective_date,
427 	 p_datetrack_mode	   => p_datetrack_mode,
428 	 p_base_table_name	   => 'ben_pl_typ_opt_typ_f',
429 	 p_base_key_column	   => 'pl_typ_opt_typ_id',
430 	 p_base_key_value 	   => p_pl_typ_opt_typ_id,
431 	 p_parent_table_name1      => 'ben_opt_f',
432 	 p_parent_key_column1      => 'opt_id',
433 	 p_parent_key_value1       => g_old_rec.opt_id,
437 	 p_child_table_name1       => 'ben_vrbl_rt_prfl_f',
434 	 p_parent_table_name2      => 'ben_pl_typ_f',
435 	 p_parent_key_column2      => 'pl_typ_id',
436 	 p_parent_key_value2       => g_old_rec.pl_typ_id,
438 	 p_child_key_column1       => 'vrbl_rt_prfl_id',
439          p_enforce_foreign_locking => false,   -- Bug 1880631
440 	 p_validation_start_date   => l_validation_start_date,
441  	 p_validation_end_date	   => l_validation_end_date);
442   Else
443     --
444     -- We are doing a datetrack 'INSERT' which is illegal within this
445     -- procedure therefore we must error (note: to lck on insert the
446     -- private procedure ins_lck should be called).
447     --
448     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
449     fnd_message.set_token('PROCEDURE', l_proc);
450     fnd_message.set_token('STEP','20');
451     fnd_message.raise_error;
452   End If;
453   --
454   -- Set the validation start and end date OUT arguments
455   --
456   p_validation_start_date := l_validation_start_date;
457   p_validation_end_date   := l_validation_end_date;
458   --
459   hr_utility.set_location(' Leaving:'||l_proc, 30);
460 --
461 -- We need to trap the ORA LOCK exception
462 --
463 Exception
464   When HR_Api.Object_Locked then
465     --
466     -- The object is locked therefore we need to supply a meaningful
467     -- error message.
468     --
469     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
470     fnd_message.set_token('TABLE_NAME', 'ben_pl_typ_opt_typ_f');
471     fnd_message.raise_error;
472   When l_object_invalid then
473     --
474     -- The object doesn't exist or is invalid
475     --
476     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
477     fnd_message.set_token('TABLE_NAME', 'ben_pl_typ_opt_typ_f');
478     fnd_message.raise_error;
479 End lck;
480 --
481 -- ----------------------------------------------------------------------------
482 -- |-----------------------------< convert_args >-----------------------------|
483 -- ----------------------------------------------------------------------------
484 Function convert_args
485 	(
486 	p_pl_typ_opt_typ_id             in number,
487 	p_effective_start_date          in date,
488 	p_effective_end_date            in date,
489 	p_pl_typ_opt_typ_cd             in varchar2,
490 	p_opt_id                        in number,
491 	p_pl_typ_id                     in number,
492 	p_business_group_id             in number,
493 	p_legislation_code        in varchar2,
494 	p_legislation_subgroup        in varchar2,
495 	p_pon_attribute_category        in varchar2,
496 	p_pon_attribute1                in varchar2,
497 	p_pon_attribute2                in varchar2,
498 	p_pon_attribute3                in varchar2,
499 	p_pon_attribute4                in varchar2,
500 	p_pon_attribute5                in varchar2,
501 	p_pon_attribute6                in varchar2,
502 	p_pon_attribute7                in varchar2,
503 	p_pon_attribute8                in varchar2,
504 	p_pon_attribute9                in varchar2,
505 	p_pon_attribute10               in varchar2,
506 	p_pon_attribute11               in varchar2,
507 	p_pon_attribute12               in varchar2,
508 	p_pon_attribute13               in varchar2,
509 	p_pon_attribute14               in varchar2,
510 	p_pon_attribute15               in varchar2,
511 	p_pon_attribute16               in varchar2,
512 	p_pon_attribute17               in varchar2,
513 	p_pon_attribute18               in varchar2,
514 	p_pon_attribute19               in varchar2,
515 	p_pon_attribute20               in varchar2,
516 	p_pon_attribute21               in varchar2,
517 	p_pon_attribute22               in varchar2,
518 	p_pon_attribute23               in varchar2,
519 	p_pon_attribute24               in varchar2,
520 	p_pon_attribute25               in varchar2,
521 	p_pon_attribute26               in varchar2,
522 	p_pon_attribute27               in varchar2,
523 	p_pon_attribute28               in varchar2,
524 	p_pon_attribute29               in varchar2,
525 	p_pon_attribute30               in varchar2,
526 	p_object_version_number         in number
527 	)
528 	Return g_rec_type is
529 --
530   l_rec	  g_rec_type;
531   l_proc  varchar2(72) := g_package||'convert_args';
532 --
533 Begin
534   --
535   hr_utility.set_location('Entering:'||l_proc, 5);
536   --
537   -- Convert arguments into local l_rec structure.
538   --
539   l_rec.pl_typ_opt_typ_id                := p_pl_typ_opt_typ_id;
540   l_rec.effective_start_date             := p_effective_start_date;
541   l_rec.effective_end_date               := p_effective_end_date;
542   l_rec.pl_typ_opt_typ_cd                := p_pl_typ_opt_typ_cd;
543   l_rec.opt_id                           := p_opt_id;
544   l_rec.pl_typ_id                        := p_pl_typ_id;
545   l_rec.business_group_id                := p_business_group_id;
546   l_rec.legislation_code           := p_legislation_code;
547   l_rec.legislation_subgroup           := p_legislation_subgroup;
548   l_rec.pon_attribute_category           := p_pon_attribute_category;
549   l_rec.pon_attribute1                   := p_pon_attribute1;
550   l_rec.pon_attribute2                   := p_pon_attribute2;
551   l_rec.pon_attribute3                   := p_pon_attribute3;
555   l_rec.pon_attribute7                   := p_pon_attribute7;
552   l_rec.pon_attribute4                   := p_pon_attribute4;
553   l_rec.pon_attribute5                   := p_pon_attribute5;
554   l_rec.pon_attribute6                   := p_pon_attribute6;
556   l_rec.pon_attribute8                   := p_pon_attribute8;
557   l_rec.pon_attribute9                   := p_pon_attribute9;
558   l_rec.pon_attribute10                  := p_pon_attribute10;
559   l_rec.pon_attribute11                  := p_pon_attribute11;
560   l_rec.pon_attribute12                  := p_pon_attribute12;
561   l_rec.pon_attribute13                  := p_pon_attribute13;
562   l_rec.pon_attribute14                  := p_pon_attribute14;
563   l_rec.pon_attribute15                  := p_pon_attribute15;
564   l_rec.pon_attribute16                  := p_pon_attribute16;
565   l_rec.pon_attribute17                  := p_pon_attribute17;
566   l_rec.pon_attribute18                  := p_pon_attribute18;
567   l_rec.pon_attribute19                  := p_pon_attribute19;
568   l_rec.pon_attribute20                  := p_pon_attribute20;
569   l_rec.pon_attribute21                  := p_pon_attribute21;
570   l_rec.pon_attribute22                  := p_pon_attribute22;
571   l_rec.pon_attribute23                  := p_pon_attribute23;
572   l_rec.pon_attribute24                  := p_pon_attribute24;
573   l_rec.pon_attribute25                  := p_pon_attribute25;
574   l_rec.pon_attribute26                  := p_pon_attribute26;
575   l_rec.pon_attribute27                  := p_pon_attribute27;
576   l_rec.pon_attribute28                  := p_pon_attribute28;
577   l_rec.pon_attribute29                  := p_pon_attribute29;
578   l_rec.pon_attribute30                  := p_pon_attribute30;
579   l_rec.object_version_number            := p_object_version_number;
580   --
581   -- Return the plsql record structure.
582   --
583   hr_utility.set_location(' Leaving:'||l_proc, 10);
584   Return(l_rec);
585 --
586 End convert_args;
587 --
588 end ben_pon_shd;