DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PTR_SHD

Source


1 Package Body ben_ptr_shd as
2 /* $Header: beptrrhi.pkb 120.0.12010000.2 2008/08/05 15:24:01 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_ptr_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_PER_TYP_RTS_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_per_typ_rt_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 	per_typ_rt_id,
66 	effective_start_date,
67 	effective_end_date,
68 	vrbl_rt_prfl_id,
69 	per_typ_cd,
70         person_type_id,
71 	excld_flag,
72 	ordr_num,
73 	business_group_id,
74 	ptr_attribute_category,
75 	ptr_attribute1,
76 	ptr_attribute2,
77 	ptr_attribute3,
78 	ptr_attribute4,
79 	ptr_attribute5,
80 	ptr_attribute6,
81 	ptr_attribute7,
82 	ptr_attribute8,
83 	ptr_attribute9,
84 	ptr_attribute10,
85 	ptr_attribute11,
86 	ptr_attribute12,
87 	ptr_attribute13,
88 	ptr_attribute14,
89 	ptr_attribute15,
90 	ptr_attribute16,
91 	ptr_attribute17,
92 	ptr_attribute18,
93 	ptr_attribute19,
94 	ptr_attribute20,
95 	ptr_attribute21,
96 	ptr_attribute22,
97 	ptr_attribute23,
98 	ptr_attribute24,
99 	ptr_attribute25,
100 	ptr_attribute26,
101 	ptr_attribute27,
102 	ptr_attribute28,
103 	ptr_attribute29,
104 	ptr_attribute30,
105 	object_version_number
106     from	ben_per_typ_rt_f
107     where	per_typ_rt_id = p_per_typ_rt_id
108     and		p_effective_date
109     between	effective_start_date and effective_end_date;
110 --
111   l_proc	varchar2(72)	:= g_package||'api_updating';
112   l_fct_ret	boolean;
113 --
114 Begin
115   hr_utility.set_location('Entering:'||l_proc, 5);
116   --
117   If (p_effective_date is null or
118       p_per_typ_rt_id is null or
119       p_object_version_number is null) Then
120     --
121     -- One of the primary key arguments is null therefore we must
122     -- set the returning function value to false
123     --
124     l_fct_ret := false;
125   Else
126     If (p_per_typ_rt_id = g_old_rec.per_typ_rt_id and
127         p_object_version_number = g_old_rec.object_version_number) Then
128       hr_utility.set_location(l_proc, 10);
129       --
130       -- The g_old_rec is current therefore we must
131       -- set the returning function to true
132       --
133       l_fct_ret := true;
134     Else
135       --
136       -- Select the current row
137       --
138       Open C_Sel1;
139       Fetch C_Sel1 Into g_old_rec;
140       If C_Sel1%notfound Then
141         Close C_Sel1;
142         --
143         -- The primary key is invalid therefore we must error
144         --
145         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
146         hr_utility.raise_error;
147       End If;
148       Close C_Sel1;
149       If (p_object_version_number <> g_old_rec.object_version_number) Then
150         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
151         hr_utility.raise_error;
152       End If;
153       hr_utility.set_location(l_proc, 15);
154       l_fct_ret := true;
155     End If;
156   End If;
157   hr_utility.set_location(' Leaving:'||l_proc, 20);
158   Return (l_fct_ret);
159 --
160 End api_updating;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |--------------------------< find_dt_del_modes >---------------------------|
164 -- ----------------------------------------------------------------------------
165 Procedure find_dt_del_modes
166 	(p_effective_date	in  date,
167 	 p_base_key_value	in  number,
168 	 p_zap		 out nocopy boolean,
169 	 p_delete	 out nocopy boolean,
170 	 p_future_change out nocopy boolean,
171 	 p_delete_next_change out nocopy boolean) is
172 --
173   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
174 --
175   l_parent_key_value1   number;
176   --
177   Cursor C_Sel1 Is
178     select  t.vrbl_rt_prfl_id
179     from    ben_per_typ_rt_f t
180     where   t.per_typ_rt_id = p_base_key_value
181     and     p_effective_date
182     between t.effective_start_date and t.effective_end_date;
183 --
184 Begin
185   hr_utility.set_location('Entering:'||l_proc, 5);
186     --
187   Open  C_Sel1;
188   Fetch C_Sel1 Into l_parent_key_value1;
189   If C_Sel1%notfound then
190     Close C_Sel1;
191     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
192     hr_utility.set_message_token('PROCEDURE', l_proc);
193     hr_utility.set_message_token('STEP','10');
194     hr_utility.raise_error;
195   End If;
196   Close C_Sel1;
197   --
198   -- Call the corresponding datetrack api
199   --
200   dt_api.find_dt_del_modes
201 	(p_effective_date	=> p_effective_date,
202 	 p_base_table_name	=> 'ben_per_typ_rt_f',
203 	 p_base_key_column	=> 'per_typ_rt_id',
204 	 p_base_key_value	=> p_base_key_value,
205          p_parent_table_name1   => 'ben_vrbl_rt_prfl_f',
206          p_parent_key_column1   => 'vrbl_rt_prfl_id',
207          p_parent_key_value1    => l_parent_key_value1,
208 	 p_zap			=> p_zap,
209 	 p_delete		=> p_delete,
210 	 p_future_change	=> p_future_change,
211 	 p_delete_next_change	=> p_delete_next_change);
212   --
213   hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End find_dt_del_modes;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< find_dt_upd_modes >---------------------------|
218 -- ----------------------------------------------------------------------------
219 Procedure find_dt_upd_modes
220 	(p_effective_date	in  date,
221 	 p_base_key_value	in  number,
222 	 p_correction	 out nocopy boolean,
223 	 p_update	 out nocopy boolean,
224 	 p_update_override out nocopy boolean,
225 	 p_update_change_insert out nocopy boolean) is
226 --
227   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
228 --
229 Begin
230   hr_utility.set_location('Entering:'||l_proc, 5);
231   --
232   -- Call the corresponding datetrack api
233   --
234   dt_api.find_dt_upd_modes
235 	(p_effective_date	=> p_effective_date,
236 	 p_base_table_name	=> 'ben_per_typ_rt_f',
237 	 p_base_key_column	=> 'per_typ_rt_id',
238 	 p_base_key_value	=> p_base_key_value,
239 	 p_correction		=> p_correction,
240 	 p_update		=> p_update,
241 	 p_update_override	=> p_update_override,
242 	 p_update_change_insert	=> p_update_change_insert);
243   --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End find_dt_upd_modes;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |------------------------< upd_effective_end_date >------------------------|
249 -- ----------------------------------------------------------------------------
250 Procedure upd_effective_end_date
251 	(p_effective_date		in date,
252 	 p_base_key_value		in number,
253 	 p_new_effective_end_date	in date,
254 	 p_validation_start_date	in date,
255 	 p_validation_end_date		in date,
256          p_object_version_number       out nocopy number) is
257 --
258   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
259   l_object_version_number number;
260 --
261 Begin
262   hr_utility.set_location('Entering:'||l_proc, 5);
263   --
264   -- Because we are updating a row we must get the next object
265   -- version number.
266   --
267   l_object_version_number :=
268     dt_api.get_object_version_number
269 	(p_base_table_name	=> 'ben_per_typ_rt_f',
270 	 p_base_key_column	=> 'per_typ_rt_id',
271 	 p_base_key_value	=> p_base_key_value);
272   --
273   hr_utility.set_location(l_proc, 10);
274   g_api_dml := true;  -- Set the api dml status
275   --
276   -- Update the specified datetrack row setting the effective
277   -- end date to the specified new effective end date.
278   --
279   update  ben_per_typ_rt_f t
280   set	  t.effective_end_date	  = p_new_effective_end_date,
281 	  t.object_version_number = l_object_version_number
282   where	  t.per_typ_rt_id	  = p_base_key_value
283   and	  p_effective_date
284   between t.effective_start_date and t.effective_end_date;
285   --
286   g_api_dml := false;   -- Unset the api dml status
287   p_object_version_number := l_object_version_number;
288   hr_utility.set_location(' Leaving:'||l_proc, 15);
289 --
290 Exception
291   When Others Then
292     g_api_dml := false;   -- Unset the api dml status
293     Raise;
294 End upd_effective_end_date;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------------< lck >----------------------------------|
298 -- ----------------------------------------------------------------------------
299 Procedure lck
300 	(p_effective_date	 in  date,
301 	 p_datetrack_mode	 in  varchar2,
302 	 p_per_typ_rt_id	 in  number,
303 	 p_object_version_number in  number,
304 	 p_validation_start_date out nocopy date,
305 	 p_validation_end_date	 out nocopy date) is
306 --
307   l_proc		  varchar2(72) := g_package||'lck';
308   l_validation_start_date date;
309   l_validation_end_date	  date;
310   l_object_invalid 	  exception;
311   l_argument		  varchar2(30);
312   --
313   -- Cursor C_Sel1 selects the current locked row as of session date
314   -- ensuring that the object version numbers match.
315   --
316   Cursor C_Sel1 is
317     select
318 	per_typ_rt_id,
319 	effective_start_date,
320 	effective_end_date,
321 	vrbl_rt_prfl_id,
322 	per_typ_cd,
323         person_type_id,
324 	excld_flag,
325 	ordr_num,
326 	business_group_id,
327 	ptr_attribute_category,
328 	ptr_attribute1,
329 	ptr_attribute2,
330 	ptr_attribute3,
331 	ptr_attribute4,
332 	ptr_attribute5,
333 	ptr_attribute6,
334 	ptr_attribute7,
335 	ptr_attribute8,
336 	ptr_attribute9,
337 	ptr_attribute10,
338 	ptr_attribute11,
339 	ptr_attribute12,
340 	ptr_attribute13,
341 	ptr_attribute14,
342 	ptr_attribute15,
343 	ptr_attribute16,
344 	ptr_attribute17,
345 	ptr_attribute18,
346 	ptr_attribute19,
347 	ptr_attribute20,
348 	ptr_attribute21,
349 	ptr_attribute22,
350 	ptr_attribute23,
351 	ptr_attribute24,
352 	ptr_attribute25,
353 	ptr_attribute26,
354 	ptr_attribute27,
355 	ptr_attribute28,
356 	ptr_attribute29,
357 	ptr_attribute30,
358 	object_version_number
359     from    ben_per_typ_rt_f
360     where   per_typ_rt_id         = p_per_typ_rt_id
361     and	    p_effective_date
362     between effective_start_date and effective_end_date
363     for update nowait;
364   --
365   --
366   --
367 Begin
368   hr_utility.set_location('Entering:'||l_proc, 5);
369   --
370   -- Ensure that all the mandatory arguments are not null
371   --
372   hr_api.mandatory_arg_error(p_api_name       => l_proc,
373                              p_argument       => 'effective_date',
374                              p_argument_value => p_effective_date);
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'datetrack_mode',
378                              p_argument_value => p_datetrack_mode);
379   --
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'per_typ_rt_id',
382                              p_argument_value => p_per_typ_rt_id);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'object_version_number',
386                              p_argument_value => p_object_version_number);
387   --
388   -- Check to ensure the datetrack mode is not INSERT.
389   --
390   If (p_datetrack_mode <> 'INSERT') then
391     --
392     -- We must select and lock the current row.
393     --
394     Open  C_Sel1;
395     Fetch C_Sel1 Into g_old_rec;
396     If C_Sel1%notfound then
397       Close C_Sel1;
398       --
399       -- The primary key is invalid therefore we must error
400       --
401       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
402       hr_utility.raise_error;
403     End If;
404     Close C_Sel1;
405     If (p_object_version_number <> g_old_rec.object_version_number) Then
406         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
407         hr_utility.raise_error;
408       End If;
409     hr_utility.set_location(l_proc, 15);
410     --
411     --
412     -- Validate the datetrack mode mode getting the validation start
413     -- and end dates for the specified datetrack operation.
414     --
415     dt_api.validate_dt_mode
416 	(p_effective_date	   => p_effective_date,
417 	 p_datetrack_mode	   => p_datetrack_mode,
418 	 p_base_table_name	   => 'ben_per_typ_rt_f',
419 	 p_base_key_column	   => 'per_typ_rt_id',
420 	 p_base_key_value 	   => p_per_typ_rt_id,
421          p_parent_table_name1      => 'ben_vrbl_rt_prfl_f',
422          p_parent_key_column1      => 'vrbl_rt_prfl_id',
423          p_parent_key_value1       => g_old_rec.vrbl_rt_prfl_id,
424          p_enforce_foreign_locking => false , --true,
425 	 p_validation_start_date   => l_validation_start_date,
426  	 p_validation_end_date	   => l_validation_end_date);
427   Else
428     --
429     -- We are doing a datetrack 'INSERT' which is illegal within this
430     -- procedure therefore we must error (note: to lck on insert the
431     -- private procedure ins_lck should be called).
432     --
436     hr_utility.raise_error;
433     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
434     hr_utility.set_message_token('PROCEDURE', l_proc);
435     hr_utility.set_message_token('STEP','20');
437   End If;
438   --
439   -- Set the validation start and end date OUT arguments
440   --
441   p_validation_start_date := l_validation_start_date;
442   p_validation_end_date   := l_validation_end_date;
443   --
444   hr_utility.set_location(' Leaving:'||l_proc, 30);
445 --
446 -- We need to trap the ORA LOCK exception
447 --
448 Exception
449   When HR_Api.Object_Locked then
450     --
451     -- The object is locked therefore we need to supply a meaningful
452     -- error message.
453     --
454     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
455     hr_utility.set_message_token('TABLE_NAME', 'ben_per_typ_rt_f');
456     hr_utility.raise_error;
457   When l_object_invalid then
458     --
459     -- The object doesn't exist or is invalid
460     --
461     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
462     hr_utility.set_message_token('TABLE_NAME', 'ben_per_typ_rt_f');
463     hr_utility.raise_error;
464 End lck;
465 --
466 -- ----------------------------------------------------------------------------
467 -- |-----------------------------< convert_args >-----------------------------|
468 -- ----------------------------------------------------------------------------
469 Function convert_args
470 	(
471 	p_per_typ_rt_id                 in number,
472 	p_effective_start_date          in date,
473 	p_effective_end_date            in date,
474 	p_vrbl_rt_prfl_id               in number,
475 	p_per_typ_cd                    in varchar2,
476         p_person_type_id                in number,
477 	p_excld_flag                    in varchar2,
478 	p_ordr_num                      in number,
479 	p_business_group_id             in number,
480 	p_ptr_attribute_category        in varchar2,
481 	p_ptr_attribute1                in varchar2,
482 	p_ptr_attribute2                in varchar2,
483 	p_ptr_attribute3                in varchar2,
484 	p_ptr_attribute4                in varchar2,
485 	p_ptr_attribute5                in varchar2,
486 	p_ptr_attribute6                in varchar2,
487 	p_ptr_attribute7                in varchar2,
488 	p_ptr_attribute8                in varchar2,
489 	p_ptr_attribute9                in varchar2,
490 	p_ptr_attribute10               in varchar2,
491 	p_ptr_attribute11               in varchar2,
492 	p_ptr_attribute12               in varchar2,
493 	p_ptr_attribute13               in varchar2,
494 	p_ptr_attribute14               in varchar2,
495 	p_ptr_attribute15               in varchar2,
496 	p_ptr_attribute16               in varchar2,
497 	p_ptr_attribute17               in varchar2,
498 	p_ptr_attribute18               in varchar2,
499 	p_ptr_attribute19               in varchar2,
500 	p_ptr_attribute20               in varchar2,
501 	p_ptr_attribute21               in varchar2,
502 	p_ptr_attribute22               in varchar2,
503 	p_ptr_attribute23               in varchar2,
504 	p_ptr_attribute24               in varchar2,
505 	p_ptr_attribute25               in varchar2,
506 	p_ptr_attribute26               in varchar2,
507 	p_ptr_attribute27               in varchar2,
508 	p_ptr_attribute28               in varchar2,
509 	p_ptr_attribute29               in varchar2,
510 	p_ptr_attribute30               in varchar2,
511 	p_object_version_number         in number
512 	)
513 	Return g_rec_type is
514 --
515   l_rec	  g_rec_type;
516   l_proc  varchar2(72) := g_package||'convert_args';
517 --
518 Begin
519   --
520   hr_utility.set_location('Entering:'||l_proc, 5);
521   --
522   -- Convert arguments into local l_rec structure.
523   --
524   l_rec.per_typ_rt_id                    := p_per_typ_rt_id;
525   l_rec.effective_start_date             := p_effective_start_date;
526   l_rec.effective_end_date               := p_effective_end_date;
527   l_rec.vrbl_rt_prfl_id                  := p_vrbl_rt_prfl_id;
528   l_rec.per_typ_cd                       := p_per_typ_cd;
529   l_rec.person_type_id	                 := p_person_type_id;
530   l_rec.excld_flag                       := p_excld_flag;
531   l_rec.ordr_num                         := p_ordr_num;
532   l_rec.business_group_id                := p_business_group_id;
533   l_rec.ptr_attribute_category           := p_ptr_attribute_category;
534   l_rec.ptr_attribute1                   := p_ptr_attribute1;
535   l_rec.ptr_attribute2                   := p_ptr_attribute2;
536   l_rec.ptr_attribute3                   := p_ptr_attribute3;
537   l_rec.ptr_attribute4                   := p_ptr_attribute4;
538   l_rec.ptr_attribute5                   := p_ptr_attribute5;
539   l_rec.ptr_attribute6                   := p_ptr_attribute6;
540   l_rec.ptr_attribute7                   := p_ptr_attribute7;
541   l_rec.ptr_attribute8                   := p_ptr_attribute8;
542   l_rec.ptr_attribute9                   := p_ptr_attribute9;
543   l_rec.ptr_attribute10                  := p_ptr_attribute10;
544   l_rec.ptr_attribute11                  := p_ptr_attribute11;
545   l_rec.ptr_attribute12                  := p_ptr_attribute12;
546   l_rec.ptr_attribute13                  := p_ptr_attribute13;
547   l_rec.ptr_attribute14                  := p_ptr_attribute14;
548   l_rec.ptr_attribute15                  := p_ptr_attribute15;
549   l_rec.ptr_attribute16                  := p_ptr_attribute16;
550   l_rec.ptr_attribute17                  := p_ptr_attribute17;
551   l_rec.ptr_attribute18                  := p_ptr_attribute18;
552   l_rec.ptr_attribute19                  := p_ptr_attribute19;
553   l_rec.ptr_attribute20                  := p_ptr_attribute20;
554   l_rec.ptr_attribute21                  := p_ptr_attribute21;
555   l_rec.ptr_attribute22                  := p_ptr_attribute22;
556   l_rec.ptr_attribute23                  := p_ptr_attribute23;
557   l_rec.ptr_attribute24                  := p_ptr_attribute24;
558   l_rec.ptr_attribute25                  := p_ptr_attribute25;
559   l_rec.ptr_attribute26                  := p_ptr_attribute26;
560   l_rec.ptr_attribute27                  := p_ptr_attribute27;
561   l_rec.ptr_attribute28                  := p_ptr_attribute28;
562   l_rec.ptr_attribute29                  := p_ptr_attribute29;
563   l_rec.ptr_attribute30                  := p_ptr_attribute30;
564   l_rec.object_version_number            := p_object_version_number;
565   --
566   -- Return the plsql record structure.
567   --
568   hr_utility.set_location(' Leaving:'||l_proc, 10);
569   Return(l_rec);
570 --
571 End convert_args;
572 --
573 end ben_ptr_shd;