DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_LRN_SHD

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_lrn_shd as
2 /* $Header: belrnrhi.pkb 120.2 2006/03/30 23:47:10 gsehgal noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_lrn_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_LVG_RSN_RT_PK') 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   Else
42     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
45     fnd_message.raise_error;
46   End If;
47   --
48   hr_utility.set_location(' Leaving:'||l_proc, 10);
49 End constraint_error;
50 --
51 -- ----------------------------------------------------------------------------
52 -- |-----------------------------< api_updating >-----------------------------|
53 -- ----------------------------------------------------------------------------
54 Function api_updating
55   (p_effective_date		in date,
56    p_lvg_rsn_rt_id		in number,
57    p_object_version_number	in number
58   ) Return Boolean Is
59 --
60   --
61   -- Cursor selects the 'current' row from the HR Schema
62   --
63   Cursor C_Sel1 is
64     select
65 	lvg_rsn_rt_id,
66 	effective_start_date,
67 	effective_end_date,
68 	excld_flag,
69 	ordr_num,
70 	lvg_rsn_cd,
71 	vrbl_rt_prfl_id,
72 	business_group_id,
73 	lrn_attribute_category,
74 	lrn_attribute1,
75 	lrn_attribute2,
76 	lrn_attribute3,
77 	lrn_attribute4,
78 	lrn_attribute5,
79 	lrn_attribute6,
80 	lrn_attribute7,
81 	lrn_attribute8,
82 	lrn_attribute9,
83 	lrn_attribute10,
84 	lrn_attribute11,
85 	lrn_attribute12,
86 	lrn_attribute13,
87 	lrn_attribute14,
88 	lrn_attribute15,
89 	lrn_attribute16,
90 	lrn_attribute17,
91 	lrn_attribute18,
92 	lrn_attribute19,
93 	lrn_attribute20,
94 	lrn_attribute21,
95 	lrn_attribute22,
96 	lrn_attribute23,
97 	lrn_attribute24,
98 	lrn_attribute25,
99 	lrn_attribute26,
100 	lrn_attribute27,
101 	lrn_attribute28,
102 	lrn_attribute29,
103 	lrn_attribute30,
104 	object_version_number
105     from	ben_lvg_rsn_rt_f
106     where	lvg_rsn_rt_id = p_lvg_rsn_rt_id
107     and		p_effective_date
108     between	effective_start_date and effective_end_date;
109 --
110   l_proc	varchar2(72)	:= g_package||'api_updating';
111   l_fct_ret	boolean;
112 --
113 Begin
114   hr_utility.set_location('Entering:'||l_proc, 5);
115   --
116   If (p_effective_date is null or
117       p_lvg_rsn_rt_id is null or
118       p_object_version_number is null) Then
119     --
120     -- One of the primary key arguments is null therefore we must
121     -- set the returning function value to false
122     --
123     l_fct_ret := false;
124   Else
128       --
125     If (p_lvg_rsn_rt_id = g_old_rec.lvg_rsn_rt_id and
126         p_object_version_number = g_old_rec.object_version_number) Then
127       hr_utility.set_location(l_proc, 10);
129       -- The g_old_rec is current therefore we must
130       -- set the returning function to true
131       --
132       l_fct_ret := true;
133     Else
134       --
135       -- Select the current row
136       --
137       Open C_Sel1;
138       Fetch C_Sel1 Into g_old_rec;
139       If C_Sel1%notfound Then
140         Close C_Sel1;
141         --
142         -- The primary key is invalid therefore we must error
143         --
144         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
145         fnd_message.raise_error;
146       End If;
147       Close C_Sel1;
148       If (p_object_version_number <> g_old_rec.object_version_number) Then
149         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
150         fnd_message.raise_error;
151       End If;
152       hr_utility.set_location(l_proc, 15);
153       l_fct_ret := true;
154     End If;
155   End If;
156   hr_utility.set_location(' Leaving:'||l_proc, 20);
157   Return (l_fct_ret);
158 --
159 End api_updating;
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) is
171 --
172   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
173 --
174   l_parent_key_value1	number;
175   --
176   Cursor C_Sel1 Is
177     select  t.vrbl_rt_prfl_id
178     from    ben_lvg_rsn_rt_f t
179     where   t.lvg_rsn_rt_id = p_base_key_value
180     and     p_effective_date
181     between t.effective_start_date and t.effective_end_date;
182 --
183 Begin
184   hr_utility.set_location('Entering:'||l_proc, 5);
185   Open  C_Sel1;
186   Fetch C_Sel1 Into l_parent_key_value1;
187   If C_Sel1%notfound then
188     Close C_Sel1;
189     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
190     fnd_message.set_token('PROCEDURE', l_proc);
191     fnd_message.set_token('STEP','10');
192     fnd_message.raise_error;
193   End If;
194   Close C_Sel1;
195   --
196   -- Call the corresponding datetrack api
197   --
198   dt_api.find_dt_del_modes
199 	(p_effective_date	=> p_effective_date,
200 	 p_base_table_name	=> 'ben_lvg_rsn_rt_f',
201 	 p_base_key_column	=> 'lvg_rsn_rt_id',
202 	 p_base_key_value	=> p_base_key_value,
203 	 p_parent_table_name1	=> 'ben_vrbl_rt_prfl_f',
204 	 p_parent_key_column1	=> 'vrbl_rt_prfl_id',
205 	 p_parent_key_value1	=> l_parent_key_value1,
206 	 p_zap			=> p_zap,
207 	 p_delete		=> p_delete,
208 	 p_future_change	=> p_future_change,
209 	 p_delete_next_change	=> p_delete_next_change);
210   --
211   hr_utility.set_location(' Leaving:'||l_proc, 10);
212 End find_dt_del_modes;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |--------------------------< find_dt_upd_modes >---------------------------|
216 -- ----------------------------------------------------------------------------
217 Procedure find_dt_upd_modes
218 	(p_effective_date	in  date,
219 	 p_base_key_value	in  number,
220 	 p_correction	 out nocopy boolean,
221 	 p_update	 out nocopy boolean,
222 	 p_update_override out nocopy boolean,
223 	 p_update_change_insert out nocopy boolean) is
224 --
225   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   --
230   -- Call the corresponding datetrack api
231   --
232   dt_api.find_dt_upd_modes
233 	(p_effective_date	=> p_effective_date,
234 	 p_base_table_name	=> 'ben_lvg_rsn_rt_f',
235 	 p_base_key_column	=> 'lvg_rsn_rt_id',
236 	 p_base_key_value	=> p_base_key_value,
237 	 p_correction		=> p_correction,
238 	 p_update		=> p_update,
239 	 p_update_override	=> p_update_override,
240 	 p_update_change_insert	=> p_update_change_insert);
241   --
242   hr_utility.set_location(' Leaving:'||l_proc, 10);
243 End find_dt_upd_modes;
244 --
245 -- ----------------------------------------------------------------------------
246 -- |------------------------< upd_effective_end_date >------------------------|
247 -- ----------------------------------------------------------------------------
248 Procedure upd_effective_end_date
249 	(p_effective_date		in date,
250 	 p_base_key_value		in number,
251 	 p_new_effective_end_date	in date,
252 	 p_validation_start_date	in date,
253 	 p_validation_end_date		in date,
254          p_object_version_number       out nocopy number) is
255 --
256   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
257   l_object_version_number number;
258 --
259 Begin
260   hr_utility.set_location('Entering:'||l_proc, 5);
261   --
262   -- Because we are updating a row we must get the next object
263   -- version number.
264   --
265   l_object_version_number :=
266     dt_api.get_object_version_number
267 	(p_base_table_name	=> 'ben_lvg_rsn_rt_f',
268 	 p_base_key_column	=> 'lvg_rsn_rt_id',
269 	 p_base_key_value	=> p_base_key_value);
270   --
271   hr_utility.set_location(l_proc, 10);
272   g_api_dml := true;  -- Set the api dml status
273   --
277   update  ben_lvg_rsn_rt_f t
274   -- Update the specified datetrack row setting the effective
275   -- end date to the specified new effective end date.
276   --
278   set	  t.effective_end_date	  = p_new_effective_end_date,
279 	  t.object_version_number = l_object_version_number
280   where	  t.lvg_rsn_rt_id	  = p_base_key_value
281   and	  p_effective_date
282   between t.effective_start_date and t.effective_end_date;
283   --
284   g_api_dml := false;   -- Unset the api dml status
285   p_object_version_number := l_object_version_number;
286   hr_utility.set_location(' Leaving:'||l_proc, 15);
287 --
288 Exception
289   When Others Then
290     g_api_dml := false;   -- Unset the api dml status
291     Raise;
292 End upd_effective_end_date;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------------< lck >----------------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure lck
298 	(p_effective_date	 in  date,
299 	 p_datetrack_mode	 in  varchar2,
300 	 p_lvg_rsn_rt_id	 in  number,
301 	 p_object_version_number in  number,
302 	 p_validation_start_date out nocopy date,
303 	 p_validation_end_date	 out nocopy date) is
304 --
305   l_proc		  varchar2(72) := g_package||'lck';
306   l_validation_start_date date;
307   l_validation_end_date	  date;
308   l_object_invalid 	  exception;
309   l_argument		  varchar2(30);
310   --
311   -- Cursor C_Sel1 selects the current locked row as of session date
312   -- ensuring that the object version numbers match.
313   --
314   Cursor C_Sel1 is
315     select
316 	lvg_rsn_rt_id,
317 	effective_start_date,
318 	effective_end_date,
319 	excld_flag,
320 	ordr_num,
321 	lvg_rsn_cd,
322 	vrbl_rt_prfl_id,
323 	business_group_id,
324 	lrn_attribute_category,
325 	lrn_attribute1,
326 	lrn_attribute2,
327 	lrn_attribute3,
328 	lrn_attribute4,
329 	lrn_attribute5,
330 	lrn_attribute6,
331 	lrn_attribute7,
332 	lrn_attribute8,
333 	lrn_attribute9,
334 	lrn_attribute10,
335 	lrn_attribute11,
336 	lrn_attribute12,
337 	lrn_attribute13,
338 	lrn_attribute14,
339 	lrn_attribute15,
340 	lrn_attribute16,
341 	lrn_attribute17,
342 	lrn_attribute18,
343 	lrn_attribute19,
344 	lrn_attribute20,
345 	lrn_attribute21,
346 	lrn_attribute22,
347 	lrn_attribute23,
348 	lrn_attribute24,
349 	lrn_attribute25,
350 	lrn_attribute26,
351 	lrn_attribute27,
352 	lrn_attribute28,
353 	lrn_attribute29,
354 	lrn_attribute30,
355 	object_version_number
356     from    ben_lvg_rsn_rt_f
357     where   lvg_rsn_rt_id         = p_lvg_rsn_rt_id
358     and	    p_effective_date
359     between effective_start_date and effective_end_date
360     for update nowait;
361   --
362   --
363   --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Ensure that all the mandatory arguments are not null
368   --
369   hr_api.mandatory_arg_error(p_api_name       => l_proc,
370                              p_argument       => 'effective_date',
371                              p_argument_value => p_effective_date);
372   --
373   hr_api.mandatory_arg_error(p_api_name       => l_proc,
374                              p_argument       => 'datetrack_mode',
375                              p_argument_value => p_datetrack_mode);
376   --
377   hr_api.mandatory_arg_error(p_api_name       => l_proc,
378                              p_argument       => 'lvg_rsn_rt_id',
379                              p_argument_value => p_lvg_rsn_rt_id);
380   --
381   hr_api.mandatory_arg_error(p_api_name       => l_proc,
382                              p_argument       => 'object_version_number',
383                              p_argument_value => p_object_version_number);
384   --
385   -- Check to ensure the datetrack mode is not INSERT.
386   --
387   If (p_datetrack_mode <> 'INSERT') then
388     --
389     -- We must select and lock the current row.
390     --
391     Open  C_Sel1;
392     Fetch C_Sel1 Into g_old_rec;
393     If C_Sel1%notfound then
394       Close C_Sel1;
395       --
396       -- The primary key is invalid therefore we must error
397       --
398       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
399       fnd_message.raise_error;
400     End If;
401     Close C_Sel1;
402     If (p_object_version_number <> g_old_rec.object_version_number) Then
403         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
404         fnd_message.raise_error;
405       End If;
406     hr_utility.set_location(l_proc, 15);
407     --
408     --
409     -- Validate the datetrack mode mode getting the validation start
410     -- and end dates for the specified datetrack operation.
411     --
412     dt_api.validate_dt_mode
413 	(p_effective_date	   => p_effective_date,
414 	 p_datetrack_mode	   => p_datetrack_mode,
415 	 p_base_table_name	   => 'ben_lvg_rsn_rt_f',
416 	 p_base_key_column	   => 'lvg_rsn_rt_id',
417 	 p_base_key_value 	   => p_lvg_rsn_rt_id,
418 	 p_parent_table_name1      => 'ben_vrbl_rt_prfl_f',
419 	 p_parent_key_column1      => 'vrbl_rt_prfl_id',
420 	 p_parent_key_value1       => g_old_rec.vrbl_rt_prfl_id,
421          p_enforce_foreign_locking => true,
422 	 p_validation_start_date   => l_validation_start_date,
423  	 p_validation_end_date	   => l_validation_end_date);
424   Else
425     --
426     -- We are doing a datetrack 'INSERT' which is illegal within this
430     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
427     -- procedure therefore we must error (note: to lck on insert the
428     -- private procedure ins_lck should be called).
429     --
431     fnd_message.set_token('PROCEDURE', l_proc);
432     fnd_message.set_token('STEP','20');
433     fnd_message.raise_error;
434   End If;
435   --
436   -- Set the validation start and end date OUT arguments
437   --
438   p_validation_start_date := l_validation_start_date;
439   p_validation_end_date   := l_validation_end_date;
440   --
441   hr_utility.set_location(' Leaving:'||l_proc, 30);
442 --
443 -- We need to trap the ORA LOCK exception
444 --
445 Exception
446   When HR_Api.Object_Locked then
447     --
448     -- The object is locked therefore we need to supply a meaningful
449     -- error message.
450     --
451     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
452     fnd_message.set_token('TABLE_NAME', 'ben_lvg_rsn_rt_f');
453     fnd_message.raise_error;
454   When l_object_invalid then
455     --
456     -- The object doesn't exist or is invalid
457     --
458     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
459     fnd_message.set_token('TABLE_NAME', 'ben_lvg_rsn_rt_f');
460     fnd_message.raise_error;
461 End lck;
462 --
463 -- ----------------------------------------------------------------------------
464 -- |-----------------------------< convert_args >-----------------------------|
465 -- ----------------------------------------------------------------------------
466 Function convert_args
467 	(
468 	p_lvg_rsn_rt_id          in number,
469 	p_effective_start_date          in date,
470 	p_effective_end_date            in date,
471 	p_excld_flag                    in varchar2,
472 	p_ordr_num                      in number,
473 	p_lvg_rsn_cd                    in varchar2,
474 	p_vrbl_rt_prfl_id                 in number,
475 	p_business_group_id             in number,
476 	p_lrn_attribute_category        in varchar2,
477 	p_lrn_attribute1                in varchar2,
478 	p_lrn_attribute2                in varchar2,
479 	p_lrn_attribute3                in varchar2,
480 	p_lrn_attribute4                in varchar2,
481 	p_lrn_attribute5                in varchar2,
482 	p_lrn_attribute6                in varchar2,
483 	p_lrn_attribute7                in varchar2,
484 	p_lrn_attribute8                in varchar2,
485 	p_lrn_attribute9                in varchar2,
486 	p_lrn_attribute10               in varchar2,
487 	p_lrn_attribute11               in varchar2,
488 	p_lrn_attribute12               in varchar2,
489 	p_lrn_attribute13               in varchar2,
490 	p_lrn_attribute14               in varchar2,
491 	p_lrn_attribute15               in varchar2,
492 	p_lrn_attribute16               in varchar2,
493 	p_lrn_attribute17               in varchar2,
494 	p_lrn_attribute18               in varchar2,
495 	p_lrn_attribute19               in varchar2,
496 	p_lrn_attribute20               in varchar2,
497 	p_lrn_attribute21               in varchar2,
498 	p_lrn_attribute22               in varchar2,
499 	p_lrn_attribute23               in varchar2,
500 	p_lrn_attribute24               in varchar2,
501 	p_lrn_attribute25               in varchar2,
502 	p_lrn_attribute26               in varchar2,
503 	p_lrn_attribute27               in varchar2,
504 	p_lrn_attribute28               in varchar2,
505 	p_lrn_attribute29               in varchar2,
506 	p_lrn_attribute30               in varchar2,
507 	p_object_version_number         in number
508 	)
509 	Return g_rec_type is
510 --
511   l_rec	  g_rec_type;
512   l_proc  varchar2(72) := g_package||'convert_args';
513 --
514 Begin
515   --
516   hr_utility.set_location('Entering:'||l_proc, 5);
517   --
518   -- Convert arguments into local l_rec structure.
519   --
520   l_rec.lvg_rsn_rt_id             := p_lvg_rsn_rt_id;
521   l_rec.effective_start_date             := p_effective_start_date;
522   l_rec.effective_end_date               := p_effective_end_date;
523   l_rec.excld_flag                       := p_excld_flag;
524   l_rec.ordr_num                         := p_ordr_num;
525   l_rec.lvg_rsn_cd                       := p_lvg_rsn_cd;
526   l_rec.vrbl_rt_prfl_id                  := p_vrbl_rt_prfl_id;
527   l_rec.business_group_id                := p_business_group_id;
528   l_rec.lrn_attribute_category           := p_lrn_attribute_category;
529   l_rec.lrn_attribute1                   := p_lrn_attribute1;
530   l_rec.lrn_attribute2                   := p_lrn_attribute2;
531   l_rec.lrn_attribute3                   := p_lrn_attribute3;
532   l_rec.lrn_attribute4                   := p_lrn_attribute4;
533   l_rec.lrn_attribute5                   := p_lrn_attribute5;
534   l_rec.lrn_attribute6                   := p_lrn_attribute6;
535   l_rec.lrn_attribute7                   := p_lrn_attribute7;
536   l_rec.lrn_attribute8                   := p_lrn_attribute8;
537   l_rec.lrn_attribute9                   := p_lrn_attribute9;
538   l_rec.lrn_attribute10                  := p_lrn_attribute10;
539   l_rec.lrn_attribute11                  := p_lrn_attribute11;
540   l_rec.lrn_attribute12                  := p_lrn_attribute12;
541   l_rec.lrn_attribute13                  := p_lrn_attribute13;
542   l_rec.lrn_attribute14                  := p_lrn_attribute14;
543   l_rec.lrn_attribute15                  := p_lrn_attribute15;
544   l_rec.lrn_attribute16                  := p_lrn_attribute16;
545   l_rec.lrn_attribute17                  := p_lrn_attribute17;
546   l_rec.lrn_attribute18                  := p_lrn_attribute18;
547   l_rec.lrn_attribute19                  := p_lrn_attribute19;
548   l_rec.lrn_attribute20                  := p_lrn_attribute20;
549   l_rec.lrn_attribute21                  := p_lrn_attribute21;
550   l_rec.lrn_attribute22                  := p_lrn_attribute22;
551   l_rec.lrn_attribute23                  := p_lrn_attribute23;
552   l_rec.lrn_attribute24                  := p_lrn_attribute24;
553   l_rec.lrn_attribute25                  := p_lrn_attribute25;
554   l_rec.lrn_attribute26                  := p_lrn_attribute26;
555   l_rec.lrn_attribute27                  := p_lrn_attribute27;
556   l_rec.lrn_attribute28                  := p_lrn_attribute28;
557   l_rec.lrn_attribute29                  := p_lrn_attribute29;
558   l_rec.lrn_attribute30                  := p_lrn_attribute30;
559   l_rec.object_version_number            := p_object_version_number;
560   --
561   -- Return the plsql record structure.
562   --
563   hr_utility.set_location(' Leaving:'||l_proc, 10);
564   Return(l_rec);
565 --
566 End convert_args;
567 --
568 end ben_lrn_shd;