DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_RTU_SHD

Source


1 Package Body pay_rtu_shd as
2 /* $Header: pyrturhi.pkb 115.3 2002/12/09 15:08:35 divicker noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_rtu_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_RUN_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_RUN_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_run_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      parent_run_type_id
54     ,child_run_type_id
55     ,effective_start_date
56     ,effective_end_date
57     ,sequence
58     ,object_version_number
59     ,run_type_usage_id
60     ,business_group_id
61     ,legislation_code
62     from	pay_run_type_usages_f
63     where	run_type_usage_id = p_run_type_usage_id
64     and		p_effective_date
65     between	effective_start_date and effective_end_date;
66 --
67   l_fct_ret	boolean;
68 --
69 Begin
70   --
71   If (p_effective_date is null or
72       p_run_type_usage_id is null or
73       p_object_version_number is null) Then
74     --
75     -- One of the primary key arguments is null therefore we must
76     -- set the returning function value to false
77     --
78     l_fct_ret := false;
79   Else
80     If (p_run_type_usage_id =
81         pay_rtu_shd.g_old_rec.run_type_usage_id and
82         p_object_version_number =
83         pay_rtu_shd.g_old_rec.object_version_number) 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 pay_rtu_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           <> pay_rtu_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
124   ,p_update_override        out nocopy boolean
125   ,p_update_change_insert   out nocopy boolean
126   ) is
127 --
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       => 'pay_run_type_usages_f'
138     ,p_base_key_column       => 'run_type_usage_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   l_parent_key_value1     number;
164   l_parent_key_value2     number;
165   --
166   Cursor C_Sel1 Is
167     select
168      t.parent_run_type_id
169     ,t.child_run_type_id
170     from   pay_run_type_usages_f t
171     where  t.run_type_usage_id = p_base_key_value
172     and    p_effective_date
173     between t.effective_start_date and t.effective_end_date;
174   --
175 Begin
176   hr_utility.set_location('Entering:'||l_proc, 5);
177   Open C_sel1;
178   Fetch C_Sel1 Into
179      l_parent_key_value1
180     ,l_parent_key_value2;
181   If C_Sel1%NOTFOUND then
182     Close C_Sel1;
183     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
184      fnd_message.set_token('PROCEDURE',l_proc);
185      fnd_message.set_token('STEP','10');
186      fnd_message.raise_error;
187   End If;
188   Close C_Sel1;
189   --
190   -- Call the corresponding datetrack api
191   --
192   dt_api.find_dt_del_modes
193    (p_effective_date                => p_effective_date
194    ,p_base_table_name               => 'pay_run_type_usages_f'
195    ,p_base_key_column               => 'run_type_usage_id'
196    ,p_base_key_value                => p_base_key_value
197    ,p_parent_table_name1            => 'pay_run_types_f'
198    ,p_parent_key_column1            => 'run_type_id'
199    ,p_parent_key_value1             => l_parent_key_value1
200    ,p_parent_table_name2            => 'pay_run_types_f'
201    ,p_parent_key_column2            => 'run_type_id'
202    ,p_parent_key_value2             => l_parent_key_value2
203    ,p_zap                           => p_zap
204    ,p_delete                        => p_delete
205    ,p_future_change                 => p_future_change
206    ,p_delete_next_change            => p_delete_next_change
207    );
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End find_dt_del_modes;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |-----------------------< upd_effective_end_date >-------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure upd_effective_end_date
216   (p_effective_date                   in date
217   ,p_base_key_value                   in number
218   ,p_new_effective_end_date           in date
219   ,p_validation_start_date            in date
220   ,p_validation_end_date              in date
221   ,p_object_version_number  out nocopy number
222   ) is
223 --
224   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
225   l_object_version_number number;
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   --
230   -- Because we are updating a row we must get the next object
231   -- version number.
232   --
233   l_object_version_number :=
234     dt_api.get_object_version_number
235       (p_base_table_name    => 'pay_run_type_usages_f'
236       ,p_base_key_column    => 'run_type_usage_id'
237       ,p_base_key_value     => p_base_key_value
238       );
239   --
240   hr_utility.set_location(l_proc, 10);
241   --
242   --
243   -- Update the specified datetrack row setting the effective
244   -- end date to the specified new effective end date.
245   --
246   update  pay_run_type_usages_f t
247   set     t.effective_end_date    = p_new_effective_end_date
248     ,     t.object_version_number = l_object_version_number
249   where   t.run_type_usage_id        = p_base_key_value
250   and     p_effective_date
251   between t.effective_start_date and t.effective_end_date;
252   --
253   --
254   p_object_version_number := l_object_version_number;
255   hr_utility.set_location(' Leaving:'||l_proc, 15);
256 --
257 End upd_effective_end_date;
258 --
259 -- ----------------------------------------------------------------------------
260 -- |---------------------------------< lck >----------------------------------|
261 -- ----------------------------------------------------------------------------
262 Procedure lck
263   (p_effective_date                   in date
264   ,p_datetrack_mode                   in varchar2
265   ,p_run_type_usage_id                in number
266   ,p_object_version_number            in number
267   ,p_validation_start_date            out nocopy date
268   ,p_validation_end_date              out nocopy date
269   ) is
270 --
271   l_proc		  varchar2(72) := g_package||'lck';
272   l_validation_start_date date;
273   l_validation_end_date	  date;
274   l_argument		  varchar2(30);
275   --
276   -- Cursor C_Sel1 selects the current locked row as of session date
277   -- ensuring that the object version numbers match.
278   --
279   Cursor C_Sel1 is
280     select
281      parent_run_type_id
282     ,child_run_type_id
283     ,effective_start_date
284     ,effective_end_date
285     ,sequence
286     ,object_version_number
287     ,run_type_usage_id
288     ,business_group_id
289     ,legislation_code
290     from    pay_run_type_usages_f
291     where   run_type_usage_id = p_run_type_usage_id
292     and	    p_effective_date
293     between effective_start_date and effective_end_date
294     for update nowait;
295   --
296   --
297   --
298 Begin
299   hr_utility.set_location('Entering:'||l_proc, 5);
300   --
301   -- Ensure that all the mandatory arguments are not null
302   --
303   hr_api.mandatory_arg_error(p_api_name       => l_proc
304                             ,p_argument       => 'effective_date'
305                             ,p_argument_value => p_effective_date
306                             );
307   --
308   hr_api.mandatory_arg_error(p_api_name       => l_proc
309                             ,p_argument       => 'datetrack_mode'
310                             ,p_argument_value => p_datetrack_mode
311                             );
312   --
313   hr_api.mandatory_arg_error(p_api_name       => l_proc
314                             ,p_argument       => 'run_type_usage_id'
315                             ,p_argument_value => p_run_type_usage_id
316                             );
317   --
318   hr_api.mandatory_arg_error(p_api_name       => l_proc
319                             ,p_argument       => 'object_version_number'
320                             ,p_argument_value => p_object_version_number
321                             );
322   hr_utility.set_location(l_proc, 10);
323   --
324   -- Check to ensure the datetrack mode is not INSERT.
325   --
326   If (p_datetrack_mode <> hr_api.g_insert) then
327   hr_utility.set_location(l_proc, 15);
328     --
329     -- We must select and lock the current row.
330     --
331     Open  C_Sel1;
332     Fetch C_Sel1 Into pay_rtu_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_rtu_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_run_type_usages_f'
356       ,p_base_key_column         => 'run_type_usage_id'
357       ,p_base_key_value          => p_run_type_usage_id
358       ,p_parent_table_name1      => 'pay_run_types_f'
359       ,p_parent_key_column1      => 'run_type_id'
360       ,p_parent_key_value1       => pay_rtu_shd.g_old_rec.parent_run_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_rtu_shd.g_old_rec.child_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_run_type_usages_f');
397     fnd_message.raise_error;
398 End lck;
399 --
400 -- ----------------------------------------------------------------------------
401 -- |-----------------------------< convert_args >-----------------------------|
402 -- ----------------------------------------------------------------------------
403 Function convert_args
404   (p_parent_run_type_id             in number
405   ,p_child_run_type_id              in number
406   ,p_effective_start_date           in date
407   ,p_effective_end_date             in date
408   ,p_sequence                       in number
409   ,p_object_version_number          in number
410   ,p_run_type_usage_id              in number
411   ,p_business_group_id              in number
412   ,p_legislation_code               in varchar2
413   )
414   Return g_rec_type is
415 --
416   l_rec   g_rec_type;
417 --
418 Begin
419   --
420   -- Convert arguments into local l_rec structure.
421   --
422   l_rec.parent_run_type_id               := p_parent_run_type_id;
423   l_rec.child_run_type_id                := p_child_run_type_id;
424   l_rec.effective_start_date             := p_effective_start_date;
425   l_rec.effective_end_date               := p_effective_end_date;
426   l_rec.sequence                         := p_sequence;
427   l_rec.object_version_number            := p_object_version_number;
428   l_rec.run_type_usage_id                := p_run_type_usage_id;
429   l_rec.business_group_id                := p_business_group_id;
430   l_rec.legislation_code                 := p_legislation_code;
431   --
432   -- Return the plsql record structure.
433   --
434   Return(l_rec);
435 --
436 End convert_args;
437 --
438 end pay_rtu_shd;