DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EHC_SHD

Source


1 Package Body ben_ehc_shd as
2 /* $Header: beehcrhi.pkb 120.0 2005/05/28 02:14:11 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ehc_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 --
28 Procedure constraint_error
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
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_HLTH_CVG_PRTE_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_HLTH_CVG_PRTE_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','7');
45     fnd_message.raise_error;
46   ElsIf (p_constraint_name = 'BEN_ELIG_HLTH_CVG_PRTE_PK') Then
47     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('STEP','10');
50     fnd_message.raise_error;
51   Else
52     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
53     fnd_message.set_token('PROCEDURE', l_proc);
54     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
55     fnd_message.raise_error;
56   End If;
57   --
58   hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65   (p_effective_date		in date,
66    p_ELIG_HLTH_CVG_PRTE_id	in number,
67    p_object_version_number	in number
68   ) Return Boolean Is
69 --
70   --
71   -- Cursor selects the 'current' row from the HR Schema
72   --
73   Cursor C_Sel1 is
74     select
75 	ELIG_HLTH_CVG_PRTE_id,
76 	effective_start_date,
77 	effective_end_date,
78 	excld_flag,
79 	ordr_num,
80 	pl_typ_opt_typ_id,
81 	oipl_id,
82 	eligy_prfl_id,
83 	business_group_id,
84 	ehc_attribute_category,
85 	ehc_attribute1,
86 	ehc_attribute2,
87 	ehc_attribute3,
88 	ehc_attribute4,
89 	ehc_attribute5,
90 	ehc_attribute6,
91 	ehc_attribute7,
92 	ehc_attribute8,
93 	ehc_attribute9,
94 	ehc_attribute10,
95 	ehc_attribute11,
96 	ehc_attribute12,
97 	ehc_attribute13,
98 	ehc_attribute14,
99 	ehc_attribute15,
100 	ehc_attribute16,
101 	ehc_attribute17,
102 	ehc_attribute18,
103 	ehc_attribute19,
104 	ehc_attribute20,
105 	ehc_attribute21,
106 	ehc_attribute22,
107 	ehc_attribute23,
108 	ehc_attribute24,
109 	ehc_attribute25,
110 	ehc_attribute26,
111 	ehc_attribute27,
112 	ehc_attribute28,
113 	ehc_attribute29,
114 	ehc_attribute30,
115 	object_version_number
116     from	ben_ELIG_HLTH_CVG_PRTE_f
117     where	ELIG_HLTH_CVG_PRTE_id = p_ELIG_HLTH_CVG_PRTE_id
118     and		p_effective_date
119     between	effective_start_date and effective_end_date;
120 --
121   l_proc	varchar2(72)	:= g_package||'api_updating';
122   l_fct_ret	boolean;
123 --
124 Begin
125   hr_utility.set_location('Entering:'||l_proc, 5);
126   --
127   If (p_effective_date is null or
128       p_ELIG_HLTH_CVG_PRTE_id is null or
129       p_object_version_number is null) Then
130     --
131     -- One of the primary key arguments is null therefore we must
132     -- set the returning function value to false
133     --
134     l_fct_ret := false;
135   Else
136     If (p_ELIG_HLTH_CVG_PRTE_id = g_old_rec.ELIG_HLTH_CVG_PRTE_id and
137         p_object_version_number = g_old_rec.object_version_number) Then
138       hr_utility.set_location(l_proc, 10);
139       --
140       -- The g_old_rec is current therefore we must
141       -- set the returning function to true
142       --
143       l_fct_ret := true;
144     Else
145       --
146       -- Select the current row
147       --
148       Open C_Sel1;
149       Fetch C_Sel1 Into g_old_rec;
150       If C_Sel1%notfound Then
151         Close C_Sel1;
152         --
153         -- The primary key is invalid therefore we must error
154         --
155         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
156         fnd_message.raise_error;
157       End If;
158       Close C_Sel1;
159       If (p_object_version_number <> g_old_rec.object_version_number) Then
160         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
161         fnd_message.raise_error;
162       End If;
163       hr_utility.set_location(l_proc, 15);
164       l_fct_ret := true;
165     End If;
166   End If;
167   hr_utility.set_location(' Leaving:'||l_proc, 20);
168   Return (l_fct_ret);
169 --
170 End api_updating;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |--------------------------< find_dt_del_modes >---------------------------|
174 -- ----------------------------------------------------------------------------
175 Procedure find_dt_del_modes
176 	(p_effective_date	in  date,
177 	 p_base_key_value	in  number,
178 	 p_zap		 out nocopy boolean,
179 	 p_delete	 out nocopy boolean,
180 	 p_future_change out nocopy boolean,
181 	 p_delete_next_change out nocopy boolean) is
182 --
183   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
184 --
185   --
186   --
187 --
188 Begin
189   hr_utility.set_location('Entering:'||l_proc, 5);
190     --
191   --
192   -- Call the corresponding datetrack api
193   --
194   dt_api.find_dt_del_modes
195 	(p_effective_date	=> p_effective_date,
196 	 p_base_table_name	=> 'ben_ELIG_HLTH_CVG_PRTE_f',
197 	 p_base_key_column	=> 'ELIG_HLTH_CVG_PRTE_id',
198 	 p_base_key_value	=> p_base_key_value,
199 	 p_zap			=> p_zap,
200 	 p_delete		=> p_delete,
201 	 p_future_change	=> p_future_change,
202 	 p_delete_next_change	=> p_delete_next_change);
203   --
204   hr_utility.set_location(' Leaving:'||l_proc, 10);
205 End find_dt_del_modes;
206 --
207 -- ----------------------------------------------------------------------------
208 -- |--------------------------< find_dt_upd_modes >---------------------------|
209 -- ----------------------------------------------------------------------------
210 Procedure find_dt_upd_modes
211 	(p_effective_date	in  date,
212 	 p_base_key_value	in  number,
213 	 p_correction	 out nocopy boolean,
214 	 p_update	 out nocopy boolean,
215 	 p_update_override out nocopy boolean,
216 	 p_update_change_insert out nocopy boolean) is
217 --
218   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
219 --
220 Begin
221   hr_utility.set_location('Entering:'||l_proc, 5);
222   --
223   -- Call the corresponding datetrack api
224   --
225   dt_api.find_dt_upd_modes
226 	(p_effective_date	=> p_effective_date,
227 	 p_base_table_name	=> 'ben_ELIG_HLTH_CVG_PRTE_f',
228 	 p_base_key_column	=> 'ELIG_HLTH_CVG_PRTE_id',
229 	 p_base_key_value	=> p_base_key_value,
230 	 p_correction		=> p_correction,
231 	 p_update		=> p_update,
232 	 p_update_override	=> p_update_override,
233 	 p_update_change_insert	=> p_update_change_insert);
234   --
235   hr_utility.set_location(' Leaving:'||l_proc, 10);
236 End find_dt_upd_modes;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |------------------------< upd_effective_end_date >------------------------|
240 -- ----------------------------------------------------------------------------
241 Procedure upd_effective_end_date
242 	(p_effective_date		in date,
243 	 p_base_key_value		in number,
244 	 p_new_effective_end_date	in date,
245 	 p_validation_start_date	in date,
246 	 p_validation_end_date		in date,
247          p_object_version_number       out nocopy number) is
248 --
249   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
250   l_object_version_number number;
251 --
252 Begin
253   hr_utility.set_location('Entering:'||l_proc, 5);
254   --
255   -- Because we are updating a row we must get the next object
256   -- version number.
257   --
258   l_object_version_number :=
259     dt_api.get_object_version_number
260 	(p_base_table_name	=> 'ben_ELIG_HLTH_CVG_PRTE_f',
261 	 p_base_key_column	=> 'ELIG_HLTH_CVG_PRTE_id',
262 	 p_base_key_value	=> p_base_key_value);
263   --
264   hr_utility.set_location(l_proc, 10);
265   g_api_dml := true;  -- Set the api dml status
266   --
267   -- Update the specified datetrack row setting the effective
268   -- end date to the specified new effective end date.
269   --
270   update  ben_ELIG_HLTH_CVG_PRTE_f t
271   set	  t.effective_end_date	  = p_new_effective_end_date,
272 	  t.object_version_number = l_object_version_number
273   where	  t.ELIG_HLTH_CVG_PRTE_id = p_base_key_value
274   and	  p_effective_date
275   between t.effective_start_date and t.effective_end_date;
276   --
277   g_api_dml := false;   -- Unset the api dml status
278   p_object_version_number := l_object_version_number;
279   hr_utility.set_location(' Leaving:'||l_proc, 15);
280 --
281 Exception
282   When Others Then
283     g_api_dml := false;   -- Unset the api dml status
284     Raise;
285 End upd_effective_end_date;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< lck >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure lck
291 	(p_effective_date	 in  date,
292 	 p_datetrack_mode	 in  varchar2,
293 	 p_ELIG_HLTH_CVG_PRTE_id in  number,
294 	 p_object_version_number in  number,
295 	 p_validation_start_date out nocopy date,
296 	 p_validation_end_date	 out nocopy date) is
297 --
298   l_proc		  varchar2(72) := g_package||'lck';
299   l_validation_start_date date;
300   l_validation_end_date	  date;
301   l_object_invalid 	  exception;
302   l_argument		  varchar2(30);
303   --
304   -- Cursor C_Sel1 selects the current locked row as of session date
305   -- ensuring that the object version numbers match.
306   --
307   Cursor C_Sel1 is
308     select
309 	ELIG_HLTH_CVG_PRTE_id,
310 	effective_start_date,
311 	effective_end_date,
312 	excld_flag,
313 	ordr_num,
314 	pl_typ_opt_typ_id,
315 	oipl_id,
316 	eligy_prfl_id,
317 	business_group_id,
318 	ehc_attribute_category,
319 	ehc_attribute1,
320 	ehc_attribute2,
321 	ehc_attribute3,
322 	ehc_attribute4,
323 	ehc_attribute5,
324 	ehc_attribute6,
325 	ehc_attribute7,
326 	ehc_attribute8,
327 	ehc_attribute9,
328 	ehc_attribute10,
329 	ehc_attribute11,
330 	ehc_attribute12,
331 	ehc_attribute13,
332 	ehc_attribute14,
333 	ehc_attribute15,
334 	ehc_attribute16,
335 	ehc_attribute17,
336 	ehc_attribute18,
337 	ehc_attribute19,
338 	ehc_attribute20,
339 	ehc_attribute21,
340 	ehc_attribute22,
341 	ehc_attribute23,
342 	ehc_attribute24,
343 	ehc_attribute25,
344 	ehc_attribute26,
345 	ehc_attribute27,
346 	ehc_attribute28,
347 	ehc_attribute29,
348 	ehc_attribute30,
349 	object_version_number
350     from    ben_ELIG_HLTH_CVG_PRTE_f
351     where   ELIG_HLTH_CVG_PRTE_id = p_ELIG_HLTH_CVG_PRTE_id
352     and	    p_effective_date
353     between effective_start_date and effective_end_date
354     for update nowait;
355   --
356   --
357   --
358 Begin
359   hr_utility.set_location('Entering:'||l_proc, 5);
360   --
361   -- Ensure that all the mandatory arguments are not null
362   --
363   hr_api.mandatory_arg_error(p_api_name       => l_proc,
364                              p_argument       => 'effective_date',
365                              p_argument_value => p_effective_date);
366   --
367   hr_api.mandatory_arg_error(p_api_name       => l_proc,
368                              p_argument       => 'datetrack_mode',
369                              p_argument_value => p_datetrack_mode);
370   --
371   hr_api.mandatory_arg_error(p_api_name       => l_proc,
372                              p_argument       => 'ELIG_HLTH_CVG_PRTE_id',
373                              p_argument_value => p_ELIG_HLTH_CVG_PRTE_id);
374   --
375   hr_api.mandatory_arg_error(p_api_name       => l_proc,
376                              p_argument       => 'object_version_number',
377                              p_argument_value => p_object_version_number);
378   --
379   -- Check to ensure the datetrack mode is not INSERT.
380   --
381   If (p_datetrack_mode <> 'INSERT') then
382     --
383     -- We must select and lock the current row.
384     --
385     Open  C_Sel1;
386     Fetch C_Sel1 Into g_old_rec;
387     If C_Sel1%notfound then
388       Close C_Sel1;
389       --
390       -- The primary key is invalid therefore we must error
391       --
392       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
393       fnd_message.raise_error;
394     End If;
395     Close C_Sel1;
396     If (p_object_version_number <> g_old_rec.object_version_number) Then
397         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
398         fnd_message.raise_error;
399       End If;
400     hr_utility.set_location(l_proc, 15);
401     --
402     --
403     -- Validate the datetrack mode mode getting the validation start
404     -- and end dates for the specified datetrack operation.
405     --
406     dt_api.validate_dt_mode
407 	(p_effective_date	   => p_effective_date,
408 	 p_datetrack_mode	   => p_datetrack_mode,
409 	 p_base_table_name	   => 'ben_ELIG_HLTH_CVG_PRTE_f',
410 	 p_base_key_column	   => 'ELIG_HLTH_CVG_PRTE_id',
411 	 p_base_key_value 	   => p_ELIG_HLTH_CVG_PRTE_id,
412 
413          p_enforce_foreign_locking => true,
417     --
414 	 p_validation_start_date   => l_validation_start_date,
415  	 p_validation_end_date	   => l_validation_end_date);
416   Else
418     -- We are doing a datetrack 'INSERT' which is illegal within this
419     -- procedure therefore we must error (note: to lck on insert the
420     -- private procedure ins_lck should be called).
421     --
422     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
423     fnd_message.set_token('PROCEDURE', l_proc);
424     fnd_message.set_token('STEP','20');
425     fnd_message.raise_error;
426   End If;
427   --
428   -- Set the validation start and end date OUT arguments
429   --
430   p_validation_start_date := l_validation_start_date;
431   p_validation_end_date   := l_validation_end_date;
432   --
433   hr_utility.set_location(' Leaving:'||l_proc, 30);
434 --
435 -- We need to trap the ORA LOCK exception
436 --
437 Exception
438   When HR_Api.Object_Locked then
439     --
440     -- The object is locked therefore we need to supply a meaningful
441     -- error message.
442     --
443     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
444     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_HLTH_CVG_PRTE_f');
445     fnd_message.raise_error;
446   When l_object_invalid then
447     --
448     -- The object doesn't exist or is invalid
449     --
450     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
451     fnd_message.set_token('TABLE_NAME', 'ben_ELIG_HLTH_CVG_PRTE_f');
452     fnd_message.raise_error;
453 End lck;
454 --
455 -- ----------------------------------------------------------------------------
456 -- |-----------------------------< convert_args >-----------------------------|
457 -- ----------------------------------------------------------------------------
458 Function convert_args
459 	(
460 	p_ELIG_HLTH_CVG_PRTE_id         in number,
461 	p_effective_start_date          in date,
462 	p_effective_end_date            in date,
463 	p_excld_flag                    in varchar2,
464 	p_ordr_num                      in number,
465 	p_pl_typ_opt_typ_id             in number,
466 	p_oipl_id                       in number,
467 	p_eligy_prfl_id                 in number,
468 	p_business_group_id             in number,
469 	p_ehc_attribute_category        in varchar2,
470 	p_ehc_attribute1                in varchar2,
471 	p_ehc_attribute2                in varchar2,
472 	p_ehc_attribute3                in varchar2,
473 	p_ehc_attribute4                in varchar2,
474 	p_ehc_attribute5                in varchar2,
475 	p_ehc_attribute6                in varchar2,
476 	p_ehc_attribute7                in varchar2,
477 	p_ehc_attribute8                in varchar2,
478 	p_ehc_attribute9                in varchar2,
479 	p_ehc_attribute10               in varchar2,
480 	p_ehc_attribute11               in varchar2,
481 	p_ehc_attribute12               in varchar2,
482 	p_ehc_attribute13               in varchar2,
483 	p_ehc_attribute14               in varchar2,
484 	p_ehc_attribute15               in varchar2,
485 	p_ehc_attribute16               in varchar2,
486 	p_ehc_attribute17               in varchar2,
487 	p_ehc_attribute18               in varchar2,
488 	p_ehc_attribute19               in varchar2,
489 	p_ehc_attribute20               in varchar2,
490 	p_ehc_attribute21               in varchar2,
491 	p_ehc_attribute22               in varchar2,
492 	p_ehc_attribute23               in varchar2,
493 	p_ehc_attribute24               in varchar2,
494 	p_ehc_attribute25               in varchar2,
495 	p_ehc_attribute26               in varchar2,
496 	p_ehc_attribute27               in varchar2,
497 	p_ehc_attribute28               in varchar2,
498 	p_ehc_attribute29               in varchar2,
499 	p_ehc_attribute30               in varchar2,
500 	p_object_version_number         in number
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_HLTH_CVG_PRTE_id            := p_ELIG_HLTH_CVG_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.ordr_num                         := p_ordr_num;
518   l_rec.pl_typ_opt_typ_id                := p_pl_typ_opt_typ_id;
519   l_rec.oipl_id                          := p_oipl_id;
520   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
521   l_rec.business_group_id                := p_business_group_id;
522   l_rec.ehc_attribute_category           := p_ehc_attribute_category;
523   l_rec.ehc_attribute1                   := p_ehc_attribute1;
524   l_rec.ehc_attribute2                   := p_ehc_attribute2;
525   l_rec.ehc_attribute3                   := p_ehc_attribute3;
526   l_rec.ehc_attribute4                   := p_ehc_attribute4;
527   l_rec.ehc_attribute5                   := p_ehc_attribute5;
528   l_rec.ehc_attribute6                   := p_ehc_attribute6;
529   l_rec.ehc_attribute7                   := p_ehc_attribute7;
530   l_rec.ehc_attribute8                   := p_ehc_attribute8;
531   l_rec.ehc_attribute9                   := p_ehc_attribute9;
532   l_rec.ehc_attribute10                  := p_ehc_attribute10;
533   l_rec.ehc_attribute11                  := p_ehc_attribute11;
534   l_rec.ehc_attribute12                  := p_ehc_attribute12;
535   l_rec.ehc_attribute13                  := p_ehc_attribute13;
536   l_rec.ehc_attribute14                  := p_ehc_attribute14;
537   l_rec.ehc_attribute15                  := p_ehc_attribute15;
538   l_rec.ehc_attribute16                  := p_ehc_attribute16;
539   l_rec.ehc_attribute17                  := p_ehc_attribute17;
540   l_rec.ehc_attribute18                  := p_ehc_attribute18;
541   l_rec.ehc_attribute19                  := p_ehc_attribute19;
542   l_rec.ehc_attribute20                  := p_ehc_attribute20;
543   l_rec.ehc_attribute21                  := p_ehc_attribute21;
544   l_rec.ehc_attribute22                  := p_ehc_attribute22;
545   l_rec.ehc_attribute23                  := p_ehc_attribute23;
546   l_rec.ehc_attribute24                  := p_ehc_attribute24;
547   l_rec.ehc_attribute25                  := p_ehc_attribute25;
548   l_rec.ehc_attribute26                  := p_ehc_attribute26;
549   l_rec.ehc_attribute27                  := p_ehc_attribute27;
550   l_rec.ehc_attribute28                  := p_ehc_attribute28;
551   l_rec.ehc_attribute29                  := p_ehc_attribute29;
552   l_rec.ehc_attribute30                  := p_ehc_attribute30;
553   l_rec.object_version_number            := p_object_version_number;
554   --
555   -- Return the plsql record structure.
556   --
557   hr_utility.set_location(' Leaving:'||l_proc, 10);
558   Return(l_rec);
559 --
560 End convert_args;
561 --
562 end ben_ehc_shd;