DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ETW_SHD

Source


1 Package Body ben_etw_shd as
2 /* $Header: beetwrhi.pkb 120.0 2005/05/28 03:04:05 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_etw_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_ELIG_PER_WV_PL_TYP_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_elig_per_wv_pl_typ_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 	elig_per_wv_pl_typ_id,
66 	effective_start_date,
67 	effective_end_date,
68 	pl_typ_id,
69 	elig_per_id,
70 	wv_cftn_typ_cd,
71 	wv_prtn_rsn_cd,
72 	wvd_flag,
73 	business_group_id,
74 	etw_attribute_category,
75 	etw_attribute1,
76 	etw_attribute2,
77 	etw_attribute3,
78 	etw_attribute4,
79 	etw_attribute5,
80 	etw_attribute6,
81 	etw_attribute7,
82 	etw_attribute8,
83 	etw_attribute9,
84 	etw_attribute10,
85 	etw_attribute11,
86 	etw_attribute12,
87 	etw_attribute13,
88 	etw_attribute14,
89 	etw_attribute15,
90 	etw_attribute16,
91 	etw_attribute17,
92 	etw_attribute18,
93 	etw_attribute19,
94 	etw_attribute20,
95 	etw_attribute21,
96 	etw_attribute22,
97 	etw_attribute23,
98 	etw_attribute24,
99 	etw_attribute25,
100 	etw_attribute26,
101 	etw_attribute27,
102 	etw_attribute28,
103 	etw_attribute29,
104 	etw_attribute30,
105 	object_version_number
106     from	ben_elig_per_wv_pl_typ_f
107     where	elig_per_wv_pl_typ_id = p_elig_per_wv_pl_typ_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_elig_per_wv_pl_typ_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_elig_per_wv_pl_typ_id = g_old_rec.elig_per_wv_pl_typ_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   l_parent_key_value2	number;
177   --
178   Cursor C_Sel1 Is
179     select  t.elig_per_id,
180 	    t.pl_typ_id
181     from    ben_elig_per_wv_pl_typ_f t
182     where   t.elig_per_wv_pl_typ_id = p_base_key_value
183     and     p_effective_date
184     between t.effective_start_date and t.effective_end_date;
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   Open  C_Sel1;
189   Fetch C_Sel1 Into l_parent_key_value1,
190 		    l_parent_key_value2;
191   If C_Sel1%notfound then
192     Close C_Sel1;
193     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
194     hr_utility.set_message_token('PROCEDURE', l_proc);
195     hr_utility.set_message_token('STEP','10');
196     hr_utility.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_elig_per_wv_pl_typ_f',
205 	 p_base_key_column	=> 'elig_per_wv_pl_typ_id',
206 	 p_base_key_value	=> p_base_key_value,
207 	 p_parent_table_name1	=> 'ben_elig_per_f',
208 	 p_parent_key_column1	=> 'elig_per_id',
209 	 p_parent_key_value1	=> l_parent_key_value1,
210 	 p_parent_table_name2	=> 'ben_pl_typ_f',
211 	 p_parent_key_column2	=> 'pl_typ_id',
212 	 p_parent_key_value2	=> l_parent_key_value2,
213 	 p_zap			=> p_zap,
214 	 p_delete		=> p_delete,
215 	 p_future_change	=> p_future_change,
216 	 p_delete_next_change	=> p_delete_next_change);
217   --
218   hr_utility.set_location(' Leaving:'||l_proc, 10);
219 End find_dt_del_modes;
220 --
221 -- ----------------------------------------------------------------------------
222 -- |--------------------------< find_dt_upd_modes >---------------------------|
223 -- ----------------------------------------------------------------------------
224 Procedure find_dt_upd_modes
225 	(p_effective_date	in  date,
226 	 p_base_key_value	in  number,
227 	 p_correction	 out nocopy boolean,
228 	 p_update	 out nocopy boolean,
229 	 p_update_override out nocopy boolean,
230 	 p_update_change_insert out nocopy boolean) is
231 --
232   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
233 --
234 Begin
235   hr_utility.set_location('Entering:'||l_proc, 5);
236   --
237   -- Call the corresponding datetrack api
238   --
239   dt_api.find_dt_upd_modes
240 	(p_effective_date	=> p_effective_date,
241 	 p_base_table_name	=> 'ben_elig_per_wv_pl_typ_f',
242 	 p_base_key_column	=> 'elig_per_wv_pl_typ_id',
243 	 p_base_key_value	=> p_base_key_value,
244 	 p_correction		=> p_correction,
245 	 p_update		=> p_update,
246 	 p_update_override	=> p_update_override,
247 	 p_update_change_insert	=> p_update_change_insert);
248   --
249   hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End find_dt_upd_modes;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |------------------------< upd_effective_end_date >------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure upd_effective_end_date
256 	(p_effective_date		in date,
257 	 p_base_key_value		in number,
258 	 p_new_effective_end_date	in date,
259 	 p_validation_start_date	in date,
260 	 p_validation_end_date		in date,
261          p_object_version_number       out nocopy number) is
262 --
263   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
264   l_object_version_number number;
265 --
266 Begin
267   hr_utility.set_location('Entering:'||l_proc, 5);
268   --
269   -- Because we are updating a row we must get the next object
270   -- version number.
271   --
272   l_object_version_number :=
273     dt_api.get_object_version_number
274 	(p_base_table_name	=> 'ben_elig_per_wv_pl_typ_f',
275 	 p_base_key_column	=> 'elig_per_wv_pl_typ_id',
276 	 p_base_key_value	=> p_base_key_value);
277   --
278   hr_utility.set_location(l_proc, 10);
279   g_api_dml := true;  -- Set the api dml status
280   --
281   -- Update the specified datetrack row setting the effective
282   -- end date to the specified new effective end date.
283   --
284   update  ben_elig_per_wv_pl_typ_f t
285   set	  t.effective_end_date	  = p_new_effective_end_date,
286 	  t.object_version_number = l_object_version_number
287   where	  t.elig_per_wv_pl_typ_id	  = p_base_key_value
288   and	  p_effective_date
289   between t.effective_start_date and t.effective_end_date;
290   --
291   g_api_dml := false;   -- Unset the api dml status
292   p_object_version_number := l_object_version_number;
293   hr_utility.set_location(' Leaving:'||l_proc, 15);
294 --
295 Exception
296   When Others Then
297     g_api_dml := false;   -- Unset the api dml status
298     Raise;
299 End upd_effective_end_date;
300 --
301 -- ----------------------------------------------------------------------------
302 -- |---------------------------------< lck >----------------------------------|
303 -- ----------------------------------------------------------------------------
304 Procedure lck
305 	(p_effective_date	 in  date,
306 	 p_datetrack_mode	 in  varchar2,
307 	 p_elig_per_wv_pl_typ_id	 in  number,
308 	 p_object_version_number in  number,
309 	 p_validation_start_date out nocopy date,
310 	 p_validation_end_date	 out nocopy date) is
311 --
312   l_proc		  varchar2(72) := g_package||'lck';
313   l_validation_start_date date;
314   l_validation_end_date	  date;
315   l_object_invalid 	  exception;
316   l_argument		  varchar2(30);
317   --
318   -- Cursor C_Sel1 selects the current locked row as of session date
319   -- ensuring that the object version numbers match.
320   --
321   Cursor C_Sel1 is
322     select
323 	elig_per_wv_pl_typ_id,
324 	effective_start_date,
325 	effective_end_date,
326 	pl_typ_id,
327 	elig_per_id,
328 	wv_cftn_typ_cd,
329 	wv_prtn_rsn_cd,
330 	wvd_flag,
331 	business_group_id,
332 	etw_attribute_category,
333 	etw_attribute1,
334 	etw_attribute2,
335 	etw_attribute3,
336 	etw_attribute4,
337 	etw_attribute5,
338 	etw_attribute6,
339 	etw_attribute7,
340 	etw_attribute8,
341 	etw_attribute9,
342 	etw_attribute10,
343 	etw_attribute11,
344 	etw_attribute12,
345 	etw_attribute13,
346 	etw_attribute14,
347 	etw_attribute15,
348 	etw_attribute16,
349 	etw_attribute17,
350 	etw_attribute18,
351 	etw_attribute19,
352 	etw_attribute20,
353 	etw_attribute21,
354 	etw_attribute22,
355 	etw_attribute23,
356 	etw_attribute24,
357 	etw_attribute25,
358 	etw_attribute26,
359 	etw_attribute27,
360 	etw_attribute28,
361 	etw_attribute29,
362 	etw_attribute30,
363 	object_version_number
364     from    ben_elig_per_wv_pl_typ_f
365     where   elig_per_wv_pl_typ_id         = p_elig_per_wv_pl_typ_id
366     and	    p_effective_date
367     between effective_start_date and effective_end_date
368     for update nowait;
369   --
370   --
371   --
372 Begin
373   hr_utility.set_location('Entering:'||l_proc, 5);
374   --
375   -- Ensure that all the mandatory arguments are not null
376   --
377   hr_api.mandatory_arg_error(p_api_name       => l_proc,
378                              p_argument       => 'effective_date',
379                              p_argument_value => p_effective_date);
380   --
381   hr_api.mandatory_arg_error(p_api_name       => l_proc,
382                              p_argument       => 'datetrack_mode',
383                              p_argument_value => p_datetrack_mode);
384   --
385   hr_api.mandatory_arg_error(p_api_name       => l_proc,
386                              p_argument       => 'elig_per_wv_pl_typ_id',
387                              p_argument_value => p_elig_per_wv_pl_typ_id);
388   --
389   hr_api.mandatory_arg_error(p_api_name       => l_proc,
390                              p_argument       => 'object_version_number',
391                              p_argument_value => p_object_version_number);
392   --
393   -- Check to ensure the datetrack mode is not INSERT.
394   --
395   If (p_datetrack_mode <> 'INSERT') then
396     --
400     Fetch C_Sel1 Into g_old_rec;
397     -- We must select and lock the current row.
398     --
399     Open  C_Sel1;
401     If C_Sel1%notfound then
402       Close C_Sel1;
403       --
404       -- The primary key is invalid therefore we must error
405       --
406       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
407       hr_utility.raise_error;
408     End If;
409     Close C_Sel1;
410     If (p_object_version_number <> g_old_rec.object_version_number) Then
411         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
412         hr_utility.raise_error;
413       End If;
414     hr_utility.set_location(l_proc, 15);
415     --
416     --
417     -- Validate the datetrack mode mode getting the validation start
418     -- and end dates for the specified datetrack operation.
419     --
420     dt_api.validate_dt_mode
421 	(p_effective_date	   => p_effective_date,
422 	 p_datetrack_mode	   => p_datetrack_mode,
423 	 p_base_table_name	   => 'ben_elig_per_wv_pl_typ_f',
424 	 p_base_key_column	   => 'elig_per_wv_pl_typ_id',
425 	 p_base_key_value 	   => p_elig_per_wv_pl_typ_id,
426 	 p_parent_table_name1      => 'ben_elig_per_f',
427 	 p_parent_key_column1      => 'elig_per_id',
428 	 p_parent_key_value1       => g_old_rec.elig_per_id,
429 	 p_parent_table_name2      => 'ben_pl_typ_f',
430 	 p_parent_key_column2      => 'pl_typ_id',
431 	 p_parent_key_value2       => g_old_rec.pl_typ_id,
432          p_enforce_foreign_locking => true,
433 	 p_validation_start_date   => l_validation_start_date,
434  	 p_validation_end_date	   => l_validation_end_date);
435   Else
436     --
437     -- We are doing a datetrack 'INSERT' which is illegal within this
438     -- procedure therefore we must error (note: to lck on insert the
439     -- private procedure ins_lck should be called).
440     --
441     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
442     hr_utility.set_message_token('PROCEDURE', l_proc);
443     hr_utility.set_message_token('STEP','20');
444     hr_utility.raise_error;
445   End If;
446   --
447   -- Set the validation start and end date OUT arguments
448   --
449   p_validation_start_date := l_validation_start_date;
450   p_validation_end_date   := l_validation_end_date;
451   --
452   hr_utility.set_location(' Leaving:'||l_proc, 30);
453 --
454 -- We need to trap the ORA LOCK exception
455 --
456 Exception
457   When HR_Api.Object_Locked then
458     --
459     -- The object is locked therefore we need to supply a meaningful
460     -- error message.
461     --
462     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
463     hr_utility.set_message_token('TABLE_NAME', 'ben_elig_per_wv_pl_typ_f');
464     hr_utility.raise_error;
465   When l_object_invalid then
466     --
467     -- The object doesn't exist or is invalid
468     --
469     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
470     hr_utility.set_message_token('TABLE_NAME', 'ben_elig_per_wv_pl_typ_f');
471     hr_utility.raise_error;
472 End lck;
473 --
474 -- ----------------------------------------------------------------------------
475 -- |-----------------------------< convert_args >-----------------------------|
476 -- ----------------------------------------------------------------------------
477 Function convert_args
478 	(
479 	p_elig_per_wv_pl_typ_id         in number,
480 	p_effective_start_date          in date,
481 	p_effective_end_date            in date,
482 	p_pl_typ_id                     in number,
483 	p_elig_per_id                   in number,
484 	p_wv_cftn_typ_cd                in varchar2,
485 	p_wv_prtn_rsn_cd                in varchar2,
486 	p_wvd_flag                      in varchar2,
487 	p_business_group_id             in number,
488 	p_etw_attribute_category        in varchar2,
489 	p_etw_attribute1                in varchar2,
490 	p_etw_attribute2                in varchar2,
491 	p_etw_attribute3                in varchar2,
492 	p_etw_attribute4                in varchar2,
493 	p_etw_attribute5                in varchar2,
494 	p_etw_attribute6                in varchar2,
495 	p_etw_attribute7                in varchar2,
496 	p_etw_attribute8                in varchar2,
497 	p_etw_attribute9                in varchar2,
498 	p_etw_attribute10               in varchar2,
499 	p_etw_attribute11               in varchar2,
500 	p_etw_attribute12               in varchar2,
501 	p_etw_attribute13               in varchar2,
502 	p_etw_attribute14               in varchar2,
503 	p_etw_attribute15               in varchar2,
504 	p_etw_attribute16               in varchar2,
505 	p_etw_attribute17               in varchar2,
506 	p_etw_attribute18               in varchar2,
507 	p_etw_attribute19               in varchar2,
508 	p_etw_attribute20               in varchar2,
509 	p_etw_attribute21               in varchar2,
510 	p_etw_attribute22               in varchar2,
511 	p_etw_attribute23               in varchar2,
512 	p_etw_attribute24               in varchar2,
513 	p_etw_attribute25               in varchar2,
514 	p_etw_attribute26               in varchar2,
515 	p_etw_attribute27               in varchar2,
516 	p_etw_attribute28               in varchar2,
517 	p_etw_attribute29               in varchar2,
518 	p_etw_attribute30               in varchar2,
519 	p_object_version_number         in number
520 	)
521 	Return g_rec_type is
522 --
523   l_rec	  g_rec_type;
524   l_proc  varchar2(72) := g_package||'convert_args';
525 --
526 Begin
527   --
528   hr_utility.set_location('Entering:'||l_proc, 5);
529   --
530   -- Convert arguments into local l_rec structure.
531   --
532   l_rec.elig_per_wv_pl_typ_id            := p_elig_per_wv_pl_typ_id;
533   l_rec.effective_start_date             := p_effective_start_date;
534   l_rec.effective_end_date               := p_effective_end_date;
535   l_rec.pl_typ_id                        := p_pl_typ_id;
536   l_rec.elig_per_id                      := p_elig_per_id;
537   l_rec.wv_cftn_typ_cd                   := p_wv_cftn_typ_cd;
538   l_rec.wv_prtn_rsn_cd                   := p_wv_prtn_rsn_cd;
539   l_rec.wvd_flag                         := p_wvd_flag;
540   l_rec.business_group_id                := p_business_group_id;
541   l_rec.etw_attribute_category           := p_etw_attribute_category;
542   l_rec.etw_attribute1                   := p_etw_attribute1;
543   l_rec.etw_attribute2                   := p_etw_attribute2;
544   l_rec.etw_attribute3                   := p_etw_attribute3;
545   l_rec.etw_attribute4                   := p_etw_attribute4;
546   l_rec.etw_attribute5                   := p_etw_attribute5;
547   l_rec.etw_attribute6                   := p_etw_attribute6;
548   l_rec.etw_attribute7                   := p_etw_attribute7;
549   l_rec.etw_attribute8                   := p_etw_attribute8;
550   l_rec.etw_attribute9                   := p_etw_attribute9;
551   l_rec.etw_attribute10                  := p_etw_attribute10;
552   l_rec.etw_attribute11                  := p_etw_attribute11;
553   l_rec.etw_attribute12                  := p_etw_attribute12;
554   l_rec.etw_attribute13                  := p_etw_attribute13;
555   l_rec.etw_attribute14                  := p_etw_attribute14;
556   l_rec.etw_attribute15                  := p_etw_attribute15;
557   l_rec.etw_attribute16                  := p_etw_attribute16;
558   l_rec.etw_attribute17                  := p_etw_attribute17;
559   l_rec.etw_attribute18                  := p_etw_attribute18;
560   l_rec.etw_attribute19                  := p_etw_attribute19;
561   l_rec.etw_attribute20                  := p_etw_attribute20;
562   l_rec.etw_attribute21                  := p_etw_attribute21;
563   l_rec.etw_attribute22                  := p_etw_attribute22;
564   l_rec.etw_attribute23                  := p_etw_attribute23;
565   l_rec.etw_attribute24                  := p_etw_attribute24;
566   l_rec.etw_attribute25                  := p_etw_attribute25;
567   l_rec.etw_attribute26                  := p_etw_attribute26;
568   l_rec.etw_attribute27                  := p_etw_attribute27;
569   l_rec.etw_attribute28                  := p_etw_attribute28;
570   l_rec.etw_attribute29                  := p_etw_attribute29;
571   l_rec.etw_attribute30                  := p_etw_attribute30;
572   l_rec.object_version_number            := p_object_version_number;
573   --
574   -- Return the plsql record structure.
575   --
576   hr_utility.set_location(' Leaving:'||l_proc, 10);
577   Return(l_rec);
578 --
579 End convert_args;
580 --
581 end ben_etw_shd;