DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_RRB_SHD

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_rrb_shd as
2 /* $Header: berrbrhi.pkb 120.1 2008/02/05 08:33:28 rtagarra noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_rrb_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_REGN_FOR_REGY_BODY_FK1') Then
37     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38     fnd_message.set_token('PROCEDURE', l_proc);
39     fnd_message.set_token('STEP','5');
40     fnd_message.raise_error;
41   ElsIf (p_constraint_name = 'BEN_REGN_FOR_REGY_BODY_PK') Then
42     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('STEP','10');
45     fnd_message.raise_error;
46   Else
47     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50     fnd_message.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_regn_for_regy_body_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 	regn_for_regy_body_id,
71 	effective_start_date,
72 	effective_end_date,
73 	regn_admin_cd,
74 	regn_id,
75 	organization_id,
76 	business_group_id,
77 	rrb_attribute_category,
78 	rrb_attribute1,
79 	rrb_attribute2,
80 	rrb_attribute3,
81 	rrb_attribute4,
82 	rrb_attribute5,
83 	rrb_attribute6,
84 	rrb_attribute7,
85 	rrb_attribute8,
86 	rrb_attribute9,
87 	rrb_attribute10,
88 	rrb_attribute11,
89 	rrb_attribute12,
90 	rrb_attribute13,
91 	rrb_attribute14,
92 	rrb_attribute15,
93 	rrb_attribute16,
94 	rrb_attribute17,
95 	rrb_attribute18,
96 	rrb_attribute19,
97 	rrb_attribute20,
98 	rrb_attribute21,
99 	rrb_attribute22,
100 	rrb_attribute23,
101 	rrb_attribute24,
102 	rrb_attribute25,
103 	rrb_attribute26,
104 	rrb_attribute27,
105 	rrb_attribute28,
106 	rrb_attribute29,
107 	rrb_attribute30,
108 	object_version_number
109     from	ben_regn_for_regy_body_f
110     where	regn_for_regy_body_id = p_regn_for_regy_body_id
111     and		p_effective_date
112     between	effective_start_date and effective_end_date;
113 --
114   l_proc	varchar2(72)	:= g_package||'api_updating';
115   l_fct_ret	boolean;
116 --
117 Begin
118   hr_utility.set_location('Entering:'||l_proc, 5);
119   --
120   If (p_effective_date is null or
121       p_regn_for_regy_body_id is null or
122       p_object_version_number is null) Then
123     --
124     -- One of the primary key arguments is null therefore we must
125     -- set the returning function value to false
126     --
127     l_fct_ret := false;
128   Else
129     If (p_regn_for_regy_body_id = g_old_rec.regn_for_regy_body_id and
130         p_object_version_number = g_old_rec.object_version_number) Then
131       hr_utility.set_location(l_proc, 10);
132       --
133       -- The g_old_rec is current therefore we must
134       -- set the returning function to true
135       --
136       l_fct_ret := true;
137     Else
138       --
139       -- Select the current row
140       --
141       Open C_Sel1;
142       Fetch C_Sel1 Into g_old_rec;
143       If C_Sel1%notfound Then
144         Close C_Sel1;
145         --
146         -- The primary key is invalid therefore we must error
147         --
148         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149         fnd_message.raise_error;
150       End If;
151       Close C_Sel1;
152       If (p_object_version_number <> g_old_rec.object_version_number) Then
156       hr_utility.set_location(l_proc, 15);
153         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154         fnd_message.raise_error;
155       End If;
157       l_fct_ret := true;
158     End If;
159   End If;
160   hr_utility.set_location(' Leaving:'||l_proc, 20);
161   Return (l_fct_ret);
162 --
163 End api_updating;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |--------------------------< find_dt_del_modes >---------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure find_dt_del_modes
169 	(p_effective_date	in  date,
170 	 p_base_key_value	in  number,
171 	 p_zap		 out nocopy boolean,
172 	 p_delete	 out nocopy boolean,
173 	 p_future_change out nocopy boolean,
174 	 p_delete_next_change out nocopy boolean) is
175 --
176   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
177 --
178   l_parent_key_value1	number;
179   --
180   Cursor C_Sel1 Is
181     select  t.regn_id
182     from    ben_regn_for_regy_body_f t
183     where   t.regn_for_regy_body_id = p_base_key_value
184     and     p_effective_date
185     between t.effective_start_date and t.effective_end_date;
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   Open  C_Sel1;
190   Fetch C_Sel1 Into l_parent_key_value1;
191   If C_Sel1%notfound then
192     Close C_Sel1;
193     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
194     fnd_message.set_token('PROCEDURE', l_proc);
195     fnd_message.set_token('STEP','10');
196     fnd_message.raise_error;
197   End If;
198   Close C_Sel1;
199   --
200   -- Call the corresponding datetrack api
201   --
202   dt_api.find_dt_del_modes
203 	(p_effective_date	=> p_effective_date,
204 	 p_base_table_name	=> 'ben_regn_for_regy_body_f',
205 	 p_base_key_column	=> 'regn_for_regy_body_id',
206 	 p_base_key_value	=> p_base_key_value,
207 	 p_parent_table_name1	=> 'ben_regn_f',
208 	 p_parent_key_column1	=> 'regn_id',
209 	 p_parent_key_value1	=> l_parent_key_value1,
210 	 p_zap			=> p_zap,
211 	 p_delete		=> p_delete,
212 	 p_future_change	=> p_future_change,
213 	 p_delete_next_change	=> p_delete_next_change);
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End find_dt_del_modes;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |--------------------------< find_dt_upd_modes >---------------------------|
220 -- ----------------------------------------------------------------------------
221 Procedure find_dt_upd_modes
222 	(p_effective_date	in  date,
223 	 p_base_key_value	in  number,
224 	 p_correction	 out nocopy boolean,
225 	 p_update	 out nocopy boolean,
226 	 p_update_override out nocopy boolean,
227 	 p_update_change_insert out nocopy boolean) is
228 --
229   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233   --
234   -- Call the corresponding datetrack api
235   --
236   dt_api.find_dt_upd_modes
237 	(p_effective_date	=> p_effective_date,
238 	 p_base_table_name	=> 'ben_regn_for_regy_body_f',
239 	 p_base_key_column	=> 'regn_for_regy_body_id',
240 	 p_base_key_value	=> p_base_key_value,
241 	 p_correction		=> p_correction,
242 	 p_update		=> p_update,
243 	 p_update_override	=> p_update_override,
244 	 p_update_change_insert	=> p_update_change_insert);
245   --
246   hr_utility.set_location(' Leaving:'||l_proc, 10);
247 End find_dt_upd_modes;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |------------------------< upd_effective_end_date >------------------------|
251 -- ----------------------------------------------------------------------------
252 Procedure upd_effective_end_date
253 	(p_effective_date		in date,
254 	 p_base_key_value		in number,
255 	 p_new_effective_end_date	in date,
256 	 p_validation_start_date	in date,
257 	 p_validation_end_date		in date,
258          p_object_version_number       out nocopy number) is
259 --
260   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
261   l_object_version_number number;
262 --
263 Begin
264   hr_utility.set_location('Entering:'||l_proc, 5);
265   --
266   -- Because we are updating a row we must get the next object
267   -- version number.
268   --
269   l_object_version_number :=
270     dt_api.get_object_version_number
271 	(p_base_table_name	=> 'ben_regn_for_regy_body_f',
272 	 p_base_key_column	=> 'regn_for_regy_body_id',
273 	 p_base_key_value	=> p_base_key_value);
274   --
275   hr_utility.set_location(l_proc, 10);
276   g_api_dml := true;  -- Set the api dml status
277   --
278   -- Update the specified datetrack row setting the effective
279   -- end date to the specified new effective end date.
280   --
281   update  ben_regn_for_regy_body_f t
282   set	  t.effective_end_date	  = p_new_effective_end_date,
283 	  t.object_version_number = l_object_version_number
284   where	  t.regn_for_regy_body_id	  = p_base_key_value
285   and	  p_effective_date
286   between t.effective_start_date and t.effective_end_date;
287   --
288   g_api_dml := false;   -- Unset the api dml status
289   p_object_version_number := l_object_version_number;
290   hr_utility.set_location(' Leaving:'||l_proc, 15);
291 --
292 Exception
293   When Others Then
294     g_api_dml := false;   -- Unset the api dml status
295     Raise;
296 End upd_effective_end_date;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |---------------------------------< lck >----------------------------------|
303 	 p_datetrack_mode	 in  varchar2,
300 -- ----------------------------------------------------------------------------
301 Procedure lck
302 	(p_effective_date	 in  date,
304 	 p_regn_for_regy_body_id	 in  number,
305 	 p_object_version_number in  number,
306 	 p_validation_start_date out nocopy date,
307 	 p_validation_end_date	 out nocopy date) is
308 --
309   l_proc		  varchar2(72) := g_package||'lck';
310   l_validation_start_date date;
311   l_validation_end_date	  date;
312   l_object_invalid 	  exception;
313   l_argument		  varchar2(30);
314   --
315   -- Cursor C_Sel1 selects the current locked row as of session date
316   -- ensuring that the object version numbers match.
317   --
318   Cursor C_Sel1 is
319     select
320 	regn_for_regy_body_id,
321 	effective_start_date,
322 	effective_end_date,
323 	regn_admin_cd,
324 	regn_id,
325 	organization_id,
326 	business_group_id,
327 	rrb_attribute_category,
328 	rrb_attribute1,
329 	rrb_attribute2,
330 	rrb_attribute3,
331 	rrb_attribute4,
332 	rrb_attribute5,
333 	rrb_attribute6,
334 	rrb_attribute7,
335 	rrb_attribute8,
336 	rrb_attribute9,
337 	rrb_attribute10,
338 	rrb_attribute11,
339 	rrb_attribute12,
340 	rrb_attribute13,
341 	rrb_attribute14,
342 	rrb_attribute15,
343 	rrb_attribute16,
344 	rrb_attribute17,
345 	rrb_attribute18,
346 	rrb_attribute19,
347 	rrb_attribute20,
348 	rrb_attribute21,
349 	rrb_attribute22,
350 	rrb_attribute23,
351 	rrb_attribute24,
352 	rrb_attribute25,
353 	rrb_attribute26,
354 	rrb_attribute27,
355 	rrb_attribute28,
356 	rrb_attribute29,
357 	rrb_attribute30,
358 	object_version_number
359     from    ben_regn_for_regy_body_f
360     where   regn_for_regy_body_id         = p_regn_for_regy_body_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       => 'regn_for_regy_body_id',
382                              p_argument_value => p_regn_for_regy_body_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       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
402       fnd_message.raise_error;
403     End If;
404     Close C_Sel1;
405     If (p_object_version_number <> g_old_rec.object_version_number) Then
406         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
407         fnd_message.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_regn_for_regy_body_f',
419 	 p_base_key_column	   => 'regn_for_regy_body_id',
420 	 p_base_key_value 	   => p_regn_for_regy_body_id,
421 	 p_parent_table_name1      => 'ben_regn_f',
422 	 p_parent_key_column1      => 'regn_id',
423 	 p_parent_key_value1       => g_old_rec.regn_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     --
433     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
434     fnd_message.set_token('PROCEDURE', l_proc);
435     fnd_message.set_token('STEP','20');
436     fnd_message.raise_error;
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     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
455     fnd_message.set_token('TABLE_NAME', 'ben_regn_for_regy_body_f');
456     fnd_message.raise_error;
457   When l_object_invalid then
458     --
459     -- The object doesn't exist or is invalid
460     --
461     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
462     fnd_message.set_token('TABLE_NAME', 'ben_regn_for_regy_body_f');
463     fnd_message.raise_error;
464 End lck;
465 --
466 -- ----------------------------------------------------------------------------
467 -- |-----------------------------< convert_args >-----------------------------|
468 -- ----------------------------------------------------------------------------
469 Function convert_args
470 	(
471 	p_regn_for_regy_body_id         in number,
472 	p_effective_start_date          in date,
473 	p_effective_end_date            in date,
474 	p_regn_admin_cd                 in varchar2,
475 	p_regn_id                       in number,
476 	p_organization_id               in number,
477 	p_business_group_id             in number,
478 	p_rrb_attribute_category        in varchar2,
479 	p_rrb_attribute1                in varchar2,
480 	p_rrb_attribute2                in varchar2,
481 	p_rrb_attribute3                in varchar2,
482 	p_rrb_attribute4                in varchar2,
483 	p_rrb_attribute5                in varchar2,
484 	p_rrb_attribute6                in varchar2,
485 	p_rrb_attribute7                in varchar2,
486 	p_rrb_attribute8                in varchar2,
487 	p_rrb_attribute9                in varchar2,
488 	p_rrb_attribute10               in varchar2,
489 	p_rrb_attribute11               in varchar2,
490 	p_rrb_attribute12               in varchar2,
491 	p_rrb_attribute13               in varchar2,
492 	p_rrb_attribute14               in varchar2,
493 	p_rrb_attribute15               in varchar2,
494 	p_rrb_attribute16               in varchar2,
495 	p_rrb_attribute17               in varchar2,
496 	p_rrb_attribute18               in varchar2,
497 	p_rrb_attribute19               in varchar2,
498 	p_rrb_attribute20               in varchar2,
499 	p_rrb_attribute21               in varchar2,
500 	p_rrb_attribute22               in varchar2,
501 	p_rrb_attribute23               in varchar2,
502 	p_rrb_attribute24               in varchar2,
503 	p_rrb_attribute25               in varchar2,
504 	p_rrb_attribute26               in varchar2,
505 	p_rrb_attribute27               in varchar2,
506 	p_rrb_attribute28               in varchar2,
507 	p_rrb_attribute29               in varchar2,
508 	p_rrb_attribute30               in varchar2,
509 	p_object_version_number         in number
510 	)
511 	Return g_rec_type is
512 --
513   l_rec	  g_rec_type;
514   l_proc  varchar2(72) := g_package||'convert_args';
515 --
516 Begin
517   --
518   hr_utility.set_location('Entering:'||l_proc, 5);
519   --
520   -- Convert arguments into local l_rec structure.
521   --
522   l_rec.regn_for_regy_body_id            := p_regn_for_regy_body_id;
523   l_rec.effective_start_date             := p_effective_start_date;
524   l_rec.effective_end_date               := p_effective_end_date;
525   l_rec.regn_admin_cd                    := p_regn_admin_cd;
526   l_rec.regn_id                          := p_regn_id;
527   l_rec.organization_id                  := p_organization_id;
528   l_rec.business_group_id                := p_business_group_id;
529   l_rec.rrb_attribute_category           := p_rrb_attribute_category;
530   l_rec.rrb_attribute1                   := p_rrb_attribute1;
531   l_rec.rrb_attribute2                   := p_rrb_attribute2;
532   l_rec.rrb_attribute3                   := p_rrb_attribute3;
533   l_rec.rrb_attribute4                   := p_rrb_attribute4;
534   l_rec.rrb_attribute5                   := p_rrb_attribute5;
535   l_rec.rrb_attribute6                   := p_rrb_attribute6;
536   l_rec.rrb_attribute7                   := p_rrb_attribute7;
537   l_rec.rrb_attribute8                   := p_rrb_attribute8;
538   l_rec.rrb_attribute9                   := p_rrb_attribute9;
539   l_rec.rrb_attribute10                  := p_rrb_attribute10;
540   l_rec.rrb_attribute11                  := p_rrb_attribute11;
541   l_rec.rrb_attribute12                  := p_rrb_attribute12;
542   l_rec.rrb_attribute13                  := p_rrb_attribute13;
543   l_rec.rrb_attribute14                  := p_rrb_attribute14;
544   l_rec.rrb_attribute15                  := p_rrb_attribute15;
545   l_rec.rrb_attribute16                  := p_rrb_attribute16;
546   l_rec.rrb_attribute17                  := p_rrb_attribute17;
547   l_rec.rrb_attribute18                  := p_rrb_attribute18;
548   l_rec.rrb_attribute19                  := p_rrb_attribute19;
549   l_rec.rrb_attribute20                  := p_rrb_attribute20;
550   l_rec.rrb_attribute21                  := p_rrb_attribute21;
551   l_rec.rrb_attribute22                  := p_rrb_attribute22;
552   l_rec.rrb_attribute23                  := p_rrb_attribute23;
553   l_rec.rrb_attribute24                  := p_rrb_attribute24;
554   l_rec.rrb_attribute25                  := p_rrb_attribute25;
555   l_rec.rrb_attribute26                  := p_rrb_attribute26;
556   l_rec.rrb_attribute27                  := p_rrb_attribute27;
557   l_rec.rrb_attribute28                  := p_rrb_attribute28;
558   l_rec.rrb_attribute29                  := p_rrb_attribute29;
559   l_rec.rrb_attribute30                  := p_rrb_attribute30;
560   l_rec.object_version_number            := p_object_version_number;
561   --
562   -- Return the plsql record structure.
563   --
564   hr_utility.set_location(' Leaving:'||l_proc, 10);
565   Return(l_rec);
566 --
567 End convert_args;
568 --
569 end ben_rrb_shd;