[Home] [Help]
PACKAGE BODY: APPS.BEN_CTT_SHD
Source
1 Package Body ben_ctt_shd as
2 /* $Header: becttrhi.pkb 115.7 2002/12/16 17:35:13 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_ctt_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_TRGR_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_trgr_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_trgr_id,
66 effective_start_date,
67 effective_end_date,
68 cm_typ_trgr_rl,
69 cm_trgr_id,
70 cm_typ_id,
71 business_group_id,
72 ctt_attribute_category,
73 ctt_attribute1,
74 ctt_attribute2,
75 ctt_attribute3,
76 ctt_attribute4,
77 ctt_attribute5,
78 ctt_attribute6,
79 ctt_attribute7,
80 ctt_attribute8,
81 ctt_attribute9,
82 ctt_attribute10,
83 ctt_attribute11,
84 ctt_attribute12,
85 ctt_attribute13,
86 ctt_attribute14,
87 ctt_attribute15,
88 ctt_attribute16,
89 ctt_attribute17,
90 ctt_attribute18,
91 ctt_attribute19,
92 ctt_attribute20,
93 ctt_attribute21,
94 ctt_attribute22,
95 ctt_attribute23,
96 ctt_attribute24,
97 ctt_attribute25,
98 ctt_attribute26,
99 ctt_attribute27,
100 ctt_attribute28,
101 ctt_attribute29,
102 ctt_attribute30,
103 object_version_number
104 from ben_cm_typ_trgr_f
105 where cm_typ_trgr_id = p_cm_typ_trgr_id
106 and p_effective_date
107 between effective_start_date and effective_end_date;
108 --
109 l_proc varchar2(72) := g_package||'api_updating';
110 l_fct_ret boolean;
111 --
112 Begin
113 hr_utility.set_location('Entering:'||l_proc, 5);
114 --
115 If (p_effective_date is null or
116 p_cm_typ_trgr_id is null or
117 p_object_version_number is null) Then
118 --
119 -- One of the primary key arguments is null therefore we must
120 -- set the returning function value to false
121 --
122 l_fct_ret := false;
123 Else
124 If (p_cm_typ_trgr_id = g_old_rec.cm_typ_trgr_id and
125 p_object_version_number = g_old_rec.object_version_number) Then
126 hr_utility.set_location(l_proc, 10);
127 --
128 -- The g_old_rec is current therefore we must
129 -- set the returning function to true
130 --
131 l_fct_ret := true;
132 Else
133 --
134 -- Select the current row
135 --
136 Open C_Sel1;
137 Fetch C_Sel1 Into g_old_rec;
138 If C_Sel1%notfound Then
139 Close C_Sel1;
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
144 hr_utility.raise_error;
145 End If;
146 Close C_Sel1;
147 If (p_object_version_number <> g_old_rec.object_version_number) Then
148 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
149 hr_utility.raise_error;
150 End If;
151 hr_utility.set_location(l_proc, 15);
152 l_fct_ret := true;
153 End If;
154 End If;
155 hr_utility.set_location(' Leaving:'||l_proc, 20);
156 Return (l_fct_ret);
157 --
158 End api_updating;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |--------------------------< find_dt_del_modes >---------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure find_dt_del_modes
164 (p_effective_date in date,
165 p_base_key_value in number,
166 p_zap out nocopy boolean,
167 p_delete out nocopy boolean,
168 p_future_change out nocopy boolean,
169 p_delete_next_change out nocopy boolean) is
170 --
171 l_proc varchar2(72) := g_package||'find_dt_del_modes';
172 --
173 l_parent_key_value1 number;
174 --
175 Cursor C_Sel1 Is
176 select t.cm_typ_id
177 from ben_cm_typ_trgr_f t
178 where t.cm_typ_trgr_id = p_base_key_value
179 and p_effective_date
180 between t.effective_start_date and t.effective_end_date;
181 --
182 Begin
183 hr_utility.set_location('Entering:'||l_proc, 5);
184 Open C_Sel1;
185 Fetch C_Sel1 Into l_parent_key_value1;
186 If C_Sel1%notfound then
187 Close C_Sel1;
188 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
189 hr_utility.set_message_token('PROCEDURE', l_proc);
190 hr_utility.set_message_token('STEP','10');
191 hr_utility.raise_error;
192 End If;
193 Close C_Sel1;
194 --
195 -- Call the corresponding datetrack api
196 --
197 dt_api.find_dt_del_modes
198 (p_effective_date => p_effective_date,
199 p_base_table_name => 'ben_cm_typ_trgr_f',
200 p_base_key_column => 'cm_typ_trgr_id',
201 p_base_key_value => p_base_key_value,
202 p_parent_table_name1 => 'ben_cm_typ_f',
203 p_parent_key_column1 => 'cm_typ_id',
204 p_parent_key_value1 => l_parent_key_value1,
205 p_zap => p_zap,
206 p_delete => p_delete,
207 p_future_change => p_future_change,
208 p_delete_next_change => p_delete_next_change);
209 --
210 hr_utility.set_location(' Leaving:'||l_proc, 10);
211 End find_dt_del_modes;
212 --
213 -- ----------------------------------------------------------------------------
214 -- |--------------------------< find_dt_upd_modes >---------------------------|
215 -- ----------------------------------------------------------------------------
216 Procedure find_dt_upd_modes
217 (p_effective_date in date,
218 p_base_key_value in number,
219 p_correction out nocopy boolean,
220 p_update out nocopy boolean,
221 p_update_override out nocopy boolean,
222 p_update_change_insert out nocopy boolean) is
223 --
224 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
225 --
226 Begin
227 hr_utility.set_location('Entering:'||l_proc, 5);
228 --
229 -- Call the corresponding datetrack api
230 --
231 dt_api.find_dt_upd_modes
232 (p_effective_date => p_effective_date,
233 p_base_table_name => 'ben_cm_typ_trgr_f',
234 p_base_key_column => 'cm_typ_trgr_id',
235 p_base_key_value => p_base_key_value,
236 p_correction => p_correction,
237 p_update => p_update,
238 p_update_override => p_update_override,
239 p_update_change_insert => p_update_change_insert);
240 --
241 hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End find_dt_upd_modes;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |------------------------< upd_effective_end_date >------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure upd_effective_end_date
248 (p_effective_date in date,
249 p_base_key_value in number,
250 p_new_effective_end_date in date,
251 p_validation_start_date in date,
252 p_validation_end_date in date,
253 p_object_version_number out nocopy number) is
254 --
255 l_proc varchar2(72) := g_package||'upd_effective_end_date';
256 l_object_version_number number;
257 --
258 Begin
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 --
261 -- Because we are updating a row we must get the next object
262 -- version number.
263 --
264 l_object_version_number :=
265 dt_api.get_object_version_number
266 (p_base_table_name => 'ben_cm_typ_trgr_f',
267 p_base_key_column => 'cm_typ_trgr_id',
268 p_base_key_value => p_base_key_value);
269 --
270 hr_utility.set_location(l_proc, 10);
271 g_api_dml := true; -- Set the api dml status
272 --
273 -- Update the specified datetrack row setting the effective
274 -- end date to the specified new effective end date.
275 --
276 update ben_cm_typ_trgr_f t
277 set t.effective_end_date = p_new_effective_end_date,
278 t.object_version_number = l_object_version_number
279 where t.cm_typ_trgr_id = p_base_key_value
280 and p_effective_date
281 between t.effective_start_date and t.effective_end_date;
282 --
283 g_api_dml := false; -- Unset the api dml status
284 p_object_version_number := l_object_version_number;
285 hr_utility.set_location(' Leaving:'||l_proc, 15);
286 --
287 Exception
288 When Others Then
289 g_api_dml := false; -- Unset the api dml status
290 Raise;
291 End upd_effective_end_date;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |---------------------------------< lck >----------------------------------|
295 -- ----------------------------------------------------------------------------
296 Procedure lck
297 (p_effective_date in date,
298 p_datetrack_mode in varchar2,
299 p_cm_typ_trgr_id in number,
300 p_object_version_number in number,
301 p_validation_start_date out nocopy date,
302 p_validation_end_date out nocopy date) is
303 --
304 l_proc varchar2(72) := g_package||'lck';
305 l_validation_start_date date;
306 l_validation_end_date date;
307 l_object_invalid exception;
308 l_argument varchar2(30);
309 --
310 -- Cursor C_Sel1 selects the current locked row as of session date
311 -- ensuring that the object version numbers match.
312 --
313 Cursor C_Sel1 is
314 select
315 cm_typ_trgr_id,
316 effective_start_date,
317 effective_end_date,
318 cm_typ_trgr_rl,
319 cm_trgr_id,
320 cm_typ_id,
321 business_group_id,
322 ctt_attribute_category,
323 ctt_attribute1,
324 ctt_attribute2,
325 ctt_attribute3,
326 ctt_attribute4,
327 ctt_attribute5,
328 ctt_attribute6,
329 ctt_attribute7,
330 ctt_attribute8,
331 ctt_attribute9,
332 ctt_attribute10,
333 ctt_attribute11,
334 ctt_attribute12,
335 ctt_attribute13,
336 ctt_attribute14,
337 ctt_attribute15,
338 ctt_attribute16,
339 ctt_attribute17,
340 ctt_attribute18,
341 ctt_attribute19,
342 ctt_attribute20,
343 ctt_attribute21,
344 ctt_attribute22,
345 ctt_attribute23,
346 ctt_attribute24,
347 ctt_attribute25,
348 ctt_attribute26,
349 ctt_attribute27,
350 ctt_attribute28,
351 ctt_attribute29,
352 ctt_attribute30,
353 object_version_number
354 from ben_cm_typ_trgr_f
355 where cm_typ_trgr_id = p_cm_typ_trgr_id
356 and p_effective_date
357 between effective_start_date and effective_end_date
358 for update nowait;
359 --
360 --
361 --
362 Begin
363 hr_utility.set_location('Entering:'||l_proc, 5);
364 --
365 -- Ensure that all the mandatory arguments are not null
366 --
367 hr_api.mandatory_arg_error(p_api_name => l_proc,
368 p_argument => 'effective_date',
369 p_argument_value => p_effective_date);
370 --
371 hr_api.mandatory_arg_error(p_api_name => l_proc,
372 p_argument => 'datetrack_mode',
373 p_argument_value => p_datetrack_mode);
374 --
375 hr_api.mandatory_arg_error(p_api_name => l_proc,
376 p_argument => 'cm_typ_trgr_id',
377 p_argument_value => p_cm_typ_trgr_id);
378 --
379 hr_api.mandatory_arg_error(p_api_name => l_proc,
380 p_argument => 'object_version_number',
381 p_argument_value => p_object_version_number);
382 --
383 -- Check to ensure the datetrack mode is not INSERT.
384 --
385 If (p_datetrack_mode <> 'INSERT') then
386 --
387 -- We must select and lock the current row.
388 --
389 Open C_Sel1;
390 Fetch C_Sel1 Into g_old_rec;
391 If C_Sel1%notfound then
392 Close C_Sel1;
393 --
394 -- The primary key is invalid therefore we must error
395 --
396 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
397 hr_utility.raise_error;
398 End If;
399 Close C_Sel1;
400 If (p_object_version_number <> g_old_rec.object_version_number) Then
401 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
402 hr_utility.raise_error;
403 End If;
404 hr_utility.set_location(l_proc, 15);
405 --
406 --
407 -- Validate the datetrack mode mode getting the validation start
408 -- and end dates for the specified datetrack operation.
409 --
410 dt_api.validate_dt_mode
411 (p_effective_date => p_effective_date,
412 p_datetrack_mode => p_datetrack_mode,
413 p_base_table_name => 'ben_cm_typ_trgr_f',
414 p_base_key_column => 'cm_typ_trgr_id',
415 p_base_key_value => p_cm_typ_trgr_id,
416 p_parent_table_name1 => 'ben_cm_typ_f',
417 p_parent_key_column1 => 'cm_typ_id',
421 p_validation_end_date => l_validation_end_date);
418 p_parent_key_value1 => g_old_rec.cm_typ_id,
419 p_enforce_foreign_locking => true,
420 p_validation_start_date => l_validation_start_date,
422 Else
423 --
424 -- We are doing a datetrack 'INSERT' which is illegal within this
425 -- procedure therefore we must error (note: to lck on insert the
426 -- private procedure ins_lck should be called).
427 --
428 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
429 hr_utility.set_message_token('PROCEDURE', l_proc);
430 hr_utility.set_message_token('STEP','20');
431 hr_utility.raise_error;
432 End If;
433 --
434 -- Set the validation start and end date OUT arguments
435 --
436 p_validation_start_date := l_validation_start_date;
437 p_validation_end_date := l_validation_end_date;
438 --
439 hr_utility.set_location(' Leaving:'||l_proc, 30);
440 --
441 -- We need to trap the ORA LOCK exception
442 --
443 Exception
444 When HR_Api.Object_Locked then
445 --
446 -- The object is locked therefore we need to supply a meaningful
447 -- error message.
448 --
449 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
450 hr_utility.set_message_token('TABLE_NAME', 'ben_cm_typ_trgr_f');
451 hr_utility.raise_error;
452 When l_object_invalid then
453 --
454 -- The object doesn't exist or is invalid
455 --
456 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
457 hr_utility.set_message_token('TABLE_NAME', 'ben_cm_typ_trgr_f');
458 hr_utility.raise_error;
459 End lck;
460 --
461 -- ----------------------------------------------------------------------------
462 -- |-----------------------------< convert_args >-----------------------------|
463 -- ----------------------------------------------------------------------------
464 Function convert_args
465 (
466 p_cm_typ_trgr_id in number,
467 p_effective_start_date in date,
468 p_effective_end_date in date,
469 p_cm_typ_trgr_rl in number,
470 p_cm_trgr_id in number,
471 p_cm_typ_id in number,
472 p_business_group_id in number,
473 p_ctt_attribute_category in varchar2,
474 p_ctt_attribute1 in varchar2,
475 p_ctt_attribute2 in varchar2,
476 p_ctt_attribute3 in varchar2,
477 p_ctt_attribute4 in varchar2,
478 p_ctt_attribute5 in varchar2,
479 p_ctt_attribute6 in varchar2,
480 p_ctt_attribute7 in varchar2,
481 p_ctt_attribute8 in varchar2,
482 p_ctt_attribute9 in varchar2,
483 p_ctt_attribute10 in varchar2,
484 p_ctt_attribute11 in varchar2,
485 p_ctt_attribute12 in varchar2,
486 p_ctt_attribute13 in varchar2,
487 p_ctt_attribute14 in varchar2,
488 p_ctt_attribute15 in varchar2,
489 p_ctt_attribute16 in varchar2,
490 p_ctt_attribute17 in varchar2,
491 p_ctt_attribute18 in varchar2,
492 p_ctt_attribute19 in varchar2,
493 p_ctt_attribute20 in varchar2,
494 p_ctt_attribute21 in varchar2,
495 p_ctt_attribute22 in varchar2,
496 p_ctt_attribute23 in varchar2,
497 p_ctt_attribute24 in varchar2,
498 p_ctt_attribute25 in varchar2,
499 p_ctt_attribute26 in varchar2,
500 p_ctt_attribute27 in varchar2,
501 p_ctt_attribute28 in varchar2,
502 p_ctt_attribute29 in varchar2,
503 p_ctt_attribute30 in varchar2,
504 p_object_version_number in number
505 )
506 Return g_rec_type is
507 --
508 l_rec g_rec_type;
509 l_proc varchar2(72) := g_package||'convert_args';
510 --
511 Begin
512 --
513 hr_utility.set_location('Entering:'||l_proc, 5);
514 --
515 -- Convert arguments into local l_rec structure.
516 --
517 l_rec.cm_typ_trgr_id := p_cm_typ_trgr_id;
518 l_rec.effective_start_date := p_effective_start_date;
519 l_rec.effective_end_date := p_effective_end_date;
520 l_rec.cm_typ_trgr_rl := p_cm_typ_trgr_rl;
521 l_rec.cm_trgr_id := p_cm_trgr_id;
522 l_rec.cm_typ_id := p_cm_typ_id;
523 l_rec.business_group_id := p_business_group_id;
524 l_rec.ctt_attribute_category := p_ctt_attribute_category;
525 l_rec.ctt_attribute1 := p_ctt_attribute1;
526 l_rec.ctt_attribute2 := p_ctt_attribute2;
527 l_rec.ctt_attribute3 := p_ctt_attribute3;
528 l_rec.ctt_attribute4 := p_ctt_attribute4;
529 l_rec.ctt_attribute5 := p_ctt_attribute5;
530 l_rec.ctt_attribute6 := p_ctt_attribute6;
531 l_rec.ctt_attribute7 := p_ctt_attribute7;
532 l_rec.ctt_attribute8 := p_ctt_attribute8;
533 l_rec.ctt_attribute9 := p_ctt_attribute9;
534 l_rec.ctt_attribute10 := p_ctt_attribute10;
535 l_rec.ctt_attribute11 := p_ctt_attribute11;
536 l_rec.ctt_attribute12 := p_ctt_attribute12;
537 l_rec.ctt_attribute13 := p_ctt_attribute13;
538 l_rec.ctt_attribute14 := p_ctt_attribute14;
539 l_rec.ctt_attribute15 := p_ctt_attribute15;
540 l_rec.ctt_attribute16 := p_ctt_attribute16;
541 l_rec.ctt_attribute17 := p_ctt_attribute17;
542 l_rec.ctt_attribute18 := p_ctt_attribute18;
543 l_rec.ctt_attribute19 := p_ctt_attribute19;
544 l_rec.ctt_attribute20 := p_ctt_attribute20;
545 l_rec.ctt_attribute21 := p_ctt_attribute21;
546 l_rec.ctt_attribute22 := p_ctt_attribute22;
547 l_rec.ctt_attribute23 := p_ctt_attribute23;
548 l_rec.ctt_attribute24 := p_ctt_attribute24;
549 l_rec.ctt_attribute25 := p_ctt_attribute25;
550 l_rec.ctt_attribute26 := p_ctt_attribute26;
551 l_rec.ctt_attribute27 := p_ctt_attribute27;
552 l_rec.ctt_attribute28 := p_ctt_attribute28;
553 l_rec.ctt_attribute29 := p_ctt_attribute29;
554 l_rec.ctt_attribute30 := p_ctt_attribute30;
555 l_rec.object_version_number := p_object_version_number;
556 --
557 -- Return the plsql record structure.
558 --
559 hr_utility.set_location(' Leaving:'||l_proc, 10);
560 Return(l_rec);
561 --
562 End convert_args;
563 --
564 end ben_ctt_shd;