DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_EST_SHD

Source


1 Package Body ben_est_shd as
2 /* $Header: beestrhi.pkb 120.0 2005/05/28 02:59:20 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_est_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_SUPPL_ROLE_PRTE_F_PK') 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   Else
42     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
45     fnd_message.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_suppl_role_prte_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_suppl_role_prte_id,
66 	effective_start_date,
67 	effective_end_date,
68 	business_group_id,
69 	eligy_prfl_id,
70 	ordr_num,
71 	excld_flag,
72 	job_group_id,
73 	job_id,
74 	est_attribute_category,
75 	est_attribute1,
76 	est_attribute2,
77 	est_attribute3,
78 	est_attribute4,
79 	est_attribute5,
80 	est_attribute6,
81 	est_attribute7,
82 	est_attribute8,
83 	est_attribute9,
84 	est_attribute10,
85 	est_attribute11,
86 	est_attribute12,
87 	est_attribute13,
88 	est_attribute14,
89 	est_attribute15,
90 	est_attribute16,
91 	est_attribute17,
92 	est_attribute18,
93 	est_attribute19,
94 	est_attribute20,
95 	est_attribute21,
96 	est_attribute22,
97 	est_attribute23,
98 	est_attribute24,
99 	est_attribute25,
100 	est_attribute26,
101 	est_attribute27,
102 	est_attribute28,
103 	est_attribute29,
104 	est_attribute30,
105 	object_version_number,
106 	criteria_score,
107 	criteria_weight
108     from	ben_elig_suppl_role_prte_f
109     where	elig_suppl_role_prte_id = p_elig_suppl_role_prte_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_elig_suppl_role_prte_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_elig_suppl_role_prte_id = g_old_rec.elig_suppl_role_prte_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         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
148         fnd_message.raise_error;
149       End If;
150       Close C_Sel1;
151       If (p_object_version_number <> g_old_rec.object_version_number) Then
152         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
153         fnd_message.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   --
179   Cursor C_Sel1 Is
180     select  t.eligy_prfl_id
181     from    ben_elig_suppl_role_prte_f t
182     where   t.elig_suppl_role_prte_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   If C_Sel1%notfound then
191     Close C_Sel1;
192     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
193     fnd_message.set_token('PROCEDURE', l_proc);
194     fnd_message.set_token('STEP','10');
195     fnd_message.raise_error;
196   End If;
197   Close C_Sel1;
198   --
199   -- Call the corresponding datetrack api
200   --
201   dt_api.find_dt_del_modes
202 	(p_effective_date	=> p_effective_date,
203 	 p_base_table_name	=> 'ben_elig_suppl_role_prte_f',
204 	 p_base_key_column	=> 'elig_suppl_role_prte_id',
205 	 p_base_key_value	=> p_base_key_value,
206 	 p_parent_table_name1	=> 'ben_eligy_prfl_f',
207 	 p_parent_key_column1	=> 'eligy_prfl_id',
208 	 p_parent_key_value1	=> l_parent_key_value1,
209 	 p_zap			=> p_zap,
210 	 p_delete		=> p_delete,
211 	 p_future_change	=> p_future_change,
212 	 p_delete_next_change	=> p_delete_next_change);
213   --
214   hr_utility.set_location(' Leaving:'||l_proc, 10);
215 End find_dt_del_modes;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |--------------------------< find_dt_upd_modes >---------------------------|
219 -- ----------------------------------------------------------------------------
220 Procedure find_dt_upd_modes
221 	(p_effective_date	in  date,
222 	 p_base_key_value	in  number,
223 	 p_correction	 out nocopy boolean,
224 	 p_update	 out nocopy boolean,
225 	 p_update_override out nocopy boolean,
226 	 p_update_change_insert out nocopy boolean) is
227 --
228   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
229 --
230 Begin
231   hr_utility.set_location('Entering:'||l_proc, 5);
232   --
233   -- Call the corresponding datetrack api
234   --
235   dt_api.find_dt_upd_modes
236 	(p_effective_date	=> p_effective_date,
237 	 p_base_table_name	=> 'ben_elig_suppl_role_prte_f',
238 	 p_base_key_column	=> 'elig_suppl_role_prte_id',
239 	 p_base_key_value	=> p_base_key_value,
240 	 p_correction		=> p_correction,
241 	 p_update		=> p_update,
242 	 p_update_override	=> p_update_override,
243 	 p_update_change_insert	=> p_update_change_insert);
244   --
245   hr_utility.set_location(' Leaving:'||l_proc, 10);
246 End find_dt_upd_modes;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |------------------------< upd_effective_end_date >------------------------|
250 -- ----------------------------------------------------------------------------
251 Procedure upd_effective_end_date
252 	(p_effective_date		in date,
253 	 p_base_key_value		in number,
254 	 p_new_effective_end_date	in date,
255 	 p_validation_start_date	in date,
256 	 p_validation_end_date		in date,
257          p_object_version_number       out nocopy number) is
258 --
259   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
260   l_object_version_number number;
261 --
262 Begin
263   hr_utility.set_location('Entering:'||l_proc, 5);
264   --
265   -- Because we are updating a row we must get the next object
266   -- version number.
267   --
268   l_object_version_number :=
269     dt_api.get_object_version_number
270 	(p_base_table_name	=> 'ben_elig_suppl_role_prte_f',
271 	 p_base_key_column	=> 'elig_suppl_role_prte_id',
272 	 p_base_key_value	=> p_base_key_value);
273   --
274   hr_utility.set_location(l_proc, 10);
275   g_api_dml := true;  -- Set the api dml status
276   --
277   -- Update the specified datetrack row setting the effective
278   -- end date to the specified new effective end date.
279   --
280   update  ben_elig_suppl_role_prte_f t
281   set	  t.effective_end_date	  = p_new_effective_end_date,
282 	  t.object_version_number = l_object_version_number
283   where	  t.elig_suppl_role_prte_id	  = p_base_key_value
284   and	  p_effective_date
285   between t.effective_start_date and t.effective_end_date;
286   --
287   g_api_dml := false;   -- Unset the api dml status
288   p_object_version_number := l_object_version_number;
289   hr_utility.set_location(' Leaving:'||l_proc, 15);
290 --
291 Exception
292   When Others Then
293     g_api_dml := false;   -- Unset the api dml status
294     Raise;
295 End upd_effective_end_date;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------------< lck >----------------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure lck
301 	(p_effective_date	 in  date,
302 	 p_datetrack_mode	 in  varchar2,
303 	 p_elig_suppl_role_prte_id	 in  number,
304 	 p_object_version_number in  number,
305 	 p_validation_start_date out nocopy date,
306 	 p_validation_end_date	 out nocopy date) is
307 --
308   l_proc		  varchar2(72) := g_package||'lck';
309   l_validation_start_date date;
310   l_validation_end_date	  date;
311   l_object_invalid 	  exception;
312   l_argument		  varchar2(30);
313   --
314   -- Cursor C_Sel1 selects the current locked row as of session date
315   -- ensuring that the object version numbers match.
316   --
317   Cursor C_Sel1 is
318     select
319 	elig_suppl_role_prte_id,
320 	effective_start_date,
321 	effective_end_date,
322 	business_group_id,
323 	eligy_prfl_id,
324 	ordr_num,
325 	excld_flag,
326 	job_group_id,
327 	job_id,
328 	est_attribute_category,
329 	est_attribute1,
330 	est_attribute2,
331 	est_attribute3,
332 	est_attribute4,
333 	est_attribute5,
334 	est_attribute6,
335 	est_attribute7,
336 	est_attribute8,
337 	est_attribute9,
338 	est_attribute10,
339 	est_attribute11,
340 	est_attribute12,
341 	est_attribute13,
342 	est_attribute14,
343 	est_attribute15,
344 	est_attribute16,
345 	est_attribute17,
346 	est_attribute18,
347 	est_attribute19,
348 	est_attribute20,
349 	est_attribute21,
350 	est_attribute22,
351 	est_attribute23,
352 	est_attribute24,
353 	est_attribute25,
354 	est_attribute26,
355 	est_attribute27,
356 	est_attribute28,
357 	est_attribute29,
358 	est_attribute30,
359 	object_version_number,
360 	criteria_score,
361 	criteria_weight
362     from    ben_elig_suppl_role_prte_f
363     where   elig_suppl_role_prte_id = p_elig_suppl_role_prte_id
364     and	    p_effective_date
365     between effective_start_date and effective_end_date
366     for update nowait;
367   --
368   --
369   --
370 Begin
371   hr_utility.set_location('Entering:'||l_proc, 5);
375   hr_api.mandatory_arg_error(p_api_name       => l_proc,
372   --
373   -- Ensure that all the mandatory arguments are not null
374   --
376                              p_argument       => 'effective_date',
377                              p_argument_value => p_effective_date);
378   --
379   hr_api.mandatory_arg_error(p_api_name       => l_proc,
380                              p_argument       => 'datetrack_mode',
381                              p_argument_value => p_datetrack_mode);
382   --
383   hr_api.mandatory_arg_error(p_api_name       => l_proc,
384                              p_argument       => 'elig_suppl_role_prte_id',
385                              p_argument_value => p_elig_suppl_role_prte_id);
386   --
387   hr_api.mandatory_arg_error(p_api_name       => l_proc,
388                              p_argument       => 'object_version_number',
389                              p_argument_value => p_object_version_number);
390   --
391   -- Check to ensure the datetrack mode is not INSERT.
392   --
393   If (p_datetrack_mode <> 'INSERT') then
394     --
395     -- We must select and lock the current row.
396     --
397     Open  C_Sel1;
398     Fetch C_Sel1 Into g_old_rec;
399     If C_Sel1%notfound then
400       Close C_Sel1;
401       --
402       -- The primary key is invalid therefore we must error
403       --
404       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
405       fnd_message.raise_error;
406     End If;
407     Close C_Sel1;
408     If (p_object_version_number <> g_old_rec.object_version_number) Then
409         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
410         fnd_message.raise_error;
411       End If;
412     hr_utility.set_location(l_proc, 15);
413     --
414     --
415     -- Validate the datetrack mode mode getting the validation start
416     -- and end dates for the specified datetrack operation.
417     --
418     dt_api.validate_dt_mode
419 	(p_effective_date	   => p_effective_date,
420 	 p_datetrack_mode	   => p_datetrack_mode,
421 	 p_base_table_name	   => 'ben_elig_suppl_role_prte_f',
422 	 p_base_key_column	   => 'elig_suppl_role_prte_id',
423 	 p_base_key_value 	   => p_elig_suppl_role_prte_id,
424 	 p_parent_table_name1      => 'ben_eligy_prfl_f',
425 	 p_parent_key_column1      => 'eligy_prfl_id',
426 	 p_parent_key_value1       => g_old_rec.eligy_prfl_id,
427          p_enforce_foreign_locking => 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     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
437     fnd_message.set_token('PROCEDURE', l_proc);
438     fnd_message.set_token('STEP','20');
439     fnd_message.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     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
458     fnd_message.set_token('TABLE_NAME', 'ben_elig_suppl_role_prte_f');
459     fnd_message.raise_error;
460   When l_object_invalid then
461     --
462     -- The object doesn't exist or is invalid
463     --
464     fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
465     fnd_message.set_token('TABLE_NAME', 'ben_elig_suppl_role_prte_f');
466     fnd_message.raise_error;
467 End lck;
468 --
469 -- ----------------------------------------------------------------------------
470 -- |-----------------------------< convert_args >-----------------------------|
471 -- ----------------------------------------------------------------------------
472 Function convert_args
473 	(
474 	p_elig_suppl_role_prte_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_eligy_prfl_id                 in number,
479 	p_ordr_num                      in number,
480 	p_excld_flag                    in varchar2,
481 	p_job_group_id                  in number,
482 	p_job_id                        in number,
483 	p_est_attribute_category        in varchar2,
484 	p_est_attribute1                in varchar2,
485 	p_est_attribute2                in varchar2,
486 	p_est_attribute3                in varchar2,
487 	p_est_attribute4                in varchar2,
488 	p_est_attribute5                in varchar2,
489 	p_est_attribute6                in varchar2,
490 	p_est_attribute7                in varchar2,
491 	p_est_attribute8                in varchar2,
492 	p_est_attribute9                in varchar2,
493 	p_est_attribute10               in varchar2,
494 	p_est_attribute11               in varchar2,
495 	p_est_attribute12               in varchar2,
496 	p_est_attribute13               in varchar2,
500 	p_est_attribute17               in varchar2,
497 	p_est_attribute14               in varchar2,
498 	p_est_attribute15               in varchar2,
499 	p_est_attribute16               in varchar2,
501 	p_est_attribute18               in varchar2,
502 	p_est_attribute19               in varchar2,
503 	p_est_attribute20               in varchar2,
504 	p_est_attribute21               in varchar2,
505 	p_est_attribute22               in varchar2,
506 	p_est_attribute23               in varchar2,
507 	p_est_attribute24               in varchar2,
508 	p_est_attribute25               in varchar2,
509 	p_est_attribute26               in varchar2,
510 	p_est_attribute27               in varchar2,
511 	p_est_attribute28               in varchar2,
512 	p_est_attribute29               in varchar2,
513 	p_est_attribute30               in varchar2,
514 	p_object_version_number         in number,
515 	p_criteria_score                in number,
516 	p_criteria_weight               in number
517 	)
518 	Return g_rec_type is
519 --
520   l_rec	  g_rec_type;
521   l_proc  varchar2(72) := g_package||'convert_args';
522 --
523 Begin
524   --
525   hr_utility.set_location('Entering:'||l_proc, 5);
526   --
527   -- Convert arguments into local l_rec structure.
528   --
529   l_rec.elig_suppl_role_prte_id       := p_elig_suppl_role_prte_id;
530   l_rec.effective_start_date             := p_effective_start_date;
531   l_rec.effective_end_date               := p_effective_end_date;
532   l_rec.business_group_id                := p_business_group_id;
533   l_rec.eligy_prfl_id                    := p_eligy_prfl_id;
534   l_rec.ordr_num                         := p_ordr_num;
535   l_rec.excld_flag                       := p_excld_flag;
536   l_rec.job_group_id                     := p_job_group_id;
537   l_rec.job_id                           := p_job_id;
538   l_rec.est_attribute_category           := p_est_attribute_category;
539   l_rec.est_attribute1                   := p_est_attribute1;
540   l_rec.est_attribute2                   := p_est_attribute2;
541   l_rec.est_attribute3                   := p_est_attribute3;
542   l_rec.est_attribute4                   := p_est_attribute4;
543   l_rec.est_attribute5                   := p_est_attribute5;
544   l_rec.est_attribute6                   := p_est_attribute6;
545   l_rec.est_attribute7                   := p_est_attribute7;
546   l_rec.est_attribute8                   := p_est_attribute8;
547   l_rec.est_attribute9                   := p_est_attribute9;
548   l_rec.est_attribute10                  := p_est_attribute10;
549   l_rec.est_attribute11                  := p_est_attribute11;
550   l_rec.est_attribute12                  := p_est_attribute12;
551   l_rec.est_attribute13                  := p_est_attribute13;
552   l_rec.est_attribute14                  := p_est_attribute14;
553   l_rec.est_attribute15                  := p_est_attribute15;
554   l_rec.est_attribute16                  := p_est_attribute16;
555   l_rec.est_attribute17                  := p_est_attribute17;
556   l_rec.est_attribute18                  := p_est_attribute18;
557   l_rec.est_attribute19                  := p_est_attribute19;
558   l_rec.est_attribute20                  := p_est_attribute20;
559   l_rec.est_attribute21                  := p_est_attribute21;
560   l_rec.est_attribute22                  := p_est_attribute22;
561   l_rec.est_attribute23                  := p_est_attribute23;
562   l_rec.est_attribute24                  := p_est_attribute24;
563   l_rec.est_attribute25                  := p_est_attribute25;
564   l_rec.est_attribute26                  := p_est_attribute26;
565   l_rec.est_attribute27                  := p_est_attribute27;
566   l_rec.est_attribute28                  := p_est_attribute28;
567   l_rec.est_attribute29                  := p_est_attribute29;
568   l_rec.est_attribute30                  := p_est_attribute30;
569   l_rec.object_version_number            := p_object_version_number;
570   l_rec.criteria_score                   := p_criteria_score;
571   l_rec.criteria_weight                  := p_criteria_weight;
572   --
573   -- Return the plsql record structure.
574   --
575   hr_utility.set_location(' Leaving:'||l_proc, 10);
576   Return(l_rec);
577 --
578 End convert_args;
579 --
580 end ben_est_shd;