[Home] [Help]
PACKAGE BODY: APPS.BEN_CTU_SHD
Source
1 Package Body ben_ctu_shd as
2 /* $Header: becturhi.pkb 115.10 2002/12/16 17:35:35 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_ctu_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_CM_TYP_USG_F_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_cm_typ_usg_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 cm_typ_usg_id,
66 effective_start_date,
67 effective_end_date,
68 all_r_any_cd,
69 cm_usg_rl,
70 descr_text,
71 pgm_id,
72 pl_id,
73 pl_typ_id,
74 enrt_perd_id,
75 actn_typ_id,
76 cm_typ_id,
77 ler_id,
78 business_group_id,
79 ctu_attribute_category,
80 ctu_attribute1,
81 ctu_attribute2,
82 ctu_attribute3,
83 ctu_attribute4,
84 ctu_attribute5,
85 ctu_attribute6,
86 ctu_attribute7,
87 ctu_attribute8,
88 ctu_attribute9,
89 ctu_attribute10,
90 ctu_attribute11,
91 ctu_attribute12,
92 ctu_attribute13,
93 ctu_attribute14,
94 ctu_attribute15,
95 ctu_attribute16,
96 ctu_attribute17,
97 ctu_attribute18,
98 ctu_attribute19,
99 ctu_attribute20,
100 ctu_attribute21,
101 ctu_attribute22,
102 ctu_attribute23,
103 ctu_attribute24,
104 ctu_attribute25,
105 ctu_attribute26,
106 ctu_attribute27,
107 ctu_attribute28,
108 ctu_attribute29,
109 ctu_attribute30,
110 object_version_number
111 from ben_cm_typ_usg_f
112 where cm_typ_usg_id = p_cm_typ_usg_id
113 and p_effective_date
114 between effective_start_date and effective_end_date;
115 --
116 l_proc varchar2(72) := g_package||'api_updating';
117 l_fct_ret boolean;
118 --
119 Begin
120 hr_utility.set_location('Entering:'||l_proc, 5);
121 --
122 If (p_effective_date is null or
123 p_cm_typ_usg_id is null or
124 p_object_version_number is null) Then
125 --
126 -- One of the primary key arguments is null therefore we must
127 -- set the returning function value to false
128 --
129 l_fct_ret := false;
130 Else
131 If (p_cm_typ_usg_id = g_old_rec.cm_typ_usg_id and
132 p_object_version_number = g_old_rec.object_version_number) Then
133 hr_utility.set_location(l_proc, 10);
134 --
135 -- The g_old_rec is current therefore we must
136 -- set the returning function to true
137 --
138 l_fct_ret := true;
139 Else
140 --
141 -- Select the current row
142 --
143 Open C_Sel1;
144 Fetch C_Sel1 Into g_old_rec;
145 If C_Sel1%notfound Then
146 Close C_Sel1;
147 --
148 -- The primary key is invalid therefore we must error
149 --
150 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
151 hr_utility.raise_error;
152 End If;
153 Close C_Sel1;
154 If (p_object_version_number <> g_old_rec.object_version_number) Then
155 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
156 hr_utility.raise_error;
157 End If;
158 hr_utility.set_location(l_proc, 15);
159 l_fct_ret := true;
160 End If;
161 End If;
162 hr_utility.set_location(' Leaving:'||l_proc, 20);
163 Return (l_fct_ret);
164 --
165 End api_updating;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |--------------------------< find_dt_del_modes >---------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 (p_effective_date in date,
172 p_base_key_value in number,
173 p_zap out nocopy boolean,
174 p_delete out nocopy boolean,
175 p_future_change out nocopy boolean,
176 p_delete_next_change out nocopy boolean) is
177 --
178 l_proc varchar2(72) := g_package||'find_dt_del_modes';
179 --
180 l_parent_key_value1 number;
181 l_parent_key_value2 number;
182 l_parent_key_value3 number;
183 l_parent_key_value4 number;
184 --
185 Cursor C_Sel1 Is
186 select t.pgm_id,
187 t.cm_typ_id,
188 t.pl_id,
189 t.pl_typ_id
190 from ben_cm_typ_usg_f t
191 where t.cm_typ_usg_id = p_base_key_value
192 and p_effective_date
193 between t.effective_start_date and t.effective_end_date;
194 --
195 Begin
196 hr_utility.set_location('Entering:'||l_proc, 5);
197 Open C_Sel1;
198 Fetch C_Sel1 Into l_parent_key_value1,
199 l_parent_key_value2,
200 l_parent_key_value3,
201 l_parent_key_value4;
202 If C_Sel1%notfound then
203 Close C_Sel1;
204 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
205 hr_utility.set_message_token('PROCEDURE', l_proc);
206 hr_utility.set_message_token('STEP','10');
207 hr_utility.raise_error;
208 End If;
209 Close C_Sel1;
210 --
211 -- Call the corresponding datetrack api
212 --
213 dt_api.find_dt_del_modes
214 (p_effective_date => p_effective_date,
215 p_base_table_name => 'ben_cm_typ_usg_f',
216 p_base_key_column => 'cm_typ_usg_id',
217 p_base_key_value => p_base_key_value,
218 p_parent_table_name1 => 'ben_pgm_f',
219 p_parent_key_column1 => 'pgm_id',
220 p_parent_key_value1 => l_parent_key_value1,
221 p_parent_table_name2 => 'ben_cm_typ_f',
222 p_parent_key_column2 => 'cm_typ_id',
223 p_parent_key_value2 => l_parent_key_value2,
224 p_parent_table_name3 => 'ben_pl_f',
225 p_parent_key_column3 => 'pl_id',
226 p_parent_key_value3 => l_parent_key_value3,
227 p_parent_table_name4 => 'ben_pl_typ_f',
228 p_parent_key_column4 => 'pl_typ_id',
229 p_parent_key_value4 => l_parent_key_value4,
230 p_zap => p_zap,
231 p_delete => p_delete,
232 p_future_change => p_future_change,
233 p_delete_next_change => p_delete_next_change);
234 --
235 hr_utility.set_location(' Leaving:'||l_proc, 10);
236 End find_dt_del_modes;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |--------------------------< find_dt_upd_modes >---------------------------|
240 -- ----------------------------------------------------------------------------
241 Procedure find_dt_upd_modes
242 (p_effective_date in date,
243 p_base_key_value in number,
244 p_correction out nocopy boolean,
245 p_update out nocopy boolean,
246 p_update_override out nocopy boolean,
247 p_update_change_insert out nocopy boolean) is
248 --
249 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
250 --
251 Begin
252 hr_utility.set_location('Entering:'||l_proc, 5);
253 --
254 -- Call the corresponding datetrack api
255 --
256 dt_api.find_dt_upd_modes
257 (p_effective_date => p_effective_date,
258 p_base_table_name => 'ben_cm_typ_usg_f',
259 p_base_key_column => 'cm_typ_usg_id',
260 p_base_key_value => p_base_key_value,
261 p_correction => p_correction,
262 p_update => p_update,
263 p_update_override => p_update_override,
264 p_update_change_insert => p_update_change_insert);
265 --
266 hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End find_dt_upd_modes;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |------------------------< upd_effective_end_date >------------------------|
271 -- ----------------------------------------------------------------------------
272 Procedure upd_effective_end_date
273 (p_effective_date in date,
274 p_base_key_value in number,
275 p_new_effective_end_date in date,
276 p_validation_start_date in date,
277 p_validation_end_date in date,
278 p_object_version_number out nocopy number) is
279 --
280 l_proc varchar2(72) := g_package||'upd_effective_end_date';
281 l_object_version_number number;
282 --
283 Begin
284 hr_utility.set_location('Entering:'||l_proc, 5);
285 --
286 -- Because we are updating a row we must get the next object
287 -- version number.
288 --
289 l_object_version_number :=
290 dt_api.get_object_version_number
291 (p_base_table_name => 'ben_cm_typ_usg_f',
292 p_base_key_column => 'cm_typ_usg_id',
293 p_base_key_value => p_base_key_value);
294 --
295 hr_utility.set_location(l_proc, 10);
296 g_api_dml := true; -- Set the api dml status
297 --
298 -- Update the specified datetrack row setting the effective
299 -- end date to the specified new effective end date.
300 --
301 update ben_cm_typ_usg_f t
302 set t.effective_end_date = p_new_effective_end_date,
303 t.object_version_number = l_object_version_number
304 where t.cm_typ_usg_id = p_base_key_value
305 and p_effective_date
306 between t.effective_start_date and t.effective_end_date;
307 --
308 g_api_dml := false; -- Unset the api dml status
309 p_object_version_number := l_object_version_number;
310 hr_utility.set_location(' Leaving:'||l_proc, 15);
311 --
312 Exception
313 When Others Then
314 g_api_dml := false; -- Unset the api dml status
315 Raise;
316 End upd_effective_end_date;
317 --
318 -- ----------------------------------------------------------------------------
319 -- |---------------------------------< lck >----------------------------------|
320 -- ----------------------------------------------------------------------------
321 Procedure lck
322 (p_effective_date in date,
323 p_datetrack_mode in varchar2,
324 p_cm_typ_usg_id in number,
325 p_object_version_number in number,
326 p_validation_start_date out nocopy date,
327 p_validation_end_date out nocopy date) is
328 --
329 l_proc varchar2(72) := g_package||'lck';
330 l_validation_start_date date;
331 l_validation_end_date date;
332 l_object_invalid exception;
333 l_argument varchar2(30);
334 --
335 -- Cursor C_Sel1 selects the current locked row as of session date
336 -- ensuring that the object version numbers match.
337 --
338 Cursor C_Sel1 is
339 select
340 cm_typ_usg_id,
341 effective_start_date,
342 effective_end_date,
343 all_r_any_cd,
344 cm_usg_rl,
345 descr_text,
346 pgm_id,
347 pl_id,
348 pl_typ_id,
349 enrt_perd_id,
350 actn_typ_id,
351 cm_typ_id,
352 ler_id,
353 business_group_id,
354 ctu_attribute_category,
355 ctu_attribute1,
356 ctu_attribute2,
357 ctu_attribute3,
358 ctu_attribute4,
359 ctu_attribute5,
360 ctu_attribute6,
361 ctu_attribute7,
362 ctu_attribute8,
363 ctu_attribute9,
364 ctu_attribute10,
365 ctu_attribute11,
366 ctu_attribute12,
367 ctu_attribute13,
368 ctu_attribute14,
369 ctu_attribute15,
370 ctu_attribute16,
371 ctu_attribute17,
372 ctu_attribute18,
373 ctu_attribute19,
374 ctu_attribute20,
375 ctu_attribute21,
376 ctu_attribute22,
377 ctu_attribute23,
378 ctu_attribute24,
379 ctu_attribute25,
380 ctu_attribute26,
381 ctu_attribute27,
382 ctu_attribute28,
383 ctu_attribute29,
384 ctu_attribute30,
385 object_version_number
386 from ben_cm_typ_usg_f
387 where cm_typ_usg_id = p_cm_typ_usg_id
388 and p_effective_date
389 between effective_start_date and effective_end_date
390 for update nowait;
391 --
392 --
393 --
394 Begin
395 hr_utility.set_location('Entering:'||l_proc, 5);
396 --
397 -- Ensure that all the mandatory arguments are not null
398 --
399 hr_api.mandatory_arg_error(p_api_name => l_proc,
400 p_argument => 'effective_date',
401 p_argument_value => p_effective_date);
402 --
403 hr_api.mandatory_arg_error(p_api_name => l_proc,
404 p_argument => 'datetrack_mode',
405 p_argument_value => p_datetrack_mode);
406 --
407 hr_api.mandatory_arg_error(p_api_name => l_proc,
408 p_argument => 'cm_typ_usg_id',
409 p_argument_value => p_cm_typ_usg_id);
410 --
411 hr_api.mandatory_arg_error(p_api_name => l_proc,
412 p_argument => 'object_version_number',
413 p_argument_value => p_object_version_number);
414 --
415 -- Check to ensure the datetrack mode is not INSERT.
416 --
417 If (p_datetrack_mode <> 'INSERT') then
418 --
419 -- We must select and lock the current row.
420 --
421 Open C_Sel1;
422 Fetch C_Sel1 Into g_old_rec;
423 If C_Sel1%notfound then
424 Close C_Sel1;
425 --
426 -- The primary key is invalid therefore we must error
427 --
428 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
429 hr_utility.raise_error;
430 End If;
431 Close C_Sel1;
432 If (p_object_version_number <> g_old_rec.object_version_number) Then
433 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
434 hr_utility.raise_error;
435 End If;
436 hr_utility.set_location(l_proc, 15);
437 --
438 --
439 -- Validate the datetrack mode mode getting the validation start
440 -- and end dates for the specified datetrack operation.
441 --
442 dt_api.validate_dt_mode
443 (p_effective_date => p_effective_date,
444 p_datetrack_mode => p_datetrack_mode,
445 p_base_table_name => 'ben_cm_typ_usg_f',
446 p_base_key_column => 'cm_typ_usg_id',
450 p_parent_key_value1 => g_old_rec.pgm_id,
447 p_base_key_value => p_cm_typ_usg_id,
448 p_parent_table_name1 => 'ben_pgm_f',
449 p_parent_key_column1 => 'pgm_id',
451 p_parent_table_name2 => 'ben_cm_typ_f',
452 p_parent_key_column2 => 'cm_typ_id',
453 p_parent_key_value2 => g_old_rec.cm_typ_id,
454 p_parent_table_name3 => 'ben_pl_f',
455 p_parent_key_column3 => 'pl_id',
456 p_parent_key_value3 => g_old_rec.pl_id,
457 p_parent_table_name4 => 'ben_pl_typ_f',
458 p_parent_key_column4 => 'pl_typ_id',
459 p_parent_key_value4 => g_old_rec.pl_typ_id,
460 --p_child_table_name1 => 'ben_per_cm_usg_f',
461 --p_child_key_column1 => 'per_cm_usg_id',
462 p_enforce_foreign_locking => true,
463 p_validation_start_date => l_validation_start_date,
464 p_validation_end_date => l_validation_end_date);
465 Else
466 --
467 -- We are doing a datetrack 'INSERT' which is illegal within this
468 -- procedure therefore we must error (note: to lck on insert the
469 -- private procedure ins_lck should be called).
470 --
471 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
472 hr_utility.set_message_token('PROCEDURE', l_proc);
473 hr_utility.set_message_token('STEP','20');
474 hr_utility.raise_error;
475 End If;
476 --
477 -- Set the validation start and end date OUT arguments
478 --
479 p_validation_start_date := l_validation_start_date;
480 p_validation_end_date := l_validation_end_date;
481 --
482 hr_utility.set_location(' Leaving:'||l_proc, 30);
483 --
484 -- We need to trap the ORA LOCK exception
485 --
486 Exception
487 When HR_Api.Object_Locked then
488 --
489 -- The object is locked therefore we need to supply a meaningful
490 -- error message.
491 --
492 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
493 hr_utility.set_message_token('TABLE_NAME', 'ben_cm_typ_usg_f');
494 hr_utility.raise_error;
495 When l_object_invalid then
496 --
497 -- The object doesn't exist or is invalid
498 --
499 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
500 hr_utility.set_message_token('TABLE_NAME', 'ben_cm_typ_usg_f');
501 hr_utility.raise_error;
502 End lck;
503 --
504 -- ----------------------------------------------------------------------------
505 -- |-----------------------------< convert_args >-----------------------------|
506 -- ----------------------------------------------------------------------------
507 Function convert_args
508 (
509 p_cm_typ_usg_id in number,
510 p_effective_start_date in date,
511 p_effective_end_date in date,
512 p_all_r_any_cd in varchar2,
513 p_cm_usg_rl in number,
514 p_descr_text in varchar2,
515 p_pgm_id in number,
516 p_pl_id in number,
517 p_pl_typ_id in number,
518 p_enrt_perd_id in number,
519 p_actn_typ_id in number,
520 p_cm_typ_id in number,
521 p_ler_id in number,
522 p_business_group_id in number,
523 p_ctu_attribute_category in varchar2,
524 p_ctu_attribute1 in varchar2,
525 p_ctu_attribute2 in varchar2,
526 p_ctu_attribute3 in varchar2,
527 p_ctu_attribute4 in varchar2,
528 p_ctu_attribute5 in varchar2,
529 p_ctu_attribute6 in varchar2,
530 p_ctu_attribute7 in varchar2,
531 p_ctu_attribute8 in varchar2,
532 p_ctu_attribute9 in varchar2,
533 p_ctu_attribute10 in varchar2,
534 p_ctu_attribute11 in varchar2,
535 p_ctu_attribute12 in varchar2,
536 p_ctu_attribute13 in varchar2,
537 p_ctu_attribute14 in varchar2,
538 p_ctu_attribute15 in varchar2,
539 p_ctu_attribute16 in varchar2,
540 p_ctu_attribute17 in varchar2,
541 p_ctu_attribute18 in varchar2,
542 p_ctu_attribute19 in varchar2,
543 p_ctu_attribute20 in varchar2,
544 p_ctu_attribute21 in varchar2,
545 p_ctu_attribute22 in varchar2,
546 p_ctu_attribute23 in varchar2,
547 p_ctu_attribute24 in varchar2,
548 p_ctu_attribute25 in varchar2,
549 p_ctu_attribute26 in varchar2,
550 p_ctu_attribute27 in varchar2,
551 p_ctu_attribute28 in varchar2,
552 p_ctu_attribute29 in varchar2,
553 p_ctu_attribute30 in varchar2,
554 p_object_version_number in number
555 )
556 Return g_rec_type is
557 --
558 l_rec g_rec_type;
559 l_proc varchar2(72) := g_package||'convert_args';
560 --
561 Begin
562 --
563 hr_utility.set_location('Entering:'||l_proc, 5);
564 --
565 -- Convert arguments into local l_rec structure.
566 --
567 l_rec.cm_typ_usg_id := p_cm_typ_usg_id;
568 l_rec.effective_start_date := p_effective_start_date;
569 l_rec.effective_end_date := p_effective_end_date;
570 l_rec.all_r_any_cd := p_all_r_any_cd;
571 l_rec.cm_usg_rl := p_cm_usg_rl;
572 l_rec.descr_text := p_descr_text;
573 l_rec.pgm_id := p_pgm_id;
574 l_rec.pl_id := p_pl_id;
575 l_rec.pl_typ_id := p_pl_typ_id;
576 l_rec.enrt_perd_id := p_enrt_perd_id;
577 l_rec.actn_typ_id := p_actn_typ_id;
578 l_rec.cm_typ_id := p_cm_typ_id;
579 l_rec.ler_id := p_ler_id;
580 l_rec.business_group_id := p_business_group_id;
581 l_rec.ctu_attribute_category := p_ctu_attribute_category;
582 l_rec.ctu_attribute1 := p_ctu_attribute1;
583 l_rec.ctu_attribute2 := p_ctu_attribute2;
584 l_rec.ctu_attribute3 := p_ctu_attribute3;
585 l_rec.ctu_attribute4 := p_ctu_attribute4;
586 l_rec.ctu_attribute5 := p_ctu_attribute5;
587 l_rec.ctu_attribute6 := p_ctu_attribute6;
588 l_rec.ctu_attribute7 := p_ctu_attribute7;
589 l_rec.ctu_attribute8 := p_ctu_attribute8;
590 l_rec.ctu_attribute9 := p_ctu_attribute9;
591 l_rec.ctu_attribute10 := p_ctu_attribute10;
592 l_rec.ctu_attribute11 := p_ctu_attribute11;
593 l_rec.ctu_attribute12 := p_ctu_attribute12;
594 l_rec.ctu_attribute13 := p_ctu_attribute13;
595 l_rec.ctu_attribute14 := p_ctu_attribute14;
596 l_rec.ctu_attribute15 := p_ctu_attribute15;
597 l_rec.ctu_attribute16 := p_ctu_attribute16;
598 l_rec.ctu_attribute17 := p_ctu_attribute17;
599 l_rec.ctu_attribute18 := p_ctu_attribute18;
600 l_rec.ctu_attribute19 := p_ctu_attribute19;
601 l_rec.ctu_attribute20 := p_ctu_attribute20;
602 l_rec.ctu_attribute21 := p_ctu_attribute21;
603 l_rec.ctu_attribute22 := p_ctu_attribute22;
604 l_rec.ctu_attribute23 := p_ctu_attribute23;
605 l_rec.ctu_attribute24 := p_ctu_attribute24;
606 l_rec.ctu_attribute25 := p_ctu_attribute25;
607 l_rec.ctu_attribute26 := p_ctu_attribute26;
608 l_rec.ctu_attribute27 := p_ctu_attribute27;
609 l_rec.ctu_attribute28 := p_ctu_attribute28;
610 l_rec.ctu_attribute29 := p_ctu_attribute29;
611 l_rec.ctu_attribute30 := p_ctu_attribute30;
612 l_rec.object_version_number := p_object_version_number;
613 --
614 -- Return the plsql record structure.
615 --
616 hr_utility.set_location(' Leaving:'||l_proc, 10);
617 Return(l_rec);
618 --
619 End convert_args;
620 --
621 end ben_ctu_shd;