DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PPR_SHD

Source


1 Package Body ben_ppr_shd as
2 /* $Header: bepprrhi.pkb 120.0.12010000.2 2008/08/05 15:17:03 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_ppr_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_PRMRY_CARE_PRVDR_F_FK3') 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_PRMRY_CARE_PRVDR_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_prmry_care_prvdr_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   prmry_care_prvdr_id,
71   effective_start_date,
72   effective_end_date,
73   prmry_care_prvdr_typ_cd,
74   name,
75   ext_ident,
76   prtt_enrt_rslt_id,
77   elig_cvrd_dpnt_id,
78   business_group_id,
79   ppr_attribute_category,
80   ppr_attribute1,
81   ppr_attribute2,
82   ppr_attribute3,
83   ppr_attribute4,
84   ppr_attribute5,
85   ppr_attribute6,
86   ppr_attribute7,
87   ppr_attribute8,
88   ppr_attribute9,
89   ppr_attribute10,
90   ppr_attribute11,
91   ppr_attribute12,
92   ppr_attribute13,
93   ppr_attribute14,
94   ppr_attribute15,
95   ppr_attribute16,
96   ppr_attribute17,
97   ppr_attribute18,
98   ppr_attribute19,
99   ppr_attribute20,
100   ppr_attribute21,
101   ppr_attribute22,
102   ppr_attribute23,
103   ppr_attribute24,
104   ppr_attribute25,
105   ppr_attribute26,
106   ppr_attribute27,
107   ppr_attribute28,
108   ppr_attribute29,
109   ppr_attribute30,
110   request_id,
111   program_application_id,
112   program_id,
113   program_update_date,
114   object_version_number
115     from  ben_prmry_care_prvdr_f
116     where prmry_care_prvdr_id = p_prmry_care_prvdr_id
117     and   p_effective_date
118     between effective_start_date and effective_end_date;
119 --
120   l_proc  varchar2(72)  := g_package||'api_updating';
121   l_fct_ret boolean;
122 --
123 Begin
124   hr_utility.set_location('Entering:'||l_proc, 5);
125   --
126   If (p_effective_date is null or
127       p_prmry_care_prvdr_id is null or
128       p_object_version_number is null) Then
129     --
130     -- One of the primary key arguments is null therefore we must
131     -- set the returning function value to false
132     --
133     l_fct_ret := false;
134   Else
135     If (p_prmry_care_prvdr_id = g_old_rec.prmry_care_prvdr_id and
136         p_object_version_number = g_old_rec.object_version_number) Then
137       hr_utility.set_location(l_proc, 10);
138       --
139       -- The g_old_rec is current therefore we must
140       -- set the returning function to true
141       --
142       l_fct_ret := true;
143     Else
144       --
145       -- Select the current row
146       --
147       Open C_Sel1;
148       Fetch C_Sel1 Into g_old_rec;
149       If C_Sel1%notfound Then
150         Close C_Sel1;
151         --
152         -- The primary key is invalid therefore we must error
153         --
154         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
155         fnd_message.raise_error;
156       End If;
157       Close C_Sel1;
158       If (p_object_version_number <> g_old_rec.object_version_number) Then
159         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
160         fnd_message.raise_error;
161       End If;
162       hr_utility.set_location(l_proc, 15);
163       l_fct_ret := true;
164     End If;
165   End If;
166   hr_utility.set_location(' Leaving:'||l_proc, 20);
167   Return (l_fct_ret);
168 --
169 End api_updating;
170 --
171 -- ----------------------------------------------------------------------------
172 -- |--------------------------< find_dt_del_modes >---------------------------|
173 -- ----------------------------------------------------------------------------
174 Procedure find_dt_del_modes
175   (p_effective_date in  date,
176    p_base_key_value in  number,
177    p_zap     out nocopy boolean,
178    p_delete  out nocopy boolean,
179    p_future_change out nocopy boolean,
180    p_delete_next_change out nocopy boolean) is
181 --
182   l_proc    varchar2(72)  := g_package||'find_dt_del_modes';
183 --
184   l_parent_key_value1 number;
185   l_parent_key_value2 number;
186   --
187   Cursor C_Sel1 Is
188     select  t.elig_cvrd_dpnt_id,
189       t.prtt_enrt_rslt_id
190     from    ben_prmry_care_prvdr_f t
191     where   t.prmry_care_prvdr_id = p_base_key_value
192     and     p_effective_date
193     between t.effective_start_date and t.effective_end_date;
194 --
195 Begin
196   hr_utility.set_location('Entering:'||l_proc, 5);
197   Open  C_Sel1;
198   Fetch C_Sel1 Into l_parent_key_value1,
199         l_parent_key_value2;
200   If C_Sel1%notfound then
201     Close C_Sel1;
202     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
203     fnd_message.set_token('PROCEDURE', l_proc);
204     fnd_message.set_token('STEP','10');
205     fnd_message.raise_error;
206   End If;
207   Close C_Sel1;
208   --
209   -- Call the corresponding datetrack api
210   --
211   dt_api.find_dt_del_modes
212   (p_effective_date => p_effective_date,
213    p_base_table_name  => 'ben_prmry_care_prvdr_f',
214    p_base_key_column  => 'prmry_care_prvdr_id',
215    p_base_key_value => p_base_key_value,
216    p_parent_table_name1 => 'ben_elig_cvrd_dpnt_f',
217    p_parent_key_column1 => 'elig_cvrd_dpnt_id',
218    p_parent_key_value1  => l_parent_key_value1,
219    p_parent_table_name2 => 'ben_prtt_enrt_rslt_f',
220    p_parent_key_column2 => 'prtt_enrt_rslt_id',
221    p_parent_key_value2  => l_parent_key_value2,
222    p_zap      => p_zap,
223    p_delete   => p_delete,
224    p_future_change  => p_future_change,
225    p_delete_next_change => p_delete_next_change);
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End find_dt_del_modes;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |--------------------------< find_dt_upd_modes >---------------------------|
232 -- ----------------------------------------------------------------------------
233 Procedure find_dt_upd_modes
234   (p_effective_date in  date,
235    p_base_key_value in  number,
236    p_correction  out nocopy boolean,
237    p_update  out nocopy boolean,
238    p_update_override out nocopy boolean,
239    p_update_change_insert out nocopy boolean) is
240 --
241   l_proc  varchar2(72) := g_package||'find_dt_upd_modes';
242 --
243 Begin
244   hr_utility.set_location('Entering:'||l_proc, 5);
245   --
246   -- Call the corresponding datetrack api
247   --
248   dt_api.find_dt_upd_modes
249   (p_effective_date => p_effective_date,
250    p_base_table_name  => 'ben_prmry_care_prvdr_f',
251    p_base_key_column  => 'prmry_care_prvdr_id',
252    p_base_key_value => p_base_key_value,
253    p_correction   => p_correction,
254    p_update   => p_update,
255    p_update_override  => p_update_override,
256    p_update_change_insert => p_update_change_insert);
257   --
258   hr_utility.set_location(' Leaving:'||l_proc, 10);
259 End find_dt_upd_modes;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |------------------------< upd_effective_end_date >------------------------|
263 -- ----------------------------------------------------------------------------
264 Procedure upd_effective_end_date
265   (p_effective_date   in date,
266    p_base_key_value   in number,
267    p_new_effective_end_date in date,
268    p_validation_start_date  in date,
269    p_validation_end_date    in date,
270          p_object_version_number       out nocopy number) is
271 --
272   l_proc      varchar2(72) := g_package||'upd_effective_end_date';
273   l_object_version_number number;
274 --
275 Begin
276   hr_utility.set_location('Entering:'||l_proc, 5);
277   --
278   -- Because we are updating a row we must get the next object
279   -- version number.
280   --
281   l_object_version_number :=
282     dt_api.get_object_version_number
283   (p_base_table_name  => 'ben_prmry_care_prvdr_f',
284    p_base_key_column  => 'prmry_care_prvdr_id',
285    p_base_key_value => p_base_key_value);
286   --
287   hr_utility.set_location(l_proc, 10);
288   g_api_dml := true;  -- Set the api dml status
289   --
290   -- Update the specified datetrack row setting the effective
291   -- end date to the specified new effective end date.
292   --
293   update  ben_prmry_care_prvdr_f t
294   set   t.effective_end_date    = p_new_effective_end_date,
295     t.object_version_number = l_object_version_number
296   where   t.prmry_care_prvdr_id   = p_base_key_value
297   and   p_effective_date
298   between t.effective_start_date and t.effective_end_date;
299   --
300   g_api_dml := false;   -- Unset the api dml status
301   p_object_version_number := l_object_version_number;
302   hr_utility.set_location(' Leaving:'||l_proc, 15);
303 --
304 Exception
305   When Others Then
306     g_api_dml := false;   -- Unset the api dml status
307     Raise;
308 End upd_effective_end_date;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------------< lck >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure lck
314   (p_effective_date  in  date,
315    p_datetrack_mode  in  varchar2,
316    p_prmry_care_prvdr_id   in  number,
317    p_object_version_number in  number,
318    p_validation_start_date out nocopy date,
319    p_validation_end_date   out nocopy date) is
320 --
321   l_proc      varchar2(72) := g_package||'lck';
322   l_validation_start_date date;
323   l_validation_end_date   date;
324   l_object_invalid    exception;
325   l_argument      varchar2(30);
326   --
327   -- Cursor C_Sel1 selects the current locked row as of session date
328   -- ensuring that the object version numbers match.
329   --
330   Cursor C_Sel1 is
331     select
332   prmry_care_prvdr_id,
333   effective_start_date,
334   effective_end_date,
335   prmry_care_prvdr_typ_cd,
336   name,
337   ext_ident,
338   prtt_enrt_rslt_id,
339   elig_cvrd_dpnt_id,
340   business_group_id,
341   ppr_attribute_category,
342   ppr_attribute1,
343   ppr_attribute2,
344   ppr_attribute3,
345   ppr_attribute4,
346   ppr_attribute5,
347   ppr_attribute6,
348   ppr_attribute7,
349   ppr_attribute8,
350   ppr_attribute9,
351   ppr_attribute10,
352   ppr_attribute11,
353   ppr_attribute12,
354   ppr_attribute13,
355   ppr_attribute14,
356   ppr_attribute15,
357   ppr_attribute16,
358   ppr_attribute17,
359   ppr_attribute18,
360   ppr_attribute19,
361   ppr_attribute20,
362   ppr_attribute21,
363   ppr_attribute22,
364   ppr_attribute23,
365   ppr_attribute24,
366   ppr_attribute25,
367   ppr_attribute26,
368   ppr_attribute27,
369   ppr_attribute28,
370   ppr_attribute29,
371   ppr_attribute30,
372   request_id,
373   program_application_id,
374   program_id,
375   program_update_date,
376   object_version_number
377     from    ben_prmry_care_prvdr_f
378     where   prmry_care_prvdr_id         = p_prmry_care_prvdr_id
379     and     p_effective_date
380     between effective_start_date and effective_end_date
381     for update nowait;
382   --
383   --
384   --
385 Begin
386   hr_utility.set_location('Entering:'||l_proc, 5);
387   --
388   -- Ensure that all the mandatory arguments are not null
389   --
390   hr_api.mandatory_arg_error(p_api_name       => l_proc,
391                              p_argument       => 'effective_date',
392                              p_argument_value => p_effective_date);
393   --
394   hr_api.mandatory_arg_error(p_api_name       => l_proc,
395                              p_argument       => 'datetrack_mode',
396                              p_argument_value => p_datetrack_mode);
397   --
398   hr_api.mandatory_arg_error(p_api_name       => l_proc,
399                              p_argument       => 'prmry_care_prvdr_id',
400                              p_argument_value => p_prmry_care_prvdr_id);
401   --
402   hr_api.mandatory_arg_error(p_api_name       => l_proc,
403                              p_argument       => 'object_version_number',
404                              p_argument_value => p_object_version_number);
405   --
406   -- Check to ensure the datetrack mode is not INSERT.
407   --
408   If (p_datetrack_mode <> 'INSERT') then
409     --
410     -- We must select and lock the current row.
411     --
415       Close C_Sel1;
412     Open  C_Sel1;
413     Fetch C_Sel1 Into g_old_rec;
414     If C_Sel1%notfound then
416       --
417       -- The primary key is invalid therefore we must error
418       --
419       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
420       fnd_message.raise_error;
421     End If;
422     Close C_Sel1;
423     If (p_object_version_number <> g_old_rec.object_version_number) Then
424         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
425         fnd_message.raise_error;
426       End If;
427     hr_utility.set_location(l_proc, 15);
428     --
429     --
430     -- Validate the datetrack mode mode getting the validation start
431     -- and end dates for the specified datetrack operation.
432     --
433     dt_api.validate_dt_mode
434   (p_effective_date    => p_effective_date,
435    p_datetrack_mode    => p_datetrack_mode,
436    p_base_table_name     => 'ben_prmry_care_prvdr_f',
437    p_base_key_column     => 'prmry_care_prvdr_id',
438    p_base_key_value      => p_prmry_care_prvdr_id,
439    p_parent_table_name1      => 'ben_elig_cvrd_dpnt_f',
440    p_parent_key_column1      => 'elig_cvrd_dpnt_id',
441    p_parent_key_value1       => g_old_rec.elig_cvrd_dpnt_id,
442    p_parent_table_name2      => 'ben_prtt_enrt_rslt_f',
443    p_parent_key_column2      => 'prtt_enrt_rslt_id',
444    p_parent_key_value2       => g_old_rec.prtt_enrt_rslt_id,
445    p_enforce_foreign_locking => false , --true,
446    p_validation_start_date   => l_validation_start_date,
447    p_validation_end_date     => l_validation_end_date);
448   Else
449     --
450     -- We are doing a datetrack 'INSERT' which is illegal within this
451     -- procedure therefore we must error (note: to lck on insert the
452     -- private procedure ins_lck should be called).
453     --
454     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
455     fnd_message.set_token('PROCEDURE', l_proc);
456     fnd_message.set_token('STEP','20');
457     fnd_message.raise_error;
458   End If;
459   --
460   -- Set the validation start and end date OUT arguments
461   --
462   p_validation_start_date := l_validation_start_date;
463   p_validation_end_date   := l_validation_end_date;
464   --
465   hr_utility.set_location(' Leaving:'||l_proc, 30);
466 --
467 -- We need to trap the ORA LOCK exception
468 --
469 Exception
470   When HR_Api.Object_Locked then
471     --
472     -- The object is locked therefore we need to supply a meaningful
473     -- error message.
474     --
475     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
476     fnd_message.set_token('TABLE_NAME', 'ben_prmry_care_prvdr_f');
477     fnd_message.raise_error;
478   When l_object_invalid then
479     --
480     -- The object doesn't exist or is invalid
481     --
482     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
483     fnd_message.set_token('TABLE_NAME', 'ben_prmry_care_prvdr_f');
484     fnd_message.raise_error;
485 End lck;
486 --
487 -- ----------------------------------------------------------------------------
488 -- |-----------------------------< convert_args >-----------------------------|
489 -- ----------------------------------------------------------------------------
490 Function convert_args
491   (
492   p_prmry_care_prvdr_id           in number,
493   p_effective_start_date          in date,
494   p_effective_end_date            in date,
495   p_prmry_care_prvdr_typ_cd       in varchar2,
496   p_name                          in varchar2,
497   p_ext_ident                     in varchar2,
498   p_prtt_enrt_rslt_id             in number,
499   p_elig_cvrd_dpnt_id             in number,
500   p_business_group_id             in number,
501   p_ppr_attribute_category        in varchar2,
502   p_ppr_attribute1                in varchar2,
503   p_ppr_attribute2                in varchar2,
504   p_ppr_attribute3                in varchar2,
505   p_ppr_attribute4                in varchar2,
506   p_ppr_attribute5                in varchar2,
507   p_ppr_attribute6                in varchar2,
508   p_ppr_attribute7                in varchar2,
509   p_ppr_attribute8                in varchar2,
510   p_ppr_attribute9                in varchar2,
511   p_ppr_attribute10               in varchar2,
512   p_ppr_attribute11               in varchar2,
513   p_ppr_attribute12               in varchar2,
514   p_ppr_attribute13               in varchar2,
515   p_ppr_attribute14               in varchar2,
516   p_ppr_attribute15               in varchar2,
517   p_ppr_attribute16               in varchar2,
518   p_ppr_attribute17               in varchar2,
519   p_ppr_attribute18               in varchar2,
520   p_ppr_attribute19               in varchar2,
521   p_ppr_attribute20               in varchar2,
522   p_ppr_attribute21               in varchar2,
523   p_ppr_attribute22               in varchar2,
524   p_ppr_attribute23               in varchar2,
525   p_ppr_attribute24               in varchar2,
526   p_ppr_attribute25               in varchar2,
527   p_ppr_attribute26               in varchar2,
528   p_ppr_attribute27               in varchar2,
529   p_ppr_attribute28               in varchar2,
530   p_ppr_attribute29               in varchar2,
531   p_ppr_attribute30               in varchar2,
532   p_request_id                    in number,
533   p_program_application_id        in number,
534   p_program_id                    in number,
535   p_program_update_date           in date,
536   p_object_version_number         in number
537   )
538   Return g_rec_type is
539 --
540   l_rec   g_rec_type;
541   l_proc  varchar2(72) := g_package||'convert_args';
542 --
543 Begin
544   --
545   hr_utility.set_location('Entering:'||l_proc, 5);
546   --
547   -- Convert arguments into local l_rec structure.
548   --
549   l_rec.prmry_care_prvdr_id              := p_prmry_care_prvdr_id;
550   l_rec.effective_start_date             := p_effective_start_date;
551   l_rec.effective_end_date               := p_effective_end_date;
552   l_rec.name                             := p_name;
553   l_rec.ext_ident                        := p_ext_ident;
554   l_rec.prmry_care_prvdr_typ_cd          := p_prmry_care_prvdr_typ_cd;
555   l_rec.prtt_enrt_rslt_id                := p_prtt_enrt_rslt_id;
556   l_rec.elig_cvrd_dpnt_id                := p_elig_cvrd_dpnt_id;
557   l_rec.business_group_id                := p_business_group_id;
558   l_rec.ppr_attribute_category           := p_ppr_attribute_category;
559   l_rec.ppr_attribute1                   := p_ppr_attribute1;
560   l_rec.ppr_attribute2                   := p_ppr_attribute2;
561   l_rec.ppr_attribute3                   := p_ppr_attribute3;
562   l_rec.ppr_attribute4                   := p_ppr_attribute4;
563   l_rec.ppr_attribute5                   := p_ppr_attribute5;
564   l_rec.ppr_attribute6                   := p_ppr_attribute6;
565   l_rec.ppr_attribute7                   := p_ppr_attribute7;
566   l_rec.ppr_attribute8                   := p_ppr_attribute8;
567   l_rec.ppr_attribute9                   := p_ppr_attribute9;
568   l_rec.ppr_attribute10                  := p_ppr_attribute10;
569   l_rec.ppr_attribute11                  := p_ppr_attribute11;
570   l_rec.ppr_attribute12                  := p_ppr_attribute12;
571   l_rec.ppr_attribute13                  := p_ppr_attribute13;
572   l_rec.ppr_attribute14                  := p_ppr_attribute14;
573   l_rec.ppr_attribute15                  := p_ppr_attribute15;
574   l_rec.ppr_attribute16                  := p_ppr_attribute16;
575   l_rec.ppr_attribute17                  := p_ppr_attribute17;
576   l_rec.ppr_attribute18                  := p_ppr_attribute18;
577   l_rec.ppr_attribute19                  := p_ppr_attribute19;
578   l_rec.ppr_attribute20                  := p_ppr_attribute20;
579   l_rec.ppr_attribute21                  := p_ppr_attribute21;
580   l_rec.ppr_attribute22                  := p_ppr_attribute22;
581   l_rec.ppr_attribute23                  := p_ppr_attribute23;
582   l_rec.ppr_attribute24                  := p_ppr_attribute24;
583   l_rec.ppr_attribute25                  := p_ppr_attribute25;
584   l_rec.ppr_attribute26                  := p_ppr_attribute26;
585   l_rec.ppr_attribute27                  := p_ppr_attribute27;
586   l_rec.ppr_attribute28                  := p_ppr_attribute28;
587   l_rec.ppr_attribute29                  := p_ppr_attribute29;
588   l_rec.ppr_attribute30                  := p_ppr_attribute30;
589   l_rec.request_id                       := p_request_id;
590   l_rec.program_application_id           := p_program_application_id;
591   l_rec.program_id                       := p_program_id;
592   l_rec.program_update_date              := p_program_update_date;
593   l_rec.object_version_number            := p_object_version_number;
594   --
595   -- Return the plsql record structure.
596   --
597   hr_utility.set_location(' Leaving:'||l_proc, 10);
598   Return(l_rec);
599 --
600 End convert_args;
601 --
602 
603 end ben_ppr_shd;