[Home] [Help]
PACKAGE BODY: APPS.BEN_SAZ_BUS
Source
1 Package Body ben_saz_bus as
2 /* $Header: besazrhi.pkb 120.0.12010000.2 2008/08/05 15:27:12 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_saz_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_svc_area_pstl_zip_rng_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 -- This procedure is used to check that the primary key for the table
16 -- is created properly. It should be null on insert and
17 -- should not be able to be updated.
18 --
19 -- Pre Conditions
20 -- None.
21 --
22 -- In Parameters
23 -- svc_area_pstl_zip_rng_id PK of record being inserted or updated.
24 -- effective_date Effective Date of session
25 -- object_version_number Object version number of record being
26 -- inserted or updated.
27 --
28 -- Post Success
29 -- Processing continues
30 --
31 -- Post Failure
32 -- Errors handled by the procedure
33 --
34 -- Access Status
35 -- Internal table handler use only.
36 --
37 Procedure chk_svc_area_pstl_zip_rng_id(p_svc_area_pstl_zip_rng_id in number,
38 p_effective_date in date,
39 p_object_version_number in number) is
40 --
41 l_proc varchar2(72) := g_package||'chk_svc_area_pstl_zip_rng_id';
42 l_api_updating boolean;
43 --
44 Begin
45 --
46 hr_utility.set_location('Entering:'||l_proc, 5);
47 --
48 l_api_updating := ben_saz_shd.api_updating
49 (p_effective_date => p_effective_date,
50 p_svc_area_pstl_zip_rng_id => p_svc_area_pstl_zip_rng_id,
51 p_object_version_number => p_object_version_number);
52 --
53 if (l_api_updating
54 and nvl(p_svc_area_pstl_zip_rng_id,hr_api.g_number)
55 <> ben_saz_shd.g_old_rec.svc_area_pstl_zip_rng_id) then
56 --
57 -- raise error as PK has changed
58 --
59 ben_saz_shd.constraint_error('BEN_SVC_AREA_PSTL_ZIP_RNG_PK');
60 --
61 elsif not l_api_updating then
62 --
63 -- check if PK is null
64 --
65 if p_svc_area_pstl_zip_rng_id is not null then
66 --
67 -- raise error as PK is not null
68 --
69 ben_saz_shd.constraint_error('BEN_SVC_AREA_PSTL_ZIP_RNG_PK');
70 --
71 end if;
72 --
73 end if;
74 --
75 hr_utility.set_location('Leaving:'||l_proc, 10);
76 --
77 End chk_svc_area_pstl_zip_rng_id;
78 --
79 -- ----------------------------------------------------------------------------
80 -- |--------------------------< dt_update_validate >--------------------------|
81 -- ----------------------------------------------------------------------------
82 -- {Start Of Comments}
83 --
84 -- Description:
85 -- This procedure is used for referential integrity of datetracked
86 -- parent entities when a datetrack update operation is taking place
87 -- and where there is no cascading of update defined for this entity.
88 --
89 -- Prerequisites:
90 -- This procedure is called from the update_validate.
91 --
92 -- In Parameters:
93 --
94 -- Post Success:
95 -- Processing continues.
96 --
97 -- Post Failure:
98 --
99 -- Developer Implementation Notes:
100 -- This procedure should not need maintenance unless the HR Schema model
101 -- changes.
102 --
103 -- Access Status:
104 -- Internal Row Handler Use Only.
105 --
106 -- {End Of Comments}
107 -- ----------------------------------------------------------------------------
108 Procedure dt_update_validate
109 (p_pstl_zip_rng_id in number default hr_api.g_number,
110 p_svc_area_id in number default hr_api.g_number,
111 p_datetrack_mode in varchar2,
112 p_validation_start_date in date,
113 p_validation_end_date in date) Is
114 --
115 l_proc varchar2(72) := g_package||'dt_update_validate';
116 l_integrity_error Exception;
117 l_table_name all_tables.table_name%TYPE;
118 --
119 Begin
120 hr_utility.set_location('Entering:'||l_proc, 5);
121 --
122 -- Ensure that the p_datetrack_mode argument is not null
123 --
124 hr_api.mandatory_arg_error
125 (p_api_name => l_proc,
126 p_argument => 'datetrack_mode',
127 p_argument_value => p_datetrack_mode);
128 --
129 -- Only perform the validation if the datetrack update mode is valid
130 --
131 If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
132 --
133 --
134 -- Ensure the arguments are not null
135 --
136 hr_api.mandatory_arg_error
137 (p_api_name => l_proc,
138 p_argument => 'validation_start_date',
139 p_argument_value => p_validation_start_date);
140 --
141 hr_api.mandatory_arg_error
142 (p_api_name => l_proc,
143 p_argument => 'validation_end_date',
144 p_argument_value => p_validation_end_date);
145 --
146 If ((nvl(p_pstl_zip_rng_id, hr_api.g_number) <> hr_api.g_number) and
147 NOT (dt_api.check_min_max_dates
148 (p_base_table_name => 'ben_pstl_zip_rng_f',
149 p_base_key_column => 'pstl_zip_rng_id',
150 p_base_key_value => p_pstl_zip_rng_id,
151 p_from_date => p_validation_start_date,
152 p_to_date => p_validation_end_date))) Then
153 l_table_name := 'ben_pstl_zip_rng_f';
154 Raise l_integrity_error;
155 End If;
156 If ((nvl(p_svc_area_id, hr_api.g_number) <> hr_api.g_number) and
157 NOT (dt_api.check_min_max_dates
158 (p_base_table_name => 'ben_svc_area_f',
159 p_base_key_column => 'svc_area_id',
160 p_base_key_value => p_svc_area_id,
161 p_from_date => p_validation_start_date,
162 p_to_date => p_validation_end_date))) Then
163 l_table_name := 'ben_svc_area_f';
164 Raise l_integrity_error;
165 End If;
166 --
167 End If;
168 --
169 hr_utility.set_location(' Leaving:'||l_proc, 10);
170 Exception
171 When l_integrity_error Then
172 --
173 -- A referential integrity check was violated therefore
174 -- we must error
175 --
176 ben_utility.parent_integrity_error(p_table_name => l_table_name);
177 When Others Then
178 --
179 -- An unhandled or unexpected error has occurred which
180 -- we must report
181 --
182 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
183 hr_utility.set_message_token('PROCEDURE', l_proc);
184 hr_utility.set_message_token('STEP','15');
185 hr_utility.raise_error;
186 End dt_update_validate;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |--------------------------< dt_delete_validate >--------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 -- This procedure is used for referential integrity of datetracked
195 -- child entities when either a datetrack DELETE or ZAP is in operation
196 -- and where there is no cascading of delete defined for this entity.
197 -- For the datetrack mode of DELETE or ZAP we must ensure that no
198 -- datetracked child rows exist between the validation start and end
199 -- dates.
200 --
201 -- Prerequisites:
202 -- This procedure is called from the delete_validate.
203 --
204 -- In Parameters:
205 --
206 -- Post Success:
207 -- Processing continues.
208 --
209 -- Post Failure:
210 -- If a row exists by determining the returning Boolean value from the
211 -- generic dt_api.rows_exist function then we must supply an error via
212 -- the use of the local exception handler l_rows_exist.
213 --
214 -- Developer Implementation Notes:
215 -- This procedure should not need maintenance unless the HR Schema model
216 -- changes.
217 --
218 -- Access Status:
219 -- Internal Row Handler Use Only.
220 --
221 -- {End Of Comments}
222 -- ----------------------------------------------------------------------------
223 Procedure dt_delete_validate
224 (p_svc_area_pstl_zip_rng_id in number,
225 p_datetrack_mode in varchar2,
226 p_validation_start_date in date,
227 p_validation_end_date in date) Is
228 --
229 l_proc varchar2(72) := g_package||'dt_delete_validate';
230 l_rows_exist Exception;
231 l_table_name all_tables.table_name%TYPE;
232 --
233 Begin
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 --
236 -- Ensure that the p_datetrack_mode argument is not null
237 --
238 hr_api.mandatory_arg_error
239 (p_api_name => l_proc,
240 p_argument => 'datetrack_mode',
241 p_argument_value => p_datetrack_mode);
242 --
243 -- Only perform the validation if the datetrack mode is either
244 -- DELETE or ZAP
245 --
246 If (p_datetrack_mode = 'DELETE' or
247 p_datetrack_mode = 'ZAP') then
248 --
249 --
250 -- Ensure the arguments are not null
251 --
252 hr_api.mandatory_arg_error
253 (p_api_name => l_proc,
254 p_argument => 'validation_start_date',
255 p_argument_value => p_validation_start_date);
256 --
257 hr_api.mandatory_arg_error
258 (p_api_name => l_proc,
259 p_argument => 'validation_end_date',
260 p_argument_value => p_validation_end_date);
261 --
262 hr_api.mandatory_arg_error
263 (p_api_name => l_proc,
264 p_argument => 'svc_area_pstl_zip_rng_id',
265 p_argument_value => p_svc_area_pstl_zip_rng_id);
266 --
267 --
268 --
269 End If;
270 --
271 hr_utility.set_location(' Leaving:'||l_proc, 10);
272 Exception
273 When l_rows_exist Then
274 --
275 -- A referential integrity check was violated therefore
276 -- we must error
277 --
278 ben_utility.child_exists_error(p_table_name => l_table_name);
279 When Others Then
280 --
281 -- An unhandled or unexpected error has occurred which
282 -- we must report
283 --
284 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
285 hr_utility.set_message_token('PROCEDURE', l_proc);
286 hr_utility.set_message_token('STEP','15');
287 hr_utility.raise_error;
288 End dt_delete_validate;
289 --
290 -- ----------------------------------------------------------------------------
291 -- |---------------------------< insert_validate >----------------------------|
292 -- ----------------------------------------------------------------------------
293 Procedure insert_validate
294 (p_rec in ben_saz_shd.g_rec_type,
295 p_effective_date in date,
296 p_datetrack_mode in varchar2,
297 p_validation_start_date in date,
298 p_validation_end_date in date) is
299 --
300 l_proc varchar2(72) := g_package||'insert_validate';
301 --
302 Begin
303 hr_utility.set_location('Entering:'||l_proc, 5);
304 --
305 -- Call all supporting business operations
306 --
307 --
308 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
309 --
310 chk_svc_area_pstl_zip_rng_id
311 (p_svc_area_pstl_zip_rng_id => p_rec.svc_area_pstl_zip_rng_id,
312 p_effective_date => p_effective_date,
313 p_object_version_number => p_rec.object_version_number);
314 --
315 hr_utility.set_location(' Leaving:'||l_proc, 10);
316 End insert_validate;
317 --
318 -- ----------------------------------------------------------------------------
319 -- |---------------------------< update_validate >----------------------------|
320 -- ----------------------------------------------------------------------------
321 Procedure update_validate
322 (p_rec in ben_saz_shd.g_rec_type,
323 p_effective_date in date,
324 p_datetrack_mode in varchar2,
325 p_validation_start_date in date,
326 p_validation_end_date in date) is
327 --
328 l_proc varchar2(72) := g_package||'update_validate';
329 --
330 Begin
331 hr_utility.set_location('Entering:'||l_proc, 5);
332 --
333 -- Call all supporting business operations
334 --
335 --
336 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
337 --
338 chk_svc_area_pstl_zip_rng_id
339 (p_svc_area_pstl_zip_rng_id => p_rec.svc_area_pstl_zip_rng_id,
340 p_effective_date => p_effective_date,
341 p_object_version_number => p_rec.object_version_number);
342 --
343 -- Call the datetrack update integrity operation
344 --
345 dt_update_validate
346 (p_pstl_zip_rng_id => p_rec.pstl_zip_rng_id,
347 p_svc_area_id => p_rec.svc_area_id,
348 p_datetrack_mode => p_datetrack_mode,
349 p_validation_start_date => p_validation_start_date,
350 p_validation_end_date => p_validation_end_date);
351 --
352 hr_utility.set_location(' Leaving:'||l_proc, 10);
353 End update_validate;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------< delete_validate >----------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure delete_validate
359 (p_rec in ben_saz_shd.g_rec_type,
360 p_effective_date in date,
361 p_datetrack_mode in varchar2,
362 p_validation_start_date in date,
363 p_validation_end_date in date) is
364 --
365 l_proc varchar2(72) := g_package||'delete_validate';
366 --
367 Begin
368 hr_utility.set_location('Entering:'||l_proc, 5);
369 --
370 -- Call all supporting business operations
371 --
372 dt_delete_validate
373 (p_datetrack_mode => p_datetrack_mode,
374 p_validation_start_date => p_validation_start_date,
375 p_validation_end_date => p_validation_end_date,
376 p_svc_area_pstl_zip_rng_id => p_rec.svc_area_pstl_zip_rng_id);
377 --
378 hr_utility.set_location(' Leaving:'||l_proc, 10);
379 End delete_validate;
380 --
381 --
382 -- ---------------------------------------------------------------------------
383 -- |---------------------< return_legislation_code >-------------------------|
384 -- ---------------------------------------------------------------------------
385 --
386 function return_legislation_code
387 (p_svc_area_pstl_zip_rng_id in number) return varchar2 is
388 --
389 -- Declare cursor
390 --
391 cursor csr_leg_code is
392 select a.legislation_code
393 from per_business_groups a,
394 ben_svc_area_pstl_zip_rng_f b
395 where b.svc_area_pstl_zip_rng_id = p_svc_area_pstl_zip_rng_id
396 and a.business_group_id = b.business_group_id;
397 --
398 -- Declare local variables
399 --
400 l_legislation_code varchar2(150);
401 l_proc varchar2(72) := g_package||'return_legislation_code';
402 --
403 begin
404 --
405 hr_utility.set_location('Entering:'|| l_proc, 10);
406 --
407 -- Ensure that all the mandatory parameter are not null
408 --
409 hr_api.mandatory_arg_error(p_api_name => l_proc,
410 p_argument => 'svc_area_pstl_zip_rng_id',
411 p_argument_value => p_svc_area_pstl_zip_rng_id);
412 --
413 open csr_leg_code;
414 --
415 fetch csr_leg_code into l_legislation_code;
416 --
417 if csr_leg_code%notfound then
418 --
419 close csr_leg_code;
420 --
421 -- The primary key is invalid therefore we must error
422 --
423 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
424 hr_utility.raise_error;
425 --
426 end if;
427 --
428 close csr_leg_code;
429 --
430 hr_utility.set_location(' Leaving:'|| l_proc, 20);
431 --
432 return l_legislation_code;
433 --
434 end return_legislation_code;
435 --
436 end ben_saz_bus;