[Home] [Help]
PACKAGE BODY: APPS.BEN_BTR_SHD
Source
1 Package Body ben_btr_shd as
2 /* $Header: bebtrrhi.pkb 120.0.12010000.2 2008/08/05 14:13:49 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_btr_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_COMP_LVL_ACTY_RT_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_COMP_LVL_ACTY_RT_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_COMP_LVL_ACTY_RT_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_comp_lvl_acty_rt_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 comp_lvl_acty_rt_id,
76 effective_start_date,
77 effective_end_date,
78 dflt_flag,
79 comp_lvl_fctr_id,
80 acty_base_rt_id,
81 business_group_id,
82 btr_attribute_category,
83 btr_attribute1,
84 btr_attribute2,
85 btr_attribute3,
86 btr_attribute4,
87 btr_attribute5,
88 btr_attribute6,
89 btr_attribute7,
90 btr_attribute8,
91 btr_attribute9,
92 btr_attribute10,
93 btr_attribute11,
94 btr_attribute12,
95 btr_attribute13,
96 btr_attribute14,
97 btr_attribute15,
98 btr_attribute16,
99 btr_attribute17,
100 btr_attribute18,
101 btr_attribute19,
102 btr_attribute20,
103 btr_attribute21,
104 btr_attribute22,
105 btr_attribute23,
106 btr_attribute24,
107 btr_attribute25,
108 btr_attribute26,
109 btr_attribute27,
110 btr_attribute28,
111 btr_attribute29,
112 btr_attribute30,
113 object_version_number
114 from ben_comp_lvl_acty_rt_f
115 where comp_lvl_acty_rt_id = p_comp_lvl_acty_rt_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_comp_lvl_acty_rt_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_comp_lvl_acty_rt_id = g_old_rec.comp_lvl_acty_rt_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 l_parent_key_value1 number;
184 --
185 Cursor C_Sel1 Is
186 select t.acty_base_rt_id
187 from ben_comp_lvl_acty_rt_f t
188 where t.comp_lvl_acty_rt_id = p_base_key_value
189 and p_effective_date
190 between t.effective_start_date and t.effective_end_date;
191 --
192 Begin
193 hr_utility.set_location('Entering:'||l_proc, 5);
194 Open C_Sel1;
195 Fetch C_Sel1 Into l_parent_key_value1;
196 If C_Sel1%notfound then
197 Close C_Sel1;
198 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
199 fnd_message.set_token('PROCEDURE', l_proc);
200 fnd_message.set_token('STEP','10');
201 fnd_message.raise_error;
202 End If;
203 Close C_Sel1;
204 --
205 -- Call the corresponding datetrack api
206 --
207 dt_api.find_dt_del_modes
208 (p_effective_date => p_effective_date,
209 p_base_table_name => 'ben_comp_lvl_acty_rt_f',
210 p_base_key_column => 'comp_lvl_acty_rt_id',
211 p_base_key_value => p_base_key_value,
212 p_parent_table_name1 => 'ben_acty_base_rt_f',
213 p_parent_key_column1 => 'acty_base_rt_id',
214 p_parent_key_value1 => l_parent_key_value1,
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_comp_lvl_acty_rt_f',
244 p_base_key_column => 'comp_lvl_acty_rt_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_comp_lvl_acty_rt_f',
277 p_base_key_column => 'comp_lvl_acty_rt_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_comp_lvl_acty_rt_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.comp_lvl_acty_rt_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_comp_lvl_acty_rt_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 comp_lvl_acty_rt_id,
326 effective_start_date,
327 effective_end_date,
328 dflt_flag,
329 comp_lvl_fctr_id,
330 acty_base_rt_id,
331 business_group_id,
332 btr_attribute_category,
333 btr_attribute1,
334 btr_attribute2,
335 btr_attribute3,
336 btr_attribute4,
337 btr_attribute5,
338 btr_attribute6,
339 btr_attribute7,
340 btr_attribute8,
341 btr_attribute9,
342 btr_attribute10,
343 btr_attribute11,
344 btr_attribute12,
345 btr_attribute13,
346 btr_attribute14,
347 btr_attribute15,
348 btr_attribute16,
349 btr_attribute17,
350 btr_attribute18,
351 btr_attribute19,
352 btr_attribute20,
353 btr_attribute21,
354 btr_attribute22,
355 btr_attribute23,
356 btr_attribute24,
357 btr_attribute25,
358 btr_attribute26,
359 btr_attribute27,
360 btr_attribute28,
361 btr_attribute29,
362 btr_attribute30,
363 object_version_number
364 from ben_comp_lvl_acty_rt_f
365 where comp_lvl_acty_rt_id = p_comp_lvl_acty_rt_id
366 and p_effective_date
367 between effective_start_date and effective_end_date
368 for update nowait;
369 --
370 --
371 --
372 Begin
373 hr_utility.set_location('Entering:'||l_proc, 5);
374 --
375 -- Ensure that all the mandatory arguments are not null
376 --
377 hr_api.mandatory_arg_error(p_api_name => l_proc,
378 p_argument => 'effective_date',
379 p_argument_value => p_effective_date);
380 --
381 hr_api.mandatory_arg_error(p_api_name => l_proc,
382 p_argument => 'datetrack_mode',
383 p_argument_value => p_datetrack_mode);
384 --
385 hr_api.mandatory_arg_error(p_api_name => l_proc,
386 p_argument => 'comp_lvl_acty_rt_id',
387 p_argument_value => p_comp_lvl_acty_rt_id);
388 --
389 hr_api.mandatory_arg_error(p_api_name => l_proc,
390 p_argument => 'object_version_number',
391 p_argument_value => p_object_version_number);
392 --
393 -- Check to ensure the datetrack mode is not INSERT.
394 --
395 If (p_datetrack_mode <> 'INSERT') then
396 --
397 -- We must select and lock the current row.
398 --
399 Open C_Sel1;
400 Fetch C_Sel1 Into g_old_rec;
401 If C_Sel1%notfound then
402 Close C_Sel1;
403 --
404 -- The primary key is invalid therefore we must error
405 --
406 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
407 fnd_message.raise_error;
408 End If;
409 Close C_Sel1;
410 If (p_object_version_number <> g_old_rec.object_version_number) Then
411 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
412 fnd_message.raise_error;
413 End If;
414 hr_utility.set_location(l_proc, 15);
415 --
416 --
417 -- Validate the datetrack mode mode getting the validation start
418 -- and end dates for the specified datetrack operation.
419 --
420 dt_api.validate_dt_mode
421 (p_effective_date => p_effective_date,
422 p_datetrack_mode => p_datetrack_mode,
423 p_base_table_name => 'ben_comp_lvl_acty_rt_f',
424 p_base_key_column => 'comp_lvl_acty_rt_id',
425 p_base_key_value => p_comp_lvl_acty_rt_id,
426 p_parent_table_name1 => 'ben_acty_base_rt_f',
427 p_parent_key_column1 => 'acty_base_rt_id',
431 p_validation_end_date => l_validation_end_date);
428 p_parent_key_value1 => g_old_rec.acty_base_rt_id,
429 p_enforce_foreign_locking => false ,--true,
430 p_validation_start_date => l_validation_start_date,
432 Else
433 --
434 -- We are doing a datetrack 'INSERT' which is illegal within this
435 -- procedure therefore we must error (note: to lck on insert the
436 -- private procedure ins_lck should be called).
437 --
438 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
439 fnd_message.set_token('PROCEDURE', l_proc);
440 fnd_message.set_token('STEP','20');
441 fnd_message.raise_error;
442 End If;
443 --
444 -- Set the validation start and end date OUT arguments
445 --
446 p_validation_start_date := l_validation_start_date;
447 p_validation_end_date := l_validation_end_date;
448 --
449 hr_utility.set_location(' Leaving:'||l_proc, 30);
450 --
451 -- We need to trap the ORA LOCK exception
452 --
453 Exception
454 When HR_Api.Object_Locked then
455 --
456 -- The object is locked therefore we need to supply a meaningful
457 -- error message.
458 --
459 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
460 fnd_message.set_token('TABLE_NAME', 'ben_comp_lvl_acty_rt_f');
461 fnd_message.raise_error;
462 When l_object_invalid then
463 --
464 -- The object doesn't exist or is invalid
465 --
466 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
467 fnd_message.set_token('TABLE_NAME', 'ben_comp_lvl_acty_rt_f');
468 fnd_message.raise_error;
469 End lck;
470 --
471 -- ----------------------------------------------------------------------------
472 -- |-----------------------------< convert_args >-----------------------------|
473 -- ----------------------------------------------------------------------------
474 Function convert_args
475 (
476 p_comp_lvl_acty_rt_id in number,
477 p_effective_start_date in date,
478 p_effective_end_date in date,
479 p_dflt_flag in varchar2,
480 p_comp_lvl_fctr_id in number,
481 p_acty_base_rt_id in number,
482 p_business_group_id in number,
483 p_btr_attribute_category in varchar2,
484 p_btr_attribute1 in varchar2,
485 p_btr_attribute2 in varchar2,
486 p_btr_attribute3 in varchar2,
487 p_btr_attribute4 in varchar2,
488 p_btr_attribute5 in varchar2,
489 p_btr_attribute6 in varchar2,
490 p_btr_attribute7 in varchar2,
491 p_btr_attribute8 in varchar2,
492 p_btr_attribute9 in varchar2,
493 p_btr_attribute10 in varchar2,
494 p_btr_attribute11 in varchar2,
495 p_btr_attribute12 in varchar2,
496 p_btr_attribute13 in varchar2,
497 p_btr_attribute14 in varchar2,
498 p_btr_attribute15 in varchar2,
499 p_btr_attribute16 in varchar2,
500 p_btr_attribute17 in varchar2,
501 p_btr_attribute18 in varchar2,
502 p_btr_attribute19 in varchar2,
503 p_btr_attribute20 in varchar2,
504 p_btr_attribute21 in varchar2,
505 p_btr_attribute22 in varchar2,
506 p_btr_attribute23 in varchar2,
507 p_btr_attribute24 in varchar2,
508 p_btr_attribute25 in varchar2,
509 p_btr_attribute26 in varchar2,
510 p_btr_attribute27 in varchar2,
511 p_btr_attribute28 in varchar2,
512 p_btr_attribute29 in varchar2,
513 p_btr_attribute30 in varchar2,
514 p_object_version_number in number
515 )
516 Return g_rec_type is
517 --
518 l_rec g_rec_type;
519 l_proc varchar2(72) := g_package||'convert_args';
520 --
521 Begin
522 --
523 hr_utility.set_location('Entering:'||l_proc, 5);
524 --
525 -- Convert arguments into local l_rec structure.
526 --
527 l_rec.comp_lvl_acty_rt_id := p_comp_lvl_acty_rt_id;
528 l_rec.effective_start_date := p_effective_start_date;
529 l_rec.effective_end_date := p_effective_end_date;
530 l_rec.dflt_flag := p_dflt_flag;
531 l_rec.comp_lvl_fctr_id := p_comp_lvl_fctr_id;
532 l_rec.acty_base_rt_id := p_acty_base_rt_id;
533 l_rec.business_group_id := p_business_group_id;
534 l_rec.btr_attribute_category := p_btr_attribute_category;
535 l_rec.btr_attribute1 := p_btr_attribute1;
536 l_rec.btr_attribute2 := p_btr_attribute2;
537 l_rec.btr_attribute3 := p_btr_attribute3;
538 l_rec.btr_attribute4 := p_btr_attribute4;
539 l_rec.btr_attribute5 := p_btr_attribute5;
540 l_rec.btr_attribute6 := p_btr_attribute6;
541 l_rec.btr_attribute7 := p_btr_attribute7;
542 l_rec.btr_attribute8 := p_btr_attribute8;
543 l_rec.btr_attribute9 := p_btr_attribute9;
544 l_rec.btr_attribute10 := p_btr_attribute10;
545 l_rec.btr_attribute11 := p_btr_attribute11;
546 l_rec.btr_attribute12 := p_btr_attribute12;
547 l_rec.btr_attribute13 := p_btr_attribute13;
548 l_rec.btr_attribute14 := p_btr_attribute14;
549 l_rec.btr_attribute15 := p_btr_attribute15;
550 l_rec.btr_attribute16 := p_btr_attribute16;
551 l_rec.btr_attribute17 := p_btr_attribute17;
552 l_rec.btr_attribute18 := p_btr_attribute18;
553 l_rec.btr_attribute19 := p_btr_attribute19;
554 l_rec.btr_attribute20 := p_btr_attribute20;
555 l_rec.btr_attribute21 := p_btr_attribute21;
556 l_rec.btr_attribute22 := p_btr_attribute22;
557 l_rec.btr_attribute23 := p_btr_attribute23;
558 l_rec.btr_attribute24 := p_btr_attribute24;
559 l_rec.btr_attribute25 := p_btr_attribute25;
560 l_rec.btr_attribute26 := p_btr_attribute26;
561 l_rec.btr_attribute27 := p_btr_attribute27;
562 l_rec.btr_attribute28 := p_btr_attribute28;
563 l_rec.btr_attribute29 := p_btr_attribute29;
564 l_rec.btr_attribute30 := p_btr_attribute30;
565 l_rec.object_version_number := p_object_version_number;
566 --
567 -- Return the plsql record structure.
568 --
569 hr_utility.set_location(' Leaving:'||l_proc, 10);
570 Return(l_rec);
571 --
572 End convert_args;
573 --
574 end ben_btr_shd;