DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CGP_SHD

Source


1 Package Body ben_cgp_shd as
2 /* $Header: becgprhi.pkb 120.0 2005/05/28 01:01:58 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cgp_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_CNTNG_PRTN_FK1') Then
37     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38     fnd_message.set_token('PROCEDURE', l_proc);
39     fnd_message.set_token('STEP','5');
40     fnd_message.raise_error;
41   ElsIf (p_constraint_name = 'BEN_CNTNG_PRTN_PK') Then
42     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('STEP','10');
45     fnd_message.raise_error;
46   Else
47     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48     fnd_message.set_token('PROCEDURE', l_proc);
49     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50     fnd_message.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_cntng_prtn_elig_prfl_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 	cntng_prtn_elig_prfl_id,
71 	effective_start_date,
72 	effective_end_date,
73 	business_group_id,
77 	pymt_must_be_rcvd_num,
74 	eligy_prfl_id,
75 	name,
76 	pymt_must_be_rcvd_uom,
78 	pymt_must_be_rcvd_rl,
79 	cgp_attribute_category,
80 	cgp_attribute1,
81 	cgp_attribute2,
82 	cgp_attribute3,
83 	cgp_attribute4,
84 	cgp_attribute5,
85 	cgp_attribute6,
86 	cgp_attribute7,
87 	cgp_attribute8,
88 	cgp_attribute9,
89 	cgp_attribute10,
90 	cgp_attribute11,
91 	cgp_attribute12,
92 	cgp_attribute13,
93 	cgp_attribute14,
94 	cgp_attribute15,
95 	cgp_attribute16,
96 	cgp_attribute17,
97 	cgp_attribute18,
98 	cgp_attribute19,
99 	cgp_attribute20,
100 	cgp_attribute21,
101 	cgp_attribute22,
102 	cgp_attribute23,
103 	cgp_attribute24,
104 	cgp_attribute25,
105 	cgp_attribute26,
106 	cgp_attribute27,
107 	cgp_attribute28,
108 	cgp_attribute29,
109 	cgp_attribute30,
110 	object_version_number
111     from	ben_cntng_prtn_elig_prfl_f
112     where	cntng_prtn_elig_prfl_id = p_cntng_prtn_elig_prfl_id
113     and		p_effective_date
114     between	effective_start_date and effective_end_date;
115 --
116   l_proc	varchar2(72)	:= g_package||'api_updating';
117   l_fct_ret	boolean;
118 --
119 Begin
120   hr_utility.set_location('Entering:'||l_proc, 5);
121   --
122   If (p_effective_date is null or
123       p_cntng_prtn_elig_prfl_id is null or
124       p_object_version_number is null) Then
125     --
126     -- One of the primary key arguments is null therefore we must
127     -- set the returning function value to false
128     --
129     l_fct_ret := false;
130   Else
131     If (p_cntng_prtn_elig_prfl_id = g_old_rec.cntng_prtn_elig_prfl_id and
132         p_object_version_number = g_old_rec.object_version_number) Then
133       hr_utility.set_location(l_proc, 10);
134       --
135       -- The g_old_rec is current therefore we must
136       -- set the returning function to true
137       --
138       l_fct_ret := true;
139     Else
140       --
141       -- Select the current row
142       --
143       Open C_Sel1;
144       Fetch C_Sel1 Into g_old_rec;
145       If C_Sel1%notfound Then
146         Close C_Sel1;
147         --
148         -- The primary key is invalid therefore we must error
149         --
150         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
151         fnd_message.raise_error;
152       End If;
153       Close C_Sel1;
154       If (p_object_version_number <> g_old_rec.object_version_number) Then
155         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
156         fnd_message.raise_error;
157       End If;
158       hr_utility.set_location(l_proc, 15);
159       l_fct_ret := true;
160     End If;
161   End If;
162   hr_utility.set_location(' Leaving:'||l_proc, 20);
163   Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |--------------------------< find_dt_del_modes >---------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 	(p_effective_date	in  date,
172 	 p_base_key_value	in  number,
173 	 p_zap		 out nocopy boolean,
174 	 p_delete	 out nocopy boolean,
175 	 p_future_change out nocopy boolean,
176 	 p_delete_next_change out nocopy boolean) is
177 --
178   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
179 --
180   l_parent_key_value1	number;
181   --
182   Cursor C_Sel1 Is
183     select  t.eligy_prfl_id
184     from    ben_cntng_prtn_elig_prfl_f t
185     where   t.cntng_prtn_elig_prfl_id = p_base_key_value
186     and     p_effective_date
187     between t.effective_start_date and t.effective_end_date;
188 --
189 Begin
190   hr_utility.set_location('Entering:'||l_proc, 5);
191   Open  C_Sel1;
192   Fetch C_Sel1 Into l_parent_key_value1;
193   If C_Sel1%notfound then
194     Close C_Sel1;
195     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
196     fnd_message.set_token('PROCEDURE', l_proc);
197     fnd_message.set_token('STEP','10');
198     fnd_message.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_cntng_prtn_elig_prfl_f',
207 	 p_base_key_column	=> 'cntng_prtn_elig_prfl_id',
208 	 p_base_key_value	=> p_base_key_value,
209 	 p_parent_table_name1	=> 'ben_eligy_prfl_f',
210 	 p_parent_key_column1	=> 'eligy_prfl_id',
211 	 p_parent_key_value1	=> l_parent_key_value1,
212 	 p_zap			=> p_zap,
213 	 p_delete		=> p_delete,
214 	 p_future_change	=> p_future_change,
215 	 p_delete_next_change	=> p_delete_next_change);
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End find_dt_del_modes;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |--------------------------< find_dt_upd_modes >---------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure find_dt_upd_modes
224 	(p_effective_date	in  date,
225 	 p_base_key_value	in  number,
226 	 p_correction	 out nocopy boolean,
227 	 p_update	 out nocopy boolean,
228 	 p_update_override out nocopy boolean,
229 	 p_update_change_insert out nocopy boolean) is
230 --
231   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
232 --
233 Begin
234   hr_utility.set_location('Entering:'||l_proc, 5);
235   --
236   -- Call the corresponding datetrack api
237   --
238   dt_api.find_dt_upd_modes
242 	 p_base_key_value	=> p_base_key_value,
239 	(p_effective_date	=> p_effective_date,
240 	 p_base_table_name	=> 'ben_cntng_prtn_elig_prfl_f',
241 	 p_base_key_column	=> 'cntng_prtn_elig_prfl_id',
243 	 p_correction		=> p_correction,
244 	 p_update		=> p_update,
245 	 p_update_override	=> p_update_override,
246 	 p_update_change_insert	=> p_update_change_insert);
247   --
248   hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End find_dt_upd_modes;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |------------------------< upd_effective_end_date >------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure upd_effective_end_date
255 	(p_effective_date		in date,
256 	 p_base_key_value		in number,
257 	 p_new_effective_end_date	in date,
258 	 p_validation_start_date	in date,
259 	 p_validation_end_date		in date,
260          p_object_version_number       out nocopy number) is
261 --
262   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
263   l_object_version_number number;
264 --
265 Begin
266   hr_utility.set_location('Entering:'||l_proc, 5);
267   --
268   -- Because we are updating a row we must get the next object
269   -- version number.
270   --
271   l_object_version_number :=
272     dt_api.get_object_version_number
273 	(p_base_table_name	=> 'ben_cntng_prtn_elig_prfl_f',
274 	 p_base_key_column	=> 'cntng_prtn_elig_prfl_id',
275 	 p_base_key_value	=> p_base_key_value);
276   --
277   hr_utility.set_location(l_proc, 10);
278   g_api_dml := true;  -- Set the api dml status
279   --
280   -- Update the specified datetrack row setting the effective
281   -- end date to the specified new effective end date.
282   --
283   update  ben_cntng_prtn_elig_prfl_f t
284   set	  t.effective_end_date	  = p_new_effective_end_date,
285 	  t.object_version_number = l_object_version_number
286   where	  t.cntng_prtn_elig_prfl_id	  = p_base_key_value
287   and	  p_effective_date
288   between t.effective_start_date and t.effective_end_date;
289   --
290   g_api_dml := false;   -- Unset the api dml status
291   p_object_version_number := l_object_version_number;
292   hr_utility.set_location(' Leaving:'||l_proc, 15);
293 --
294 Exception
295   When Others Then
296     g_api_dml := false;   -- Unset the api dml status
297     Raise;
298 End upd_effective_end_date;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< lck >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure lck
304 	(p_effective_date	 in  date,
305 	 p_datetrack_mode	 in  varchar2,
306 	 p_cntng_prtn_elig_prfl_id	 in  number,
307 	 p_object_version_number in  number,
308 	 p_validation_start_date out nocopy date,
309 	 p_validation_end_date	 out nocopy date) is
310 --
311   l_proc		  varchar2(72) := g_package||'lck';
312   l_validation_start_date date;
313   l_validation_end_date	  date;
314   l_object_invalid 	  exception;
315   l_argument		  varchar2(30);
316   --
317   -- Cursor C_Sel1 selects the current locked row as of session date
318   -- ensuring that the object version numbers match.
319   --
320   Cursor C_Sel1 is
321     select
322 	cntng_prtn_elig_prfl_id,
323 	effective_start_date,
324 	effective_end_date,
325 	business_group_id,
326 	eligy_prfl_id,
327 	name,
328 	pymt_must_be_rcvd_uom,
329 	pymt_must_be_rcvd_num,
330 	pymt_must_be_rcvd_rl,
331 	cgp_attribute_category,
332 	cgp_attribute1,
333 	cgp_attribute2,
334 	cgp_attribute3,
335 	cgp_attribute4,
336 	cgp_attribute5,
337 	cgp_attribute6,
338 	cgp_attribute7,
339 	cgp_attribute8,
340 	cgp_attribute9,
341 	cgp_attribute10,
342 	cgp_attribute11,
343 	cgp_attribute12,
344 	cgp_attribute13,
345 	cgp_attribute14,
346 	cgp_attribute15,
347 	cgp_attribute16,
348 	cgp_attribute17,
349 	cgp_attribute18,
350 	cgp_attribute19,
351 	cgp_attribute20,
352 	cgp_attribute21,
353 	cgp_attribute22,
354 	cgp_attribute23,
355 	cgp_attribute24,
356 	cgp_attribute25,
357 	cgp_attribute26,
358 	cgp_attribute27,
359 	cgp_attribute28,
360 	cgp_attribute29,
361 	cgp_attribute30,
362 	object_version_number
363     from    ben_cntng_prtn_elig_prfl_f
364     where   cntng_prtn_elig_prfl_id         = p_cntng_prtn_elig_prfl_id
365     and	    p_effective_date
366     between effective_start_date and effective_end_date
367     for update nowait;
368   --
369   --
370   --
371 Begin
372   hr_utility.set_location('Entering:'||l_proc, 5);
373   --
374   -- Ensure that all the mandatory arguments are not null
375   --
376   hr_api.mandatory_arg_error(p_api_name       => l_proc,
377                              p_argument       => 'effective_date',
378                              p_argument_value => p_effective_date);
379   --
380   hr_api.mandatory_arg_error(p_api_name       => l_proc,
381                              p_argument       => 'datetrack_mode',
382                              p_argument_value => p_datetrack_mode);
383   --
384   hr_api.mandatory_arg_error(p_api_name       => l_proc,
385                              p_argument       => 'cntng_prtn_elig_prfl_id',
386                              p_argument_value => p_cntng_prtn_elig_prfl_id);
387   --
391   --
388   hr_api.mandatory_arg_error(p_api_name       => l_proc,
389                              p_argument       => 'object_version_number',
390                              p_argument_value => p_object_version_number);
392   -- Check to ensure the datetrack mode is not INSERT.
393   --
394   If (p_datetrack_mode <> 'INSERT') then
395     --
396     -- We must select and lock the current row.
397     --
398     Open  C_Sel1;
399     Fetch C_Sel1 Into g_old_rec;
400     If C_Sel1%notfound then
401       Close C_Sel1;
402       --
403       -- The primary key is invalid therefore we must error
404       --
405       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
406       fnd_message.raise_error;
407     End If;
408     Close C_Sel1;
409     If (p_object_version_number <> g_old_rec.object_version_number) Then
410         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
411         fnd_message.raise_error;
412       End If;
413     hr_utility.set_location(l_proc, 15);
414     --
415     --
416     -- Validate the datetrack mode mode getting the validation start
417     -- and end dates for the specified datetrack operation.
418     --
419     dt_api.validate_dt_mode
420 	(p_effective_date	   => p_effective_date,
421 	 p_datetrack_mode	   => p_datetrack_mode,
422 	 p_base_table_name	   => 'ben_cntng_prtn_elig_prfl_f',
423 	 p_base_key_column	   => 'cntng_prtn_elig_prfl_id',
424 	 p_base_key_value 	   => p_cntng_prtn_elig_prfl_id,
425 	 p_parent_table_name1      => 'ben_eligy_prfl_f',
426 	 p_parent_key_column1      => 'eligy_prfl_id',
427 	 p_parent_key_value1       => g_old_rec.eligy_prfl_id,
428 	 p_child_table_name1       => 'ben_cntnu_prtn_ctfn_typ_f',
429 	 p_child_key_column1       => 'cntnu_prtn_ctfn_typ_id',
430          p_enforce_foreign_locking => true,
431 	 p_validation_start_date   => l_validation_start_date,
432  	 p_validation_end_date	   => l_validation_end_date);
433   Else
434     --
435     -- We are doing a datetrack 'INSERT' which is illegal within this
436     -- procedure therefore we must error (note: to lck on insert the
437     -- private procedure ins_lck should be called).
438     --
439     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
440     fnd_message.set_token('PROCEDURE', l_proc);
441     fnd_message.set_token('STEP','20');
442     fnd_message.raise_error;
443   End If;
444   --
445   -- Set the validation start and end date OUT arguments
446   --
447   p_validation_start_date := l_validation_start_date;
448   p_validation_end_date   := l_validation_end_date;
449   --
450   hr_utility.set_location(' Leaving:'||l_proc, 30);
451 --
452 -- We need to trap the ORA LOCK exception
453 --
454 Exception
455   When HR_Api.Object_Locked then
456     --
457     -- The object is locked therefore we need to supply a meaningful
458     -- error message.
459     --
460     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
461     fnd_message.set_token('TABLE_NAME', 'ben_cntng_prtn_elig_prfl_f');
462     fnd_message.raise_error;
463   When l_object_invalid then
464     --
465     -- The object doesn't exist or is invalid
466     --
467     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
468     fnd_message.set_token('TABLE_NAME', 'ben_cntng_prtn_elig_prfl_f');
469     fnd_message.raise_error;
470 End lck;
471 --
472 -- ----------------------------------------------------------------------------
473 -- |-----------------------------< convert_args >-----------------------------|
474 -- ----------------------------------------------------------------------------
475 Function convert_args
476 	(
477 	p_cntng_prtn_elig_prfl_id       in number,
478 	p_effective_start_date          in date,
479 	p_effective_end_date            in date,
480 	p_business_group_id             in number,
481 	p_eligy_prfl_id                 in number,
482 	p_name                          in varchar2,
483 	p_pymt_must_be_rcvd_uom         in varchar2,
484 	p_pymt_must_be_rcvd_num         in number,
485 	p_pymt_must_be_rcvd_rl          in number,
486 	p_cgp_attribute_category        in varchar2,
487 	p_cgp_attribute1                in varchar2,
488 	p_cgp_attribute2                in varchar2,
489 	p_cgp_attribute3                in varchar2,
490 	p_cgp_attribute4                in varchar2,
491 	p_cgp_attribute5                in varchar2,
492 	p_cgp_attribute6                in varchar2,
493 	p_cgp_attribute7                in varchar2,
494 	p_cgp_attribute8                in varchar2,
495 	p_cgp_attribute9                in varchar2,
496 	p_cgp_attribute10               in varchar2,
497 	p_cgp_attribute11               in varchar2,
498 	p_cgp_attribute12               in varchar2,
499 	p_cgp_attribute13               in varchar2,
500 	p_cgp_attribute14               in varchar2,
501 	p_cgp_attribute15               in varchar2,
502 	p_cgp_attribute16               in varchar2,
503 	p_cgp_attribute17               in varchar2,
504 	p_cgp_attribute18               in varchar2,
505 	p_cgp_attribute19               in varchar2,
506 	p_cgp_attribute20               in varchar2,
507 	p_cgp_attribute21               in varchar2,
508 	p_cgp_attribute22               in varchar2,
509 	p_cgp_attribute23               in varchar2,
510 	p_cgp_attribute24               in varchar2,
511 	p_cgp_attribute25               in varchar2,
512 	p_cgp_attribute26               in varchar2,
513 	p_cgp_attribute27               in varchar2,
514 	p_cgp_attribute28               in varchar2,
515 	p_cgp_attribute29               in varchar2,
516 	p_cgp_attribute30               in varchar2,
517 	p_object_version_number         in number
518 	)
519 	Return g_rec_type is
520 --
521   l_rec	  g_rec_type;
525   --
522   l_proc  varchar2(72) := g_package||'convert_args';
523 --
524 Begin
526   hr_utility.set_location('Entering:'||l_proc, 5);
527   --
528   -- Convert arguments into local l_rec structure.
529   --
533   l_rec.business_group_id                := p_business_group_id;
530   l_rec.cntng_prtn_elig_prfl_id          := p_cntng_prtn_elig_prfl_id;
531   l_rec.effective_start_date             := p_effective_start_date;
532   l_rec.effective_end_date               := p_effective_end_date;
534   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
535   l_rec.name                             := p_name;
536   l_rec.pymt_must_be_rcvd_uom            := p_pymt_must_be_rcvd_uom;
537   l_rec.pymt_must_be_rcvd_num            := p_pymt_must_be_rcvd_num;
538   l_rec.pymt_must_be_rcvd_rl             := p_pymt_must_be_rcvd_rl;
539   l_rec.cgp_attribute_category           := p_cgp_attribute_category;
540   l_rec.cgp_attribute1                   := p_cgp_attribute1;
541   l_rec.cgp_attribute2                   := p_cgp_attribute2;
542   l_rec.cgp_attribute3                   := p_cgp_attribute3;
543   l_rec.cgp_attribute4                   := p_cgp_attribute4;
544   l_rec.cgp_attribute5                   := p_cgp_attribute5;
545   l_rec.cgp_attribute6                   := p_cgp_attribute6;
546   l_rec.cgp_attribute7                   := p_cgp_attribute7;
547   l_rec.cgp_attribute8                   := p_cgp_attribute8;
548   l_rec.cgp_attribute9                   := p_cgp_attribute9;
549   l_rec.cgp_attribute10                  := p_cgp_attribute10;
550   l_rec.cgp_attribute11                  := p_cgp_attribute11;
551   l_rec.cgp_attribute12                  := p_cgp_attribute12;
552   l_rec.cgp_attribute13                  := p_cgp_attribute13;
553   l_rec.cgp_attribute14                  := p_cgp_attribute14;
554   l_rec.cgp_attribute15                  := p_cgp_attribute15;
555   l_rec.cgp_attribute16                  := p_cgp_attribute16;
556   l_rec.cgp_attribute17                  := p_cgp_attribute17;
557   l_rec.cgp_attribute18                  := p_cgp_attribute18;
558   l_rec.cgp_attribute19                  := p_cgp_attribute19;
559   l_rec.cgp_attribute20                  := p_cgp_attribute20;
560   l_rec.cgp_attribute21                  := p_cgp_attribute21;
561   l_rec.cgp_attribute22                  := p_cgp_attribute22;
562   l_rec.cgp_attribute23                  := p_cgp_attribute23;
563   l_rec.cgp_attribute24                  := p_cgp_attribute24;
564   l_rec.cgp_attribute25                  := p_cgp_attribute25;
565   l_rec.cgp_attribute26                  := p_cgp_attribute26;
566   l_rec.cgp_attribute27                  := p_cgp_attribute27;
567   l_rec.cgp_attribute28                  := p_cgp_attribute28;
568   l_rec.cgp_attribute29                  := p_cgp_attribute29;
569   l_rec.cgp_attribute30                  := p_cgp_attribute30;
570   l_rec.object_version_number            := p_object_version_number;
571   --
572   -- Return the plsql record structure.
573   --
574   hr_utility.set_location(' Leaving:'||l_proc, 10);
575   Return(l_rec);
576 --
577 End convert_args;
578 --
579 end ben_cgp_shd;