[Home] [Help]
PACKAGE BODY: APPS.BEN_CPR_SHD
Source
1 Package Body ben_cpr_shd as
2 /* $Header: becprrhi.pkb 115.12 2002/12/13 06:21:26 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_cpr_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_POPL_ORG_ROLE_F_FK1') Then
37 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38 fnd_message.set_token('PROCEDURE', l_proc);
39 fnd_message.set_token('STEP','5');
40 fnd_message.raise_error;
41 ElsIf (p_constraint_name = 'BEN_POPL_ORG_ROLE_F_PK') Then
42 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43 fnd_message.set_token('PROCEDURE', l_proc);
44 fnd_message.set_token('STEP','10');
45 fnd_message.raise_error;
46 Else
47 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
48 fnd_message.set_token('PROCEDURE', l_proc);
49 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
50 fnd_message.raise_error;
51 End If;
52 --
53 hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60 (p_effective_date in date,
61 p_popl_org_role_id in number,
62 p_object_version_number in number
63 ) Return Boolean Is
64 --
65 --
66 -- Cursor selects the 'current' row from the HR Schema
67 --
68 Cursor C_Sel1 is
69 select
70 popl_org_role_id,
71 effective_start_date,
72 effective_end_date,
73 name,
74 org_role_typ_cd,
75 popl_org_id,
76 business_group_id,
77 cpr_attribute_category,
78 cpr_attribute1,
79 cpr_attribute2,
80 cpr_attribute3,
81 cpr_attribute4,
82 cpr_attribute5,
83 cpr_attribute6,
84 cpr_attribute7,
85 cpr_attribute8,
86 cpr_attribute9,
87 cpr_attribute10,
88 cpr_attribute11,
89 cpr_attribute12,
90 cpr_attribute13,
91 cpr_attribute14,
92 cpr_attribute15,
93 cpr_attribute16,
94 cpr_attribute17,
95 cpr_attribute18,
96 cpr_attribute19,
97 cpr_attribute20,
98 cpr_attribute21,
99 cpr_attribute22,
100 cpr_attribute23,
101 cpr_attribute24,
102 cpr_attribute25,
103 cpr_attribute26,
104 cpr_attribute27,
105 cpr_attribute28,
106 cpr_attribute29,
107 cpr_attribute30,
108 object_version_number
109 from ben_popl_org_role_f
113 --
110 where popl_org_role_id = p_popl_org_role_id
111 and p_effective_date
112 between effective_start_date and effective_end_date;
114 l_proc varchar2(72) := g_package||'api_updating';
115 l_fct_ret boolean;
116 --
117 Begin
118 hr_utility.set_location('Entering:'||l_proc, 5);
119 --
120 If (p_effective_date is null or
121 p_popl_org_role_id is null or
122 p_object_version_number is null) Then
123 --
124 -- One of the primary key arguments is null therefore we must
125 -- set the returning function value to false
126 --
127 l_fct_ret := false;
128 Else
129 If (p_popl_org_role_id = g_old_rec.popl_org_role_id and
130 p_object_version_number = g_old_rec.object_version_number) Then
131 hr_utility.set_location(l_proc, 10);
132 --
133 -- The g_old_rec is current therefore we must
134 -- set the returning function to true
135 --
136 l_fct_ret := true;
137 Else
138 --
139 -- Select the current row
140 --
141 Open C_Sel1;
142 Fetch C_Sel1 Into g_old_rec;
143 If C_Sel1%notfound Then
144 Close C_Sel1;
145 --
146 -- The primary key is invalid therefore we must error
147 --
148 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
149 fnd_message.raise_error;
150 End If;
151 Close C_Sel1;
152 If (p_object_version_number <> g_old_rec.object_version_number) Then
153 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154 fnd_message.raise_error;
155 End If;
156 hr_utility.set_location(l_proc, 15);
157 l_fct_ret := true;
158 End If;
159 End If;
160 hr_utility.set_location(' Leaving:'||l_proc, 20);
161 Return (l_fct_ret);
162 --
163 End api_updating;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |--------------------------< find_dt_del_modes >---------------------------|
167 -- ----------------------------------------------------------------------------
168 Procedure find_dt_del_modes
169 (p_effective_date in date,
170 p_base_key_value in number,
171 p_zap out nocopy boolean,
172 p_delete out nocopy boolean,
173 p_future_change out nocopy boolean,
174 p_delete_next_change out nocopy boolean) is
175 --
176 l_proc varchar2(72) := g_package||'find_dt_del_modes';
177 --
178 --
179 --
180 --
181 Begin
182 hr_utility.set_location('Entering:'||l_proc, 5);
183 --
184 --
185 -- Call the corresponding datetrack api
186 --
187 dt_api.find_dt_del_modes
188 (p_effective_date => p_effective_date,
189 p_base_table_name => 'ben_popl_org_role_f',
190 p_base_key_column => 'popl_org_role_id',
191 p_base_key_value => p_base_key_value,
192 p_zap => p_zap,
193 p_delete => p_delete,
194 p_future_change => p_future_change,
195 p_delete_next_change => p_delete_next_change);
196 --
197 hr_utility.set_location(' Leaving:'||l_proc, 10);
198 End find_dt_del_modes;
199 --
200 -- ----------------------------------------------------------------------------
201 -- |--------------------------< find_dt_upd_modes >---------------------------|
202 -- ----------------------------------------------------------------------------
203 Procedure find_dt_upd_modes
204 (p_effective_date in date,
205 p_base_key_value in number,
206 p_correction out nocopy boolean,
207 p_update out nocopy boolean,
208 p_update_override out nocopy boolean,
209 p_update_change_insert out nocopy boolean) is
210 --
211 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
212 --
213 Begin
214 hr_utility.set_location('Entering:'||l_proc, 5);
215 --
216 -- Call the corresponding datetrack api
217 --
218 dt_api.find_dt_upd_modes
219 (p_effective_date => p_effective_date,
220 p_base_table_name => 'ben_popl_org_role_f',
221 p_base_key_column => 'popl_org_role_id',
222 p_base_key_value => p_base_key_value,
223 p_correction => p_correction,
224 p_update => p_update,
225 p_update_override => p_update_override,
226 p_update_change_insert => p_update_change_insert);
227 --
228 hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End find_dt_upd_modes;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |------------------------< upd_effective_end_date >------------------------|
233 -- ----------------------------------------------------------------------------
234 Procedure upd_effective_end_date
235 (p_effective_date in date,
236 p_base_key_value in number,
237 p_new_effective_end_date in date,
238 p_validation_start_date in date,
239 p_validation_end_date in date,
240 p_object_version_number out nocopy number) is
241 --
242 l_proc varchar2(72) := g_package||'upd_effective_end_date';
243 l_object_version_number number;
244 --
245 Begin
246 hr_utility.set_location('Entering:'||l_proc, 5);
247 --
248 -- Because we are updating a row we must get the next object
249 -- version number.
250 --
251 l_object_version_number :=
252 dt_api.get_object_version_number
253 (p_base_table_name => 'ben_popl_org_role_f',
254 p_base_key_column => 'popl_org_role_id',
255 p_base_key_value => p_base_key_value);
256 --
257 hr_utility.set_location(l_proc, 10);
258 g_api_dml := true; -- Set the api dml status
259 --
260 -- Update the specified datetrack row setting the effective
261 -- end date to the specified new effective end date.
262 --
266 where t.popl_org_role_id = p_base_key_value
263 update ben_popl_org_role_f t
264 set t.effective_end_date = p_new_effective_end_date,
265 t.object_version_number = l_object_version_number
267 and p_effective_date
268 between t.effective_start_date and t.effective_end_date;
269 --
270 g_api_dml := false; -- Unset the api dml status
271 p_object_version_number := l_object_version_number;
272 hr_utility.set_location(' Leaving:'||l_proc, 15);
273 --
274 Exception
275 When Others Then
276 g_api_dml := false; -- Unset the api dml status
277 Raise;
278 End upd_effective_end_date;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------------< lck >----------------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure lck
284 (p_effective_date in date,
285 p_datetrack_mode in varchar2,
286 p_popl_org_role_id in number,
287 p_object_version_number in number,
288 p_validation_start_date out nocopy date,
289 p_validation_end_date out nocopy date) is
290 --
291 l_proc varchar2(72) := g_package||'lck';
292 l_validation_start_date date;
293 l_validation_end_date date;
294 l_object_invalid exception;
295 l_argument varchar2(30);
296 --
297 -- Cursor C_Sel1 selects the current locked row as of session date
298 -- ensuring that the object version numbers match.
299 --
300 Cursor C_Sel1 is
301 select
302 popl_org_role_id,
303 effective_start_date,
304 effective_end_date,
305 name,
306 org_role_typ_cd,
307 popl_org_id,
308 business_group_id,
309 cpr_attribute_category,
310 cpr_attribute1,
311 cpr_attribute2,
312 cpr_attribute3,
313 cpr_attribute4,
314 cpr_attribute5,
315 cpr_attribute6,
316 cpr_attribute7,
317 cpr_attribute8,
318 cpr_attribute9,
319 cpr_attribute10,
320 cpr_attribute11,
321 cpr_attribute12,
322 cpr_attribute13,
323 cpr_attribute14,
324 cpr_attribute15,
325 cpr_attribute16,
326 cpr_attribute17,
327 cpr_attribute18,
328 cpr_attribute19,
329 cpr_attribute20,
330 cpr_attribute21,
331 cpr_attribute22,
332 cpr_attribute23,
333 cpr_attribute24,
334 cpr_attribute25,
335 cpr_attribute26,
336 cpr_attribute27,
337 cpr_attribute28,
338 cpr_attribute29,
339 cpr_attribute30,
340 object_version_number
341 from ben_popl_org_role_f
342 where popl_org_role_id = p_popl_org_role_id
343 and p_effective_date
344 between effective_start_date and effective_end_date
345 for update nowait;
346 --
347 --
348 --
349 Begin
350 hr_utility.set_location('Entering:'||l_proc, 5);
351 --
352 -- Ensure that all the mandatory arguments are not null
353 --
354 hr_api.mandatory_arg_error(p_api_name => l_proc,
355 p_argument => 'effective_date',
356 p_argument_value => p_effective_date);
357 --
358 hr_api.mandatory_arg_error(p_api_name => l_proc,
359 p_argument => 'datetrack_mode',
360 p_argument_value => p_datetrack_mode);
361 --
362 hr_api.mandatory_arg_error(p_api_name => l_proc,
363 p_argument => 'popl_org_role_id',
364 p_argument_value => p_popl_org_role_id);
365 --
366 hr_api.mandatory_arg_error(p_api_name => l_proc,
367 p_argument => 'object_version_number',
368 p_argument_value => p_object_version_number);
369 --
370 -- Check to ensure the datetrack mode is not INSERT.
371 --
372 If (p_datetrack_mode <> 'INSERT') then
373 --
374 -- We must select and lock the current row.
375 --
376 Open C_Sel1;
377 Fetch C_Sel1 Into g_old_rec;
378 If C_Sel1%notfound then
379 Close C_Sel1;
380 --
381 -- The primary key is invalid therefore we must error
382 --
383 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
384 fnd_message.raise_error;
385 End If;
386 Close C_Sel1;
387 If (p_object_version_number <> g_old_rec.object_version_number) Then
388 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
389 fnd_message.raise_error;
390 End If;
391 hr_utility.set_location(l_proc, 15);
392 --
393 --
394 -- Validate the datetrack mode mode getting the validation start
395 -- and end dates for the specified datetrack operation.
396 --
397 dt_api.validate_dt_mode
398 (p_effective_date => p_effective_date,
399 p_datetrack_mode => p_datetrack_mode,
400 p_base_table_name => 'ben_popl_org_role_f',
401 p_base_key_column => 'popl_org_role_id',
402 p_base_key_value => p_popl_org_role_id,
403 p_enforce_foreign_locking => true,
404 p_validation_start_date => l_validation_start_date,
405 p_validation_end_date => l_validation_end_date);
406 Else
407 --
408 -- We are doing a datetrack 'INSERT' which is illegal within this
409 -- procedure therefore we must error (note: to lck on insert the
410 -- private procedure ins_lck should be called).
411 --
412 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
413 fnd_message.set_token('PROCEDURE', l_proc);
414 fnd_message.set_token('STEP','20');
418 -- Set the validation start and end date OUT arguments
415 fnd_message.raise_error;
416 End If;
417 --
419 --
420 p_validation_start_date := l_validation_start_date;
421 p_validation_end_date := l_validation_end_date;
422 --
423 hr_utility.set_location(' Leaving:'||l_proc, 30);
424 --
425 -- We need to trap the ORA LOCK exception
426 --
427 Exception
428 When HR_Api.Object_Locked then
429 --
430 -- The object is locked therefore we need to supply a meaningful
431 -- error message.
432 --
433 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
434 fnd_message.set_token('TABLE_NAME', 'ben_popl_org_role_f');
435 fnd_message.raise_error;
436 When l_object_invalid then
437 --
438 -- The object doesn't exist or is invalid
439 --
440 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
441 fnd_message.set_token('TABLE_NAME', 'ben_popl_org_role_f');
442 fnd_message.raise_error;
443 End lck;
444 --
445 -- ----------------------------------------------------------------------------
446 -- |-----------------------------< convert_args >-----------------------------|
447 -- ----------------------------------------------------------------------------
448 Function convert_args
449 (
450 p_popl_org_role_id in number,
451 p_effective_start_date in date,
452 p_effective_end_date in date,
453 p_name in varchar2,
454 p_org_role_typ_cd in varchar2,
455 p_popl_org_id in number,
456 p_business_group_id in number,
457 p_cpr_attribute_category in varchar2,
458 p_cpr_attribute1 in varchar2,
459 p_cpr_attribute2 in varchar2,
460 p_cpr_attribute3 in varchar2,
461 p_cpr_attribute4 in varchar2,
462 p_cpr_attribute5 in varchar2,
463 p_cpr_attribute6 in varchar2,
464 p_cpr_attribute7 in varchar2,
465 p_cpr_attribute8 in varchar2,
466 p_cpr_attribute9 in varchar2,
467 p_cpr_attribute10 in varchar2,
468 p_cpr_attribute11 in varchar2,
469 p_cpr_attribute12 in varchar2,
470 p_cpr_attribute13 in varchar2,
471 p_cpr_attribute14 in varchar2,
472 p_cpr_attribute15 in varchar2,
473 p_cpr_attribute16 in varchar2,
474 p_cpr_attribute17 in varchar2,
475 p_cpr_attribute18 in varchar2,
476 p_cpr_attribute19 in varchar2,
477 p_cpr_attribute20 in varchar2,
478 p_cpr_attribute21 in varchar2,
479 p_cpr_attribute22 in varchar2,
480 p_cpr_attribute23 in varchar2,
481 p_cpr_attribute24 in varchar2,
482 p_cpr_attribute25 in varchar2,
483 p_cpr_attribute26 in varchar2,
484 p_cpr_attribute27 in varchar2,
485 p_cpr_attribute28 in varchar2,
486 p_cpr_attribute29 in varchar2,
487 p_cpr_attribute30 in varchar2,
488 p_object_version_number in number
489 )
490 Return g_rec_type is
491 --
492 l_rec g_rec_type;
493 l_proc varchar2(72) := g_package||'convert_args';
494 --
495 Begin
496 --
497 hr_utility.set_location('Entering:'||l_proc, 5);
498 --
499 -- Convert arguments into local l_rec structure.
500 --
501 l_rec.popl_org_role_id := p_popl_org_role_id;
502 l_rec.effective_start_date := p_effective_start_date;
503 l_rec.effective_end_date := p_effective_end_date;
504 l_rec.name := p_name;
505 l_rec.org_role_typ_cd := P_org_role_typ_cd;
506 l_rec.popl_org_id := p_popl_org_id;
507 l_rec.business_group_id := p_business_group_id;
508 l_rec.cpr_attribute_category := p_cpr_attribute_category;
509 l_rec.cpr_attribute1 := p_cpr_attribute1;
510 l_rec.cpr_attribute2 := p_cpr_attribute2;
511 l_rec.cpr_attribute3 := p_cpr_attribute3;
512 l_rec.cpr_attribute4 := p_cpr_attribute4;
513 l_rec.cpr_attribute5 := p_cpr_attribute5;
514 l_rec.cpr_attribute6 := p_cpr_attribute6;
515 l_rec.cpr_attribute7 := p_cpr_attribute7;
516 l_rec.cpr_attribute8 := p_cpr_attribute8;
517 l_rec.cpr_attribute9 := p_cpr_attribute9;
518 l_rec.cpr_attribute10 := p_cpr_attribute10;
519 l_rec.cpr_attribute11 := p_cpr_attribute11;
520 l_rec.cpr_attribute12 := p_cpr_attribute12;
521 l_rec.cpr_attribute13 := p_cpr_attribute13;
522 l_rec.cpr_attribute14 := p_cpr_attribute14;
523 l_rec.cpr_attribute15 := p_cpr_attribute15;
524 l_rec.cpr_attribute16 := p_cpr_attribute16;
525 l_rec.cpr_attribute17 := p_cpr_attribute17;
526 l_rec.cpr_attribute18 := p_cpr_attribute18;
527 l_rec.cpr_attribute19 := p_cpr_attribute19;
528 l_rec.cpr_attribute20 := p_cpr_attribute20;
529 l_rec.cpr_attribute21 := p_cpr_attribute21;
530 l_rec.cpr_attribute22 := p_cpr_attribute22;
531 l_rec.cpr_attribute23 := p_cpr_attribute23;
532 l_rec.cpr_attribute24 := p_cpr_attribute24;
533 l_rec.cpr_attribute25 := p_cpr_attribute25;
534 l_rec.cpr_attribute26 := p_cpr_attribute26;
535 l_rec.cpr_attribute27 := p_cpr_attribute27;
536 l_rec.cpr_attribute28 := p_cpr_attribute28;
537 l_rec.cpr_attribute29 := p_cpr_attribute29;
538 l_rec.cpr_attribute30 := p_cpr_attribute30;
539 l_rec.object_version_number := p_object_version_number;
540 --
541 -- Return the plsql record structure.
542 --
543 hr_utility.set_location(' Leaving:'||l_proc, 10);
544 Return(l_rec);
545 --
546 End convert_args;
547 --
548 end ben_cpr_shd;