DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPT_SHD

Source


1 Package Body ben_cpt_shd as
2 /* $Header: becptrhi.pkb 115.5 2002/12/13 06:20:31 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cpt_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_PTIP_OPT_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_ptip_opt_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_ptip_opt_id,
66 	effective_start_date,
67 	effective_end_date,
68 	name,
69 	business_group_id,
70 	cpt_attribute_category,
71 	cpt_attribute1,
72 	cpt_attribute2,
73 	cpt_attribute3,
74 	cpt_attribute4,
75 	cpt_attribute5,
76 	cpt_attribute6,
77 	cpt_attribute7,
78 	cpt_attribute8,
79 	cpt_attribute9,
80 	cpt_attribute10,
81 	cpt_attribute11,
82 	cpt_attribute12,
83 	cpt_attribute13,
84 	cpt_attribute14,
85 	cpt_attribute15,
86 	cpt_attribute16,
87 	cpt_attribute17,
88 	cpt_attribute18,
89 	cpt_attribute19,
90 	cpt_attribute20,
91 	cpt_attribute21,
92 	cpt_attribute22,
93 	cpt_attribute23,
94 	cpt_attribute24,
95 	cpt_attribute25,
96 	cpt_attribute26,
97 	cpt_attribute27,
98 	cpt_attribute28,
99 	cpt_attribute29,
100 	cpt_attribute30,
101 	object_version_number,
102 	ptip_id,
103         pgm_id,
104         opt_id
105     from	ben_cmbn_ptip_opt_f
106     where	cmbn_ptip_opt_id = p_cmbn_ptip_opt_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_cmbn_ptip_opt_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
125     If (p_cmbn_ptip_opt_id = g_old_rec.cmbn_ptip_opt_id and
126         p_object_version_number = g_old_rec.object_version_number) Then
127       hr_utility.set_location(l_proc, 10);
128       --
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         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
145         hr_utility.raise_error;
146       End If;
147       Close C_Sel1;
148       If (p_object_version_number <> g_old_rec.object_version_number) Then
152       hr_utility.set_location(l_proc, 15);
149         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
150         hr_utility.raise_error;
151       End If;
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   --
175   --
176 --
177 Begin
178   hr_utility.set_location('Entering:'||l_proc, 5);
179     --
180   --
181   -- Call the corresponding datetrack api
182   --
183   dt_api.find_dt_del_modes
184 	(p_effective_date	=> p_effective_date,
185 	 p_base_table_name	=> 'ben_cmbn_ptip_opt_f',
186 	 p_base_key_column	=> 'cmbn_ptip_opt_id',
187 	 p_base_key_value	=> p_base_key_value,
188 	 p_zap			=> p_zap,
189 	 p_delete		=> p_delete,
190 	 p_future_change	=> p_future_change,
191 	 p_delete_next_change	=> p_delete_next_change);
192   --
193   hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End find_dt_del_modes;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |--------------------------< find_dt_upd_modes >---------------------------|
198 -- ----------------------------------------------------------------------------
199 Procedure find_dt_upd_modes
200 	(p_effective_date	in  date,
201 	 p_base_key_value	in  number,
202 	 p_correction	 out nocopy boolean,
203 	 p_update	 out nocopy boolean,
204 	 p_update_override out nocopy boolean,
205 	 p_update_change_insert out nocopy boolean) is
206 --
207   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
208 --
209 Begin
210   hr_utility.set_location('Entering:'||l_proc, 5);
211   --
212   -- Call the corresponding datetrack api
213   --
214   dt_api.find_dt_upd_modes
215 	(p_effective_date	=> p_effective_date,
216 	 p_base_table_name	=> 'ben_cmbn_ptip_opt_f',
217 	 p_base_key_column	=> 'cmbn_ptip_opt_id',
218 	 p_base_key_value	=> p_base_key_value,
219 	 p_correction		=> p_correction,
220 	 p_update		=> p_update,
221 	 p_update_override	=> p_update_override,
222 	 p_update_change_insert	=> p_update_change_insert);
223   --
224   hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End find_dt_upd_modes;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |------------------------< upd_effective_end_date >------------------------|
229 -- ----------------------------------------------------------------------------
230 Procedure upd_effective_end_date
231 	(p_effective_date		in date,
232 	 p_base_key_value		in number,
233 	 p_new_effective_end_date	in date,
234 	 p_validation_start_date	in date,
235 	 p_validation_end_date		in date,
236          p_object_version_number       out nocopy number) is
237 --
238   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
239   l_object_version_number number;
240 --
241 Begin
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   -- Because we are updating a row we must get the next object
245   -- version number.
246   --
247   l_object_version_number :=
248     dt_api.get_object_version_number
249 	(p_base_table_name	=> 'ben_cmbn_ptip_opt_f',
250 	 p_base_key_column	=> 'cmbn_ptip_opt_id',
251 	 p_base_key_value	=> p_base_key_value);
252   --
253   hr_utility.set_location(l_proc, 10);
254   g_api_dml := true;  -- Set the api dml status
255   --
256   -- Update the specified datetrack row setting the effective
257   -- end date to the specified new effective end date.
258   --
259   update  ben_cmbn_ptip_opt_f t
260   set	  t.effective_end_date	  = p_new_effective_end_date,
261 	  t.object_version_number = l_object_version_number
262   where	  t.cmbn_ptip_opt_id	  = p_base_key_value
263   and	  p_effective_date
264   between t.effective_start_date and t.effective_end_date;
265   --
266   g_api_dml := false;   -- Unset the api dml status
267   p_object_version_number := l_object_version_number;
268   hr_utility.set_location(' Leaving:'||l_proc, 15);
269 --
270 Exception
271   When Others Then
272     g_api_dml := false;   -- Unset the api dml status
273     Raise;
274 End upd_effective_end_date;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |---------------------------------< lck >----------------------------------|
278 -- ----------------------------------------------------------------------------
279 Procedure lck
280 	(p_effective_date	 in  date,
281 	 p_datetrack_mode	 in  varchar2,
282 	 p_cmbn_ptip_opt_id	 in  number,
283 	 p_object_version_number in  number,
284 	 p_validation_start_date out nocopy date,
285 	 p_validation_end_date	 out nocopy date) is
286 --
287   l_proc		  varchar2(72) := g_package||'lck';
288   l_validation_start_date date;
289   l_validation_end_date	  date;
290   l_object_invalid 	  exception;
291   l_argument		  varchar2(30);
292   --
293   -- Cursor C_Sel1 selects the current locked row as of session date
294   -- ensuring that the object version numbers match.
295   --
296   Cursor C_Sel1 is
297     select
298 	cmbn_ptip_opt_id,
302 	business_group_id,
299 	effective_start_date,
300 	effective_end_date,
301 	name,
303 	cpt_attribute_category,
304 	cpt_attribute1,
305 	cpt_attribute2,
306 	cpt_attribute3,
307 	cpt_attribute4,
308 	cpt_attribute5,
309 	cpt_attribute6,
310 	cpt_attribute7,
311 	cpt_attribute8,
312 	cpt_attribute9,
313 	cpt_attribute10,
314 	cpt_attribute11,
315 	cpt_attribute12,
316 	cpt_attribute13,
317 	cpt_attribute14,
318 	cpt_attribute15,
319 	cpt_attribute16,
320 	cpt_attribute17,
321 	cpt_attribute18,
322 	cpt_attribute19,
323 	cpt_attribute20,
324 	cpt_attribute21,
325 	cpt_attribute22,
326 	cpt_attribute23,
327 	cpt_attribute24,
328 	cpt_attribute25,
329 	cpt_attribute26,
330 	cpt_attribute27,
331 	cpt_attribute28,
332 	cpt_attribute29,
333 	cpt_attribute30,
334 	object_version_number,
335 	ptip_id,
336         pgm_id,
337         opt_id
338     from    ben_cmbn_ptip_opt_f
339     where   cmbn_ptip_opt_id         = p_cmbn_ptip_opt_id
340     and	    p_effective_date
341     between effective_start_date and effective_end_date
342     for update nowait;
343   --
344   --
345   --
346 Begin
347   hr_utility.set_location('Entering:'||l_proc, 5);
348   --
349   -- Ensure that all the mandatory arguments are not null
350   --
351   hr_api.mandatory_arg_error(p_api_name       => l_proc,
352                              p_argument       => 'effective_date',
353                              p_argument_value => p_effective_date);
354   --
355   hr_api.mandatory_arg_error(p_api_name       => l_proc,
356                              p_argument       => 'datetrack_mode',
357                              p_argument_value => p_datetrack_mode);
358   --
359   hr_api.mandatory_arg_error(p_api_name       => l_proc,
360                              p_argument       => 'cmbn_ptip_opt_id',
361                              p_argument_value => p_cmbn_ptip_opt_id);
362   --
363   hr_api.mandatory_arg_error(p_api_name       => l_proc,
364                              p_argument       => 'object_version_number',
365                              p_argument_value => p_object_version_number);
366   --
367   -- Check to ensure the datetrack mode is not INSERT.
368   --
369   If (p_datetrack_mode <> 'INSERT') then
370     --
371     -- We must select and lock the current row.
372     --
373     Open  C_Sel1;
374     Fetch C_Sel1 Into g_old_rec;
375     If C_Sel1%notfound then
376       Close C_Sel1;
377       --
378       -- The primary key is invalid therefore we must error
379       --
380       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
381       hr_utility.raise_error;
382     End If;
383     Close C_Sel1;
384     If (p_object_version_number <> g_old_rec.object_version_number) Then
385         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
386         hr_utility.raise_error;
387       End If;
388     hr_utility.set_location(l_proc, 15);
389     --
390     --
391     -- Validate the datetrack mode mode getting the validation start
392     -- and end dates for the specified datetrack operation.
393     --
394     dt_api.validate_dt_mode
395 	(p_effective_date	   => p_effective_date,
396 	 p_datetrack_mode	   => p_datetrack_mode,
397 	 p_base_table_name	   => 'ben_cmbn_ptip_opt_f',
398 	 p_base_key_column	   => 'cmbn_ptip_opt_id',
399 	 p_base_key_value 	   => p_cmbn_ptip_opt_id,
400 /*
401 	 p_child_table_name1       => 'ben_ptip_f',
402 	 p_child_key_column1       => 'ptip_id',
403 */
404          p_child_table_name1       => 'ben_pgm_f',
405          p_child_key_column1       => 'pgm_id',
406 	 p_child_table_name2       => 'ben_opt_f',
407 	 p_child_key_column2       => 'opt_id',
408          p_child_table_name3       => 'ben_optip_f',
409          p_child_key_column3       => 'optip_id',
410 	 p_child_table_name4       => 'ben_bnft_prvdr_pool_f',
411 	 p_child_key_column4       => 'bnft_prvdr_pool_id',
412 	 p_child_table_name5       => 'ben_acty_base_rt_f',
413 	 p_child_key_column5       => 'acty_base_rt_id',
414          p_enforce_foreign_locking => true,
415 	 p_validation_start_date   => l_validation_start_date,
416  	 p_validation_end_date	   => l_validation_end_date);
417   Else
418     --
419     -- We are doing a datetrack 'INSERT' which is illegal within this
420     -- procedure therefore we must error (note: to lck on insert the
421     -- private procedure ins_lck should be called).
422     --
423     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
424     hr_utility.set_message_token('PROCEDURE', l_proc);
425     hr_utility.set_message_token('STEP','20');
426     hr_utility.raise_error;
427   End If;
428   --
429   -- Set the validation start and end date OUT arguments
430   --
431   p_validation_start_date := l_validation_start_date;
432   p_validation_end_date   := l_validation_end_date;
433   --
434   hr_utility.set_location(' Leaving:'||l_proc, 30);
435 --
436 -- We need to trap the ORA LOCK exception
437 --
438 Exception
439   When HR_Api.Object_Locked then
440     --
441     -- The object is locked therefore we need to supply a meaningful
442     -- error message.
443     --
444     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
445     hr_utility.set_message_token('TABLE_NAME', 'ben_cmbn_ptip_opt_f');
446     hr_utility.raise_error;
447   When l_object_invalid then
448     --
449     -- The object doesn't exist or is invalid
450     --
451     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
452     hr_utility.set_message_token('TABLE_NAME', 'ben_cmbn_ptip_opt_f');
453     hr_utility.raise_error;
454 End lck;
455 --
456 -- ----------------------------------------------------------------------------
457 -- |-----------------------------< convert_args >-----------------------------|
458 -- ----------------------------------------------------------------------------
459 Function convert_args
460 	(
461 	p_cmbn_ptip_opt_id              in number,
462 	p_effective_start_date          in date,
463 	p_effective_end_date            in date,
464 	p_name                          in varchar2,
465 	p_business_group_id             in number,
466 	p_cpt_attribute_category        in varchar2,
467 	p_cpt_attribute1                in varchar2,
468 	p_cpt_attribute2                in varchar2,
469 	p_cpt_attribute3                in varchar2,
470 	p_cpt_attribute4                in varchar2,
471 	p_cpt_attribute5                in varchar2,
472 	p_cpt_attribute6                in varchar2,
473 	p_cpt_attribute7                in varchar2,
474 	p_cpt_attribute8                in varchar2,
475 	p_cpt_attribute9                in varchar2,
476 	p_cpt_attribute10               in varchar2,
477 	p_cpt_attribute11               in varchar2,
478 	p_cpt_attribute12               in varchar2,
479 	p_cpt_attribute13               in varchar2,
480 	p_cpt_attribute14               in varchar2,
481 	p_cpt_attribute15               in varchar2,
482 	p_cpt_attribute16               in varchar2,
483 	p_cpt_attribute17               in varchar2,
484 	p_cpt_attribute18               in varchar2,
485 	p_cpt_attribute19               in varchar2,
486 	p_cpt_attribute20               in varchar2,
487 	p_cpt_attribute21               in varchar2,
488 	p_cpt_attribute22               in varchar2,
489 	p_cpt_attribute23               in varchar2,
490 	p_cpt_attribute24               in varchar2,
491 	p_cpt_attribute25               in varchar2,
492 	p_cpt_attribute26               in varchar2,
493 	p_cpt_attribute27               in varchar2,
494 	p_cpt_attribute28               in varchar2,
495 	p_cpt_attribute29               in varchar2,
496 	p_cpt_attribute30               in varchar2,
497 	p_object_version_number         in number,
498 	p_ptip_id                       in number,
499         p_pgm_id                        in number,
500         p_opt_id                        in number
501 	)
502 	Return g_rec_type is
503 --
504   l_rec	  g_rec_type;
505   l_proc  varchar2(72) := g_package||'convert_args';
506 --
507 Begin
508   --
509   hr_utility.set_location('Entering:'||l_proc, 5);
510   --
511   -- Convert arguments into local l_rec structure.
512   --
513   l_rec.cmbn_ptip_opt_id                 := p_cmbn_ptip_opt_id;
514   l_rec.effective_start_date             := p_effective_start_date;
515   l_rec.effective_end_date               := p_effective_end_date;
516   l_rec.name                             := p_name;
517   l_rec.business_group_id                := p_business_group_id;
518   l_rec.cpt_attribute_category           := p_cpt_attribute_category;
519   l_rec.cpt_attribute1                   := p_cpt_attribute1;
520   l_rec.cpt_attribute2                   := p_cpt_attribute2;
521   l_rec.cpt_attribute3                   := p_cpt_attribute3;
522   l_rec.cpt_attribute4                   := p_cpt_attribute4;
523   l_rec.cpt_attribute5                   := p_cpt_attribute5;
524   l_rec.cpt_attribute6                   := p_cpt_attribute6;
525   l_rec.cpt_attribute7                   := p_cpt_attribute7;
526   l_rec.cpt_attribute8                   := p_cpt_attribute8;
527   l_rec.cpt_attribute9                   := p_cpt_attribute9;
528   l_rec.cpt_attribute10                  := p_cpt_attribute10;
529   l_rec.cpt_attribute11                  := p_cpt_attribute11;
530   l_rec.cpt_attribute12                  := p_cpt_attribute12;
531   l_rec.cpt_attribute13                  := p_cpt_attribute13;
532   l_rec.cpt_attribute14                  := p_cpt_attribute14;
533   l_rec.cpt_attribute15                  := p_cpt_attribute15;
534   l_rec.cpt_attribute16                  := p_cpt_attribute16;
535   l_rec.cpt_attribute17                  := p_cpt_attribute17;
536   l_rec.cpt_attribute18                  := p_cpt_attribute18;
537   l_rec.cpt_attribute19                  := p_cpt_attribute19;
538   l_rec.cpt_attribute20                  := p_cpt_attribute20;
539   l_rec.cpt_attribute21                  := p_cpt_attribute21;
540   l_rec.cpt_attribute22                  := p_cpt_attribute22;
541   l_rec.cpt_attribute23                  := p_cpt_attribute23;
542   l_rec.cpt_attribute24                  := p_cpt_attribute24;
543   l_rec.cpt_attribute25                  := p_cpt_attribute25;
544   l_rec.cpt_attribute26                  := p_cpt_attribute26;
545   l_rec.cpt_attribute27                  := p_cpt_attribute27;
546   l_rec.cpt_attribute28                  := p_cpt_attribute28;
547   l_rec.cpt_attribute29                  := p_cpt_attribute29;
548   l_rec.cpt_attribute30                  := p_cpt_attribute30;
549   l_rec.object_version_number            := p_object_version_number;
550   l_rec.ptip_id                          := p_ptip_id;
551   l_rec.pgm_id                           := p_pgm_id;
552   l_rec.opt_id                           := p_opt_id;
553   --
554   -- Return the plsql record structure.
555   --
556   hr_utility.set_location(' Leaving:'||l_proc, 10);
557   Return(l_rec);
558 --
559 End convert_args;
560 --
561 end ben_cpt_shd;