DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_ETU_SHD

Source


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