[Home] [Help]
PACKAGE BODY: APPS.BEN_SHR_SHD
Source
1 Package Body ben_shr_shd as
2 /* $Header: beshrrhi.pkb 120.0.12010000.2 2008/08/05 15:27:41 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_shr_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_SCHEDD_HRS_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_schedd_hrs_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 schedd_hrs_rt_id,
66 effective_start_date,
67 effective_end_date,
68 vrbl_rt_prfl_id,
69 excld_flag,
70 ordr_num,
71 freq_cd,
72 hrs_num,
73 max_hrs_num,
74 schedd_hrs_rl,
75 determination_cd,
76 determination_rl,
77 rounding_cd,
78 rounding_rl,
79 business_group_id,
80 shr_attribute_category,
81 shr_attribute1,
82 shr_attribute2,
83 shr_attribute3,
84 shr_attribute4,
85 shr_attribute5,
86 shr_attribute6,
87 shr_attribute7,
88 shr_attribute8,
89 shr_attribute9,
90 shr_attribute10,
91 shr_attribute11,
92 shr_attribute12,
93 shr_attribute13,
94 shr_attribute14,
95 shr_attribute15,
96 shr_attribute16,
97 shr_attribute17,
98 shr_attribute18,
99 shr_attribute19,
100 shr_attribute20,
101 shr_attribute21,
102 shr_attribute22,
103 shr_attribute23,
104 shr_attribute24,
105 shr_attribute25,
106 shr_attribute26,
107 shr_attribute27,
108 shr_attribute28,
109 shr_attribute29,
110 shr_attribute30,
111 object_version_number
112 from ben_schedd_hrs_rt_f
113 where schedd_hrs_rt_id = p_schedd_hrs_rt_id
114 and p_effective_date
115 between effective_start_date and effective_end_date;
116 --
117 l_proc varchar2(72) := g_package||'api_updating';
118 l_fct_ret boolean;
119 --
120 Begin
121 hr_utility.set_location('Entering:'||l_proc, 5);
122 --
123 If (p_effective_date is null or
124 p_schedd_hrs_rt_id is null or
125 p_object_version_number is null) Then
126 --
127 -- One of the primary key arguments is null therefore we must
128 -- set the returning function value to false
129 --
130 l_fct_ret := false;
131 Else
132 If (p_schedd_hrs_rt_id = g_old_rec.schedd_hrs_rt_id and
133 p_object_version_number = g_old_rec.object_version_number) Then
134 hr_utility.set_location(l_proc, 10);
135 --
136 -- The g_old_rec is current therefore we must
137 -- set the returning function to true
138 --
139 l_fct_ret := true;
140 Else
141 --
142 -- Select the current row
143 --
144 Open C_Sel1;
145 Fetch C_Sel1 Into g_old_rec;
146 If C_Sel1%notfound Then
147 Close C_Sel1;
148 --
149 -- The primary key is invalid therefore we must error
150 --
151 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
152 hr_utility.raise_error;
153 End If;
154 Close C_Sel1;
155 If (p_object_version_number <> g_old_rec.object_version_number) Then
156 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
157 hr_utility.raise_error;
158 End If;
159 hr_utility.set_location(l_proc, 15);
160 l_fct_ret := true;
161 End If;
162 End If;
163 hr_utility.set_location(' Leaving:'||l_proc, 20);
164 Return (l_fct_ret);
165 --
166 End api_updating;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |--------------------------< find_dt_del_modes >---------------------------|
170 -- ----------------------------------------------------------------------------
171 Procedure find_dt_del_modes
172 (p_effective_date in date,
173 p_base_key_value in number,
174 p_zap out nocopy boolean,
175 p_delete out nocopy boolean,
176 p_future_change out nocopy boolean,
177 p_delete_next_change out nocopy boolean) is
178 --
179 l_proc varchar2(72) := g_package||'find_dt_del_modes';
180 --
181 l_parent_key_value1 number;
182 --
183 Cursor C_Sel1 Is
184 select t.vrbl_rt_prfl_id
185 from ben_schedd_hrs_rt_f t
186 where t.schedd_hrs_rt_id = p_base_key_value
187 and p_effective_date
188 between t.effective_start_date and t.effective_end_date;
189 --
190 Begin
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 Open C_Sel1;
193 Fetch C_Sel1 Into l_parent_key_value1;
194 If C_Sel1%notfound then
195 Close C_Sel1;
196 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
197 hr_utility.set_message_token('PROCEDURE', l_proc);
198 hr_utility.set_message_token('STEP','10');
199 hr_utility.raise_error;
200 End If;
201 Close C_Sel1;
202 --
203 -- Call the corresponding datetrack api
204 --
205 dt_api.find_dt_del_modes
206 (p_effective_date => p_effective_date,
207 p_base_table_name => 'ben_schedd_hrs_rt_f',
208 p_base_key_column => 'schedd_hrs_rt_id',
209 p_base_key_value => p_base_key_value,
210 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
211 p_parent_key_column1 => 'vrbl_rt_prfl_id',
212 p_parent_key_value1 => l_parent_key_value1,
213 p_zap => p_zap,
214 p_delete => p_delete,
215 p_future_change => p_future_change,
216 p_delete_next_change => p_delete_next_change);
217 --
218 hr_utility.set_location(' Leaving:'||l_proc, 10);
219 End find_dt_del_modes;
220 --
221 -- ----------------------------------------------------------------------------
222 -- |--------------------------< find_dt_upd_modes >---------------------------|
223 -- ----------------------------------------------------------------------------
224 Procedure find_dt_upd_modes
225 (p_effective_date in date,
226 p_base_key_value in number,
227 p_correction out nocopy boolean,
228 p_update out nocopy boolean,
229 p_update_override out nocopy boolean,
230 p_update_change_insert out nocopy boolean) is
231 --
232 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
233 --
234 Begin
235 hr_utility.set_location('Entering:'||l_proc, 5);
236 --
237 -- Call the corresponding datetrack api
238 --
239 dt_api.find_dt_upd_modes
240 (p_effective_date => p_effective_date,
241 p_base_table_name => 'ben_schedd_hrs_rt_f',
242 p_base_key_column => 'schedd_hrs_rt_id',
243 p_base_key_value => p_base_key_value,
244 p_correction => p_correction,
245 p_update => p_update,
246 p_update_override => p_update_override,
247 p_update_change_insert => p_update_change_insert);
248 --
249 hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End find_dt_upd_modes;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |------------------------< upd_effective_end_date >------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure upd_effective_end_date
256 (p_effective_date in date,
257 p_base_key_value in number,
258 p_new_effective_end_date in date,
259 p_validation_start_date in date,
260 p_validation_end_date in date,
261 p_object_version_number out nocopy number) is
262 --
263 l_proc varchar2(72) := g_package||'upd_effective_end_date';
264 l_object_version_number number;
265 --
266 Begin
267 hr_utility.set_location('Entering:'||l_proc, 5);
268 --
269 -- Because we are updating a row we must get the next object
270 -- version number.
271 --
272 l_object_version_number :=
273 dt_api.get_object_version_number
274 (p_base_table_name => 'ben_schedd_hrs_rt_f',
275 p_base_key_column => 'schedd_hrs_rt_id',
276 p_base_key_value => p_base_key_value);
277 --
278 hr_utility.set_location(l_proc, 10);
279 g_api_dml := true; -- Set the api dml status
280 --
281 -- Update the specified datetrack row setting the effective
282 -- end date to the specified new effective end date.
283 --
284 update ben_schedd_hrs_rt_f t
285 set t.effective_end_date = p_new_effective_end_date,
286 t.object_version_number = l_object_version_number
287 where t.schedd_hrs_rt_id = p_base_key_value
288 and p_effective_date
289 between t.effective_start_date and t.effective_end_date;
290 --
291 g_api_dml := false; -- Unset the api dml status
292 p_object_version_number := l_object_version_number;
293 hr_utility.set_location(' Leaving:'||l_proc, 15);
294 --
295 Exception
296 When Others Then
297 g_api_dml := false; -- Unset the api dml status
298 Raise;
299 End upd_effective_end_date;
300 --
301 -- ----------------------------------------------------------------------------
302 -- |---------------------------------< lck >----------------------------------|
303 -- ----------------------------------------------------------------------------
304 Procedure lck
305 (p_effective_date in date,
306 p_datetrack_mode in varchar2,
307 p_schedd_hrs_rt_id in number,
308 p_object_version_number in number,
309 p_validation_start_date out nocopy date,
310 p_validation_end_date out nocopy date) is
311 --
312 l_proc varchar2(72) := g_package||'lck';
313 l_validation_start_date date;
314 l_validation_end_date date;
315 l_object_invalid exception;
316 l_argument varchar2(30);
317 --
318 -- Cursor C_Sel1 selects the current locked row as of session date
319 -- ensuring that the object version numbers match.
320 --
321 Cursor C_Sel1 is
322 select
323 schedd_hrs_rt_id,
324 effective_start_date,
325 effective_end_date,
326 vrbl_rt_prfl_id,
327 excld_flag,
328 ordr_num,
329 freq_cd,
330 hrs_num,
331 max_hrs_num,
332 schedd_hrs_rl,
333 determination_cd,
334 determination_rl,
335 rounding_cd,
336 rounding_rl,
337 business_group_id,
338 shr_attribute_category,
339 shr_attribute1,
340 shr_attribute2,
341 shr_attribute3,
342 shr_attribute4,
343 shr_attribute5,
344 shr_attribute6,
345 shr_attribute7,
346 shr_attribute8,
347 shr_attribute9,
348 shr_attribute10,
349 shr_attribute11,
350 shr_attribute12,
351 shr_attribute13,
352 shr_attribute14,
353 shr_attribute15,
354 shr_attribute16,
355 shr_attribute17,
356 shr_attribute18,
357 shr_attribute19,
358 shr_attribute20,
359 shr_attribute21,
360 shr_attribute22,
361 shr_attribute23,
362 shr_attribute24,
363 shr_attribute25,
364 shr_attribute26,
365 shr_attribute27,
366 shr_attribute28,
367 shr_attribute29,
368 shr_attribute30,
369 object_version_number
370 from ben_schedd_hrs_rt_f
371 where schedd_hrs_rt_id = p_schedd_hrs_rt_id
372 and p_effective_date
373 between effective_start_date and effective_end_date
374 for update nowait;
375 --
376 --
377 --
378 Begin
379 hr_utility.set_location('Entering:'||l_proc, 5);
380 --
381 -- Ensure that all the mandatory arguments are not null
382 --
383 hr_api.mandatory_arg_error(p_api_name => l_proc,
384 p_argument => 'effective_date',
385 p_argument_value => p_effective_date);
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'datetrack_mode',
389 p_argument_value => p_datetrack_mode);
390 --
391 hr_api.mandatory_arg_error(p_api_name => l_proc,
392 p_argument => 'schedd_hrs_rt_id',
393 p_argument_value => p_schedd_hrs_rt_id);
394 --
395 hr_api.mandatory_arg_error(p_api_name => l_proc,
396 p_argument => 'object_version_number',
397 p_argument_value => p_object_version_number);
398 --
399 -- Check to ensure the datetrack mode is not INSERT.
400 --
401 If (p_datetrack_mode <> 'INSERT') then
402 --
403 -- We must select and lock the current row.
404 --
405 Open C_Sel1;
406 Fetch C_Sel1 Into g_old_rec;
407 If C_Sel1%notfound then
408 Close C_Sel1;
409 --
410 -- The primary key is invalid therefore we must error
411 --
412 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
413 hr_utility.raise_error;
414 End If;
415 Close C_Sel1;
416 If (p_object_version_number <> g_old_rec.object_version_number) Then
417 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
418 hr_utility.raise_error;
419 End If;
420 hr_utility.set_location(l_proc, 15);
421 --
422 --
423 -- Validate the datetrack mode mode getting the validation start
424 -- and end dates for the specified datetrack operation.
425 --
426 dt_api.validate_dt_mode
427 (p_effective_date => p_effective_date,
428 p_datetrack_mode => p_datetrack_mode,
429 p_base_table_name => 'ben_schedd_hrs_rt_f',
430 p_base_key_column => 'schedd_hrs_rt_id',
434 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
431 p_base_key_value => p_schedd_hrs_rt_id,
432 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
433 p_parent_key_column1 => 'vrbl_rt_prfl_id',
435 p_enforce_foreign_locking => false , --true,
436 p_validation_start_date => l_validation_start_date,
437 p_validation_end_date => l_validation_end_date);
438 Else
439 --
440 -- We are doing a datetrack 'INSERT' which is illegal within this
441 -- procedure therefore we must error (note: to lck on insert the
442 -- private procedure ins_lck should be called).
443 --
444 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
445 hr_utility.set_message_token('PROCEDURE', l_proc);
446 hr_utility.set_message_token('STEP','20');
447 hr_utility.raise_error;
448 End If;
449 --
450 -- Set the validation start and end date OUT arguments
451 --
452 p_validation_start_date := l_validation_start_date;
453 p_validation_end_date := l_validation_end_date;
454 --
455 hr_utility.set_location(' Leaving:'||l_proc, 30);
456 --
457 -- We need to trap the ORA LOCK exception
458 --
459 Exception
460 When HR_Api.Object_Locked then
461 --
462 -- The object is locked therefore we need to supply a meaningful
463 -- error message.
464 --
465 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
466 hr_utility.set_message_token('TABLE_NAME', 'ben_schedd_hrs_rt_f');
467 hr_utility.raise_error;
468 When l_object_invalid then
469 --
470 -- The object doesn't exist or is invalid
471 --
472 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
473 hr_utility.set_message_token('TABLE_NAME', 'ben_schedd_hrs_rt_f');
474 hr_utility.raise_error;
475 End lck;
476 --
477 -- ----------------------------------------------------------------------------
478 -- |-----------------------------< convert_args >-----------------------------|
479 -- ----------------------------------------------------------------------------
480 Function convert_args
481 (
482 p_schedd_hrs_rt_id in number,
483 p_effective_start_date in date,
484 p_effective_end_date in date,
485 p_vrbl_rt_prfl_id in number,
486 p_excld_flag in varchar2,
487 p_ordr_num in number,
488 p_freq_cd in varchar2,
489 p_hrs_num in number,
490 p_max_hrs_num in number,
491 p_schedd_hrs_rl in number,
492 p_determination_cd in varchar2,
493 p_determination_rl in number,
494 p_rounding_cd in varchar2,
495 p_rounding_rl in number,
496 p_business_group_id in number,
497 p_shr_attribute_category in varchar2,
498 p_shr_attribute1 in varchar2,
499 p_shr_attribute2 in varchar2,
500 p_shr_attribute3 in varchar2,
501 p_shr_attribute4 in varchar2,
502 p_shr_attribute5 in varchar2,
503 p_shr_attribute6 in varchar2,
504 p_shr_attribute7 in varchar2,
505 p_shr_attribute8 in varchar2,
506 p_shr_attribute9 in varchar2,
507 p_shr_attribute10 in varchar2,
508 p_shr_attribute11 in varchar2,
509 p_shr_attribute12 in varchar2,
510 p_shr_attribute13 in varchar2,
511 p_shr_attribute14 in varchar2,
512 p_shr_attribute15 in varchar2,
513 p_shr_attribute16 in varchar2,
514 p_shr_attribute17 in varchar2,
515 p_shr_attribute18 in varchar2,
516 p_shr_attribute19 in varchar2,
517 p_shr_attribute20 in varchar2,
518 p_shr_attribute21 in varchar2,
519 p_shr_attribute22 in varchar2,
520 p_shr_attribute23 in varchar2,
521 p_shr_attribute24 in varchar2,
522 p_shr_attribute25 in varchar2,
523 p_shr_attribute26 in varchar2,
524 p_shr_attribute27 in varchar2,
525 p_shr_attribute28 in varchar2,
526 p_shr_attribute29 in varchar2,
527 p_shr_attribute30 in varchar2,
528 p_object_version_number in number
529 )
530 Return g_rec_type is
531 --
532 l_rec g_rec_type;
533 l_proc varchar2(72) := g_package||'convert_args';
534 --
535 Begin
536 --
537 hr_utility.set_location('Entering:'||l_proc, 5);
538 --
539 -- Convert arguments into local l_rec structure.
540 --
541 l_rec.schedd_hrs_rt_id := p_schedd_hrs_rt_id;
542 l_rec.effective_start_date := p_effective_start_date;
543 l_rec.effective_end_date := p_effective_end_date;
544 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
545 l_rec.excld_flag := p_excld_flag;
546 l_rec.ordr_num := p_ordr_num;
547 l_rec.freq_cd := p_freq_cd;
548 l_rec.hrs_num := p_hrs_num;
549 l_rec.max_hrs_num := p_max_hrs_num;
550 l_rec.schedd_hrs_rl := p_schedd_hrs_rl;
551 l_rec.determination_cd := p_determination_cd;
555 l_rec.business_group_id := p_business_group_id;
552 l_rec.determination_rl := p_determination_rl;
553 l_rec.rounding_cd := p_rounding_cd;
554 l_rec.rounding_rl := p_rounding_rl;
556 l_rec.shr_attribute_category := p_shr_attribute_category;
557 l_rec.shr_attribute1 := p_shr_attribute1;
558 l_rec.shr_attribute2 := p_shr_attribute2;
559 l_rec.shr_attribute3 := p_shr_attribute3;
560 l_rec.shr_attribute4 := p_shr_attribute4;
561 l_rec.shr_attribute5 := p_shr_attribute5;
562 l_rec.shr_attribute6 := p_shr_attribute6;
563 l_rec.shr_attribute7 := p_shr_attribute7;
564 l_rec.shr_attribute8 := p_shr_attribute8;
565 l_rec.shr_attribute9 := p_shr_attribute9;
566 l_rec.shr_attribute10 := p_shr_attribute10;
567 l_rec.shr_attribute11 := p_shr_attribute11;
568 l_rec.shr_attribute12 := p_shr_attribute12;
569 l_rec.shr_attribute13 := p_shr_attribute13;
570 l_rec.shr_attribute14 := p_shr_attribute14;
571 l_rec.shr_attribute15 := p_shr_attribute15;
572 l_rec.shr_attribute16 := p_shr_attribute16;
573 l_rec.shr_attribute17 := p_shr_attribute17;
574 l_rec.shr_attribute18 := p_shr_attribute18;
575 l_rec.shr_attribute19 := p_shr_attribute19;
576 l_rec.shr_attribute20 := p_shr_attribute20;
577 l_rec.shr_attribute21 := p_shr_attribute21;
578 l_rec.shr_attribute22 := p_shr_attribute22;
579 l_rec.shr_attribute23 := p_shr_attribute23;
580 l_rec.shr_attribute24 := p_shr_attribute24;
581 l_rec.shr_attribute25 := p_shr_attribute25;
582 l_rec.shr_attribute26 := p_shr_attribute26;
583 l_rec.shr_attribute27 := p_shr_attribute27;
584 l_rec.shr_attribute28 := p_shr_attribute28;
585 l_rec.shr_attribute29 := p_shr_attribute29;
586 l_rec.shr_attribute30 := p_shr_attribute30;
587 l_rec.object_version_number := p_object_version_number;
588 --
589 -- Return the plsql record structure.
590 --
591 hr_utility.set_location(' Leaving:'||l_proc, 10);
592 Return(l_rec);
593 --
594 End convert_args;
595 --
596 end ben_shr_shd;