[Home] [Help]
PACKAGE BODY: APPS.BEN_RGR_SHD
Source
6 -- ----------------------------------------------------------------------------
1 Package Body ben_rgr_shd as
2 /* $Header: bergrrhi.pkb 120.2 2008/02/05 08:36:14 rtagarra ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
7 --
8 g_package varchar2(33) := ' ben_rgr_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_POPL_RPTG_GRP_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_POPL_RPTG_GRP_FK2') 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 ElsIf (p_constraint_name = 'BEN_POPL_RPTG_GRP_PK') Then
47 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
48 fnd_message.set_token('PROCEDURE', l_proc);
49 fnd_message.set_token('STEP','15');
50 fnd_message.raise_error;
51 Else
52 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
53 fnd_message.set_token('PROCEDURE', l_proc);
54 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
55 fnd_message.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_popl_rptg_grp_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 popl_rptg_grp_id,
76 effective_start_date,
77 effective_end_date,
78 business_group_id,
79 rptg_grp_id,
80 pgm_id,
81 pl_id,
82 ordr_num, --iRec
83 rgr_attribute_category,
84 rgr_attribute1,
85 rgr_attribute2,
86 rgr_attribute3,
87 rgr_attribute4,
88 rgr_attribute5,
89 rgr_attribute6,
90 rgr_attribute7,
91 rgr_attribute8,
92 rgr_attribute9,
93 rgr_attribute10,
94 rgr_attribute11,
95 rgr_attribute12,
96 rgr_attribute13,
97 rgr_attribute14,
98 rgr_attribute15,
99 rgr_attribute16,
100 rgr_attribute17,
101 rgr_attribute18,
102 rgr_attribute19,
103 rgr_attribute20,
104 rgr_attribute21,
105 rgr_attribute22,
106 rgr_attribute23,
107 rgr_attribute24,
108 rgr_attribute25,
109 rgr_attribute26,
110 rgr_attribute27,
111 rgr_attribute28,
112 rgr_attribute29,
113 rgr_attribute30,
114 object_version_number
115 from ben_popl_rptg_grp_f
116 where popl_rptg_grp_id = p_popl_rptg_grp_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_popl_rptg_grp_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_popl_rptg_grp_id = g_old_rec.popl_rptg_grp_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');
158 If (p_object_version_number <> g_old_rec.object_version_number) Then
155 fnd_message.raise_error;
156 End If;
157 Close C_Sel1;
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 --
169 End api_updating;
170 --
171 -- ----------------------------------------------------------------------------
172 -- |--------------------------< find_dt_del_modes >---------------------------|
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 l_parent_key_value2 number;
189 t.pl_id
186 --
187 Cursor C_Sel1 Is
188 select t.pgm_id,
190 from ben_popl_rptg_grp_f t
191 where t.popl_rptg_grp_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 l_parent_key_value2;
200 If C_Sel1%notfound then
201 Close C_Sel1;
202 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
203 fnd_message.set_token('PROCEDURE', l_proc);
204 fnd_message.set_token('STEP','10');
205 fnd_message.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_popl_rptg_grp_f',
214 p_base_key_column => 'popl_rptg_grp_id',
215 p_base_key_value => p_base_key_value,
216 p_parent_table_name1 => 'ben_pgm_f',
217 p_parent_key_column1 => 'pgm_id',
218 p_parent_key_value1 => l_parent_key_value1,
219 p_parent_table_name2 => 'ben_pl_f',
220 p_parent_key_column2 => 'pl_id',
221 p_parent_key_value2 => l_parent_key_value2,
222 p_zap => p_zap,
223 p_delete => p_delete,
224 p_future_change => p_future_change,
225 p_delete_next_change => p_delete_next_change);
226 --
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End find_dt_del_modes;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |--------------------------< find_dt_upd_modes >---------------------------|
232 -- ----------------------------------------------------------------------------
233 Procedure find_dt_upd_modes
234 (p_effective_date in date,
235 p_base_key_value in number,
236 p_correction out nocopy boolean,
237 p_update out nocopy boolean,
238 p_update_override out nocopy boolean,
239 p_update_change_insert out nocopy boolean) is
240 --
241 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
242 --
243 Begin
244 hr_utility.set_location('Entering:'||l_proc, 5);
245 --
246 -- Call the corresponding datetrack api
247 --
248 dt_api.find_dt_upd_modes
249 (p_effective_date => p_effective_date,
250 p_base_table_name => 'ben_popl_rptg_grp_f',
251 p_base_key_column => 'popl_rptg_grp_id',
252 p_base_key_value => p_base_key_value,
253 p_correction => p_correction,
254 p_update => p_update,
255 p_update_override => p_update_override,
256 p_update_change_insert => p_update_change_insert);
257 --
258 hr_utility.set_location(' Leaving:'||l_proc, 10);
259 End find_dt_upd_modes;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |------------------------< upd_effective_end_date >------------------------|
263 -- ----------------------------------------------------------------------------
264 Procedure upd_effective_end_date
265 (p_effective_date in date,
266 p_base_key_value in number,
267 p_new_effective_end_date in date,
268 p_validation_start_date in date,
269 p_validation_end_date in date,
270 p_object_version_number out nocopy number) is
271 --
272 l_proc varchar2(72) := g_package||'upd_effective_end_date';
273 l_object_version_number number;
274 --
275 Begin
276 hr_utility.set_location('Entering:'||l_proc, 5);
277 --
278 -- Because we are updating a row we must get the next object
279 -- version number.
280 --
281 l_object_version_number :=
282 dt_api.get_object_version_number
286 --
283 (p_base_table_name => 'ben_popl_rptg_grp_f',
284 p_base_key_column => 'popl_rptg_grp_id',
285 p_base_key_value => p_base_key_value);
287 hr_utility.set_location(l_proc, 10);
288 g_api_dml := true; -- Set the api dml status
289 --
290 -- Update the specified datetrack row setting the effective
291 -- end date to the specified new effective end date.
292 --
293 update ben_popl_rptg_grp_f t
294 set t.effective_end_date = p_new_effective_end_date,
295 t.object_version_number = l_object_version_number
296 where t.popl_rptg_grp_id = p_base_key_value
297 and p_effective_date
298 between t.effective_start_date and t.effective_end_date;
299 --
300 g_api_dml := false; -- Unset the api dml status
301 p_object_version_number := l_object_version_number;
302 hr_utility.set_location(' Leaving:'||l_proc, 15);
303 --
304 Exception
305 When Others Then
306 g_api_dml := false; -- Unset the api dml status
307 Raise;
308 End upd_effective_end_date;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------------< lck >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure lck
314 (p_effective_date in date,
315 p_datetrack_mode in varchar2,
316 p_popl_rptg_grp_id in number,
317 p_object_version_number in number,
318 p_validation_start_date out nocopy date,
319 p_validation_end_date out nocopy date) is
320 --
321 l_proc varchar2(72) := g_package||'lck';
322 l_validation_start_date date;
323 l_validation_end_date date;
324 l_object_invalid exception;
325 l_argument varchar2(30);
326 --
327 -- Cursor C_Sel1 selects the current locked row as of session date
328 -- ensuring that the object version numbers match.
329 --
330 Cursor C_Sel1 is
331 select
332 popl_rptg_grp_id,
333 effective_start_date,
334 effective_end_date,
335 business_group_id,
336 rptg_grp_id,
337 pgm_id,
338 pl_id,
339 ordr_num, --iRec
340 rgr_attribute_category,
341 rgr_attribute1,
342 rgr_attribute2,
343 rgr_attribute3,
344 rgr_attribute4,
345 rgr_attribute5,
346 rgr_attribute6,
347 rgr_attribute7,
348 rgr_attribute8,
349 rgr_attribute9,
350 rgr_attribute10,
351 rgr_attribute11,
352 rgr_attribute12,
353 rgr_attribute13,
354 rgr_attribute14,
355 rgr_attribute15,
356 rgr_attribute16,
357 rgr_attribute17,
358 rgr_attribute18,
359 rgr_attribute19,
360 rgr_attribute20,
361 rgr_attribute21,
362 rgr_attribute22,
363 rgr_attribute23,
364 rgr_attribute24,
365 rgr_attribute25,
366 rgr_attribute26,
367 rgr_attribute27,
368 rgr_attribute28,
369 rgr_attribute29,
370 rgr_attribute30,
371 object_version_number
372 from ben_popl_rptg_grp_f
373 where popl_rptg_grp_id = p_popl_rptg_grp_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 => 'popl_rptg_grp_id',
398 p_argument => 'object_version_number',
395 p_argument_value => p_popl_rptg_grp_id);
396 --
397 hr_api.mandatory_arg_error(p_api_name => l_proc,
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_popl_rptg_grp_f',
432 p_base_key_column => 'popl_rptg_grp_id',
433 p_base_key_value => p_popl_rptg_grp_id,
434 p_parent_table_name1 => 'ben_pgm_f',
435 p_parent_key_column1 => 'pgm_id',
436 p_parent_key_value1 => g_old_rec.pgm_id,
437 p_parent_table_name2 => 'ben_pl_f',
438 p_parent_key_column2 => 'pl_id',
439 p_parent_key_value2 => g_old_rec.pl_id,
440 p_enforce_foreign_locking => false , --true,
441 p_validation_start_date => l_validation_start_date,
442 p_validation_end_date => l_validation_end_date);
443 Else
444 --
445 -- We are doing a datetrack 'INSERT' which is illegal within this
446 -- procedure therefore we must error (note: to lck on insert the
447 -- private procedure ins_lck should be called).
448 --
449 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
450 fnd_message.set_token('PROCEDURE', l_proc);
451 fnd_message.set_token('STEP','20');
452 fnd_message.raise_error;
453 End If;
454 --
455 -- Set the validation start and end date OUT arguments
456 --
457 p_validation_start_date := l_validation_start_date;
458 p_validation_end_date := l_validation_end_date;
459 --
460 hr_utility.set_location(' Leaving:'||l_proc, 30);
461 --
462 -- We need to trap the ORA LOCK exception
463 --
464 Exception
465 When HR_Api.Object_Locked then
466 --
467 -- The object is locked therefore we need to supply a meaningful
468 -- error message.
469 --
470 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
471 fnd_message.set_token('TABLE_NAME', 'ben_popl_rptg_grp_f');
472 fnd_message.raise_error;
473 When l_object_invalid then
474 --
475 -- The object doesn't exist or is invalid
476 --
477 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
478 fnd_message.set_token('TABLE_NAME', 'ben_popl_rptg_grp_f');
479 fnd_message.raise_error;
480 End lck;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |-----------------------------< convert_args >-----------------------------|
484 -- ----------------------------------------------------------------------------
485 Function convert_args
486 (
487 p_popl_rptg_grp_id in number,
488 p_effective_start_date in date,
489 p_effective_end_date in date,
490 p_business_group_id in number,
491 p_rptg_grp_id in number,
492 p_pgm_id in number,
493 p_pl_id in number,
494 p_ordr_num in number, --iRec
495 p_rgr_attribute_category in varchar2,
496 p_rgr_attribute1 in varchar2,
497 p_rgr_attribute2 in varchar2,
498 p_rgr_attribute3 in varchar2,
499 p_rgr_attribute4 in varchar2,
500 p_rgr_attribute5 in varchar2,
501 p_rgr_attribute6 in varchar2,
502 p_rgr_attribute7 in varchar2,
503 p_rgr_attribute8 in varchar2,
504 p_rgr_attribute9 in varchar2,
505 p_rgr_attribute10 in varchar2,
506 p_rgr_attribute11 in varchar2,
507 p_rgr_attribute12 in varchar2,
508 p_rgr_attribute13 in varchar2,
509 p_rgr_attribute14 in varchar2,
510 p_rgr_attribute15 in varchar2,
511 p_rgr_attribute16 in varchar2,
512 p_rgr_attribute17 in varchar2,
513 p_rgr_attribute18 in varchar2,
514 p_rgr_attribute19 in varchar2,
515 p_rgr_attribute20 in varchar2,
516 p_rgr_attribute21 in varchar2,
517 p_rgr_attribute22 in varchar2,
518 p_rgr_attribute23 in varchar2,
519 p_rgr_attribute24 in varchar2,
520 p_rgr_attribute25 in varchar2,
521 p_rgr_attribute26 in varchar2,
522 p_rgr_attribute27 in varchar2,
523 p_rgr_attribute28 in varchar2,
524 p_rgr_attribute29 in varchar2,
525 p_rgr_attribute30 in varchar2,
526 p_object_version_number in number
527 )
528 Return g_rec_type is
529 --
530 l_rec g_rec_type;
534 --
531 l_proc varchar2(72) := g_package||'convert_args';
532 --
533 Begin
535 hr_utility.set_location('Entering:'||l_proc, 5);
536 --
537 -- Convert arguments into local l_rec structure.
538 --
539 l_rec.popl_rptg_grp_id := p_popl_rptg_grp_id;
540 l_rec.effective_start_date := p_effective_start_date;
541 l_rec.effective_end_date := p_effective_end_date;
542 l_rec.business_group_id := p_business_group_id;
543 l_rec.rptg_grp_id := p_rptg_grp_id;
544 l_rec.pgm_id := p_pgm_id;
545 l_rec.pl_id := p_pl_id;
546 l_rec.ordr_num := p_ordr_num; --iRec
547 l_rec.rgr_attribute_category := p_rgr_attribute_category;
548 l_rec.rgr_attribute1 := p_rgr_attribute1;
549 l_rec.rgr_attribute2 := p_rgr_attribute2;
550 l_rec.rgr_attribute3 := p_rgr_attribute3;
551 l_rec.rgr_attribute4 := p_rgr_attribute4;
552 l_rec.rgr_attribute5 := p_rgr_attribute5;
553 l_rec.rgr_attribute6 := p_rgr_attribute6;
554 l_rec.rgr_attribute7 := p_rgr_attribute7;
555 l_rec.rgr_attribute8 := p_rgr_attribute8;
556 l_rec.rgr_attribute9 := p_rgr_attribute9;
557 l_rec.rgr_attribute10 := p_rgr_attribute10;
558 l_rec.rgr_attribute11 := p_rgr_attribute11;
559 l_rec.rgr_attribute12 := p_rgr_attribute12;
560 l_rec.rgr_attribute13 := p_rgr_attribute13;
561 l_rec.rgr_attribute14 := p_rgr_attribute14;
562 l_rec.rgr_attribute15 := p_rgr_attribute15;
563 l_rec.rgr_attribute16 := p_rgr_attribute16;
564 l_rec.rgr_attribute17 := p_rgr_attribute17;
565 l_rec.rgr_attribute18 := p_rgr_attribute18;
566 l_rec.rgr_attribute19 := p_rgr_attribute19;
567 l_rec.rgr_attribute20 := p_rgr_attribute20;
568 l_rec.rgr_attribute21 := p_rgr_attribute21;
569 l_rec.rgr_attribute22 := p_rgr_attribute22;
570 l_rec.rgr_attribute23 := p_rgr_attribute23;
571 l_rec.rgr_attribute24 := p_rgr_attribute24;
572 l_rec.rgr_attribute25 := p_rgr_attribute25;
573 l_rec.rgr_attribute26 := p_rgr_attribute26;
574 l_rec.rgr_attribute27 := p_rgr_attribute27;
575 l_rec.rgr_attribute28 := p_rgr_attribute28;
576 l_rec.rgr_attribute29 := p_rgr_attribute29;
577 l_rec.rgr_attribute30 := p_rgr_attribute30;
578 l_rec.object_version_number := p_object_version_number;
579 --
580 -- Return the plsql record structure.
581 --
582 hr_utility.set_location(' Leaving:'||l_proc, 10);
583 Return(l_rec);
584 --
585 End convert_args;
586 --
587 end ben_rgr_shd;