[Home] [Help]
PACKAGE BODY: APPS.BEN_VGS_SHD
Source
1 Package Body ben_vgs_shd as
2 /* $Header: bevgsrhi.pkb 120.0.12010000.2 2008/08/05 15:33:59 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_vgs_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_PL_GD_OR_SVC_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_PL_GD_OR_SVC_FK2') 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 ElsIf (p_constraint_name = 'BEN_PL_GD_OR_SVC_PK') Then
47 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
48 hr_utility.set_message_token('PROCEDURE', l_proc);
49 hr_utility.set_message_token('STEP','15');
50 hr_utility.raise_error;
51 Else
52 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
53 hr_utility.set_message_token('PROCEDURE', l_proc);
54 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
55 hr_utility.raise_error;
56 End If;
57 --
58 hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65 (p_effective_date in date,
66 p_pl_gd_or_svc_id in number,
67 p_object_version_number in number
68 ) Return Boolean Is
69 --
70 --
71 -- Cursor selects the 'current' row from the HR Schema
72 --
73 Cursor C_Sel1 is
74 select
75 pl_gd_or_svc_id,
76 effective_start_date,
77 effective_end_date,
78 business_group_id,
79 pl_id,
80 gd_or_svc_typ_id,
81 alw_rcrrg_clms_flag,
82 gd_or_svc_usg_cd,
83 vgs_attribute_category,
84 vgs_attribute1,
85 vgs_attribute2,
86 vgs_attribute3,
87 vgs_attribute4,
88 vgs_attribute5,
89 vgs_attribute6,
90 vgs_attribute7,
91 vgs_attribute8,
92 vgs_attribute9,
93 vgs_attribute10,
94 vgs_attribute11,
95 vgs_attribute12,
96 vgs_attribute13,
97 vgs_attribute14,
98 vgs_attribute15,
99 vgs_attribute16,
100 vgs_attribute17,
101 vgs_attribute18,
102 vgs_attribute19,
103 vgs_attribute20,
104 vgs_attribute21,
105 vgs_attribute22,
106 vgs_attribute23,
107 vgs_attribute24,
108 vgs_attribute25,
109 vgs_attribute26,
110 vgs_attribute27,
111 vgs_attribute28,
112 vgs_attribute29,
113 vgs_attribute30,
114 object_version_number,
115 gd_svc_recd_basis_cd ,
116 gd_svc_recd_basis_dt ,
117 gd_svc_recd_basis_mo
118 from ben_pl_gd_or_svc_f
119 where pl_gd_or_svc_id = p_pl_gd_or_svc_id
120 and p_effective_date
121 between effective_start_date and effective_end_date;
122 --
123 l_proc varchar2(72) := g_package||'api_updating';
124 l_fct_ret boolean;
125 --
126 Begin
127 hr_utility.set_location('Entering:'||l_proc, 5);
128 --
129 If (p_effective_date is null or
130 p_pl_gd_or_svc_id is null or
131 p_object_version_number is null) Then
132 --
133 -- One of the primary key arguments is null therefore we must
134 -- set the returning function value to false
135 --
136 l_fct_ret := false;
137 Else
138 If (p_pl_gd_or_svc_id = g_old_rec.pl_gd_or_svc_id and
139 p_object_version_number = g_old_rec.object_version_number) Then
140 hr_utility.set_location(l_proc, 10);
141 --
142 -- The g_old_rec is current therefore we must
143 -- set the returning function to true
144 --
145 l_fct_ret := true;
146 Else
147 --
148 -- Select the current row
149 --
150 Open C_Sel1;
151 Fetch C_Sel1 Into g_old_rec;
152 If C_Sel1%notfound Then
153 Close C_Sel1;
154 --
155 -- The primary key is invalid therefore we must error
156 --
157 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
158 hr_utility.raise_error;
159 End If;
160 Close C_Sel1;
161 If (p_object_version_number <> g_old_rec.object_version_number) Then
162 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
163 hr_utility.raise_error;
164 End If;
165 hr_utility.set_location(l_proc, 15);
166 l_fct_ret := true;
167 End If;
168 End If;
169 hr_utility.set_location(' Leaving:'||l_proc, 20);
170 Return (l_fct_ret);
171 --
172 End api_updating;
173 --
174 -- ----------------------------------------------------------------------------
175 -- |--------------------------< find_dt_del_modes >---------------------------|
176 -- ----------------------------------------------------------------------------
177 Procedure find_dt_del_modes
178 (p_effective_date in date,
179 p_base_key_value in number,
180 p_zap out nocopy boolean,
181 p_delete out nocopy boolean,
182 p_future_change out nocopy boolean,
183 p_delete_next_change out nocopy boolean) is
184 --
185 l_proc varchar2(72) := g_package||'find_dt_del_modes';
186 --
187 l_parent_key_value1 number;
188 --
189 Cursor C_Sel1 Is
190 select t.pl_id
191 from ben_pl_gd_or_svc_f t
192 where t.pl_gd_or_svc_id = p_base_key_value
193 and p_effective_date
194 between t.effective_start_date and t.effective_end_date;
195 --
196 Begin
197 hr_utility.set_location('Entering:'||l_proc, 5);
198 Open C_Sel1;
199 Fetch C_Sel1 Into l_parent_key_value1;
200 If C_Sel1%notfound then
201 Close C_Sel1;
202 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
203 hr_utility.set_message_token('PROCEDURE', l_proc);
204 hr_utility.set_message_token('STEP','10');
205 hr_utility.raise_error;
206 End If;
207 Close C_Sel1;
208 --
209 -- Call the corresponding datetrack api
210 --
211 dt_api.find_dt_del_modes
212 (p_effective_date => p_effective_date,
213 p_base_table_name => 'ben_pl_gd_or_svc_f',
214 p_base_key_column => 'pl_gd_or_svc_id',
215 p_base_key_value => p_base_key_value,
216 p_parent_table_name1 => 'ben_pl_f',
217 p_parent_key_column1 => 'pl_id',
218 p_parent_key_value1 => l_parent_key_value1,
219 p_zap => p_zap,
220 p_delete => p_delete,
221 p_future_change => p_future_change,
222 p_delete_next_change => p_delete_next_change);
223 --
224 hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End find_dt_del_modes;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |--------------------------< find_dt_upd_modes >---------------------------|
229 -- ----------------------------------------------------------------------------
230 Procedure find_dt_upd_modes
231 (p_effective_date in date,
232 p_base_key_value in number,
233 p_correction out nocopy boolean,
234 p_update out nocopy boolean,
235 p_update_override out nocopy boolean,
236 p_update_change_insert out nocopy boolean) is
237 --
238 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
239 --
240 Begin
241 hr_utility.set_location('Entering:'||l_proc, 5);
242 --
243 -- Call the corresponding datetrack api
244 --
245 dt_api.find_dt_upd_modes
246 (p_effective_date => p_effective_date,
247 p_base_table_name => 'ben_pl_gd_or_svc_f',
248 p_base_key_column => 'pl_gd_or_svc_id',
249 p_base_key_value => p_base_key_value,
250 p_correction => p_correction,
251 p_update => p_update,
252 p_update_override => p_update_override,
253 p_update_change_insert => p_update_change_insert);
254 --
255 hr_utility.set_location(' Leaving:'||l_proc, 10);
256 End find_dt_upd_modes;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |------------------------< upd_effective_end_date >------------------------|
260 -- ----------------------------------------------------------------------------
261 Procedure upd_effective_end_date
262 (p_effective_date in date,
263 p_base_key_value in number,
264 p_new_effective_end_date in date,
265 p_validation_start_date in date,
266 p_validation_end_date in date,
267 p_object_version_number out nocopy number) is
268 --
269 l_proc varchar2(72) := g_package||'upd_effective_end_date';
270 l_object_version_number number;
271 --
272 Begin
273 hr_utility.set_location('Entering:'||l_proc, 5);
274 --
275 -- Because we are updating a row we must get the next object
276 -- version number.
277 --
278 l_object_version_number :=
279 dt_api.get_object_version_number
280 (p_base_table_name => 'ben_pl_gd_or_svc_f',
281 p_base_key_column => 'pl_gd_or_svc_id',
282 p_base_key_value => p_base_key_value);
283 --
284 hr_utility.set_location(l_proc, 10);
285 g_api_dml := true; -- Set the api dml status
286 --
287 -- Update the specified datetrack row setting the effective
288 -- end date to the specified new effective end date.
289 --
290 update ben_pl_gd_or_svc_f t
291 set t.effective_end_date = p_new_effective_end_date,
292 t.object_version_number = l_object_version_number
293 where t.pl_gd_or_svc_id = p_base_key_value
294 and p_effective_date
295 between t.effective_start_date and t.effective_end_date;
296 --
297 g_api_dml := false; -- Unset the api dml status
298 p_object_version_number := l_object_version_number;
299 hr_utility.set_location(' Leaving:'||l_proc, 15);
300 --
301 Exception
302 When Others Then
303 g_api_dml := false; -- Unset the api dml status
304 Raise;
305 End upd_effective_end_date;
306 --
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------------< lck >----------------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure lck
311 (p_effective_date in date,
312 p_datetrack_mode in varchar2,
313 p_pl_gd_or_svc_id in number,
314 p_object_version_number in number,
315 p_validation_start_date out nocopy date,
316 p_validation_end_date out nocopy date) is
317 --
318 l_proc varchar2(72) := g_package||'lck';
319 l_validation_start_date date;
320 l_validation_end_date date;
321 l_object_invalid exception;
322 l_argument varchar2(30);
323 --
324 -- Cursor C_Sel1 selects the current locked row as of session date
325 -- ensuring that the object version numbers match.
326 --
327 Cursor C_Sel1 is
328 select
329 pl_gd_or_svc_id,
330 effective_start_date,
331 effective_end_date,
332 business_group_id,
333 pl_id,
334 gd_or_svc_typ_id,
335 alw_rcrrg_clms_flag,
336 gd_or_svc_usg_cd,
337 vgs_attribute_category,
338 vgs_attribute1,
339 vgs_attribute2,
340 vgs_attribute3,
341 vgs_attribute4,
342 vgs_attribute5,
343 vgs_attribute6,
344 vgs_attribute7,
345 vgs_attribute8,
346 vgs_attribute9,
347 vgs_attribute10,
348 vgs_attribute11,
349 vgs_attribute12,
350 vgs_attribute13,
351 vgs_attribute14,
352 vgs_attribute15,
353 vgs_attribute16,
354 vgs_attribute17,
355 vgs_attribute18,
356 vgs_attribute19,
357 vgs_attribute20,
358 vgs_attribute21,
359 vgs_attribute22,
360 vgs_attribute23,
361 vgs_attribute24,
362 vgs_attribute25,
363 vgs_attribute26,
364 vgs_attribute27,
365 vgs_attribute28,
366 vgs_attribute29,
367 vgs_attribute30,
368 object_version_number ,
369 gd_svc_recd_basis_cd ,
370 gd_svc_recd_basis_dt ,
371 gd_svc_recd_basis_mo
372 from ben_pl_gd_or_svc_f
373 where pl_gd_or_svc_id = p_pl_gd_or_svc_id
374 and p_effective_date
375 between effective_start_date and effective_end_date
376 for update nowait;
377 --
378 --
379 --
380 Begin
381 hr_utility.set_location('Entering:'||l_proc, 5);
382 --
383 -- Ensure that all the mandatory arguments are not null
384 --
385 hr_api.mandatory_arg_error(p_api_name => l_proc,
386 p_argument => 'effective_date',
387 p_argument_value => p_effective_date);
388 --
389 hr_api.mandatory_arg_error(p_api_name => l_proc,
390 p_argument => 'datetrack_mode',
391 p_argument_value => p_datetrack_mode);
392 --
393 hr_api.mandatory_arg_error(p_api_name => l_proc,
394 p_argument => 'pl_gd_or_svc_id',
395 p_argument_value => p_pl_gd_or_svc_id);
396 --
397 hr_api.mandatory_arg_error(p_api_name => l_proc,
398 p_argument => 'object_version_number',
399 p_argument_value => p_object_version_number);
400 --
401 -- Check to ensure the datetrack mode is not INSERT.
402 --
403 If (p_datetrack_mode <> 'INSERT') then
404 --
405 -- We must select and lock the current row.
406 --
407 Open C_Sel1;
408 Fetch C_Sel1 Into g_old_rec;
409 If C_Sel1%notfound then
410 Close C_Sel1;
411 --
412 -- The primary key is invalid therefore we must error
413 --
414 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
415 hr_utility.raise_error;
416 End If;
417 Close C_Sel1;
418 If (p_object_version_number <> g_old_rec.object_version_number) Then
419 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
420 hr_utility.raise_error;
421 End If;
422 hr_utility.set_location(l_proc, 15);
423 --
424 --
425 -- Validate the datetrack mode mode getting the validation start
426 -- and end dates for the specified datetrack operation.
427 --
428 dt_api.validate_dt_mode
429 (p_effective_date => p_effective_date,
430 p_datetrack_mode => p_datetrack_mode,
431 p_base_table_name => 'ben_pl_gd_or_svc_f',
432 p_base_key_column => 'pl_gd_or_svc_id',
436 p_parent_key_value1 => g_old_rec.pl_id,
433 p_base_key_value => p_pl_gd_or_svc_id,
434 p_parent_table_name1 => 'ben_pl_f',
435 p_parent_key_column1 => 'pl_id',
437 p_child_table_name1 => 'ben_pl_gd_r_svc_ctfn_f',
438 p_child_key_column1 => 'pl_gd_r_svc_ctfn_id',
439 p_enforce_foreign_locking => false , --true,
440 p_validation_start_date => l_validation_start_date,
441 p_validation_end_date => l_validation_end_date);
442 Else
443 --
444 -- We are doing a datetrack 'INSERT' which is illegal within this
445 -- procedure therefore we must error (note: to lck on insert the
446 -- private procedure ins_lck should be called).
447 --
448 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
449 hr_utility.set_message_token('PROCEDURE', l_proc);
450 hr_utility.set_message_token('STEP','20');
451 hr_utility.raise_error;
452 End If;
453 --
454 -- Set the validation start and end date OUT arguments
455 --
456 p_validation_start_date := l_validation_start_date;
457 p_validation_end_date := l_validation_end_date;
458 --
459 hr_utility.set_location(' Leaving:'||l_proc, 30);
460 --
461 -- We need to trap the ORA LOCK exception
462 --
463 Exception
464 When HR_Api.Object_Locked then
465 --
466 -- The object is locked therefore we need to supply a meaningful
467 -- error message.
468 --
469 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
470 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_gd_or_svc_f');
471 hr_utility.raise_error;
472 When l_object_invalid then
473 --
474 -- The object doesn't exist or is invalid
475 --
476 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
477 hr_utility.set_message_token('TABLE_NAME', 'ben_pl_gd_or_svc_f');
478 hr_utility.raise_error;
479 End lck;
480 --
481 -- ----------------------------------------------------------------------------
482 -- |-----------------------------< convert_args >-----------------------------|
483 -- ----------------------------------------------------------------------------
484 Function convert_args
485 (
486 p_pl_gd_or_svc_id in number,
487 p_effective_start_date in date,
488 p_effective_end_date in date,
489 p_business_group_id in number,
490 p_pl_id in number,
491 p_gd_or_svc_typ_id in number,
492 p_alw_rcrrg_clms_flag in varchar2,
493 p_gd_or_svc_usg_cd in varchar2,
494 p_vgs_attribute_category in varchar2,
495 p_vgs_attribute1 in varchar2,
496 p_vgs_attribute2 in varchar2,
497 p_vgs_attribute3 in varchar2,
498 p_vgs_attribute4 in varchar2,
499 p_vgs_attribute5 in varchar2,
500 p_vgs_attribute6 in varchar2,
501 p_vgs_attribute7 in varchar2,
502 p_vgs_attribute8 in varchar2,
503 p_vgs_attribute9 in varchar2,
504 p_vgs_attribute10 in varchar2,
505 p_vgs_attribute11 in varchar2,
506 p_vgs_attribute12 in varchar2,
507 p_vgs_attribute13 in varchar2,
508 p_vgs_attribute14 in varchar2,
509 p_vgs_attribute15 in varchar2,
510 p_vgs_attribute16 in varchar2,
511 p_vgs_attribute17 in varchar2,
512 p_vgs_attribute18 in varchar2,
513 p_vgs_attribute19 in varchar2,
514 p_vgs_attribute20 in varchar2,
515 p_vgs_attribute21 in varchar2,
516 p_vgs_attribute22 in varchar2,
517 p_vgs_attribute23 in varchar2,
518 p_vgs_attribute24 in varchar2,
519 p_vgs_attribute25 in varchar2,
520 p_vgs_attribute26 in varchar2,
521 p_vgs_attribute27 in varchar2,
522 p_vgs_attribute28 in varchar2,
523 p_vgs_attribute29 in varchar2,
524 p_vgs_attribute30 in varchar2,
525 p_object_version_number in number ,
526 p_gd_svc_recd_basis_cd in varchar2,
527 p_gd_svc_recd_basis_dt in date,
528 p_gd_svc_recd_basis_mo in number
529 )
530 Return g_rec_type is
531 --
532 l_rec g_rec_type;
533 l_proc varchar2(72) := g_package||'convert_args';
534 --
535 Begin
536 --
537 hr_utility.set_location('Entering:'||l_proc, 5);
538 --
539 -- Convert arguments into local l_rec structure.
540 --
541 l_rec.pl_gd_or_svc_id := p_pl_gd_or_svc_id;
542 l_rec.effective_start_date := p_effective_start_date;
543 l_rec.effective_end_date := p_effective_end_date;
544 l_rec.business_group_id := p_business_group_id;
545 l_rec.pl_id := p_pl_id;
546 l_rec.gd_or_svc_typ_id := p_gd_or_svc_typ_id;
547 l_rec.alw_rcrrg_clms_flag := p_alw_rcrrg_clms_flag;
548 l_rec.gd_or_svc_usg_cd := p_gd_or_svc_usg_cd;
549 l_rec.vgs_attribute_category := p_vgs_attribute_category;
550 l_rec.vgs_attribute1 := p_vgs_attribute1;
551 l_rec.vgs_attribute2 := p_vgs_attribute2;
552 l_rec.vgs_attribute3 := p_vgs_attribute3;
553 l_rec.vgs_attribute4 := p_vgs_attribute4;
554 l_rec.vgs_attribute5 := p_vgs_attribute5;
555 l_rec.vgs_attribute6 := p_vgs_attribute6;
556 l_rec.vgs_attribute7 := p_vgs_attribute7;
557 l_rec.vgs_attribute8 := p_vgs_attribute8;
558 l_rec.vgs_attribute9 := p_vgs_attribute9;
559 l_rec.vgs_attribute10 := p_vgs_attribute10;
560 l_rec.vgs_attribute11 := p_vgs_attribute11;
561 l_rec.vgs_attribute12 := p_vgs_attribute12;
562 l_rec.vgs_attribute13 := p_vgs_attribute13;
563 l_rec.vgs_attribute14 := p_vgs_attribute14;
564 l_rec.vgs_attribute15 := p_vgs_attribute15;
565 l_rec.vgs_attribute16 := p_vgs_attribute16;
566 l_rec.vgs_attribute17 := p_vgs_attribute17;
567 l_rec.vgs_attribute18 := p_vgs_attribute18;
568 l_rec.vgs_attribute19 := p_vgs_attribute19;
569 l_rec.vgs_attribute20 := p_vgs_attribute20;
570 l_rec.vgs_attribute21 := p_vgs_attribute21;
571 l_rec.vgs_attribute22 := p_vgs_attribute22;
572 l_rec.vgs_attribute23 := p_vgs_attribute23;
573 l_rec.vgs_attribute24 := p_vgs_attribute24;
574 l_rec.vgs_attribute25 := p_vgs_attribute25;
575 l_rec.vgs_attribute26 := p_vgs_attribute26;
576 l_rec.vgs_attribute27 := p_vgs_attribute27;
577 l_rec.vgs_attribute28 := p_vgs_attribute28;
578 l_rec.vgs_attribute29 := p_vgs_attribute29;
579 l_rec.vgs_attribute30 := p_vgs_attribute30;
580 l_rec.object_version_number := p_object_version_number;
581 l_rec.gd_svc_recd_basis_cd := p_gd_svc_recd_basis_cd;
582 l_rec.gd_svc_recd_basis_dt := p_gd_svc_recd_basis_dt;
583 l_rec.gd_svc_recd_basis_mo := p_gd_svc_recd_basis_mo ;
584
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_vgs_shd;