[Home] [Help]
PACKAGE BODY: APPS.BEN_PPE_SHD
Source
1 Package Body ben_ppe_shd as
2 /* $Header: bepperhi.pkb 120.0 2005/05/28 10:57:37 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_ppe_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_PRTT_PREM_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_prtt_prem_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 prtt_prem_id,
66 effective_start_date,
67 effective_end_date,
68 std_prem_uom,
69 std_prem_val,
70 actl_prem_id,
71 prtt_enrt_rslt_id,
72 per_in_ler_id,
73 business_group_id,
74 ppe_attribute_category,
75 ppe_attribute1,
76 ppe_attribute2,
77 ppe_attribute3,
78 ppe_attribute4,
79 ppe_attribute5,
80 ppe_attribute6,
81 ppe_attribute7,
82 ppe_attribute8,
83 ppe_attribute9,
84 ppe_attribute10,
85 ppe_attribute11,
86 ppe_attribute12,
87 ppe_attribute13,
88 ppe_attribute14,
89 ppe_attribute15,
90 ppe_attribute16,
91 ppe_attribute17,
92 ppe_attribute18,
93 ppe_attribute19,
94 ppe_attribute20,
95 ppe_attribute21,
96 ppe_attribute22,
97 ppe_attribute23,
98 ppe_attribute24,
99 ppe_attribute25,
100 ppe_attribute26,
101 ppe_attribute27,
102 ppe_attribute28,
103 ppe_attribute29,
104 ppe_attribute30,
105 object_version_number,
106 request_id,
107 program_application_id,
108 program_id,
109 program_update_date
110 from ben_prtt_prem_f
111 where prtt_prem_id = p_prtt_prem_id
112 and p_effective_date
113 between effective_start_date and effective_end_date;
114 --
115 l_proc varchar2(72) := g_package||'api_updating';
116 l_fct_ret boolean;
117 --
118 Begin
119 hr_utility.set_location('Entering:'||l_proc, 5);
120 --
121 If (p_effective_date is null or
122 p_prtt_prem_id is null or
123 p_object_version_number is null) Then
124 --
125 -- One of the primary key arguments is null therefore we must
126 -- set the returning function value to false
127 --
128 l_fct_ret := false;
129 Else
130 If (p_prtt_prem_id = g_old_rec.prtt_prem_id and
131 p_object_version_number = g_old_rec.object_version_number) Then
132 hr_utility.set_location(l_proc, 10);
133 --
134 -- The g_old_rec is current therefore we must
135 -- set the returning function to true
136 --
137 l_fct_ret := true;
138 Else
139 --
140 -- Select the current row
141 --
142 Open C_Sel1;
143 Fetch C_Sel1 Into g_old_rec;
144 If C_Sel1%notfound Then
145 Close C_Sel1;
146 --
147 -- The primary key is invalid therefore we must error
148 --
149 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
150 fnd_message.raise_error;
151 End If;
152 Close C_Sel1;
153 If (p_object_version_number <> g_old_rec.object_version_number) Then
154 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
158 l_fct_ret := true;
155 fnd_message.raise_error;
156 End If;
157 hr_utility.set_location(l_proc, 15);
159 End If;
160 End If;
161 hr_utility.set_location(' Leaving:'||l_proc, 20);
162 Return (l_fct_ret);
163 --
164 End api_updating;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |--------------------------< find_dt_del_modes >---------------------------|
168 -- ----------------------------------------------------------------------------
169 Procedure find_dt_del_modes
170 (p_effective_date in date,
171 p_base_key_value in number,
172 p_zap out nocopy boolean,
173 p_delete out nocopy boolean,
174 p_future_change out nocopy boolean,
175 p_delete_next_change out nocopy boolean) is
176 --
177 l_proc varchar2(72) := g_package||'find_dt_del_modes';
178 --
179 l_parent_key_value1 number;
180 l_parent_key_value2 number;
181 --
182 Cursor C_Sel1 Is
183 select t.actl_prem_id,
184 t.prtt_enrt_rslt_id
185 from ben_prtt_prem_f t
186 where t.prtt_prem_id = p_base_key_value
187 and p_effective_date
188 between t.effective_start_date and t.effective_end_date;
189 --
190 Begin
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 Open C_Sel1;
193 Fetch C_Sel1 Into l_parent_key_value1,
194 l_parent_key_value2;
195 If C_Sel1%notfound then
196 Close C_Sel1;
197 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
198 fnd_message.set_token('PROCEDURE', l_proc);
199 fnd_message.set_token('STEP','10');
200 fnd_message.raise_error;
201 End If;
202 Close C_Sel1;
203 --
204 -- Call the corresponding datetrack api
205 --
206 dt_api.find_dt_del_modes
207 (p_effective_date => p_effective_date,
208 p_base_table_name => 'ben_prtt_prem_f',
209 p_base_key_column => 'prtt_prem_id',
210 p_base_key_value => p_base_key_value,
211 p_parent_table_name1 => 'ben_actl_prem_f',
212 p_parent_key_column1 => 'actl_prem_id',
213 p_parent_key_value1 => l_parent_key_value1,
214 p_parent_table_name2 => 'ben_prtt_enrt_rslt_f',
215 p_parent_key_column2 => 'prtt_enrt_rslt_id',
216 p_parent_key_value2 => l_parent_key_value2,
217 p_zap => p_zap,
218 p_delete => p_delete,
219 p_future_change => p_future_change,
220 p_delete_next_change => p_delete_next_change);
221 --
222 hr_utility.set_location(' Leaving:'||l_proc, 10);
223 End find_dt_del_modes;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |--------------------------< find_dt_upd_modes >---------------------------|
227 -- ----------------------------------------------------------------------------
228 Procedure find_dt_upd_modes
229 (p_effective_date in date,
230 p_base_key_value in number,
231 p_correction out nocopy boolean,
232 p_update out nocopy boolean,
233 p_update_override out nocopy boolean,
234 p_update_change_insert out nocopy boolean) is
235 --
236 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
237 --
238 Begin
239 hr_utility.set_location('Entering:'||l_proc, 5);
240 --
241 -- Call the corresponding datetrack api
242 --
243 dt_api.find_dt_upd_modes
244 (p_effective_date => p_effective_date,
245 p_base_table_name => 'ben_prtt_prem_f',
246 p_base_key_column => 'prtt_prem_id',
247 p_base_key_value => p_base_key_value,
248 p_correction => p_correction,
249 p_update => p_update,
250 p_update_override => p_update_override,
251 p_update_change_insert => p_update_change_insert);
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End find_dt_upd_modes;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |------------------------< upd_effective_end_date >------------------------|
258 -- ----------------------------------------------------------------------------
259 Procedure upd_effective_end_date
260 (p_effective_date in date,
261 p_base_key_value in number,
262 p_new_effective_end_date in date,
263 p_validation_start_date in date,
264 p_validation_end_date in date,
265 p_object_version_number out nocopy number) is
266 --
267 l_proc varchar2(72) := g_package||'upd_effective_end_date';
268 l_object_version_number number;
269 --
270 Begin
271 hr_utility.set_location('Entering:'||l_proc, 5);
272 --
273 -- Because we are updating a row we must get the next object
274 -- version number.
275 --
276 l_object_version_number :=
277 dt_api.get_object_version_number
278 (p_base_table_name => 'ben_prtt_prem_f',
279 p_base_key_column => 'prtt_prem_id',
280 p_base_key_value => p_base_key_value);
281 --
282 hr_utility.set_location(l_proc, 10);
283 g_api_dml := true; -- Set the api dml status
284 --
285 -- Update the specified datetrack row setting the effective
286 -- end date to the specified new effective end date.
287 --
288 update ben_prtt_prem_f t
289 set t.effective_end_date = p_new_effective_end_date,
290 t.object_version_number = l_object_version_number
291 where t.prtt_prem_id = p_base_key_value
292 and p_effective_date
293 between t.effective_start_date and t.effective_end_date;
294 --
295 g_api_dml := false; -- Unset the api dml status
296 p_object_version_number := l_object_version_number;
297 hr_utility.set_location(' Leaving:'||l_proc, 15);
298 --
299 Exception
300 When Others Then
301 g_api_dml := false; -- Unset the api dml status
302 Raise;
303 End upd_effective_end_date;
304 --
308 Procedure lck
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< lck >----------------------------------|
307 -- ----------------------------------------------------------------------------
309 (p_effective_date in date,
310 p_datetrack_mode in varchar2,
311 p_prtt_prem_id in number,
312 p_object_version_number in number,
313 p_validation_start_date out nocopy date,
314 p_validation_end_date out nocopy date) is
315 --
316 l_proc varchar2(72) := g_package||'lck';
317 l_validation_start_date date;
318 l_validation_end_date date;
319 l_object_invalid exception;
320 l_argument varchar2(30);
321 --
322 -- Cursor C_Sel1 selects the current locked row as of session date
323 -- ensuring that the object version numbers match.
324 --
325 Cursor C_Sel1 is
326 select
327 prtt_prem_id,
328 effective_start_date,
329 effective_end_date,
330 std_prem_uom,
331 std_prem_val,
332 actl_prem_id,
333 prtt_enrt_rslt_id,
334 per_in_ler_id,
335 business_group_id,
336 ppe_attribute_category,
337 ppe_attribute1,
338 ppe_attribute2,
339 ppe_attribute3,
340 ppe_attribute4,
341 ppe_attribute5,
342 ppe_attribute6,
343 ppe_attribute7,
344 ppe_attribute8,
345 ppe_attribute9,
346 ppe_attribute10,
347 ppe_attribute11,
348 ppe_attribute12,
349 ppe_attribute13,
350 ppe_attribute14,
351 ppe_attribute15,
352 ppe_attribute16,
353 ppe_attribute17,
354 ppe_attribute18,
355 ppe_attribute19,
356 ppe_attribute20,
357 ppe_attribute21,
358 ppe_attribute22,
359 ppe_attribute23,
360 ppe_attribute24,
361 ppe_attribute25,
362 ppe_attribute26,
363 ppe_attribute27,
364 ppe_attribute28,
365 ppe_attribute29,
366 ppe_attribute30,
367 object_version_number,
368 request_id,
369 program_application_id,
370 program_id,
371 program_update_date
372 from ben_prtt_prem_f
373 where prtt_prem_id = p_prtt_prem_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 => 'prtt_prem_id',
395 p_argument_value => p_prtt_prem_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 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
415 fnd_message.raise_error;
416 End If;
417 Close C_Sel1;
418 If (p_object_version_number <> g_old_rec.object_version_number) Then
419 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
420 fnd_message.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_prtt_prem_f',
432 p_base_key_column => 'prtt_prem_id',
433 p_base_key_value => p_prtt_prem_id,
434 p_parent_table_name1 => 'ben_actl_prem_f',
435 p_parent_key_column1 => 'actl_prem_id',
436 p_parent_key_value1 => g_old_rec.actl_prem_id,
437 /*
438 p_parent_table_name2 => 'ben_prtt_enrt_rslt_f',
439 p_parent_key_column2 => 'prtt_enrt_rslt_id',
440 p_parent_key_value2 => g_old_rec.prtt_enrt_rslt_id,
441 */
442 p_enforce_foreign_locking => false,
443 p_validation_start_date => l_validation_start_date,
444 p_validation_end_date => l_validation_end_date);
445 Else
446 --
447 -- We are doing a datetrack 'INSERT' which is illegal within this
448 -- procedure therefore we must error (note: to lck on insert the
449 -- private procedure ins_lck should be called).
450 --
451 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
452 fnd_message.set_token('PROCEDURE', l_proc);
453 fnd_message.set_token('STEP','20');
454 fnd_message.raise_error;
455 End If;
456 --
457 -- Set the validation start and end date OUT arguments
458 --
459 p_validation_start_date := l_validation_start_date;
460 p_validation_end_date := l_validation_end_date;
461 --
465 --
462 hr_utility.set_location(' Leaving:'||l_proc, 30);
463 --
464 -- We need to trap the ORA LOCK exception
466 Exception
467 When HR_Api.Object_Locked then
468 --
469 -- The object is locked therefore we need to supply a meaningful
470 -- error message.
471 --
472 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
473 fnd_message.set_token('TABLE_NAME', 'ben_prtt_prem_f');
474 fnd_message.raise_error;
475 When l_object_invalid then
476 --
477 -- The object doesn't exist or is invalid
478 --
479 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
480 fnd_message.set_token('TABLE_NAME', 'ben_prtt_prem_f');
481 fnd_message.raise_error;
482 End lck;
483 --
484 -- ----------------------------------------------------------------------------
485 -- |-----------------------------< convert_args >-----------------------------|
486 -- ----------------------------------------------------------------------------
487 Function convert_args
488 (
489 p_prtt_prem_id in number,
490 p_effective_start_date in date,
491 p_effective_end_date in date,
492 p_std_prem_uom in varchar2,
493 p_std_prem_val in number,
494 p_actl_prem_id in number,
495 p_prtt_enrt_rslt_id in number,
496 p_per_in_ler_id in number,
497 p_business_group_id in number,
498 p_ppe_attribute_category in varchar2,
499 p_ppe_attribute1 in varchar2,
500 p_ppe_attribute2 in varchar2,
501 p_ppe_attribute3 in varchar2,
502 p_ppe_attribute4 in varchar2,
503 p_ppe_attribute5 in varchar2,
504 p_ppe_attribute6 in varchar2,
505 p_ppe_attribute7 in varchar2,
506 p_ppe_attribute8 in varchar2,
507 p_ppe_attribute9 in varchar2,
508 p_ppe_attribute10 in varchar2,
509 p_ppe_attribute11 in varchar2,
510 p_ppe_attribute12 in varchar2,
511 p_ppe_attribute13 in varchar2,
512 p_ppe_attribute14 in varchar2,
513 p_ppe_attribute15 in varchar2,
514 p_ppe_attribute16 in varchar2,
515 p_ppe_attribute17 in varchar2,
516 p_ppe_attribute18 in varchar2,
517 p_ppe_attribute19 in varchar2,
518 p_ppe_attribute20 in varchar2,
519 p_ppe_attribute21 in varchar2,
520 p_ppe_attribute22 in varchar2,
521 p_ppe_attribute23 in varchar2,
522 p_ppe_attribute24 in varchar2,
523 p_ppe_attribute25 in varchar2,
524 p_ppe_attribute26 in varchar2,
525 p_ppe_attribute27 in varchar2,
526 p_ppe_attribute28 in varchar2,
527 p_ppe_attribute29 in varchar2,
528 p_ppe_attribute30 in varchar2,
529 p_object_version_number in number,
530 p_request_id in number,
531 p_program_application_id in number,
532 p_program_id in number,
533 p_program_update_date in date
534 )
535 Return g_rec_type is
536 --
537 l_rec g_rec_type;
538 l_proc varchar2(72) := g_package||'convert_args';
539 --
540 Begin
541 --
542 hr_utility.set_location('Entering:'||l_proc, 5);
543 --
544 -- Convert arguments into local l_rec structure.
545 --
546 l_rec.prtt_prem_id := p_prtt_prem_id;
547 l_rec.effective_start_date := p_effective_start_date;
548 l_rec.effective_end_date := p_effective_end_date;
549 l_rec.std_prem_uom := p_std_prem_uom;
550 l_rec.std_prem_val := p_std_prem_val;
551 l_rec.actl_prem_id := p_actl_prem_id;
552 l_rec.prtt_enrt_rslt_id := p_prtt_enrt_rslt_id;
553 l_rec.per_in_ler_id := p_per_in_ler_id;
554 l_rec.business_group_id := p_business_group_id;
555 l_rec.ppe_attribute_category := p_ppe_attribute_category;
556 l_rec.ppe_attribute1 := p_ppe_attribute1;
557 l_rec.ppe_attribute2 := p_ppe_attribute2;
558 l_rec.ppe_attribute3 := p_ppe_attribute3;
559 l_rec.ppe_attribute4 := p_ppe_attribute4;
560 l_rec.ppe_attribute5 := p_ppe_attribute5;
561 l_rec.ppe_attribute6 := p_ppe_attribute6;
562 l_rec.ppe_attribute7 := p_ppe_attribute7;
563 l_rec.ppe_attribute8 := p_ppe_attribute8;
564 l_rec.ppe_attribute9 := p_ppe_attribute9;
565 l_rec.ppe_attribute10 := p_ppe_attribute10;
566 l_rec.ppe_attribute11 := p_ppe_attribute11;
567 l_rec.ppe_attribute12 := p_ppe_attribute12;
568 l_rec.ppe_attribute13 := p_ppe_attribute13;
569 l_rec.ppe_attribute14 := p_ppe_attribute14;
570 l_rec.ppe_attribute15 := p_ppe_attribute15;
571 l_rec.ppe_attribute16 := p_ppe_attribute16;
572 l_rec.ppe_attribute17 := p_ppe_attribute17;
573 l_rec.ppe_attribute18 := p_ppe_attribute18;
574 l_rec.ppe_attribute19 := p_ppe_attribute19;
575 l_rec.ppe_attribute20 := p_ppe_attribute20;
576 l_rec.ppe_attribute21 := p_ppe_attribute21;
577 l_rec.ppe_attribute22 := p_ppe_attribute22;
578 l_rec.ppe_attribute23 := p_ppe_attribute23;
579 l_rec.ppe_attribute24 := p_ppe_attribute24;
580 l_rec.ppe_attribute25 := p_ppe_attribute25;
581 l_rec.ppe_attribute26 := p_ppe_attribute26;
585 l_rec.ppe_attribute30 := p_ppe_attribute30;
582 l_rec.ppe_attribute27 := p_ppe_attribute27;
583 l_rec.ppe_attribute28 := p_ppe_attribute28;
584 l_rec.ppe_attribute29 := p_ppe_attribute29;
586 l_rec.object_version_number := p_object_version_number;
587 l_rec.request_id := p_request_id;
588 l_rec.program_application_id := p_program_application_id;
589 l_rec.program_id := p_program_id;
590 l_rec.program_update_date := p_program_update_date;
591 --
592 -- Return the plsql record structure.
593 --
594 hr_utility.set_location(' Leaving:'||l_proc, 10);
595 Return(l_rec);
596 --
597 End convert_args;
598 --
599 end ben_ppe_shd;