DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_OPT_SHD

Source


1 Package Body ben_opt_shd as
2 /* $Header: beoptrhi.pkb 120.0 2005/05/28 09:56:38 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_opt_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_OPT_F_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_OPT_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 -- ----------------------------------------------------------------------------
60   (p_effective_date		in date,
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
61    p_opt_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 	opt_id,
71 	effective_start_date,
72 	effective_end_date,
73 	name,
74 	cmbn_ptip_opt_id,
75 	business_group_id,
76 	opt_attribute_category,
77 	opt_attribute1,
78 	opt_attribute2,
79 	opt_attribute3,
80 	opt_attribute4,
81 	opt_attribute5,
82 	opt_attribute6,
83 	opt_attribute7,
84 	opt_attribute8,
85 	opt_attribute9,
86 	opt_attribute10,
87 	opt_attribute11,
88 	opt_attribute12,
89 	opt_attribute13,
90 	opt_attribute14,
91 	opt_attribute15,
92 	opt_attribute16,
93 	opt_attribute17,
94 	opt_attribute18,
95 	opt_attribute19,
96 	opt_attribute20,
97 	opt_attribute21,
98 	opt_attribute22,
99 	opt_attribute23,
100 	opt_attribute24,
101 	opt_attribute25,
102 	opt_attribute26,
103 	opt_attribute27,
104 	opt_attribute28,
105 	opt_attribute29,
106 	opt_attribute30,
107 	object_version_number,
108 	rqd_perd_enrt_nenrt_uom,
109 	rqd_perd_enrt_nenrt_val,
110 	rqd_perd_enrt_nenrt_rl,
111 	invk_wv_opt_flag,
112 	short_name,
113 	short_code,
114 	legislation_code,
115 	legislation_subgroup,
116         group_opt_id,
117 	component_reason,
118         mapping_table_name,
119         mapping_table_pk_id
120     from	ben_opt_f
121     where	opt_id = p_opt_id
122     and		p_effective_date
123     between	effective_start_date and effective_end_date;
124 --
125   l_proc	varchar2(72)	:= g_package||'api_updating';
126   l_fct_ret	boolean;
127 --
128 Begin
129   hr_utility.set_location('Entering:'||l_proc, 5);
130   --
131   If (p_effective_date is null or
132       p_opt_id is null or
133       p_object_version_number is null) Then
134     --
135     -- One of the primary key arguments is null therefore we must
136     -- set the returning function value to false
137     --
138     l_fct_ret := false;
139   Else
140     If (p_opt_id = g_old_rec.opt_id and
141         p_object_version_number = g_old_rec.object_version_number) Then
142       hr_utility.set_location(l_proc, 10);
143       --
144       -- The g_old_rec is current therefore we must
145       -- set the returning function to true
146       --
147       l_fct_ret := true;
148     Else
149       --
150       -- Select the current row
151       --
152       Open C_Sel1;
153       Fetch C_Sel1 Into g_old_rec;
154       If C_Sel1%notfound Then
155         Close C_Sel1;
156         --
157         -- The primary key is invalid therefore we must error
158         --
159         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
160         hr_utility.raise_error;
161       End If;
162       Close C_Sel1;
163       If (p_object_version_number <> g_old_rec.object_version_number) Then
164         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
165         hr_utility.raise_error;
166       End If;
167       hr_utility.set_location(l_proc, 15);
168       l_fct_ret := true;
169     End If;
170   End If;
171   hr_utility.set_location(' Leaving:'||l_proc, 20);
172   Return (l_fct_ret);
173 --
174 End api_updating;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |--------------------------< find_dt_del_modes >---------------------------|
178 -- ----------------------------------------------------------------------------
179 Procedure find_dt_del_modes
180 	(p_effective_date	in  date,
181 	 p_base_key_value	in  number,
182 	 p_zap		 out nocopy boolean,
183 	 p_delete	 out nocopy boolean,
184 	 p_future_change out nocopy boolean,
185 	 p_delete_next_change out nocopy boolean) is
186 --
187   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
188 --
189   l_parent_key_value1	number;
190   --
191   Cursor C_Sel1 Is
192     select  t.cmbn_ptip_opt_id
193     from    ben_opt_f t
194     where   t.opt_id = p_base_key_value
195     and     p_effective_date
196     between t.effective_start_date and t.effective_end_date;
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200   Open  C_Sel1;
201   Fetch C_Sel1 Into l_parent_key_value1;
202   If C_Sel1%notfound then
203     Close C_Sel1;
204     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
205     hr_utility.set_message_token('PROCEDURE', l_proc);
206     hr_utility.set_message_token('STEP','10');
207     hr_utility.raise_error;
208   End If;
209   Close C_Sel1;
210   --
211   -- Call the corresponding datetrack api
212   --
213   dt_api.find_dt_del_modes
214 	(p_effective_date	=> p_effective_date,
215 	 p_base_table_name	=> 'ben_opt_f',
216 	 p_base_key_column	=> 'opt_id',
217 	 p_base_key_value	=> p_base_key_value,
218 	 p_parent_table_name1	=> 'ben_cmbn_ptip_opt_f',
219 	 p_parent_key_column1	=> 'cmbn_ptip_opt_id',
220 	 p_parent_key_value1	=> l_parent_key_value1,
221 	 p_zap			=> p_zap,
222 	 p_delete		=> p_delete,
223 	 p_future_change	=> p_future_change,
224 	 p_delete_next_change	=> p_delete_next_change);
225   --
226   hr_utility.set_location(' Leaving:'||l_proc, 10);
227 End find_dt_del_modes;
228 --
229 -- ----------------------------------------------------------------------------
233 	(p_effective_date	in  date,
230 -- |--------------------------< find_dt_upd_modes >---------------------------|
231 -- ----------------------------------------------------------------------------
232 Procedure find_dt_upd_modes
234 	 p_base_key_value	in  number,
235 	 p_correction	 out nocopy boolean,
236 	 p_update	 out nocopy boolean,
237 	 p_update_override out nocopy boolean,
238 	 p_update_change_insert out nocopy boolean) is
239 --
240   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
241 --
242 Begin
243   hr_utility.set_location('Entering:'||l_proc, 5);
244   --
245   -- Call the corresponding datetrack api
246   --
247   dt_api.find_dt_upd_modes
248 	(p_effective_date	=> p_effective_date,
249 	 p_base_table_name	=> 'ben_opt_f',
250 	 p_base_key_column	=> 'opt_id',
251 	 p_base_key_value	=> p_base_key_value,
252 	 p_correction		=> p_correction,
253 	 p_update		=> p_update,
254 	 p_update_override	=> p_update_override,
255 	 p_update_change_insert	=> p_update_change_insert);
256   --
257   hr_utility.set_location(' Leaving:'||l_proc, 10);
258 End find_dt_upd_modes;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |------------------------< upd_effective_end_date >------------------------|
262 -- ----------------------------------------------------------------------------
263 Procedure upd_effective_end_date
264 	(p_effective_date		in date,
265 	 p_base_key_value		in number,
266 	 p_new_effective_end_date	in date,
267 	 p_validation_start_date	in date,
268 	 p_validation_end_date		in date,
269          p_object_version_number       out nocopy number) is
270 --
271   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
272   l_object_version_number number;
273 --
274 Begin
275   hr_utility.set_location('Entering:'||l_proc, 5);
276   --
277   -- Because we are updating a row we must get the next object
278   -- version number.
279   --
280   l_object_version_number :=
281     dt_api.get_object_version_number
282 	(p_base_table_name	=> 'ben_opt_f',
283 	 p_base_key_column	=> 'opt_id',
284 	 p_base_key_value	=> p_base_key_value);
285   --
286   hr_utility.set_location(l_proc, 10);
287   g_api_dml := true;  -- Set the api dml status
288   --
289   -- Update the specified datetrack row setting the effective
290   -- end date to the specified new effective end date.
291   --
292   update  ben_opt_f t
293   set	  t.effective_end_date	  = p_new_effective_end_date,
294 	  t.object_version_number = l_object_version_number
295   where	  t.opt_id	  = p_base_key_value
296   and	  p_effective_date
297   between t.effective_start_date and t.effective_end_date;
298   --
299   g_api_dml := false;   -- Unset the api dml status
300   p_object_version_number := l_object_version_number;
301   hr_utility.set_location(' Leaving:'||l_proc, 15);
302 --
303 Exception
304   When Others Then
305     g_api_dml := false;   -- Unset the api dml status
306     Raise;
307 End upd_effective_end_date;
308 --
309 -- ----------------------------------------------------------------------------
310 -- |---------------------------------< lck >----------------------------------|
311 -- ----------------------------------------------------------------------------
312 Procedure lck
313 	(p_effective_date	 in  date,
314 	 p_datetrack_mode	 in  varchar2,
315 	 p_opt_id	 in  number,
316 	 p_object_version_number in  number,
317 	 p_validation_start_date out nocopy date,
318 	 p_validation_end_date	 out nocopy date) is
319 --
320   l_proc		  varchar2(72) := g_package||'lck';
321   l_validation_start_date date;
322   l_validation_end_date	  date;
323   l_object_invalid 	  exception;
324   l_argument		  varchar2(30);
325   --
326   -- Cursor C_Sel1 selects the current locked row as of session date
327   -- ensuring that the object version numbers match.
328   --
329   Cursor C_Sel1 is
330     select
331 	opt_id,
332 	effective_start_date,
333 	effective_end_date,
334 	name,
335 	cmbn_ptip_opt_id,
336 	business_group_id,
337 	opt_attribute_category,
338 	opt_attribute1,
339 	opt_attribute2,
340 	opt_attribute3,
341 	opt_attribute4,
342 	opt_attribute5,
343 	opt_attribute6,
344 	opt_attribute7,
345 	opt_attribute8,
346 	opt_attribute9,
347 	opt_attribute10,
348 	opt_attribute11,
349 	opt_attribute12,
350 	opt_attribute13,
351 	opt_attribute14,
352 	opt_attribute15,
353 	opt_attribute16,
354 	opt_attribute17,
355 	opt_attribute18,
356 	opt_attribute19,
357 	opt_attribute20,
358 	opt_attribute21,
359 	opt_attribute22,
360 	opt_attribute23,
361 	opt_attribute24,
362 	opt_attribute25,
363 	opt_attribute26,
364 	opt_attribute27,
365 	opt_attribute28,
366 	opt_attribute29,
367 	opt_attribute30,
368 	object_version_number,
369 	rqd_perd_enrt_nenrt_uom,
370 	rqd_perd_enrt_nenrt_val,
371 	rqd_perd_enrt_nenrt_rl,
372 	invk_wv_opt_flag,
373 	short_name,
374 	short_code,
375 	legislation_code,
376 	legislation_subgroup,
377         group_opt_id ,
378 	component_reason,
379         mapping_table_name,
380         mapping_table_pk_id
381     from    ben_opt_f
382     where   opt_id         = p_opt_id
383     and	    p_effective_date
384     between effective_start_date and effective_end_date
385     for update nowait;
386   --
387   --
388   --
389 Begin
390   hr_utility.set_location('Entering:'||l_proc, 5);
391   --
392   -- Ensure that all the mandatory arguments are not null
393   --
394   hr_api.mandatory_arg_error(p_api_name       => l_proc,
398   hr_api.mandatory_arg_error(p_api_name       => l_proc,
395                              p_argument       => 'effective_date',
396                              p_argument_value => p_effective_date);
397   --
399                              p_argument       => 'datetrack_mode',
400                              p_argument_value => p_datetrack_mode);
401   --
402   hr_api.mandatory_arg_error(p_api_name       => l_proc,
403                              p_argument       => 'opt_id',
404                              p_argument_value => p_opt_id);
405   --
406   hr_api.mandatory_arg_error(p_api_name       => l_proc,
407                              p_argument       => 'object_version_number',
408                              p_argument_value => p_object_version_number);
409   --
410   -- Check to ensure the datetrack mode is not INSERT.
411   --
412   If (p_datetrack_mode <> 'INSERT') then
413     --
414     -- We must select and lock the current row.
415     --
416     Open  C_Sel1;
417     Fetch C_Sel1 Into g_old_rec;
418     If C_Sel1%notfound then
419       Close C_Sel1;
420       --
421       -- The primary key is invalid therefore we must error
422       --
423       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
424       hr_utility.raise_error;
425     End If;
426     Close C_Sel1;
427     If (p_object_version_number <> g_old_rec.object_version_number) Then
428         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
429         hr_utility.raise_error;
430       End If;
431     hr_utility.set_location(l_proc, 15);
432     --
433     --
434     -- Validate the datetrack mode mode getting the validation start
435     -- and end dates for the specified datetrack operation.
436     --
437     dt_api.validate_dt_mode
438 	(p_effective_date	   => p_effective_date,
439 	 p_datetrack_mode	   => p_datetrack_mode,
440 	 p_base_table_name	   => 'ben_opt_f',
441 	 p_base_key_column	   => 'opt_id',
442 	 p_base_key_value 	   => p_opt_id,
443 	 p_parent_table_name1      => 'ben_cmbn_ptip_opt_f',
444 	 p_parent_key_column1      => 'cmbn_ptip_opt_id',
445 	 p_parent_key_value1       => g_old_rec.cmbn_ptip_opt_id,
446          p_enforce_foreign_locking => true,
447 	 p_validation_start_date   => l_validation_start_date,
448  	 p_validation_end_date	   => l_validation_end_date);
449   Else
450     --
451     -- We are doing a datetrack 'INSERT' which is illegal within this
452     -- procedure therefore we must error (note: to lck on insert the
453     -- private procedure ins_lck should be called).
454     --
455     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
456     hr_utility.set_message_token('PROCEDURE', l_proc);
457     hr_utility.set_message_token('STEP','20');
458     hr_utility.raise_error;
459   End If;
460   --
461   -- Set the validation start and end date OUT arguments
462   --
463   p_validation_start_date := l_validation_start_date;
464   p_validation_end_date   := l_validation_end_date;
465   --
466   hr_utility.set_location(' Leaving:'||l_proc, 30);
467 --
468 -- We need to trap the ORA LOCK exception
469 --
470 Exception
471   When HR_Api.Object_Locked then
472     --
473     -- The object is locked therefore we need to supply a meaningful
474     -- error message.
475     --
476     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
477     hr_utility.set_message_token('TABLE_NAME', 'ben_opt_f');
478     hr_utility.raise_error;
479   When l_object_invalid then
480     --
481     -- The object doesn't exist or is invalid
482     --
483     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
484     hr_utility.set_message_token('TABLE_NAME', 'ben_opt_f');
485     hr_utility.raise_error;
486 End lck;
487 --
488 -- ----------------------------------------------------------------------------
489 -- |-----------------------------< convert_args >-----------------------------|
490 -- ----------------------------------------------------------------------------
491 Function convert_args
492 	(
493 	p_opt_id                        in number,
494 	p_effective_start_date          in date,
495 	p_effective_end_date            in date,
496 	p_name                          in varchar2,
497 	p_cmbn_ptip_opt_id              in number,
498 	p_business_group_id             in number,
499 	p_opt_attribute_category        in varchar2,
500 	p_opt_attribute1                in varchar2,
501 	p_opt_attribute2                in varchar2,
502 	p_opt_attribute3                in varchar2,
503 	p_opt_attribute4                in varchar2,
504 	p_opt_attribute5                in varchar2,
505 	p_opt_attribute6                in varchar2,
506 	p_opt_attribute7                in varchar2,
507 	p_opt_attribute8                in varchar2,
508 	p_opt_attribute9                in varchar2,
509 	p_opt_attribute10               in varchar2,
510 	p_opt_attribute11               in varchar2,
511 	p_opt_attribute12               in varchar2,
512 	p_opt_attribute13               in varchar2,
513 	p_opt_attribute14               in varchar2,
514 	p_opt_attribute15               in varchar2,
515 	p_opt_attribute16               in varchar2,
516 	p_opt_attribute17               in varchar2,
517 	p_opt_attribute18               in varchar2,
518 	p_opt_attribute19               in varchar2,
519 	p_opt_attribute20               in varchar2,
520 	p_opt_attribute21               in varchar2,
521 	p_opt_attribute22               in varchar2,
522 	p_opt_attribute23               in varchar2,
523 	p_opt_attribute24               in varchar2,
524 	p_opt_attribute25               in varchar2,
525 	p_opt_attribute26               in varchar2,
526 	p_opt_attribute27               in varchar2,
527 	p_opt_attribute28               in varchar2,
528 	p_opt_attribute29               in varchar2,
532 	p_rqd_perd_enrt_nenrt_val       in number,
529 	p_opt_attribute30               in varchar2,
530 	p_object_version_number         in number,
531 	p_rqd_perd_enrt_nenrt_uom       in varchar2,
533 	p_rqd_perd_enrt_nenrt_rl        in number,
534 	p_invk_wv_opt_flag              in varchar2,
535 	p_short_name			in varchar2,
536 	p_short_code			in varchar2,
537 	p_legislation_code		in varchar2,
538 	p_legislation_subgroup		in varchar2,
539 	p_group_opt_id      		in number,
540 	p_component_reason              in varchar2,
541         p_mapping_table_name            in varchar2,
542         p_mapping_table_pk_id           in number
543 	)
544 	Return g_rec_type is
545 --
546   l_rec	  g_rec_type;
547   l_proc  varchar2(72) := g_package||'convert_args';
548 --
549 Begin
550   --
551   hr_utility.set_location('Entering:'||l_proc, 5);
552   --
553   -- Convert arguments into local l_rec structure.
554   --
555   l_rec.opt_id                           := p_opt_id;
556   l_rec.effective_start_date             := p_effective_start_date;
557   l_rec.effective_end_date               := p_effective_end_date;
558   l_rec.name                             := p_name;
559   l_rec.cmbn_ptip_opt_id                 := p_cmbn_ptip_opt_id;
560   l_rec.business_group_id                := p_business_group_id;
561   l_rec.opt_attribute_category           := p_opt_attribute_category;
562   l_rec.opt_attribute1                   := p_opt_attribute1;
563   l_rec.opt_attribute2                   := p_opt_attribute2;
564   l_rec.opt_attribute3                   := p_opt_attribute3;
565   l_rec.opt_attribute4                   := p_opt_attribute4;
566   l_rec.opt_attribute5                   := p_opt_attribute5;
567   l_rec.opt_attribute6                   := p_opt_attribute6;
568   l_rec.opt_attribute7                   := p_opt_attribute7;
569   l_rec.opt_attribute8                   := p_opt_attribute8;
570   l_rec.opt_attribute9                   := p_opt_attribute9;
571   l_rec.opt_attribute10                  := p_opt_attribute10;
572   l_rec.opt_attribute11                  := p_opt_attribute11;
573   l_rec.opt_attribute12                  := p_opt_attribute12;
574   l_rec.opt_attribute13                  := p_opt_attribute13;
575   l_rec.opt_attribute14                  := p_opt_attribute14;
576   l_rec.opt_attribute15                  := p_opt_attribute15;
577   l_rec.opt_attribute16                  := p_opt_attribute16;
578   l_rec.opt_attribute17                  := p_opt_attribute17;
579   l_rec.opt_attribute18                  := p_opt_attribute18;
580   l_rec.opt_attribute19                  := p_opt_attribute19;
581   l_rec.opt_attribute20                  := p_opt_attribute20;
582   l_rec.opt_attribute21                  := p_opt_attribute21;
583   l_rec.opt_attribute22                  := p_opt_attribute22;
584   l_rec.opt_attribute23                  := p_opt_attribute23;
585   l_rec.opt_attribute24                  := p_opt_attribute24;
586   l_rec.opt_attribute25                  := p_opt_attribute25;
587   l_rec.opt_attribute26                  := p_opt_attribute26;
588   l_rec.opt_attribute27                  := p_opt_attribute27;
589   l_rec.opt_attribute28                  := p_opt_attribute28;
590   l_rec.opt_attribute29                  := p_opt_attribute29;
591   l_rec.opt_attribute30                  := p_opt_attribute30;
592   l_rec.object_version_number            := p_object_version_number;
593   l_rec.rqd_perd_enrt_nenrt_uom          := p_rqd_perd_enrt_nenrt_uom;
594   l_rec.rqd_perd_enrt_nenrt_val          := p_rqd_perd_enrt_nenrt_val;
595   l_rec.rqd_perd_enrt_nenrt_rl           := p_rqd_perd_enrt_nenrt_rl;
596   l_rec.invk_wv_opt_flag                 := p_invk_wv_opt_flag;
597   l_rec.short_name                       := p_short_name;
598   l_rec.short_code                       := p_short_code;
599   l_rec.legislation_code                 := p_legislation_code;
600   l_rec.legislation_subgroup             := p_legislation_subgroup;
601   l_rec.group_opt_id                     := p_group_opt_id;
602   l_rec.component_reason                 := p_component_reason;
603   l_rec.mapping_table_name               := p_mapping_table_name;
604   l_rec.mapping_table_pk_id              := p_mapping_table_pk_id;
605   --
606   -- Return the plsql record structure.
607   --
608   hr_utility.set_location(' Leaving:'||l_proc, 10);
609   Return(l_rec);
610 --
611 End convert_args;
612 --
613 end ben_opt_shd;