DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BER_SHD

Source


1 Package Body ben_ber_shd as
2 /* $Header: beberrhi.pkb 120.1.12010000.2 2008/08/05 14:08:07 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_ber_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14   (p_constraint_name in all_constraints.constraint_name%TYPE
15   ) Is
16 --
17   l_proc        varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20   --
21   If (p_constraint_name = 'BEN_ELIG_RSLT_PK') Then
22     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23     fnd_message.set_token('PROCEDURE', l_proc);
24     fnd_message.set_token('STEP','5');
25     fnd_message.raise_error;
26   Else
27     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28     fnd_message.set_token('PROCEDURE', l_proc);
29     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30     fnd_message.raise_error;
31   End If;
32   --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39   (p_effective_date                   in date
40   ,p_elig_rslt_id                     in number
41   ,p_object_version_number            in number
42   ) Return Boolean Is
43   --
44   -- Cursor selects the 'current' row from the HR Schema
45   --
46   Cursor C_Sel1 is
47     select
48      elig_rslt_id
49     ,effective_start_date
50     ,effective_end_date
51     ,elig_obj_id
52     ,person_id
53     ,assignment_id
54     ,elig_flag
55     ,business_group_id
56     ,object_version_number
57     from        ben_elig_rslt_f
58     where       elig_rslt_id = p_elig_rslt_id
59     and         p_effective_date
63 --
60     between     effective_start_date and effective_end_date;
61 --
62   l_fct_ret     boolean;
64 Begin
65   --
66   If (p_effective_date is null or
67       p_elig_rslt_id is null or
68       p_object_version_number is null) Then
69     --
70     -- One of the primary key arguments is null therefore we must
71     -- set the returning function value to false
72     --
73     l_fct_ret := false;
74   Else
75     If (p_elig_rslt_id =
76         ben_ber_shd.g_old_rec.elig_rslt_id and
77         p_object_version_number =
78         ben_ber_shd.g_old_rec.object_version_number
79 ) Then
80       --
81       -- The g_old_rec is current therefore we must
82       -- set the returning function to true
83       --
84       l_fct_ret := true;
85     Else
86       --
87       -- Select the current row
88       --
89       Open C_Sel1;
90       Fetch C_Sel1 Into ben_ber_shd.g_old_rec;
91       If C_Sel1%notfound Then
92         Close C_Sel1;
93         --
94         -- The primary key is invalid therefore we must error
95         --
96         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
97         fnd_message.raise_error;
98       End If;
99       Close C_Sel1;
100       If (p_object_version_number
101           <> ben_ber_shd.g_old_rec.object_version_number) Then
102         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
103         fnd_message.raise_error;
104       End If;
105       l_fct_ret := true;
106     End If;
107   End If;
108   Return (l_fct_ret);
109 --
110 End api_updating;
111 --
112 -- ----------------------------------------------------------------------------
113 -- |---------------------------< find_dt_upd_modes >--------------------------|
114 -- ----------------------------------------------------------------------------
115 Procedure find_dt_upd_modes
116   (p_effective_date         in date
117   ,p_base_key_value         in number
118   ,p_correction             out nocopy boolean
119   ,p_update                 out nocopy boolean
120   ,p_update_override        out nocopy boolean
121   ,p_update_change_insert   out nocopy boolean
122   ) is
123 --
124   l_proc        varchar2(72) := g_package||'find_dt_upd_modes';
125 --
126 Begin
127   hr_utility.set_location('Entering:'||l_proc, 5);
128   --
129   -- Call the corresponding datetrack api
130   --
131   dt_api.find_dt_upd_modes
132     (p_effective_date        => p_effective_date
133     ,p_base_table_name       => 'ben_elig_rslt_f'
134     ,p_base_key_column       => 'elig_rslt_id'
135     ,p_base_key_value        => p_base_key_value
136     ,p_correction            => p_correction
137     ,p_update                => p_update
138     ,p_update_override       => p_update_override
139     ,p_update_change_insert  => p_update_change_insert
140     );
141   --
142   hr_utility.set_location(' Leaving:'||l_proc, 10);
143 End find_dt_upd_modes;
144 --
145 -- ----------------------------------------------------------------------------
146 -- |---------------------------< find_dt_del_modes >--------------------------|
147 -- ----------------------------------------------------------------------------
148 Procedure find_dt_del_modes
149   (p_effective_date        in date
150   ,p_base_key_value        in number
151   ,p_zap                   out nocopy boolean
152   ,p_delete                out nocopy boolean
153   ,p_future_change         out nocopy boolean
154   ,p_delete_next_change    out nocopy boolean
155   ) is
156   --
157   l_proc                varchar2(72)    := g_package||'find_dt_del_modes';
158   --
159   l_parent_key_value1     number;
160   --
161   Cursor C_Sel1 Is
162     select
163      t.elig_obj_id
164     from   ben_elig_rslt_f t
165     where  t.elig_rslt_id = p_base_key_value
166     and    p_effective_date
167     between t.effective_start_date and t.effective_end_date;
168   --
169 Begin
170   hr_utility.set_location('Entering:'||l_proc, 5);
171   Open C_sel1;
172   Fetch C_Sel1 Into
173      l_parent_key_value1;
174   If C_Sel1%NOTFOUND then
175     Close C_Sel1;
176     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
177      fnd_message.set_token('PROCEDURE',l_proc);
178      fnd_message.set_token('STEP','10');
179      fnd_message.raise_error;
180   End If;
181   Close C_Sel1;
182   --
183   -- Call the corresponding datetrack api
184   --
185   dt_api.find_dt_del_modes
186    (p_effective_date                => p_effective_date
187    ,p_base_table_name               => 'ben_elig_rslt_f'
188    ,p_base_key_column               => 'elig_rslt_id'
189    ,p_base_key_value                => p_base_key_value
190    ,p_parent_table_name1            => 'ben_elig_obj_f'
191    ,p_parent_key_column1            => 'elig_obj_id'
192    ,p_parent_key_value1             => l_parent_key_value1
193    ,p_zap                           => p_zap
194    ,p_delete                        => p_delete
195    ,p_future_change                 => p_future_change
196    ,p_delete_next_change            => p_delete_next_change
197    );
198   --
199   hr_utility.set_location(' Leaving:'||l_proc, 10);
200 End find_dt_del_modes;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-----------------------< upd_effective_end_date >-------------------------|
204 -- ----------------------------------------------------------------------------
205 Procedure upd_effective_end_date
206   (p_effective_date                   in date
207   ,p_base_key_value                   in number
208   ,p_new_effective_end_date           in date
209   ,p_validation_start_date            in date
213 --
210   ,p_validation_end_date              in date
211   ,p_object_version_number  out nocopy number
212   ) is
214   l_proc                  varchar2(72) := g_package||'upd_effective_end_date';
215   l_object_version_number number;
216 --
217 Begin
218   hr_utility.set_location('Entering:'||l_proc, 5);
219   --
220   -- Because we are updating a row we must get the next object
221   -- version number.
222   --
223   l_object_version_number :=
224     dt_api.get_object_version_number
225       (p_base_table_name    => 'ben_elig_rslt_f'
226       ,p_base_key_column    => 'elig_rslt_id'
227       ,p_base_key_value     => p_base_key_value
228       );
229   --
230   hr_utility.set_location(l_proc, 10);
231   --
232 --
233   -- Update the specified datetrack row setting the effective
234   -- end date to the specified new effective end date.
235   --
236   update  ben_elig_rslt_f t
237   set     t.effective_end_date    = p_new_effective_end_date
238     ,     t.object_version_number = l_object_version_number
239   where   t.elig_rslt_id        = p_base_key_value
240   and     p_effective_date
241   between t.effective_start_date and t.effective_end_date;
242   --
243   --
244   p_object_version_number := l_object_version_number;
245   hr_utility.set_location(' Leaving:'||l_proc, 15);
246 --
247 End upd_effective_end_date;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |---------------------------------< lck >----------------------------------|
251 -- ----------------------------------------------------------------------------
252 Procedure lck
253   (p_effective_date                   in date
254   ,p_datetrack_mode                   in varchar2
255   ,p_elig_rslt_id                     in number
256   ,p_object_version_number            in number
257   ,p_validation_start_date            out nocopy date
258   ,p_validation_end_date              out nocopy date
259   ) is
260 --
261   l_proc                  varchar2(72) := g_package||'lck';
262   l_validation_start_date date;
263   l_validation_end_date   date;
264   l_argument              varchar2(30);
265   --
266   -- Cursor C_Sel1 selects the current locked row as of session date
267   -- ensuring that the object version numbers match.
268   --
269   Cursor C_Sel1 is
270     select
271      elig_rslt_id
272     ,effective_start_date
273     ,effective_end_date
274     ,elig_obj_id
275     ,person_id
276     ,assignment_id
277     ,elig_flag
278     ,business_group_id
279     ,object_version_number
280     from    ben_elig_rslt_f
281     where   elig_rslt_id = p_elig_rslt_id
282     and     p_effective_date
283     between effective_start_date and effective_end_date
284     for update nowait;
285   --
286   --
287   --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 5);
290   --
291   -- Ensure that all the mandatory arguments are not null
292   --
293   hr_api.mandatory_arg_error(p_api_name       => l_proc
294                             ,p_argument       => 'effective_date'
295                             ,p_argument_value => p_effective_date
296                             );
297   --
298   hr_api.mandatory_arg_error(p_api_name       => l_proc
299                             ,p_argument       => 'datetrack_mode'
300                             ,p_argument_value => p_datetrack_mode
301                             );
302   --
303   hr_api.mandatory_arg_error(p_api_name       => l_proc
304                             ,p_argument       => 'elig_rslt_id'
305                             ,p_argument_value => p_elig_rslt_id
306                             );
307   --
308     hr_api.mandatory_arg_error(p_api_name       => l_proc
309                             ,p_argument       => 'object_version_number'
310                             ,p_argument_value => p_object_version_number
311                             );
312   --
313   -- Check to ensure the datetrack mode is not INSERT.
314   --
315   If (p_datetrack_mode <> hr_api.g_insert) then
316     --
317     -- We must select and lock the current row.
318     --
319     Open  C_Sel1;
320     Fetch C_Sel1 Into ben_ber_shd.g_old_rec;
321     If C_Sel1%notfound then
322       Close C_Sel1;
323       --
324       -- The primary key is invalid therefore we must error
325       --
326       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
327       fnd_message.raise_error;
328     End If;
329     Close C_Sel1;
330     If (p_object_version_number
331           <> ben_ber_shd.g_old_rec.object_version_number) Then
332         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
333         fnd_message.raise_error;
334     End If;
335     --
336     --
337     -- Validate the datetrack mode mode getting the validation start
338     -- and end dates for the specified datetrack operation.
339     --
340     dt_api.validate_dt_mode
341       (p_effective_date          => p_effective_date
342       ,p_datetrack_mode          => p_datetrack_mode
343       ,p_base_table_name         => 'ben_elig_rslt_f'
344       ,p_base_key_column         => 'elig_rslt_id'
345       ,p_base_key_value          => p_elig_rslt_id
346       ,p_parent_table_name1      => 'ben_elig_obj_f'
347       ,p_parent_key_column1      => 'elig_obj_id'
348       ,p_parent_key_value1       => ben_ber_shd.g_old_rec.elig_obj_id
349       ,p_enforce_foreign_locking => false                     -- Bug 4525373
350       ,p_validation_start_date   => l_validation_start_date
354     --
351       ,p_validation_end_date     => l_validation_end_date
352       );
353   Else
355     -- We are doing a datetrack 'INSERT' which is illegal within this
356     -- procedure therefore we must error (note: to lck on insert the
357     -- private procedure ins_lck should be called).
358     --
359     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
360     fnd_message.set_token('PROCEDURE', l_proc);
361     fnd_message.set_token('STEP','20');
362     fnd_message.raise_error;
363   End If;
364   --
365   -- Set the validation start and end date OUT arguments
366   --
367   p_validation_start_date := l_validation_start_date;
368   p_validation_end_date   := l_validation_end_date;
369   --
370   hr_utility.set_location(' Leaving:'||l_proc, 30);
371 --
372 -- We need to trap the ORA LOCK exception
373 --
374 Exception
375   When HR_Api.Object_Locked then
376     --
377     -- The object is locked therefore we need to supply a meaningful
378     -- error message.
379     --
380     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
381     fnd_message.set_token('TABLE_NAME', 'ben_elig_rslt_f');
382     fnd_message.raise_error;
383 End lck;
384 --
385 -- ----------------------------------------------------------------------------
386 -- |-----------------------------< convert_args >-----------------------------|
387 -- ----------------------------------------------------------------------------
388 Function convert_args
389   (p_elig_rslt_id                   in number
390   ,p_effective_start_date           in date
391   ,p_effective_end_date             in date
392   ,p_elig_obj_id                    in number
393   ,p_person_id                      in number
394   ,p_assignment_id                  in number
395   ,p_elig_flag                      in varchar2
396   ,p_business_group_id              in number
397   ,p_object_version_number          in number
398   )
399   Return g_rec_type is
400 --
401   l_rec   g_rec_type;
402 --
403 Begin
404   --
405   -- Convert arguments into local l_rec structure.
406   --
407   l_rec.elig_rslt_id                     := p_elig_rslt_id;
408   l_rec.effective_start_date             := p_effective_start_date;
409   l_rec.effective_end_date               := p_effective_end_date;
410   l_rec.elig_obj_id                      := p_elig_obj_id;
411   l_rec.person_id                        := p_person_id;
412   l_rec.assignment_id                    := p_assignment_id;
413   l_rec.elig_flag                        := p_elig_flag;
414   l_rec.business_group_id                := p_business_group_id;
415   l_rec.object_version_number            := p_object_version_number;
416   --
417   -- Return the plsql record structure.
418   --
419   Return(l_rec);
420 --
421 End convert_args;
422 --
423 end ben_ber_shd;