[Home] [Help]
PACKAGE BODY: APPS.BEN_ESR_SHD
Source
1 Package Body ben_esr_shd as
2 /* $Header: beesrrhi.pkb 120.0 2005/05/28 02:58:22 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_esr_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_EE_STAT_RTS_F') 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_ee_stat_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 ee_stat_rt_id,
66 effective_start_date,
67 effective_end_date,
68 vrbl_rt_prfl_id,
69 assignment_status_type_id,
70 excld_flag,
71 ordr_num,
72 business_group_id,
73 esr_attribute_category,
74 esr_attribute1,
75 esr_attribute2,
76 esr_attribute3,
77 esr_attribute4,
78 esr_attribute5,
79 esr_attribute6,
80 esr_attribute7,
81 esr_attribute8,
82 esr_attribute9,
83 esr_attribute10,
84 esr_attribute11,
85 esr_attribute12,
86 esr_attribute13,
87 esr_attribute14,
88 esr_attribute15,
89 esr_attribute16,
90 esr_attribute17,
91 esr_attribute18,
92 esr_attribute19,
93 esr_attribute20,
94 esr_attribute21,
95 esr_attribute22,
96 esr_attribute23,
97 esr_attribute24,
98 esr_attribute25,
99 esr_attribute26,
100 esr_attribute27,
101 esr_attribute28,
102 esr_attribute29,
103 esr_attribute30,
104 object_version_number
105 from ben_ee_stat_rt_f
106 where ee_stat_rt_id = p_ee_stat_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_ee_stat_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_ee_stat_rt_id = g_old_rec.ee_stat_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');
150 hr_utility.raise_error;
151 End If;
152 hr_utility.set_location(l_proc, 15);
153 l_fct_ret := true;
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 l_parent_key_value2 number;
176 --
177 Cursor C_Sel1 Is
178 select t.vrbl_rt_prfl_id
179 -- ,t.assignment_status_type_id
180 from ben_ee_stat_rt_f t
181 where t.ee_stat_rt_id = p_base_key_value
182 and p_effective_date
183 between t.effective_start_date and t.effective_end_date;
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 Open C_Sel1;
188 Fetch C_Sel1 Into l_parent_key_value1;
189 -- l_parent_key_value2;
190 If C_Sel1%notfound then
191 Close C_Sel1;
192 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
193 hr_utility.set_message_token('PROCEDURE', l_proc);
194 hr_utility.set_message_token('STEP','10');
195 hr_utility.raise_error;
196 End If;
197 Close C_Sel1;
198 --
199 -- Call the corresponding datetrack api
200 --
201 dt_api.find_dt_del_modes
202 (p_effective_date => p_effective_date,
203 p_base_table_name => 'ben_ee_stat_rt_f',
204 p_base_key_column => 'ee_stat_rt_id',
205 p_base_key_value => p_base_key_value,
206 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
207 p_parent_key_column1 => 'vrbl_rt_prfl_id',
208 p_parent_key_value1 => l_parent_key_value1,
209 --p_parent_table_name2 => 'per_assignment_status_types',
210 --p_parent_key_column2 => 'assignment_status_type_id',
211 --p_parent_key_value2 => l_parent_key_value2,
212 p_zap => p_zap,
213 p_delete => p_delete,
214 p_future_change => p_future_change,
215 p_delete_next_change => p_delete_next_change);
216 --
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End find_dt_del_modes;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |--------------------------< find_dt_upd_modes >---------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure find_dt_upd_modes
224 (p_effective_date in date,
225 p_base_key_value in number,
226 p_correction out nocopy boolean,
227 p_update out nocopy boolean,
228 p_update_override out nocopy boolean,
229 p_update_change_insert out nocopy boolean) is
230 --
231 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
232 --
233 Begin
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 --
236 -- Call the corresponding datetrack api
237 --
238 dt_api.find_dt_upd_modes
239 (p_effective_date => p_effective_date,
240 p_base_table_name => 'ben_ee_stat_rt_f',
241 p_base_key_column => 'ee_stat_rt_id',
242 p_base_key_value => p_base_key_value,
243 p_correction => p_correction,
244 p_update => p_update,
245 p_update_override => p_update_override,
246 p_update_change_insert => p_update_change_insert);
247 --
248 hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End find_dt_upd_modes;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |------------------------< upd_effective_end_date >------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure upd_effective_end_date
255 (p_effective_date in date,
256 p_base_key_value in number,
257 p_new_effective_end_date in date,
258 p_validation_start_date in date,
259 p_validation_end_date in date,
260 p_object_version_number out nocopy number) is
261 --
262 l_proc varchar2(72) := g_package||'upd_effective_end_date';
263 l_object_version_number number;
264 --
265 Begin
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 -- Because we are updating a row we must get the next object
269 -- version number.
270 --
271 l_object_version_number :=
272 dt_api.get_object_version_number
273 (p_base_table_name => 'ben_ee_stat_rt_f',
274 p_base_key_column => 'ee_stat_rt_id',
275 p_base_key_value => p_base_key_value);
276 --
277 hr_utility.set_location(l_proc, 10);
278 g_api_dml := true; -- Set the api dml status
279 --
280 -- Update the specified datetrack row setting the effective
281 -- end date to the specified new effective end date.
282 --
283 update ben_ee_stat_rt_f t
284 set t.effective_end_date = p_new_effective_end_date,
285 t.object_version_number = l_object_version_number
286 where t.ee_stat_rt_id = p_base_key_value
287 and p_effective_date
288 between t.effective_start_date and t.effective_end_date;
289 --
290 g_api_dml := false; -- Unset the api dml status
291 p_object_version_number := l_object_version_number;
292 hr_utility.set_location(' Leaving:'||l_proc, 15);
293 --
294 Exception
295 When Others Then
296 g_api_dml := false; -- Unset the api dml status
297 Raise;
298 End upd_effective_end_date;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< lck >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure lck
304 (p_effective_date in date,
305 p_datetrack_mode in varchar2,
306 p_ee_stat_rt_id in number,
307 p_object_version_number in number,
308 p_validation_start_date out nocopy date,
309 p_validation_end_date out nocopy date) is
310 --
311 l_proc varchar2(72) := g_package||'lck';
312 l_validation_start_date date;
313 l_validation_end_date date;
314 l_object_invalid exception;
315 l_argument varchar2(30);
316 --
317 -- Cursor C_Sel1 selects the current locked row as of session date
318 -- ensuring that the object version numbers match.
319 --
320 Cursor C_Sel1 is
321 select
322 ee_stat_rt_id,
323 effective_start_date,
324 effective_end_date,
325 vrbl_rt_prfl_id,
326 assignment_status_type_id,
327 excld_flag,
328 ordr_num,
329 business_group_id,
330 esr_attribute_category,
331 esr_attribute1,
332 esr_attribute2,
333 esr_attribute3,
334 esr_attribute4,
335 esr_attribute5,
336 esr_attribute6,
337 esr_attribute7,
338 esr_attribute8,
339 esr_attribute9,
340 esr_attribute10,
341 esr_attribute11,
342 esr_attribute12,
343 esr_attribute13,
344 esr_attribute14,
345 esr_attribute15,
346 esr_attribute16,
347 esr_attribute17,
348 esr_attribute18,
349 esr_attribute19,
350 esr_attribute20,
351 esr_attribute21,
352 esr_attribute22,
353 esr_attribute23,
354 esr_attribute24,
355 esr_attribute25,
356 esr_attribute26,
357 esr_attribute27,
358 esr_attribute28,
359 esr_attribute29,
360 esr_attribute30,
361 object_version_number
362 from ben_ee_stat_rt_f
363 where ee_stat_rt_id = p_ee_stat_rt_id
364 and p_effective_date
365 between effective_start_date and effective_end_date
366 for update nowait;
367 --
368 --
369 --
370 Begin
371 hr_utility.set_location('Entering:'||l_proc, 5);
372 --
373 -- Ensure that all the mandatory arguments are not null
374 --
375 hr_api.mandatory_arg_error(p_api_name => l_proc,
376 p_argument => 'effective_date',
377 p_argument_value => p_effective_date);
378 --
379 hr_api.mandatory_arg_error(p_api_name => l_proc,
380 p_argument => 'datetrack_mode',
381 p_argument_value => p_datetrack_mode);
382 --
383 hr_api.mandatory_arg_error(p_api_name => l_proc,
384 p_argument => 'ee_stat_rt_id',
385 p_argument_value => p_ee_stat_rt_id);
386 --
387 hr_api.mandatory_arg_error(p_api_name => l_proc,
388 p_argument => 'object_version_number',
389 p_argument_value => p_object_version_number);
390 --
391 -- Check to ensure the datetrack mode is not INSERT.
392 --
393 If (p_datetrack_mode <> 'INSERT') then
394 --
395 -- We must select and lock the current row.
396 --
397 Open C_Sel1;
398 Fetch C_Sel1 Into g_old_rec;
399 If C_Sel1%notfound then
400 Close C_Sel1;
401 --
402 -- The primary key is invalid therefore we must error
403 --
404 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
405 hr_utility.raise_error;
406 End If;
407 Close C_Sel1;
408 If (p_object_version_number <> g_old_rec.object_version_number) Then
409 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
410 hr_utility.raise_error;
411 End If;
412 hr_utility.set_location(l_proc, 15);
413 --
414 --
415 -- Validate the datetrack mode mode getting the validation start
416 -- and end dates for the specified datetrack operation.
417 --
418 dt_api.validate_dt_mode
419 (p_effective_date => p_effective_date,
420 p_datetrack_mode => p_datetrack_mode,
421 p_base_table_name => 'ben_ee_stat_rt_f',
422 p_base_key_column => 'ee_stat_rt_id',
423 p_base_key_value => p_ee_stat_rt_id,
424 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
425 p_parent_key_column1 => 'vrbl_rt_prfl_id',
426 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
427 --p_parent_table_name2 => 'per_assignment_status_types',
428 --p_parent_key_column2 => 'assignment_status_type_id',
429 --p_parent_key_value2 => g_old_rec.assignment_status_type_id,
430 p_enforce_foreign_locking => true,
431 p_validation_start_date => l_validation_start_date,
432 p_validation_end_date => l_validation_end_date);
433 Else
434 --
438 --
435 -- We are doing a datetrack 'INSERT' which is illegal within this
436 -- procedure therefore we must error (note: to lck on insert the
437 -- private procedure ins_lck should be called).
439 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
440 hr_utility.set_message_token('PROCEDURE', l_proc);
441 hr_utility.set_message_token('STEP','20');
442 hr_utility.raise_error;
443 End If;
444 --
445 -- Set the validation start and end date OUT arguments
446 --
447 p_validation_start_date := l_validation_start_date;
448 p_validation_end_date := l_validation_end_date;
449 --
450 hr_utility.set_location(' Leaving:'||l_proc, 30);
451 --
452 -- We need to trap the ORA LOCK exception
453 --
454 Exception
455 When HR_Api.Object_Locked then
456 --
457 -- The object is locked therefore we need to supply a meaningful
458 -- error message.
459 --
460 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
461 hr_utility.set_message_token('TABLE_NAME', 'ben_ee_stat_rt_f');
462 hr_utility.raise_error;
463 When l_object_invalid then
464 --
465 -- The object doesn't exist or is invalid
466 --
467 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
468 hr_utility.set_message_token('TABLE_NAME', 'ben_ee_stat_rt_f');
469 hr_utility.raise_error;
470 End lck;
471 --
472 -- ----------------------------------------------------------------------------
473 -- |-----------------------------< convert_args >-----------------------------|
474 -- ----------------------------------------------------------------------------
475 Function convert_args
476 (
477 p_ee_stat_rt_id in number,
478 p_effective_start_date in date,
479 p_effective_end_date in date,
480 p_vrbl_rt_prfl_id in number,
481 p_assignment_status_type_id in number,
482 p_excld_flag in varchar2,
483 p_ordr_num in number,
484 p_business_group_id in number,
485 p_esr_attribute_category in varchar2,
486 p_esr_attribute1 in varchar2,
487 p_esr_attribute2 in varchar2,
488 p_esr_attribute3 in varchar2,
489 p_esr_attribute4 in varchar2,
490 p_esr_attribute5 in varchar2,
491 p_esr_attribute6 in varchar2,
492 p_esr_attribute7 in varchar2,
493 p_esr_attribute8 in varchar2,
494 p_esr_attribute9 in varchar2,
495 p_esr_attribute10 in varchar2,
496 p_esr_attribute11 in varchar2,
497 p_esr_attribute12 in varchar2,
498 p_esr_attribute13 in varchar2,
499 p_esr_attribute14 in varchar2,
500 p_esr_attribute15 in varchar2,
501 p_esr_attribute16 in varchar2,
502 p_esr_attribute17 in varchar2,
503 p_esr_attribute18 in varchar2,
504 p_esr_attribute19 in varchar2,
505 p_esr_attribute20 in varchar2,
506 p_esr_attribute21 in varchar2,
507 p_esr_attribute22 in varchar2,
508 p_esr_attribute23 in varchar2,
509 p_esr_attribute24 in varchar2,
510 p_esr_attribute25 in varchar2,
511 p_esr_attribute26 in varchar2,
512 p_esr_attribute27 in varchar2,
513 p_esr_attribute28 in varchar2,
514 p_esr_attribute29 in varchar2,
515 p_esr_attribute30 in varchar2,
516 p_object_version_number in number
517 )
518 Return g_rec_type is
519 --
520 l_rec g_rec_type;
521 l_proc varchar2(72) := g_package||'convert_args';
522 --
523 Begin
524 --
525 hr_utility.set_location('Entering:'||l_proc, 5);
526 --
527 -- Convert arguments into local l_rec structure.
528 --
529 l_rec.ee_stat_rt_id := p_ee_stat_rt_id;
530 l_rec.effective_start_date := p_effective_start_date;
531 l_rec.effective_end_date := p_effective_end_date;
532 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
533 l_rec.assignment_status_type_id := p_assignment_status_type_id;
534 l_rec.excld_flag := p_excld_flag;
535 l_rec.ordr_num := p_ordr_num;
536 l_rec.business_group_id := p_business_group_id;
537 l_rec.esr_attribute_category := p_esr_attribute_category;
538 l_rec.esr_attribute1 := p_esr_attribute1;
539 l_rec.esr_attribute2 := p_esr_attribute2;
540 l_rec.esr_attribute3 := p_esr_attribute3;
541 l_rec.esr_attribute4 := p_esr_attribute4;
542 l_rec.esr_attribute5 := p_esr_attribute5;
543 l_rec.esr_attribute6 := p_esr_attribute6;
544 l_rec.esr_attribute7 := p_esr_attribute7;
545 l_rec.esr_attribute8 := p_esr_attribute8;
546 l_rec.esr_attribute9 := p_esr_attribute9;
547 l_rec.esr_attribute10 := p_esr_attribute10;
548 l_rec.esr_attribute11 := p_esr_attribute11;
549 l_rec.esr_attribute12 := p_esr_attribute12;
550 l_rec.esr_attribute13 := p_esr_attribute13;
554 l_rec.esr_attribute17 := p_esr_attribute17;
551 l_rec.esr_attribute14 := p_esr_attribute14;
552 l_rec.esr_attribute15 := p_esr_attribute15;
553 l_rec.esr_attribute16 := p_esr_attribute16;
555 l_rec.esr_attribute18 := p_esr_attribute18;
556 l_rec.esr_attribute19 := p_esr_attribute19;
557 l_rec.esr_attribute20 := p_esr_attribute20;
558 l_rec.esr_attribute21 := p_esr_attribute21;
559 l_rec.esr_attribute22 := p_esr_attribute22;
560 l_rec.esr_attribute23 := p_esr_attribute23;
561 l_rec.esr_attribute24 := p_esr_attribute24;
562 l_rec.esr_attribute25 := p_esr_attribute25;
563 l_rec.esr_attribute26 := p_esr_attribute26;
564 l_rec.esr_attribute27 := p_esr_attribute27;
565 l_rec.esr_attribute28 := p_esr_attribute28;
566 l_rec.esr_attribute29 := p_esr_attribute29;
567 l_rec.esr_attribute30 := p_esr_attribute30;
568 l_rec.object_version_number := p_object_version_number;
569 --
570 -- Return the plsql record structure.
571 --
572 hr_utility.set_location(' Leaving:'||l_proc, 10);
573 Return(l_rec);
574 --
575 End convert_args;
576 --
577 end ben_esr_shd;