DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ESW_SHD

Source


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