DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_SAR_SHD

Source


1 Package Body ben_sar_shd as
2 /* $Header: besarrhi.pkb 120.0.12010000.2 2008/08/05 15:26:57 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_sar_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_SVC_AREA_RT_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   ElsIf (p_constraint_name = 'EXCLD_FLAG_FLGD') 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_svc_area_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 	svc_area_rt_id,
71 	effective_start_date,
72 	effective_end_date,
73 	excld_flag,
74 	ordr_num,
75 	svc_area_id,
76 	vrbl_rt_prfl_id,
77 	business_group_id,
78 	sar_attribute_category,
79 	sar_attribute1,
80 	sar_attribute2,
81 	sar_attribute3,
82 	sar_attribute4,
83 	sar_attribute5,
84 	sar_attribute6,
85 	sar_attribute7,
86 	sar_attribute8,
87 	sar_attribute9,
88 	sar_attribute10,
89 	sar_attribute11,
90 	sar_attribute12,
91 	sar_attribute13,
92 	sar_attribute14,
93 	sar_attribute15,
94 	sar_attribute16,
95 	sar_attribute17,
96 	sar_attribute18,
97 	sar_attribute19,
98 	sar_attribute20,
99 	sar_attribute21,
100 	sar_attribute22,
101 	sar_attribute23,
102 	sar_attribute24,
103 	sar_attribute25,
104 	sar_attribute26,
105 	sar_attribute27,
106 	sar_attribute28,
107 	sar_attribute29,
108 	sar_attribute30,
109 	object_version_number
110     from	ben_svc_area_rt_f
111     where	svc_area_rt_id = p_svc_area_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_svc_area_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_svc_area_rt_id = g_old_rec.svc_area_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   l_parent_key_value2	number;
181   --
182   Cursor C_Sel1 Is
183     select  t.vrbl_rt_prfl_id,
184 	    t.svc_area_id
185     from    ben_svc_area_rt_f t
186     where   t.svc_area_rt_id = p_base_key_value
187     and     p_effective_date
188     between t.effective_start_date and t.effective_end_date;
189 --
190 Begin
191   hr_utility.set_location('Entering:'||l_proc, 5);
192   Open  C_Sel1;
193   Fetch C_Sel1 Into l_parent_key_value1,
194 		    l_parent_key_value2;
195   If C_Sel1%notfound then
196     Close C_Sel1;
197     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
198     hr_utility.set_message_token('PROCEDURE', l_proc);
199     hr_utility.set_message_token('STEP','10');
200     hr_utility.raise_error;
201   End If;
202   Close C_Sel1;
203   --
204   -- Call the corresponding datetrack api
205   --
206   dt_api.find_dt_del_modes
207 	(p_effective_date	=> p_effective_date,
208 	 p_base_table_name	=> 'ben_svc_area_rt_f',
209 	 p_base_key_column	=> 'svc_area_rt_id',
210 	 p_base_key_value	=> p_base_key_value,
211 	 p_parent_table_name1	=> 'ben_vrbl_rt_prfl_f',
212 	 p_parent_key_column1	=> 'vrbl_rt_prfl_id',
213 	 p_parent_key_value1	=> l_parent_key_value1,
214 	 p_parent_table_name2	=> 'ben_svc_area_f',
215 	 p_parent_key_column2	=> 'svc_area_id',
216 	 p_parent_key_value2	=> l_parent_key_value2,
217 	 p_zap			=> p_zap,
218 	 p_delete		=> p_delete,
219 	 p_future_change	=> p_future_change,
220 	 p_delete_next_change	=> p_delete_next_change);
221   --
222   hr_utility.set_location(' Leaving:'||l_proc, 10);
223 End find_dt_del_modes;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |--------------------------< find_dt_upd_modes >---------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure find_dt_upd_modes
229 	(p_effective_date	in  date,
230 	 p_base_key_value	in  number,
231 	 p_correction	 out nocopy boolean,
232 	 p_update	 out nocopy boolean,
233 	 p_update_override out nocopy boolean,
234 	 p_update_change_insert out nocopy boolean) is
235 --
236   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
237 --
238 Begin
239   hr_utility.set_location('Entering:'||l_proc, 5);
240   --
241   -- Call the corresponding datetrack api
242   --
243   dt_api.find_dt_upd_modes
244 	(p_effective_date	=> p_effective_date,
245 	 p_base_table_name	=> 'ben_svc_area_rt_f',
246 	 p_base_key_column	=> 'svc_area_rt_id',
247 	 p_base_key_value	=> p_base_key_value,
248 	 p_correction		=> p_correction,
249 	 p_update		=> p_update,
250 	 p_update_override	=> p_update_override,
251 	 p_update_change_insert	=> p_update_change_insert);
252   --
253   hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End find_dt_upd_modes;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |------------------------< upd_effective_end_date >------------------------|
258 -- ----------------------------------------------------------------------------
259 Procedure upd_effective_end_date
260 	(p_effective_date		in date,
261 	 p_base_key_value		in number,
262 	 p_new_effective_end_date	in date,
263 	 p_validation_start_date	in date,
264 	 p_validation_end_date		in date,
265          p_object_version_number       out nocopy number) is
266 --
267   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
268   l_object_version_number number;
269 --
270 Begin
271   hr_utility.set_location('Entering:'||l_proc, 5);
272   --
273   -- Because we are updating a row we must get the next object
274   -- version number.
275   --
276   l_object_version_number :=
277     dt_api.get_object_version_number
278 	(p_base_table_name	=> 'ben_svc_area_rt_f',
279 	 p_base_key_column	=> 'svc_area_rt_id',
280 	 p_base_key_value	=> p_base_key_value);
281   --
282   hr_utility.set_location(l_proc, 10);
283   g_api_dml := true;  -- Set the api dml status
284   --
285   -- Update the specified datetrack row setting the effective
286   -- end date to the specified new effective end date.
287   --
288   update  ben_svc_area_rt_f t
289   set	  t.effective_end_date	  = p_new_effective_end_date,
290 	  t.object_version_number = l_object_version_number
291   where	  t.svc_area_rt_id	  = p_base_key_value
292   and	  p_effective_date
293   between t.effective_start_date and t.effective_end_date;
294   --
295   g_api_dml := false;   -- Unset the api dml status
296   p_object_version_number := l_object_version_number;
297   hr_utility.set_location(' Leaving:'||l_proc, 15);
298 --
299 Exception
300   When Others Then
301     g_api_dml := false;   -- Unset the api dml status
302     Raise;
303 End upd_effective_end_date;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< lck >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure lck
309 	(p_effective_date	 in  date,
310 	 p_datetrack_mode	 in  varchar2,
311 	 p_svc_area_rt_id	 in  number,
312 	 p_object_version_number in  number,
313 	 p_validation_start_date out nocopy date,
314 	 p_validation_end_date	 out nocopy date) is
315 --
316   l_proc		  varchar2(72) := g_package||'lck';
317   l_validation_start_date date;
318   l_validation_end_date	  date;
319   l_object_invalid 	  exception;
320   l_argument		  varchar2(30);
321   --
322   -- Cursor C_Sel1 selects the current locked row as of session date
323   -- ensuring that the object version numbers match.
324   --
325   Cursor C_Sel1 is
326     select
327 	svc_area_rt_id,
328 	effective_start_date,
329 	effective_end_date,
330 	excld_flag,
331 	ordr_num,
332 	svc_area_id,
333 	vrbl_rt_prfl_id,
334 	business_group_id,
335 	sar_attribute_category,
336 	sar_attribute1,
337 	sar_attribute2,
338 	sar_attribute3,
339 	sar_attribute4,
340 	sar_attribute5,
341 	sar_attribute6,
342 	sar_attribute7,
343 	sar_attribute8,
344 	sar_attribute9,
345 	sar_attribute10,
346 	sar_attribute11,
347 	sar_attribute12,
348 	sar_attribute13,
349 	sar_attribute14,
350 	sar_attribute15,
351 	sar_attribute16,
352 	sar_attribute17,
353 	sar_attribute18,
354 	sar_attribute19,
355 	sar_attribute20,
356 	sar_attribute21,
357 	sar_attribute22,
358 	sar_attribute23,
359 	sar_attribute24,
360 	sar_attribute25,
361 	sar_attribute26,
362 	sar_attribute27,
363 	sar_attribute28,
364 	sar_attribute29,
365 	sar_attribute30,
366 	object_version_number
367     from    ben_svc_area_rt_f
368     where   svc_area_rt_id         = p_svc_area_rt_id
369     and	    p_effective_date
370     between effective_start_date and effective_end_date
371     for update nowait;
372   --
373   --
374   --
375 Begin
376   hr_utility.set_location('Entering:'||l_proc, 5);
377   --
378   -- Ensure that all the mandatory arguments are not null
379   --
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'effective_date',
382                              p_argument_value => p_effective_date);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'datetrack_mode',
386                              p_argument_value => p_datetrack_mode);
387   --
388   hr_api.mandatory_arg_error(p_api_name       => l_proc,
389                              p_argument       => 'svc_area_rt_id',
390                              p_argument_value => p_svc_area_rt_id);
391   --
392   hr_api.mandatory_arg_error(p_api_name       => l_proc,
393                              p_argument       => 'object_version_number',
394                              p_argument_value => p_object_version_number);
395   --
396   -- Check to ensure the datetrack mode is not INSERT.
397   --
398   If (p_datetrack_mode <> 'INSERT') then
399     --
400     -- We must select and lock the current row.
401     --
402     Open  C_Sel1;
403     Fetch C_Sel1 Into g_old_rec;
404     If C_Sel1%notfound then
405       Close C_Sel1;
406       --
407       -- The primary key is invalid therefore we must error
408       --
409       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
410       hr_utility.raise_error;
411     End If;
412     Close C_Sel1;
413     If (p_object_version_number <> g_old_rec.object_version_number) Then
414         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
415         hr_utility.raise_error;
416       End If;
417     hr_utility.set_location(l_proc, 15);
418     --
419     --
420     -- Validate the datetrack mode mode getting the validation start
421     -- and end dates for the specified datetrack operation.
422     --
423     dt_api.validate_dt_mode
424 	(p_effective_date	   => p_effective_date,
425 	 p_datetrack_mode	   => p_datetrack_mode,
426 	 p_base_table_name	   => 'ben_svc_area_rt_f',
427 	 p_base_key_column	   => 'svc_area_rt_id',
428 	 p_base_key_value 	   => p_svc_area_rt_id,
429 	 p_parent_table_name1      => 'ben_vrbl_rt_prfl_f',
430 	 p_parent_key_column1      => 'vrbl_rt_prfl_id',
431 	 p_parent_key_value1       => g_old_rec.vrbl_rt_prfl_id,
432 	 p_parent_table_name2      => 'ben_svc_area_f',
433 	 p_parent_key_column2      => 'svc_area_id',
434 	 p_parent_key_value2       => g_old_rec.svc_area_id,
438   Else
435          p_enforce_foreign_locking => false, --true,
436 	 p_validation_start_date   => l_validation_start_date,
437  	 p_validation_end_date	   => l_validation_end_date);
439     --
440     -- We are doing a datetrack 'INSERT' which is illegal within this
441     -- procedure therefore we must error (note: to lck on insert the
442     -- private procedure ins_lck should be called).
443     --
444     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
445     hr_utility.set_message_token('PROCEDURE', l_proc);
446     hr_utility.set_message_token('STEP','20');
447     hr_utility.raise_error;
448   End If;
449   --
450   -- Set the validation start and end date OUT arguments
451   --
452   p_validation_start_date := l_validation_start_date;
453   p_validation_end_date   := l_validation_end_date;
454   --
455   hr_utility.set_location(' Leaving:'||l_proc, 30);
456 --
457 -- We need to trap the ORA LOCK exception
458 --
459 Exception
460   When HR_Api.Object_Locked then
461     --
462     -- The object is locked therefore we need to supply a meaningful
463     -- error message.
464     --
465     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
466     hr_utility.set_message_token('TABLE_NAME', 'ben_svc_area_rt_f');
467     hr_utility.raise_error;
468   When l_object_invalid then
469     --
470     -- The object doesn't exist or is invalid
471     --
472     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
473     hr_utility.set_message_token('TABLE_NAME', 'ben_svc_area_rt_f');
474     hr_utility.raise_error;
475 End lck;
476 --
477 -- ----------------------------------------------------------------------------
478 -- |-----------------------------< convert_args >-----------------------------|
479 -- ----------------------------------------------------------------------------
480 Function convert_args
481 	(
482 	p_svc_area_rt_id                in number,
483 	p_effective_start_date          in date,
484 	p_effective_end_date            in date,
485 	p_excld_flag                    in varchar2,
486 	p_ordr_num                      in number,
487 	p_svc_area_id                   in number,
488 	p_vrbl_rt_prfl_id               in number,
489 	p_business_group_id             in number,
490 	p_sar_attribute_category        in varchar2,
491 	p_sar_attribute1                in varchar2,
492 	p_sar_attribute2                in varchar2,
493 	p_sar_attribute3                in varchar2,
494 	p_sar_attribute4                in varchar2,
495 	p_sar_attribute5                in varchar2,
496 	p_sar_attribute6                in varchar2,
497 	p_sar_attribute7                in varchar2,
498 	p_sar_attribute8                in varchar2,
499 	p_sar_attribute9                in varchar2,
500 	p_sar_attribute10               in varchar2,
501 	p_sar_attribute11               in varchar2,
502 	p_sar_attribute12               in varchar2,
503 	p_sar_attribute13               in varchar2,
504 	p_sar_attribute14               in varchar2,
505 	p_sar_attribute15               in varchar2,
506 	p_sar_attribute16               in varchar2,
507 	p_sar_attribute17               in varchar2,
508 	p_sar_attribute18               in varchar2,
509 	p_sar_attribute19               in varchar2,
510 	p_sar_attribute20               in varchar2,
511 	p_sar_attribute21               in varchar2,
512 	p_sar_attribute22               in varchar2,
513 	p_sar_attribute23               in varchar2,
514 	p_sar_attribute24               in varchar2,
515 	p_sar_attribute25               in varchar2,
516 	p_sar_attribute26               in varchar2,
517 	p_sar_attribute27               in varchar2,
518 	p_sar_attribute28               in varchar2,
519 	p_sar_attribute29               in varchar2,
520 	p_sar_attribute30               in varchar2,
521 	p_object_version_number         in number
522 	)
523 	Return g_rec_type is
524 --
525   l_rec	  g_rec_type;
526   l_proc  varchar2(72) := g_package||'convert_args';
527 --
528 Begin
529   --
530   hr_utility.set_location('Entering:'||l_proc, 5);
531   --
532   -- Convert arguments into local l_rec structure.
533   --
534   l_rec.svc_area_rt_id                   := p_svc_area_rt_id;
535   l_rec.effective_start_date             := p_effective_start_date;
536   l_rec.effective_end_date               := p_effective_end_date;
537   l_rec.excld_flag                       := p_excld_flag;
538   l_rec.ordr_num                         := p_ordr_num;
539   l_rec.svc_area_id                      := p_svc_area_id;
540   l_rec.vrbl_rt_prfl_id                  := p_vrbl_rt_prfl_id;
541   l_rec.business_group_id                := p_business_group_id;
542   l_rec.sar_attribute_category           := p_sar_attribute_category;
543   l_rec.sar_attribute1                   := p_sar_attribute1;
544   l_rec.sar_attribute2                   := p_sar_attribute2;
545   l_rec.sar_attribute3                   := p_sar_attribute3;
546   l_rec.sar_attribute4                   := p_sar_attribute4;
547   l_rec.sar_attribute5                   := p_sar_attribute5;
548   l_rec.sar_attribute6                   := p_sar_attribute6;
549   l_rec.sar_attribute7                   := p_sar_attribute7;
550   l_rec.sar_attribute8                   := p_sar_attribute8;
551   l_rec.sar_attribute9                   := p_sar_attribute9;
555   l_rec.sar_attribute13                  := p_sar_attribute13;
552   l_rec.sar_attribute10                  := p_sar_attribute10;
553   l_rec.sar_attribute11                  := p_sar_attribute11;
554   l_rec.sar_attribute12                  := p_sar_attribute12;
556   l_rec.sar_attribute14                  := p_sar_attribute14;
557   l_rec.sar_attribute15                  := p_sar_attribute15;
558   l_rec.sar_attribute16                  := p_sar_attribute16;
559   l_rec.sar_attribute17                  := p_sar_attribute17;
560   l_rec.sar_attribute18                  := p_sar_attribute18;
561   l_rec.sar_attribute19                  := p_sar_attribute19;
562   l_rec.sar_attribute20                  := p_sar_attribute20;
563   l_rec.sar_attribute21                  := p_sar_attribute21;
564   l_rec.sar_attribute22                  := p_sar_attribute22;
565   l_rec.sar_attribute23                  := p_sar_attribute23;
566   l_rec.sar_attribute24                  := p_sar_attribute24;
567   l_rec.sar_attribute25                  := p_sar_attribute25;
568   l_rec.sar_attribute26                  := p_sar_attribute26;
569   l_rec.sar_attribute27                  := p_sar_attribute27;
570   l_rec.sar_attribute28                  := p_sar_attribute28;
571   l_rec.sar_attribute29                  := p_sar_attribute29;
572   l_rec.sar_attribute30                  := p_sar_attribute30;
573   l_rec.object_version_number            := p_object_version_number;
574   --
575   -- Return the plsql record structure.
576   --
577   hr_utility.set_location(' Leaving:'||l_proc, 10);
578   Return(l_rec);
579 --
580 End convert_args;
581 --
582 end ben_sar_shd;