DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_UCI_SHD

Source


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