[Home] [Help]
PACKAGE BODY: APPS.BEN_PRM_SHD
Source
1 Package Body ben_prm_shd as
2 /* $Header: beprmrhi.pkb 115.6 2002/12/30 10:49:28 rpgupta ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_prm_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_BY_MO_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_by_mo_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_by_mo_id,
66 effective_start_date,
67 effective_end_date,
68 mnl_adj_flag,
69 mo_num,
70 yr_num,
71 antcpd_prtt_cntr_uom,
72 antcpd_prtt_cntr_val,
73 val,
74 cr_val,
75 cr_mnl_adj_flag,
76 alctd_val_flag,
77 uom,
78 prtt_prem_id,
79 cost_allocation_keyflex_id,
80 business_group_id,
81 prm_attribute_category,
82 prm_attribute1,
83 prm_attribute2,
84 prm_attribute3,
85 prm_attribute4,
86 prm_attribute5,
87 prm_attribute6,
88 prm_attribute7,
89 prm_attribute8,
90 prm_attribute9,
91 prm_attribute10,
92 prm_attribute11,
93 prm_attribute12,
94 prm_attribute13,
95 prm_attribute14,
96 prm_attribute15,
97 prm_attribute16,
98 prm_attribute17,
99 prm_attribute18,
100 prm_attribute19,
101 prm_attribute20,
102 prm_attribute21,
103 prm_attribute22,
104 prm_attribute23,
105 prm_attribute24,
106 prm_attribute25,
107 prm_attribute26,
108 prm_attribute27,
109 prm_attribute28,
110 prm_attribute29,
111 prm_attribute30,
112 object_version_number,
113 request_id,
114 program_application_id,
115 program_id,
116 program_update_date
117 from ben_prtt_prem_by_mo_f
118 where prtt_prem_by_mo_id = p_prtt_prem_by_mo_id
119 and p_effective_date
120 between effective_start_date and effective_end_date;
121 --
122 l_proc varchar2(72) := g_package||'api_updating';
123 l_fct_ret boolean;
124 --
125 Begin
126 hr_utility.set_location('Entering:'||l_proc, 5);
127 --
128 If (p_effective_date is null or
129 p_prtt_prem_by_mo_id is null or
130 p_object_version_number is null) Then
131 --
132 -- One of the primary key arguments is null therefore we must
133 -- set the returning function value to false
134 --
135 l_fct_ret := false;
136 Else
137 If (p_prtt_prem_by_mo_id = g_old_rec.prtt_prem_by_mo_id and
138 p_object_version_number = g_old_rec.object_version_number) Then
139 hr_utility.set_location(l_proc, 10);
140 --
141 -- The g_old_rec is current therefore we must
142 -- set the returning function to true
143 --
144 l_fct_ret := true;
145 Else
146 --
147 -- Select the current row
148 --
149 Open C_Sel1;
150 Fetch C_Sel1 Into g_old_rec;
151 If C_Sel1%notfound Then
152 Close C_Sel1;
153 --
154 -- The primary key is invalid therefore we must error
155 --
156 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
157 fnd_message.raise_error;
158 End If;
159 Close C_Sel1;
160 If (p_object_version_number <> g_old_rec.object_version_number) Then
161 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
162 fnd_message.raise_error;
163 End If;
164 hr_utility.set_location(l_proc, 15);
165 l_fct_ret := true;
166 End If;
167 End If;
168 hr_utility.set_location(' Leaving:'||l_proc, 20);
169 Return (l_fct_ret);
170 --
171 End api_updating;
172 --
173 -- ----------------------------------------------------------------------------
174 -- |--------------------------< find_dt_del_modes >---------------------------|
175 -- ----------------------------------------------------------------------------
176 Procedure find_dt_del_modes
177 (p_effective_date in date,
178 p_base_key_value in number,
179 p_zap out nocopy boolean,
180 p_delete out nocopy boolean,
181 p_future_change out nocopy boolean,
182 p_delete_next_change out nocopy boolean) is
183 --
184 l_proc varchar2(72) := g_package||'find_dt_del_modes';
185 --
186 l_parent_key_value1 number;
187 --
188 Cursor C_Sel1 Is
189 select t.prtt_prem_id
190 from ben_prtt_prem_by_mo_f t
191 where t.prtt_prem_by_mo_id = p_base_key_value
192 and p_effective_date
193 between t.effective_start_date and t.effective_end_date;
194 --
195 Begin
196 hr_utility.set_location('Entering:'||l_proc, 5);
197 Open C_Sel1;
198 Fetch C_Sel1 Into l_parent_key_value1;
199 If C_Sel1%notfound then
200 Close C_Sel1;
201 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
202 fnd_message.set_token('PROCEDURE', l_proc);
203 fnd_message.set_token('STEP','10');
204 fnd_message.raise_error;
205 End If;
206 Close C_Sel1;
207 --
208 -- Call the corresponding datetrack api
209 --
210 dt_api.find_dt_del_modes
211 (p_effective_date => p_effective_date,
212 p_base_table_name => 'ben_prtt_prem_by_mo_f',
213 p_base_key_column => 'prtt_prem_by_mo_id',
214 p_base_key_value => p_base_key_value,
215 p_parent_table_name1 => 'ben_prtt_prem_f',
216 p_parent_key_column1 => 'prtt_prem_id',
217 p_parent_key_value1 => l_parent_key_value1,
218 p_zap => p_zap,
219 p_delete => p_delete,
220 p_future_change => p_future_change,
221 p_delete_next_change => p_delete_next_change);
222 --
223 hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End find_dt_del_modes;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |--------------------------< find_dt_upd_modes >---------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure find_dt_upd_modes
230 (p_effective_date in date,
231 p_base_key_value in number,
232 p_correction out nocopy boolean,
233 p_update out nocopy boolean,
234 p_update_override out nocopy boolean,
235 p_update_change_insert out nocopy boolean) is
236 --
237 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
238 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242 -- Call the corresponding datetrack api
243 --
244 dt_api.find_dt_upd_modes
245 (p_effective_date => p_effective_date,
246 p_base_table_name => 'ben_prtt_prem_by_mo_f',
247 p_base_key_column => 'prtt_prem_by_mo_id',
248 p_base_key_value => p_base_key_value,
249 p_correction => p_correction,
250 p_update => p_update,
251 p_update_override => p_update_override,
252 p_update_change_insert => p_update_change_insert);
253 --
254 hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End find_dt_upd_modes;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |------------------------< upd_effective_end_date >------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure upd_effective_end_date
261 (p_effective_date in date,
262 p_base_key_value in number,
263 p_new_effective_end_date in date,
264 p_validation_start_date in date,
265 p_validation_end_date in date,
266 p_object_version_number out nocopy number) is
267 --
268 l_proc varchar2(72) := g_package||'upd_effective_end_date';
269 l_object_version_number number;
270 --
271 Begin
272 hr_utility.set_location('Entering:'||l_proc, 5);
273 --
274 -- Because we are updating a row we must get the next object
275 -- version number.
276 --
277 l_object_version_number :=
278 dt_api.get_object_version_number
279 (p_base_table_name => 'ben_prtt_prem_by_mo_f',
280 p_base_key_column => 'prtt_prem_by_mo_id',
281 p_base_key_value => p_base_key_value);
282 --
283 hr_utility.set_location(l_proc, 10);
284 g_api_dml := true; -- Set the api dml status
285 --
286 -- Update the specified datetrack row setting the effective
287 -- end date to the specified new effective end date.
288 --
289 update ben_prtt_prem_by_mo_f t
290 set t.effective_end_date = p_new_effective_end_date,
291 t.object_version_number = l_object_version_number
292 where t.prtt_prem_by_mo_id = p_base_key_value
293 and p_effective_date
294 between t.effective_start_date and t.effective_end_date;
295 --
296 g_api_dml := false; -- Unset the api dml status
297 p_object_version_number := l_object_version_number;
298 hr_utility.set_location(' Leaving:'||l_proc, 15);
299 --
300 Exception
301 When Others Then
302 g_api_dml := false; -- Unset the api dml status
303 Raise;
304 End upd_effective_end_date;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< lck >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure lck
310 (p_effective_date in date,
311 p_datetrack_mode in varchar2,
312 p_prtt_prem_by_mo_id in number,
313 p_object_version_number in number,
314 p_validation_start_date out nocopy date,
315 p_validation_end_date out nocopy date) is
316 --
317 l_proc varchar2(72) := g_package||'lck';
318 l_validation_start_date date;
319 l_validation_end_date date;
320 l_object_invalid exception;
321 l_argument varchar2(30);
322 --
323 -- Cursor C_Sel1 selects the current locked row as of session date
324 -- ensuring that the object version numbers match.
325 --
326 Cursor C_Sel1 is
327 select
328 prtt_prem_by_mo_id,
329 effective_start_date,
330 effective_end_date,
331 mnl_adj_flag,
332 mo_num,
333 yr_num,
334 antcpd_prtt_cntr_uom,
335 antcpd_prtt_cntr_val,
336 val,
337 cr_val,
338 cr_mnl_adj_flag,
339 alctd_val_flag,
340 uom,
341 prtt_prem_id,
342 cost_allocation_keyflex_id,
343 business_group_id,
344 prm_attribute_category,
345 prm_attribute1,
346 prm_attribute2,
347 prm_attribute3,
348 prm_attribute4,
349 prm_attribute5,
350 prm_attribute6,
351 prm_attribute7,
352 prm_attribute8,
353 prm_attribute9,
354 prm_attribute10,
355 prm_attribute11,
356 prm_attribute12,
357 prm_attribute13,
358 prm_attribute14,
359 prm_attribute15,
360 prm_attribute16,
361 prm_attribute17,
362 prm_attribute18,
363 prm_attribute19,
364 prm_attribute20,
365 prm_attribute21,
366 prm_attribute22,
367 prm_attribute23,
368 prm_attribute24,
369 prm_attribute25,
370 prm_attribute26,
371 prm_attribute27,
372 prm_attribute28,
373 prm_attribute29,
374 prm_attribute30,
375 object_version_number,
376 request_id,
377 program_application_id,
378 program_id,
379 program_update_date
380 from ben_prtt_prem_by_mo_f
381 where prtt_prem_by_mo_id = p_prtt_prem_by_mo_id
382 and p_effective_date
383 between effective_start_date and effective_end_date
384 for update nowait;
385 --
386 --
387 --
388 Begin
389 hr_utility.set_location('Entering:'||l_proc, 5);
390 --
391 -- Ensure that all the mandatory arguments are not null
392 --
393 hr_api.mandatory_arg_error(p_api_name => l_proc,
394 p_argument => 'effective_date',
395 p_argument_value => p_effective_date);
396 --
397 hr_api.mandatory_arg_error(p_api_name => l_proc,
398 p_argument => 'datetrack_mode',
399 p_argument_value => p_datetrack_mode);
400 --
401 hr_api.mandatory_arg_error(p_api_name => l_proc,
402 p_argument => 'prtt_prem_by_mo_id',
403 p_argument_value => p_prtt_prem_by_mo_id);
404 --
405 hr_api.mandatory_arg_error(p_api_name => l_proc,
406 p_argument => 'object_version_number',
407 p_argument_value => p_object_version_number);
408 --
409 -- Check to ensure the datetrack mode is not INSERT.
410 --
411 If (p_datetrack_mode <> 'INSERT') then
412 --
413 -- We must select and lock the current row.
414 --
415 Open C_Sel1;
416 Fetch C_Sel1 Into g_old_rec;
417 If C_Sel1%notfound then
418 Close C_Sel1;
419 --
420 -- The primary key is invalid therefore we must error
421 --
422 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
423 fnd_message.raise_error;
424 End If;
425 Close C_Sel1;
426 If (p_object_version_number <> g_old_rec.object_version_number) Then
427 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
428 fnd_message.raise_error;
429 End If;
430 hr_utility.set_location(l_proc, 15);
431 --
432 --
433 -- Validate the datetrack mode mode getting the validation start
434 -- and end dates for the specified datetrack operation.
435 --
436 dt_api.validate_dt_mode
437 (p_effective_date => p_effective_date,
438 p_datetrack_mode => p_datetrack_mode,
439 p_base_table_name => 'ben_prtt_prem_by_mo_f',
440 p_base_key_column => 'prtt_prem_by_mo_id',
441 p_base_key_value => p_prtt_prem_by_mo_id,
442 p_parent_table_name1 => 'ben_prtt_prem_f',
446 p_validation_start_date => l_validation_start_date,
443 p_parent_key_column1 => 'prtt_prem_id',
444 p_parent_key_value1 => g_old_rec.prtt_prem_id,
445 p_enforce_foreign_locking => false,
447 p_validation_end_date => l_validation_end_date);
448 Else
449 --
450 -- We are doing a datetrack 'INSERT' which is illegal within this
451 -- procedure therefore we must error (note: to lck on insert the
452 -- private procedure ins_lck should be called).
453 --
454 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
455 fnd_message.set_token('PROCEDURE', l_proc);
456 fnd_message.set_token('STEP','20');
457 fnd_message.raise_error;
458 End If;
459 --
460 -- Set the validation start and end date OUT arguments
461 --
462 p_validation_start_date := l_validation_start_date;
463 p_validation_end_date := l_validation_end_date;
464 --
465 hr_utility.set_location(' Leaving:'||l_proc, 30);
466 --
467 -- We need to trap the ORA LOCK exception
468 --
469 Exception
470 When HR_Api.Object_Locked then
471 --
472 -- The object is locked therefore we need to supply a meaningful
473 -- error message.
474 --
475 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
476 fnd_message.set_token('TABLE_NAME', 'ben_prtt_prem_by_mo_f');
477 fnd_message.raise_error;
478 When l_object_invalid then
479 --
480 -- The object doesn't exist or is invalid
481 --
482 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
483 fnd_message.set_token('TABLE_NAME', 'ben_prtt_prem_by_mo_f');
484 fnd_message.raise_error;
485 End lck;
486 --
487 -- ----------------------------------------------------------------------------
488 -- |-----------------------------< convert_args >-----------------------------|
489 -- ----------------------------------------------------------------------------
490 Function convert_args
491 (
492 p_prtt_prem_by_mo_id in number,
493 p_effective_start_date in date,
494 p_effective_end_date in date,
495 p_mnl_adj_flag in varchar2,
496 p_mo_num in number,
497 p_yr_num in number,
498 p_antcpd_prtt_cntr_uom in varchar2,
499 p_antcpd_prtt_cntr_val in number,
500 p_val in number,
501 p_cr_val in number,
502 p_cr_mnl_adj_flag in varchar2,
503 p_alctd_val_flag in varchar2,
504 p_uom in varchar2,
505 p_prtt_prem_id in number,
506 p_cost_allocation_keyflex_id in number,
507 p_business_group_id in number,
508 p_prm_attribute_category in varchar2,
509 p_prm_attribute1 in varchar2,
510 p_prm_attribute2 in varchar2,
511 p_prm_attribute3 in varchar2,
512 p_prm_attribute4 in varchar2,
513 p_prm_attribute5 in varchar2,
514 p_prm_attribute6 in varchar2,
515 p_prm_attribute7 in varchar2,
516 p_prm_attribute8 in varchar2,
517 p_prm_attribute9 in varchar2,
518 p_prm_attribute10 in varchar2,
519 p_prm_attribute11 in varchar2,
520 p_prm_attribute12 in varchar2,
521 p_prm_attribute13 in varchar2,
522 p_prm_attribute14 in varchar2,
523 p_prm_attribute15 in varchar2,
524 p_prm_attribute16 in varchar2,
525 p_prm_attribute17 in varchar2,
526 p_prm_attribute18 in varchar2,
527 p_prm_attribute19 in varchar2,
528 p_prm_attribute20 in varchar2,
529 p_prm_attribute21 in varchar2,
530 p_prm_attribute22 in varchar2,
531 p_prm_attribute23 in varchar2,
532 p_prm_attribute24 in varchar2,
533 p_prm_attribute25 in varchar2,
534 p_prm_attribute26 in varchar2,
535 p_prm_attribute27 in varchar2,
536 p_prm_attribute28 in varchar2,
537 p_prm_attribute29 in varchar2,
538 p_prm_attribute30 in varchar2,
539 p_object_version_number in number,
540 p_request_id in number,
541 p_program_application_id in number,
542 p_program_id in number,
543 p_program_update_date in date
544 )
545 Return g_rec_type is
546 --
547 l_rec g_rec_type;
548 l_proc varchar2(72) := g_package||'convert_args';
549 --
550 Begin
551 --
552 hr_utility.set_location('Entering:'||l_proc, 5);
553 --
554 -- Convert arguments into local l_rec structure.
555 --
556 l_rec.prtt_prem_by_mo_id := p_prtt_prem_by_mo_id;
557 l_rec.effective_start_date := p_effective_start_date;
558 l_rec.effective_end_date := p_effective_end_date;
559 l_rec.mnl_adj_flag := p_mnl_adj_flag;
560 l_rec.mo_num := p_mo_num;
561 l_rec.yr_num := p_yr_num;
562 l_rec.antcpd_prtt_cntr_uom := p_antcpd_prtt_cntr_uom;
566 l_rec.cr_mnl_adj_flag := p_cr_mnl_adj_flag;
563 l_rec.antcpd_prtt_cntr_val := p_antcpd_prtt_cntr_val;
564 l_rec.val := p_val;
565 l_rec.cr_val := p_cr_val;
567 l_rec.alctd_val_flag := p_alctd_val_flag;
568 l_rec.uom := p_uom;
569 l_rec.prtt_prem_id := p_prtt_prem_id;
570 l_rec.cost_allocation_keyflex_id := p_cost_allocation_keyflex_id;
571 l_rec.business_group_id := p_business_group_id;
572 l_rec.prm_attribute_category := p_prm_attribute_category;
573 l_rec.prm_attribute1 := p_prm_attribute1;
574 l_rec.prm_attribute2 := p_prm_attribute2;
575 l_rec.prm_attribute3 := p_prm_attribute3;
576 l_rec.prm_attribute4 := p_prm_attribute4;
577 l_rec.prm_attribute5 := p_prm_attribute5;
578 l_rec.prm_attribute6 := p_prm_attribute6;
579 l_rec.prm_attribute7 := p_prm_attribute7;
580 l_rec.prm_attribute8 := p_prm_attribute8;
581 l_rec.prm_attribute9 := p_prm_attribute9;
582 l_rec.prm_attribute10 := p_prm_attribute10;
583 l_rec.prm_attribute11 := p_prm_attribute11;
584 l_rec.prm_attribute12 := p_prm_attribute12;
585 l_rec.prm_attribute13 := p_prm_attribute13;
586 l_rec.prm_attribute14 := p_prm_attribute14;
587 l_rec.prm_attribute15 := p_prm_attribute15;
588 l_rec.prm_attribute16 := p_prm_attribute16;
589 l_rec.prm_attribute17 := p_prm_attribute17;
590 l_rec.prm_attribute18 := p_prm_attribute18;
591 l_rec.prm_attribute19 := p_prm_attribute19;
592 l_rec.prm_attribute20 := p_prm_attribute20;
593 l_rec.prm_attribute21 := p_prm_attribute21;
594 l_rec.prm_attribute22 := p_prm_attribute22;
595 l_rec.prm_attribute23 := p_prm_attribute23;
596 l_rec.prm_attribute24 := p_prm_attribute24;
597 l_rec.prm_attribute25 := p_prm_attribute25;
598 l_rec.prm_attribute26 := p_prm_attribute26;
599 l_rec.prm_attribute27 := p_prm_attribute27;
600 l_rec.prm_attribute28 := p_prm_attribute28;
601 l_rec.prm_attribute29 := p_prm_attribute29;
602 l_rec.prm_attribute30 := p_prm_attribute30;
603 l_rec.object_version_number := p_object_version_number;
604 l_rec.request_id := p_request_id;
605 l_rec.program_application_id := p_program_application_id;
606 l_rec.program_id := p_program_id;
607 l_rec.program_update_date := p_program_update_date;
608 --
609 -- Return the plsql record structure.
610 --
611 hr_utility.set_location(' Leaving:'||l_proc, 10);
612 Return(l_rec);
613 --
614 End convert_args;
615 --
616 end ben_prm_shd;