DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_LOU_SHD

Source


1 Package Body ben_lou_shd as
2 /* $Header: belourhi.pkb 115.7 2002/12/13 06:19:52 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_lou_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_LER_CHG_OIPL_ENRT_RL_FK1') Then
37     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
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_LER_CHG_OIPL_ENRT_RL_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_ler_chg_oipl_enrt_rl_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 	ler_chg_oipl_enrt_rl_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
74 	formula_id,
75 	ler_chg_oipl_enrt_id,
76 	ordr_to_aply_num,
77 	lou_attribute_category,
78 	lou_attribute1,
79 	lou_attribute2,
80 	lou_attribute3,
81 	lou_attribute4,
82 	lou_attribute5,
83 	lou_attribute6,
84 	lou_attribute7,
85 	lou_attribute8,
86 	lou_attribute9,
87 	lou_attribute10,
88 	lou_attribute11,
89 	lou_attribute12,
90 	lou_attribute13,
91 	lou_attribute14,
92 	lou_attribute15,
93 	lou_attribute16,
94 	lou_attribute17,
95 	lou_attribute18,
96 	lou_attribute19,
97 	lou_attribute20,
98 	lou_attribute21,
99 	lou_attribute22,
100 	lou_attribute23,
101 	lou_attribute24,
102 	lou_attribute25,
103 	lou_attribute26,
104 	lou_attribute27,
105 	lou_attribute28,
106 	lou_attribute29,
107 	lou_attribute30,
108 	object_version_number
109     from	ben_ler_chg_oipl_enrt_rl_f
110     where	ler_chg_oipl_enrt_rl_id = p_ler_chg_oipl_enrt_rl_id
111     and		p_effective_date
112     between	effective_start_date and effective_end_date;
113 --
114   l_proc	varchar2(72)	:= g_package||'api_updating';
115   l_fct_ret	boolean;
116 --
117 Begin
118   hr_utility.set_location('Entering:'||l_proc, 5);
119   --
120   If (p_effective_date is null or
121       p_ler_chg_oipl_enrt_rl_id is null or
122       p_object_version_number is null) Then
123     --
124     -- One of the primary key arguments is null therefore we must
125     -- set the returning function value to false
126     --
127     l_fct_ret := false;
128   Else
129     If (p_ler_chg_oipl_enrt_rl_id = g_old_rec.ler_chg_oipl_enrt_rl_id and
130         p_object_version_number = g_old_rec.object_version_number) Then
131       hr_utility.set_location(l_proc, 10);
132       --
133       -- The g_old_rec is current therefore we must
134       -- set the returning function to true
135       --
136       l_fct_ret := true;
137     Else
138       --
139       -- Select the current row
140       --
141       Open C_Sel1;
142       Fetch C_Sel1 Into g_old_rec;
143       If C_Sel1%notfound Then
144         Close C_Sel1;
145         --
146         -- The primary key is invalid therefore we must error
147         --
148         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149         fnd_message.raise_error;
150       End If;
151       Close C_Sel1;
152       If (p_object_version_number <> g_old_rec.object_version_number) Then
153         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154         fnd_message.raise_error;
155       End If;
156       hr_utility.set_location(l_proc, 15);
157       l_fct_ret := true;
158     End If;
159   End If;
160   hr_utility.set_location(' Leaving:'||l_proc, 20);
161   Return (l_fct_ret);
162 --
163 End api_updating;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |--------------------------< find_dt_del_modes >---------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure find_dt_del_modes
169 	(p_effective_date	in  date,
170 	 p_base_key_value	in  number,
171 	 p_zap		 out nocopy boolean,
172 	 p_delete	 out nocopy boolean,
173 	 p_future_change out nocopy boolean,
174 	 p_delete_next_change out nocopy boolean) is
175 --
176   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
177 --
178   l_parent_key_value1	number;
179   --
180   Cursor C_Sel1 Is
181     select  t.ler_chg_oipl_enrt_id
182     from    ben_ler_chg_oipl_enrt_rl_f t
183     where   t.ler_chg_oipl_enrt_rl_id = p_base_key_value
184     and     p_effective_date
185     between t.effective_start_date and t.effective_end_date;
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   Open  C_Sel1;
190   Fetch C_Sel1 Into l_parent_key_value1;
191   If C_Sel1%notfound then
192     Close C_Sel1;
193     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
194     fnd_message.set_token('PROCEDURE', l_proc);
195     fnd_message.set_token('STEP','10');
196     fnd_message.raise_error;
197   End If;
198   Close C_Sel1;
199   --
200   -- Call the corresponding datetrack api
201   --
202   dt_api.find_dt_del_modes
203 	(p_effective_date	=> p_effective_date,
204 	 p_base_table_name	=> 'ben_ler_chg_oipl_enrt_rl_f',
205 	 p_base_key_column	=> 'ler_chg_oipl_enrt_rl_id',
206 	 p_base_key_value	=> p_base_key_value,
207 	 p_parent_table_name1	=> 'ben_ler_chg_oipl_enrt_f',
208 	 p_parent_key_column1	=> 'ler_chg_oipl_enrt_id',
209 	 p_parent_key_value1	=> l_parent_key_value1,
210 	 p_zap			=> p_zap,
211 	 p_delete		=> p_delete,
212 	 p_future_change	=> p_future_change,
213 	 p_delete_next_change	=> p_delete_next_change);
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End find_dt_del_modes;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |--------------------------< find_dt_upd_modes >---------------------------|
220 -- ----------------------------------------------------------------------------
221 Procedure find_dt_upd_modes
222 	(p_effective_date	in  date,
223 	 p_base_key_value	in  number,
224 	 p_correction	 out nocopy boolean,
225 	 p_update	 out nocopy boolean,
226 	 p_update_override out nocopy boolean,
227 	 p_update_change_insert out nocopy boolean) is
228 --
229   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233   --
234   -- Call the corresponding datetrack api
235   --
236   dt_api.find_dt_upd_modes
237 	(p_effective_date	=> p_effective_date,
238 	 p_base_table_name	=> 'ben_ler_chg_oipl_enrt_rl_f',
239 	 p_base_key_column	=> 'ler_chg_oipl_enrt_rl_id',
240 	 p_base_key_value	=> p_base_key_value,
241 	 p_correction		=> p_correction,
242 	 p_update		=> p_update,
243 	 p_update_override	=> p_update_override,
244 	 p_update_change_insert	=> p_update_change_insert);
245   --
246   hr_utility.set_location(' Leaving:'||l_proc, 10);
247 End find_dt_upd_modes;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |------------------------< upd_effective_end_date >------------------------|
251 -- ----------------------------------------------------------------------------
252 Procedure upd_effective_end_date
253 	(p_effective_date		in date,
254 	 p_base_key_value		in number,
255 	 p_new_effective_end_date	in date,
256 	 p_validation_start_date	in date,
257 	 p_validation_end_date		in date,
258          p_object_version_number       out nocopy number) is
259 --
260   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
261   l_object_version_number number;
262 --
263 Begin
264   hr_utility.set_location('Entering:'||l_proc, 5);
265   --
266   -- Because we are updating a row we must get the next object
267   -- version number.
268   --
269   l_object_version_number :=
270     dt_api.get_object_version_number
271 	(p_base_table_name	=> 'ben_ler_chg_oipl_enrt_rl_f',
272 	 p_base_key_column	=> 'ler_chg_oipl_enrt_rl_id',
273 	 p_base_key_value	=> p_base_key_value);
274   --
278   -- Update the specified datetrack row setting the effective
275   hr_utility.set_location(l_proc, 10);
276   g_api_dml := true;  -- Set the api dml status
277   --
279   -- end date to the specified new effective end date.
280   --
281   update  ben_ler_chg_oipl_enrt_rl_f t
282   set	  t.effective_end_date	  = p_new_effective_end_date,
283 	  t.object_version_number = l_object_version_number
284   where	  t.ler_chg_oipl_enrt_rl_id	  = p_base_key_value
285   and	  p_effective_date
286   between t.effective_start_date and t.effective_end_date;
287   --
288   g_api_dml := false;   -- Unset the api dml status
289   p_object_version_number := l_object_version_number;
290   hr_utility.set_location(' Leaving:'||l_proc, 15);
291 --
292 Exception
293   When Others Then
294     g_api_dml := false;   -- Unset the api dml status
295     Raise;
296 End upd_effective_end_date;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |---------------------------------< lck >----------------------------------|
300 -- ----------------------------------------------------------------------------
301 Procedure lck
302 	(p_effective_date	 in  date,
303 	 p_datetrack_mode	 in  varchar2,
304 	 p_ler_chg_oipl_enrt_rl_id	 in  number,
305 	 p_object_version_number in  number,
306 	 p_validation_start_date out nocopy date,
307 	 p_validation_end_date	 out nocopy date) is
308 --
309   l_proc		  varchar2(72) := g_package||'lck';
310   l_validation_start_date date;
311   l_validation_end_date	  date;
312   l_object_invalid 	  exception;
313   l_argument		  varchar2(30);
314   --
315   -- Cursor C_Sel1 selects the current locked row as of session date
316   -- ensuring that the object version numbers match.
317   --
318   Cursor C_Sel1 is
319     select
320 	ler_chg_oipl_enrt_rl_id,
321 	effective_start_date,
322 	effective_end_date,
323 	business_group_id,
324 	formula_id,
325 	ler_chg_oipl_enrt_id,
326 	ordr_to_aply_num,
327 	lou_attribute_category,
328 	lou_attribute1,
329 	lou_attribute2,
330 	lou_attribute3,
334 	lou_attribute7,
331 	lou_attribute4,
332 	lou_attribute5,
333 	lou_attribute6,
335 	lou_attribute8,
336 	lou_attribute9,
337 	lou_attribute10,
338 	lou_attribute11,
339 	lou_attribute12,
340 	lou_attribute13,
341 	lou_attribute14,
342 	lou_attribute15,
343 	lou_attribute16,
344 	lou_attribute17,
345 	lou_attribute18,
346 	lou_attribute19,
347 	lou_attribute20,
348 	lou_attribute21,
349 	lou_attribute22,
350 	lou_attribute23,
351 	lou_attribute24,
352 	lou_attribute25,
353 	lou_attribute26,
354 	lou_attribute27,
355 	lou_attribute28,
356 	lou_attribute29,
357 	lou_attribute30,
358 	object_version_number
359     from    ben_ler_chg_oipl_enrt_rl_f
360     where   ler_chg_oipl_enrt_rl_id         = p_ler_chg_oipl_enrt_rl_id
361     and	    p_effective_date
362     between effective_start_date and effective_end_date
363     for update nowait;
364   --
365   --
366   --
367 Begin
368   hr_utility.set_location('Entering:'||l_proc, 5);
369   --
370   -- Ensure that all the mandatory arguments are not null
371   --
372   hr_api.mandatory_arg_error(p_api_name       => l_proc,
373                              p_argument       => 'effective_date',
374                              p_argument_value => p_effective_date);
375   --
379   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'datetrack_mode',
378                              p_argument_value => p_datetrack_mode);
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'ler_chg_oipl_enrt_rl_id',
382                              p_argument_value => p_ler_chg_oipl_enrt_rl_id);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'object_version_number',
386                              p_argument_value => p_object_version_number);
387   --
388   -- Check to ensure the datetrack mode is not INSERT.
389   --
390   If (p_datetrack_mode <> 'INSERT') then
391     --
392     -- We must select and lock the current row.
393     --
394     Open  C_Sel1;
395     Fetch C_Sel1 Into g_old_rec;
396     If C_Sel1%notfound then
397       Close C_Sel1;
398       --
399       -- The primary key is invalid therefore we must error
400       --
401       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
402       fnd_message.raise_error;
403     End If;
404     Close C_Sel1;
405     If (p_object_version_number <> g_old_rec.object_version_number) Then
406         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
407         fnd_message.raise_error;
408       End If;
409     hr_utility.set_location(l_proc, 15);
410     --
411     --
415     dt_api.validate_dt_mode
412     -- Validate the datetrack mode mode getting the validation start
413     -- and end dates for the specified datetrack operation.
414     --
416 	(p_effective_date	   => p_effective_date,
417 	 p_datetrack_mode	   => p_datetrack_mode,
418 	 p_base_table_name	   => 'ben_ler_chg_oipl_enrt_rl_f',
419 	 p_base_key_column	   => 'ler_chg_oipl_enrt_rl_id',
420 	 p_base_key_value 	   => p_ler_chg_oipl_enrt_rl_id,
421 	 p_parent_table_name1      => 'ben_ler_chg_oipl_enrt_f',
422 	 p_parent_key_column1      => 'ler_chg_oipl_enrt_id',
423 	 p_parent_key_value1       => g_old_rec.ler_chg_oipl_enrt_id,
424          p_enforce_foreign_locking => true,
425 	 p_validation_start_date   => l_validation_start_date,
426  	 p_validation_end_date	   => l_validation_end_date);
427   Else
428     --
429     -- We are doing a datetrack 'INSERT' which is illegal within this
430     -- procedure therefore we must error (note: to lck on insert the
431     -- private procedure ins_lck should be called).
432     --
433     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
434     fnd_message.set_token('PROCEDURE', l_proc);
435     fnd_message.set_token('STEP','20');
436     fnd_message.raise_error;
437   End If;
438   --
439   -- Set the validation start and end date OUT arguments
440   --
441   p_validation_start_date := l_validation_start_date;
442   p_validation_end_date   := l_validation_end_date;
443   --
444   hr_utility.set_location(' Leaving:'||l_proc, 30);
445 --
449   When HR_Api.Object_Locked then
446 -- We need to trap the ORA LOCK exception
447 --
448 Exception
450     --
451     -- The object is locked therefore we need to supply a meaningful
452     -- error message.
453     --
454     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
455     fnd_message.set_token('TABLE_NAME', 'ben_ler_chg_oipl_enrt_rl_f');
456     fnd_message.raise_error;
457   When l_object_invalid then
458     --
459     -- The object doesn't exist or is invalid
460     --
461     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
462     fnd_message.set_token('TABLE_NAME', 'ben_ler_chg_oipl_enrt_rl_f');
463     fnd_message.raise_error;
464 End lck;
465 --
466 -- ----------------------------------------------------------------------------
467 -- |-----------------------------< convert_args >-----------------------------|
468 -- ----------------------------------------------------------------------------
469 Function convert_args
470 	(
471 	p_ler_chg_oipl_enrt_rl_id       in number,
472 	p_effective_start_date          in date,
473 	p_effective_end_date            in date,
474 	p_business_group_id             in number,
475 	p_formula_id           in number,
476 	p_ler_chg_oipl_enrt_id          in number,
477 	p_ordr_to_aply_num              in number,
478 	p_lou_attribute_category        in varchar2,
479 	p_lou_attribute1                in varchar2,
480 	p_lou_attribute2                in varchar2,
481 	p_lou_attribute3                in varchar2,
482 	p_lou_attribute4                in varchar2,
483 	p_lou_attribute5                in varchar2,
484 	p_lou_attribute6                in varchar2,
485 	p_lou_attribute7                in varchar2,
486 	p_lou_attribute8                in varchar2,
487 	p_lou_attribute9                in varchar2,
488 	p_lou_attribute10               in varchar2,
489 	p_lou_attribute11               in varchar2,
490 	p_lou_attribute12               in varchar2,
491 	p_lou_attribute13               in varchar2,
492 	p_lou_attribute14               in varchar2,
493 	p_lou_attribute15               in varchar2,
494 	p_lou_attribute16               in varchar2,
495 	p_lou_attribute17               in varchar2,
496 	p_lou_attribute18               in varchar2,
497 	p_lou_attribute19               in varchar2,
498 	p_lou_attribute20               in varchar2,
499 	p_lou_attribute21               in varchar2,
500 	p_lou_attribute22               in varchar2,
501 	p_lou_attribute23               in varchar2,
502 	p_lou_attribute24               in varchar2,
503 	p_lou_attribute25               in varchar2,
504 	p_lou_attribute26               in varchar2,
505 	p_lou_attribute27               in varchar2,
506 	p_lou_attribute28               in varchar2,
507 	p_lou_attribute29               in varchar2,
508 	p_lou_attribute30               in varchar2,
509 	p_object_version_number         in number
510 	)
511 	Return g_rec_type is
512 --
513   l_rec	  g_rec_type;
514   l_proc  varchar2(72) := g_package||'convert_args';
515 --
516 Begin
517   --
518   hr_utility.set_location('Entering:'||l_proc, 5);
519   --
520   -- Convert arguments into local l_rec structure.
521   --
522   l_rec.ler_chg_oipl_enrt_rl_id          := p_ler_chg_oipl_enrt_rl_id;
523   l_rec.effective_start_date             := p_effective_start_date;
524   l_rec.effective_end_date               := p_effective_end_date;
525   l_rec.business_group_id                := p_business_group_id;
526   l_rec.formula_id              := p_formula_id;
527   l_rec.ler_chg_oipl_enrt_id             := p_ler_chg_oipl_enrt_id;
528   l_rec.ordr_to_aply_num                 := p_ordr_to_aply_num;
529   l_rec.lou_attribute_category           := p_lou_attribute_category;
530   l_rec.lou_attribute1                   := p_lou_attribute1;
531   l_rec.lou_attribute2                   := p_lou_attribute2;
532   l_rec.lou_attribute3                   := p_lou_attribute3;
533   l_rec.lou_attribute4                   := p_lou_attribute4;
534   l_rec.lou_attribute5                   := p_lou_attribute5;
535   l_rec.lou_attribute6                   := p_lou_attribute6;
536   l_rec.lou_attribute7                   := p_lou_attribute7;
537   l_rec.lou_attribute8                   := p_lou_attribute8;
538   l_rec.lou_attribute9                   := p_lou_attribute9;
539   l_rec.lou_attribute10                  := p_lou_attribute10;
540   l_rec.lou_attribute11                  := p_lou_attribute11;
541   l_rec.lou_attribute12                  := p_lou_attribute12;
542   l_rec.lou_attribute13                  := p_lou_attribute13;
543   l_rec.lou_attribute14                  := p_lou_attribute14;
544   l_rec.lou_attribute15                  := p_lou_attribute15;
545   l_rec.lou_attribute16                  := p_lou_attribute16;
546   l_rec.lou_attribute17                  := p_lou_attribute17;
547   l_rec.lou_attribute18                  := p_lou_attribute18;
548   l_rec.lou_attribute19                  := p_lou_attribute19;
549   l_rec.lou_attribute20                  := p_lou_attribute20;
550   l_rec.lou_attribute21                  := p_lou_attribute21;
551   l_rec.lou_attribute22                  := p_lou_attribute22;
552   l_rec.lou_attribute23                  := p_lou_attribute23;
553   l_rec.lou_attribute24                  := p_lou_attribute24;
554   l_rec.lou_attribute25                  := p_lou_attribute25;
555   l_rec.lou_attribute26                  := p_lou_attribute26;
556   l_rec.lou_attribute27                  := p_lou_attribute27;
557   l_rec.lou_attribute28                  := p_lou_attribute28;
558   l_rec.lou_attribute29                  := p_lou_attribute29;
559   l_rec.lou_attribute30                  := p_lou_attribute30;
560   l_rec.object_version_number            := p_object_version_number;
561   --
562   -- Return the plsql record structure.
563   --
564   hr_utility.set_location(' Leaving:'||l_proc, 10);
565   Return(l_rec);
566 --
567 End convert_args;
568 --
569 end ben_lou_shd;