DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EPN_SHD

Source


1 Package Body ben_epn_shd as
2 /* $Header: beepnrhi.pkb 120.0 2005/05/28 02:41:31 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_epn_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_PRBTN_PERD_PRTE_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_ELIG_PRBTN_PERD_PRTE_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_ELIG_PRBTN_PERD_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_PRBTN_PERD_PRTE_id,
71 	effective_start_date,
72 	effective_end_date,
73 	excld_flag,
74 	ordr_num,
75 	probation_period,
76         probation_unit,
77 	eligy_prfl_id,
78 	business_group_id,
79 	epn_attribute_category,
80 	epn_attribute1,
81 	epn_attribute2,
82 	epn_attribute3,
83 	epn_attribute4,
84 	epn_attribute5,
85 	epn_attribute6,
86 	epn_attribute7,
87 	epn_attribute8,
88 	epn_attribute9,
89 	epn_attribute10,
90 	epn_attribute11,
91 	epn_attribute12,
92 	epn_attribute13,
93 	epn_attribute14,
94 	epn_attribute15,
95 	epn_attribute16,
96 	epn_attribute17,
97 	epn_attribute18,
98 	epn_attribute19,
99 	epn_attribute20,
100 	epn_attribute21,
101 	epn_attribute22,
102 	epn_attribute23,
103 	epn_attribute24,
104 	epn_attribute25,
105 	epn_attribute26,
106 	epn_attribute27,
107 	epn_attribute28,
108 	epn_attribute29,
109 	epn_attribute30,
110 	object_version_number,
111 	criteria_score,
112 	criteria_weight
113     from	ben_ELIG_PRBTN_PERD_PRTE_f
114     where	ELIG_PRBTN_PERD_PRTE_id = p_ELIG_PRBTN_PERD_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_PRBTN_PERD_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_PRBTN_PERD_PRTE_id = g_old_rec.ELIG_PRBTN_PERD_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   --
183   --
184 --
185 Begin
186   hr_utility.set_location('Entering:'||l_proc, 5);
187     --
188   --
189   -- Call the corresponding datetrack api
190   --
191   dt_api.find_dt_del_modes
192 	(p_effective_date	=> p_effective_date,
193 	 p_base_table_name	=> 'ben_ELIG_PRBTN_PERD_PRTE_f',
194 	 p_base_key_column	=> 'ELIG_PRBTN_PERD_PRTE_id',
195 	 p_base_key_value	=> p_base_key_value,
196 	 p_zap			=> p_zap,
197 	 p_delete		=> p_delete,
198 	 p_future_change	=> p_future_change,
199 	 p_delete_next_change	=> p_delete_next_change);
200   --
201   hr_utility.set_location(' Leaving:'||l_proc, 10);
202 End find_dt_del_modes;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |--------------------------< find_dt_upd_modes >---------------------------|
206 -- ----------------------------------------------------------------------------
207 Procedure find_dt_upd_modes
208 	(p_effective_date	in  date,
209 	 p_base_key_value	in  number,
210 	 p_correction	 out nocopy boolean,
211 	 p_update	 out nocopy boolean,
212 	 p_update_override out nocopy boolean,
213 	 p_update_change_insert out nocopy boolean) is
214 --
215   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
216 --
217 Begin
218   hr_utility.set_location('Entering:'||l_proc, 5);
219   --
220   -- Call the corresponding datetrack api
221   --
222   dt_api.find_dt_upd_modes
223 	(p_effective_date	=> p_effective_date,
224 	 p_base_table_name	=> 'ben_ELIG_PRBTN_PERD_PRTE_f',
225 	 p_base_key_column	=> 'ELIG_PRBTN_PERD_PRTE_id',
226 	 p_base_key_value	=> p_base_key_value,
227 	 p_correction		=> p_correction,
228 	 p_update		=> p_update,
229 	 p_update_override	=> p_update_override,
230 	 p_update_change_insert	=> p_update_change_insert);
231   --
232   hr_utility.set_location(' Leaving:'||l_proc, 10);
233 End find_dt_upd_modes;
234 --
235 -- ----------------------------------------------------------------------------
236 -- |------------------------< upd_effective_end_date >------------------------|
237 -- ----------------------------------------------------------------------------
238 Procedure upd_effective_end_date
239 	(p_effective_date		in date,
240 	 p_base_key_value		in number,
241 	 p_new_effective_end_date	in date,
242 	 p_validation_start_date	in date,
243 	 p_validation_end_date		in date,
244          p_object_version_number       out nocopy number) is
245 --
246   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
247   l_object_version_number number;
248 --
249 Begin
250   hr_utility.set_location('Entering:'||l_proc, 5);
251   --
252   -- Because we are updating a row we must get the next object
253   -- version number.
254   --
255   l_object_version_number :=
256     dt_api.get_object_version_number
257 	(p_base_table_name	=> 'ben_ELIG_PRBTN_PERD_PRTE_f',
258 	 p_base_key_column	=> 'ELIG_PRBTN_PERD_PRTE_id',
259 	 p_base_key_value	=> p_base_key_value);
260   --
261   hr_utility.set_location(l_proc, 10);
262   g_api_dml := true;  -- Set the api dml status
263   --
264   -- Update the specified datetrack row setting the effective
265   -- end date to the specified new effective end date.
266   --
267   update  ben_ELIG_PRBTN_PERD_PRTE_f t
268   set	  t.effective_end_date	  = p_new_effective_end_date,
269 	  t.object_version_number = l_object_version_number
270   where	  t.ELIG_PRBTN_PERD_PRTE_id	  = p_base_key_value
271   and	  p_effective_date
272   between t.effective_start_date and t.effective_end_date;
273   --
274   g_api_dml := false;   -- Unset the api dml status
275   p_object_version_number := l_object_version_number;
276   hr_utility.set_location(' Leaving:'||l_proc, 15);
277 --
278 Exception
279   When Others Then
280     g_api_dml := false;   -- Unset the api dml status
281     Raise;
282 End upd_effective_end_date;
283 --
284 -- ----------------------------------------------------------------------------
285 -- |---------------------------------< lck >----------------------------------|
286 -- ----------------------------------------------------------------------------
287 Procedure lck
288 	(p_effective_date	 in  date,
289 	 p_datetrack_mode	 in  varchar2,
290 	 p_ELIG_PRBTN_PERD_PRTE_id	 in  number,
291 	 p_object_version_number in  number,
292 	 p_validation_start_date out nocopy date,
293 	 p_validation_end_date	 out nocopy date) is
294 --
295   l_proc		  varchar2(72) := g_package||'lck';
296   l_validation_start_date date;
297   l_validation_end_date	  date;
298   l_object_invalid 	  exception;
299   l_argument		  varchar2(30);
300   --
301   -- Cursor C_Sel1 selects the current locked row as of session date
302   -- ensuring that the object version numbers match.
303   --
304   Cursor C_Sel1 is
305     select
306 	ELIG_PRBTN_PERD_PRTE_id,
307 	effective_start_date,
308 	effective_end_date,
309 	excld_flag,
310 	ordr_num,
311 	PROBATION_PERIOD,
312         probation_unit,
313 	eligy_prfl_id,
314 	business_group_id,
315 	epn_attribute_category,
316 	epn_attribute1,
317 	epn_attribute2,
318 	epn_attribute3,
319 	epn_attribute4,
320 	epn_attribute5,
321 	epn_attribute6,
322 	epn_attribute7,
323 	epn_attribute8,
324 	epn_attribute9,
325 	epn_attribute10,
326 	epn_attribute11,
327 	epn_attribute12,
328 	epn_attribute13,
329 	epn_attribute14,
330 	epn_attribute15,
331 	epn_attribute16,
332 	epn_attribute17,
333 	epn_attribute18,
334 	epn_attribute19,
335 	epn_attribute20,
336 	epn_attribute21,
337 	epn_attribute22,
338 	epn_attribute23,
339 	epn_attribute24,
340 	epn_attribute25,
341 	epn_attribute26,
342 	epn_attribute27,
343 	epn_attribute28,
344 	epn_attribute29,
345 	epn_attribute30,
346 	object_version_number,
347 	criteria_score,
348 	criteria_weight
349     from    ben_ELIG_PRBTN_PERD_PRTE_f
350     where   ELIG_PRBTN_PERD_PRTE_id         = p_ELIG_PRBTN_PERD_PRTE_id
351     and	    p_effective_date
352     between effective_start_date and effective_end_date
353     for update nowait;
354   --
355   --
356   --
357 Begin
358   hr_utility.set_location('Entering:'||l_proc, 5);
359   --
360   -- Ensure that all the mandatory arguments are not null
361   --
362   hr_api.mandatory_arg_error(p_api_name       => l_proc,
363                              p_argument       => 'effective_date',
364                              p_argument_value => p_effective_date);
365   --
366   hr_api.mandatory_arg_error(p_api_name       => l_proc,
367                              p_argument       => 'datetrack_mode',
368                              p_argument_value => p_datetrack_mode);
369   --
370   hr_api.mandatory_arg_error(p_api_name       => l_proc,
371                              p_argument       => 'ELIG_PRBTN_PERD_PRTE_id',
372                              p_argument_value => p_ELIG_PRBTN_PERD_PRTE_id);
373   --
374   hr_api.mandatory_arg_error(p_api_name       => l_proc,
375                              p_argument       => 'object_version_number',
376                              p_argument_value => p_object_version_number);
377   --
378   -- Check to ensure the datetrack mode is not INSERT.
379   --
380   If (p_datetrack_mode <> 'INSERT') then
381     --
382     -- We must select and lock the current row.
383     --
384     Open  C_Sel1;
385     Fetch C_Sel1 Into g_old_rec;
386     If C_Sel1%notfound then
387       Close C_Sel1;
388       --
389       -- The primary key is invalid therefore we must error
390       --
391       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
392       fnd_message.raise_error;
393     End If;
394     Close C_Sel1;
395     If (p_object_version_number <> g_old_rec.object_version_number) Then
396         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
397         fnd_message.raise_error;
398       End If;
399     hr_utility.set_location(l_proc, 15);
400     --
401     --
402     -- Validate the datetrack mode mode getting the validation start
403     -- and end dates for the specified datetrack operation.
404     --
405     dt_api.validate_dt_mode
406 	(p_effective_date	   => p_effective_date,
407 	 p_datetrack_mode	   => p_datetrack_mode,
408 	 p_base_table_name	   => 'ben_ELIG_PRBTN_PERD_PRTE_f',
409 	 p_base_key_column	   => 'ELIG_PRBTN_PERD_PRTE_id',
410 	 p_base_key_value 	   => p_ELIG_PRBTN_PERD_PRTE_id,
411 
412          p_enforce_foreign_locking => true,
413 	 p_validation_start_date   => l_validation_start_date,
414  	 p_validation_end_date	   => l_validation_end_date);
415   Else
416     --
417     -- We are doing a datetrack 'INSERT' which is illegal within this
418     -- procedure therefore we must error (note: to lck on insert the
419     -- private procedure ins_lck should be called).
420     --
421     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
422     fnd_message.set_token('PROCEDURE', l_proc);
423     fnd_message.set_token('STEP','20');
424     fnd_message.raise_error;
425   End If;
426   --
427   -- Set the validation start and end date OUT arguments
428   --
429   p_validation_start_date := l_validation_start_date;
430   p_validation_end_date   := l_validation_end_date;
431   --
435 --
432   hr_utility.set_location(' Leaving:'||l_proc, 30);
433 --
434 -- We need to trap the ORA LOCK exception
436 Exception
437   When HR_Api.Object_Locked then
438     --
439     -- The object is locked therefore we need to supply a meaningful
440     -- error message.
441     --
442     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
443     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_PRBTN_PERD_PRTE_f');
444     fnd_message.raise_error;
445   When l_object_invalid then
446     --
447     -- The object doesn't exist or is invalid
448     --
449     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
450     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_PRBTN_PERD_PRTE_f');
451     fnd_message.raise_error;
452 End lck;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |-----------------------------< convert_args >-----------------------------|
456 -- ----------------------------------------------------------------------------
457 Function convert_args
458 	(
459 	p_ELIG_PRBTN_PERD_PRTE_id        in number,
460 	p_effective_start_date          in date,
461 	p_effective_end_date            in date,
462 	p_excld_flag                    in varchar2,
463 	p_ordr_num                      in number,
464 	p_PROBATION_PERIOD              in number,
465         p_probation_unit                in varchar2,
466 	p_eligy_prfl_id                 in number,
467 	p_business_group_id             in number,
468 	p_epn_attribute_category        in varchar2,
469 	p_epn_attribute1                in varchar2,
470 	p_epn_attribute2                in varchar2,
471 	p_epn_attribute3                in varchar2,
472 	p_epn_attribute4                in varchar2,
473 	p_epn_attribute5                in varchar2,
474 	p_epn_attribute6                in varchar2,
475 	p_epn_attribute7                in varchar2,
476 	p_epn_attribute8                in varchar2,
477 	p_epn_attribute9                in varchar2,
478 	p_epn_attribute10               in varchar2,
479 	p_epn_attribute11               in varchar2,
480 	p_epn_attribute12               in varchar2,
481 	p_epn_attribute13               in varchar2,
482 	p_epn_attribute14               in varchar2,
483 	p_epn_attribute15               in varchar2,
484 	p_epn_attribute16               in varchar2,
485 	p_epn_attribute17               in varchar2,
486 	p_epn_attribute18               in varchar2,
487 	p_epn_attribute19               in varchar2,
488 	p_epn_attribute20               in varchar2,
489 	p_epn_attribute21               in varchar2,
490 	p_epn_attribute22               in varchar2,
491 	p_epn_attribute23               in varchar2,
492 	p_epn_attribute24               in varchar2,
493 	p_epn_attribute25               in varchar2,
494 	p_epn_attribute26               in varchar2,
495 	p_epn_attribute27               in varchar2,
496 	p_epn_attribute28               in varchar2,
497 	p_epn_attribute29               in varchar2,
498 	p_epn_attribute30               in varchar2,
499 	p_object_version_number         in number  ,
500 	p_criteria_score                in number  ,
501 	p_criteria_weight               in number
502 	)
503 	Return g_rec_type is
504 --
505   l_rec	  g_rec_type;
506   l_proc  varchar2(72) := g_package||'convert_args';
507 --
508 Begin
509   --
510   hr_utility.set_location('Entering:'||l_proc, 5);
511   --
512   -- Convert arguments into local l_rec structure.
513   --
514   l_rec.ELIG_PRBTN_PERD_PRTE_id           := p_ELIG_PRBTN_PERD_PRTE_id;
515   l_rec.effective_start_date             := p_effective_start_date;
516   l_rec.effective_end_date               := p_effective_end_date;
517   l_rec.excld_flag                       := p_excld_flag;
518   l_rec.ordr_num                         := p_ordr_num;
519   l_rec.PROBATION_PERIOD                 := p_PROBATION_PERIOD;
520   l_rec.probation_unit                   := p_probation_unit;
521   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
522   l_rec.business_group_id                := p_business_group_id;
523   l_rec.epn_attribute_category           := p_epn_attribute_category;
524   l_rec.epn_attribute1                   := p_epn_attribute1;
525   l_rec.epn_attribute2                   := p_epn_attribute2;
526   l_rec.epn_attribute3                   := p_epn_attribute3;
527   l_rec.epn_attribute4                   := p_epn_attribute4;
528   l_rec.epn_attribute5                   := p_epn_attribute5;
529   l_rec.epn_attribute6                   := p_epn_attribute6;
530   l_rec.epn_attribute7                   := p_epn_attribute7;
531   l_rec.epn_attribute8                   := p_epn_attribute8;
532   l_rec.epn_attribute9                   := p_epn_attribute9;
533   l_rec.epn_attribute10                  := p_epn_attribute10;
534   l_rec.epn_attribute11                  := p_epn_attribute11;
535   l_rec.epn_attribute12                  := p_epn_attribute12;
536   l_rec.epn_attribute13                  := p_epn_attribute13;
537   l_rec.epn_attribute14                  := p_epn_attribute14;
538   l_rec.epn_attribute15                  := p_epn_attribute15;
539   l_rec.epn_attribute16                  := p_epn_attribute16;
540   l_rec.epn_attribute17                  := p_epn_attribute17;
541   l_rec.epn_attribute18                  := p_epn_attribute18;
542   l_rec.epn_attribute19                  := p_epn_attribute19;
543   l_rec.epn_attribute20                  := p_epn_attribute20;
544   l_rec.epn_attribute21                  := p_epn_attribute21;
545   l_rec.epn_attribute22                  := p_epn_attribute22;
546   l_rec.epn_attribute23                  := p_epn_attribute23;
547   l_rec.epn_attribute24                  := p_epn_attribute24;
548   l_rec.epn_attribute25                  := p_epn_attribute25;
549   l_rec.epn_attribute26                  := p_epn_attribute26;
550   l_rec.epn_attribute27                  := p_epn_attribute27;
551   l_rec.epn_attribute28                  := p_epn_attribute28;
552   l_rec.epn_attribute29                  := p_epn_attribute29;
553   l_rec.epn_attribute30                  := p_epn_attribute30;
554   l_rec.object_version_number            := p_object_version_number;
555   l_rec.criteria_score                   := p_criteria_score;
556   l_rec.criteria_weight                  := p_criteria_weight;
557   --
558   -- Return the plsql record structure.
559   --
560   hr_utility.set_location(' Leaving:'||l_proc, 10);
561   Return(l_rec);
562 --
563 End convert_args;
564 --
565 end ben_epn_shd;