DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CEP_SHD

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_CEP_shd as
2 /* $Header: beceprhi.pkb 120.0 2005/05/28 01:00:07 appldev noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_CEP_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_PRTN_ELIG_PRFL_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_PRTN_ELIG_PRFL_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_elig_prfl_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_elig_prfl_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
74 	mndtry_flag,
75 	prtn_elig_id,
76 	eligy_prfl_id,
77         Elig_prfl_type_cd,
78 	cep_attribute_category,
79 	cep_attribute1,
80 	cep_attribute2,
81 	cep_attribute3,
82 	cep_attribute4,
83 	cep_attribute5,
84 	cep_attribute6,
85 	cep_attribute7,
86 	cep_attribute8,
87 	cep_attribute9,
88 	cep_attribute10,
89 	cep_attribute11,
90 	cep_attribute12,
91 	cep_attribute13,
92 	cep_attribute14,
93 	cep_attribute15,
94 	cep_attribute16,
95 	cep_attribute17,
96 	cep_attribute18,
97 	cep_attribute19,
98 	cep_attribute20,
99 	cep_attribute21,
100 	cep_attribute22,
101 	cep_attribute23,
102 	cep_attribute24,
103 	cep_attribute25,
104 	cep_attribute26,
105 	cep_attribute27,
106 	cep_attribute28,
110 	compute_score_flag
107 	cep_attribute29,
108 	cep_attribute30,
109 	object_version_number,
111     from	ben_prtn_elig_prfl_f
112     where	prtn_elig_prfl_id = p_prtn_elig_prfl_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_elig_prfl_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_elig_prfl_id = g_old_rec.prtn_elig_prfl_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   l_parent_key_value2	number;
182   --
183   Cursor C_Sel1 Is
184     select  t.eligy_prfl_id,
185 	    t.prtn_elig_id
186     from    ben_prtn_elig_prfl_f t
187     where   t.prtn_elig_prfl_id = p_base_key_value
188     and     p_effective_date
189     between t.effective_start_date and t.effective_end_date;
190 --
191 Begin
192   hr_utility.set_location('Entering:'||l_proc, 5);
193   Open  C_Sel1;
194   Fetch C_Sel1 Into l_parent_key_value1,
195 		    l_parent_key_value2;
196   If C_Sel1%notfound then
197     Close C_Sel1;
198     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
199     hr_utility.set_message_token('PROCEDURE', l_proc);
200     hr_utility.set_message_token('STEP','10');
201     hr_utility.raise_error;
202   End If;
203   Close C_Sel1;
204   --
205   -- Call the corresponding datetrack api
206   --
207   dt_api.find_dt_del_modes
208 	(p_effective_date	=> p_effective_date,
209 	 p_base_table_name	=> 'ben_prtn_elig_prfl_f',
210 	 p_base_key_column	=> 'prtn_elig_prfl_id',
211 	 p_base_key_value	=> p_base_key_value,
212 	 p_parent_table_name1	=> 'ben_eligy_prfl_f',
213 	 p_parent_key_column1	=> 'eligy_prfl_id',
214 	 p_parent_key_value1	=> l_parent_key_value1,
215 	 p_parent_table_name2	=> 'ben_prtn_elig_f',
216 	 p_parent_key_column2	=> 'prtn_elig_id',
217 	 p_parent_key_value2	=> l_parent_key_value2,
218 	 p_zap			=> p_zap,
219 	 p_delete		=> p_delete,
220 	 p_future_change	=> p_future_change,
221 	 p_delete_next_change	=> p_delete_next_change);
222   --
223   hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End find_dt_del_modes;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |--------------------------< find_dt_upd_modes >---------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure find_dt_upd_modes
230 	(p_effective_date	in  date,
231 	 p_base_key_value	in  number,
232 	 p_correction	 out nocopy boolean,
233 	 p_update	 out nocopy boolean,
234 	 p_update_override out nocopy boolean,
235 	 p_update_change_insert out nocopy boolean) is
236 --
237   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241   --
242   -- Call the corresponding datetrack api
243   --
244   dt_api.find_dt_upd_modes
245 	(p_effective_date	=> p_effective_date,
246 	 p_base_table_name	=> 'ben_prtn_elig_prfl_f',
247 	 p_base_key_column	=> 'prtn_elig_prfl_id',
248 	 p_base_key_value	=> p_base_key_value,
249 	 p_correction		=> p_correction,
250 	 p_update		=> p_update,
251 	 p_update_override	=> p_update_override,
252 	 p_update_change_insert	=> p_update_change_insert);
253   --
254   hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End find_dt_upd_modes;
256 --
257 -- ----------------------------------------------------------------------------
261 	(p_effective_date		in date,
258 -- |------------------------< upd_effective_end_date >------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure upd_effective_end_date
262 	 p_base_key_value		in number,
263 	 p_new_effective_end_date	in date,
264 	 p_validation_start_date	in date,
265 	 p_validation_end_date		in date,
266          p_object_version_number       out nocopy number) is
267 --
268   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
269   l_object_version_number number;
270 --
271 Begin
272   hr_utility.set_location('Entering:'||l_proc, 5);
273   --
274   -- Because we are updating a row we must get the next object
275   -- version number.
276   --
277   l_object_version_number :=
278     dt_api.get_object_version_number
279 	(p_base_table_name	=> 'ben_prtn_elig_prfl_f',
280 	 p_base_key_column	=> 'prtn_elig_prfl_id',
281 	 p_base_key_value	=> p_base_key_value);
282   --
283   hr_utility.set_location(l_proc, 10);
284   g_api_dml := true;  -- Set the api dml status
285   --
286   -- Update the specified datetrack row setting the effective
287   -- end date to the specified new effective end date.
288   --
289   update  ben_prtn_elig_prfl_f t
290   set	  t.effective_end_date	  = p_new_effective_end_date,
291 	  t.object_version_number = l_object_version_number
292   where	  t.prtn_elig_prfl_id	  = p_base_key_value
293   and	  p_effective_date
294   between t.effective_start_date and t.effective_end_date;
295   --
296   g_api_dml := false;   -- Unset the api dml status
297   p_object_version_number := l_object_version_number;
298   hr_utility.set_location(' Leaving:'||l_proc, 15);
299 --
300 Exception
301   When Others Then
302     g_api_dml := false;   -- Unset the api dml status
303     Raise;
304 End upd_effective_end_date;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< lck >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure lck
310 	(p_effective_date	 in  date,
311 	 p_datetrack_mode	 in  varchar2,
312 	 p_prtn_elig_prfl_id	 in  number,
313 	 p_object_version_number in  number,
314 	 p_validation_start_date out nocopy date,
315 	 p_validation_end_date	 out nocopy date) is
316 --
317   l_proc		  varchar2(72) := g_package||'lck';
318   l_validation_start_date date;
319   l_validation_end_date	  date;
320   l_object_invalid 	  exception;
321   l_argument		  varchar2(30);
322   --
323   -- Cursor C_Sel1 selects the current locked row as of session date
324   -- ensuring that the object version numbers match.
325   --
326   Cursor C_Sel1 is
327     select
328 	prtn_elig_prfl_id,
329 	effective_start_date,
330 	effective_end_date,
331 	business_group_id,
332 	mndtry_flag,
333 	prtn_elig_id,
334 	eligy_prfl_id,
335         Elig_prfl_type_cd,
336 	cep_attribute_category,
337 	cep_attribute1,
338 	cep_attribute2,
339 	cep_attribute3,
340 	cep_attribute4,
341 	cep_attribute5,
342 	cep_attribute6,
343 	cep_attribute7,
344 	cep_attribute8,
345 	cep_attribute9,
346 	cep_attribute10,
347 	cep_attribute11,
348 	cep_attribute12,
349 	cep_attribute13,
350 	cep_attribute14,
351 	cep_attribute15,
352 	cep_attribute16,
353 	cep_attribute17,
354 	cep_attribute18,
355 	cep_attribute19,
356 	cep_attribute20,
357 	cep_attribute21,
358 	cep_attribute22,
359 	cep_attribute23,
360 	cep_attribute24,
361 	cep_attribute25,
362 	cep_attribute26,
363 	cep_attribute27,
364 	cep_attribute28,
365 	cep_attribute29,
366 	cep_attribute30,
367 	object_version_number,
368 	compute_score_flag
369     from    ben_prtn_elig_prfl_f
370     where   prtn_elig_prfl_id         = p_prtn_elig_prfl_id
371     and	    p_effective_date
372     between effective_start_date and effective_end_date
373     for update nowait;
374   --
375   --
376   --
377 Begin
378   hr_utility.set_location('Entering:'||l_proc, 5);
379   --
380   -- Ensure that all the mandatory arguments are not null
381   --
382   hr_api.mandatory_arg_error(p_api_name       => l_proc,
383                              p_argument       => 'effective_date',
384                              p_argument_value => p_effective_date);
385   --
386   hr_api.mandatory_arg_error(p_api_name       => l_proc,
387                              p_argument       => 'datetrack_mode',
388                              p_argument_value => p_datetrack_mode);
389   --
390   hr_api.mandatory_arg_error(p_api_name       => l_proc,
391                              p_argument       => 'prtn_elig_prfl_id',
392                              p_argument_value => p_prtn_elig_prfl_id);
393   --
394   hr_api.mandatory_arg_error(p_api_name       => l_proc,
395                              p_argument       => 'object_version_number',
396                              p_argument_value => p_object_version_number);
397   --
398   -- Check to ensure the datetrack mode is not INSERT.
399   --
400   If (p_datetrack_mode <> 'INSERT') then
401     --
402     -- We must select and lock the current row.
403     --
404     Open  C_Sel1;
405     Fetch C_Sel1 Into g_old_rec;
406     If C_Sel1%notfound then
407       Close C_Sel1;
408       --
409       -- The primary key is invalid therefore we must error
410       --
411       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
415     If (p_object_version_number <> g_old_rec.object_version_number) Then
412       hr_utility.raise_error;
413     End If;
414     Close C_Sel1;
416         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
417         hr_utility.raise_error;
418       End If;
419     hr_utility.set_location(l_proc, 15);
420     --
421     --
422     -- Validate the datetrack mode mode getting the validation start
423     -- and end dates for the specified datetrack operation.
424     --
425     dt_api.validate_dt_mode
426 	(p_effective_date	   => p_effective_date,
427 	 p_datetrack_mode	   => p_datetrack_mode,
428 	 p_base_table_name	   => 'ben_prtn_elig_prfl_f',
429 	 p_base_key_column	   => 'prtn_elig_prfl_id',
430 	 p_base_key_value 	   => p_prtn_elig_prfl_id,
431 	 p_parent_table_name1      => 'ben_eligy_prfl_f',
432 	 p_parent_key_column1      => 'eligy_prfl_id',
433 	 p_parent_key_value1       => g_old_rec.eligy_prfl_id,
434 	 p_parent_table_name2      => 'ben_prtn_elig_f',
435 	 p_parent_key_column2      => 'prtn_elig_id',
436 	 p_parent_key_value2       => g_old_rec.prtn_elig_id,
437          p_enforce_foreign_locking => true,
438 	 p_validation_start_date   => l_validation_start_date,
439  	 p_validation_end_date	   => l_validation_end_date);
440   Else
441     --
442     -- We are doing a datetrack 'INSERT' which is illegal within this
443     -- procedure therefore we must error (note: to lck on insert the
444     -- private procedure ins_lck should be called).
445     --
446     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
447     hr_utility.set_message_token('PROCEDURE', l_proc);
448     hr_utility.set_message_token('STEP','20');
449     hr_utility.raise_error;
450   End If;
451   --
452   -- Set the validation start and end date OUT arguments
453   --
454   p_validation_start_date := l_validation_start_date;
455   p_validation_end_date   := l_validation_end_date;
456   --
457   hr_utility.set_location(' Leaving:'||l_proc, 30);
458 --
459 -- We need to trap the ORA LOCK exception
460 --
461 Exception
462   When HR_Api.Object_Locked then
463     --
464     -- The object is locked therefore we need to supply a meaningful
465     -- error message.
466     --
467     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
468     hr_utility.set_message_token('TABLE_NAME', 'ben_prtn_elig_prfl_f');
469     hr_utility.raise_error;
470   When l_object_invalid then
471     --
472     -- The object doesn't exist or is invalid
473     --
474     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
475     hr_utility.set_message_token('TABLE_NAME', 'ben_prtn_elig_prfl_f');
476     hr_utility.raise_error;
477 End lck;
478 --
479 -- ----------------------------------------------------------------------------
480 -- |-----------------------------< convert_args >-----------------------------|
481 -- ----------------------------------------------------------------------------
482 Function convert_args
483 	(
484 	p_prtn_elig_prfl_id             in number,
485 	p_effective_start_date          in date,
486 	p_effective_end_date            in date,
487 	p_business_group_id             in number,
488 	p_mndtry_flag                   in varchar2,
489 	p_prtn_elig_id                  in number,
490 	p_eligy_prfl_id                 in number,
491         p_Elig_prfl_type_cd             in varchar2,
492 	p_cep_attribute_category        in varchar2,
493 	p_cep_attribute1                in varchar2,
494 	p_cep_attribute2                in varchar2,
495 	p_cep_attribute3                in varchar2,
496 	p_cep_attribute4                in varchar2,
497 	p_cep_attribute5                in varchar2,
498 	p_cep_attribute6                in varchar2,
499 	p_cep_attribute7                in varchar2,
500 	p_cep_attribute8                in varchar2,
501 	p_cep_attribute9                in varchar2,
502 	p_cep_attribute10               in varchar2,
503 	p_cep_attribute11               in varchar2,
504 	p_cep_attribute12               in varchar2,
505 	p_cep_attribute13               in varchar2,
506 	p_cep_attribute14               in varchar2,
507 	p_cep_attribute15               in varchar2,
508 	p_cep_attribute16               in varchar2,
509 	p_cep_attribute17               in varchar2,
510 	p_cep_attribute18               in varchar2,
511 	p_cep_attribute19               in varchar2,
512 	p_cep_attribute20               in varchar2,
513 	p_cep_attribute21               in varchar2,
514 	p_cep_attribute22               in varchar2,
515 	p_cep_attribute23               in varchar2,
516 	p_cep_attribute24               in varchar2,
517 	p_cep_attribute25               in varchar2,
518 	p_cep_attribute26               in varchar2,
519 	p_cep_attribute27               in varchar2,
520 	p_cep_attribute28               in varchar2,
521 	p_cep_attribute29               in varchar2,
522 	p_cep_attribute30               in varchar2,
523 	p_object_version_number         in number  ,
524 	p_compute_score_flag            in varchar2
525 	)
526 	Return g_rec_type is
527 --
528   l_rec	  g_rec_type;
529   l_proc  varchar2(72) := g_package||'convert_args';
530 --
531 Begin
532   --
533   hr_utility.set_location('Entering:'||l_proc, 5);
534   --
535   -- Convert arguments into local l_rec structure.
536   --
537   l_rec.prtn_elig_prfl_id                := p_prtn_elig_prfl_id;
538   l_rec.effective_start_date             := p_effective_start_date;
539   l_rec.effective_end_date               := p_effective_end_date;
540   l_rec.business_group_id                := p_business_group_id;
541   l_rec.mndtry_flag                      := p_mndtry_flag;
542   l_rec.prtn_elig_id                     := p_prtn_elig_id;
543   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
547   l_rec.cep_attribute2                   := p_cep_attribute2;
544   l_rec.Elig_prfl_type_cd                := p_Elig_prfl_type_cd;
545   l_rec.cep_attribute_category           := p_cep_attribute_category;
546   l_rec.cep_attribute1                   := p_cep_attribute1;
548   l_rec.cep_attribute3                   := p_cep_attribute3;
549   l_rec.cep_attribute4                   := p_cep_attribute4;
550   l_rec.cep_attribute5                   := p_cep_attribute5;
551   l_rec.cep_attribute6                   := p_cep_attribute6;
552   l_rec.cep_attribute7                   := p_cep_attribute7;
553   l_rec.cep_attribute8                   := p_cep_attribute8;
554   l_rec.cep_attribute9                   := p_cep_attribute9;
555   l_rec.cep_attribute10                  := p_cep_attribute10;
556   l_rec.cep_attribute11                  := p_cep_attribute11;
557   l_rec.cep_attribute12                  := p_cep_attribute12;
558   l_rec.cep_attribute13                  := p_cep_attribute13;
559   l_rec.cep_attribute14                  := p_cep_attribute14;
560   l_rec.cep_attribute15                  := p_cep_attribute15;
561   l_rec.cep_attribute16                  := p_cep_attribute16;
562   l_rec.cep_attribute17                  := p_cep_attribute17;
563   l_rec.cep_attribute18                  := p_cep_attribute18;
564   l_rec.cep_attribute19                  := p_cep_attribute19;
565   l_rec.cep_attribute20                  := p_cep_attribute20;
566   l_rec.cep_attribute21                  := p_cep_attribute21;
567   l_rec.cep_attribute22                  := p_cep_attribute22;
568   l_rec.cep_attribute23                  := p_cep_attribute23;
569   l_rec.cep_attribute24                  := p_cep_attribute24;
570   l_rec.cep_attribute25                  := p_cep_attribute25;
571   l_rec.cep_attribute26                  := p_cep_attribute26;
572   l_rec.cep_attribute27                  := p_cep_attribute27;
573   l_rec.cep_attribute28                  := p_cep_attribute28;
574   l_rec.cep_attribute29                  := p_cep_attribute29;
575   l_rec.cep_attribute30                  := p_cep_attribute30;
576   l_rec.object_version_number            := p_object_version_number;
577   l_rec.compute_score_flag               := p_compute_score_flag;
578   --
579   -- Return the plsql record structure.
580   --
581   hr_utility.set_location(' Leaving:'||l_proc, 10);
582   Return(l_rec);
583 --
584 End convert_args;
585 --
586 end ben_CEP_shd;