DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EGN_SHD

Source


1 Package Body ben_egn_shd as
2 /* $Header: beegnrhi.pkb 120.0 2005/05/28 02:12:39 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_egn_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_GNDR_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_GNDR_PRTE_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_gndr_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_gndr_prte_id,
71 	effective_start_date,
72 	effective_end_date,
73 	excld_flag,
74 	sex,
75 	eligy_prfl_id,
76 	business_group_id,
77 	egn_attribute_category,
78 	egn_attribute1,
79 	egn_attribute2,
80 	egn_attribute3,
81 	egn_attribute4,
82 	egn_attribute5,
83 	egn_attribute6,
84 	egn_attribute7,
85 	egn_attribute8,
86 	egn_attribute9,
87 	egn_attribute10,
88 	egn_attribute11,
89 	egn_attribute12,
90 	egn_attribute13,
91 	egn_attribute14,
92 	egn_attribute15,
93 	egn_attribute16,
94 	egn_attribute17,
95 	egn_attribute18,
96 	egn_attribute19,
97 	egn_attribute20,
98 	egn_attribute21,
99 	egn_attribute22,
100 	egn_attribute23,
101 	egn_attribute24,
102 	egn_attribute25,
103 	egn_attribute26,
104 	egn_attribute27,
105 	egn_attribute28,
106 	egn_attribute29,
107 	egn_attribute30,
108 	ordr_num,
109 	object_version_number,
110 	criteria_score,
111 	criteria_weight
112     from	ben_elig_gndr_prte_f
113     where	elig_gndr_prte_id = p_elig_gndr_prte_id
114     and		p_effective_date
115     between	effective_start_date and effective_end_date;
116 --
117   l_proc	varchar2(72)	:= g_package||'api_updating';
118   l_fct_ret	boolean;
119 --
120 Begin
121   hr_utility.set_location('Entering:'||l_proc, 5);
122   --
123   If (p_effective_date is null or
124       p_elig_gndr_prte_id is null or
125       p_object_version_number is null) Then
126     --
127     -- One of the primary key arguments is null therefore we must
128     -- set the returning function value to false
129     --
130     l_fct_ret := false;
131   Else
132     If (p_elig_gndr_prte_id = g_old_rec.elig_gndr_prte_id and
136       -- The g_old_rec is current therefore we must
133         p_object_version_number = g_old_rec.object_version_number) Then
134       hr_utility.set_location(l_proc, 10);
135       --
137       -- set the returning function to true
138       --
139       l_fct_ret := true;
140     Else
141       --
142       -- Select the current row
143       --
144       Open C_Sel1;
145       Fetch C_Sel1 Into g_old_rec;
146       If C_Sel1%notfound Then
147         Close C_Sel1;
148         --
149         -- The primary key is invalid therefore we must error
150         --
151         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
152         fnd_message.raise_error;
153       End If;
154       Close C_Sel1;
155       If (p_object_version_number <> g_old_rec.object_version_number) Then
156         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
157         fnd_message.raise_error;
158       End If;
159       hr_utility.set_location(l_proc, 15);
160       l_fct_ret := true;
161     End If;
162   End If;
163   hr_utility.set_location(' Leaving:'||l_proc, 20);
164   Return (l_fct_ret);
165 --
166 End api_updating;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |--------------------------< find_dt_del_modes >---------------------------|
170 -- ----------------------------------------------------------------------------
171 Procedure find_dt_del_modes
172 	(p_effective_date	in  date,
173 	 p_base_key_value	in  number,
174 	 p_zap		 out nocopy boolean,
175 	 p_delete	 out nocopy boolean,
176 	 p_future_change out nocopy boolean,
177 	 p_delete_next_change out nocopy boolean) is
178 --
179   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
180 --
181   --
182   --
183 --
184 Begin
185   hr_utility.set_location('Entering:'||l_proc, 5);
186     --
187   --
188   -- Call the corresponding datetrack api
189   --
190   dt_api.find_dt_del_modes
191 	(p_effective_date	=> p_effective_date,
192 	 p_base_table_name	=> 'ben_ELIG_GNDR_PRTE_f',
193 	 p_base_key_column	=> 'ELIG_GNDR_PRTE_id',
194 	 p_base_key_value	=> p_base_key_value,
195 	 p_zap			=> p_zap,
196 	 p_delete		=> p_delete,
197 	 p_future_change	=> p_future_change,
198 	 p_delete_next_change	=> p_delete_next_change);
199   --
200   hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End find_dt_del_modes;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |--------------------------< find_dt_upd_modes >---------------------------|
205 -- ----------------------------------------------------------------------------
206 Procedure find_dt_upd_modes
207 	(p_effective_date	in  date,
208 	 p_base_key_value	in  number,
209 	 p_correction	 out nocopy boolean,
210 	 p_update	 out nocopy boolean,
211 	 p_update_override out nocopy boolean,
212 	 p_update_change_insert out nocopy boolean) is
213 --
214   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
215 --
216 Begin
217   hr_utility.set_location('Entering:'||l_proc, 5);
218   --
219   -- Call the corresponding datetrack api
220   --
221   dt_api.find_dt_upd_modes
222 	(p_effective_date	=> p_effective_date,
223 	 p_base_table_name	=> 'ben_ELIG_GNDR_PRTE_f',
224 	 p_base_key_column	=> 'ELIG_GNDR_PRTE_id',
225 	 p_base_key_value	=> p_base_key_value,
226 	 p_correction		=> p_correction,
227 	 p_update		=> p_update,
228 	 p_update_override	=> p_update_override,
229 	 p_update_change_insert	=> p_update_change_insert);
230   --
231   hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End find_dt_upd_modes;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |------------------------< upd_effective_end_date >------------------------|
236 -- ----------------------------------------------------------------------------
237 Procedure upd_effective_end_date
238 	(p_effective_date		in date,
239 	 p_base_key_value		in number,
240 	 p_new_effective_end_date	in date,
241 	 p_validation_start_date	in date,
242 	 p_validation_end_date		in date,
243          p_object_version_number       out nocopy number) is
244 --
245   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
246   l_object_version_number number;
247 --
248 Begin
249   hr_utility.set_location('Entering:'||l_proc, 5);
250   --
251   -- Because we are updating a row we must get the next object
252   -- version number.
253   --
254   l_object_version_number :=
255     dt_api.get_object_version_number
256 	(p_base_table_name	=> 'ben_ELIG_GNDR_PRTE_f',
257 	 p_base_key_column	=> 'ELIG_GNDR_PRTE_id',
258 	 p_base_key_value	=> p_base_key_value);
259   --
260   hr_utility.set_location(l_proc, 10);
261   g_api_dml := true;  -- Set the api dml status
262   --
263   -- Update the specified datetrack row setting the effective
264   -- end date to the specified new effective end date.
265   --
266   update  ben_ELIG_GNDR_PRTE_f t
267   set	  t.effective_end_date	  = p_new_effective_end_date,
268 	  t.object_version_number = l_object_version_number
269   where	  t.ELIG_GNDR_PRTE_id	  = p_base_key_value
270   and	  p_effective_date
271   between t.effective_start_date and t.effective_end_date;
272   --
273   g_api_dml := false;   -- Unset the api dml status
274   p_object_version_number := l_object_version_number;
275   hr_utility.set_location(' Leaving:'||l_proc, 15);
276 --
277 Exception
278   When Others Then
279     g_api_dml := false;   -- Unset the api dml status
280     Raise;
281 End upd_effective_end_date;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------------< lck >----------------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure lck
287 	(p_effective_date	 in  date,
288 	 p_datetrack_mode	 in  varchar2,
289 	 p_ELIG_GNDR_PRTE_id	 in  number,
290 	 p_object_version_number in  number,
291 	 p_validation_start_date out nocopy date,
292 	 p_validation_end_date	 out nocopy date) is
293 --
294   l_proc		  varchar2(72) := g_package||'lck';
295   l_validation_start_date date;
296   l_validation_end_date	  date;
297   l_object_invalid 	  exception;
298   l_argument		  varchar2(30);
299   --
300   -- Cursor C_Sel1 selects the current locked row as of session date
301   -- ensuring that the object version numbers match.
302   --
303   Cursor C_Sel1 is
304     select
305 	ELIG_GNDR_PRTE_id,
306 	effective_start_date,
307 	effective_end_date,
308 	excld_flag,
309 	sex,
310 	eligy_prfl_id,
311 	business_group_id,
312 	egn_attribute_category,
313 	egn_attribute1,
314 	egn_attribute2,
315 	egn_attribute3,
316 	egn_attribute4,
317 	egn_attribute5,
318 	egn_attribute6,
319 	egn_attribute7,
320 	egn_attribute8,
321 	egn_attribute9,
322 	egn_attribute10,
323 	egn_attribute11,
324 	egn_attribute12,
325 	egn_attribute13,
326 	egn_attribute14,
327 	egn_attribute15,
328 	egn_attribute16,
329 	egn_attribute17,
330 	egn_attribute18,
331 	egn_attribute19,
332 	egn_attribute20,
333 	egn_attribute21,
334 	egn_attribute22,
335 	egn_attribute23,
336 	egn_attribute24,
337 	egn_attribute25,
338 	egn_attribute26,
339 	egn_attribute27,
340 	egn_attribute28,
341 	egn_attribute29,
342 	egn_attribute30,
343 	ordr_num,
344 	object_version_number,
345 	criteria_score,
346 	criteria_weight
347 
348     from    ben_ELIG_GNDR_PRTE_f
349     where   ELIG_GNDR_PRTE_id         = p_ELIG_GNDR_PRTE_id
350     and	    p_effective_date
351     between effective_start_date and effective_end_date
352     for update nowait;
353   --
354   --
355   --
356 Begin
357   hr_utility.set_location('Entering:'||l_proc, 5);
358   --
359   -- Ensure that all the mandatory arguments are not null
360   --
361   hr_api.mandatory_arg_error(p_api_name       => l_proc,
362                              p_argument       => 'effective_date',
363                              p_argument_value => p_effective_date);
364   --
365   hr_api.mandatory_arg_error(p_api_name       => l_proc,
366                              p_argument       => 'datetrack_mode',
367                              p_argument_value => p_datetrack_mode);
368   --
369   hr_api.mandatory_arg_error(p_api_name       => l_proc,
370                              p_argument       => 'ELIG_GNDR_PRTE_id',
371                              p_argument_value => p_ELIG_GNDR_PRTE_id);
372   --
373   hr_api.mandatory_arg_error(p_api_name       => l_proc,
374                              p_argument       => 'object_version_number',
375                              p_argument_value => p_object_version_number);
376   --
377   -- Check to ensure the datetrack mode is not INSERT.
378   --
379   If (p_datetrack_mode <> 'INSERT') then
380     --
381     -- We must select and lock the current row.
382     --
383     Open  C_Sel1;
384     Fetch C_Sel1 Into g_old_rec;
385     If C_Sel1%notfound then
386       Close C_Sel1;
387       --
388       -- The primary key is invalid therefore we must error
389       --
390       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
391       fnd_message.raise_error;
392     End If;
393     Close C_Sel1;
394     If (p_object_version_number <> g_old_rec.object_version_number) Then
395         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
396         fnd_message.raise_error;
397       End If;
398     hr_utility.set_location(l_proc, 15);
399     --
400     --
401     -- Validate the datetrack mode mode getting the validation start
402     -- and end dates for the specified datetrack operation.
403     --
404     dt_api.validate_dt_mode
405 	(p_effective_date	   => p_effective_date,
406 	 p_datetrack_mode	   => p_datetrack_mode,
407 	 p_base_table_name	   => 'ben_ELIG_GNDR_PRTE_f',
408 	 p_base_key_column	   => 'ELIG_GNDR_PRTE_id',
409 	 p_base_key_value 	   => p_ELIG_GNDR_PRTE_id,
410 
411          p_enforce_foreign_locking => true,
415     --
412 	 p_validation_start_date   => l_validation_start_date,
413  	 p_validation_end_date	   => l_validation_end_date);
414   Else
416     -- We are doing a datetrack 'INSERT' which is illegal within this
417     -- procedure therefore we must error (note: to lck on insert the
418     -- private procedure ins_lck should be called).
419     --
420     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
421     fnd_message.set_token('PROCEDURE', l_proc);
422     fnd_message.set_token('STEP','20');
423     fnd_message.raise_error;
424   End If;
425   --
426   -- Set the validation start and end date OUT arguments
427   --
428   p_validation_start_date := l_validation_start_date;
429   p_validation_end_date   := l_validation_end_date;
430   --
431   hr_utility.set_location(' Leaving:'||l_proc, 30);
432 --
433 -- We need to trap the ORA LOCK exception
434 --
435 Exception
436   When HR_Api.Object_Locked then
437     --
438     -- The object is locked therefore we need to supply a meaningful
439     -- error message.
440     --
441     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
442     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_GNDR_PRTE_f');
443     fnd_message.raise_error;
444   When l_object_invalid then
445     --
446     -- The object doesn't exist or is invalid
447     --
448     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
449     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_GNDR_PRTE_f');
450     fnd_message.raise_error;
451 End lck;
452 --
453 -- ----------------------------------------------------------------------------
454 -- |-----------------------------< convert_args >-----------------------------|
455 -- ----------------------------------------------------------------------------
456 Function convert_args
457 	(
458 	p_ELIG_GNDR_PRTE_id             in number,
459 	p_effective_start_date          in date,
460 	p_effective_end_date            in date,
461 	p_excld_flag                    in varchar2,
462 	p_sex                           in varchar2,
463 	p_eligy_prfl_id                 in number,
464 	p_business_group_id             in number,
465 	p_egn_attribute_category        in varchar2,
466 	p_egn_attribute1                in varchar2,
467 	p_egn_attribute2                in varchar2,
468 	p_egn_attribute3                in varchar2,
469 	p_egn_attribute4                in varchar2,
470 	p_egn_attribute5                in varchar2,
471 	p_egn_attribute6                in varchar2,
472 	p_egn_attribute7                in varchar2,
473 	p_egn_attribute8                in varchar2,
474 	p_egn_attribute9                in varchar2,
475 	p_egn_attribute10               in varchar2,
476 	p_egn_attribute11               in varchar2,
477 	p_egn_attribute12               in varchar2,
478 	p_egn_attribute13               in varchar2,
479 	p_egn_attribute14               in varchar2,
480 	p_egn_attribute15               in varchar2,
481 	p_egn_attribute16               in varchar2,
482 	p_egn_attribute17               in varchar2,
483 	p_egn_attribute18               in varchar2,
484 	p_egn_attribute19               in varchar2,
485 	p_egn_attribute20               in varchar2,
486 	p_egn_attribute21               in varchar2,
487 	p_egn_attribute22               in varchar2,
488 	p_egn_attribute23               in varchar2,
489 	p_egn_attribute24               in varchar2,
490 	p_egn_attribute25               in varchar2,
491 	p_egn_attribute26               in varchar2,
492 	p_egn_attribute27               in varchar2,
493 	p_egn_attribute28               in varchar2,
494 	p_egn_attribute29               in varchar2,
495 	p_egn_attribute30               in varchar2,
496         p_ordr_num			in number,
497 	p_object_version_number         in number
498    ,p_criteria_score					in number
499  ,p_criteria_weight					in number
500 
501 	)
502 	Return g_rec_type is
503 --
504   l_rec	  g_rec_type;
505   l_proc  varchar2(72) := g_package||'convert_args';
506 --
507 Begin
508   --
509   hr_utility.set_location('Entering:'||l_proc, 5);
510   --
511   -- Convert arguments into local l_rec structure.
512   --
513   l_rec.ELIG_GNDR_PRTE_id                := p_ELIG_GNDR_PRTE_id;
514   l_rec.effective_start_date             := p_effective_start_date;
515   l_rec.effective_end_date               := p_effective_end_date;
516   l_rec.excld_flag                       := p_excld_flag;
517   l_rec.sex                              := p_sex;
518   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
519   l_rec.business_group_id                := p_business_group_id;
520   l_rec.egn_attribute_category           := p_egn_attribute_category;
521   l_rec.egn_attribute1                   := p_egn_attribute1;
522   l_rec.egn_attribute2                   := p_egn_attribute2;
523   l_rec.egn_attribute3                   := p_egn_attribute3;
524   l_rec.egn_attribute4                   := p_egn_attribute4;
525   l_rec.egn_attribute5                   := p_egn_attribute5;
526   l_rec.egn_attribute6                   := p_egn_attribute6;
527   l_rec.egn_attribute7                   := p_egn_attribute7;
528   l_rec.egn_attribute8                   := p_egn_attribute8;
529   l_rec.egn_attribute9                   := p_egn_attribute9;
530   l_rec.egn_attribute10                  := p_egn_attribute10;
531   l_rec.egn_attribute11                  := p_egn_attribute11;
532   l_rec.egn_attribute12                  := p_egn_attribute12;
533   l_rec.egn_attribute13                  := p_egn_attribute13;
534   l_rec.egn_attribute14                  := p_egn_attribute14;
535   l_rec.egn_attribute15                  := p_egn_attribute15;
536   l_rec.egn_attribute16                  := p_egn_attribute16;
537   l_rec.egn_attribute17                  := p_egn_attribute17;
538   l_rec.egn_attribute18                  := p_egn_attribute18;
539   l_rec.egn_attribute19                  := p_egn_attribute19;
540   l_rec.egn_attribute20                  := p_egn_attribute20;
541   l_rec.egn_attribute21                  := p_egn_attribute21;
542   l_rec.egn_attribute22                  := p_egn_attribute22;
543   l_rec.egn_attribute23                  := p_egn_attribute23;
544   l_rec.egn_attribute24                  := p_egn_attribute24;
545   l_rec.egn_attribute25                  := p_egn_attribute25;
546   l_rec.egn_attribute26                  := p_egn_attribute26;
547   l_rec.egn_attribute27                  := p_egn_attribute27;
548   l_rec.egn_attribute28                  := p_egn_attribute28;
549   l_rec.egn_attribute29                  := p_egn_attribute29;
550   l_rec.egn_attribute30                  := p_egn_attribute30;
551   l_rec.ordr_num                         := p_ordr_num;
552   l_rec.object_version_number            := p_object_version_number;
553   l_rec.criteria_score					 := p_criteria_score;
554  l_rec.criteria_weight					 := p_criteria_weight;
555 
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_egn_shd;