[Home] [Help]
PACKAGE BODY: APPS.BEN_TUR_SHD
Source
4 -- ----------------------------------------------------------------------------
1 Package Body ben_tur_shd as
2 /* $Header: beturrhi.pkb 120.1 2008/02/05 08:20:57 rtagarra noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_tur_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_TBCO_USE_RT_PK') Then
37 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38 hr_utility.set_message_token('PROCEDURE', l_proc);
39 hr_utility.set_message_token('STEP','5');
40 hr_utility.raise_error;
41 Else
42 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
43 hr_utility.set_message_token('PROCEDURE', l_proc);
44 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
45 hr_utility.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_tbco_use_rt_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 tbco_use_rt_id,
66 effective_start_date,
67 effective_end_date,
68 business_group_id,
69 vrbl_rt_prfl_id,
70 excld_flag,
71 ordr_num,
72 uses_tbco_flag,
73 tur_attribute_category,
74 tur_attribute1,
75 tur_attribute2,
76 tur_attribute3,
77 tur_attribute4,
78 tur_attribute5,
79 tur_attribute6,
80 tur_attribute7,
81 tur_attribute8,
82 tur_attribute9,
83 tur_attribute10,
84 tur_attribute11,
85 tur_attribute12,
86 tur_attribute13,
87 tur_attribute14,
88 tur_attribute15,
89 tur_attribute16,
90 tur_attribute17,
91 tur_attribute18,
92 tur_attribute19,
93 tur_attribute20,
94 tur_attribute21,
95 tur_attribute22,
96 tur_attribute23,
97 tur_attribute24,
98 tur_attribute25,
99 tur_attribute26,
100 tur_attribute27,
101 tur_attribute28,
102 tur_attribute29,
103 tur_attribute30,
104 object_version_number
105 from ben_tbco_use_rt_f
106 where tbco_use_rt_id = p_tbco_use_rt_id
107 and p_effective_date
108 between effective_start_date and effective_end_date;
109 --
110 l_proc varchar2(72) := g_package||'api_updating';
111 l_fct_ret boolean;
112 --
113 Begin
114 hr_utility.set_location('Entering:'||l_proc, 5);
115 --
116 If (p_effective_date is null or
117 p_tbco_use_rt_id is null or
118 p_object_version_number is null) Then
119 --
120 -- One of the primary key arguments is null therefore we must
121 -- set the returning function value to false
122 --
123 l_fct_ret := false;
124 Else
125 If (p_tbco_use_rt_id = g_old_rec.tbco_use_rt_id and
126 p_object_version_number = g_old_rec.object_version_number) Then
127 hr_utility.set_location(l_proc, 10);
128 --
129 -- The g_old_rec is current therefore we must
130 -- set the returning function to true
131 --
132 l_fct_ret := true;
133 Else
134 --
135 -- Select the current row
136 --
137 Open C_Sel1;
138 Fetch C_Sel1 Into g_old_rec;
139 If C_Sel1%notfound Then
140 Close C_Sel1;
141 --
142 -- The primary key is invalid therefore we must error
143 --
144 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
145 hr_utility.raise_error;
146 End If;
147 Close C_Sel1;
148 If (p_object_version_number <> g_old_rec.object_version_number) Then
149 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
153 l_fct_ret := true;
150 hr_utility.raise_error;
151 End If;
152 hr_utility.set_location(l_proc, 15);
154 End If;
155 End If;
156 hr_utility.set_location(' Leaving:'||l_proc, 20);
157 Return (l_fct_ret);
158 --
159 End api_updating;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |--------------------------< find_dt_del_modes >---------------------------|
163 -- ----------------------------------------------------------------------------
164 Procedure find_dt_del_modes
165 (p_effective_date in date,
166 p_base_key_value in number,
167 p_zap out nocopy boolean,
168 p_delete out nocopy boolean,
169 p_future_change out nocopy boolean,
170 p_delete_next_change out nocopy boolean) is
171 --
172 l_proc varchar2(72) := g_package||'find_dt_del_modes';
173 --
174 l_parent_key_value1 number;
175 --
176 Cursor C_Sel1 Is
177 select t.vrbl_rt_prfl_id
178 from ben_tbco_use_rt_f t
179 where t.tbco_use_rt_id = p_base_key_value
180 and p_effective_date
181 between t.effective_start_date and t.effective_end_date;
182 --
183 Begin
184 hr_utility.set_location('Entering:'||l_proc, 5);
185 --
186 Open C_Sel1;
187 Fetch C_Sel1 Into l_parent_key_value1;
188 If C_Sel1%notfound then
189 Close C_Sel1;
190 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
191 hr_utility.set_message_token('PROCEDURE', l_proc);
192 hr_utility.set_message_token('STEP','10');
193 hr_utility.raise_error;
194 End If;
195 Close C_Sel1;
196 --
197 -- Call the corresponding datetrack api
198 --
199 dt_api.find_dt_del_modes
200 (p_effective_date => p_effective_date,
201 p_base_table_name => 'ben_tbco_use_rt_f',
202 p_base_key_column => 'tbco_use_rt_id',
203 p_base_key_value => p_base_key_value,
204 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
205 p_parent_key_column1 => 'vrbl_rt_prfl_id',
206 p_parent_key_value1 => l_parent_key_value1,
207 p_zap => p_zap,
208 p_delete => p_delete,
209 p_future_change => p_future_change,
210 p_delete_next_change => p_delete_next_change);
211 --
212 hr_utility.set_location(' Leaving:'||l_proc, 10);
213 End find_dt_del_modes;
214 --
215 -- ----------------------------------------------------------------------------
216 -- |--------------------------< find_dt_upd_modes >---------------------------|
217 -- ----------------------------------------------------------------------------
218 Procedure find_dt_upd_modes
219 (p_effective_date in date,
220 p_base_key_value in number,
221 p_correction out nocopy boolean,
222 p_update out nocopy boolean,
223 p_update_override out nocopy boolean,
224 p_update_change_insert out nocopy boolean) is
225 --
226 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
227 --
228 Begin
229 hr_utility.set_location('Entering:'||l_proc, 5);
230 --
231 -- Call the corresponding datetrack api
232 --
233 dt_api.find_dt_upd_modes
234 (p_effective_date => p_effective_date,
235 p_base_table_name => 'ben_tbco_use_rt_f',
236 p_base_key_column => 'tbco_use_rt_id',
237 p_base_key_value => p_base_key_value,
238 p_correction => p_correction,
239 p_update => p_update,
240 p_update_override => p_update_override,
241 p_update_change_insert => p_update_change_insert);
242 --
243 hr_utility.set_location(' Leaving:'||l_proc, 10);
244 End find_dt_upd_modes;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |------------------------< upd_effective_end_date >------------------------|
248 -- ----------------------------------------------------------------------------
249 Procedure upd_effective_end_date
250 (p_effective_date in date,
251 p_base_key_value in number,
252 p_new_effective_end_date in date,
253 p_validation_start_date in date,
254 p_validation_end_date in date,
255 p_object_version_number out nocopy number) is
256 --
257 l_proc varchar2(72) := g_package||'upd_effective_end_date';
258 l_object_version_number number;
259 --
260 Begin
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 --
263 -- Because we are updating a row we must get the next object
264 -- version number.
265 --
266 l_object_version_number :=
267 dt_api.get_object_version_number
268 (p_base_table_name => 'ben_tbco_use_rt_f',
269 p_base_key_column => 'tbco_use_rt_id',
270 p_base_key_value => p_base_key_value);
271 --
272 hr_utility.set_location(l_proc, 10);
273 g_api_dml := true; -- Set the api dml status
274 --
275 -- Update the specified datetrack row setting the effective
276 -- end date to the specified new effective end date.
277 --
278 update ben_tbco_use_rt_f t
279 set t.effective_end_date = p_new_effective_end_date,
280 t.object_version_number = l_object_version_number
281 where t.tbco_use_rt_id = p_base_key_value
282 and p_effective_date
283 between t.effective_start_date and t.effective_end_date;
284 --
285 g_api_dml := false; -- Unset the api dml status
286 p_object_version_number := l_object_version_number;
287 hr_utility.set_location(' Leaving:'||l_proc, 15);
288 --
289 Exception
290 When Others Then
291 g_api_dml := false; -- Unset the api dml status
292 Raise;
293 End upd_effective_end_date;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |---------------------------------< lck >----------------------------------|
300 p_datetrack_mode in varchar2,
297 -- ----------------------------------------------------------------------------
298 Procedure lck
299 (p_effective_date in date,
301 p_tbco_use_rt_id in number,
302 p_object_version_number in number,
303 p_validation_start_date out nocopy date,
304 p_validation_end_date out nocopy date) is
305 --
306 l_proc varchar2(72) := g_package||'lck';
307 l_validation_start_date date;
308 l_validation_end_date date;
309 l_object_invalid exception;
310 l_argument varchar2(30);
311 --
312 -- Cursor C_Sel1 selects the current locked row as of session date
313 -- ensuring that the object version numbers match.
314 --
315 Cursor C_Sel1 is
316 select
317 tbco_use_rt_id,
318 effective_start_date,
319 effective_end_date,
320 business_group_id,
321 vrbl_rt_prfl_id,
322 excld_flag,
323 ordr_num,
324 uses_tbco_flag,
325 tur_attribute_category,
326 tur_attribute1,
327 tur_attribute2,
328 tur_attribute3,
329 tur_attribute4,
330 tur_attribute5,
331 tur_attribute6,
332 tur_attribute7,
333 tur_attribute8,
334 tur_attribute9,
335 tur_attribute10,
336 tur_attribute11,
337 tur_attribute12,
338 tur_attribute13,
339 tur_attribute14,
340 tur_attribute15,
341 tur_attribute16,
342 tur_attribute17,
343 tur_attribute18,
344 tur_attribute19,
345 tur_attribute20,
346 tur_attribute21,
347 tur_attribute22,
348 tur_attribute23,
349 tur_attribute24,
350 tur_attribute25,
351 tur_attribute26,
352 tur_attribute27,
353 tur_attribute28,
354 tur_attribute29,
355 tur_attribute30,
356 object_version_number
357 from ben_tbco_use_rt_f
358 where tbco_use_rt_id = p_tbco_use_rt_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 => 'tbco_use_rt_id',
380 p_argument_value => p_tbco_use_rt_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 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
400 hr_utility.raise_error;
401 End If;
402 Close C_Sel1;
403 If (p_object_version_number <> g_old_rec.object_version_number) Then
404 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
405 hr_utility.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_tbco_use_rt_f',
417 p_base_key_column => 'tbco_use_rt_id',
418 p_base_key_value => p_tbco_use_rt_id,
419 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
420 p_parent_key_column1 => 'vrbl_rt_prfl_id',
421 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
422 p_enforce_foreign_locking => false , --true,
423 p_validation_start_date => l_validation_start_date,
424 p_validation_end_date => l_validation_end_date);
425 Else
426 --
427 -- We are doing a datetrack 'INSERT' which is illegal within this
428 -- procedure therefore we must error (note: to lck on insert the
429 -- private procedure ins_lck should be called).
430 --
431 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
432 hr_utility.set_message_token('PROCEDURE', l_proc);
433 hr_utility.set_message_token('STEP','20');
434 hr_utility.raise_error;
435 End If;
436 --
437 -- Set the validation start and end date OUT arguments
438 --
439 p_validation_start_date := l_validation_start_date;
440 p_validation_end_date := l_validation_end_date;
441 --
442 hr_utility.set_location(' Leaving:'||l_proc, 30);
443 --
444 -- We need to trap the ORA LOCK exception
445 --
446 Exception
447 When HR_Api.Object_Locked then
448 --
449 -- The object is locked therefore we need to supply a meaningful
450 -- error message.
451 --
452 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
456 --
453 hr_utility.set_message_token('TABLE_NAME', 'ben_tbco_use_rt_f');
454 hr_utility.raise_error;
455 When l_object_invalid then
457 -- The object doesn't exist or is invalid
458 --
459 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
460 hr_utility.set_message_token('TABLE_NAME', 'ben_tbco_use_rt_f');
461 hr_utility.raise_error;
462 End lck;
463 --
464 -- ----------------------------------------------------------------------------
465 -- |-----------------------------< convert_args >-----------------------------|
466 -- ----------------------------------------------------------------------------
467 Function convert_args
468 (
469 p_tbco_use_rt_id in number,
470 p_effective_start_date in date,
471 p_effective_end_date in date,
472 p_business_group_id in number,
473 p_vrbl_rt_prfl_id in number,
474 p_excld_flag in varchar2,
475 p_ordr_num in number,
476 p_uses_tbco_flag in varchar2,
477 p_tur_attribute_category in varchar2,
478 p_tur_attribute1 in varchar2,
479 p_tur_attribute2 in varchar2,
480 p_tur_attribute3 in varchar2,
481 p_tur_attribute4 in varchar2,
482 p_tur_attribute5 in varchar2,
483 p_tur_attribute6 in varchar2,
484 p_tur_attribute7 in varchar2,
485 p_tur_attribute8 in varchar2,
486 p_tur_attribute9 in varchar2,
487 p_tur_attribute10 in varchar2,
488 p_tur_attribute11 in varchar2,
489 p_tur_attribute12 in varchar2,
490 p_tur_attribute13 in varchar2,
491 p_tur_attribute14 in varchar2,
492 p_tur_attribute15 in varchar2,
493 p_tur_attribute16 in varchar2,
494 p_tur_attribute17 in varchar2,
495 p_tur_attribute18 in varchar2,
496 p_tur_attribute19 in varchar2,
497 p_tur_attribute20 in varchar2,
498 p_tur_attribute21 in varchar2,
499 p_tur_attribute22 in varchar2,
500 p_tur_attribute23 in varchar2,
501 p_tur_attribute24 in varchar2,
502 p_tur_attribute25 in varchar2,
503 p_tur_attribute26 in varchar2,
504 p_tur_attribute27 in varchar2,
505 p_tur_attribute28 in varchar2,
506 p_tur_attribute29 in varchar2,
507 p_tur_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.tbco_use_rt_id := p_tbco_use_rt_id;
522 l_rec.effective_start_date := p_effective_start_date;
523 l_rec.effective_end_date := p_effective_end_date;
524 l_rec.business_group_id := p_business_group_id;
525 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
526 l_rec.excld_flag := p_excld_flag;
527 l_rec.ordr_num := p_ordr_num;
528 l_rec.uses_tbco_flag := p_uses_tbco_flag;
529 l_rec.tur_attribute_category := p_tur_attribute_category;
530 l_rec.tur_attribute1 := p_tur_attribute1;
531 l_rec.tur_attribute2 := p_tur_attribute2;
532 l_rec.tur_attribute3 := p_tur_attribute3;
533 l_rec.tur_attribute4 := p_tur_attribute4;
534 l_rec.tur_attribute5 := p_tur_attribute5;
535 l_rec.tur_attribute6 := p_tur_attribute6;
536 l_rec.tur_attribute7 := p_tur_attribute7;
537 l_rec.tur_attribute8 := p_tur_attribute8;
538 l_rec.tur_attribute9 := p_tur_attribute9;
539 l_rec.tur_attribute10 := p_tur_attribute10;
540 l_rec.tur_attribute11 := p_tur_attribute11;
541 l_rec.tur_attribute12 := p_tur_attribute12;
542 l_rec.tur_attribute13 := p_tur_attribute13;
543 l_rec.tur_attribute14 := p_tur_attribute14;
544 l_rec.tur_attribute15 := p_tur_attribute15;
545 l_rec.tur_attribute16 := p_tur_attribute16;
546 l_rec.tur_attribute17 := p_tur_attribute17;
547 l_rec.tur_attribute18 := p_tur_attribute18;
548 l_rec.tur_attribute19 := p_tur_attribute19;
549 l_rec.tur_attribute20 := p_tur_attribute20;
550 l_rec.tur_attribute21 := p_tur_attribute21;
551 l_rec.tur_attribute22 := p_tur_attribute22;
552 l_rec.tur_attribute23 := p_tur_attribute23;
553 l_rec.tur_attribute24 := p_tur_attribute24;
554 l_rec.tur_attribute25 := p_tur_attribute25;
555 l_rec.tur_attribute26 := p_tur_attribute26;
556 l_rec.tur_attribute27 := p_tur_attribute27;
557 l_rec.tur_attribute28 := p_tur_attribute28;
558 l_rec.tur_attribute29 := p_tur_attribute29;
559 l_rec.tur_attribute30 := p_tur_attribute30;
560 l_rec.object_version_number := p_object_version_number;
561 --
562 -- Return the plsql record structure.
563 --
564 hr_utility.set_location(' Leaving:'||l_proc, 10);
565 Return(l_rec);
566 --
567 End convert_args;
568 --
569 end ben_tur_shd;