[Home] [Help]
PACKAGE BODY: APPS.BEN_WCT_SHD
Source
1 Package Body ben_wct_shd as
2 /* $Header: bewctrhi.pkb 120.0.12010000.2 2008/08/05 15:46:41 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_wct_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_WV_PRTN_RSN_CTFN_PTIP_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_wv_prtn_rsn_ctfn_ptip_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 wv_prtn_rsn_ctfn_ptip_id,
66 effective_start_date,
67 effective_end_date,
68 wv_prtn_ctfn_cd,
69 wv_prtn_rsn_ptip_id,
70 lack_ctfn_sspnd_wvr_flag,
71 rqd_flag,
72 ctfn_rqd_when_rl,
73 pfd_flag,
74 wv_prtn_ctfn_typ_cd,
75 business_group_id,
76 wct_attribute_category,
77 wct_attribute1,
78 wct_attribute2,
79 wct_attribute3,
80 wct_attribute4,
81 wct_attribute5,
82 wct_attribute6,
83 wct_attribute7,
84 wct_attribute8,
85 wct_attribute9,
86 wct_attribute10,
87 wct_attribute11,
88 wct_attribute12,
89 wct_attribute13,
90 wct_attribute14,
91 wct_attribute15,
92 wct_attribute16,
93 wct_attribute17,
94 wct_attribute18,
95 wct_attribute19,
96 wct_attribute20,
97 wct_attribute21,
98 wct_attribute22,
99 wct_attribute23,
100 wct_attribute24,
101 wct_attribute25,
102 wct_attribute26,
103 wct_attribute27,
104 wct_attribute28,
105 wct_attribute29,
106 wct_attribute30,
107 object_version_number
108 from ben_wv_prtn_rsn_ctfn_ptip_f
109 where wv_prtn_rsn_ctfn_ptip_id = p_wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_id = g_old_rec.wv_prtn_rsn_ctfn_ptip_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.ctfn_rqd_when_rl,
182 t.wv_prtn_rsn_ptip_id
183 from ben_wv_prtn_rsn_ctfn_ptip_f t
184 where t.wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_f',
207 p_base_key_column => 'wv_prtn_rsn_ctfn_ptip_id',
208 p_base_key_value => p_base_key_value,
209 p_parent_table_name1 => 'ff_formulas_f',
210 p_parent_key_column1 => 'formula_id',
211 p_parent_key_value1 => l_parent_key_value1,
212 p_parent_table_name2 => 'ben_wv_prtn_rsn_ptip_f',
213 p_parent_key_column2 => 'wv_prtn_rsn_ptip_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_wv_prtn_rsn_ctfn_ptip_f',
244 p_base_key_column => 'wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_f',
277 p_base_key_column => 'wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_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.wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_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 wv_prtn_rsn_ctfn_ptip_id,
326 effective_start_date,
327 effective_end_date,
328 wv_prtn_ctfn_cd,
329 wv_prtn_rsn_ptip_id,
330 lack_ctfn_sspnd_wvr_flag,
331 rqd_flag,
332 ctfn_rqd_when_rl,
333 pfd_flag,
334 wv_prtn_ctfn_typ_cd,
335 business_group_id,
336 wct_attribute_category,
337 wct_attribute1,
338 wct_attribute2,
339 wct_attribute3,
340 wct_attribute4,
341 wct_attribute5,
342 wct_attribute6,
343 wct_attribute7,
344 wct_attribute8,
345 wct_attribute9,
346 wct_attribute10,
347 wct_attribute11,
348 wct_attribute12,
349 wct_attribute13,
350 wct_attribute14,
351 wct_attribute15,
352 wct_attribute16,
353 wct_attribute17,
354 wct_attribute18,
355 wct_attribute19,
356 wct_attribute20,
357 wct_attribute21,
358 wct_attribute22,
359 wct_attribute23,
360 wct_attribute24,
361 wct_attribute25,
362 wct_attribute26,
363 wct_attribute27,
364 wct_attribute28,
365 wct_attribute29,
366 wct_attribute30,
367 object_version_number
368 from ben_wv_prtn_rsn_ctfn_ptip_f
369 where wv_prtn_rsn_ctfn_ptip_id = p_wv_prtn_rsn_ctfn_ptip_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
383 p_argument_value => p_effective_date);
380 --
381 hr_api.mandatory_arg_error(p_api_name => l_proc,
382 p_argument => '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 => 'wv_prtn_rsn_ctfn_ptip_id',
391 p_argument_value => p_wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_f',
428 p_base_key_column => 'wv_prtn_rsn_ctfn_ptip_id',
429 p_base_key_value => p_wv_prtn_rsn_ctfn_ptip_id,
430 p_parent_table_name1 => 'ff_formulas_f',
431 p_parent_key_column1 => 'formula_id',
432 p_parent_key_value1 => g_old_rec.ctfn_rqd_when_rl,
433 p_parent_table_name2 => 'ben_wv_prtn_rsn_ptip_f',
434 p_parent_key_column2 => 'wv_prtn_rsn_ptip_id',
435 p_parent_key_value2 => g_old_rec.wv_prtn_rsn_ptip_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 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_wv_prtn_rsn_ctfn_ptip_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_wv_prtn_rsn_ctfn_ptip_f');
475 hr_utility.raise_error;
476 End lck;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |-----------------------------< convert_args >-----------------------------|
480 -- ----------------------------------------------------------------------------
481 Function convert_args
482 (
483 p_wv_prtn_rsn_ctfn_ptip_id in number,
484 p_effective_start_date in date,
485 p_effective_end_date in date,
486 p_wv_prtn_ctfn_cd in varchar2,
487 p_wv_prtn_rsn_ptip_id in number,
488 p_lack_ctfn_sspnd_wvr_flag in varchar2,
489 p_rqd_flag in varchar2,
490 p_ctfn_rqd_when_rl in number,
491 p_pfd_flag in varchar2,
492 p_wv_prtn_ctfn_typ_cd in varchar2,
493 p_business_group_id in number,
494 p_wct_attribute_category in varchar2,
495 p_wct_attribute1 in varchar2,
496 p_wct_attribute2 in varchar2,
497 p_wct_attribute3 in varchar2,
498 p_wct_attribute4 in varchar2,
499 p_wct_attribute5 in varchar2,
500 p_wct_attribute6 in varchar2,
501 p_wct_attribute7 in varchar2,
502 p_wct_attribute8 in varchar2,
503 p_wct_attribute9 in varchar2,
504 p_wct_attribute10 in varchar2,
505 p_wct_attribute11 in varchar2,
506 p_wct_attribute12 in varchar2,
507 p_wct_attribute13 in varchar2,
508 p_wct_attribute14 in varchar2,
509 p_wct_attribute15 in varchar2,
510 p_wct_attribute16 in varchar2,
511 p_wct_attribute17 in varchar2,
512 p_wct_attribute18 in varchar2,
513 p_wct_attribute19 in varchar2,
514 p_wct_attribute20 in varchar2,
515 p_wct_attribute21 in varchar2,
516 p_wct_attribute22 in varchar2,
517 p_wct_attribute23 in varchar2,
518 p_wct_attribute24 in varchar2,
519 p_wct_attribute25 in varchar2,
520 p_wct_attribute26 in varchar2,
521 p_wct_attribute27 in varchar2,
522 p_wct_attribute28 in varchar2,
523 p_wct_attribute29 in varchar2,
524 p_wct_attribute30 in varchar2,
525 p_object_version_number in number
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.wv_prtn_rsn_ctfn_ptip_id := p_wv_prtn_rsn_ctfn_ptip_id;
539 l_rec.effective_start_date := p_effective_start_date;
540 l_rec.effective_end_date := p_effective_end_date;
541 l_rec.wv_prtn_ctfn_cd := p_wv_prtn_ctfn_cd;
542 l_rec.wv_prtn_rsn_ptip_id := p_wv_prtn_rsn_ptip_id;
543 l_rec.lack_ctfn_sspnd_wvr_flag := p_lack_ctfn_sspnd_wvr_flag;
544 l_rec.rqd_flag := p_rqd_flag;
545 l_rec.ctfn_rqd_when_rl := p_ctfn_rqd_when_rl;
546 l_rec.pfd_flag := p_pfd_flag;
547 l_rec.wv_prtn_ctfn_typ_cd := p_wv_prtn_ctfn_typ_cd;
548 l_rec.business_group_id := p_business_group_id;
549 l_rec.wct_attribute_category := p_wct_attribute_category;
550 l_rec.wct_attribute1 := p_wct_attribute1;
551 l_rec.wct_attribute2 := p_wct_attribute2;
552 l_rec.wct_attribute3 := p_wct_attribute3;
553 l_rec.wct_attribute4 := p_wct_attribute4;
554 l_rec.wct_attribute5 := p_wct_attribute5;
555 l_rec.wct_attribute6 := p_wct_attribute6;
556 l_rec.wct_attribute7 := p_wct_attribute7;
557 l_rec.wct_attribute8 := p_wct_attribute8;
558 l_rec.wct_attribute9 := p_wct_attribute9;
559 l_rec.wct_attribute10 := p_wct_attribute10;
560 l_rec.wct_attribute11 := p_wct_attribute11;
561 l_rec.wct_attribute12 := p_wct_attribute12;
562 l_rec.wct_attribute13 := p_wct_attribute13;
563 l_rec.wct_attribute14 := p_wct_attribute14;
564 l_rec.wct_attribute15 := p_wct_attribute15;
565 l_rec.wct_attribute16 := p_wct_attribute16;
566 l_rec.wct_attribute17 := p_wct_attribute17;
567 l_rec.wct_attribute18 := p_wct_attribute18;
568 l_rec.wct_attribute19 := p_wct_attribute19;
569 l_rec.wct_attribute20 := p_wct_attribute20;
570 l_rec.wct_attribute21 := p_wct_attribute21;
571 l_rec.wct_attribute22 := p_wct_attribute22;
572 l_rec.wct_attribute23 := p_wct_attribute23;
573 l_rec.wct_attribute24 := p_wct_attribute24;
574 l_rec.wct_attribute25 := p_wct_attribute25;
575 l_rec.wct_attribute26 := p_wct_attribute26;
576 l_rec.wct_attribute27 := p_wct_attribute27;
577 l_rec.wct_attribute28 := p_wct_attribute28;
578 l_rec.wct_attribute29 := p_wct_attribute29;
579 l_rec.wct_attribute30 := p_wct_attribute30;
580 l_rec.object_version_number := p_object_version_number;
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_wct_shd;