DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_WPT_SHD

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ben_wpt_shd as
2 /* $Header: bewptrhi.pkb 120.1 2008/02/05 07:58:41 rtagarra noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_wpt_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_WV_PRTN_RSN_PTIP_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_WV_PRTN_RSN_PTIP_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);
52   --
49     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
50     hr_utility.raise_error;
51   End If;
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_wv_prtn_rsn_ptip_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 	wv_prtn_rsn_ptip_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
74 	ptip_id,
75 	dflt_flag,
76 	wv_prtn_rsn_cd,
77 	wpt_attribute_category,
78 	wpt_attribute1,
79 	wpt_attribute2,
80 	wpt_attribute3,
81 	wpt_attribute4,
82 	wpt_attribute5,
83 	wpt_attribute6,
84 	wpt_attribute7,
85 	wpt_attribute8,
86 	wpt_attribute9,
87 	wpt_attribute10,
88 	wpt_attribute11,
89 	wpt_attribute12,
90 	wpt_attribute13,
91 	wpt_attribute14,
92 	wpt_attribute15,
93 	wpt_attribute16,
94 	wpt_attribute17,
95 	wpt_attribute18,
96 	wpt_attribute19,
97 	wpt_attribute20,
98 	wpt_attribute21,
99 	wpt_attribute22,
100 	wpt_attribute23,
101 	wpt_attribute24,
102 	wpt_attribute25,
103 	wpt_attribute26,
104 	wpt_attribute27,
105 	wpt_attribute28,
106 	wpt_attribute29,
107 	wpt_attribute30,
108 	object_version_number
109     from	ben_wv_prtn_rsn_ptip_f
110     where	wv_prtn_rsn_ptip_id = p_wv_prtn_rsn_ptip_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_wv_prtn_rsn_ptip_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_wv_prtn_rsn_ptip_id = g_old_rec.wv_prtn_rsn_ptip_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         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
149         hr_utility.raise_error;
150       End If;
151       Close C_Sel1;
152       If (p_object_version_number <> g_old_rec.object_version_number) Then
153         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
154         hr_utility.raise_error;
155       End If;
156       hr_utility.set_location(l_proc, 15);
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 -- ----------------------------------------------------------------------------
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.ptip_id
183     from    ben_wv_prtn_rsn_ptip_f t
184     where   t.wv_prtn_rsn_ptip_id = p_base_key_value
185     and     p_effective_date
186     between t.effective_start_date and t.effective_end_date;
187 --
188 Begin
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   Open  C_Sel1;
191   Fetch C_Sel1 Into l_parent_key_value1;
192   If C_Sel1%notfound then
193     Close C_Sel1;
194     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
195     hr_utility.set_message_token('PROCEDURE', l_proc);
196     hr_utility.set_message_token('STEP','10');
197     hr_utility.raise_error;
198   End If;
199   Close C_Sel1;
200   --
201   -- Call the corresponding datetrack api
202   --
203   dt_api.find_dt_del_modes
204 	(p_effective_date	=> p_effective_date,
205 	 p_base_table_name	=> 'ben_wv_prtn_rsn_ptip_f',
206 	 p_base_key_column	=> 'wv_prtn_rsn_ptip_id',
207 	 p_base_key_value	=> p_base_key_value,
208 	 p_parent_table_name1	=> 'ben_ptip_f',
209 	 p_parent_key_column1	=> 'ptip_id',
210 	 p_parent_key_value1	=> l_parent_key_value1,
211 	 p_zap			=> p_zap,
212 	 p_delete		=> p_delete,
213 	 p_future_change	=> p_future_change,
217 End find_dt_del_modes;
214 	 p_delete_next_change	=> p_delete_next_change);
215   --
216   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 --
219 -- ----------------------------------------------------------------------------
220 -- |--------------------------< find_dt_upd_modes >---------------------------|
221 -- ----------------------------------------------------------------------------
222 Procedure find_dt_upd_modes
223 	(p_effective_date	in  date,
224 	 p_base_key_value	in  number,
225 	 p_correction	 out nocopy boolean,
226 	 p_update	 out nocopy boolean,
227 	 p_update_override out nocopy boolean,
228 	 p_update_change_insert out nocopy boolean) is
229 --
230   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
231 --
232 Begin
233   hr_utility.set_location('Entering:'||l_proc, 5);
234   --
235   -- Call the corresponding datetrack api
236   --
237   dt_api.find_dt_upd_modes
238 	(p_effective_date	=> p_effective_date,
239 	 p_base_table_name	=> 'ben_wv_prtn_rsn_ptip_f',
240 	 p_base_key_column	=> 'wv_prtn_rsn_ptip_id',
241 	 p_base_key_value	=> p_base_key_value,
242 	 p_correction		=> p_correction,
243 	 p_update		=> p_update,
244 	 p_update_override	=> p_update_override,
245 	 p_update_change_insert	=> p_update_change_insert);
246   --
247   hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End find_dt_upd_modes;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |------------------------< upd_effective_end_date >------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure upd_effective_end_date
254 	(p_effective_date		in date,
255 	 p_base_key_value		in number,
256 	 p_new_effective_end_date	in date,
257 	 p_validation_start_date	in date,
258 	 p_validation_end_date		in date,
259          p_object_version_number       out nocopy number) is
260 --
261   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
262   l_object_version_number number;
263 --
264 Begin
265   hr_utility.set_location('Entering:'||l_proc, 5);
266   --
267   -- Because we are updating a row we must get the next object
268   -- version number.
269   --
270   l_object_version_number :=
271     dt_api.get_object_version_number
272 	(p_base_table_name	=> 'ben_wv_prtn_rsn_ptip_f',
273 	 p_base_key_column	=> 'wv_prtn_rsn_ptip_id',
274 	 p_base_key_value	=> p_base_key_value);
275   --
276   hr_utility.set_location(l_proc, 10);
277   g_api_dml := true;  -- Set the api dml status
278   --
279   -- Update the specified datetrack row setting the effective
280   -- end date to the specified new effective end date.
281   --
282   update  ben_wv_prtn_rsn_ptip_f t
283   set	  t.effective_end_date	  = p_new_effective_end_date,
284 	  t.object_version_number = l_object_version_number
285   where	  t.wv_prtn_rsn_ptip_id	  = p_base_key_value
286   and	  p_effective_date
287   between t.effective_start_date and t.effective_end_date;
288   --
289   g_api_dml := false;   -- Unset the api dml status
290   p_object_version_number := l_object_version_number;
291   hr_utility.set_location(' Leaving:'||l_proc, 15);
292 --
293 Exception
294   When Others Then
295     g_api_dml := false;   -- Unset the api dml status
296     Raise;
297 End upd_effective_end_date;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |---------------------------------< lck >----------------------------------|
301 -- ----------------------------------------------------------------------------
302 Procedure lck
303 	(p_effective_date	 in  date,
304 	 p_datetrack_mode	 in  varchar2,
305 	 p_wv_prtn_rsn_ptip_id	 in  number,
306 	 p_object_version_number in  number,
307 	 p_validation_start_date out nocopy date,
308 	 p_validation_end_date	 out nocopy date) is
309 --
310   l_proc		  varchar2(72) := g_package||'lck';
311   l_validation_start_date date;
312   l_validation_end_date	  date;
313   l_object_invalid 	  exception;
314   l_argument		  varchar2(30);
315   --
316   -- Cursor C_Sel1 selects the current locked row as of session date
317   -- ensuring that the object version numbers match.
318   --
319   Cursor C_Sel1 is
320     select
321 	wv_prtn_rsn_ptip_id,
322 	effective_start_date,
323 	effective_end_date,
324 	business_group_id,
325 	ptip_id,
326 	dflt_flag,
327 	wv_prtn_rsn_cd,
328 	wpt_attribute_category,
329 	wpt_attribute1,
330 	wpt_attribute2,
331 	wpt_attribute3,
332 	wpt_attribute4,
333 	wpt_attribute5,
334 	wpt_attribute6,
335 	wpt_attribute7,
336 	wpt_attribute8,
337 	wpt_attribute9,
338 	wpt_attribute10,
339 	wpt_attribute11,
340 	wpt_attribute12,
341 	wpt_attribute13,
342 	wpt_attribute14,
343 	wpt_attribute15,
344 	wpt_attribute16,
345 	wpt_attribute17,
346 	wpt_attribute18,
347 	wpt_attribute19,
348 	wpt_attribute20,
349 	wpt_attribute21,
350 	wpt_attribute22,
351 	wpt_attribute23,
352 	wpt_attribute24,
353 	wpt_attribute25,
354 	wpt_attribute26,
355 	wpt_attribute27,
356 	wpt_attribute28,
357 	wpt_attribute29,
358 	wpt_attribute30,
359 	object_version_number
360     from    ben_wv_prtn_rsn_ptip_f
361     where   wv_prtn_rsn_ptip_id         = p_wv_prtn_rsn_ptip_id
362     and	    p_effective_date
363     between effective_start_date and effective_end_date
364     for update nowait;
365   --
366   --
367   --
371   -- Ensure that all the mandatory arguments are not null
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
372   --
373   hr_api.mandatory_arg_error(p_api_name       => l_proc,
374                              p_argument       => 'effective_date',
375                              p_argument_value => p_effective_date);
376   --
377   hr_api.mandatory_arg_error(p_api_name       => l_proc,
378                              p_argument       => 'datetrack_mode',
379                              p_argument_value => p_datetrack_mode);
380   --
381   hr_api.mandatory_arg_error(p_api_name       => l_proc,
382                              p_argument       => 'wv_prtn_rsn_ptip_id',
383                              p_argument_value => p_wv_prtn_rsn_ptip_id);
384   --
385   hr_api.mandatory_arg_error(p_api_name       => l_proc,
386                              p_argument       => 'object_version_number',
387                              p_argument_value => p_object_version_number);
388   --
389   -- Check to ensure the datetrack mode is not INSERT.
390   --
391   If (p_datetrack_mode <> 'INSERT') then
392     --
393     -- We must select and lock the current row.
394     --
395     Open  C_Sel1;
396     Fetch C_Sel1 Into g_old_rec;
397     If C_Sel1%notfound then
398       Close C_Sel1;
399       --
400       -- The primary key is invalid therefore we must error
401       --
402       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
403       hr_utility.raise_error;
404     End If;
405     Close C_Sel1;
406     If (p_object_version_number <> g_old_rec.object_version_number) Then
407         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
408         hr_utility.raise_error;
409       End If;
410     hr_utility.set_location(l_proc, 15);
411     --
412     --
413     -- Validate the datetrack mode mode getting the validation start
414     -- and end dates for the specified datetrack operation.
415     --
416     dt_api.validate_dt_mode
417 	(p_effective_date	   => p_effective_date,
418 	 p_datetrack_mode	   => p_datetrack_mode,
419 	 p_base_table_name	   => 'ben_wv_prtn_rsn_ptip_f',
420 	 p_base_key_column	   => 'wv_prtn_rsn_ptip_id',
421 	 p_base_key_value 	   => p_wv_prtn_rsn_ptip_id,
422 	 p_parent_table_name1      => 'ben_ptip_f',
423 	 p_parent_key_column1      => 'ptip_id',
424 	 p_parent_key_value1       => g_old_rec.ptip_id,
425 	 p_child_table_name1       => 'ben_wv_prtn_rsn_ctfn_ptip_f',
426 	 p_child_key_column1       => 'wv_prtn_rsn_ctfn_ptip_id',
427          p_enforce_foreign_locking => false , --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_wv_prtn_rsn_ptip_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_wv_prtn_rsn_ptip_f');
466     hr_utility.raise_error;
467 End lck;
468 --
469 -- ----------------------------------------------------------------------------
470 -- |-----------------------------< convert_args >-----------------------------|
471 -- ----------------------------------------------------------------------------
472 Function convert_args
473 	(
474 	p_wv_prtn_rsn_ptip_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_ptip_id                       in number,
479 	p_dflt_flag                     in varchar2,
480 	p_wv_prtn_rsn_cd                in varchar2,
481 	p_wpt_attribute_category        in varchar2,
482 	p_wpt_attribute1                in varchar2,
483 	p_wpt_attribute2                in varchar2,
484 	p_wpt_attribute3                in varchar2,
485 	p_wpt_attribute4                in varchar2,
486 	p_wpt_attribute5                in varchar2,
487 	p_wpt_attribute6                in varchar2,
488 	p_wpt_attribute7                in varchar2,
489 	p_wpt_attribute8                in varchar2,
490 	p_wpt_attribute9                in varchar2,
491 	p_wpt_attribute10               in varchar2,
492 	p_wpt_attribute11               in varchar2,
493 	p_wpt_attribute12               in varchar2,
494 	p_wpt_attribute13               in varchar2,
495 	p_wpt_attribute14               in varchar2,
496 	p_wpt_attribute15               in varchar2,
497 	p_wpt_attribute16               in varchar2,
498 	p_wpt_attribute17               in varchar2,
499 	p_wpt_attribute18               in varchar2,
500 	p_wpt_attribute19               in varchar2,
501 	p_wpt_attribute20               in varchar2,
502 	p_wpt_attribute21               in varchar2,
503 	p_wpt_attribute22               in varchar2,
504 	p_wpt_attribute23               in varchar2,
505 	p_wpt_attribute24               in varchar2,
506 	p_wpt_attribute25               in varchar2,
507 	p_wpt_attribute26               in varchar2,
508 	p_wpt_attribute27               in varchar2,
509 	p_wpt_attribute28               in varchar2,
510 	p_wpt_attribute29               in varchar2,
511 	p_wpt_attribute30               in varchar2,
512 	p_object_version_number         in number
513 	)
514 	Return g_rec_type is
515 --
516   l_rec	  g_rec_type;
517   l_proc  varchar2(72) := g_package||'convert_args';
518 --
519 Begin
520   --
521   hr_utility.set_location('Entering:'||l_proc, 5);
522   --
523   -- Convert arguments into local l_rec structure.
524   --
525   l_rec.wv_prtn_rsn_ptip_id              := p_wv_prtn_rsn_ptip_id;
526   l_rec.effective_start_date             := p_effective_start_date;
527   l_rec.effective_end_date               := p_effective_end_date;
528   l_rec.business_group_id                := p_business_group_id;
529   l_rec.ptip_id                          := p_ptip_id;
530   l_rec.dflt_flag                        := p_dflt_flag;
531   l_rec.wv_prtn_rsn_cd                   := p_wv_prtn_rsn_cd;
532   l_rec.wpt_attribute_category           := p_wpt_attribute_category;
533   l_rec.wpt_attribute1                   := p_wpt_attribute1;
534   l_rec.wpt_attribute2                   := p_wpt_attribute2;
535   l_rec.wpt_attribute3                   := p_wpt_attribute3;
536   l_rec.wpt_attribute4                   := p_wpt_attribute4;
537   l_rec.wpt_attribute5                   := p_wpt_attribute5;
538   l_rec.wpt_attribute6                   := p_wpt_attribute6;
539   l_rec.wpt_attribute7                   := p_wpt_attribute7;
540   l_rec.wpt_attribute8                   := p_wpt_attribute8;
541   l_rec.wpt_attribute9                   := p_wpt_attribute9;
542   l_rec.wpt_attribute10                  := p_wpt_attribute10;
543   l_rec.wpt_attribute11                  := p_wpt_attribute11;
544   l_rec.wpt_attribute12                  := p_wpt_attribute12;
545   l_rec.wpt_attribute13                  := p_wpt_attribute13;
546   l_rec.wpt_attribute14                  := p_wpt_attribute14;
547   l_rec.wpt_attribute15                  := p_wpt_attribute15;
548   l_rec.wpt_attribute16                  := p_wpt_attribute16;
549   l_rec.wpt_attribute17                  := p_wpt_attribute17;
550   l_rec.wpt_attribute18                  := p_wpt_attribute18;
551   l_rec.wpt_attribute19                  := p_wpt_attribute19;
552   l_rec.wpt_attribute20                  := p_wpt_attribute20;
553   l_rec.wpt_attribute21                  := p_wpt_attribute21;
554   l_rec.wpt_attribute22                  := p_wpt_attribute22;
555   l_rec.wpt_attribute23                  := p_wpt_attribute23;
556   l_rec.wpt_attribute24                  := p_wpt_attribute24;
557   l_rec.wpt_attribute25                  := p_wpt_attribute25;
558   l_rec.wpt_attribute26                  := p_wpt_attribute26;
559   l_rec.wpt_attribute27                  := p_wpt_attribute27;
560   l_rec.wpt_attribute28                  := p_wpt_attribute28;
561   l_rec.wpt_attribute29                  := p_wpt_attribute29;
562   l_rec.wpt_attribute30                  := p_wpt_attribute30;
563   l_rec.object_version_number            := p_object_version_number;
564   --
565   -- Return the plsql record structure.
566   --
567   hr_utility.set_location(' Leaving:'||l_proc, 10);
568   Return(l_rec);
569 --
570 End convert_args;
571 --
572 end ben_wpt_shd;