DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_HWR_SHD

Source


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