1 Package Body ben_esw_bus as
2 /* $Header: beeswrhi.pkb 120.1 2005/06/17 09:40 abparekh noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_esw_bus.'; -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code varchar2(150) default null;
14 g_elig_scre_wtg_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_elig_scre_wtg_id in number
22 ,p_associated_column1 in varchar2 default null
23 ) is
24 --
25 -- Declare cursor
26 --
27 cursor csr_sec_grp is
28 select pbg.security_group_id,
29 pbg.legislation_code
30 from per_business_groups_perf pbg
31 , ben_elig_scre_wtg_f esw
32 , ben_elig_per_f epe
33 where esw.elig_scre_wtg_id = p_elig_scre_wtg_id
34 and esw.elig_per_id = epe.elig_per_id
35 and pbg.business_group_id = epe.business_group_id;
36 --
37 -- Declare local variables
38 --
39 l_security_group_id number;
40 l_proc varchar2(72) := g_package||'set_security_group_id';
41 l_legislation_code varchar2(150);
42 --
43 begin
44 --
45 hr_utility.set_location('Entering:'|| l_proc, 10);
46 --
47 -- Ensure that all the mandatory parameter are not null
48 --
49 hr_api.mandatory_arg_error
50 (p_api_name => l_proc
51 ,p_argument => 'elig_scre_wtg_id'
52 ,p_argument_value => p_elig_scre_wtg_id
53 );
54 --
55 open csr_sec_grp;
56 fetch csr_sec_grp into l_security_group_id
57 , l_legislation_code;
58 --
59 if csr_sec_grp%notfound then
60 --
61 close csr_sec_grp;
62 --
63 -- The primary key is invalid therefore we must error
64 --
65 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66 hr_multi_message.add
67 (p_associated_column1
68 => nvl(p_associated_column1,'ELIG_SCRE_WTG_ID')
69 );
70 --
71 else
72 close csr_sec_grp;
73 --
74 -- Set the security_group_id in CLIENT_INFO
75 --
76 hr_api.set_security_group_id
77 (p_security_group_id => l_security_group_id
78 );
79 --
80 -- Set the sessions legislation context in HR_SESSION_DATA
81 --
82 hr_api.set_legislation_context(l_legislation_code);
83 end if;
84 --
85 hr_utility.set_location(' Leaving:'|| l_proc, 20);
86 --
87 end set_security_group_id;
88 --
89 -- ---------------------------------------------------------------------------
90 -- |---------------------< return_legislation_code >-------------------------|
91 -- ---------------------------------------------------------------------------
92 --
93 Function return_legislation_code
94 (p_elig_scre_wtg_id in number
95 )
96 Return Varchar2 Is
97 --
98 -- Declare cursor
99 --
100 cursor csr_leg_code is
101 select pbg.legislation_code
102 from per_business_groups_perf pbg
103 , ben_elig_scre_wtg_f esw
104 , ben_elig_per_f epe
105 where esw.elig_scre_wtg_id = p_elig_scre_wtg_id
106 and esw.elig_per_id = epe.elig_per_id
107 and pbg.business_group_id = epe.business_group_id;
108 --
109 -- Declare local variables
110 --
111 l_legislation_code varchar2(150);
112 l_proc varchar2(72) := g_package||'return_legislation_code';
113 --
114 Begin
115 --
116 hr_utility.set_location('Entering:'|| l_proc, 10);
117 --
118 -- Ensure that all the mandatory parameter are not null
119 --
120 hr_api.mandatory_arg_error
121 (p_api_name => l_proc
122 ,p_argument => 'elig_scre_wtg_id'
123 ,p_argument_value => p_elig_scre_wtg_id
124 );
125 --
126 if ( nvl(ben_esw_bus.g_elig_scre_wtg_id, hr_api.g_number)
127 = p_elig_scre_wtg_id) then
128 --
129 -- The legislation code has already been found with a previous
130 -- call to this function. Just return the value in the global
131 -- variable.
132 --
133 l_legislation_code := ben_esw_bus.g_legislation_code;
134 hr_utility.set_location(l_proc, 20);
135 else
136 --
137 -- The ID is different to the last call to this function
138 -- or this is the first call to this function.
139 --
140 open csr_leg_code;
141 fetch csr_leg_code into l_legislation_code;
142 --
143 if csr_leg_code%notfound then
144 --
145 -- The primary key is invalid therefore we must error
146 --
147 close csr_leg_code;
148 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
149 fnd_message.raise_error;
150 end if;
151 hr_utility.set_location(l_proc,30);
152 --
153 -- Set the global variables so the values are
154 -- available for the next call to this function.
155 --
156 close csr_leg_code;
157 ben_esw_bus.g_elig_scre_wtg_id := p_elig_scre_wtg_id;
158 ben_esw_bus.g_legislation_code := l_legislation_code;
159 end if;
160 hr_utility.set_location(' Leaving:'|| l_proc, 40);
161 return l_legislation_code;
162 end return_legislation_code;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |-----------------------< chk_non_updateable_args >------------------------|
166 -- ----------------------------------------------------------------------------
167 -- {Start Of Comments}
168 --
169 -- Description:
170 -- This procedure is used to ensure that non updateable attributes have
171 -- not been updated. If an attribute has been updated an error is generated.
172 --
173 -- Pre Conditions:
174 -- g_old_rec has been populated with details of the values currently in
175 -- the database.
176 --
177 -- In Arguments:
178 -- p_rec has been populated with the updated values the user would like the
179 -- record set to.
180 --
181 -- Post Success:
182 -- Processing continues if all the non updateable attributes have not
183 -- changed.
184 --
185 -- Post Failure:
186 -- An application error is raised if any of the non updatable attributes
187 -- have been altered.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure chk_non_updateable_args
192 (p_effective_date in date
193 ,p_rec in ben_esw_shd.g_rec_type
194 ) IS
195 --
196 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
197 --
198 Begin
199 --
200 -- Only proceed with the validation if a row exists for the current
201 -- record in the HR Schema.
202 --
203 IF NOT ben_esw_shd.api_updating
204 (p_elig_scre_wtg_id => p_rec.elig_scre_wtg_id
205 ,p_effective_date => p_effective_date
206 ,p_object_version_number => p_rec.object_version_number
207 ) THEN
208 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
209 fnd_message.set_token('PROCEDURE ', l_proc);
210 fnd_message.set_token('STEP ', '5');
211 fnd_message.raise_error;
212 END IF;
213 --
214 End chk_non_updateable_args;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |--------------------------< dt_update_validate >--------------------------|
218 -- ----------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 -- This procedure is used for referential integrity of datetracked
223 -- parent entities when a datetrack update operation is taking place
224 -- and where there is no cascading of update defined for this entity.
225 --
226 -- Prerequisites:
227 -- This procedure is called from the update_validate.
228 --
229 -- In Parameters:
230 --
231 -- Post Success:
232 -- Processing continues.
233 --
234 -- Post Failure:
235 --
236 -- Developer Implementation Notes:
237 -- This procedure should not need maintenance unless the HR Schema model
238 -- changes.
239 --
240 -- Access Status:
241 -- Internal Row Handler Use Only.
242 --
243 -- {End Of Comments}
244 -- ----------------------------------------------------------------------------
245 Procedure dt_update_validate
246 (p_datetrack_mode in varchar2
247 ,p_validation_start_date in date
248 ,p_validation_end_date in date
249 ) Is
250 --
251 l_proc varchar2(72) := g_package||'dt_update_validate';
252 --
253 Begin
254 --
255 -- Ensure that the p_datetrack_mode argument is not null
256 --
257 hr_api.mandatory_arg_error
258 (p_api_name => l_proc
259 ,p_argument => 'datetrack_mode'
260 ,p_argument_value => p_datetrack_mode
261 );
262 --
263 -- Mode will be valid, as this is checked at the start of the upd.
264 --
265 -- Ensure the arguments are not null
266 --
267 hr_api.mandatory_arg_error
268 (p_api_name => l_proc
269 ,p_argument => 'validation_start_date'
270 ,p_argument_value => p_validation_start_date
271 );
272 --
273 hr_api.mandatory_arg_error
274 (p_api_name => l_proc
275 ,p_argument => 'validation_end_date'
276 ,p_argument_value => p_validation_end_date
277 );
278 --
279 --
280 --
281 Exception
282 When Others Then
283 --
284 -- An unhandled or unexpected error has occurred which
285 -- we must report
286 --
287 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
288 fnd_message.set_token('PROCEDURE', l_proc);
289 fnd_message.set_token('STEP','15');
290 fnd_message.raise_error;
291 End dt_update_validate;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |--------------------------< dt_delete_validate >--------------------------|
295 -- ----------------------------------------------------------------------------
296 -- {Start Of Comments}
297 --
298 -- Description:
299 -- This procedure is used for referential integrity of datetracked
300 -- child entities when either a datetrack DELETE or ZAP is in operation
301 -- and where there is no cascading of delete defined for this entity.
302 -- For the datetrack mode of DELETE or ZAP we must ensure that no
303 -- datetracked child rows exist between the validation start and end
304 -- dates.
305 --
306 -- Prerequisites:
307 -- This procedure is called from the delete_validate.
308 --
309 -- In Parameters:
310 --
311 -- Post Success:
312 -- Processing continues.
313 --
314 -- Post Failure:
315 -- If a row exists by determining the returning Boolean value from the
316 -- generic dt_api.rows_exist function then we must supply an error via
317 -- the use of the local exception handler l_rows_exist.
318 --
319 -- Developer Implementation Notes:
320 -- This procedure should not need maintenance unless the HR Schema model
321 -- changes.
322 --
323 -- Access Status:
324 -- Internal Row Handler Use Only.
325 --
326 -- {End Of Comments}
327 -- ----------------------------------------------------------------------------
328 Procedure dt_delete_validate
329 (p_elig_scre_wtg_id in number
330 ,p_datetrack_mode in varchar2
331 ,p_validation_start_date in date
332 ,p_validation_end_date in date
333 ) Is
334 --
335 l_proc varchar2(72) := g_package||'dt_delete_validate';
336 --
337 Begin
338 --
339 -- Ensure that the p_datetrack_mode argument is not null
340 --
341 hr_api.mandatory_arg_error
342 (p_api_name => l_proc
343 ,p_argument => 'datetrack_mode'
344 ,p_argument_value => p_datetrack_mode
345 );
346 --
347 -- Only perform the validation if the datetrack mode is either
348 -- DELETE or ZAP
349 --
350 If (p_datetrack_mode = hr_api.g_delete or
351 p_datetrack_mode = hr_api.g_zap) then
352 --
353 --
354 -- Ensure the arguments are not null
355 --
356 hr_api.mandatory_arg_error
357 (p_api_name => l_proc
358 ,p_argument => 'validation_start_date'
359 ,p_argument_value => p_validation_start_date
360 );
361 --
362 hr_api.mandatory_arg_error
363 (p_api_name => l_proc
364 ,p_argument => 'validation_end_date'
365 ,p_argument_value => p_validation_end_date
366 );
367 --
368 hr_api.mandatory_arg_error
369 (p_api_name => l_proc
370 ,p_argument => 'elig_scre_wtg_id'
371 ,p_argument_value => p_elig_scre_wtg_id
372 );
373 --
374 --
375 --
376 End If;
377 --
378 Exception
379 When Others Then
380 --
381 -- An unhandled or unexpected error has occurred which
382 -- we must report
383 --
384 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
385 fnd_message.set_token('PROCEDURE', l_proc);
386 fnd_message.set_token('STEP','15');
387 fnd_message.raise_error;
388 --
389 End dt_delete_validate;
390 --
391 -- ----------------------------------------------------------------------------
392 -- |---------------------------< insert_validate >----------------------------|
393 -- ----------------------------------------------------------------------------
394 Procedure insert_validate
395 (p_rec in ben_esw_shd.g_rec_type
396 ,p_effective_date in date
397 ,p_datetrack_mode in varchar2
398 ,p_validation_start_date in date
399 ,p_validation_end_date in date
400 ) is
401 --
402 l_proc varchar2(72) := g_package||'insert_validate';
403 --
404 Begin
405 hr_utility.set_location('Entering:'||l_proc, 5);
406 --
407 -- Call all supporting business operations
408 --
409 --
410 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
411 --
412 -- Validate Dependent Attributes
413 --
414 --
415 hr_utility.set_location(' Leaving:'||l_proc, 10);
416 End insert_validate;
417 --
418 -- ----------------------------------------------------------------------------
419 -- |---------------------------< update_validate >----------------------------|
420 -- ----------------------------------------------------------------------------
421 Procedure update_validate
422 (p_rec in ben_esw_shd.g_rec_type
423 ,p_effective_date in date
424 ,p_datetrack_mode in varchar2
425 ,p_validation_start_date in date
426 ,p_validation_end_date in date
427 ) is
428 --
429 l_proc varchar2(72) := g_package||'update_validate';
430 --
431 Begin
432 hr_utility.set_location('Entering:'||l_proc, 5);
433 --
434 -- Call all supporting business operations
435 --
436 --
437 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
438 --
439 -- Validate Dependent Attributes
440 --
441 -- Call the datetrack update integrity operation
442 --
443 dt_update_validate
444 (p_datetrack_mode => p_datetrack_mode
445 ,p_validation_start_date => p_validation_start_date
446 ,p_validation_end_date => p_validation_end_date
447 );
448 --
449 chk_non_updateable_args
450 (p_effective_date => p_effective_date
451 ,p_rec => p_rec
452 );
453 --
454 --
455 hr_utility.set_location(' Leaving:'||l_proc, 10);
456 End update_validate;
457 --
458 -- ----------------------------------------------------------------------------
459 -- |---------------------------< delete_validate >----------------------------|
460 -- ----------------------------------------------------------------------------
461 Procedure delete_validate
462 (p_rec in ben_esw_shd.g_rec_type
463 ,p_effective_date in date
464 ,p_datetrack_mode in varchar2
465 ,p_validation_start_date in date
466 ,p_validation_end_date in date
467 ) is
468 --
469 l_proc varchar2(72) := g_package||'delete_validate';
470 --
471 Begin
472 hr_utility.set_location('Entering:'||l_proc, 5);
473 --
474 -- Call all supporting business operations
475 --
476 dt_delete_validate
477 (p_datetrack_mode => p_datetrack_mode
478 ,p_validation_start_date => p_validation_start_date
479 ,p_validation_end_date => p_validation_end_date
480 ,p_elig_scre_wtg_id => p_rec.elig_scre_wtg_id
481 );
482 --
483 hr_utility.set_location(' Leaving:'||l_proc, 10);
484 End delete_validate;
485 --
486 end ben_esw_bus;