[Home] [Help]
PACKAGE BODY: APPS.BEN_REG_SHD
Source
4 -- ----------------------------------------------------------------------------
1 Package Body ben_reg_shd as
2 /* $Header: beregrhi.pkb 120.3 2008/04/29 07:22:53 sagnanas noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_reg_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_REGN_FK2') 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_REGN_PK') 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_REGN_UK1') Then
47 fnd_message.set_name('BEN', 'BEN_91009_NAME_NOT_UNIQUE');
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_regn_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 regn_id,
76 effective_start_date,
77 effective_end_date,
78 name,
79 organization_id,
80 business_group_id,
81 sttry_citn_name,
82 reg_attribute_category,
83 reg_attribute1,
84 reg_attribute2,
85 reg_attribute3,
86 reg_attribute4,
87 reg_attribute5,
88 reg_attribute6,
89 reg_attribute7,
90 reg_attribute8,
91 reg_attribute9,
92 reg_attribute10,
93 reg_attribute11,
94 reg_attribute12,
95 reg_attribute13,
96 reg_attribute14,
97 reg_attribute15,
98 reg_attribute16,
99 reg_attribute17,
100 reg_attribute18,
101 reg_attribute19,
102 reg_attribute20,
103 reg_attribute21,
104 reg_attribute22,
105 reg_attribute23,
106 reg_attribute24,
107 reg_attribute25,
108 reg_attribute26,
109 reg_attribute27,
110 reg_attribute28,
111 reg_attribute29,
112 reg_attribute30,
113 object_version_number
114 from ben_regn_f
115 where regn_id = p_regn_id
116 and p_effective_date
117 between effective_start_date and effective_end_date;
118 --
119 l_proc varchar2(72) := g_package||'api_updating';
120 l_fct_ret boolean;
121 --
122 Begin
123 hr_utility.set_location('Entering:'||l_proc, 5);
124 --
125 If (p_effective_date is null or
126 p_regn_id is null or
127 p_object_version_number is null) Then
128 --
129 -- One of the primary key arguments is null therefore we must
130 -- set the returning function value to false
131 --
132 l_fct_ret := false;
133 Else
134 If (p_regn_id = g_old_rec.regn_id and
135 p_object_version_number = g_old_rec.object_version_number) Then
136 hr_utility.set_location(l_proc, 10);
137 --
138 -- The g_old_rec is current therefore we must
139 -- set the returning function to true
140 --
141 l_fct_ret := true;
142 Else
143 --
144 -- Select the current row
145 --
146 Open C_Sel1;
147 Fetch C_Sel1 Into g_old_rec;
148 If C_Sel1%notfound Then
149 Close C_Sel1;
150 --
151 -- The primary key is invalid therefore we must error
152 --
153 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
154 fnd_message.raise_error;
155 End If;
156 Close C_Sel1;
157 If (p_object_version_number <> g_old_rec.object_version_number) Then
158 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
159 fnd_message.raise_error;
160 End If;
161 hr_utility.set_location(l_proc, 15);
162 l_fct_ret := true;
163 End If;
164 End If;
165 hr_utility.set_location(' Leaving:'||l_proc, 20);
166 Return (l_fct_ret);
167 --
168 End api_updating;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |--------------------------< find_dt_del_modes >---------------------------|
172 -- ----------------------------------------------------------------------------
173 Procedure find_dt_del_modes
174 (p_effective_date in date,
175 p_base_key_value in number,
176 p_zap out nocopy boolean,
177 p_delete out nocopy boolean,
178 p_future_change out nocopy boolean,
179 p_delete_next_change out nocopy boolean) is
180 --
181 l_proc varchar2(72) := g_package||'find_dt_del_modes';
182 --
183 --
184 --
185 --
186 Begin
187 hr_utility.set_location('Entering:'||l_proc, 5);
188 --
189 --
190 -- Call the corresponding datetrack api
191 --
192 dt_api.find_dt_del_modes
193 (p_effective_date => p_effective_date,
194 p_base_table_name => 'ben_regn_f',
195 p_base_key_column => 'regn_id',
196 p_base_key_value => p_base_key_value,
197 p_zap => p_zap,
198 p_delete => p_delete,
199 p_future_change => p_future_change,
200 p_delete_next_change => p_delete_next_change);
201 --
202 hr_utility.set_location(' Leaving:'||l_proc, 10);
203 End find_dt_del_modes;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |--------------------------< find_dt_upd_modes >---------------------------|
207 -- ----------------------------------------------------------------------------
208 Procedure find_dt_upd_modes
209 (p_effective_date in date,
210 p_base_key_value in number,
211 p_correction out nocopy boolean,
212 p_update out nocopy boolean,
213 p_update_override out nocopy boolean,
214 p_update_change_insert out nocopy boolean) is
215 --
216 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
217 --
218 Begin
219 hr_utility.set_location('Entering:'||l_proc, 5);
220 --
221 -- Call the corresponding datetrack api
222 --
223 dt_api.find_dt_upd_modes
224 (p_effective_date => p_effective_date,
225 p_base_table_name => 'ben_regn_f',
226 p_base_key_column => 'regn_id',
227 p_base_key_value => p_base_key_value,
228 p_correction => p_correction,
229 p_update => p_update,
230 p_update_override => p_update_override,
231 p_update_change_insert => p_update_change_insert);
232 --
233 hr_utility.set_location(' Leaving:'||l_proc, 10);
234 End find_dt_upd_modes;
235 --
236 -- ----------------------------------------------------------------------------
237 -- |------------------------< upd_effective_end_date >------------------------|
238 -- ----------------------------------------------------------------------------
239 Procedure upd_effective_end_date
240 (p_effective_date in date,
241 p_base_key_value in number,
242 p_new_effective_end_date in date,
243 p_validation_start_date in date,
244 p_validation_end_date in date,
245 p_object_version_number out nocopy number) is
246 --
247 l_proc varchar2(72) := g_package||'upd_effective_end_date';
248 l_object_version_number number;
249 --
250 Begin
251 hr_utility.set_location('Entering:'||l_proc, 5);
252 --
253 -- Because we are updating a row we must get the next object
254 -- version number.
255 --
256 l_object_version_number :=
257 dt_api.get_object_version_number
258 (p_base_table_name => 'ben_regn_f',
259 p_base_key_column => 'regn_id',
260 p_base_key_value => p_base_key_value);
261 --
262 hr_utility.set_location(l_proc, 10);
263 g_api_dml := true; -- Set the api dml status
264 --
265 -- Update the specified datetrack row setting the effective
266 -- end date to the specified new effective end date.
267 --
268 update ben_regn_f t
269 set t.effective_end_date = p_new_effective_end_date,
270 t.object_version_number = l_object_version_number
271 where t.regn_id = p_base_key_value
272 and p_effective_date
273 between t.effective_start_date and t.effective_end_date;
274 --
275 -- Update MLS table.
276 --
277 update ben_regn_f_tl t
278 set t.effective_end_date = p_new_effective_end_date,
279 t.last_update_date = sysdate,
280 t.last_updated_by = fnd_global.user_id,
281 t.last_update_login = fnd_global.login_id
282 where t.regn_id = p_base_key_value
283 and p_effective_date
284 between t.effective_start_date and t.effective_end_date;
285 --
286 g_api_dml := false; -- Unset the api dml status
287 p_object_version_number := l_object_version_number;
288 hr_utility.set_location(' Leaving:'||l_proc, 15);
289 --
290 Exception
291 When Others Then
292 g_api_dml := false; -- Unset the api dml status
293 Raise;
294 End upd_effective_end_date;
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------------< lck >----------------------------------|
298 -- ----------------------------------------------------------------------------
299 Procedure lck
300 (p_effective_date in date,
301 p_datetrack_mode in varchar2,
302 p_regn_id in number,
303 p_object_version_number in number,
304 p_validation_start_date out nocopy date,
305 p_validation_end_date out nocopy date) is
306 --
307 l_proc varchar2(72) := g_package||'lck';
308 l_validation_start_date date;
309 l_validation_end_date date;
310 l_object_invalid exception;
311 l_argument varchar2(30);
312 --
313 -- Cursor C_Sel1 selects the current locked row as of session date
314 -- ensuring that the object version numbers match.
315 --
316 Cursor C_Sel1 is
317 select
318 regn_id,
319 effective_start_date,
320 effective_end_date,
321 name,
322 organization_id,
323 business_group_id,
324 sttry_citn_name,
325 reg_attribute_category,
326 reg_attribute1,
327 reg_attribute2,
328 reg_attribute3,
329 reg_attribute4,
330 reg_attribute5,
331 reg_attribute6,
332 reg_attribute7,
333 reg_attribute8,
334 reg_attribute9,
335 reg_attribute10,
336 reg_attribute11,
337 reg_attribute12,
338 reg_attribute13,
339 reg_attribute14,
340 reg_attribute15,
341 reg_attribute16,
342 reg_attribute17,
343 reg_attribute18,
344 reg_attribute19,
345 reg_attribute20,
346 reg_attribute21,
347 reg_attribute22,
348 reg_attribute23,
349 reg_attribute24,
350 reg_attribute25,
351 reg_attribute26,
352 reg_attribute27,
353 reg_attribute28,
354 reg_attribute29,
355 reg_attribute30,
356 object_version_number
357 from ben_regn_f
358 where regn_id = p_regn_id
359 and p_effective_date
360 between effective_start_date and effective_end_date
361 for update nowait;
362 --
363 --
364 --
365 Begin
366 hr_utility.set_location('Entering:'||l_proc, 5);
367 --
368 -- Ensure that all the mandatory arguments are not null
369 --
370 hr_api.mandatory_arg_error(p_api_name => l_proc,
371 p_argument => 'effective_date',
372 p_argument_value => p_effective_date);
373 --
374 hr_api.mandatory_arg_error(p_api_name => l_proc,
375 p_argument => 'datetrack_mode',
376 p_argument_value => p_datetrack_mode);
377 --
378 hr_api.mandatory_arg_error(p_api_name => l_proc,
379 p_argument => 'regn_id',
380 p_argument_value => p_regn_id);
381 --
382 hr_api.mandatory_arg_error(p_api_name => l_proc,
383 p_argument => 'object_version_number',
384 p_argument_value => p_object_version_number);
385 --
386 -- Check to ensure the datetrack mode is not INSERT.
387 --
388 If (p_datetrack_mode <> 'INSERT') then
389 --
390 -- We must select and lock the current row.
391 --
392 Open C_Sel1;
393 Fetch C_Sel1 Into g_old_rec;
394 If C_Sel1%notfound then
395 Close C_Sel1;
396 --
397 -- The primary key is invalid therefore we must error
398 --
399 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
400 fnd_message.raise_error;
401 End If;
402 Close C_Sel1;
403 If (p_object_version_number <> g_old_rec.object_version_number) Then
404 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
405 fnd_message.raise_error;
406 End If;
407 hr_utility.set_location(l_proc, 15);
408 --
409 --
410 -- Validate the datetrack mode mode getting the validation start
411 -- and end dates for the specified datetrack operation.
412 --
413 dt_api.validate_dt_mode
414 (p_effective_date => p_effective_date,
415 p_datetrack_mode => p_datetrack_mode,
416 p_base_table_name => 'ben_regn_f',
417 p_base_key_column => 'regn_id',
418 p_base_key_value => p_regn_id,
419 p_child_table_name1 => 'ben_pl_regn_f',
420 p_child_key_column1 => 'pl_regn_id',
421 p_child_table_name2 => 'ben_regn_for_regy_body_f',
422 p_child_key_column2 => 'regn_for_regy_body_id',
423 p_enforce_foreign_locking => false , --true,
424 p_validation_start_date => l_validation_start_date,
425 p_validation_end_date => l_validation_end_date);
426 Else
427 --
428 -- We are doing a datetrack 'INSERT' which is illegal within this
429 -- procedure therefore we must error (note: to lck on insert the
430 -- private procedure ins_lck should be called).
431 --
432 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
433 fnd_message.set_token('PROCEDURE', l_proc);
434 fnd_message.set_token('STEP','20');
435 fnd_message.raise_error;
436 End If;
437 --
438 -- Set the validation start and end date OUT arguments
439 --
440 p_validation_start_date := l_validation_start_date;
441 p_validation_end_date := l_validation_end_date;
442 --
443 hr_utility.set_location(' Leaving:'||l_proc, 30);
444 --
445 -- We need to trap the ORA LOCK exception
446 --
447 Exception
448 When HR_Api.Object_Locked then
449 --
450 -- The object is locked therefore we need to supply a meaningful
451 -- error message.
452 --
453 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
454 fnd_message.set_token('TABLE_NAME', 'ben_regn_f');
455 fnd_message.raise_error;
456 When l_object_invalid then
457 --
458 -- The object doesn't exist or is invalid
459 --
460 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
461 fnd_message.set_token('TABLE_NAME', 'ben_regn_f');
462 fnd_message.raise_error;
463 End lck;
464 --
465 -- ----------------------------------------------------------------------------
466 -- |-----------------------------< convert_args >-----------------------------|
467 -- ----------------------------------------------------------------------------
468 Function convert_args
469 (
470 p_regn_id in number,
471 p_effective_start_date in date,
472 p_effective_end_date in date,
473 p_name in varchar2,
474 p_organization_id in number,
475 p_business_group_id in number,
476 p_sttry_citn_name in varchar2,
477 p_reg_attribute_category in varchar2,
478 p_reg_attribute1 in varchar2,
479 p_reg_attribute2 in varchar2,
480 p_reg_attribute3 in varchar2,
481 p_reg_attribute4 in varchar2,
482 p_reg_attribute5 in varchar2,
483 p_reg_attribute6 in varchar2,
484 p_reg_attribute7 in varchar2,
485 p_reg_attribute8 in varchar2,
486 p_reg_attribute9 in varchar2,
487 p_reg_attribute10 in varchar2,
488 p_reg_attribute11 in varchar2,
489 p_reg_attribute12 in varchar2,
490 p_reg_attribute13 in varchar2,
491 p_reg_attribute14 in varchar2,
492 p_reg_attribute15 in varchar2,
493 p_reg_attribute16 in varchar2,
494 p_reg_attribute17 in varchar2,
495 p_reg_attribute18 in varchar2,
496 p_reg_attribute19 in varchar2,
497 p_reg_attribute20 in varchar2,
498 p_reg_attribute21 in varchar2,
499 p_reg_attribute22 in varchar2,
500 p_reg_attribute23 in varchar2,
501 p_reg_attribute24 in varchar2,
502 p_reg_attribute25 in varchar2,
503 p_reg_attribute26 in varchar2,
504 p_reg_attribute27 in varchar2,
505 p_reg_attribute28 in varchar2,
506 p_reg_attribute29 in varchar2,
507 p_reg_attribute30 in varchar2,
508 p_object_version_number in number
509 )
510 Return g_rec_type is
511 --
512 l_rec g_rec_type;
513 l_proc varchar2(72) := g_package||'convert_args';
514 --
515 Begin
516 --
517 hr_utility.set_location('Entering:'||l_proc, 5);
518 --
519 -- Convert arguments into local l_rec structure.
520 --
521 l_rec.regn_id := p_regn_id;
522 l_rec.effective_start_date := p_effective_start_date;
523 l_rec.effective_end_date := p_effective_end_date;
524 l_rec.name := p_name;
525 l_rec.organization_id := p_organization_id;
526 l_rec.business_group_id := p_business_group_id;
527 l_rec.sttry_citn_name := p_sttry_citn_name;
528 l_rec.reg_attribute_category := p_reg_attribute_category;
529 l_rec.reg_attribute1 := p_reg_attribute1;
530 l_rec.reg_attribute2 := p_reg_attribute2;
531 l_rec.reg_attribute3 := p_reg_attribute3;
532 l_rec.reg_attribute4 := p_reg_attribute4;
533 l_rec.reg_attribute5 := p_reg_attribute5;
534 l_rec.reg_attribute6 := p_reg_attribute6;
535 l_rec.reg_attribute7 := p_reg_attribute7;
536 l_rec.reg_attribute8 := p_reg_attribute8;
537 l_rec.reg_attribute9 := p_reg_attribute9;
538 l_rec.reg_attribute10 := p_reg_attribute10;
539 l_rec.reg_attribute11 := p_reg_attribute11;
540 l_rec.reg_attribute12 := p_reg_attribute12;
541 l_rec.reg_attribute13 := p_reg_attribute13;
542 l_rec.reg_attribute14 := p_reg_attribute14;
543 l_rec.reg_attribute15 := p_reg_attribute15;
544 l_rec.reg_attribute16 := p_reg_attribute16;
545 l_rec.reg_attribute17 := p_reg_attribute17;
546 l_rec.reg_attribute18 := p_reg_attribute18;
547 l_rec.reg_attribute19 := p_reg_attribute19;
548 l_rec.reg_attribute20 := p_reg_attribute20;
549 l_rec.reg_attribute21 := p_reg_attribute21;
550 l_rec.reg_attribute22 := p_reg_attribute22;
551 l_rec.reg_attribute23 := p_reg_attribute23;
552 l_rec.reg_attribute24 := p_reg_attribute24;
553 l_rec.reg_attribute25 := p_reg_attribute25;
554 l_rec.reg_attribute26 := p_reg_attribute26;
555 l_rec.reg_attribute27 := p_reg_attribute27;
556 l_rec.reg_attribute28 := p_reg_attribute28;
557 l_rec.reg_attribute29 := p_reg_attribute29;
558 l_rec.reg_attribute30 := p_reg_attribute30;
559 l_rec.object_version_number := p_object_version_number;
560 --
561 -- Return the plsql record structure.
562 --
563 hr_utility.set_location(' Leaving:'||l_proc, 10);
564 Return(l_rec);
565 --
566 End convert_args;
567 --
568 -- ----------------------------------------------------------------------------
569 -- |--------------------------<add_language>----------------------------------|
570 -- ----------------------------------------------------------------------------
571 Procedure add_language
572 is
573 begin
574 delete from ben_regn_f_tl t
575 where not exists
576 (select null
577 from ben_regn_f_tl b
578 where b.regn_id = t.regn_id
579 and b.effective_start_date = t.effective_start_date
580 );
581
582 update ben_regn_f_tl t set (
583 name,
584 sttry_citn_name
585 ) = (select
586 b.name,
587 b.sttry_citn_name
588 from ben_regn_f_tl b
589 where b.regn_id = t.regn_id
590 and b.effective_start_date = t.effective_start_date
591 and b.language = t.source_lang)
592 where (
593 t.regn_id,
594 t.effective_start_date,
595 t.language
596 ) in (select
597 subt.regn_id,
598 subt.effective_start_date,
599 subt.language
600 from ben_regn_f_tl subb, ben_regn_f_tl subt
601 where subb.regn_id = subt.regn_id
602 and subb.effective_start_date = subt.effective_start_date
603 and subb.language = subt.source_lang
604 and (subb.name <> subt.name
605 or subb.sttry_citn_name <> subt.sttry_citn_name
606 ));
607
608 insert into ben_regn_f_tl (
609 regn_id,
610 effective_start_date,
611 effective_end_date,
612 name,
613 sttry_citn_name,
614 language,
615 source_lang,
616 last_update_date,
617 last_updated_by,
618 last_update_login,
619 created_by,
620 creation_date
621 ) select
622 b.regn_id,
623 b.effective_start_date,
624 b.effective_end_date,
625 b.name,
626 b.sttry_citn_name,
627 l.language_code,
628 b.source_lang,
629 b.last_update_date,
630 b.last_updated_by,
631 b.last_update_login,
632 b.created_by,
633 b.creation_date
634 from ben_regn_f_tl b, fnd_languages l
635 where l.installed_flag in ('I', 'B')
636 and b.language = userenv('LANG')
637 and not exists
638 (select null
639 from ben_regn_f_tl t
640 where t.regn_id = b.regn_id
641 and t.effective_start_date = b.effective_start_date
642 and t.language = l.language_code);
643 end add_language;
644 --
645 end ben_reg_shd;