DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PSL_SHD

Source


1 Package Body ben_psl_shd as
2 /* $Header: bepslrhi.pkb 115.14 2004/06/30 23:53:12 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_psl_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15   l_proc    varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18   hr_utility.set_location('Entering:'||l_proc, 5);
19   --
20   Return (nvl(g_api_dml, false));
21   --
22   hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31   l_proc    varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   --
36   If (p_constraint_name = 'BEN_PER_INFO_CHG_CS_LER_F_FK1') Then
37     fnd_message.set_name('BEN', 'BEN_91000_INVALID_BUS_GROUP');
38     fnd_message.set_token('PROCEDURE', l_proc);
39     fnd_message.set_token('STEP','5');
40     fnd_message.raise_error;
41   ElsIf (p_constraint_name = 'BEN_PER_INFO_CHG_CS_LER_F_PK') Then
42     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('STEP','10');
45     fnd_message.raise_error;
46   Else
47     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50     fnd_message.raise_error;
51   End If;
52   --
53   hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60   (p_effective_date     in date,
61    p_per_info_chg_cs_ler_id     in number,
62    p_object_version_number  in number
63   ) Return Boolean Is
64 --
65   --
66   -- Cursor selects the 'current' row from the HR Schema
67   --
68   Cursor C_Sel1 is
69     select
70     per_info_chg_cs_ler_id,
71         name,
72     effective_start_date,
73     effective_end_date,
74     per_info_chg_cs_ler_rl,
75     old_val,
76     new_val,
77         whatif_lbl_txt,
78         rule_overrides_flag,
79     source_column,
80     source_table,
81     business_group_id,
82     psl_attribute_category,
83     psl_attribute1,
84     psl_attribute2,
85     psl_attribute3,
86     psl_attribute4,
87     psl_attribute5,
88     psl_attribute6,
89     psl_attribute7,
90     psl_attribute8,
91     psl_attribute9,
92     psl_attribute10,
93     psl_attribute11,
94     psl_attribute12,
95     psl_attribute13,
96     psl_attribute14,
97     psl_attribute15,
98     psl_attribute16,
99     psl_attribute17,
100     psl_attribute18,
101     psl_attribute19,
102     psl_attribute20,
103     psl_attribute21,
104     psl_attribute22,
105     psl_attribute23,
106     psl_attribute24,
107     psl_attribute25,
108     psl_attribute26,
109     psl_attribute27,
110     psl_attribute28,
111     psl_attribute29,
112     psl_attribute30,
113     object_version_number
114     from    ben_per_info_chg_cs_ler_f
115     where   per_info_chg_cs_ler_id = p_per_info_chg_cs_ler_id
116     and     p_effective_date
117     between effective_start_date and effective_end_date;
118 --
119   l_proc    varchar2(72)    := g_package||'api_updating';
120   l_fct_ret boolean;
121 --
122 Begin
123   hr_utility.set_location('Entering:'||l_proc, 5);
124   --
125   If (p_effective_date is null or
126       p_per_info_chg_cs_ler_id is null or
127       p_object_version_number is null) Then
128     --
129     -- One of the primary key arguments is null therefore we must
130     -- set the returning function value to false
131     --
132     l_fct_ret := false;
133   Else
134     If (p_per_info_chg_cs_ler_id = g_old_rec.per_info_chg_cs_ler_id and
135         p_object_version_number = g_old_rec.object_version_number) Then
136       hr_utility.set_location(l_proc, 10);
137       --
138       -- The g_old_rec is current therefore we must
139       -- set the returning function to true
140       --
141       l_fct_ret := true;
142     Else
143       --
144       -- Select the current row
145       --
146       Open C_Sel1;
147       Fetch C_Sel1 Into g_old_rec;
148       If C_Sel1%notfound Then
149         Close C_Sel1;
150         --
151         -- The primary key is invalid therefore we must error
152         --
153         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
154         fnd_message.raise_error;
155       End If;
156       Close C_Sel1;
157       If (p_object_version_number <> g_old_rec.object_version_number) Then
158         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
159         fnd_message.raise_error;
160       End If;
161       hr_utility.set_location(l_proc, 15);
162       l_fct_ret := true;
163     End If;
164   End If;
165   hr_utility.set_location(' Leaving:'||l_proc, 20);
166   Return (l_fct_ret);
167 --
168 End api_updating;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |--------------------------< find_dt_del_modes >---------------------------|
172 -- ----------------------------------------------------------------------------
173 Procedure find_dt_del_modes
174     (p_effective_date   in  date,
175      p_base_key_value   in  number,
176      p_zap       out nocopy boolean,
177      p_delete    out nocopy boolean,
178      p_future_change out nocopy boolean,
179      p_delete_next_change out nocopy boolean) is
180 --
181   l_proc        varchar2(72)    := g_package||'find_dt_del_modes';
182 --
183   --
184   --
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188     --
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  => 'ben_per_info_chg_cs_ler_f',
195      p_base_key_column  => 'per_info_chg_cs_ler_id',
196      p_base_key_value   => p_base_key_value,
197      p_zap          => p_zap,
198      p_delete       => p_delete,
199      p_future_change    => p_future_change,
200      p_delete_next_change   => p_delete_next_change);
201   --
202   hr_utility.set_location(' Leaving:'||l_proc, 10);
203 End find_dt_del_modes;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |--------------------------< find_dt_upd_modes >---------------------------|
207 -- ----------------------------------------------------------------------------
208 Procedure find_dt_upd_modes
209     (p_effective_date   in  date,
210      p_base_key_value   in  number,
211      p_correction    out nocopy boolean,
212      p_update    out nocopy boolean,
213      p_update_override out nocopy boolean,
214      p_update_change_insert out nocopy boolean) is
215 --
216   l_proc    varchar2(72) := g_package||'find_dt_upd_modes';
217 --
218 Begin
219   hr_utility.set_location('Entering:'||l_proc, 5);
220   --
221   -- Call the corresponding datetrack api
222   --
223   dt_api.find_dt_upd_modes
224     (p_effective_date   => p_effective_date,
225      p_base_table_name  => 'ben_per_info_chg_cs_ler_f',
226      p_base_key_column  => 'per_info_chg_cs_ler_id',
227      p_base_key_value   => p_base_key_value,
228      p_correction       => p_correction,
229      p_update       => p_update,
230      p_update_override  => p_update_override,
231      p_update_change_insert => p_update_change_insert);
232   --
233   hr_utility.set_location(' Leaving:'||l_proc, 10);
234 End find_dt_upd_modes;
235 --
236 -- ----------------------------------------------------------------------------
237 -- |------------------------< upd_effective_end_date >------------------------|
238 -- ----------------------------------------------------------------------------
239 Procedure upd_effective_end_date
240     (p_effective_date       in date,
241      p_base_key_value       in number,
242      p_new_effective_end_date   in date,
243      p_validation_start_date    in date,
244      p_validation_end_date      in date,
245          p_object_version_number       out nocopy number) is
246 --
247   l_proc          varchar2(72) := g_package||'upd_effective_end_date';
248   l_object_version_number number;
249 --
250 Begin
251   hr_utility.set_location('Entering:'||l_proc, 5);
252   --
253   -- Because we are updating a row we must get the next object
254   -- version number.
255   --
256   l_object_version_number :=
257     dt_api.get_object_version_number
258     (p_base_table_name  => 'ben_per_info_chg_cs_ler_f',
259      p_base_key_column  => 'per_info_chg_cs_ler_id',
260      p_base_key_value   => p_base_key_value);
261   --
262   hr_utility.set_location(l_proc, 10);
263   g_api_dml := true;  -- Set the api dml status
264   --
265   -- Update the specified datetrack row setting the effective
266   -- end date to the specified new effective end date.
267   --
268   update  ben_per_info_chg_cs_ler_f t
269   set     t.effective_end_date    = p_new_effective_end_date,
270       t.object_version_number = l_object_version_number
271   where   t.per_info_chg_cs_ler_id    = p_base_key_value
272   and     p_effective_date
273   between t.effective_start_date and t.effective_end_date;
274   --
275   g_api_dml := false;   -- Unset the api dml status
276   p_object_version_number := l_object_version_number;
277   hr_utility.set_location(' Leaving:'||l_proc, 15);
278 --
279 Exception
280   When Others Then
281     g_api_dml := false;   -- Unset the api dml status
282     Raise;
283 End upd_effective_end_date;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------------< lck >----------------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure lck
289     (p_effective_date    in  date,
290      p_datetrack_mode    in  varchar2,
291      p_per_info_chg_cs_ler_id    in  number,
292      p_object_version_number in  number,
293      p_validation_start_date out nocopy date,
294      p_validation_end_date   out nocopy date) is
295 --
296   l_proc          varchar2(72) := g_package||'lck';
297   l_validation_start_date date;
298   l_validation_end_date   date;
299   l_object_invalid    exception;
300   l_argument          varchar2(30);
301   --
302   -- Cursor C_Sel1 selects the current locked row as of session date
303   -- ensuring that the object version numbers match.
304   --
305   Cursor C_Sel1 is
306     select
307     per_info_chg_cs_ler_id,
308         name,
309     effective_start_date,
310     effective_end_date,
311     per_info_chg_cs_ler_rl,
312     old_val,
313     new_val,
314         whatif_lbl_txt,
315         rule_overrides_flag,
316     source_column,
317     source_table,
318     business_group_id,
319     psl_attribute_category,
320     psl_attribute1,
321     psl_attribute2,
322     psl_attribute3,
323     psl_attribute4,
324     psl_attribute5,
325     psl_attribute6,
326     psl_attribute7,
327     psl_attribute8,
328     psl_attribute9,
329     psl_attribute10,
330     psl_attribute11,
331     psl_attribute12,
332     psl_attribute13,
333     psl_attribute14,
334     psl_attribute15,
335     psl_attribute16,
336     psl_attribute17,
337     psl_attribute18,
338     psl_attribute19,
339     psl_attribute20,
340     psl_attribute21,
341     psl_attribute22,
342     psl_attribute23,
343     psl_attribute24,
344     psl_attribute25,
345     psl_attribute26,
346     psl_attribute27,
347     psl_attribute28,
348     psl_attribute29,
349     psl_attribute30,
350     object_version_number
351     from    ben_per_info_chg_cs_ler_f
352     where   per_info_chg_cs_ler_id         = p_per_info_chg_cs_ler_id
353     and     p_effective_date
354     between effective_start_date and effective_end_date
355     for update nowait;
356   --
357   --
358   --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- Ensure that all the mandatory arguments are not null
363   --
364   hr_api.mandatory_arg_error(p_api_name       => l_proc,
365                              p_argument       => 'effective_date',
366                              p_argument_value => p_effective_date);
367   --
368   hr_api.mandatory_arg_error(p_api_name       => l_proc,
369                              p_argument       => 'datetrack_mode',
370                              p_argument_value => p_datetrack_mode);
371   --
372   hr_api.mandatory_arg_error(p_api_name       => l_proc,
373                              p_argument       => 'per_info_chg_cs_ler_id',
374                              p_argument_value => p_per_info_chg_cs_ler_id);
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'object_version_number',
378                              p_argument_value => p_object_version_number);
379   --
380   -- Check to ensure the datetrack mode is not INSERT.
381   --
382   If (p_datetrack_mode <> 'INSERT') then
383     --
384     -- We must select and lock the current row.
385     --
386     Open  C_Sel1;
387     Fetch C_Sel1 Into g_old_rec;
388     If C_Sel1%notfound then
389       Close C_Sel1;
390       --
391       -- The primary key is invalid therefore we must error
392       --
393       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
394       fnd_message.raise_error;
395     End If;
396     Close C_Sel1;
397     If (p_object_version_number <> g_old_rec.object_version_number) Then
398         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
399         fnd_message.raise_error;
400       End If;
401     hr_utility.set_location(l_proc, 15);
402     --
403     --
404     -- Validate the datetrack mode mode getting the validation start
405     -- and end dates for the specified datetrack operation.
406     --
407     dt_api.validate_dt_mode
408     (p_effective_date      => p_effective_date,
409      p_datetrack_mode      => p_datetrack_mode,
410      p_base_table_name     => 'ben_per_info_chg_cs_ler_f',
411      p_base_key_column     => 'per_info_chg_cs_ler_id',
412      p_base_key_value      => p_per_info_chg_cs_ler_id,
413      p_child_table_name1       => 'ben_ler_per_info_cs_ler_f',
414      p_child_key_column1       => 'ler_per_info_cs_ler_id',
415          p_enforce_foreign_locking => false, -- true -- bug 3290878
416      p_validation_start_date   => l_validation_start_date,
417      p_validation_end_date     => l_validation_end_date);
421     -- procedure therefore we must error (note: to lck on insert the
418   Else
419     --
420     -- We are doing a datetrack 'INSERT' which is illegal within this
422     -- private procedure ins_lck should be called).
423     --
424     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
425     fnd_message.set_token('PROCEDURE', l_proc);
426     fnd_message.set_token('STEP','20');
427     fnd_message.raise_error;
428   End If;
429   --
430   -- Set the validation start and end date OUT arguments
431   --
432   p_validation_start_date := l_validation_start_date;
433   p_validation_end_date   := l_validation_end_date;
434   --
435   hr_utility.set_location(' Leaving:'||l_proc, 30);
436 --
437 -- We need to trap the ORA LOCK exception
438 --
439 Exception
440   When HR_Api.Object_Locked then
441     --
442     -- The object is locked therefore we need to supply a meaningful
443     -- error message.
444     --
445     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
446     fnd_message.set_token('TABLE_NAME', 'ben_per_info_chg_cs_ler_f');
447     fnd_message.raise_error;
448   When l_object_invalid then
449     --
450     -- The object doesn't exist or is invalid
451     --
452     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
453     fnd_message.set_token('TABLE_NAME', 'ben_per_info_chg_cs_ler_f');
454     fnd_message.raise_error;
455 End lck;
456 --
457 -- ----------------------------------------------------------------------------
458 -- |-----------------------------< convert_args >-----------------------------|
459 -- ----------------------------------------------------------------------------
460 Function convert_args
461     (
462     p_per_info_chg_cs_ler_id        in number,
463         p_name                          in varchar2,
464     p_effective_start_date          in date,
465     p_effective_end_date            in date,
466     p_per_info_chg_cs_ler_rl        in number,
467     p_old_val                       in varchar2,
468     p_new_val                       in varchar2,
469     p_whatif_lbl_txt                in varchar2,
470     p_rule_overrides_flag                in varchar2,
471     p_source_column                 in varchar2,
472     p_source_table                  in varchar2,
473     p_business_group_id             in number,
474     p_psl_attribute_category        in varchar2,
475     p_psl_attribute1                in varchar2,
476     p_psl_attribute2                in varchar2,
477     p_psl_attribute3                in varchar2,
478     p_psl_attribute4                in varchar2,
479     p_psl_attribute5                in varchar2,
480     p_psl_attribute6                in varchar2,
481     p_psl_attribute7                in varchar2,
482     p_psl_attribute8                in varchar2,
483     p_psl_attribute9                in varchar2,
484     p_psl_attribute10               in varchar2,
485     p_psl_attribute11               in varchar2,
486     p_psl_attribute12               in varchar2,
487     p_psl_attribute13               in varchar2,
488     p_psl_attribute14               in varchar2,
489     p_psl_attribute15               in varchar2,
490     p_psl_attribute16               in varchar2,
491     p_psl_attribute17               in varchar2,
492     p_psl_attribute18               in varchar2,
493     p_psl_attribute19               in varchar2,
494     p_psl_attribute20               in varchar2,
495     p_psl_attribute21               in varchar2,
496     p_psl_attribute22               in varchar2,
497     p_psl_attribute23               in varchar2,
498     p_psl_attribute24               in varchar2,
499     p_psl_attribute25               in varchar2,
500     p_psl_attribute26               in varchar2,
501     p_psl_attribute27               in varchar2,
502     p_psl_attribute28               in varchar2,
503     p_psl_attribute29               in varchar2,
504     p_psl_attribute30               in varchar2,
505     p_object_version_number         in number
506     )
507     Return g_rec_type is
508 --
509   l_rec   g_rec_type;
510   l_proc  varchar2(72) := g_package||'convert_args';
511 --
512 Begin
513   --
514   hr_utility.set_location('Entering:'||l_proc, 5);
515   --
516   -- Convert arguments into local l_rec structure.
517   --
518   l_rec.per_info_chg_cs_ler_id           := p_per_info_chg_cs_ler_id;
519   l_rec.name                             := p_name;
520   l_rec.effective_start_date             := p_effective_start_date;
521   l_rec.effective_end_date               := p_effective_end_date;
522   l_rec.per_info_chg_cs_ler_rl           := p_per_info_chg_cs_ler_rl;
523   l_rec.old_val                          := p_old_val;
524   l_rec.new_val                          := p_new_val;
525   l_rec.whatif_lbl_txt                   := p_whatif_lbl_txt;
526   l_rec.rule_overrides_flag                   := p_rule_overrides_flag;
527   l_rec.source_column                    := p_source_column;
528   l_rec.source_table                     := p_source_table;
529   l_rec.business_group_id                := p_business_group_id;
530   l_rec.psl_attribute_category           := p_psl_attribute_category;
531   l_rec.psl_attribute1                   := p_psl_attribute1;
532   l_rec.psl_attribute2                   := p_psl_attribute2;
533   l_rec.psl_attribute3                   := p_psl_attribute3;
534   l_rec.psl_attribute4                   := p_psl_attribute4;
535   l_rec.psl_attribute5                   := p_psl_attribute5;
536   l_rec.psl_attribute6                   := p_psl_attribute6;
537   l_rec.psl_attribute7                   := p_psl_attribute7;
538   l_rec.psl_attribute8                   := p_psl_attribute8;
539   l_rec.psl_attribute9                   := p_psl_attribute9;
540   l_rec.psl_attribute10                  := p_psl_attribute10;
541   l_rec.psl_attribute11                  := p_psl_attribute11;
542   l_rec.psl_attribute12                  := p_psl_attribute12;
543   l_rec.psl_attribute13                  := p_psl_attribute13;
544   l_rec.psl_attribute14                  := p_psl_attribute14;
545   l_rec.psl_attribute15                  := p_psl_attribute15;
546   l_rec.psl_attribute16                  := p_psl_attribute16;
547   l_rec.psl_attribute17                  := p_psl_attribute17;
548   l_rec.psl_attribute18                  := p_psl_attribute18;
549   l_rec.psl_attribute19                  := p_psl_attribute19;
550   l_rec.psl_attribute20                  := p_psl_attribute20;
551   l_rec.psl_attribute21                  := p_psl_attribute21;
552   l_rec.psl_attribute22                  := p_psl_attribute22;
553   l_rec.psl_attribute23                  := p_psl_attribute23;
554   l_rec.psl_attribute24                  := p_psl_attribute24;
555   l_rec.psl_attribute25                  := p_psl_attribute25;
556   l_rec.psl_attribute26                  := p_psl_attribute26;
557   l_rec.psl_attribute27                  := p_psl_attribute27;
558   l_rec.psl_attribute28                  := p_psl_attribute28;
559   l_rec.psl_attribute29                  := p_psl_attribute29;
560   l_rec.psl_attribute30                  := p_psl_attribute30;
561   l_rec.object_version_number            := p_object_version_number;
562   --
563   -- Return the plsql record structure.
564   --
565   hr_utility.set_location(' Leaving:'||l_proc, 10);
566   Return(l_rec);
567 --
568 End convert_args;
569 --
570 end ben_psl_shd;