[Home] [Help]
PACKAGE BODY: APPS.BEN_TCV_SHD
Source
1 Package Body ben_tcv_shd as
2 /* $Header: betcvrhi.pkb 120.1 2008/02/05 08:22:54 rtagarra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_tcv_shd.'; -- Global package name
9 --
13 Function return_api_dml_status Return Boolean Is
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
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_TTL_CVG_VOL_RT_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_TTL_CVG_VOL_RT_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_ttl_cvg_vol_rt_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 ttl_cvg_vol_rt_id,
71 effective_start_date,
72 effective_end_date,
73 business_group_id,
74 excld_flag,
75 no_mn_cvg_vol_amt_apls_flag,
76 no_mx_cvg_vol_amt_apls_flag,
77 ordr_num,
78 mn_cvg_vol_amt,
79 mx_cvg_vol_amt,
80 cvg_vol_det_cd,
81 cvg_vol_det_rl,
82 vrbl_rt_prfl_id,
83 tcv_attribute_category,
84 tcv_attribute1,
85 tcv_attribute2,
86 tcv_attribute3,
87 tcv_attribute4,
88 tcv_attribute5,
89 tcv_attribute6,
90 tcv_attribute7,
91 tcv_attribute8,
92 tcv_attribute9,
93 tcv_attribute10,
94 tcv_attribute11,
95 tcv_attribute12,
96 tcv_attribute13,
97 tcv_attribute14,
98 tcv_attribute15,
99 tcv_attribute16,
100 tcv_attribute17,
101 tcv_attribute18,
102 tcv_attribute19,
103 tcv_attribute20,
104 tcv_attribute21,
105 tcv_attribute22,
106 tcv_attribute23,
107 tcv_attribute24,
108 tcv_attribute25,
109 tcv_attribute26,
110 tcv_attribute27,
111 tcv_attribute28,
112 tcv_attribute29,
113 tcv_attribute30,
114 object_version_number
115 from ben_ttl_cvg_vol_rt_f
116 where ttl_cvg_vol_rt_id = p_ttl_cvg_vol_rt_id
117 and p_effective_date
118 between effective_start_date and effective_end_date;
119 --
120 l_proc varchar2(72) := g_package||'api_updating';
121 l_fct_ret boolean;
122 --
123 Begin
124 hr_utility.set_location('Entering:'||l_proc, 5);
125 --
126 If (p_effective_date is null or
127 p_ttl_cvg_vol_rt_id is null or
128 p_object_version_number is null) Then
129 --
130 -- One of the primary key arguments is null therefore we must
131 -- set the returning function value to false
132 --
133 l_fct_ret := false;
134 Else
135 If (p_ttl_cvg_vol_rt_id = g_old_rec.ttl_cvg_vol_rt_id and
136 p_object_version_number = g_old_rec.object_version_number) Then
137 hr_utility.set_location(l_proc, 10);
138 --
139 -- The g_old_rec is current therefore we must
140 -- set the returning function to true
141 --
142 l_fct_ret := true;
143 Else
144 --
145 -- Select the current row
146 --
147 Open C_Sel1;
148 Fetch C_Sel1 Into g_old_rec;
149 If C_Sel1%notfound Then
150 Close C_Sel1;
151 --
152 -- The primary key is invalid therefore we must error
153 --
154 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
155 fnd_message.raise_error;
156 End If;
157 Close C_Sel1;
158 If (p_object_version_number <> g_old_rec.object_version_number) Then
159 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
160 fnd_message.raise_error;
161 End If;
162 hr_utility.set_location(l_proc, 15);
163 l_fct_ret := true;
164 End If;
165 End If;
166 hr_utility.set_location(' Leaving:'||l_proc, 20);
167 Return (l_fct_ret);
168 --
172 -- |--------------------------< find_dt_del_modes >---------------------------|
169 End api_updating;
170 --
171 -- ----------------------------------------------------------------------------
173 -- ----------------------------------------------------------------------------
174 Procedure find_dt_del_modes
175 (p_effective_date in date,
176 p_base_key_value in number,
177 p_zap out nocopy boolean,
178 p_delete out nocopy boolean,
179 p_future_change out nocopy boolean,
180 p_delete_next_change out nocopy boolean) is
181 --
182 l_proc varchar2(72) := g_package||'find_dt_del_modes';
183 --
184 l_parent_key_value1 number;
185 --
186 Cursor C_Sel1 Is
187 select t.vrbl_rt_prfl_id
191 between t.effective_start_date and t.effective_end_date;
188 from ben_ttl_cvg_vol_rt_f t
189 where t.ttl_cvg_vol_rt_id = p_base_key_value
190 and p_effective_date
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 Open C_Sel1;
196 Fetch C_Sel1 Into l_parent_key_value1;
197 If C_Sel1%notfound then
198 Close C_Sel1;
199 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
200 fnd_message.set_token('PROCEDURE', l_proc);
201 fnd_message.set_token('STEP','10');
202 fnd_message.raise_error;
203 End If;
204 Close C_Sel1;
205 --
206 -- Call the corresponding datetrack api
207 --
208 dt_api.find_dt_del_modes
209 (p_effective_date => p_effective_date,
210 p_base_table_name => 'ben_ttl_cvg_vol_rt_f',
211 p_base_key_column => 'ttl_cvg_vol_rt_id',
212 p_base_key_value => p_base_key_value,
213 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
214 p_parent_key_column1 => 'vrbl_rt_prfl_id',
215 p_parent_key_value1 => l_parent_key_value1,
216 p_zap => p_zap,
217 p_delete => p_delete,
218 p_future_change => p_future_change,
219 p_delete_next_change => p_delete_next_change);
220 --
221 hr_utility.set_location(' Leaving:'||l_proc, 10);
222 End find_dt_del_modes;
223 --
224 -- ----------------------------------------------------------------------------
225 -- |--------------------------< find_dt_upd_modes >---------------------------|
226 -- ----------------------------------------------------------------------------
227 Procedure find_dt_upd_modes
228 (p_effective_date in date,
229 p_base_key_value in number,
230 p_correction out nocopy boolean,
231 p_update out nocopy boolean,
232 p_update_override out nocopy boolean,
233 p_update_change_insert out nocopy boolean) is
234 --
235 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
236 --
237 Begin
238 hr_utility.set_location('Entering:'||l_proc, 5);
239 --
240 -- Call the corresponding datetrack api
241 --
242 dt_api.find_dt_upd_modes
243 (p_effective_date => p_effective_date,
244 p_base_table_name => 'ben_ttl_cvg_vol_rt_f',
245 p_base_key_column => 'ttl_cvg_vol_rt_id',
246 p_base_key_value => p_base_key_value,
247 p_correction => p_correction,
248 p_update => p_update,
249 p_update_override => p_update_override,
250 p_update_change_insert => p_update_change_insert);
251 --
252 hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End find_dt_upd_modes;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |------------------------< upd_effective_end_date >------------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure upd_effective_end_date
259 (p_effective_date in date,
260 p_base_key_value in number,
261 p_new_effective_end_date in date,
262 p_validation_start_date in date,
263 p_validation_end_date in date,
267 l_object_version_number number;
264 p_object_version_number out nocopy number) is
265 --
266 l_proc varchar2(72) := g_package||'upd_effective_end_date';
268 --
269 Begin
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 --
272 -- Because we are updating a row we must get the next object
273 -- version number.
274 --
275 l_object_version_number :=
276 dt_api.get_object_version_number
277 (p_base_table_name => 'ben_ttl_cvg_vol_rt_f',
278 p_base_key_column => 'ttl_cvg_vol_rt_id',
279 p_base_key_value => p_base_key_value);
280 --
281 hr_utility.set_location(l_proc, 10);
282 g_api_dml := true; -- Set the api dml status
283 --
284 -- Update the specified datetrack row setting the effective
285 -- end date to the specified new effective end date.
286 --
287 update ben_ttl_cvg_vol_rt_f t
288 set t.effective_end_date = p_new_effective_end_date,
289 t.object_version_number = l_object_version_number
290 where t.ttl_cvg_vol_rt_id = p_base_key_value
291 and p_effective_date
292 between t.effective_start_date and t.effective_end_date;
293 --
294 g_api_dml := false; -- Unset the api dml status
295 p_object_version_number := l_object_version_number;
296 hr_utility.set_location(' Leaving:'||l_proc, 15);
297 --
298 Exception
299 When Others Then
300 g_api_dml := false; -- Unset the api dml status
301 Raise;
302 End upd_effective_end_date;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< lck >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure lck
308 (p_effective_date in date,
309 p_datetrack_mode in varchar2,
310 p_ttl_cvg_vol_rt_id in number,
311 p_object_version_number in number,
312 p_validation_start_date out nocopy date,
313 p_validation_end_date out nocopy date) is
314 --
315 l_proc varchar2(72) := g_package||'lck';
316 l_validation_start_date date;
317 l_validation_end_date date;
318 l_object_invalid exception;
319 l_argument varchar2(30);
320 --
321 -- Cursor C_Sel1 selects the current locked row as of session date
322 -- ensuring that the object version numbers match.
323 --
324 Cursor C_Sel1 is
325 select
326 ttl_cvg_vol_rt_id,
327 effective_start_date,
328 effective_end_date,
329 business_group_id,
330 excld_flag,
331 no_mn_cvg_vol_amt_apls_flag,
332 no_mx_cvg_vol_amt_apls_flag,
333 ordr_num,
334 mn_cvg_vol_amt,
335 mx_cvg_vol_amt,
336 cvg_vol_det_cd,
337 cvg_vol_det_rl,
338 vrbl_rt_prfl_id,
339 tcv_attribute_category,
340 tcv_attribute1,
341 tcv_attribute2,
342 tcv_attribute3,
343 tcv_attribute4,
344 tcv_attribute5,
345 tcv_attribute6,
346 tcv_attribute7,
347 tcv_attribute8,
348 tcv_attribute9,
349 tcv_attribute10,
350 tcv_attribute11,
351 tcv_attribute12,
352 tcv_attribute13,
353 tcv_attribute14,
354 tcv_attribute15,
355 tcv_attribute16,
356 tcv_attribute17,
357 tcv_attribute18,
358 tcv_attribute19,
359 tcv_attribute20,
360 tcv_attribute21,
361 tcv_attribute22,
362 tcv_attribute23,
363 tcv_attribute24,
364 tcv_attribute25,
365 tcv_attribute26,
366 tcv_attribute27,
367 tcv_attribute28,
368 tcv_attribute29,
369 tcv_attribute30,
370 object_version_number
371 from ben_ttl_cvg_vol_rt_f
372 where ttl_cvg_vol_rt_id = p_ttl_cvg_vol_rt_id
373 and p_effective_date
377 --
374 between effective_start_date and effective_end_date
375 for update nowait;
376 --
378 --
379 Begin
380 hr_utility.set_location('Entering:'||l_proc, 5);
381 --
382 -- Ensure that all the mandatory arguments are not null
383 --
384 hr_api.mandatory_arg_error(p_api_name => l_proc,
385 p_argument => 'effective_date',
386 p_argument_value => p_effective_date);
387 --
388 hr_api.mandatory_arg_error(p_api_name => l_proc,
389 p_argument => 'datetrack_mode',
390 p_argument_value => p_datetrack_mode);
391 --
392 hr_api.mandatory_arg_error(p_api_name => l_proc,
393 p_argument => 'ttl_cvg_vol_rt_id',
394 p_argument_value => p_ttl_cvg_vol_rt_id);
395 --
396 hr_api.mandatory_arg_error(p_api_name => l_proc,
397 p_argument => 'object_version_number',
398 p_argument_value => p_object_version_number);
399 --
400 -- Check to ensure the datetrack mode is not INSERT.
401 --
402 If (p_datetrack_mode <> 'INSERT') then
403 --
404 -- We must select and lock the current row.
405 --
406 Open C_Sel1;
407 Fetch C_Sel1 Into g_old_rec;
408 If C_Sel1%notfound then
409 Close C_Sel1;
410 --
411 -- The primary key is invalid therefore we must error
412 --
413 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
414 fnd_message.raise_error;
415 End If;
416 Close C_Sel1;
417 If (p_object_version_number <> g_old_rec.object_version_number) Then
418 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
419 fnd_message.raise_error;
420 End If;
421 hr_utility.set_location(l_proc, 15);
422 --
423 --
424 -- Validate the datetrack mode mode getting the validation start
425 -- and end dates for the specified datetrack operation.
426 --
427 dt_api.validate_dt_mode
428 (p_effective_date => p_effective_date,
429 p_datetrack_mode => p_datetrack_mode,
430 p_base_table_name => 'ben_ttl_cvg_vol_rt_f',
431 p_base_key_column => 'ttl_cvg_vol_rt_id',
432 p_base_key_value => p_ttl_cvg_vol_rt_id,
433 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
434 p_parent_key_column1 => 'vrbl_rt_prfl_id',
435 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
436 p_enforce_foreign_locking => false , --true,
437 p_validation_start_date => l_validation_start_date,
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 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
446 fnd_message.set_token('PROCEDURE', l_proc);
447 fnd_message.set_token('STEP','20');
448 fnd_message.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 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
467 fnd_message.set_token('TABLE_NAME', 'ben_ttl_cvg_vol_rt_f');
468 fnd_message.raise_error;
469 When l_object_invalid then
470 --
471 -- The object doesn't exist or is invalid
472 --
473 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
474 fnd_message.set_token('TABLE_NAME', 'ben_ttl_cvg_vol_rt_f');
475 fnd_message.raise_error;
476 End lck;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |-----------------------------< convert_args >-----------------------------|
480 -- ----------------------------------------------------------------------------
481 Function convert_args
482 (
483 p_ttl_cvg_vol_rt_id in number,
484 p_effective_start_date in date,
485 p_effective_end_date in date,
486 p_business_group_id in number,
487 p_excld_flag in varchar2,
488 p_no_mn_cvg_vol_amt_apls_flag in varchar2,
489 p_no_mx_cvg_vol_amt_apls_flag in varchar2,
490 p_ordr_num in number,
491 p_mn_cvg_vol_amt in number,
492 p_mx_cvg_vol_amt in number,
493 p_cvg_vol_det_cd in varchar2,
494 p_cvg_vol_det_rl in number,
495 p_vrbl_rt_prfl_id in number,
496 p_tcv_attribute_category in varchar2,
497 p_tcv_attribute1 in varchar2,
498 p_tcv_attribute2 in varchar2,
499 p_tcv_attribute3 in varchar2,
500 p_tcv_attribute4 in varchar2,
501 p_tcv_attribute5 in varchar2,
502 p_tcv_attribute6 in varchar2,
503 p_tcv_attribute7 in varchar2,
507 p_tcv_attribute11 in varchar2,
504 p_tcv_attribute8 in varchar2,
505 p_tcv_attribute9 in varchar2,
506 p_tcv_attribute10 in varchar2,
508 p_tcv_attribute12 in varchar2,
509 p_tcv_attribute13 in varchar2,
510 p_tcv_attribute14 in varchar2,
511 p_tcv_attribute15 in varchar2,
512 p_tcv_attribute16 in varchar2,
513 p_tcv_attribute17 in varchar2,
514 p_tcv_attribute18 in varchar2,
515 p_tcv_attribute19 in varchar2,
516 p_tcv_attribute20 in varchar2,
517 p_tcv_attribute21 in varchar2,
518 p_tcv_attribute22 in varchar2,
519 p_tcv_attribute23 in varchar2,
520 p_tcv_attribute24 in varchar2,
521 p_tcv_attribute25 in varchar2,
522 p_tcv_attribute26 in varchar2,
523 p_tcv_attribute27 in varchar2,
524 p_tcv_attribute28 in varchar2,
525 p_tcv_attribute29 in varchar2,
526 p_tcv_attribute30 in varchar2,
527 p_object_version_number in number
528 )
529 Return g_rec_type is
530 --
531 l_rec g_rec_type;
535 --
532 l_proc varchar2(72) := g_package||'convert_args';
533 --
534 Begin
536 hr_utility.set_location('Entering:'||l_proc, 5);
537 --
538 -- Convert arguments into local l_rec structure.
539 --
540 l_rec.ttl_cvg_vol_rt_id := p_ttl_cvg_vol_rt_id;
541 l_rec.effective_start_date := p_effective_start_date;
542 l_rec.effective_end_date := p_effective_end_date;
543 l_rec.business_group_id := p_business_group_id;
544 l_rec.excld_flag := p_excld_flag;
545 l_rec.no_mn_cvg_vol_amt_apls_flag := p_no_mn_cvg_vol_amt_apls_flag;
546 l_rec.no_mx_cvg_vol_amt_apls_flag := p_no_mx_cvg_vol_amt_apls_flag;
547 l_rec.ordr_num := p_ordr_num;
548 l_rec.mn_cvg_vol_amt := p_mn_cvg_vol_amt;
549 l_rec.mx_cvg_vol_amt := p_mx_cvg_vol_amt;
550 l_rec.cvg_vol_det_cd := p_cvg_vol_det_cd;
551 l_rec.cvg_vol_det_rl := p_cvg_vol_det_rl;
552 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
553 l_rec.tcv_attribute_category := p_tcv_attribute_category;
554 l_rec.tcv_attribute1 := p_tcv_attribute1;
555 l_rec.tcv_attribute2 := p_tcv_attribute2;
556 l_rec.tcv_attribute3 := p_tcv_attribute3;
557 l_rec.tcv_attribute4 := p_tcv_attribute4;
558 l_rec.tcv_attribute5 := p_tcv_attribute5;
559 l_rec.tcv_attribute6 := p_tcv_attribute6;
560 l_rec.tcv_attribute7 := p_tcv_attribute7;
561 l_rec.tcv_attribute8 := p_tcv_attribute8;
562 l_rec.tcv_attribute9 := p_tcv_attribute9;
563 l_rec.tcv_attribute10 := p_tcv_attribute10;
564 l_rec.tcv_attribute11 := p_tcv_attribute11;
565 l_rec.tcv_attribute12 := p_tcv_attribute12;
566 l_rec.tcv_attribute13 := p_tcv_attribute13;
567 l_rec.tcv_attribute14 := p_tcv_attribute14;
568 l_rec.tcv_attribute15 := p_tcv_attribute15;
569 l_rec.tcv_attribute16 := p_tcv_attribute16;
570 l_rec.tcv_attribute17 := p_tcv_attribute17;
571 l_rec.tcv_attribute18 := p_tcv_attribute18;
572 l_rec.tcv_attribute19 := p_tcv_attribute19;
573 l_rec.tcv_attribute20 := p_tcv_attribute20;
574 l_rec.tcv_attribute21 := p_tcv_attribute21;
575 l_rec.tcv_attribute22 := p_tcv_attribute22;
576 l_rec.tcv_attribute23 := p_tcv_attribute23;
577 l_rec.tcv_attribute24 := p_tcv_attribute24;
578 l_rec.tcv_attribute25 := p_tcv_attribute25;
579 l_rec.tcv_attribute26 := p_tcv_attribute26;
580 l_rec.tcv_attribute27 := p_tcv_attribute27;
581 l_rec.tcv_attribute28 := p_tcv_attribute28;
582 l_rec.tcv_attribute29 := p_tcv_attribute29;
583 l_rec.tcv_attribute30 := p_tcv_attribute30;
584 l_rec.object_version_number := p_object_version_number;
585 --
586 -- Return the plsql record structure.
587 --
588 hr_utility.set_location(' Leaving:'||l_proc, 10);
589 Return(l_rec);
590 --
591 End convert_args;
592 --
593 end ben_tcv_shd;