DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPT_SHD

Source


1 Package Body ben_ept_shd as
2 /* $Header: beeptrhi.pkb 120.1 2006/03/13 05:03:41 rgajula noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ept_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_ELIG_PER_TYP_FK2') 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_ELIG_PER_TYP_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_elig_per_typ_prte_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 	elig_per_typ_prte_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
74 	eligy_prfl_id,
75 	per_typ_cd,
76         person_type_id,
77 	ordr_num,
78 	excld_flag,
79 	ept_attribute_category,
80 	ept_attribute1,
81 	ept_attribute2,
82 	ept_attribute3,
83 	ept_attribute4,
84 	ept_attribute5,
85 	ept_attribute6,
86 	ept_attribute7,
87 	ept_attribute8,
88 	ept_attribute9,
89 	ept_attribute10,
90 	ept_attribute11,
91 	ept_attribute12,
92 	ept_attribute13,
93 	ept_attribute14,
94 	ept_attribute15,
95 	ept_attribute16,
96 	ept_attribute17,
97 	ept_attribute18,
98 	ept_attribute19,
99 	ept_attribute20,
100 	ept_attribute21,
101 	ept_attribute22,
102 	ept_attribute23,
103 	ept_attribute24,
104 	ept_attribute25,
105 	ept_attribute26,
106 	ept_attribute27,
107 	ept_attribute28,
108 	ept_attribute29,
109 	ept_attribute30,
110 	object_version_number,
111 	criteria_score,
112 		criteria_weight
113     from	ben_elig_per_typ_prte_f
114     where	elig_per_typ_prte_id = p_elig_per_typ_prte_id
115     and		p_effective_date
116     between	effective_start_date and effective_end_date;
117 --
118   l_proc	varchar2(72)	:= g_package||'api_updating';
119   l_fct_ret	boolean;
120 --
121 Begin
122   hr_utility.set_location('Entering:'||l_proc, 5);
123   --
124   If (p_effective_date is null or
125       p_elig_per_typ_prte_id is null or
126       p_object_version_number is null) Then
127     --
128     -- One of the primary key arguments is null therefore we must
129     -- set the returning function value to false
130     --
131     l_fct_ret := false;
132   Else
133     If (p_elig_per_typ_prte_id = g_old_rec.elig_per_typ_prte_id and
134         p_object_version_number = g_old_rec.object_version_number) Then
135       hr_utility.set_location(l_proc, 10);
136       --
137       -- The g_old_rec is current therefore we must
138       -- set the returning function to true
139       --
140       l_fct_ret := true;
141     Else
142       --
143       -- Select the current row
144       --
145       Open C_Sel1;
146       Fetch C_Sel1 Into g_old_rec;
147       If C_Sel1%notfound Then
148         Close C_Sel1;
149         --
150         -- The primary key is invalid therefore we must error
151         --
152         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
153         fnd_message.raise_error;
154       End If;
155       Close C_Sel1;
156       If (p_object_version_number <> g_old_rec.object_version_number) Then
157         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
158         fnd_message.raise_error;
159       End If;
160       hr_utility.set_location(l_proc, 15);
161       l_fct_ret := true;
162     End If;
163   End If;
164   hr_utility.set_location(' Leaving:'||l_proc, 20);
165   Return (l_fct_ret);
166 --
167 End api_updating;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |--------------------------< find_dt_del_modes >---------------------------|
171 -- ----------------------------------------------------------------------------
172 Procedure find_dt_del_modes
173 	(p_effective_date	in  date,
174 	 p_base_key_value	in  number,
175 	 p_zap		 out nocopy boolean,
176 	 p_delete	 out nocopy boolean,
177 	 p_future_change out nocopy boolean,
178 	 p_delete_next_change out nocopy boolean) is
179 --
180   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
181 --
182   l_parent_key_value1	number;
183   --
184   Cursor C_Sel1 Is
185     select  t.eligy_prfl_id
186     from    ben_elig_per_typ_prte_f t
187     where   t.elig_per_typ_prte_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   If C_Sel1%notfound then
196     Close C_Sel1;
197     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
198     fnd_message.set_token('PROCEDURE', l_proc);
199     fnd_message.set_token('STEP','10');
200     fnd_message.raise_error;
201   End If;
202   Close C_Sel1;
203   --
204   -- Call the corresponding datetrack api
205   --
206   dt_api.find_dt_del_modes
207 	(p_effective_date	=> p_effective_date,
208 	 p_base_table_name	=> 'ben_elig_per_typ_prte_f',
209 	 p_base_key_column	=> 'elig_per_typ_prte_id',
210 	 p_base_key_value	=> p_base_key_value,
211 	 p_parent_table_name1	=> 'ben_eligy_prfl_f',
212 	 p_parent_key_column1	=> 'eligy_prfl_id',
213 	 p_parent_key_value1	=> l_parent_key_value1,
214 	 p_zap			=> p_zap,
215 	 p_delete		=> p_delete,
216 	 p_future_change	=> p_future_change,
217 	 p_delete_next_change	=> p_delete_next_change);
218   --
219   hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End find_dt_del_modes;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |--------------------------< find_dt_upd_modes >---------------------------|
224 -- ----------------------------------------------------------------------------
225 Procedure find_dt_upd_modes
226 	(p_effective_date	in  date,
227 	 p_base_key_value	in  number,
228 	 p_correction	 out nocopy boolean,
229 	 p_update	 out nocopy boolean,
230 	 p_update_override out nocopy boolean,
231 	 p_update_change_insert out nocopy boolean) is
232 --
233   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
234 --
235 Begin
236   hr_utility.set_location('Entering:'||l_proc, 5);
237   --
238   -- Call the corresponding datetrack api
239   --
240   dt_api.find_dt_upd_modes
241 	(p_effective_date	=> p_effective_date,
242 	 p_base_table_name	=> 'ben_elig_per_typ_prte_f',
243 	 p_base_key_column	=> 'elig_per_typ_prte_id',
244 	 p_base_key_value	=> p_base_key_value,
245 	 p_correction		=> p_correction,
246 	 p_update		=> p_update,
247 	 p_update_override	=> p_update_override,
248 	 p_update_change_insert	=> p_update_change_insert);
249   --
250   hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End find_dt_upd_modes;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |------------------------< upd_effective_end_date >------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure upd_effective_end_date
257 	(p_effective_date		in date,
258 	 p_base_key_value		in number,
259 	 p_new_effective_end_date	in date,
260 	 p_validation_start_date	in date,
261 	 p_validation_end_date		in date,
262          p_object_version_number       out nocopy number) is
263 --
264   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
265   l_object_version_number number;
266 --
267 Begin
268   hr_utility.set_location('Entering:'||l_proc, 5);
269   --
270   -- Because we are updating a row we must get the next object
271   -- version number.
272   --
273   l_object_version_number :=
274     dt_api.get_object_version_number
275 	(p_base_table_name	=> 'ben_elig_per_typ_prte_f',
276 	 p_base_key_column	=> 'elig_per_typ_prte_id',
277 	 p_base_key_value	=> p_base_key_value);
278   --
279   hr_utility.set_location(l_proc, 10);
280   g_api_dml := true;  -- Set the api dml status
281   --
282   -- Update the specified datetrack row setting the effective
283   -- end date to the specified new effective end date.
284   --
285   update  ben_elig_per_typ_prte_f t
286   set	  t.effective_end_date	  = p_new_effective_end_date,
287 	  t.object_version_number = l_object_version_number
288   where	  t.elig_per_typ_prte_id	  = p_base_key_value
289   and	  p_effective_date
290   between t.effective_start_date and t.effective_end_date;
291   --
292   g_api_dml := false;   -- Unset the api dml status
293   p_object_version_number := l_object_version_number;
294   hr_utility.set_location(' Leaving:'||l_proc, 15);
295 --
296 Exception
297   When Others Then
298     g_api_dml := false;   -- Unset the api dml status
299     Raise;
300 End upd_effective_end_date;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< lck >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure lck
306 	(p_effective_date	 in  date,
307 	 p_datetrack_mode	 in  varchar2,
308 	 p_elig_per_typ_prte_id	 in  number,
309 	 p_object_version_number in  number,
310 	 p_validation_start_date out nocopy date,
311 	 p_validation_end_date	 out nocopy date) is
312 --
313   l_proc		  varchar2(72) := g_package||'lck';
314   l_validation_start_date date;
315   l_validation_end_date	  date;
316   l_object_invalid 	  exception;
317   l_argument		  varchar2(30);
318   --
319   -- Cursor C_Sel1 selects the current locked row as of session date
320   -- ensuring that the object version numbers match.
321   --
322   Cursor C_Sel1 is
323     select
324 	elig_per_typ_prte_id,
325 	effective_start_date,
326 	effective_end_date,
327 	business_group_id,
328 	eligy_prfl_id,
329 	per_typ_cd,
330         person_type_id,
331 	ordr_num,
332 	excld_flag,
333 	ept_attribute_category,
334 	ept_attribute1,
335 	ept_attribute2,
336 	ept_attribute3,
337 	ept_attribute4,
338 	ept_attribute5,
339 	ept_attribute6,
340 	ept_attribute7,
341 	ept_attribute8,
342 	ept_attribute9,
343 	ept_attribute10,
344 	ept_attribute11,
345 	ept_attribute12,
346 	ept_attribute13,
347 	ept_attribute14,
348 	ept_attribute15,
349 	ept_attribute16,
350 	ept_attribute17,
351 	ept_attribute18,
352 	ept_attribute19,
353 	ept_attribute20,
354 	ept_attribute21,
355 	ept_attribute22,
356 	ept_attribute23,
357 	ept_attribute24,
358 	ept_attribute25,
359 	ept_attribute26,
360 	ept_attribute27,
361 	ept_attribute28,
362 	ept_attribute29,
363 	ept_attribute30,
364 	object_version_number,
365 	criteria_score,
366 	criteria_weight
367 
368     from    ben_elig_per_typ_prte_f
369     where   elig_per_typ_prte_id         = p_elig_per_typ_prte_id
370     and	    p_effective_date
371     between effective_start_date and effective_end_date
372     for update nowait;
373   --
374   --
375   --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Ensure that all the mandatory arguments are not null
380   --
381   hr_api.mandatory_arg_error(p_api_name       => l_proc,
382                              p_argument       => 'effective_date',
383                              p_argument_value => p_effective_date);
384   --
385   hr_api.mandatory_arg_error(p_api_name       => l_proc,
386                              p_argument       => 'datetrack_mode',
387                              p_argument_value => p_datetrack_mode);
388   --
389   hr_api.mandatory_arg_error(p_api_name       => l_proc,
390                              p_argument       => 'elig_per_typ_prte_id',
391                              p_argument_value => p_elig_per_typ_prte_id);
392   --
393   hr_api.mandatory_arg_error(p_api_name       => l_proc,
394                              p_argument       => 'object_version_number',
395                              p_argument_value => p_object_version_number);
396   --
397   hr_utility.set_location('Entering:'||p_effective_date, 5);
398   hr_utility.set_location('Entering:'||p_datetrack_mode, 5);
399   hr_utility.set_location('Entering:'||p_elig_per_typ_prte_id, 5);
400   hr_utility.set_location('Entering:'||p_object_version_number, 5);
401   -- Check to ensure the datetrack mode is not INSERT.
402   --
403   If (p_datetrack_mode <> 'INSERT') then
404     --
405     -- We must select and lock the current row.
406     --
407     Open  C_Sel1;
408   hr_utility.set_location('before fetch:'||p_object_version_number, 5);
409     Fetch C_Sel1 Into g_old_rec;
410   hr_utility.set_location('after fetch:'||p_object_version_number, 5);
411     If C_Sel1%notfound then
412       Close C_Sel1;
413       --
414       -- The primary key is invalid therefore we must error
415       --
416       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
417       fnd_message.raise_error;
418     End If;
419     Close C_Sel1;
420     If (p_object_version_number <> g_old_rec.object_version_number) Then
421         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
422         fnd_message.raise_error;
423       End If;
424     hr_utility.set_location(l_proc, 15);
425     --
426     --
427     -- Validate the datetrack mode mode getting the validation start
428     -- and end dates for the specified datetrack operation.
429     --
430     dt_api.validate_dt_mode
431 	(p_effective_date	   => p_effective_date,
432 	 p_datetrack_mode	   => p_datetrack_mode,
433 	 p_base_table_name	   => 'ben_elig_per_typ_prte_f',
434 	 p_base_key_column	   => 'elig_per_typ_prte_id',
435 	 p_base_key_value 	   => p_elig_per_typ_prte_id,
436 	 p_parent_table_name1      => 'ben_eligy_prfl_f',
437 	 p_parent_key_column1      => 'eligy_prfl_id',
438 	 p_parent_key_value1       => g_old_rec.eligy_prfl_id,
439          p_enforce_foreign_locking => true,
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_elig_per_typ_prte_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_elig_per_typ_prte_f');
478     fnd_message.raise_error;
479 End lck;
480 --
481 -- ----------------------------------------------------------------------------
482 -- |-----------------------------< convert_args >-----------------------------|
483 -- ----------------------------------------------------------------------------
484 Function convert_args
485 	(
486 	p_elig_per_typ_prte_id          in number,
487 	p_effective_start_date          in date,
488 	p_effective_end_date            in date,
489 	p_business_group_id             in number,
490 	p_eligy_prfl_id                 in number,
491 	p_per_typ_cd                    in varchar2,
492         p_person_type_id                in number,
493 	p_ordr_num                      in number,
494 	p_excld_flag                    in varchar2,
495 	p_ept_attribute_category        in varchar2,
496 	p_ept_attribute1                in varchar2,
497 	p_ept_attribute2                in varchar2,
498 	p_ept_attribute3                in varchar2,
499 	p_ept_attribute4                in varchar2,
500 	p_ept_attribute5                in varchar2,
501 	p_ept_attribute6                in varchar2,
502 	p_ept_attribute7                in varchar2,
503 	p_ept_attribute8                in varchar2,
504 	p_ept_attribute9                in varchar2,
505 	p_ept_attribute10               in varchar2,
506 	p_ept_attribute11               in varchar2,
507 	p_ept_attribute12               in varchar2,
508 	p_ept_attribute13               in varchar2,
509 	p_ept_attribute14               in varchar2,
510 	p_ept_attribute15               in varchar2,
511 	p_ept_attribute16               in varchar2,
512 	p_ept_attribute17               in varchar2,
513 	p_ept_attribute18               in varchar2,
514 	p_ept_attribute19               in varchar2,
515 	p_ept_attribute20               in varchar2,
516 	p_ept_attribute21               in varchar2,
517 	p_ept_attribute22               in varchar2,
518 	p_ept_attribute23               in varchar2,
519 	p_ept_attribute24               in varchar2,
520 	p_ept_attribute25               in varchar2,
521 	p_ept_attribute26               in varchar2,
522 	p_ept_attribute27               in varchar2,
523 	p_ept_attribute28               in varchar2,
524 	p_ept_attribute29               in varchar2,
525 	p_ept_attribute30               in varchar2,
526 	p_object_version_number         in number,
527 	p_criteria_score				in number,
528 	p_criteria_weight				in number
529 
530 	)
531 	Return g_rec_type is
532 --
533   l_rec	  g_rec_type;
534   l_proc  varchar2(72) := g_package||'convert_args';
535 --
536 Begin
537   --
538   hr_utility.set_location('Entering:'||l_proc, 5);
539   --
540   -- Convert arguments into local l_rec structure.
541   --
542   l_rec.elig_per_typ_prte_id             := p_elig_per_typ_prte_id;
543   l_rec.effective_start_date             := p_effective_start_date;
544   l_rec.effective_end_date               := p_effective_end_date;
545   l_rec.business_group_id                := p_business_group_id;
546   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
547   l_rec.per_typ_cd                       := p_per_typ_cd;
548   l_rec.person_type_id                   := p_person_type_id;
549   l_rec.ordr_num                         := p_ordr_num;
550   l_rec.excld_flag                       := p_excld_flag;
551   l_rec.ept_attribute_category           := p_ept_attribute_category;
552   l_rec.ept_attribute1                   := p_ept_attribute1;
553   l_rec.ept_attribute2                   := p_ept_attribute2;
554   l_rec.ept_attribute3                   := p_ept_attribute3;
555   l_rec.ept_attribute4                   := p_ept_attribute4;
556   l_rec.ept_attribute5                   := p_ept_attribute5;
557   l_rec.ept_attribute6                   := p_ept_attribute6;
558   l_rec.ept_attribute7                   := p_ept_attribute7;
559   l_rec.ept_attribute8                   := p_ept_attribute8;
560   l_rec.ept_attribute9                   := p_ept_attribute9;
561   l_rec.ept_attribute10                  := p_ept_attribute10;
562   l_rec.ept_attribute11                  := p_ept_attribute11;
563   l_rec.ept_attribute12                  := p_ept_attribute12;
564   l_rec.ept_attribute13                  := p_ept_attribute13;
565   l_rec.ept_attribute14                  := p_ept_attribute14;
566   l_rec.ept_attribute15                  := p_ept_attribute15;
567   l_rec.ept_attribute16                  := p_ept_attribute16;
568   l_rec.ept_attribute17                  := p_ept_attribute17;
569   l_rec.ept_attribute18                  := p_ept_attribute18;
570   l_rec.ept_attribute19                  := p_ept_attribute19;
571   l_rec.ept_attribute20                  := p_ept_attribute20;
572   l_rec.ept_attribute21                  := p_ept_attribute21;
573   l_rec.ept_attribute22                  := p_ept_attribute22;
574   l_rec.ept_attribute23                  := p_ept_attribute23;
575   l_rec.ept_attribute24                  := p_ept_attribute24;
576   l_rec.ept_attribute25                  := p_ept_attribute25;
577   l_rec.ept_attribute26                  := p_ept_attribute26;
578   l_rec.ept_attribute27                  := p_ept_attribute27;
579   l_rec.ept_attribute28                  := p_ept_attribute28;
580   l_rec.ept_attribute29                  := p_ept_attribute29;
581   l_rec.ept_attribute30                  := p_ept_attribute30;
582   l_rec.object_version_number            := p_object_version_number;
583   l_rec.criteria_score					 := p_criteria_score;
584   l_rec.criteria_weight					  := p_criteria_weight;
585 
586   --
587   -- Return the plsql record structure.
588   --
589   hr_utility.set_location(' Leaving:'||l_proc, 10);
590   Return(l_rec);
591 --
592 End convert_args;
593 --
594 end ben_ept_shd;