DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PAT_SHD

Source


1 Package Body ben_pat_shd as
2 /* $Header: bepatrhi.pkb 120.1 2007/03/28 15:49:02 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pat_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_POPL_ACTN_TYP_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_popl_actn_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 	popl_actn_typ_id,
66 	effective_start_date,
67 	effective_end_date,
68 	actn_typ_due_dt_cd,
69 	actn_typ_due_dt_rl,
70 	actn_typ_id,
71 	pgm_id,
72 	pl_id,
73 	business_group_id,
74 	pat_attribute_category,
75 	pat_attribute1,
76 	pat_attribute2,
77 	pat_attribute3,
78 	pat_attribute4,
79 	pat_attribute5,
80 	pat_attribute6,
81 	pat_attribute7,
82 	pat_attribute8,
83 	pat_attribute9,
84 	pat_attribute10,
85 	pat_attribute11,
86 	pat_attribute12,
87 	pat_attribute13,
88 	pat_attribute14,
89 	pat_attribute15,
90 	pat_attribute16,
91 	pat_attribute17,
92 	pat_attribute18,
93 	pat_attribute19,
94 	pat_attribute20,
95 	pat_attribute21,
96 	pat_attribute22,
97 	pat_attribute23,
98 	pat_attribute24,
99 	pat_attribute25,
100 	pat_attribute26,
101 	pat_attribute27,
102 	pat_attribute28,
103 	pat_attribute29,
104 	pat_attribute30,
105 	object_version_number,
106 	mandatory,
107 	once_or_always
108     from	ben_popl_actn_typ_f
109     where	popl_actn_typ_id = p_popl_actn_typ_id
110     and		p_effective_date
111     between	effective_start_date and effective_end_date;
112 --
113   l_proc	varchar2(72)	:= g_package||'api_updating';
114   l_fct_ret	boolean;
115 --
116 Begin
117   hr_utility.set_location('Entering:'||l_proc, 5);
118   --
119   If (p_effective_date is null or
120       p_popl_actn_typ_id is null or
121       p_object_version_number is null) Then
122     --
123     -- One of the primary key arguments is null therefore we must
124     -- set the returning function value to false
125     --
126     l_fct_ret := false;
127   Else
128     If (p_popl_actn_typ_id = g_old_rec.popl_actn_typ_id and
129         p_object_version_number = g_old_rec.object_version_number) Then
130       hr_utility.set_location(l_proc, 10);
131       --
132       -- The g_old_rec is current therefore we must
133       -- set the returning function to true
134       --
135       l_fct_ret := true;
136     Else
137       --
138       -- Select the current row
139       --
140       Open C_Sel1;
141       Fetch C_Sel1 Into g_old_rec;
142       If C_Sel1%notfound Then
143         Close C_Sel1;
144         --
145         -- The primary key is invalid therefore we must error
146         --
147         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
148         hr_utility.raise_error;
149       End If;
150       Close C_Sel1;
151       If (p_object_version_number <> g_old_rec.object_version_number) Then
152         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
153         hr_utility.raise_error;
154       End If;
155       hr_utility.set_location(l_proc, 15);
156       l_fct_ret := true;
157     End If;
158   End If;
159   hr_utility.set_location(' Leaving:'||l_proc, 20);
160   Return (l_fct_ret);
161 --
162 End api_updating;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |--------------------------< find_dt_del_modes >---------------------------|
166 -- ----------------------------------------------------------------------------
167 Procedure find_dt_del_modes
168 	(p_effective_date	in  date,
169 	 p_base_key_value	in  number,
170 	 p_zap		 out nocopy boolean,
171 	 p_delete	 out nocopy boolean,
172 	 p_future_change out nocopy boolean,
173 	 p_delete_next_change out nocopy boolean) is
174 --
175   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
176 --
177   l_parent_key_value1	number;
178   l_parent_key_value2	number;
179   --
180   Cursor C_Sel1 Is
181     select  t.pgm_id,
182 	    t.pl_id
183     from    ben_popl_actn_typ_f t
184     where   t.popl_actn_typ_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 		    l_parent_key_value2;
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_popl_actn_typ_f',
207 	 p_base_key_column	=> 'popl_actn_typ_id',
208 	 p_base_key_value	=> p_base_key_value,
209 	 p_parent_table_name1	=> 'ben_pgm_f',
210 	 p_parent_key_column1	=> 'pgm_id',
211 	 p_parent_key_value1	=> l_parent_key_value1,
212 	 p_parent_table_name2	=> 'ben_pl_f',
213 	 p_parent_key_column2	=> 'pl_id',
214 	 p_parent_key_value2	=> l_parent_key_value2,
215 	 p_zap			=> p_zap,
216 	 p_delete		=> p_delete,
217 	 p_future_change	=> p_future_change,
218 	 p_delete_next_change	=> p_delete_next_change);
219   --
220   hr_utility.set_location(' Leaving:'||l_proc, 10);
221 End find_dt_del_modes;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |--------------------------< find_dt_upd_modes >---------------------------|
225 -- ----------------------------------------------------------------------------
226 Procedure find_dt_upd_modes
227 	(p_effective_date	in  date,
228 	 p_base_key_value	in  number,
229 	 p_correction	 out nocopy boolean,
230 	 p_update	 out nocopy boolean,
231 	 p_update_override out nocopy boolean,
232 	 p_update_change_insert out nocopy boolean) is
233 --
234   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
235 --
236 Begin
237   hr_utility.set_location('Entering:'||l_proc, 5);
238   --
239   -- Call the corresponding datetrack api
240   --
241   dt_api.find_dt_upd_modes
242 	(p_effective_date	=> p_effective_date,
243 	 p_base_table_name	=> 'ben_popl_actn_typ_f',
244 	 p_base_key_column	=> 'popl_actn_typ_id',
245 	 p_base_key_value	=> p_base_key_value,
246 	 p_correction		=> p_correction,
247 	 p_update		=> p_update,
248 	 p_update_override	=> p_update_override,
249 	 p_update_change_insert	=> p_update_change_insert);
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End find_dt_upd_modes;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |------------------------< upd_effective_end_date >------------------------|
256 -- ----------------------------------------------------------------------------
257 Procedure upd_effective_end_date
258 	(p_effective_date		in date,
259 	 p_base_key_value		in number,
260 	 p_new_effective_end_date	in date,
261 	 p_validation_start_date	in date,
262 	 p_validation_end_date		in date,
263          p_object_version_number       out nocopy number) is
264 --
265   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
266   l_object_version_number number;
267 --
268 Begin
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   --
271   -- Because we are updating a row we must get the next object
272   -- version number.
273   --
274   l_object_version_number :=
275     dt_api.get_object_version_number
276 	(p_base_table_name	=> 'ben_popl_actn_typ_f',
277 	 p_base_key_column	=> 'popl_actn_typ_id',
278 	 p_base_key_value	=> p_base_key_value);
279   --
280   hr_utility.set_location(l_proc, 10);
281   g_api_dml := true;  -- Set the api dml status
282   --
283   -- Update the specified datetrack row setting the effective
284   -- end date to the specified new effective end date.
285   --
286   update  ben_popl_actn_typ_f t
287   set	  t.effective_end_date	  = p_new_effective_end_date,
288 	  t.object_version_number = l_object_version_number
289   where	  t.popl_actn_typ_id	  = p_base_key_value
290   and	  p_effective_date
291   between t.effective_start_date and t.effective_end_date;
292   --
293   g_api_dml := false;   -- Unset the api dml status
294   p_object_version_number := l_object_version_number;
295   hr_utility.set_location(' Leaving:'||l_proc, 15);
296 --
297 Exception
298   When Others Then
299     g_api_dml := false;   -- Unset the api dml status
300     Raise;
301 End upd_effective_end_date;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------------< lck >----------------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure lck
307 	(p_effective_date	 in  date,
308 	 p_datetrack_mode	 in  varchar2,
309 	 p_popl_actn_typ_id	 in  number,
310 	 p_object_version_number in  number,
311 	 p_validation_start_date out nocopy date,
312 	 p_validation_end_date	 out nocopy date) is
313 --
314   l_proc		  varchar2(72) := g_package||'lck';
315   l_validation_start_date date;
316   l_validation_end_date	  date;
317   l_object_invalid 	  exception;
318   l_argument		  varchar2(30);
319   --
320   -- Cursor C_Sel1 selects the current locked row as of session date
321   -- ensuring that the object version numbers match.
322   --
323   Cursor C_Sel1 is
324     select
325 	popl_actn_typ_id,
326 	effective_start_date,
327 	effective_end_date,
328 	actn_typ_due_dt_cd,
329 	actn_typ_due_dt_rl,
330 	actn_typ_id,
331 	pgm_id,
332 	pl_id,
333 	business_group_id,
334 	pat_attribute_category,
335 	pat_attribute1,
336 	pat_attribute2,
337 	pat_attribute3,
338 	pat_attribute4,
339 	pat_attribute5,
340 	pat_attribute6,
341 	pat_attribute7,
342 	pat_attribute8,
343 	pat_attribute9,
344 	pat_attribute10,
345 	pat_attribute11,
346 	pat_attribute12,
347 	pat_attribute13,
348 	pat_attribute14,
349 	pat_attribute15,
350 	pat_attribute16,
351 	pat_attribute17,
352 	pat_attribute18,
353 	pat_attribute19,
354 	pat_attribute20,
355 	pat_attribute21,
356 	pat_attribute22,
357 	pat_attribute23,
358 	pat_attribute24,
359 	pat_attribute25,
360 	pat_attribute26,
361 	pat_attribute27,
362 	pat_attribute28,
363 	pat_attribute29,
364 	pat_attribute30,
365 	object_version_number,
366 	mandatory,
367 	once_or_always
368     from    ben_popl_actn_typ_f
369     where   popl_actn_typ_id         = p_popl_actn_typ_id
370     and	    p_effective_date
371     between effective_start_date and effective_end_date
372     for update nowait;
373   --
374   --
375   --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Ensure that all the mandatory arguments are not null
380   --
381   hr_api.mandatory_arg_error(p_api_name       => l_proc,
382                              p_argument       => 'effective_date',
383                              p_argument_value => p_effective_date);
384   --
385   hr_api.mandatory_arg_error(p_api_name       => l_proc,
386                              p_argument       => 'datetrack_mode',
387                              p_argument_value => p_datetrack_mode);
388   --
389   hr_api.mandatory_arg_error(p_api_name       => l_proc,
390                              p_argument       => 'popl_actn_typ_id',
391                              p_argument_value => p_popl_actn_typ_id);
392   --
393   hr_api.mandatory_arg_error(p_api_name       => l_proc,
394                              p_argument       => 'object_version_number',
395                              p_argument_value => p_object_version_number);
396   --
397   -- Check to ensure the datetrack mode is not INSERT.
398   --
399   If (p_datetrack_mode <> 'INSERT') then
400     --
401     -- We must select and lock the current row.
402     --
403     Open  C_Sel1;
404     Fetch C_Sel1 Into g_old_rec;
405     If C_Sel1%notfound then
406       Close C_Sel1;
407       --
408       -- The primary key is invalid therefore we must error
409       --
410       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
411       hr_utility.raise_error;
412     End If;
413     Close C_Sel1;
414     If (p_object_version_number <> g_old_rec.object_version_number) Then
415         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
416         hr_utility.raise_error;
417       End If;
418     hr_utility.set_location(l_proc, 15);
419     --
420     --
421     -- Validate the datetrack mode mode getting the validation start
422     -- and end dates for the specified datetrack operation.
423     --
424     dt_api.validate_dt_mode
425 	(p_effective_date	   => p_effective_date,
426 	 p_datetrack_mode	   => p_datetrack_mode,
427 	 p_base_table_name	   => 'ben_popl_actn_typ_f',
428 	 p_base_key_column	   => 'popl_actn_typ_id',
429 	 p_base_key_value 	   => p_popl_actn_typ_id,
430 	 p_parent_table_name1      => 'ben_pgm_f',
431 	 p_parent_key_column1      => 'pgm_id',
432 	 p_parent_key_value1       => g_old_rec.pgm_id,
433 	 p_parent_table_name2      => 'ben_pl_f',
437 	 p_validation_start_date   => l_validation_start_date,
434 	 p_parent_key_column2      => 'pl_id',
435 	 p_parent_key_value2       => g_old_rec.pl_id,
436          p_enforce_foreign_locking => true,
438  	 p_validation_end_date	   => l_validation_end_date);
439   Else
440     --
441     -- We are doing a datetrack 'INSERT' which is illegal within this
442     -- procedure therefore we must error (note: to lck on insert the
443     -- private procedure ins_lck should be called).
444     --
445     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
446     hr_utility.set_message_token('PROCEDURE', l_proc);
447     hr_utility.set_message_token('STEP','20');
448     hr_utility.raise_error;
449   End If;
450   --
451   -- Set the validation start and end date OUT arguments
452   --
453   p_validation_start_date := l_validation_start_date;
454   p_validation_end_date   := l_validation_end_date;
455   --
456   hr_utility.set_location(' Leaving:'||l_proc, 30);
457 --
458 -- We need to trap the ORA LOCK exception
459 --
460 Exception
461   When HR_Api.Object_Locked then
462     --
463     -- The object is locked therefore we need to supply a meaningful
464     -- error message.
465     --
466     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
467     hr_utility.set_message_token('TABLE_NAME', 'ben_popl_actn_typ_f');
468     hr_utility.raise_error;
469   When l_object_invalid then
470     --
471     -- The object doesn't exist or is invalid
472     --
473     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
474     hr_utility.set_message_token('TABLE_NAME', 'ben_popl_actn_typ_f');
475     hr_utility.raise_error;
476 End lck;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |-----------------------------< convert_args >-----------------------------|
480 -- ----------------------------------------------------------------------------
481 Function convert_args
482 	(
483 	p_popl_actn_typ_id              in number,
484 	p_effective_start_date          in date,
485 	p_effective_end_date            in date,
486 	p_actn_typ_due_dt_cd            in varchar2,
487 	p_actn_typ_due_dt_rl            in number,
488 	p_actn_typ_id                   in number,
489 	p_pgm_id                        in number,
490 	p_pl_id                         in number,
491 	p_business_group_id             in number,
492 	p_pat_attribute_category        in varchar2,
493 	p_pat_attribute1                in varchar2,
494 	p_pat_attribute2                in varchar2,
495 	p_pat_attribute3                in varchar2,
496 	p_pat_attribute4                in varchar2,
497 	p_pat_attribute5                in varchar2,
498 	p_pat_attribute6                in varchar2,
499 	p_pat_attribute7                in varchar2,
500 	p_pat_attribute8                in varchar2,
501 	p_pat_attribute9                in varchar2,
502 	p_pat_attribute10               in varchar2,
503 	p_pat_attribute11               in varchar2,
504 	p_pat_attribute12               in varchar2,
505 	p_pat_attribute13               in varchar2,
506 	p_pat_attribute14               in varchar2,
507 	p_pat_attribute15               in varchar2,
508 	p_pat_attribute16               in varchar2,
509 	p_pat_attribute17               in varchar2,
510 	p_pat_attribute18               in varchar2,
511 	p_pat_attribute19               in varchar2,
512 	p_pat_attribute20               in varchar2,
513 	p_pat_attribute21               in varchar2,
514 	p_pat_attribute22               in varchar2,
515 	p_pat_attribute23               in varchar2,
516 	p_pat_attribute24               in varchar2,
517 	p_pat_attribute25               in varchar2,
518 	p_pat_attribute26               in varchar2,
519 	p_pat_attribute27               in varchar2,
520 	p_pat_attribute28               in varchar2,
521 	p_pat_attribute29               in varchar2,
522 	p_pat_attribute30               in varchar2,
523 	p_object_version_number         in number,
524 	p_mandatory                     in varchar2,
525 	p_once_or_always                in varchar2
526 	)
527 	Return g_rec_type is
528 --
529   l_rec	  g_rec_type;
530   l_proc  varchar2(72) := g_package||'convert_args';
531 --
532 Begin
533   --
534   hr_utility.set_location('Entering:'||l_proc, 5);
535   --
536   -- Convert arguments into local l_rec structure.
537   --
538   l_rec.popl_actn_typ_id                 := p_popl_actn_typ_id;
539   l_rec.effective_start_date             := p_effective_start_date;
540   l_rec.effective_end_date               := p_effective_end_date;
541   l_rec.actn_typ_due_dt_cd               := p_actn_typ_due_dt_cd;
542   l_rec.actn_typ_due_dt_rl               := p_actn_typ_due_dt_rl;
543   l_rec.actn_typ_id                      := p_actn_typ_id;
544   l_rec.pgm_id                           := p_pgm_id;
545   l_rec.pl_id                            := p_pl_id;
546   l_rec.business_group_id                := p_business_group_id;
547   l_rec.pat_attribute_category           := p_pat_attribute_category;
548   l_rec.pat_attribute1                   := p_pat_attribute1;
549   l_rec.pat_attribute2                   := p_pat_attribute2;
550   l_rec.pat_attribute3                   := p_pat_attribute3;
551   l_rec.pat_attribute4                   := p_pat_attribute4;
552   l_rec.pat_attribute5                   := p_pat_attribute5;
553   l_rec.pat_attribute6                   := p_pat_attribute6;
554   l_rec.pat_attribute7                   := p_pat_attribute7;
555   l_rec.pat_attribute8                   := p_pat_attribute8;
556   l_rec.pat_attribute9                   := p_pat_attribute9;
557   l_rec.pat_attribute10                  := p_pat_attribute10;
558   l_rec.pat_attribute11                  := p_pat_attribute11;
559   l_rec.pat_attribute12                  := p_pat_attribute12;
560   l_rec.pat_attribute13                  := p_pat_attribute13;
561   l_rec.pat_attribute14                  := p_pat_attribute14;
562   l_rec.pat_attribute15                  := p_pat_attribute15;
563   l_rec.pat_attribute16                  := p_pat_attribute16;
564   l_rec.pat_attribute17                  := p_pat_attribute17;
565   l_rec.pat_attribute18                  := p_pat_attribute18;
566   l_rec.pat_attribute19                  := p_pat_attribute19;
567   l_rec.pat_attribute20                  := p_pat_attribute20;
568   l_rec.pat_attribute21                  := p_pat_attribute21;
569   l_rec.pat_attribute22                  := p_pat_attribute22;
570   l_rec.pat_attribute23                  := p_pat_attribute23;
571   l_rec.pat_attribute24                  := p_pat_attribute24;
572   l_rec.pat_attribute25                  := p_pat_attribute25;
573   l_rec.pat_attribute26                  := p_pat_attribute26;
574   l_rec.pat_attribute27                  := p_pat_attribute27;
575   l_rec.pat_attribute28                  := p_pat_attribute28;
576   l_rec.pat_attribute29                  := p_pat_attribute29;
577   l_rec.pat_attribute30                  := p_pat_attribute30;
578   l_rec.object_version_number            := p_object_version_number;
579   l_rec.mandatory                        := p_mandatory;
580   l_rec.once_or_always                   := p_once_or_always;
581   --
582   -- Return the plsql record structure.
583   --
584   hr_utility.set_location(' Leaving:'||l_proc, 10);
585   Return(l_rec);
586 --
587 End convert_args;
588 --
589 end ben_pat_shd;