DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CER_SHD

Source


1 Package Body ben_cer_shd as
2 /* $Header: becerrhi.pkb 120.0 2005/05/28 01:00:50 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cer_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_ELIGY_RL_FK1') Then
37     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('STEP','5');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'BEN_ELIGY_RL_F_PK') Then
42     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('STEP','10');
45     hr_utility.raise_error;
46   Else
47     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
48     hr_utility.set_message_token('PROCEDURE', l_proc);
49     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
50     hr_utility.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_prtn_eligy_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 	prtn_eligy_rl_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
74 	prtn_elig_id,
75 	formula_id,
76 	drvbl_fctr_apls_flag,
77 	mndtry_flag,
78 	ordr_to_aply_num,
79 	cer_attribute_category,
80 	cer_attribute1,
81 	cer_attribute2,
82 	cer_attribute3,
83 	cer_attribute4,
84 	cer_attribute5,
85 	cer_attribute6,
86 	cer_attribute7,
87 	cer_attribute8,
88 	cer_attribute9,
89 	cer_attribute10,
90 	cer_attribute11,
91 	cer_attribute12,
92 	cer_attribute13,
93 	cer_attribute14,
94 	cer_attribute15,
95 	cer_attribute16,
96 	cer_attribute17,
97 	cer_attribute18,
98 	cer_attribute19,
99 	cer_attribute20,
100 	cer_attribute21,
101 	cer_attribute22,
102 	cer_attribute23,
103 	cer_attribute24,
104 	cer_attribute25,
105 	cer_attribute26,
106 	cer_attribute27,
107 	cer_attribute28,
108 	cer_attribute29,
109 	cer_attribute30,
110 	object_version_number
111     from	ben_prtn_eligy_rl_f
112     where	prtn_eligy_rl_id = p_prtn_eligy_rl_id
113     and		p_effective_date
114     between	effective_start_date and effective_end_date;
115 --
116   l_proc	varchar2(72)	:= g_package||'api_updating';
117   l_fct_ret	boolean;
118 --
119 Begin
120   hr_utility.set_location('Entering:'||l_proc, 5);
121   --
122   If (p_effective_date is null or
123       p_prtn_eligy_rl_id is null or
124       p_object_version_number is null) Then
125     --
126     -- One of the primary key arguments is null therefore we must
127     -- set the returning function value to false
128     --
129     l_fct_ret := false;
130   Else
131     If (p_prtn_eligy_rl_id = g_old_rec.prtn_eligy_rl_id and
132         p_object_version_number = g_old_rec.object_version_number) Then
133       hr_utility.set_location(l_proc, 10);
134       --
135       -- The g_old_rec is current therefore we must
136       -- set the returning function to true
137       --
138       l_fct_ret := true;
139     Else
140       --
141       -- Select the current row
142       --
143       Open C_Sel1;
144       Fetch C_Sel1 Into g_old_rec;
145       If C_Sel1%notfound Then
146         Close C_Sel1;
147         --
148         -- The primary key is invalid therefore we must error
149         --
150         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
151         hr_utility.raise_error;
152       End If;
153       Close C_Sel1;
154       If (p_object_version_number <> g_old_rec.object_version_number) Then
155         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
156         hr_utility.raise_error;
157       End If;
158       hr_utility.set_location(l_proc, 15);
159       l_fct_ret := true;
160     End If;
161   End If;
162   hr_utility.set_location(' Leaving:'||l_proc, 20);
163   Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |--------------------------< find_dt_del_modes >---------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 	(p_effective_date	in  date,
172 	 p_base_key_value	in  number,
173 	 p_zap		 out nocopy boolean,
174 	 p_delete	 out nocopy boolean,
175 	 p_future_change out nocopy boolean,
176 	 p_delete_next_change out nocopy boolean) is
177 --
178   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
179 --
180   l_parent_key_value1	number;
181   --
182   Cursor C_Sel1 Is
183     select  t.prtn_elig_id
184     from    ben_prtn_eligy_rl_f t
185     where   t.prtn_eligy_rl_id = p_base_key_value
186     and     p_effective_date
187     between t.effective_start_date and t.effective_end_date;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   Open  C_Sel1;
192   Fetch C_Sel1 Into l_parent_key_value1;
193   If C_Sel1%notfound then
194     Close C_Sel1;
195     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
196     hr_utility.set_message_token('PROCEDURE', l_proc);
197     hr_utility.set_message_token('STEP','10');
198     hr_utility.raise_error;
199   End If;
200   Close C_Sel1;
201   --
202   -- Call the corresponding datetrack api
203   --
204   dt_api.find_dt_del_modes
205 	(p_effective_date	=> p_effective_date,
206 	 p_base_table_name	=> 'ben_prtn_eligy_rl_f',
207 	 p_base_key_column	=> 'prtn_eligy_rl_id',
208 	 p_base_key_value	=> p_base_key_value,
209 	 p_parent_table_name1	=> 'ben_prtn_elig_f',
210 	 p_parent_key_column1	=> 'prtn_elig_id',
211 	 p_parent_key_value1	=> l_parent_key_value1,
212 	 p_zap			=> p_zap,
213 	 p_delete		=> p_delete,
214 	 p_future_change	=> p_future_change,
215 	 p_delete_next_change	=> p_delete_next_change);
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End find_dt_del_modes;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |--------------------------< find_dt_upd_modes >---------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure find_dt_upd_modes
224 	(p_effective_date	in  date,
225 	 p_base_key_value	in  number,
226 	 p_correction	 out nocopy boolean,
227 	 p_update	 out nocopy boolean,
228 	 p_update_override out nocopy boolean,
229 	 p_update_change_insert out nocopy boolean) is
230 --
231   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
232 --
233 Begin
234   hr_utility.set_location('Entering:'||l_proc, 5);
235   --
236   -- Call the corresponding datetrack api
237   --
238   dt_api.find_dt_upd_modes
239 	(p_effective_date	=> p_effective_date,
240 	 p_base_table_name	=> 'ben_prtn_eligy_rl_f',
241 	 p_base_key_column	=> 'prtn_eligy_rl_id',
242 	 p_base_key_value	=> p_base_key_value,
243 	 p_correction		=> p_correction,
244 	 p_update		=> p_update,
245 	 p_update_override	=> p_update_override,
246 	 p_update_change_insert	=> p_update_change_insert);
247   --
248   hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End find_dt_upd_modes;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |------------------------< upd_effective_end_date >------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure upd_effective_end_date
255 	(p_effective_date		in date,
256 	 p_base_key_value		in number,
257 	 p_new_effective_end_date	in date,
258 	 p_validation_start_date	in date,
259 	 p_validation_end_date		in date,
260          p_object_version_number       out nocopy number) is
261 --
262   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
263   l_object_version_number number;
264 --
265 Begin
266   hr_utility.set_location('Entering:'||l_proc, 5);
267   --
268   -- Because we are updating a row we must get the next object
269   -- version number.
270   --
271   l_object_version_number :=
272     dt_api.get_object_version_number
273 	(p_base_table_name	=> 'ben_prtn_eligy_rl_f',
274 	 p_base_key_column	=> 'prtn_eligy_rl_id',
275 	 p_base_key_value	=> p_base_key_value);
276   --
277   hr_utility.set_location(l_proc, 10);
278   g_api_dml := true;  -- Set the api dml status
279   --
280   -- Update the specified datetrack row setting the effective
281   -- end date to the specified new effective end date.
282   --
283   update  ben_prtn_eligy_rl_f t
284   set	  t.effective_end_date	  = p_new_effective_end_date,
285 	  t.object_version_number = l_object_version_number
286   where	  t.prtn_eligy_rl_id	  = p_base_key_value
287   and	  p_effective_date
288   between t.effective_start_date and t.effective_end_date;
289   --
290   g_api_dml := false;   -- Unset the api dml status
291   p_object_version_number := l_object_version_number;
292   hr_utility.set_location(' Leaving:'||l_proc, 15);
293 --
294 Exception
295   When Others Then
296     g_api_dml := false;   -- Unset the api dml status
297     Raise;
298 End upd_effective_end_date;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< lck >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure lck
304 	(p_effective_date	 in  date,
305 	 p_datetrack_mode	 in  varchar2,
306 	 p_prtn_eligy_rl_id	 in  number,
307 	 p_object_version_number in  number,
308 	 p_validation_start_date out nocopy date,
309 	 p_validation_end_date	 out nocopy date) is
310 --
311   l_proc		  varchar2(72) := g_package||'lck';
312   l_validation_start_date date;
313   l_validation_end_date	  date;
314   l_object_invalid 	  exception;
315   l_argument		  varchar2(30);
316   --
317   -- Cursor C_Sel1 selects the current locked row as of session date
318   -- ensuring that the object version numbers match.
319   --
320   Cursor C_Sel1 is
321     select
322 	prtn_eligy_rl_id,
323 	effective_start_date,
324 	effective_end_date,
325 	business_group_id,
326 	prtn_elig_id,
327 	formula_id,
328 	drvbl_fctr_apls_flag,
329 	mndtry_flag,
330 	ordr_to_aply_num,
331 	cer_attribute_category,
332 	cer_attribute1,
333 	cer_attribute2,
334 	cer_attribute3,
335 	cer_attribute4,
336 	cer_attribute5,
337 	cer_attribute6,
338 	cer_attribute7,
339 	cer_attribute8,
340 	cer_attribute9,
341 	cer_attribute10,
342 	cer_attribute11,
343 	cer_attribute12,
344 	cer_attribute13,
345 	cer_attribute14,
346 	cer_attribute15,
347 	cer_attribute16,
348 	cer_attribute17,
349 	cer_attribute18,
350 	cer_attribute19,
351 	cer_attribute20,
352 	cer_attribute21,
353 	cer_attribute22,
354 	cer_attribute23,
355 	cer_attribute24,
356 	cer_attribute25,
357 	cer_attribute26,
358 	cer_attribute27,
359 	cer_attribute28,
360 	cer_attribute29,
361 	cer_attribute30,
362 	object_version_number
363     from    ben_prtn_eligy_rl_f
364     where   prtn_eligy_rl_id         = p_prtn_eligy_rl_id
365     and	    p_effective_date
366     between effective_start_date and effective_end_date
367     for update nowait;
368   --
369   --
370   --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374   -- Ensure that all the mandatory arguments are not null
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'effective_date',
378                              p_argument_value => p_effective_date);
379   --
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'datetrack_mode',
382                              p_argument_value => p_datetrack_mode);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'prtn_eligy_rl_id',
386                              p_argument_value => p_prtn_eligy_rl_id);
387   --
388   hr_api.mandatory_arg_error(p_api_name       => l_proc,
389                              p_argument       => 'object_version_number',
390                              p_argument_value => p_object_version_number);
391   --
392   -- Check to ensure the datetrack mode is not INSERT.
393   --
394   If (p_datetrack_mode <> 'INSERT') then
395     --
396     -- We must select and lock the current row.
397     --
398     Open  C_Sel1;
399     Fetch C_Sel1 Into g_old_rec;
400     If C_Sel1%notfound then
401       Close C_Sel1;
402       --
403       -- The primary key is invalid therefore we must error
404       --
405       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
406       hr_utility.raise_error;
407     End If;
408     Close C_Sel1;
409     If (p_object_version_number <> g_old_rec.object_version_number) Then
410         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
411         hr_utility.raise_error;
412       End If;
413     hr_utility.set_location(l_proc, 15);
414     --
415     --
416     -- Validate the datetrack mode mode getting the validation start
417     -- and end dates for the specified datetrack operation.
418     --
419     dt_api.validate_dt_mode
420 	(p_effective_date	   => p_effective_date,
421 	 p_datetrack_mode	   => p_datetrack_mode,
422 	 p_base_table_name	   => 'ben_prtn_eligy_rl_f',
423 	 p_base_key_column	   => 'prtn_eligy_rl_id',
424 	 p_base_key_value 	   => p_prtn_eligy_rl_id,
425 	 p_parent_table_name1      => 'ben_prtn_elig_f',
426 	 p_parent_key_column1      => 'prtn_elig_id',
427 	 p_parent_key_value1       => g_old_rec.prtn_elig_id,
428          p_enforce_foreign_locking => true,
429 	 p_validation_start_date   => l_validation_start_date,
430  	 p_validation_end_date	   => l_validation_end_date);
431   Else
432     --
433     -- We are doing a datetrack 'INSERT' which is illegal within this
434     -- procedure therefore we must error (note: to lck on insert the
435     -- private procedure ins_lck should be called).
439     hr_utility.set_message_token('STEP','20');
436     --
437     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
438     hr_utility.set_message_token('PROCEDURE', l_proc);
440     hr_utility.raise_error;
441   End If;
442   --
443   -- Set the validation start and end date OUT arguments
444   --
445   p_validation_start_date := l_validation_start_date;
446   p_validation_end_date   := l_validation_end_date;
447   --
448   hr_utility.set_location(' Leaving:'||l_proc, 30);
449 --
450 -- We need to trap the ORA LOCK exception
451 --
452 Exception
453   When HR_Api.Object_Locked then
454     --
455     -- The object is locked therefore we need to supply a meaningful
456     -- error message.
457     --
458     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
459     hr_utility.set_message_token('TABLE_NAME', 'ben_prtn_eligy_rl_f');
460     hr_utility.raise_error;
461   When l_object_invalid then
462     --
463     -- The object doesn't exist or is invalid
464     --
465     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
466     hr_utility.set_message_token('TABLE_NAME', 'ben_prtn_eligy_rl_f');
467     hr_utility.raise_error;
468 End lck;
469 --
470 -- ----------------------------------------------------------------------------
471 -- |-----------------------------< convert_args >-----------------------------|
472 -- ----------------------------------------------------------------------------
473 Function convert_args
474 	(
475 	p_prtn_eligy_rl_id              in number,
476 	p_effective_start_date          in date,
477 	p_effective_end_date            in date,
478 	p_business_group_id             in number,
479 	p_prtn_elig_id                  in number,
480 	p_formula_id                    in number,
481 	p_drvbl_fctr_apls_flag          in varchar2,
482 	p_mndtry_flag                   in varchar2,
483 	p_ordr_to_aply_num              in number,
484 	p_cer_attribute_category        in varchar2,
485 	p_cer_attribute1                in varchar2,
486 	p_cer_attribute2                in varchar2,
487 	p_cer_attribute3                in varchar2,
488 	p_cer_attribute4                in varchar2,
489 	p_cer_attribute5                in varchar2,
490 	p_cer_attribute6                in varchar2,
491 	p_cer_attribute7                in varchar2,
492 	p_cer_attribute8                in varchar2,
493 	p_cer_attribute9                in varchar2,
494 	p_cer_attribute10               in varchar2,
495 	p_cer_attribute11               in varchar2,
496 	p_cer_attribute12               in varchar2,
497 	p_cer_attribute13               in varchar2,
498 	p_cer_attribute14               in varchar2,
499 	p_cer_attribute15               in varchar2,
500 	p_cer_attribute16               in varchar2,
501 	p_cer_attribute17               in varchar2,
502 	p_cer_attribute18               in varchar2,
503 	p_cer_attribute19               in varchar2,
504 	p_cer_attribute20               in varchar2,
505 	p_cer_attribute21               in varchar2,
506 	p_cer_attribute22               in varchar2,
507 	p_cer_attribute23               in varchar2,
508 	p_cer_attribute24               in varchar2,
509 	p_cer_attribute25               in varchar2,
510 	p_cer_attribute26               in varchar2,
511 	p_cer_attribute27               in varchar2,
512 	p_cer_attribute28               in varchar2,
513 	p_cer_attribute29               in varchar2,
514 	p_cer_attribute30               in varchar2,
515 	p_object_version_number         in number
516 	)
517 	Return g_rec_type is
518 --
519   l_rec	  g_rec_type;
520   l_proc  varchar2(72) := g_package||'convert_args';
521 --
522 Begin
523   --
524   hr_utility.set_location('Entering:'||l_proc, 5);
525   --
526   -- Convert arguments into local l_rec structure.
527   --
528   l_rec.prtn_eligy_rl_id                 := p_prtn_eligy_rl_id;
529   l_rec.effective_start_date             := p_effective_start_date;
530   l_rec.effective_end_date               := p_effective_end_date;
531   l_rec.business_group_id                := p_business_group_id;
532   l_rec.prtn_elig_id                     := p_prtn_elig_id;
533   l_rec.formula_id                       := p_formula_id;
534   l_rec.drvbl_fctr_apls_flag             := p_drvbl_fctr_apls_flag;
535   l_rec.mndtry_flag                      := p_mndtry_flag;
536   l_rec.ordr_to_aply_num                 := p_ordr_to_aply_num;
537   l_rec.cer_attribute_category           := p_cer_attribute_category;
538   l_rec.cer_attribute1                   := p_cer_attribute1;
539   l_rec.cer_attribute2                   := p_cer_attribute2;
540   l_rec.cer_attribute3                   := p_cer_attribute3;
541   l_rec.cer_attribute4                   := p_cer_attribute4;
542   l_rec.cer_attribute5                   := p_cer_attribute5;
543   l_rec.cer_attribute6                   := p_cer_attribute6;
544   l_rec.cer_attribute7                   := p_cer_attribute7;
545   l_rec.cer_attribute8                   := p_cer_attribute8;
546   l_rec.cer_attribute9                   := p_cer_attribute9;
547   l_rec.cer_attribute10                  := p_cer_attribute10;
548   l_rec.cer_attribute11                  := p_cer_attribute11;
549   l_rec.cer_attribute12                  := p_cer_attribute12;
550   l_rec.cer_attribute13                  := p_cer_attribute13;
554   l_rec.cer_attribute17                  := p_cer_attribute17;
551   l_rec.cer_attribute14                  := p_cer_attribute14;
552   l_rec.cer_attribute15                  := p_cer_attribute15;
553   l_rec.cer_attribute16                  := p_cer_attribute16;
555   l_rec.cer_attribute18                  := p_cer_attribute18;
556   l_rec.cer_attribute19                  := p_cer_attribute19;
557   l_rec.cer_attribute20                  := p_cer_attribute20;
558   l_rec.cer_attribute21                  := p_cer_attribute21;
559   l_rec.cer_attribute22                  := p_cer_attribute22;
560   l_rec.cer_attribute23                  := p_cer_attribute23;
561   l_rec.cer_attribute24                  := p_cer_attribute24;
562   l_rec.cer_attribute25                  := p_cer_attribute25;
563   l_rec.cer_attribute26                  := p_cer_attribute26;
564   l_rec.cer_attribute27                  := p_cer_attribute27;
565   l_rec.cer_attribute28                  := p_cer_attribute28;
566   l_rec.cer_attribute29                  := p_cer_attribute29;
567   l_rec.cer_attribute30                  := p_cer_attribute30;
568   l_rec.object_version_number            := p_object_version_number;
569   --
570   -- Return the plsql record structure.
571   --
572   hr_utility.set_location(' Leaving:'||l_proc, 10);
573   Return(l_rec);
574 --
575 End convert_args;
576 --
577 end ben_cer_shd;