[Home] [Help]
PACKAGE BODY: APPS.BEN_CPN_SHD
Source
1 Package Body ben_cpn_shd as
2 /* $Header: becpnrhi.pkb 120.0 2005/05/28 01:15:18 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_cpn_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_CNTNG_PRTN_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_CNTNG_PRTN_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_cntng_prtn_prfl_rt_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 cntng_prtn_prfl_rt_id,
71 effective_start_date,
72 effective_end_date,
73 business_group_id,
74 vrbl_rt_prfl_id,
75 name,
76 pymt_must_be_rcvd_uom,
77 pymt_must_be_rcvd_num,
78 pymt_must_be_rcvd_rl,
79 cpn_attribute_category,
80 cpn_attribute1,
81 cpn_attribute2,
82 cpn_attribute3,
83 cpn_attribute4,
84 cpn_attribute5,
85 cpn_attribute6,
86 cpn_attribute7,
87 cpn_attribute8,
88 cpn_attribute9,
89 cpn_attribute10,
90 cpn_attribute11,
91 cpn_attribute12,
92 cpn_attribute13,
93 cpn_attribute14,
94 cpn_attribute15,
95 cpn_attribute16,
96 cpn_attribute17,
97 cpn_attribute18,
98 cpn_attribute19,
99 cpn_attribute20,
100 cpn_attribute21,
101 cpn_attribute22,
102 cpn_attribute23,
103 cpn_attribute24,
104 cpn_attribute25,
105 cpn_attribute26,
106 cpn_attribute27,
107 cpn_attribute28,
108 cpn_attribute29,
109 cpn_attribute30,
110 object_version_number
111 from ben_cntng_prtn_prfl_rt_f
112 where cntng_prtn_prfl_rt_id = p_cntng_prtn_prfl_rt_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_cntng_prtn_prfl_rt_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_cntng_prtn_prfl_rt_id = g_old_rec.cntng_prtn_prfl_rt_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 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
151 fnd_message.raise_error;
152 End If;
153 Close C_Sel1;
154 If (p_object_version_number <> g_old_rec.object_version_number) Then
155 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
156 fnd_message.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 --
182 Cursor C_Sel1 Is
183 select t.vrbl_rt_prfl_id
184 from ben_cntng_prtn_prfl_rt_f t
185 where t.cntng_prtn_prfl_rt_id = p_base_key_value
186 and p_effective_date
187 between t.effective_start_date and t.effective_end_date;
188 --
189 Begin
190 hr_utility.set_location('Entering:'||l_proc, 5);
191 Open C_Sel1;
192 Fetch C_Sel1 Into l_parent_key_value1;
196 fnd_message.set_token('PROCEDURE', l_proc);
193 If C_Sel1%notfound then
194 Close C_Sel1;
195 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
197 fnd_message.set_token('STEP','10');
198 fnd_message.raise_error;
199 End If;
200 Close C_Sel1;
201 --
202 -- Call the corresponding datetrack api
203 --
204 dt_api.find_dt_del_modes
205 (p_effective_date => p_effective_date,
206 p_base_table_name => 'ben_cntng_prtn_prfl_rt_f',
207 p_base_key_column => 'cntng_prtn_prfl_rt_id',
208 p_base_key_value => p_base_key_value,
209 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
210 p_parent_key_column1 => 'vrbl_rt_prfl_id',
211 p_parent_key_value1 => l_parent_key_value1,
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_cntng_prtn_prfl_rt_f',
241 p_base_key_column => 'cntng_prtn_prfl_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_cntng_prtn_prfl_rt_f',
274 p_base_key_column => 'cntng_prtn_prfl_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_cntng_prtn_prfl_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.cntng_prtn_prfl_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_cntng_prtn_prfl_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 cntng_prtn_prfl_rt_id,
323 effective_start_date,
324 effective_end_date,
325 business_group_id,
326 vrbl_rt_prfl_id,
327 name,
328 pymt_must_be_rcvd_uom,
329 pymt_must_be_rcvd_num,
330 pymt_must_be_rcvd_rl,
331 cpn_attribute_category,
332 cpn_attribute1,
333 cpn_attribute2,
334 cpn_attribute3,
335 cpn_attribute4,
336 cpn_attribute5,
340 cpn_attribute9,
337 cpn_attribute6,
338 cpn_attribute7,
339 cpn_attribute8,
341 cpn_attribute10,
342 cpn_attribute11,
343 cpn_attribute12,
344 cpn_attribute13,
345 cpn_attribute14,
346 cpn_attribute15,
347 cpn_attribute16,
348 cpn_attribute17,
349 cpn_attribute18,
350 cpn_attribute19,
351 cpn_attribute20,
352 cpn_attribute21,
353 cpn_attribute22,
354 cpn_attribute23,
355 cpn_attribute24,
356 cpn_attribute25,
357 cpn_attribute26,
358 cpn_attribute27,
359 cpn_attribute28,
360 cpn_attribute29,
361 cpn_attribute30,
362 object_version_number
363 from ben_cntng_prtn_prfl_rt_f
364 where cntng_prtn_prfl_rt_id = p_cntng_prtn_prfl_rt_id
365 and p_effective_date
366 between effective_start_date and effective_end_date
367 for update nowait;
368 --
369 --
370 --
371 Begin
372 hr_utility.set_location('Entering:'||l_proc, 5);
373 --
374 -- Ensure that all the mandatory arguments are not null
375 --
376 hr_api.mandatory_arg_error(p_api_name => l_proc,
377 p_argument => 'effective_date',
378 p_argument_value => p_effective_date);
379 --
380 hr_api.mandatory_arg_error(p_api_name => l_proc,
381 p_argument => 'datetrack_mode',
382 p_argument_value => p_datetrack_mode);
383 --
384 hr_api.mandatory_arg_error(p_api_name => l_proc,
385 p_argument => 'cntng_prtn_prfl_rt_id',
386 p_argument_value => p_cntng_prtn_prfl_rt_id);
387 --
388 hr_api.mandatory_arg_error(p_api_name => l_proc,
389 p_argument => 'object_version_number',
390 p_argument_value => p_object_version_number);
391 --
392 -- Check to ensure the datetrack mode is not INSERT.
393 --
394 If (p_datetrack_mode <> 'INSERT') then
395 --
396 -- We must select and lock the current row.
397 --
398 Open C_Sel1;
399 Fetch C_Sel1 Into g_old_rec;
400 If C_Sel1%notfound then
401 Close C_Sel1;
402 --
403 -- The primary key is invalid therefore we must error
404 --
405 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
406 fnd_message.raise_error;
407 End If;
408 Close C_Sel1;
409 If (p_object_version_number <> g_old_rec.object_version_number) Then
410 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
411 fnd_message.raise_error;
412 End If;
413 hr_utility.set_location(l_proc, 15);
414 --
415 --
416 -- Validate the datetrack mode mode getting the validation start
417 -- and end dates for the specified datetrack operation.
418 --
419 dt_api.validate_dt_mode
420 (p_effective_date => p_effective_date,
421 p_datetrack_mode => p_datetrack_mode,
422 p_base_table_name => 'ben_cntng_prtn_prfl_rt_f',
423 p_base_key_column => 'cntng_prtn_prfl_rt_id',
424 p_base_key_value => p_cntng_prtn_prfl_rt_id,
425 p_parent_table_name1 => 'ben_vrbl_rt_prfl_f',
426 p_parent_key_column1 => 'vrbl_rt_prfl_id',
427 p_parent_key_value1 => g_old_rec.vrbl_rt_prfl_id,
428 p_validation_start_date => l_validation_start_date,
429 p_validation_end_date => l_validation_end_date);
430 Else
431 --
432 -- We are doing a datetrack 'INSERT' which is illegal within this
433 -- procedure therefore we must error (note: to lck on insert the
434 -- private procedure ins_lck should be called).
435 --
436 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
437 fnd_message.set_token('PROCEDURE', l_proc);
438 fnd_message.set_token('STEP','20');
439 fnd_message.raise_error;
440 End If;
441 --
442 -- Set the validation start and end date OUT arguments
443 --
444 p_validation_start_date := l_validation_start_date;
445 p_validation_end_date := l_validation_end_date;
446 --
447 hr_utility.set_location(' Leaving:'||l_proc, 30);
448 --
449 -- We need to trap the ORA LOCK exception
450 --
451 Exception
452 When HR_Api.Object_Locked then
453 --
454 -- The object is locked therefore we need to supply a meaningful
455 -- error message.
456 --
457 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
458 fnd_message.set_token('TABLE_NAME', 'ben_cntng_prtn_prfl_rt_f');
459 fnd_message.raise_error;
460 When l_object_invalid then
461 --
462 -- The object doesn't exist or is invalid
463 --
464 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
465 fnd_message.set_token('TABLE_NAME', 'ben_cntng_prtn_prfl_rt_f');
466 fnd_message.raise_error;
467 End lck;
468 --
469 -- ----------------------------------------------------------------------------
470 -- |-----------------------------< convert_args >-----------------------------|
471 -- ----------------------------------------------------------------------------
472 Function convert_args
473 (
474 p_cntng_prtn_prfl_rt_id in number,
475 p_effective_start_date in date,
476 p_effective_end_date in date,
477 p_business_group_id in number,
478 p_vrbl_rt_prfl_id in number,
479 p_name in varchar2,
480 p_pymt_must_be_rcvd_uom in varchar2,
481 p_pymt_must_be_rcvd_num in number,
482 p_pymt_must_be_rcvd_rl in number,
483 p_cpn_attribute_category in varchar2,
484 p_cpn_attribute1 in varchar2,
485 p_cpn_attribute2 in varchar2,
486 p_cpn_attribute3 in varchar2,
487 p_cpn_attribute4 in varchar2,
488 p_cpn_attribute5 in varchar2,
489 p_cpn_attribute6 in varchar2,
490 p_cpn_attribute7 in varchar2,
491 p_cpn_attribute8 in varchar2,
492 p_cpn_attribute9 in varchar2,
493 p_cpn_attribute10 in varchar2,
494 p_cpn_attribute11 in varchar2,
495 p_cpn_attribute12 in varchar2,
496 p_cpn_attribute13 in varchar2,
497 p_cpn_attribute14 in varchar2,
498 p_cpn_attribute15 in varchar2,
499 p_cpn_attribute16 in varchar2,
500 p_cpn_attribute17 in varchar2,
501 p_cpn_attribute18 in varchar2,
502 p_cpn_attribute19 in varchar2,
503 p_cpn_attribute20 in varchar2,
504 p_cpn_attribute21 in varchar2,
505 p_cpn_attribute22 in varchar2,
506 p_cpn_attribute23 in varchar2,
507 p_cpn_attribute24 in varchar2,
508 p_cpn_attribute25 in varchar2,
509 p_cpn_attribute26 in varchar2,
510 p_cpn_attribute27 in varchar2,
511 p_cpn_attribute28 in varchar2,
512 p_cpn_attribute29 in varchar2,
513 p_cpn_attribute30 in varchar2,
514 p_object_version_number in number
515 )
516 Return g_rec_type is
517 --
518 l_rec g_rec_type;
519 l_proc varchar2(72) := g_package||'convert_args';
520 --
521 Begin
522 --
523 hr_utility.set_location('Entering:'||l_proc, 5);
524 --
525 -- Convert arguments into local l_rec structure.
526 --
527 l_rec.cntng_prtn_prfl_rt_id := p_cntng_prtn_prfl_rt_id;
528 l_rec.effective_start_date := p_effective_start_date;
529 l_rec.effective_end_date := p_effective_end_date;
530 l_rec.business_group_id := p_business_group_id;
531 l_rec.vrbl_rt_prfl_id := p_vrbl_rt_prfl_id;
532 l_rec.name := p_name;
533 l_rec.pymt_must_be_rcvd_uom := p_pymt_must_be_rcvd_uom;
534 l_rec.pymt_must_be_rcvd_num := p_pymt_must_be_rcvd_num;
535 l_rec.pymt_must_be_rcvd_rl := p_pymt_must_be_rcvd_rl;
536 l_rec.cpn_attribute_category := p_cpn_attribute_category;
537 l_rec.cpn_attribute1 := p_cpn_attribute1;
538 l_rec.cpn_attribute2 := p_cpn_attribute2;
539 l_rec.cpn_attribute3 := p_cpn_attribute3;
540 l_rec.cpn_attribute4 := p_cpn_attribute4;
541 l_rec.cpn_attribute5 := p_cpn_attribute5;
542 l_rec.cpn_attribute6 := p_cpn_attribute6;
543 l_rec.cpn_attribute7 := p_cpn_attribute7;
544 l_rec.cpn_attribute8 := p_cpn_attribute8;
545 l_rec.cpn_attribute9 := p_cpn_attribute9;
546 l_rec.cpn_attribute10 := p_cpn_attribute10;
547 l_rec.cpn_attribute11 := p_cpn_attribute11;
548 l_rec.cpn_attribute12 := p_cpn_attribute12;
549 l_rec.cpn_attribute13 := p_cpn_attribute13;
550 l_rec.cpn_attribute14 := p_cpn_attribute14;
551 l_rec.cpn_attribute15 := p_cpn_attribute15;
552 l_rec.cpn_attribute16 := p_cpn_attribute16;
553 l_rec.cpn_attribute17 := p_cpn_attribute17;
554 l_rec.cpn_attribute18 := p_cpn_attribute18;
555 l_rec.cpn_attribute19 := p_cpn_attribute19;
556 l_rec.cpn_attribute20 := p_cpn_attribute20;
557 l_rec.cpn_attribute21 := p_cpn_attribute21;
558 l_rec.cpn_attribute22 := p_cpn_attribute22;
559 l_rec.cpn_attribute23 := p_cpn_attribute23;
560 l_rec.cpn_attribute24 := p_cpn_attribute24;
561 l_rec.cpn_attribute25 := p_cpn_attribute25;
562 l_rec.cpn_attribute26 := p_cpn_attribute26;
563 l_rec.cpn_attribute27 := p_cpn_attribute27;
564 l_rec.cpn_attribute28 := p_cpn_attribute28;
565 l_rec.cpn_attribute29 := p_cpn_attribute29;
566 l_rec.cpn_attribute30 := p_cpn_attribute30;
567 l_rec.object_version_number := p_object_version_number;
568 --
569 -- Return the plsql record structure.
570 --
571 hr_utility.set_location(' Leaving:'||l_proc, 10);
572 Return(l_rec);
573 --
574 End convert_args;
575 --
576 end ben_cpn_shd;