[Home] [Help]
PACKAGE BODY: APPS.BEN_BNB_SHD
Source
1 Package Body ben_bnb_shd as
2 /* $Header: bebnbrhi.pkb 120.1 2006/04/02 22:53:31 abparekh noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bnb_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_BNFTS_BAL_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_bnfts_bal_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 bnfts_bal_id,
66 effective_start_date,
67 effective_end_date,
68 name,
69 bnfts_bal_usg_cd,
70 bnfts_bal_desc,
71 uom,
72 nnmntry_uom,
73 business_group_id,
74 bnb_attribute_category,
75 bnb_attribute1,
76 bnb_attribute2,
77 bnb_attribute3,
78 bnb_attribute4,
79 bnb_attribute5,
80 bnb_attribute6,
81 bnb_attribute7,
82 bnb_attribute8,
83 bnb_attribute9,
84 bnb_attribute10,
85 bnb_attribute11,
86 bnb_attribute12,
87 bnb_attribute13,
88 bnb_attribute14,
89 bnb_attribute15,
90 bnb_attribute16,
91 bnb_attribute17,
92 bnb_attribute18,
93 bnb_attribute19,
94 bnb_attribute20,
95 bnb_attribute21,
96 bnb_attribute22,
97 bnb_attribute23,
98 bnb_attribute24,
99 bnb_attribute25,
100 bnb_attribute26,
101 bnb_attribute27,
102 bnb_attribute28,
103 bnb_attribute29,
104 bnb_attribute30,
105 object_version_number
106 from ben_bnfts_bal_f
107 where bnfts_bal_id = p_bnfts_bal_id
108 and p_effective_date
109 between effective_start_date and effective_end_date;
110 --
111 l_proc varchar2(72) := g_package||'api_updating';
112 l_fct_ret boolean;
113 --
114 Begin
115 hr_utility.set_location('Entering:'||l_proc, 5);
116 --
117 If (p_effective_date is null or
118 p_bnfts_bal_id is null or
119 p_object_version_number is null) Then
120 --
121 -- One of the primary key arguments is null therefore we must
122 -- set the returning function value to false
123 --
124 l_fct_ret := false;
125 Else
126 If (p_bnfts_bal_id = g_old_rec.bnfts_bal_id and
127 p_object_version_number = g_old_rec.object_version_number) Then
128 hr_utility.set_location(l_proc, 10);
129 --
130 -- The g_old_rec is current therefore we must
131 -- set the returning function to true
132 --
133 l_fct_ret := true;
134 Else
135 --
136 -- Select the current row
137 --
138 Open C_Sel1;
139 Fetch C_Sel1 Into g_old_rec;
140 If C_Sel1%notfound Then
141 Close C_Sel1;
142 --
143 -- The primary key is invalid therefore we must error
144 --
145 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
146 fnd_message.raise_error;
147 End If;
148 Close C_Sel1;
149 If (p_object_version_number <> g_old_rec.object_version_number) Then
150 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
151 fnd_message.raise_error;
152 End If;
153 hr_utility.set_location(l_proc, 15);
154 l_fct_ret := true;
155 End If;
156 End If;
157 hr_utility.set_location(' Leaving:'||l_proc, 20);
158 Return (l_fct_ret);
159 --
160 End api_updating;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |--------------------------< find_dt_del_modes >---------------------------|
164 -- ----------------------------------------------------------------------------
165 Procedure find_dt_del_modes
166 (p_effective_date in date,
167 p_base_key_value in number,
168 p_zap out nocopy boolean,
169 p_delete out nocopy boolean,
170 p_future_change out nocopy boolean,
171 p_delete_next_change out nocopy boolean) is
172 --
173 l_proc varchar2(72) := g_package||'find_dt_del_modes';
174 --
175 --
176 --
177 --
178 Begin
179 hr_utility.set_location('Entering:'||l_proc, 5);
180 --
181 --
182 -- Call the corresponding datetrack api
183 --
184 dt_api.find_dt_del_modes
185 (p_effective_date => p_effective_date,
186 p_base_table_name => 'ben_bnfts_bal_f',
187 p_base_key_column => 'bnfts_bal_id',
188 p_base_key_value => p_base_key_value,
189 p_zap => p_zap,
190 p_delete => p_delete,
191 p_future_change => p_future_change,
192 p_delete_next_change => p_delete_next_change);
193 --
194 hr_utility.set_location(' Leaving:'||l_proc, 10);
195 End find_dt_del_modes;
196 --
197 -- ----------------------------------------------------------------------------
198 -- |--------------------------< find_dt_upd_modes >---------------------------|
199 -- ----------------------------------------------------------------------------
200 Procedure find_dt_upd_modes
201 (p_effective_date in date,
202 p_base_key_value in number,
203 p_correction out nocopy boolean,
204 p_update out nocopy boolean,
205 p_update_override out nocopy boolean,
206 p_update_change_insert out nocopy boolean) is
207 --
208 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
209 --
210 Begin
211 hr_utility.set_location('Entering:'||l_proc, 5);
212 --
213 -- Call the corresponding datetrack api
214 --
215 dt_api.find_dt_upd_modes
216 (p_effective_date => p_effective_date,
217 p_base_table_name => 'ben_bnfts_bal_f',
218 p_base_key_column => 'bnfts_bal_id',
219 p_base_key_value => p_base_key_value,
220 p_correction => p_correction,
221 p_update => p_update,
222 p_update_override => p_update_override,
223 p_update_change_insert => p_update_change_insert);
224 --
225 hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End find_dt_upd_modes;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |------------------------< upd_effective_end_date >------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure upd_effective_end_date
232 (p_effective_date in date,
233 p_base_key_value in number,
234 p_new_effective_end_date in date,
235 p_validation_start_date in date,
236 p_validation_end_date in date,
237 p_object_version_number out nocopy number) is
238 --
239 l_proc varchar2(72) := g_package||'upd_effective_end_date';
240 l_object_version_number number;
241 --
242 Begin
243 hr_utility.set_location('Entering:'||l_proc, 5);
244 --
245 -- Because we are updating a row we must get the next object
246 -- version number.
247 --
248 l_object_version_number :=
249 dt_api.get_object_version_number
250 (p_base_table_name => 'ben_bnfts_bal_f',
251 p_base_key_column => 'bnfts_bal_id',
252 p_base_key_value => p_base_key_value);
253 --
254 hr_utility.set_location(l_proc, 10);
255 g_api_dml := true; -- Set the api dml status
256 --
257 -- Update the specified datetrack row setting the effective
258 -- end date to the specified new effective end date.
259 --
260 update ben_bnfts_bal_f t
261 set t.effective_end_date = p_new_effective_end_date,
262 t.object_version_number = l_object_version_number
263 where t.bnfts_bal_id = p_base_key_value
264 and p_effective_date
265 between t.effective_start_date and t.effective_end_date;
266 --
267 g_api_dml := false; -- Unset the api dml status
268 p_object_version_number := l_object_version_number;
269 hr_utility.set_location(' Leaving:'||l_proc, 15);
270 --
271 Exception
272 When Others Then
273 g_api_dml := false; -- Unset the api dml status
274 Raise;
275 End upd_effective_end_date;
276 --
277 -- ----------------------------------------------------------------------------
278 -- |---------------------------------< lck >----------------------------------|
279 -- ----------------------------------------------------------------------------
280 Procedure lck
281 (p_effective_date in date,
282 p_datetrack_mode in varchar2,
283 p_bnfts_bal_id in number,
284 p_object_version_number in number,
285 p_validation_start_date out nocopy date,
286 p_validation_end_date out nocopy date) is
287 --
288 l_proc varchar2(72) := g_package||'lck';
289 l_validation_start_date date;
290 l_validation_end_date date;
291 l_object_invalid exception;
292 l_argument varchar2(30);
293 --
294 -- Cursor C_Sel1 selects the current locked row as of session date
295 -- ensuring that the object version numbers match.
296 --
297 Cursor C_Sel1 is
298 select
299 bnfts_bal_id,
300 effective_start_date,
301 effective_end_date,
302 name,
303 bnfts_bal_usg_cd,
304 bnfts_bal_desc,
305 uom,
306 nnmntry_uom,
307 business_group_id,
308 bnb_attribute_category,
309 bnb_attribute1,
310 bnb_attribute2,
311 bnb_attribute3,
312 bnb_attribute4,
313 bnb_attribute5,
314 bnb_attribute6,
315 bnb_attribute7,
316 bnb_attribute8,
317 bnb_attribute9,
318 bnb_attribute10,
319 bnb_attribute11,
320 bnb_attribute12,
321 bnb_attribute13,
322 bnb_attribute14,
323 bnb_attribute15,
324 bnb_attribute16,
325 bnb_attribute17,
326 bnb_attribute18,
327 bnb_attribute19,
328 bnb_attribute20,
329 bnb_attribute21,
330 bnb_attribute22,
331 bnb_attribute23,
332 bnb_attribute24,
333 bnb_attribute25,
334 bnb_attribute26,
335 bnb_attribute27,
336 bnb_attribute28,
337 bnb_attribute29,
338 bnb_attribute30,
339 object_version_number
340 from ben_bnfts_bal_f
341 where bnfts_bal_id = p_bnfts_bal_id
342 and p_effective_date
343 between effective_start_date and effective_end_date
344 for update nowait;
345 --
346 --
347 --
348 Begin
349 hr_utility.set_location('Entering:'||l_proc, 5);
350 --
351 -- Ensure that all the mandatory arguments are not null
352 --
353 hr_api.mandatory_arg_error(p_api_name => l_proc,
354 p_argument => 'effective_date',
355 p_argument_value => p_effective_date);
356 --
357 hr_api.mandatory_arg_error(p_api_name => l_proc,
358 p_argument => 'datetrack_mode',
359 p_argument_value => p_datetrack_mode);
360 --
361 hr_api.mandatory_arg_error(p_api_name => l_proc,
362 p_argument => 'bnfts_bal_id',
363 p_argument_value => p_bnfts_bal_id);
364 --
365 hr_api.mandatory_arg_error(p_api_name => l_proc,
366 p_argument => 'object_version_number',
367 p_argument_value => p_object_version_number);
368 --
369 -- Check to ensure the datetrack mode is not INSERT.
370 --
371 If (p_datetrack_mode <> 'INSERT') then
372 --
373 -- We must select and lock the current row.
374 --
375 Open C_Sel1;
376 Fetch C_Sel1 Into g_old_rec;
377 If C_Sel1%notfound then
378 Close C_Sel1;
379 --
380 -- The primary key is invalid therefore we must error
381 --
382 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
383 fnd_message.raise_error;
384 End If;
385 Close C_Sel1;
386 If (p_object_version_number <> g_old_rec.object_version_number) Then
387 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
388 fnd_message.raise_error;
389 End If;
390 hr_utility.set_location(l_proc, 15);
391 --
392 --
393 -- Validate the datetrack mode mode getting the validation start
394 -- and end dates for the specified datetrack operation.
395 --
396 dt_api.validate_dt_mode
397 (p_effective_date => p_effective_date,
398 p_datetrack_mode => p_datetrack_mode,
399 p_base_table_name => 'ben_bnfts_bal_f',
400 p_base_key_column => 'bnfts_bal_id',
401 p_base_key_value => p_bnfts_bal_id,
402 p_child_table_name1 => 'ben_per_bnfts_bal_f',
403 p_child_key_column1 => 'per_bnfts_bal_id',
404 p_enforce_foreign_locking => false, /* Bug 5133119 */
405 p_validation_start_date => l_validation_start_date,
406 p_validation_end_date => l_validation_end_date);
407 Else
408 --
409 -- We are doing a datetrack 'INSERT' which is illegal within this
410 -- procedure therefore we must error (note: to lck on insert the
411 -- private procedure ins_lck should be called).
412 --
413 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
414 fnd_message.set_token('PROCEDURE', l_proc);
415 fnd_message.set_token('STEP','20');
416 fnd_message.raise_error;
417 End If;
418 --
419 -- Set the validation start and end date OUT arguments
420 --
421 p_validation_start_date := l_validation_start_date;
422 p_validation_end_date := l_validation_end_date;
423 --
424 hr_utility.set_location(' Leaving:'||l_proc, 30);
425 --
426 -- We need to trap the ORA LOCK exception
427 --
428 Exception
429 When HR_Api.Object_Locked then
430 --
431 -- The object is locked therefore we need to supply a meaningful
432 -- error message.
433 --
434 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
435 fnd_message.set_token('TABLE_NAME', 'ben_bnfts_bal_f');
436 fnd_message.raise_error;
437 When l_object_invalid then
441 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
438 --
439 -- The object doesn't exist or is invalid
440 --
442 fnd_message.set_token('TABLE_NAME', 'ben_bnfts_bal_f');
443 fnd_message.raise_error;
444 End lck;
445 --
446 -- ----------------------------------------------------------------------------
447 -- |-----------------------------< convert_args >-----------------------------|
448 -- ----------------------------------------------------------------------------
449 Function convert_args
450 (
451 p_bnfts_bal_id in number,
452 p_effective_start_date in date,
453 p_effective_end_date in date,
454 p_name in varchar2,
455 p_bnfts_bal_usg_cd in varchar2,
456 p_bnfts_bal_desc in varchar2,
457 p_uom in varchar2,
458 p_nnmntry_uom in varchar2,
459 p_business_group_id in number,
460 p_bnb_attribute_category in varchar2,
461 p_bnb_attribute1 in varchar2,
462 p_bnb_attribute2 in varchar2,
463 p_bnb_attribute3 in varchar2,
464 p_bnb_attribute4 in varchar2,
465 p_bnb_attribute5 in varchar2,
466 p_bnb_attribute6 in varchar2,
467 p_bnb_attribute7 in varchar2,
468 p_bnb_attribute8 in varchar2,
469 p_bnb_attribute9 in varchar2,
470 p_bnb_attribute10 in varchar2,
471 p_bnb_attribute11 in varchar2,
472 p_bnb_attribute12 in varchar2,
473 p_bnb_attribute13 in varchar2,
474 p_bnb_attribute14 in varchar2,
475 p_bnb_attribute15 in varchar2,
476 p_bnb_attribute16 in varchar2,
477 p_bnb_attribute17 in varchar2,
478 p_bnb_attribute18 in varchar2,
479 p_bnb_attribute19 in varchar2,
480 p_bnb_attribute20 in varchar2,
481 p_bnb_attribute21 in varchar2,
482 p_bnb_attribute22 in varchar2,
483 p_bnb_attribute23 in varchar2,
484 p_bnb_attribute24 in varchar2,
485 p_bnb_attribute25 in varchar2,
486 p_bnb_attribute26 in varchar2,
487 p_bnb_attribute27 in varchar2,
488 p_bnb_attribute28 in varchar2,
489 p_bnb_attribute29 in varchar2,
490 p_bnb_attribute30 in varchar2,
491 p_object_version_number in number
492 )
493 Return g_rec_type is
494 --
495 l_rec g_rec_type;
496 l_proc varchar2(72) := g_package||'convert_args';
497 --
498 Begin
499 --
500 hr_utility.set_location('Entering:'||l_proc, 5);
501 --
502 -- Convert arguments into local l_rec structure.
503 --
504 l_rec.bnfts_bal_id := p_bnfts_bal_id;
505 l_rec.effective_start_date := p_effective_start_date;
506 l_rec.effective_end_date := p_effective_end_date;
507 l_rec.name := p_name;
508 l_rec.bnfts_bal_usg_cd := p_bnfts_bal_usg_cd;
509 l_rec.bnfts_bal_desc := p_bnfts_bal_desc;
510 l_rec.uom := p_uom;
511 l_rec.nnmntry_uom := p_nnmntry_uom;
512 l_rec.business_group_id := p_business_group_id;
513 l_rec.bnb_attribute_category := p_bnb_attribute_category;
514 l_rec.bnb_attribute1 := p_bnb_attribute1;
515 l_rec.bnb_attribute2 := p_bnb_attribute2;
516 l_rec.bnb_attribute3 := p_bnb_attribute3;
517 l_rec.bnb_attribute4 := p_bnb_attribute4;
518 l_rec.bnb_attribute5 := p_bnb_attribute5;
519 l_rec.bnb_attribute6 := p_bnb_attribute6;
520 l_rec.bnb_attribute7 := p_bnb_attribute7;
521 l_rec.bnb_attribute8 := p_bnb_attribute8;
522 l_rec.bnb_attribute9 := p_bnb_attribute9;
523 l_rec.bnb_attribute10 := p_bnb_attribute10;
524 l_rec.bnb_attribute11 := p_bnb_attribute11;
525 l_rec.bnb_attribute12 := p_bnb_attribute12;
526 l_rec.bnb_attribute13 := p_bnb_attribute13;
527 l_rec.bnb_attribute14 := p_bnb_attribute14;
528 l_rec.bnb_attribute15 := p_bnb_attribute15;
529 l_rec.bnb_attribute16 := p_bnb_attribute16;
530 l_rec.bnb_attribute17 := p_bnb_attribute17;
531 l_rec.bnb_attribute18 := p_bnb_attribute18;
532 l_rec.bnb_attribute19 := p_bnb_attribute19;
533 l_rec.bnb_attribute20 := p_bnb_attribute20;
534 l_rec.bnb_attribute21 := p_bnb_attribute21;
535 l_rec.bnb_attribute22 := p_bnb_attribute22;
536 l_rec.bnb_attribute23 := p_bnb_attribute23;
537 l_rec.bnb_attribute24 := p_bnb_attribute24;
538 l_rec.bnb_attribute25 := p_bnb_attribute25;
539 l_rec.bnb_attribute26 := p_bnb_attribute26;
540 l_rec.bnb_attribute27 := p_bnb_attribute27;
541 l_rec.bnb_attribute28 := p_bnb_attribute28;
542 l_rec.bnb_attribute29 := p_bnb_attribute29;
543 l_rec.bnb_attribute30 := p_bnb_attribute30;
544 l_rec.object_version_number := p_object_version_number;
545 --
546 -- Return the plsql record structure.
547 --
548 hr_utility.set_location(' Leaving:'||l_proc, 10);
549 Return(l_rec);
550 --
551 End convert_args;
552 --
553 end ben_bnb_shd;