1 Package Body ben_cpi_bus as
2 /* $Header: becpirhi.pkb 120.0 2005/05/28 01:13 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_cpi_bus.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10
11 --
12 -- The following two global variables are only to be
13 -- used by the return_legislation_code function.
14 --
15 g_legislation_code varchar2(150) default null;
16 g_group_per_in_ler_id number default null;
17 --
18 /* Commenting the following procedures thinking that they are not required.
19 If these are required, this could should be un-commented and modified
20 to fetch the right values.
21 --
22 -- ---------------------------------------------------------------------------
23 -- |----------------------< set_security_group_id >--------------------------|
24 -- ---------------------------------------------------------------------------
25 --
26 Procedure set_security_group_id
27 (p_group_per_in_ler_id in number
28 ,p_associated_column1 in varchar2 default null
29 ) is
30 --
31 -- Declare cursor
32 --
33 cursor csr_sec_grp is
34 select pbg.security_group_id,
35 pbg.legislation_code
36 from per_business_groups_perf pbg
37 , ben_cwb_person_info cpi
38 where cpi.group_per_in_ler_id = p_group_per_in_ler_id
39 and pbg.business_group_id (+) = cpi.business_group_id;
40 --
41 -- Declare local variables
42 --
43 l_security_group_id number;
44 l_proc varchar2(72) := g_package||'set_security_group_id';
45 l_legislation_code varchar2(150);
46 --
47 begin
48 --
49 if g_debug then
50 hr_utility.set_location('Entering:'|| l_proc, 10);
51 end if;
52 --
53 -- Ensure that all the mandatory parameter are not null
54 --
55 hr_api.mandatory_arg_error
56 (p_api_name => l_proc
57 ,p_argument => 'group_per_in_ler_id'
58 ,p_argument_value => p_group_per_in_ler_id
59 );
60 --
61 open csr_sec_grp;
62 fetch csr_sec_grp into l_security_group_id
63 , l_legislation_code;
64 --
65 if csr_sec_grp%notfound then
66 --
67 close csr_sec_grp;
68 --
69 -- The primary key is invalid therefore we must error
70 --
71 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
72 hr_multi_message.add
73 (p_associated_column1
74 => nvl(p_associated_column1,'GROUP_PER_IN_LER_ID')
75 );
76 --
77 else
78 close csr_sec_grp;
79 --
80 -- Set the security_group_id in CLIENT_INFO
81 --
82 hr_api.set_security_group_id
83 (p_security_group_id => l_security_group_id
84 );
85 --
86 -- Set the sessions legislation context in HR_SESSION_DATA
87 --
88 hr_api.set_legislation_context(l_legislation_code);
89 end if;
90 --
91 if g_debug then
92 hr_utility.set_location(' Leaving:'|| l_proc, 20);
93 end if;
94 --
95 end set_security_group_id;
96 --
97 -- ---------------------------------------------------------------------------
98 -- |---------------------< return_legislation_code >-------------------------|
99 -- ---------------------------------------------------------------------------
100 --
101 Function return_legislation_code
102 (p_group_per_in_ler_id in number
103 )
104 Return Varchar2 Is
105 --
106 -- Declare cursor
107 --
108 cursor csr_leg_code is
109 select pbg.legislation_code
110 from per_business_groups_perf pbg
111 , ben_cwb_person_info cpi
112 where cpi.group_per_in_ler_id = p_group_per_in_ler_id
113 and pbg.business_group_id (+) = cpi.business_group_id;
114 --
115 -- Declare local variables
116 --
117 l_legislation_code varchar2(150);
118 l_proc varchar2(72) := g_package||'return_legislation_code';
119 --
120 Begin
121 --
122 if g_debug then
123 hr_utility.set_location('Entering:'|| l_proc, 10);
124 end if;
125 --
126 -- Ensure that all the mandatory parameter are not null
127 --
128 hr_api.mandatory_arg_error
129 (p_api_name => l_proc
130 ,p_argument => 'group_per_in_ler_id'
131 ,p_argument_value => p_group_per_in_ler_id
132 );
133 --
134 if ( nvl(ben_cpi_bus.g_group_per_in_ler_id, hr_api.g_number)
135 = p_group_per_in_ler_id) then
136 --
137 -- The legislation code has already been found with a previous
138 -- call to this function. Just return the value in the global
139 -- variable.
140 --
141 l_legislation_code := ben_cpi_bus.g_legislation_code;
142 if g_debug then
143 hr_utility.set_location(l_proc, 20);
144 end if;
145 else
146 --
147 -- The ID is different to the last call to this function
148 -- or this is the first call to this function.
149 --
150 open csr_leg_code;
151 fetch csr_leg_code into l_legislation_code;
152 --
153 if csr_leg_code%notfound then
154 --
155 -- The primary key is invalid therefore we must error
156 --
157 close csr_leg_code;
158 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
159 fnd_message.raise_error;
160 end if;
161 if g_debug then
162 hr_utility.set_location(l_proc,30);
163 end if;
164 --
165 -- Set the global variables so the values are
166 -- available for the next call to this function.
167 --
168 close csr_leg_code;
169 ben_cpi_bus.g_group_per_in_ler_id := p_group_per_in_ler_id;
170 ben_cpi_bus.g_legislation_code := l_legislation_code;
171 end if;
172 if g_debug then
173 hr_utility.set_location(' Leaving:'|| l_proc, 40);
174 end if;
175 return l_legislation_code;
176 end return_legislation_code;
177 */
178 --
179 -- ----------------------------------------------------------------------------
180 -- |-----------------------< chk_non_updateable_args >------------------------|
181 -- ----------------------------------------------------------------------------
182 -- {Start Of Comments}
183 --
184 -- Description:
185 -- This procedure is used to ensure that non updateable attributes have
186 -- not been updated. If an attribute has been updated an error is generated.
187 --
188 -- Pre Conditions:
189 -- g_old_rec has been populated with details of the values currently in
190 -- the database.
191 --
192 -- In Arguments:
193 -- p_rec has been populated with the updated values the user would like the
194 -- record set to.
195 --
196 -- Post Success:
197 -- Processing continues if all the non updateable attributes have not
198 -- changed.
199 --
200 -- Post Failure:
201 -- An application error is raised if any of the non updatable attributes
202 -- have been altered.
203 --
204 -- {End Of Comments}
205 -- ----------------------------------------------------------------------------
206 Procedure chk_non_updateable_args
207 (p_rec in ben_cpi_shd.g_rec_type
208 ) IS
209 --
210 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
211 --
212 Begin
213 --
214 -- Only proceed with the validation if a row exists for the current
215 -- record in the HR Schema.
216 --
217 IF NOT ben_cpi_shd.api_updating
218 (p_group_per_in_ler_id => p_rec.group_per_in_ler_id
219 ,p_object_version_number => p_rec.object_version_number
220 ) THEN
221 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
222 fnd_message.set_token('PROCEDURE ', l_proc);
223 fnd_message.set_token('STEP ', '5');
224 fnd_message.raise_error;
225 END IF;
226 --
227 if nvl(p_rec.group_per_in_ler_id, hr_api.g_number) <>
228 ben_cpi_shd.g_old_rec.group_per_in_ler_id then
229 hr_api.argument_changed_error
230 (p_api_name => l_proc
231 ,p_argument => 'GROUP_PER_IN_LER_ID'
232 ,p_base_table => ben_cpi_shd.g_tab_nam
233 );
234 end if;
235 --
236 End chk_non_updateable_args;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |----------------------< chk_startup_action >------------------------------|
240 -- ----------------------------------------------------------------------------
241 --
242 -- Description:
243 -- This procedure will check that the current action is allowed according
244 -- to the current startup mode.
245 --
246 -- ----------------------------------------------------------------------------
247 PROCEDURE chk_startup_action
248 (p_insert IN boolean
249 ,p_business_group_id IN number
250 ,p_legislation_code IN varchar2
251 ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
252 --
253 BEGIN
254 --
255 -- Call the supporting procedure to check startup mode
256 --
257 IF (p_insert) THEN
258 hr_startup_data_api_support.chk_startup_action
259 (p_generic_allowed => TRUE
260 ,p_startup_allowed => TRUE
261 ,p_user_allowed => TRUE
262 ,p_business_group_id => p_business_group_id
263 ,p_legislation_code => p_legislation_code
264 ,p_legislation_subgroup => p_legislation_subgroup
265 );
266 ELSE
267 hr_startup_data_api_support.chk_upd_del_startup_action
268 (p_generic_allowed => TRUE
269 ,p_startup_allowed => TRUE
270 ,p_user_allowed => TRUE
271 ,p_business_group_id => p_business_group_id
272 ,p_legislation_code => p_legislation_code
273 ,p_legislation_subgroup => p_legislation_subgroup
274 );
275 END IF;
276 --
277 END chk_startup_action;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------< insert_validate >----------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure insert_validate
283 (p_rec in ben_cpi_shd.g_rec_type
284 ) is
285 --
286 l_proc varchar2(72) := g_package||'insert_validate';
287 --
288 Begin
289 if g_debug then
290 hr_utility.set_location('Entering:'||l_proc, 5);
291 end if;
292 --
293 -- Call all supporting business operations
294 --
295 --
296 /* Think we dont need this. So commenting.
297
298 chk_startup_action(true
299 ,p_rec.business_group_id
300 ,p_rec.legislation_code
301 );
302 IF hr_startup_data_api_support.g_startup_mode
303 NOT IN ('GENERIC','STARTUP') THEN
304 --
305 -- Validate Important Attributes
306 --
307 hr_api.validate_bus_grp_id
308 (p_business_group_id => p_rec.business_group_id
309 ,p_associated_column1 => ben_cpi_shd.g_tab_nam
310 || '.BUSINESS_GROUP_ID');
311 --
312 -- after validating the set of important attributes,
313 -- if Multiple Message Detection is enabled and at least
314 -- one error has been found then abort further validation.
315 --
316 hr_multi_message.end_validation_set;
317 END IF;
318 End of commnted code */
319 --
320 --
321 if g_debug then
322 hr_utility.set_location(' Leaving:'||l_proc, 10);
323 end if;
324 End insert_validate;
325 --
326 -- ----------------------------------------------------------------------------
327 -- |---------------------------< update_validate >----------------------------|
328 -- ----------------------------------------------------------------------------
329 Procedure update_validate
330 (p_rec in ben_cpi_shd.g_rec_type
331 ) is
332 --
333 l_proc varchar2(72) := g_package||'update_validate';
334 --
335 Begin
336 if g_debug then
337 hr_utility.set_location('Entering:'||l_proc, 5);
338 end if;
339 --
340 -- Call all supporting business operations
341 --
342 --
343 /* Think this validation is not required, so commenting....
344 chk_startup_action(false
345 ,p_rec.business_group_id
346 ,p_rec.legislation_code
347 );
348 IF hr_startup_data_api_support.g_startup_mode
349 NOT IN ('GENERIC','STARTUP') THEN
350 --
351 -- Validate Important Attributes
352 --
353 hr_api.validate_bus_grp_id
354 (p_business_group_id => p_rec.business_group_id
355 ,p_associated_column1 => ben_cpi_shd.g_tab_nam
356 || '.BUSINESS_GROUP_ID');
357 --
358 -- After validating the set of important attributes,
359 -- if Multiple Message Detection is enabled and at least
360 -- one error has been found then abort further validation.
361 --
362 hr_multi_message.end_validation_set;
363 END IF;
364 ... End of commented code */
365 --
366 --
367 -- Validate Dependent Attributes
368 --
369 chk_non_updateable_args
370 (p_rec => p_rec
371 );
372 --
373 if g_debug then
374 hr_utility.set_location(' Leaving:'||l_proc, 10);
375 end if;
376 End update_validate;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------< delete_validate >----------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure delete_validate
382 (p_rec in ben_cpi_shd.g_rec_type
383 ) is
384 --
385 l_proc varchar2(72) := g_package||'delete_validate';
386 --
387 Begin
388 if g_debug then
389 hr_utility.set_location('Entering:'||l_proc, 5);
390 end if;
391 --
392 --
393
394 /* Think this validation is not require, so commenting.....
395 chk_startup_action(false
396 ,ben_cpi_shd.g_old_rec.business_group_id
397 ,ben_cpi_shd.g_old_rec.legislation_code
398 );
399 IF hr_startup_data_api_support.g_startup_mode
400 NOT IN ('GENERIC','STARTUP') THEN
401 --
402 -- Validate Important Attributes
403 --
404 --
405 -- After validating the set of important attributes,
406 -- if Multiple Message Detection is enabled and at least
407 -- one error has been found then abort further validation.
408 --
409 hr_multi_message.end_validation_set;
410 END IF;
411 .... End of commented code */
412 --
413 -- Call all supporting business operations
414 --
415 if g_debug then
416 hr_utility.set_location(' Leaving:'||l_proc, 10);
417 end if;
418 End delete_validate;
419 --
420 end ben_cpi_bus;