DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPL_SHD

Source


1 Package Body ben_cpl_shd as
2 /* $Header: becplrhi.pkb 120.0 2005/05/28 01:14:32 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cpl_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_CMBN_PLIP_F_PK') 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   Else
42     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
45     hr_utility.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_cmbn_plip_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 	cmbn_plip_id,
66 	effective_start_date,
67 	effective_end_date,
68 	name,
69 	business_group_id,
70 	cpl_attribute_category,
71 	cpl_attribute1,
72 	cpl_attribute2,
73 	cpl_attribute3,
74 	cpl_attribute4,
75 	cpl_attribute5,
76 	cpl_attribute6,
77 	cpl_attribute7,
78 	cpl_attribute8,
79 	cpl_attribute9,
80 	cpl_attribute10,
81 	cpl_attribute11,
82 	cpl_attribute12,
83 	cpl_attribute13,
84 	cpl_attribute14,
85 	cpl_attribute15,
86 	cpl_attribute16,
87 	cpl_attribute17,
88 	cpl_attribute18,
89 	cpl_attribute19,
90 	cpl_attribute20,
91 	cpl_attribute21,
92 	cpl_attribute22,
93 	cpl_attribute23,
94 	cpl_attribute24,
95 	cpl_attribute25,
96 	cpl_attribute26,
97 	cpl_attribute27,
98 	cpl_attribute28,
99 	cpl_attribute29,
100 	cpl_attribute30,
101 	object_version_number,
102 	pgm_id
103     from	ben_cmbn_plip_f
104     where	cmbn_plip_id = p_cmbn_plip_id
105     and		p_effective_date
106     between	effective_start_date and effective_end_date;
107 --
108   l_proc	varchar2(72)	:= g_package||'api_updating';
109   l_fct_ret	boolean;
110 --
111 Begin
112   hr_utility.set_location('Entering:'||l_proc, 5);
113   --
114   If (p_effective_date is null or
115       p_cmbn_plip_id is null or
116       p_object_version_number is null) Then
117     --
118     -- One of the primary key arguments is null therefore we must
119     -- set the returning function value to false
120     --
121     l_fct_ret := false;
122   Else
123     If (p_cmbn_plip_id = g_old_rec.cmbn_plip_id and
124         p_object_version_number = g_old_rec.object_version_number) Then
125       hr_utility.set_location(l_proc, 10);
126       --
127       -- The g_old_rec is current therefore we must
128       -- set the returning function to true
129       --
130       l_fct_ret := true;
131     Else
132       --
133       -- Select the current row
134       --
135       Open C_Sel1;
136       Fetch C_Sel1 Into g_old_rec;
137       If C_Sel1%notfound Then
138         Close C_Sel1;
139         --
140         -- The primary key is invalid therefore we must error
141         --
142         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
143         hr_utility.raise_error;
144       End If;
145       Close C_Sel1;
146       If (p_object_version_number <> g_old_rec.object_version_number) Then
147         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
148         hr_utility.raise_error;
149       End If;
150       hr_utility.set_location(l_proc, 15);
151       l_fct_ret := true;
152     End If;
153   End If;
154   hr_utility.set_location(' Leaving:'||l_proc, 20);
155   Return (l_fct_ret);
156 --
157 End api_updating;
158 --
159 -- ----------------------------------------------------------------------------
160 -- |--------------------------< find_dt_del_modes >---------------------------|
161 -- ----------------------------------------------------------------------------
162 Procedure find_dt_del_modes
163 	(p_effective_date	in  date,
164 	 p_base_key_value	in  number,
165 	 p_zap		 out nocopy boolean,
166 	 p_delete	 out nocopy boolean,
167 	 p_future_change out nocopy boolean,
168 	 p_delete_next_change out nocopy boolean) is
169 --
170   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
171 --
172   l_parent_key_value1	number;
173   --
174   Cursor C_Sel1 Is
175     select  t.pgm_id
176     from    ben_cmbn_plip_f t
177     where   t.cmbn_plip_id = p_base_key_value
178     and     p_effective_date
179     between t.effective_start_date and t.effective_end_date;
180 --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183   Open  C_Sel1;
184   Fetch C_Sel1 Into l_parent_key_value1;
185   If C_Sel1%notfound then
186     Close C_Sel1;
187     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
188     hr_utility.set_message_token('PROCEDURE', l_proc);
189     hr_utility.set_message_token('STEP','10');
190     hr_utility.raise_error;
191   End If;
192   Close C_Sel1;
193   --
194   -- Call the corresponding datetrack api
195   --
196   dt_api.find_dt_del_modes
197 	(p_effective_date	=> p_effective_date,
198 	 p_base_table_name	=> 'ben_cmbn_plip_f',
199 	 p_base_key_column	=> 'cmbn_plip_id',
200 	 p_base_key_value	=> p_base_key_value,
201 	 p_parent_table_name1	=> 'ben_pgm_f',
202 	 p_parent_key_column1	=> 'pgm_id',
203 	 p_parent_key_value1	=> l_parent_key_value1,
204 	 p_zap			=> p_zap,
205 	 p_delete		=> p_delete,
206 	 p_future_change	=> p_future_change,
207 	 p_delete_next_change	=> p_delete_next_change);
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End find_dt_del_modes;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |--------------------------< find_dt_upd_modes >---------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure find_dt_upd_modes
216 	(p_effective_date	in  date,
217 	 p_base_key_value	in  number,
218 	 p_correction	 out nocopy boolean,
219 	 p_update	 out nocopy boolean,
220 	 p_update_override out nocopy boolean,
221 	 p_update_change_insert out nocopy boolean) is
222 --
223   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
224 --
225 Begin
226   hr_utility.set_location('Entering:'||l_proc, 5);
227   --
228   -- Call the corresponding datetrack api
229   --
230   dt_api.find_dt_upd_modes
231 	(p_effective_date	=> p_effective_date,
232 	 p_base_table_name	=> 'ben_cmbn_plip_f',
233 	 p_base_key_column	=> 'cmbn_plip_id',
234 	 p_base_key_value	=> p_base_key_value,
235 	 p_correction		=> p_correction,
236 	 p_update		=> p_update,
237 	 p_update_override	=> p_update_override,
238 	 p_update_change_insert	=> p_update_change_insert);
239   --
240   hr_utility.set_location(' Leaving:'||l_proc, 10);
241 End find_dt_upd_modes;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |------------------------< upd_effective_end_date >------------------------|
245 -- ----------------------------------------------------------------------------
246 Procedure upd_effective_end_date
247 	(p_effective_date		in date,
248 	 p_base_key_value		in number,
249 	 p_new_effective_end_date	in date,
250 	 p_validation_start_date	in date,
251 	 p_validation_end_date		in date,
252          p_object_version_number       out nocopy number) is
253 --
254   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
255   l_object_version_number number;
256 --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   -- Because we are updating a row we must get the next object
261   -- version number.
262   --
263   l_object_version_number :=
264     dt_api.get_object_version_number
265 	(p_base_table_name	=> 'ben_cmbn_plip_f',
266 	 p_base_key_column	=> 'cmbn_plip_id',
267 	 p_base_key_value	=> p_base_key_value);
268   --
269   hr_utility.set_location(l_proc, 10);
270   g_api_dml := true;  -- Set the api dml status
271   --
272   -- Update the specified datetrack row setting the effective
273   -- end date to the specified new effective end date.
274   --
275   update  ben_cmbn_plip_f t
276   set	  t.effective_end_date	  = p_new_effective_end_date,
277 	  t.object_version_number = l_object_version_number
278   where	  t.cmbn_plip_id	  = p_base_key_value
279   and	  p_effective_date
280   between t.effective_start_date and t.effective_end_date;
281   --
282   g_api_dml := false;   -- Unset the api dml status
283   p_object_version_number := l_object_version_number;
284   hr_utility.set_location(' Leaving:'||l_proc, 15);
285 --
286 Exception
287   When Others Then
288     g_api_dml := false;   -- Unset the api dml status
289     Raise;
290 End upd_effective_end_date;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |---------------------------------< lck >----------------------------------|
294 -- ----------------------------------------------------------------------------
295 Procedure lck
296 	(p_effective_date	 in  date,
297 	 p_datetrack_mode	 in  varchar2,
298 	 p_cmbn_plip_id	 in  number,
299 	 p_object_version_number in  number,
300 	 p_validation_start_date out nocopy date,
301 	 p_validation_end_date	 out nocopy date) is
302 --
303   l_proc		  varchar2(72) := g_package||'lck';
304   l_validation_start_date date;
305   l_validation_end_date	  date;
306   l_object_invalid 	  exception;
307   l_argument		  varchar2(30);
308   --
309   -- Cursor C_Sel1 selects the current locked row as of session date
310   -- ensuring that the object version numbers match.
311   --
312   Cursor C_Sel1 is
313     select
314 	cmbn_plip_id,
315 	effective_start_date,
316 	effective_end_date,
317 	name,
318 	business_group_id,
319 	cpl_attribute_category,
320 	cpl_attribute1,
321 	cpl_attribute2,
322 	cpl_attribute3,
323 	cpl_attribute4,
324 	cpl_attribute5,
325 	cpl_attribute6,
326 	cpl_attribute7,
327 	cpl_attribute8,
328 	cpl_attribute9,
329 	cpl_attribute10,
330 	cpl_attribute11,
331 	cpl_attribute12,
332 	cpl_attribute13,
333 	cpl_attribute14,
334 	cpl_attribute15,
335 	cpl_attribute16,
336 	cpl_attribute17,
337 	cpl_attribute18,
338 	cpl_attribute19,
339 	cpl_attribute20,
340 	cpl_attribute21,
341 	cpl_attribute22,
342 	cpl_attribute23,
343 	cpl_attribute24,
344 	cpl_attribute25,
345 	cpl_attribute26,
346 	cpl_attribute27,
347 	cpl_attribute28,
348 	cpl_attribute29,
349 	cpl_attribute30,
350 	object_version_number,
351 	pgm_id
352     from    ben_cmbn_plip_f
353     where   cmbn_plip_id         = p_cmbn_plip_id
354     and	    p_effective_date
355     between effective_start_date and effective_end_date
356     for update nowait;
357   --
358   --
359   --
360 Begin
361   hr_utility.set_location('Entering:'||l_proc, 5);
362   --
363   -- Ensure that all the mandatory arguments are not null
364   --
365   hr_api.mandatory_arg_error(p_api_name       => l_proc,
366                              p_argument       => 'effective_date',
367                              p_argument_value => p_effective_date);
368   --
369   hr_api.mandatory_arg_error(p_api_name       => l_proc,
370                              p_argument       => 'datetrack_mode',
371                              p_argument_value => p_datetrack_mode);
372   --
373   hr_api.mandatory_arg_error(p_api_name       => l_proc,
374                              p_argument       => 'cmbn_plip_id',
375                              p_argument_value => p_cmbn_plip_id);
376   --
377   hr_api.mandatory_arg_error(p_api_name       => l_proc,
378                              p_argument       => 'object_version_number',
379                              p_argument_value => p_object_version_number);
380   --
381   -- Check to ensure the datetrack mode is not INSERT.
382   --
383   If (p_datetrack_mode <> 'INSERT') then
384     --
385     -- We must select and lock the current row.
386     --
387     Open  C_Sel1;
388     Fetch C_Sel1 Into g_old_rec;
389     If C_Sel1%notfound then
390       Close C_Sel1;
391       --
392       -- The primary key is invalid therefore we must error
393       --
394       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
395       hr_utility.raise_error;
396     End If;
397     Close C_Sel1;
398     If (p_object_version_number <> g_old_rec.object_version_number) Then
399         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
400         hr_utility.raise_error;
401       End If;
402     hr_utility.set_location(l_proc, 15);
403     --
404     --
405     -- Validate the datetrack mode mode getting the validation start
406     -- and end dates for the specified datetrack operation.
407     --
408     dt_api.validate_dt_mode
409 	(p_effective_date	   => p_effective_date,
410 	 p_datetrack_mode	   => p_datetrack_mode,
411 	 p_base_table_name	   => 'ben_cmbn_plip_f',
412 	 p_base_key_column	   => 'cmbn_plip_id',
413 	 p_base_key_value 	   => p_cmbn_plip_id,
414 	 p_parent_table_name1      => 'ben_pgm_f',
415 	 p_parent_key_column1      => 'pgm_id',
416 	 p_parent_key_value1       => g_old_rec.pgm_id,
417 	 p_child_table_name1       => 'ben_bnft_prvdr_pool_f',
418 	 p_child_key_column1       => 'bnft_prvdr_pool_id',
419 	 p_child_table_name2       => 'ben_plip_f',
420 	 p_child_key_column2       => 'plip_id',
421 	 p_child_table_name3       => 'ben_acty_base_rt_f',
422 	 p_child_key_column3       => 'acty_base_rt_id',
423          p_enforce_foreign_locking => true,
424 	 p_validation_start_date   => l_validation_start_date,
425  	 p_validation_end_date	   => l_validation_end_date);
426   Else
427     --
428     -- We are doing a datetrack 'INSERT' which is illegal within this
429     -- procedure therefore we must error (note: to lck on insert the
430     -- private procedure ins_lck should be called).
431     --
432     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
436   End If;
433     hr_utility.set_message_token('PROCEDURE', l_proc);
434     hr_utility.set_message_token('STEP','20');
435     hr_utility.raise_error;
437   --
438   -- Set the validation start and end date OUT arguments
439   --
440   p_validation_start_date := l_validation_start_date;
441   p_validation_end_date   := l_validation_end_date;
442   --
443   hr_utility.set_location(' Leaving:'||l_proc, 30);
444 --
445 -- We need to trap the ORA LOCK exception
446 --
447 Exception
448   When HR_Api.Object_Locked then
449     --
450     -- The object is locked therefore we need to supply a meaningful
451     -- error message.
452     --
453     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
454     hr_utility.set_message_token('TABLE_NAME', 'ben_cmbn_plip_f');
455     hr_utility.raise_error;
456   When l_object_invalid then
457     --
458     -- The object doesn't exist or is invalid
459     --
460     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
461     hr_utility.set_message_token('TABLE_NAME', 'ben_cmbn_plip_f');
462     hr_utility.raise_error;
463 End lck;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |-----------------------------< convert_args >-----------------------------|
467 -- ----------------------------------------------------------------------------
468 Function convert_args
469 	(
470 	p_cmbn_plip_id                  in number,
471 	p_effective_start_date          in date,
472 	p_effective_end_date            in date,
473 	p_name                          in varchar2,
474 	p_business_group_id             in number,
475 	p_cpl_attribute_category        in varchar2,
476 	p_cpl_attribute1                in varchar2,
477 	p_cpl_attribute2                in varchar2,
478 	p_cpl_attribute3                in varchar2,
479 	p_cpl_attribute4                in varchar2,
480 	p_cpl_attribute5                in varchar2,
481 	p_cpl_attribute6                in varchar2,
482 	p_cpl_attribute7                in varchar2,
483 	p_cpl_attribute8                in varchar2,
484 	p_cpl_attribute9                in varchar2,
485 	p_cpl_attribute10               in varchar2,
486 	p_cpl_attribute11               in varchar2,
487 	p_cpl_attribute12               in varchar2,
488 	p_cpl_attribute13               in varchar2,
489 	p_cpl_attribute14               in varchar2,
490 	p_cpl_attribute15               in varchar2,
491 	p_cpl_attribute16               in varchar2,
492 	p_cpl_attribute17               in varchar2,
493 	p_cpl_attribute18               in varchar2,
494 	p_cpl_attribute19               in varchar2,
495 	p_cpl_attribute20               in varchar2,
496 	p_cpl_attribute21               in varchar2,
497 	p_cpl_attribute22               in varchar2,
498 	p_cpl_attribute23               in varchar2,
499 	p_cpl_attribute24               in varchar2,
500 	p_cpl_attribute25               in varchar2,
501 	p_cpl_attribute26               in varchar2,
502 	p_cpl_attribute27               in varchar2,
503 	p_cpl_attribute28               in varchar2,
504 	p_cpl_attribute29               in varchar2,
505 	p_cpl_attribute30               in varchar2,
506 	p_object_version_number         in number,
507 	p_pgm_id                        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.cmbn_plip_id                     := p_cmbn_plip_id;
521   l_rec.effective_start_date             := p_effective_start_date;
522   l_rec.effective_end_date               := p_effective_end_date;
523   l_rec.name                             := p_name;
524   l_rec.business_group_id                := p_business_group_id;
525   l_rec.cpl_attribute_category           := p_cpl_attribute_category;
526   l_rec.cpl_attribute1                   := p_cpl_attribute1;
527   l_rec.cpl_attribute2                   := p_cpl_attribute2;
528   l_rec.cpl_attribute3                   := p_cpl_attribute3;
529   l_rec.cpl_attribute4                   := p_cpl_attribute4;
530   l_rec.cpl_attribute5                   := p_cpl_attribute5;
531   l_rec.cpl_attribute6                   := p_cpl_attribute6;
532   l_rec.cpl_attribute7                   := p_cpl_attribute7;
533   l_rec.cpl_attribute8                   := p_cpl_attribute8;
534   l_rec.cpl_attribute9                   := p_cpl_attribute9;
535   l_rec.cpl_attribute10                  := p_cpl_attribute10;
536   l_rec.cpl_attribute11                  := p_cpl_attribute11;
537   l_rec.cpl_attribute12                  := p_cpl_attribute12;
538   l_rec.cpl_attribute13                  := p_cpl_attribute13;
539   l_rec.cpl_attribute14                  := p_cpl_attribute14;
540   l_rec.cpl_attribute15                  := p_cpl_attribute15;
541   l_rec.cpl_attribute16                  := p_cpl_attribute16;
542   l_rec.cpl_attribute17                  := p_cpl_attribute17;
543   l_rec.cpl_attribute18                  := p_cpl_attribute18;
544   l_rec.cpl_attribute19                  := p_cpl_attribute19;
545   l_rec.cpl_attribute20                  := p_cpl_attribute20;
546   l_rec.cpl_attribute21                  := p_cpl_attribute21;
547   l_rec.cpl_attribute22                  := p_cpl_attribute22;
548   l_rec.cpl_attribute23                  := p_cpl_attribute23;
549   l_rec.cpl_attribute24                  := p_cpl_attribute24;
550   l_rec.cpl_attribute25                  := p_cpl_attribute25;
551   l_rec.cpl_attribute26                  := p_cpl_attribute26;
552   l_rec.cpl_attribute27                  := p_cpl_attribute27;
553   l_rec.cpl_attribute28                  := p_cpl_attribute28;
554   l_rec.cpl_attribute29                  := p_cpl_attribute29;
555   l_rec.cpl_attribute30                  := p_cpl_attribute30;
556   l_rec.object_version_number            := p_object_version_number;
557   l_rec.pgm_id                           := p_pgm_id;
558   --
559   -- Return the plsql record structure.
560   --
561   hr_utility.set_location(' Leaving:'||l_proc, 10);
562   Return(l_rec);
563 --
564 End convert_args;
565 --
566 end ben_cpl_shd;