DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_SAZ_SHD

Source


1 Package Body ben_saz_shd as
2 /* $Header: besazrhi.pkb 120.0.12010000.2 2008/08/05 15:27:12 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_saz_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_PSTL_ZIP_RNG_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_svc_area_pstl_zip_rng_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 	svc_area_pstl_zip_rng_id,
66 	effective_start_date,
67 	effective_end_date,
68 	svc_area_id,
69 	pstl_zip_rng_id,
70 	business_group_id,
71 	saz_attribute_category,
72 	saz_attribute1,
73 	saz_attribute2,
74 	saz_attribute3,
75 	saz_attribute4,
76 	saz_attribute5,
77 	saz_attribute6,
78 	saz_attribute7,
79 	saz_attribute8,
80 	saz_attribute9,
81 	saz_attribute10,
82 	saz_attribute11,
83 	saz_attribute12,
84 	saz_attribute13,
85 	saz_attribute14,
86 	saz_attribute15,
87 	saz_attribute16,
88 	saz_attribute17,
89 	saz_attribute18,
90 	saz_attribute19,
91 	saz_attribute20,
92 	saz_attribute21,
93 	saz_attribute22,
94 	saz_attribute23,
95 	saz_attribute24,
96 	saz_attribute25,
97 	saz_attribute26,
98 	saz_attribute27,
99 	saz_attribute28,
100 	saz_attribute29,
101 	saz_attribute30,
102 	object_version_number
103     from	ben_svc_area_pstl_zip_rng_f
104     where	svc_area_pstl_zip_rng_id = p_svc_area_pstl_zip_rng_id
105     and		p_effective_date
106     between	effective_start_date and effective_end_date;
107 --
108   l_proc	varchar2(72)	:= g_package||'api_updating';
109   l_fct_ret	boolean;
110 --
111 Begin
112   hr_utility.set_location('Entering:'||l_proc, 5);
113   --
114   If (p_effective_date is null or
115       p_svc_area_pstl_zip_rng_id is null or
116       p_object_version_number is null) Then
117     --
118     -- One of the primary key arguments is null therefore we must
119     -- set the returning function value to false
120     --
121     l_fct_ret := false;
122   Else
123     If (p_svc_area_pstl_zip_rng_id = g_old_rec.svc_area_pstl_zip_rng_id and
124         p_object_version_number = g_old_rec.object_version_number) Then
125       hr_utility.set_location(l_proc, 10);
126       --
127       -- The g_old_rec is current therefore we must
128       -- set the returning function to true
129       --
130       l_fct_ret := true;
131     Else
132       --
133       -- Select the current row
134       --
135       Open C_Sel1;
136       Fetch C_Sel1 Into g_old_rec;
137       If C_Sel1%notfound Then
138         Close C_Sel1;
139         --
140         -- The primary key is invalid therefore we must error
141         --
142         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
143         hr_utility.raise_error;
144       End If;
145       Close C_Sel1;
146       If (p_object_version_number <> g_old_rec.object_version_number) Then
147         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
148         hr_utility.raise_error;
149       End If;
150       hr_utility.set_location(l_proc, 15);
151       l_fct_ret := true;
152     End If;
153   End If;
154   hr_utility.set_location(' Leaving:'||l_proc, 20);
155   Return (l_fct_ret);
156 --
157 End api_updating;
158 --
159 -- ----------------------------------------------------------------------------
160 -- |--------------------------< find_dt_del_modes >---------------------------|
161 -- ----------------------------------------------------------------------------
162 Procedure find_dt_del_modes
163 	(p_effective_date	in  date,
164 	 p_base_key_value	in  number,
165 	 p_zap		 out nocopy boolean,
166 	 p_delete	 out nocopy boolean,
167 	 p_future_change out nocopy boolean,
168 	 p_delete_next_change out nocopy boolean) is
169 --
170   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
171 --
172   l_parent_key_value1	number;
173   l_parent_key_value2	number;
174   --
175   Cursor C_Sel1 Is
176     select  t.pstl_zip_rng_id,
177 	    t.svc_area_id
178     from    ben_svc_area_pstl_zip_rng_f t
179     where   t.svc_area_pstl_zip_rng_id = p_base_key_value
180     and     p_effective_date
181     between t.effective_start_date and t.effective_end_date;
182 --
183 Begin
184   hr_utility.set_location('Entering:'||l_proc, 5);
185   Open  C_Sel1;
186   Fetch C_Sel1 Into l_parent_key_value1,
187 		    l_parent_key_value2;
188   If C_Sel1%notfound then
189     Close C_Sel1;
190     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
191     hr_utility.set_message_token('PROCEDURE', l_proc);
192     hr_utility.set_message_token('STEP','10');
193     hr_utility.raise_error;
194   End If;
195   Close C_Sel1;
196   --
197   -- Call the corresponding datetrack api
198   --
199   dt_api.find_dt_del_modes
200 	(p_effective_date	=> p_effective_date,
201 	 p_base_table_name	=> 'ben_svc_area_pstl_zip_rng_f',
202 	 p_base_key_column	=> 'svc_area_pstl_zip_rng_id',
203 	 p_base_key_value	=> p_base_key_value,
204 	 p_parent_table_name1	=> 'ben_pstl_zip_rng_f',
205 	 p_parent_key_column1	=> 'pstl_zip_rng_id',
206 	 p_parent_key_value1	=> l_parent_key_value1,
207 	 p_parent_table_name2	=> 'ben_svc_area_f',
208 	 p_parent_key_column2	=> 'svc_area_id',
209 	 p_parent_key_value2	=> l_parent_key_value2,
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_svc_area_pstl_zip_rng_f',
239 	 p_base_key_column	=> 'svc_area_pstl_zip_rng_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_svc_area_pstl_zip_rng_f',
272 	 p_base_key_column	=> 'svc_area_pstl_zip_rng_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_svc_area_pstl_zip_rng_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.svc_area_pstl_zip_rng_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 >----------------------------------|
300 -- ----------------------------------------------------------------------------
301 Procedure lck
302 	(p_effective_date	 in  date,
303 	 p_datetrack_mode	 in  varchar2,
304 	 p_svc_area_pstl_zip_rng_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 	svc_area_pstl_zip_rng_id,
321 	effective_start_date,
322 	effective_end_date,
323 	svc_area_id,
324 	pstl_zip_rng_id,
325 	business_group_id,
326 	saz_attribute_category,
327 	saz_attribute1,
328 	saz_attribute2,
329 	saz_attribute3,
330 	saz_attribute4,
331 	saz_attribute5,
332 	saz_attribute6,
333 	saz_attribute7,
334 	saz_attribute8,
335 	saz_attribute9,
336 	saz_attribute10,
337 	saz_attribute11,
338 	saz_attribute12,
339 	saz_attribute13,
340 	saz_attribute14,
341 	saz_attribute15,
342 	saz_attribute16,
343 	saz_attribute17,
344 	saz_attribute18,
345 	saz_attribute19,
346 	saz_attribute20,
347 	saz_attribute21,
348 	saz_attribute22,
349 	saz_attribute23,
350 	saz_attribute24,
351 	saz_attribute25,
352 	saz_attribute26,
353 	saz_attribute27,
354 	saz_attribute28,
355 	saz_attribute29,
356 	saz_attribute30,
357 	object_version_number
358     from    ben_svc_area_pstl_zip_rng_f
359     where   svc_area_pstl_zip_rng_id         = p_svc_area_pstl_zip_rng_id
360     and	    p_effective_date
361     between effective_start_date and effective_end_date
362     for update nowait;
363   --
364   --
365   --
366 Begin
367   hr_utility.set_location('Entering:'||l_proc, 5);
368   --
369   -- Ensure that all the mandatory arguments are not null
370   --
371   hr_api.mandatory_arg_error(p_api_name       => l_proc,
372                              p_argument       => 'effective_date',
373                              p_argument_value => p_effective_date);
374   --
375   hr_api.mandatory_arg_error(p_api_name       => l_proc,
376                              p_argument       => 'datetrack_mode',
377                              p_argument_value => p_datetrack_mode);
378   --
379   hr_api.mandatory_arg_error(p_api_name       => l_proc,
380                              p_argument       => 'svc_area_pstl_zip_rng_id',
381                              p_argument_value => p_svc_area_pstl_zip_rng_id);
382   --
383   hr_api.mandatory_arg_error(p_api_name       => l_proc,
384                              p_argument       => 'object_version_number',
385                              p_argument_value => p_object_version_number);
386   --
387   -- Check to ensure the datetrack mode is not INSERT.
388   --
389   If (p_datetrack_mode <> 'INSERT') then
390     --
391     -- We must select and lock the current row.
392     --
393     Open  C_Sel1;
394     Fetch C_Sel1 Into g_old_rec;
395     If C_Sel1%notfound then
396       Close C_Sel1;
397       --
398       -- The primary key is invalid therefore we must error
399       --
400       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
401       hr_utility.raise_error;
402     End If;
403     Close C_Sel1;
404     If (p_object_version_number <> g_old_rec.object_version_number) Then
405         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
406         hr_utility.raise_error;
407       End If;
408     hr_utility.set_location(l_proc, 15);
409     --
410     --
411     -- Validate the datetrack mode mode getting the validation start
412     -- and end dates for the specified datetrack operation.
413     --
414     dt_api.validate_dt_mode
415 	(p_effective_date	   => p_effective_date,
416 	 p_datetrack_mode	   => p_datetrack_mode,
417 	 p_base_table_name	   => 'ben_svc_area_pstl_zip_rng_f',
418 	 p_base_key_column	   => 'svc_area_pstl_zip_rng_id',
419 	 p_base_key_value 	   => p_svc_area_pstl_zip_rng_id,
420 	 p_parent_table_name1      => 'ben_pstl_zip_rng_f',
421 	 p_parent_key_column1      => 'pstl_zip_rng_id',
422 	 p_parent_key_value1       => g_old_rec.pstl_zip_rng_id,
423 	 p_parent_table_name2      => 'ben_svc_area_f',
424 	 p_parent_key_column2      => 'svc_area_id',
428  	 p_validation_end_date	   => l_validation_end_date);
425 	 p_parent_key_value2       => g_old_rec.svc_area_id,
426          p_enforce_foreign_locking => false , --true,
427 	 p_validation_start_date   => l_validation_start_date,
429   Else
430     --
431     -- We are doing a datetrack 'INSERT' which is illegal within this
432     -- procedure therefore we must error (note: to lck on insert the
433     -- private procedure ins_lck should be called).
434     --
435     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
436     hr_utility.set_message_token('PROCEDURE', l_proc);
437     hr_utility.set_message_token('STEP','20');
438     hr_utility.raise_error;
439   End If;
440   --
441   -- Set the validation start and end date OUT arguments
442   --
443   p_validation_start_date := l_validation_start_date;
444   p_validation_end_date   := l_validation_end_date;
445   --
446   hr_utility.set_location(' Leaving:'||l_proc, 30);
447 --
448 -- We need to trap the ORA LOCK exception
449 --
450 Exception
451   When HR_Api.Object_Locked then
452     --
453     -- The object is locked therefore we need to supply a meaningful
454     -- error message.
455     --
456     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
457     hr_utility.set_message_token('TABLE_NAME', 'ben_svc_area_pstl_zip_rng_f');
458     hr_utility.raise_error;
459   When l_object_invalid then
460     --
461     -- The object doesn't exist or is invalid
462     --
463     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
464     hr_utility.set_message_token('TABLE_NAME', 'ben_svc_area_pstl_zip_rng_f');
465     hr_utility.raise_error;
466 End lck;
467 --
468 -- ----------------------------------------------------------------------------
469 -- |-----------------------------< convert_args >-----------------------------|
470 -- ----------------------------------------------------------------------------
471 Function convert_args
472 	(
473 	p_svc_area_pstl_zip_rng_id      in number,
474 	p_effective_start_date          in date,
475 	p_effective_end_date            in date,
476 	p_svc_area_id                   in number,
477 	p_pstl_zip_rng_id               in number,
478 	p_business_group_id             in number,
479 	p_saz_attribute_category        in varchar2,
480 	p_saz_attribute1                in varchar2,
481 	p_saz_attribute2                in varchar2,
482 	p_saz_attribute3                in varchar2,
483 	p_saz_attribute4                in varchar2,
484 	p_saz_attribute5                in varchar2,
485 	p_saz_attribute6                in varchar2,
486 	p_saz_attribute7                in varchar2,
487 	p_saz_attribute8                in varchar2,
488 	p_saz_attribute9                in varchar2,
489 	p_saz_attribute10               in varchar2,
490 	p_saz_attribute11               in varchar2,
491 	p_saz_attribute12               in varchar2,
492 	p_saz_attribute13               in varchar2,
493 	p_saz_attribute14               in varchar2,
494 	p_saz_attribute15               in varchar2,
495 	p_saz_attribute16               in varchar2,
496 	p_saz_attribute17               in varchar2,
497 	p_saz_attribute18               in varchar2,
498 	p_saz_attribute19               in varchar2,
499 	p_saz_attribute20               in varchar2,
500 	p_saz_attribute21               in varchar2,
501 	p_saz_attribute22               in varchar2,
502 	p_saz_attribute23               in varchar2,
503 	p_saz_attribute24               in varchar2,
504 	p_saz_attribute25               in varchar2,
505 	p_saz_attribute26               in varchar2,
506 	p_saz_attribute27               in varchar2,
507 	p_saz_attribute28               in varchar2,
508 	p_saz_attribute29               in varchar2,
509 	p_saz_attribute30               in varchar2,
510 	p_object_version_number         in number
511 	)
512 	Return g_rec_type is
513 --
514   l_rec	  g_rec_type;
515   l_proc  varchar2(72) := g_package||'convert_args';
516 --
517 Begin
518   --
519   hr_utility.set_location('Entering:'||l_proc, 5);
520   --
521   -- Convert arguments into local l_rec structure.
522   --
523   l_rec.svc_area_pstl_zip_rng_id         := p_svc_area_pstl_zip_rng_id;
524   l_rec.effective_start_date             := p_effective_start_date;
525   l_rec.effective_end_date               := p_effective_end_date;
526   l_rec.svc_area_id                      := p_svc_area_id;
527   l_rec.pstl_zip_rng_id                  := p_pstl_zip_rng_id;
528   l_rec.business_group_id                := p_business_group_id;
529   l_rec.saz_attribute_category           := p_saz_attribute_category;
530   l_rec.saz_attribute1                   := p_saz_attribute1;
531   l_rec.saz_attribute2                   := p_saz_attribute2;
532   l_rec.saz_attribute3                   := p_saz_attribute3;
533   l_rec.saz_attribute4                   := p_saz_attribute4;
534   l_rec.saz_attribute5                   := p_saz_attribute5;
535   l_rec.saz_attribute6                   := p_saz_attribute6;
536   l_rec.saz_attribute7                   := p_saz_attribute7;
537   l_rec.saz_attribute8                   := p_saz_attribute8;
538   l_rec.saz_attribute9                   := p_saz_attribute9;
539   l_rec.saz_attribute10                  := p_saz_attribute10;
540   l_rec.saz_attribute11                  := p_saz_attribute11;
541   l_rec.saz_attribute12                  := p_saz_attribute12;
542   l_rec.saz_attribute13                  := p_saz_attribute13;
543   l_rec.saz_attribute14                  := p_saz_attribute14;
544   l_rec.saz_attribute15                  := p_saz_attribute15;
545   l_rec.saz_attribute16                  := p_saz_attribute16;
546   l_rec.saz_attribute17                  := p_saz_attribute17;
547   l_rec.saz_attribute18                  := p_saz_attribute18;
548   l_rec.saz_attribute19                  := p_saz_attribute19;
549   l_rec.saz_attribute20                  := p_saz_attribute20;
550   l_rec.saz_attribute21                  := p_saz_attribute21;
551   l_rec.saz_attribute22                  := p_saz_attribute22;
552   l_rec.saz_attribute23                  := p_saz_attribute23;
553   l_rec.saz_attribute24                  := p_saz_attribute24;
554   l_rec.saz_attribute25                  := p_saz_attribute25;
555   l_rec.saz_attribute26                  := p_saz_attribute26;
556   l_rec.saz_attribute27                  := p_saz_attribute27;
557   l_rec.saz_attribute28                  := p_saz_attribute28;
558   l_rec.saz_attribute29                  := p_saz_attribute29;
559   l_rec.saz_attribute30                  := p_saz_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_saz_shd;