DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_LIP_SHD

Source


1 Package Body hr_lip_shd as
2 /* $Header: hrliprhi.pkb 115.5 2002/12/04 05:07:14 hjonnala noship $ */
3 --
7 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
8 g_package  varchar2(33) := '  hr_lip_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 = 'HR_DE_LIABILITY_PREMIUMS_F_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','10');
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_liability_premiums_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      liability_premiums_id
49     ,organization_link_id
50     ,effective_start_date
51     ,effective_end_date
52     ,std_percentage
53     ,calculation_method
54     ,std_working_hours_per_year
55     ,max_remuneration
56     ,attribute_category
57     ,attribute1
58     ,attribute2
59     ,attribute3
60     ,attribute4
61     ,attribute5
62     ,attribute6
63     ,attribute7
64     ,attribute8
65     ,attribute9
66     ,attribute10
67     ,attribute11
68     ,attribute12
69     ,attribute13
70     ,attribute14
71     ,attribute15
72     ,attribute16
73     ,attribute17
74     ,attribute18
75     ,attribute19
76     ,attribute20
77     ,object_version_number
78     from        hr_de_liability_premiums_f
79     where       liability_premiums_id = p_liability_premiums_id
80     and         p_effective_date
81     between     effective_start_date and effective_end_date;
82 --
83   l_fct_ret     boolean;
84 --
85 Begin
86   --
87   If (p_effective_date is null or
88       p_liability_premiums_id is null or
89       p_object_version_number is null) Then
90     --
91     -- One of the primary key arguments is null therefore we must
92     -- set the returning function value to false
93     --
94     l_fct_ret := false;
95   Else
96     If (p_liability_premiums_id =
97         hr_lip_shd.g_old_rec.liability_premiums_id and
98         p_object_version_number =
99         hr_lip_shd.g_old_rec.object_version_number
100 ) Then
101       --
102       -- The g_old_rec is current therefore we must
103       -- set the returning function to true
104       --
105       l_fct_ret := true;
106     Else
107       --
108       -- Select the current row
109       --
110       Open C_Sel1;
111       Fetch C_Sel1 Into hr_lip_shd.g_old_rec;
112       If C_Sel1%notfound Then
113         Close C_Sel1;
114         --
115         -- The primary key is invalid therefore we must error
116         --
117         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
118         fnd_message.raise_error;
119       End If;
120       Close C_Sel1;
121       If (p_object_version_number
122           <> hr_lip_shd.g_old_rec.object_version_number) Then
123         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
124         fnd_message.raise_error;
125       End If;
126       l_fct_ret := true;
127     End If;
128   End If;
129   Return (l_fct_ret);
130 --
131 End api_updating;
132 --
133 -- ----------------------------------------------------------------------------
134 -- |---------------------------< find_dt_upd_modes >--------------------------|
135 -- ----------------------------------------------------------------------------
136 Procedure find_dt_upd_modes
137   (p_effective_date         in date
138   ,p_base_key_value         in number
139   ,p_correction             out nocopy boolean
140   ,p_update                 out nocopy boolean
141   ,p_update_override        out nocopy boolean
142   ,p_update_change_insert   out nocopy boolean
143   ) is
144 --
145   l_proc        varchar2(72) := g_package||'find_dt_upd_modes';
146 --
147 Begin
148   hr_utility.set_location('Entering:'||l_proc, 5);
149   --
150   -- Call the corresponding datetrack api
151   --
152   dt_api.find_dt_upd_modes
153     (p_effective_date        => p_effective_date
154     ,p_base_table_name       => 'hr_de_liability_premiums_f'
155     ,p_base_key_column       => 'liability_premiums_id'
156     ,p_base_key_value        => p_base_key_value
157     ,p_correction            => p_correction
158     ,p_update                => p_update
159     ,p_update_override       => p_update_override
160     ,p_update_change_insert  => p_update_change_insert
161     );
162   --
163   hr_utility.set_location(' Leaving:'||l_proc, 10);
164 End find_dt_upd_modes;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |---------------------------< find_dt_del_modes >--------------------------|
168 -- ----------------------------------------------------------------------------
169 Procedure find_dt_del_modes
170   (p_effective_date        in date
171   ,p_base_key_value        in number
172   ,p_zap                   out nocopy boolean
173   ,p_delete                out nocopy boolean
174   ,p_future_change         out nocopy boolean
175   ,p_delete_next_change    out nocopy boolean
176   ) is
177   --
178   l_proc                varchar2(72)    := g_package||'find_dt_del_modes';
179   --
180   --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183   --
184   -- Call the corresponding datetrack api
185   --
186   dt_api.find_dt_del_modes
187    (p_effective_date                => p_effective_date
188    ,p_base_table_name               => 'hr_de_liability_premiums_f'
189    ,p_base_key_column               => 'liability_premiums_id'
190    ,p_base_key_value                => p_base_key_value
191    ,p_zap                           => p_zap
192    ,p_delete                        => p_delete
193    ,p_future_change                 => p_future_change
194    ,p_delete_next_change            => p_delete_next_change
195    );
196   --
197   hr_utility.set_location(' Leaving:'||l_proc, 10);
198 End find_dt_del_modes;
199 --
200 -- ----------------------------------------------------------------------------
201 -- |-----------------------< upd_effective_end_date >-------------------------|
202 -- ----------------------------------------------------------------------------
203 Procedure upd_effective_end_date
204   (p_effective_date                   in date
205   ,p_base_key_value                   in number
206   ,p_new_effective_end_date           in date
207   ,p_validation_start_date            in date
208   ,p_validation_end_date              in date
209   ,p_object_version_number  out nocopy number
210   ) is
211 --
212   l_proc                  varchar2(72) := g_package||'upd_effective_end_date';
213   l_object_version_number number;
214 --
215 Begin
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   --
218   -- Because we are updating a row we must get the next object
219   -- version number.
220   --
221   l_object_version_number :=
222     dt_api.get_object_version_number
223       (p_base_table_name    => 'hr_de_liability_premiums_f'
224       ,p_base_key_column    => 'liability_premiums_id'
225       ,p_base_key_value     => p_base_key_value
226       );
227   --
228   hr_utility.set_location(l_proc, 10);
229   --
230 --
231   -- Update the specified datetrack row setting the effective
232   -- end date to the specified new effective end date.
233   --
234   update  hr_de_liability_premiums_f t
235   set     t.effective_end_date    = p_new_effective_end_date
236     ,     t.object_version_number = l_object_version_number
237   where   t.liability_premiums_id        = p_base_key_value
238   and     p_effective_date
239   between t.effective_start_date and t.effective_end_date;
240   --
241   --
242   p_object_version_number := l_object_version_number;
243   hr_utility.set_location(' Leaving:'||l_proc, 15);
244 --
245 End upd_effective_end_date;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |---------------------------------< lck >----------------------------------|
249 -- ----------------------------------------------------------------------------
250 Procedure lck
251   (p_effective_date                   in date
252   ,p_datetrack_mode                   in varchar2
253   ,p_liability_premiums_id            in number
254   ,p_object_version_number            in number
255   ,p_validation_start_date            out nocopy date
256   ,p_validation_end_date              out nocopy date
257   ) is
258 --
259   l_proc                  varchar2(72) := g_package||'lck';
260   l_validation_start_date date;
261   l_validation_end_date   date;
262   l_argument              varchar2(30);
263   --
264   -- Cursor C_Sel1 selects the current locked row as of session date
265   -- ensuring that the object version numbers match.
266   --
267   Cursor C_Sel1 is
268     select
269      liability_premiums_id
270     ,organization_link_id
271     ,effective_start_date
272     ,effective_end_date
273     ,std_percentage
274     ,calculation_method
275     ,std_working_hours_per_year
276     ,max_remuneration
280     ,attribute3
277     ,attribute_category
278     ,attribute1
279     ,attribute2
281     ,attribute4
282     ,attribute5
283     ,attribute6
284     ,attribute7
285     ,attribute8
286     ,attribute9
287     ,attribute10
288     ,attribute11
289     ,attribute12
290     ,attribute13
291     ,attribute14
292     ,attribute15
293     ,attribute16
294     ,attribute17
295     ,attribute18
296     ,attribute19
297     ,attribute20
298     ,object_version_number
299     from    hr_de_liability_premiums_f
300     where   liability_premiums_id = p_liability_premiums_id
301     and     p_effective_date
302     between effective_start_date and effective_end_date
303     for update nowait;
304   --
305   --
306   --
307 Begin
308   hr_utility.set_location('Entering:'||l_proc, 5);
309   --
310   -- Ensure that all the mandatory arguments are not null
311   --
312   hr_api.mandatory_arg_error(p_api_name       => l_proc
313                             ,p_argument       => 'effective_date'
314                             ,p_argument_value => p_effective_date
315                             );
316   --
317   hr_api.mandatory_arg_error(p_api_name       => l_proc
318                             ,p_argument       => 'datetrack_mode'
319                             ,p_argument_value => p_datetrack_mode
320                             );
321   --
322   hr_api.mandatory_arg_error(p_api_name       => l_proc
323                             ,p_argument       => 'liability_premiums_id'
324                             ,p_argument_value => p_liability_premiums_id
325                             );
326   --
327     hr_api.mandatory_arg_error(p_api_name       => l_proc
328                             ,p_argument       => 'object_version_number'
329                             ,p_argument_value => p_object_version_number
330                             );
331   --
332   -- Check to ensure the datetrack mode is not INSERT.
333   --
334   If (p_datetrack_mode <> hr_api.g_insert) then
335     --
336     -- We must select and lock the current row.
337     --
338     Open  C_Sel1;
339     Fetch C_Sel1 Into hr_lip_shd.g_old_rec;
340     If C_Sel1%notfound then
341       Close C_Sel1;
342       --
343       -- The primary key is invalid therefore we must error
344       --
345       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
346       fnd_message.raise_error;
347     End If;
348     Close C_Sel1;
349     If (p_object_version_number
350           <> hr_lip_shd.g_old_rec.object_version_number) Then
351         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
352         fnd_message.raise_error;
353     End If;
354     --
355     --
356     -- Validate the datetrack mode mode getting the validation start
357     -- and end dates for the specified datetrack operation.
358     --
359     dt_api.validate_dt_mode
360       (p_effective_date          => p_effective_date
361       ,p_datetrack_mode          => p_datetrack_mode
362       ,p_base_table_name         => 'hr_de_liability_premiums_f'
363       ,p_base_key_column         => 'liability_premiums_id'
364       ,p_base_key_value          => p_liability_premiums_id
365       ,p_enforce_foreign_locking => true
366       ,p_validation_start_date   => l_validation_start_date
367       ,p_validation_end_date     => l_validation_end_date
368       );
369   Else
370     --
371     -- We are doing a datetrack 'INSERT' which is illegal within this
372     -- procedure therefore we must error (note: to lck on insert the
373     -- private procedure ins_lck should be called).
374     --
375     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
376     fnd_message.set_token('PROCEDURE', l_proc);
377     fnd_message.set_token('STEP','20');
378     fnd_message.raise_error;
379   End If;
380   --
381   -- Set the validation start and end date OUT arguments
382   --
383   p_validation_start_date := l_validation_start_date;
384   p_validation_end_date   := l_validation_end_date;
385   --
386   hr_utility.set_location(' Leaving:'||l_proc, 30);
387 --
388 -- We need to trap the ORA LOCK exception
389 --
390 Exception
391   When HR_Api.Object_Locked then
392     --
393     -- The object is locked therefore we need to supply a meaningful
394     -- error message.
395     --
396     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
397     fnd_message.set_token('TABLE_NAME', 'hr_de_liability_premiums_f');
398     fnd_message.raise_error;
399 End lck;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |-----------------------------< convert_args >-----------------------------|
403 -- ----------------------------------------------------------------------------
404 Function convert_args
405   (p_liability_premiums_id          in number
406   ,p_organization_link_id           in number
407   ,p_effective_start_date           in date
408   ,p_effective_end_date             in date
409   ,p_std_percentage                 in number
410   ,p_calculation_method             in varchar2
411   ,p_std_working_hours_per_year     in number
412   ,p_max_remuneration               in number
413   ,p_attribute_category             in varchar2
414   ,p_attribute1                     in varchar2
415   ,p_attribute2                     in varchar2
416   ,p_attribute3                     in varchar2
417   ,p_attribute4                     in varchar2
418   ,p_attribute5                     in varchar2
419   ,p_attribute6                     in varchar2
420   ,p_attribute7                     in varchar2
421   ,p_attribute8                     in varchar2
422   ,p_attribute9                     in varchar2
423   ,p_attribute10                    in varchar2
424   ,p_attribute11                    in varchar2
425   ,p_attribute12                    in varchar2
426   ,p_attribute13                    in varchar2
427   ,p_attribute14                    in varchar2
428   ,p_attribute15                    in varchar2
429   ,p_attribute16                    in varchar2
430   ,p_attribute17                    in varchar2
431   ,p_attribute18                    in varchar2
432   ,p_attribute19                    in varchar2
433   ,p_attribute20                    in varchar2
434   ,p_object_version_number          in number
435   )
436   Return g_rec_type is
437 --
438   l_rec   g_rec_type;
439 --
440 Begin
441   --
442   -- Convert arguments into local l_rec structure.
443   --
444   l_rec.liability_premiums_id            := p_liability_premiums_id;
445   l_rec.organization_link_id             := p_organization_link_id;
446   l_rec.effective_start_date             := p_effective_start_date;
447   l_rec.effective_end_date               := p_effective_end_date;
448   l_rec.std_percentage                   := p_std_percentage;
449   l_rec.calculation_method               := p_calculation_method;
450   l_rec.std_working_hours_per_year       := p_std_working_hours_per_year;
451   l_rec.max_remuneration                 := p_max_remuneration;
452   l_rec.attribute_category               := p_attribute_category;
453   l_rec.attribute1                       := p_attribute1;
454   l_rec.attribute2                       := p_attribute2;
455   l_rec.attribute3                       := p_attribute3;
456   l_rec.attribute4                       := p_attribute4;
457   l_rec.attribute5                       := p_attribute5;
458   l_rec.attribute6                       := p_attribute6;
459   l_rec.attribute7                       := p_attribute7;
460   l_rec.attribute8                       := p_attribute8;
461   l_rec.attribute9                       := p_attribute9;
462   l_rec.attribute10                      := p_attribute10;
463   l_rec.attribute11                      := p_attribute11;
464   l_rec.attribute12                      := p_attribute12;
465   l_rec.attribute13                      := p_attribute13;
466   l_rec.attribute14                      := p_attribute14;
467   l_rec.attribute15                      := p_attribute15;
468   l_rec.attribute16                      := p_attribute16;
469   l_rec.attribute17                      := p_attribute17;
470   l_rec.attribute18                      := p_attribute18;
471   l_rec.attribute19                      := p_attribute19;
472   l_rec.attribute20                      := p_attribute20;
473   l_rec.object_version_number            := p_object_version_number;
474   --
475   -- Return the plsql record structure.
476   --
477   Return(l_rec);
478 --
479 End convert_args;
480 --
481 end hr_lip_shd;