[Home] [Help]
PACKAGE BODY: APPS.BEN_DDR_SHD
Source
1 Package Body ben_ddr_shd as
2 /* $Header: beddrrhi.pkb 115.9 2003/03/12 07:36:29 rpgupta ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_ddr_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_DSGN_RQMT_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_dsgn_rqmt_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 dsgn_rqmt_id,
66 effective_start_date,
67 effective_end_date,
68 mn_dpnts_rqd_num,
69 mx_dpnts_alwd_num,
70 no_mn_num_dfnd_flag,
71 no_mx_num_dfnd_flag,
72 cvr_all_elig_flag,
73 oipl_id,
74 pl_id,
75 opt_id,
76 grp_rlshp_cd,
77 dsgn_typ_cd,
78 business_group_id,
79 ddr_attribute_category,
80 ddr_attribute1,
81 ddr_attribute2,
82 ddr_attribute3,
83 ddr_attribute4,
84 ddr_attribute5,
85 ddr_attribute6,
86 ddr_attribute7,
87 ddr_attribute8,
88 ddr_attribute9,
89 ddr_attribute10,
90 ddr_attribute11,
91 ddr_attribute12,
92 ddr_attribute13,
93 ddr_attribute14,
94 ddr_attribute15,
95 ddr_attribute16,
96 ddr_attribute17,
97 ddr_attribute18,
98 ddr_attribute19,
99 ddr_attribute20,
100 ddr_attribute21,
101 ddr_attribute22,
102 ddr_attribute23,
103 ddr_attribute24,
104 ddr_attribute25,
105 ddr_attribute26,
106 ddr_attribute27,
107 ddr_attribute28,
108 ddr_attribute29,
109 ddr_attribute30,
110 object_version_number
111 from ben_dsgn_rqmt_f
112 where dsgn_rqmt_id = p_dsgn_rqmt_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_dsgn_rqmt_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_dsgn_rqmt_id = g_old_rec.dsgn_rqmt_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 --
184 Cursor C_Sel1 Is
185 select t.oipl_id,
186 t.opt_id,
187 t.pl_id
188 from ben_dsgn_rqmt_f t
189 where t.dsgn_rqmt_id = p_base_key_value
190 and p_effective_date
191 between t.effective_start_date and t.effective_end_date;
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 Open C_Sel1;
196 Fetch C_Sel1 Into l_parent_key_value1,
197 l_parent_key_value2,
198 l_parent_key_value3;
199 If C_Sel1%notfound then
200 Close C_Sel1;
201 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
202 hr_utility.set_message_token('PROCEDURE', l_proc);
203 hr_utility.set_message_token('STEP','10');
204 hr_utility.raise_error;
205 End If;
206 Close C_Sel1;
207 --
208 -- Call the corresponding datetrack api
209 --
210 dt_api.find_dt_del_modes
211 (p_effective_date => p_effective_date,
212 p_base_table_name => 'ben_dsgn_rqmt_f',
213 p_base_key_column => 'dsgn_rqmt_id',
214 p_base_key_value => p_base_key_value,
215 p_parent_table_name1 => 'ben_oipl_f',
216 p_parent_key_column1 => 'oipl_id',
217 p_parent_key_value1 => l_parent_key_value1,
218 p_parent_table_name2 => 'ben_opt_f',
219 p_parent_key_column2 => 'opt_id',
220 p_parent_key_value2 => l_parent_key_value2,
221 p_parent_table_name3 => 'ben_pl_f',
222 p_parent_key_column3 => 'pl_id',
223 p_parent_key_value3 => l_parent_key_value3,
224 p_zap => p_zap,
225 p_delete => p_delete,
226 p_future_change => p_future_change,
227 p_delete_next_change => p_delete_next_change);
228 --
229 hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End find_dt_del_modes;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |--------------------------< find_dt_upd_modes >---------------------------|
234 -- ----------------------------------------------------------------------------
235 Procedure find_dt_upd_modes
236 (p_effective_date in date,
237 p_base_key_value in number,
238 p_correction out nocopy boolean,
239 p_update out nocopy boolean,
240 p_update_override out nocopy boolean,
241 p_update_change_insert out nocopy boolean) is
242 --
243 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
244 --
245 Begin
246 hr_utility.set_location('Entering:'||l_proc, 5);
247 --
248 -- Call the corresponding datetrack api
249 --
250 dt_api.find_dt_upd_modes
251 (p_effective_date => p_effective_date,
252 p_base_table_name => 'ben_dsgn_rqmt_f',
253 p_base_key_column => 'dsgn_rqmt_id',
254 p_base_key_value => p_base_key_value,
255 p_correction => p_correction,
256 p_update => p_update,
257 p_update_override => p_update_override,
258 p_update_change_insert => p_update_change_insert);
259 --
260 hr_utility.set_location(' Leaving:'||l_proc, 10);
261 End find_dt_upd_modes;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |------------------------< upd_effective_end_date >------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure upd_effective_end_date
267 (p_effective_date in date,
268 p_base_key_value in number,
269 p_new_effective_end_date in date,
270 p_validation_start_date in date,
271 p_validation_end_date in date,
272 p_object_version_number out nocopy number) is
273 --
274 l_proc varchar2(72) := g_package||'upd_effective_end_date';
275 l_object_version_number number;
276 --
277 Begin
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 --
280 -- Because we are updating a row we must get the next object
281 -- version number.
282 --
283 l_object_version_number :=
284 dt_api.get_object_version_number
285 (p_base_table_name => 'ben_dsgn_rqmt_f',
286 p_base_key_column => 'dsgn_rqmt_id',
287 p_base_key_value => p_base_key_value);
288 --
289 hr_utility.set_location(l_proc, 10);
290 g_api_dml := true; -- Set the api dml status
291 --
292 -- Update the specified datetrack row setting the effective
293 -- end date to the specified new effective end date.
294 --
295 update ben_dsgn_rqmt_f t
296 set t.effective_end_date = p_new_effective_end_date,
297 t.object_version_number = l_object_version_number
298 where t.dsgn_rqmt_id = p_base_key_value
299 and p_effective_date
300 between t.effective_start_date and t.effective_end_date;
301 --
302 g_api_dml := false; -- Unset the api dml status
303 p_object_version_number := l_object_version_number;
304 hr_utility.set_location(' Leaving:'||l_proc, 15);
305 --
306 Exception
307 When Others Then
308 g_api_dml := false; -- Unset the api dml status
309 Raise;
310 End upd_effective_end_date;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< lck >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure lck
316 (p_effective_date in date,
317 p_datetrack_mode in varchar2,
318 p_dsgn_rqmt_id in number,
319 p_object_version_number in number,
320 p_validation_start_date out nocopy date,
321 p_validation_end_date out nocopy date) is
322 --
323 l_proc varchar2(72) := g_package||'lck';
324 l_validation_start_date date;
325 l_validation_end_date date;
326 l_object_invalid exception;
327 l_argument varchar2(30);
328 --
329 -- Cursor C_Sel1 selects the current locked row as of session date
330 -- ensuring that the object version numbers match.
331 --
332 Cursor C_Sel1 is
333 select
334 dsgn_rqmt_id,
335 effective_start_date,
336 effective_end_date,
337 mn_dpnts_rqd_num,
338 mx_dpnts_alwd_num,
339 no_mn_num_dfnd_flag,
340 no_mx_num_dfnd_flag,
341 cvr_all_elig_flag,
342 oipl_id,
343 pl_id,
344 opt_id,
345 grp_rlshp_cd,
346 dsgn_typ_cd,
347 business_group_id,
348 ddr_attribute_category,
349 ddr_attribute1,
350 ddr_attribute2,
351 ddr_attribute3,
352 ddr_attribute4,
353 ddr_attribute5,
354 ddr_attribute6,
355 ddr_attribute7,
356 ddr_attribute8,
357 ddr_attribute9,
358 ddr_attribute10,
359 ddr_attribute11,
360 ddr_attribute12,
361 ddr_attribute13,
362 ddr_attribute14,
363 ddr_attribute15,
364 ddr_attribute16,
365 ddr_attribute17,
366 ddr_attribute18,
367 ddr_attribute19,
368 ddr_attribute20,
369 ddr_attribute21,
370 ddr_attribute22,
371 ddr_attribute23,
372 ddr_attribute24,
373 ddr_attribute25,
374 ddr_attribute26,
375 ddr_attribute27,
376 ddr_attribute28,
377 ddr_attribute29,
378 ddr_attribute30,
379 object_version_number
380 from ben_dsgn_rqmt_f
381 where dsgn_rqmt_id = p_dsgn_rqmt_id
382 and p_effective_date
383 between effective_start_date and effective_end_date
384 for update nowait;
385 --
386 --
387 --
388 Begin
389 hr_utility.set_location('Entering:'||l_proc, 5);
390 --
391 -- Ensure that all the mandatory arguments are not null
392 --
393 hr_api.mandatory_arg_error(p_api_name => l_proc,
394 p_argument => 'effective_date',
395 p_argument_value => p_effective_date);
396 --
397 hr_api.mandatory_arg_error(p_api_name => l_proc,
398 p_argument => 'datetrack_mode',
399 p_argument_value => p_datetrack_mode);
400 --
401 hr_api.mandatory_arg_error(p_api_name => l_proc,
402 p_argument => 'dsgn_rqmt_id',
403 p_argument_value => p_dsgn_rqmt_id);
404 --
405 hr_api.mandatory_arg_error(p_api_name => l_proc,
406 p_argument => 'object_version_number',
407 p_argument_value => p_object_version_number);
408 --
409 -- Check to ensure the datetrack mode is not INSERT.
410 --
411 If (p_datetrack_mode <> 'INSERT') then
412 --
413 -- We must select and lock the current row.
414 --
415 Open C_Sel1;
416 Fetch C_Sel1 Into g_old_rec;
417 If C_Sel1%notfound then
418 Close C_Sel1;
419 --
420 -- The primary key is invalid therefore we must error
421 --
422 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
423 hr_utility.raise_error;
424 End If;
425 Close C_Sel1;
426 If (p_object_version_number <> g_old_rec.object_version_number) Then
427 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
428 hr_utility.raise_error;
429 End If;
430 hr_utility.set_location(l_proc, 15);
431 --
432 --
433 -- Validate the datetrack mode mode getting the validation start
434 -- and end dates for the specified datetrack operation.
435 --
436 dt_api.validate_dt_mode
437 (p_effective_date => p_effective_date,
438 p_datetrack_mode => p_datetrack_mode,
439 p_base_table_name => 'ben_dsgn_rqmt_f',
440 p_base_key_column => 'dsgn_rqmt_id',
441 p_base_key_value => p_dsgn_rqmt_id,
442 p_parent_table_name1 => 'ben_oipl_f',
443 p_parent_key_column1 => 'oipl_id',
444 p_parent_key_value1 => g_old_rec.oipl_id,
445 p_parent_table_name2 => 'ben_opt_f',
446 p_parent_key_column2 => 'opt_id',
447 p_parent_key_value2 => g_old_rec.opt_id,
448 p_parent_table_name3 => 'ben_pl_f',
449 p_parent_key_column3 => 'pl_id',
450 p_parent_key_value3 => g_old_rec.pl_id,
451 p_enforce_foreign_locking => true,
452 p_validation_start_date => l_validation_start_date,
453 p_validation_end_date => l_validation_end_date);
454 Else
455 --
456 -- We are doing a datetrack 'INSERT' which is illegal within this
457 -- procedure therefore we must error (note: to lck on insert the
458 -- private procedure ins_lck should be called).
459 --
460 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
461 hr_utility.set_message_token('PROCEDURE', l_proc);
462 hr_utility.set_message_token('STEP','20');
463 hr_utility.raise_error;
464 End If;
465 --
466 -- Set the validation start and end date OUT arguments
467 --
468 p_validation_start_date := l_validation_start_date;
469 p_validation_end_date := l_validation_end_date;
470 --
471 hr_utility.set_location(' Leaving:'||l_proc, 30);
472 --
473 -- We need to trap the ORA LOCK exception
474 --
475 Exception
476 When HR_Api.Object_Locked then
477 --
478 -- The object is locked therefore we need to supply a meaningful
479 -- error message.
480 --
481 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
482 hr_utility.set_message_token('TABLE_NAME', 'ben_dsgn_rqmt_f');
483 hr_utility.raise_error;
484 When l_object_invalid then
485 --
486 -- The object doesn't exist or is invalid
487 --
488 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
489 hr_utility.set_message_token('TABLE_NAME', 'ben_dsgn_rqmt_f');
490 hr_utility.raise_error;
491 End lck;
492 --
493 -- ----------------------------------------------------------------------------
494 -- |-----------------------------< convert_args >-----------------------------|
495 -- ----------------------------------------------------------------------------
496 Function convert_args
497 (
498 p_dsgn_rqmt_id in number,
499 p_effective_start_date in date,
500 p_effective_end_date in date,
501 p_mn_dpnts_rqd_num in number,
502 p_mx_dpnts_alwd_num in number,
503 p_no_mn_num_dfnd_flag in varchar2,
504 p_no_mx_num_dfnd_flag in varchar2,
505 p_cvr_all_elig_flag in varchar2,
506 p_oipl_id in number,
507 p_pl_id in number,
508 p_opt_id in number,
509 p_grp_rlshp_cd in varchar2,
510 p_dsgn_typ_cd in varchar2,
511 p_business_group_id in number,
512 p_ddr_attribute_category in varchar2,
513 p_ddr_attribute1 in varchar2,
514 p_ddr_attribute2 in varchar2,
515 p_ddr_attribute3 in varchar2,
516 p_ddr_attribute4 in varchar2,
517 p_ddr_attribute5 in varchar2,
518 p_ddr_attribute6 in varchar2,
519 p_ddr_attribute7 in varchar2,
520 p_ddr_attribute8 in varchar2,
521 p_ddr_attribute9 in varchar2,
522 p_ddr_attribute10 in varchar2,
523 p_ddr_attribute11 in varchar2,
524 p_ddr_attribute12 in varchar2,
525 p_ddr_attribute13 in varchar2,
526 p_ddr_attribute14 in varchar2,
527 p_ddr_attribute15 in varchar2,
528 p_ddr_attribute16 in varchar2,
529 p_ddr_attribute17 in varchar2,
530 p_ddr_attribute18 in varchar2,
531 p_ddr_attribute19 in varchar2,
532 p_ddr_attribute20 in varchar2,
533 p_ddr_attribute21 in varchar2,
534 p_ddr_attribute22 in varchar2,
535 p_ddr_attribute23 in varchar2,
536 p_ddr_attribute24 in varchar2,
537 p_ddr_attribute25 in varchar2,
538 p_ddr_attribute26 in varchar2,
539 p_ddr_attribute27 in varchar2,
540 p_ddr_attribute28 in varchar2,
541 p_ddr_attribute29 in varchar2,
542 p_ddr_attribute30 in varchar2,
543 p_object_version_number in number
544 )
545 Return g_rec_type is
546 --
547 l_rec g_rec_type;
548 l_proc varchar2(72) := g_package||'convert_args';
549 --
550 Begin
551 --
552 hr_utility.set_location('Entering:'||l_proc, 5);
553 --
554 -- Convert arguments into local l_rec structure.
555 --
556 l_rec.dsgn_rqmt_id := p_dsgn_rqmt_id;
557 l_rec.effective_start_date := p_effective_start_date;
558 l_rec.effective_end_date := p_effective_end_date;
559 l_rec.mn_dpnts_rqd_num := p_mn_dpnts_rqd_num;
560 l_rec.mx_dpnts_alwd_num := p_mx_dpnts_alwd_num;
561 l_rec.no_mn_num_dfnd_flag := p_no_mn_num_dfnd_flag;
562 l_rec.no_mx_num_dfnd_flag := p_no_mx_num_dfnd_flag;
563 l_rec.cvr_all_elig_flag := p_cvr_all_elig_flag;
564 l_rec.oipl_id := p_oipl_id;
565 l_rec.pl_id := p_pl_id;
566 l_rec.opt_id := p_opt_id;
567 l_rec.grp_rlshp_cd := p_grp_rlshp_cd;
568 l_rec.dsgn_typ_cd := p_dsgn_typ_cd;
569 l_rec.business_group_id := p_business_group_id;
570 l_rec.ddr_attribute_category := p_ddr_attribute_category;
571 l_rec.ddr_attribute1 := p_ddr_attribute1;
572 l_rec.ddr_attribute2 := p_ddr_attribute2;
573 l_rec.ddr_attribute3 := p_ddr_attribute3;
574 l_rec.ddr_attribute4 := p_ddr_attribute4;
575 l_rec.ddr_attribute5 := p_ddr_attribute5;
576 l_rec.ddr_attribute6 := p_ddr_attribute6;
577 l_rec.ddr_attribute7 := p_ddr_attribute7;
578 l_rec.ddr_attribute8 := p_ddr_attribute8;
579 l_rec.ddr_attribute9 := p_ddr_attribute9;
580 l_rec.ddr_attribute10 := p_ddr_attribute10;
581 l_rec.ddr_attribute11 := p_ddr_attribute11;
582 l_rec.ddr_attribute12 := p_ddr_attribute12;
583 l_rec.ddr_attribute13 := p_ddr_attribute13;
584 l_rec.ddr_attribute14 := p_ddr_attribute14;
585 l_rec.ddr_attribute15 := p_ddr_attribute15;
586 l_rec.ddr_attribute16 := p_ddr_attribute16;
587 l_rec.ddr_attribute17 := p_ddr_attribute17;
588 l_rec.ddr_attribute18 := p_ddr_attribute18;
589 l_rec.ddr_attribute19 := p_ddr_attribute19;
590 l_rec.ddr_attribute20 := p_ddr_attribute20;
591 l_rec.ddr_attribute21 := p_ddr_attribute21;
592 l_rec.ddr_attribute22 := p_ddr_attribute22;
593 l_rec.ddr_attribute23 := p_ddr_attribute23;
594 l_rec.ddr_attribute24 := p_ddr_attribute24;
595 l_rec.ddr_attribute25 := p_ddr_attribute25;
596 l_rec.ddr_attribute26 := p_ddr_attribute26;
597 l_rec.ddr_attribute27 := p_ddr_attribute27;
598 l_rec.ddr_attribute28 := p_ddr_attribute28;
599 l_rec.ddr_attribute29 := p_ddr_attribute29;
600 l_rec.ddr_attribute30 := p_ddr_attribute30;
601 l_rec.object_version_number := p_object_version_number;
602 --
603 -- Return the plsql record structure.
604 --
605 hr_utility.set_location(' Leaving:'||l_proc, 10);
606 Return(l_rec);
607 --
608 End convert_args;
609 --
610 end ben_ddr_shd;