1 Package Body ben_bcm_bus as
2 /* $Header: bebcmrhi.pkb 115.2 2003/03/10 14:31:07 ssrayapu noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bcm_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_cwb_matrix_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_cwb_matrix_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_cwb_matrix bcm
32 where bcm.cwb_matrix_id = p_cwb_matrix_id
33 and pbg.business_group_id = bcm.business_group_id;
34 --
35 -- Declare local variables
36 --
37 l_security_group_id number;
38 l_proc varchar2(72) := g_package||'set_security_group_id';
39 l_legislation_code varchar2(150);
40 --
41 begin
42 --
43 hr_utility.set_location('Entering:'|| l_proc, 10);
44 --
45 -- Ensure that all the mandatory parameter are not null
46 --
47 hr_api.mandatory_arg_error
48 (p_api_name => l_proc
49 ,p_argument => 'cwb_matrix_id'
50 ,p_argument_value => p_cwb_matrix_id
51 );
52 --
53 open csr_sec_grp;
54 fetch csr_sec_grp into l_security_group_id
55 , l_legislation_code;
56 --
57 if csr_sec_grp%notfound then
58 --
59 close csr_sec_grp;
60 --
61 -- The primary key is invalid therefore we must error
62 --
63 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64 hr_multi_message.add
65 (p_associated_column1
66 => nvl(p_associated_column1,'CWB_MATRIX_ID')
67 );
68 --
69 else
70 close csr_sec_grp;
71 --
72 -- Set the security_group_id in CLIENT_INFO
73 --
74 hr_api.set_security_group_id
75 (p_security_group_id => l_security_group_id
76 );
77 --
78 -- Set the sessions legislation context in HR_SESSION_DATA
79 --
80 hr_api.set_legislation_context(l_legislation_code);
81 end if;
82 --
83 hr_utility.set_location(' Leaving:'|| l_proc, 20);
84 --
85 end set_security_group_id;
86 --
87 -- ---------------------------------------------------------------------------
88 -- |---------------------< return_legislation_code >-------------------------|
89 -- ---------------------------------------------------------------------------
90 --
91 Function return_legislation_code
92 (p_cwb_matrix_id in number
93 )
94 Return Varchar2 Is
95 --
96 -- Declare cursor
97 --
98 cursor csr_leg_code is
99 select pbg.legislation_code
100 from per_business_groups_perf pbg
101 , ben_cwb_matrix bcm
102 where bcm.cwb_matrix_id = p_cwb_matrix_id
103 and pbg.business_group_id = bcm.business_group_id;
104 --
105 -- Declare local variables
106 --
107 l_legislation_code varchar2(150);
108 l_proc varchar2(72) := g_package||'return_legislation_code';
109 --
110 Begin
111 --
112 hr_utility.set_location('Entering:'|| l_proc, 10);
113 --
114 -- Ensure that all the mandatory parameter are not null
115 --
116 hr_api.mandatory_arg_error
117 (p_api_name => l_proc
118 ,p_argument => 'cwb_matrix_id'
119 ,p_argument_value => p_cwb_matrix_id
120 );
121 --
122 if ( nvl(ben_bcm_bus.g_cwb_matrix_id, hr_api.g_number)
123 = p_cwb_matrix_id) then
124 --
125 -- The legislation code has already been found with a previous
126 -- call to this function. Just return the value in the global
127 -- variable.
128 --
129 l_legislation_code := ben_bcm_bus.g_legislation_code;
130 hr_utility.set_location(l_proc, 20);
131 else
132 --
133 -- The ID is different to the last call to this function
134 -- or this is the first call to this function.
135 --
136 open csr_leg_code;
137 fetch csr_leg_code into l_legislation_code;
138 --
139 if csr_leg_code%notfound then
140 --
141 -- The primary key is invalid therefore we must error
142 --
143 close csr_leg_code;
144 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
145 fnd_message.raise_error;
146 end if;
147 hr_utility.set_location(l_proc,30);
148 --
149 -- Set the global variables so the values are
150 -- available for the next call to this function.
151 --
152 close csr_leg_code;
153 ben_bcm_bus.g_cwb_matrix_id := p_cwb_matrix_id;
154 ben_bcm_bus.g_legislation_code := l_legislation_code;
155 end if;
156 hr_utility.set_location(' Leaving:'|| l_proc, 40);
157 return l_legislation_code;
158 end return_legislation_code;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------< chk_non_updateable_args >------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This procedure is used to ensure that non updateable attributes have
167 -- not been updated. If an attribute has been updated an error is generated.
168 --
169 -- Pre Conditions:
170 -- g_old_rec has been populated with details of the values currently in
171 -- the database.
172 --
173 -- In Arguments:
174 -- p_rec has been populated with the updated values the user would like the
175 -- record set to.
176 --
177 -- Post Success:
178 -- Processing continues if all the non updateable attributes have not
179 -- changed.
180 --
181 -- Post Failure:
182 -- An application error is raised if any of the non updatable attributes
183 -- have been altered.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure chk_non_updateable_args
188 (p_effective_date in date
189 ,p_rec in ben_bcm_shd.g_rec_type
190 ) IS
191 --
192 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
193 --
194 Begin
195 --
196 -- Only proceed with the validation if a row exists for the current
197 -- record in the HR Schema.
198 --
199 IF NOT ben_bcm_shd.api_updating
200 (p_cwb_matrix_id => p_rec.cwb_matrix_id
201 ,p_object_version_number => p_rec.object_version_number
202 ) THEN
203 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
204 fnd_message.set_token('PROCEDURE ', l_proc);
205 fnd_message.set_token('STEP ', '5');
206 fnd_message.raise_error;
207 END IF;
208 --
209 -- EDIT_HERE: Add checks to ensure non-updateable args have
210 -- not been updated.
211 --
212 End chk_non_updateable_args;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |----------------------------< chk_all_lookups >---------------------------|
216 -- ----------------------------------------------------------------------------
217 --
218 -- Description
219 -- This procedure is used to check that the lookup values are valid.
220 --
221 -- Pre Conditions
222 -- None.
223 --
224 -- In Parameters
225 -- cwb_matrix_id PK of record being inserted or updated.
226 -- row_crit_cd Value of lookup code.
227 -- col_crit_cd Value of lookup code.
228 -- alct_by_cd Value of lookup code.
229 -- effective_date effective date
230 -- object_version_number Object version number of record being
231 -- inserted or updated.
232 --
233 -- Post Success
234 -- Processing continues
235 --
236 -- Post Failure
237 -- Error handled by procedure
238 --
239 -- Access Status
240 -- Internal table handler use only.
241 --
242 Procedure chk_all_lookups(p_cwb_matrix_id in number,
243 p_row_crit_cd in varchar2,
244 p_col_crit_cd in varchar2,
245 p_alct_by_cd in varchar2,
246 p_effective_date in date,
247 p_object_version_number in number) is
248 --
249 l_proc varchar2(72) := g_package||'chk_all_lookups';
250 l_api_updating boolean;
251 --
252 Begin
253 --
254 hr_utility.set_location('Entering:'||l_proc, 5);
255 --
256 l_api_updating := ben_bcm_shd.api_updating
257 (p_cwb_matrix_id => p_cwb_matrix_id,
258 p_object_version_number => p_object_version_number);
259 --
260 if (l_api_updating
261 and p_row_crit_cd
262 <> nvl(ben_bcm_shd.g_old_rec.row_crit_cd, hr_api.g_varchar2)
263 or not l_api_updating) then
264 --
265 -- check if value of lookup falls within lookup type.
266 --
267 if hr_api.not_exists_in_hr_lookups
268 (p_lookup_type => 'BEN_CWB_MATRIX_ROW_CRITERIA',
269 p_lookup_code => p_row_crit_cd,
270 p_effective_date => p_effective_date) then
271 --
272 -- raise error as does not exist as lookup
273 --
274 fnd_message.set_name('BEN', 'BEN_91628_LOOKUP_TYPE_GENERIC');
275 fnd_message.set_token('FIELD', p_row_crit_cd);
276 fnd_message.set_token('TYPE', 'BEN_CWB_MATRIX_ROW_CRITERIA');
277 fnd_message.raise_error;
278 --
279 end if;
280 --
281 end if;
282 --
283 if (l_api_updating
284 and p_col_crit_cd
285 <> nvl(ben_bcm_shd.g_old_rec.col_crit_cd, hr_api.g_varchar2)
286 or not l_api_updating)
287 and p_col_crit_cd is not null then
288 --
289 -- check if value of lookup falls within lookup type.
290 --
291 if hr_api.not_exists_in_hr_lookups
292 (p_lookup_type => 'BEN_CWB_MATRIX_COLUMN_CRITERIA',
293 p_lookup_code => p_col_crit_cd,
294 p_effective_date => p_effective_date) then
295 --
296 -- raise error as does not exist as lookup
297 --
298 fnd_message.set_name('BEN', 'BEN_91628_LOOKUP_TYPE_GENERIC');
299 fnd_message.set_token('FIELD', p_col_crit_cd);
300 fnd_message.set_token('TYPE', 'BEN_CWB_MATRIX_COLUMN_CRITERIA');
301 fnd_message.raise_error;
302 --
303 end if;
304 --
305 end if;
306 --
307 if (l_api_updating
308 and p_alct_by_cd
309 <> nvl(ben_bcm_shd.g_old_rec.alct_by_cd, hr_api.g_varchar2)
310 or not l_api_updating) then
311 --
312 -- check if value of lookup falls within lookup type.
313 --
314 if hr_api.not_exists_in_hr_lookups
315 (p_lookup_type => 'BEN_ALLCT_BY',
316 p_lookup_code => p_alct_by_cd,
317 p_effective_date => p_effective_date) then
318 --
319 -- raise error as does not exist as lookup
320 --
321 fnd_message.set_name('BEN', 'BEN_91628_LOOKUP_TYPE_GENERIC');
322 fnd_message.set_token('FIELD', p_alct_by_cd);
323 fnd_message.set_token('TYPE', 'BEN_ALLCT_BY');
324 fnd_message.raise_error;
325 --
326 end if;
327 --
328 end if;
329 --
330 hr_utility.set_location('Leaving:'||l_proc,10);
331 --
332 end chk_all_lookups;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------< insert_validate >----------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure insert_validate
338 (p_effective_date in date
339 ,p_rec in ben_bcm_shd.g_rec_type
340 ) is
341 --
342 l_proc varchar2(72) := g_package||'insert_validate';
343 --
344 Begin
345 hr_utility.set_location('Entering:'||l_proc, 5);
346 --
347 -- Call all supporting business operations
348 --
349 hr_api.validate_bus_grp_id
350 (p_business_group_id => p_rec.business_group_id
351 ,p_associated_column1 => ben_bcm_shd.g_tab_nam
352 || '.BUSINESS_GROUP_ID');
353 --
354 -- After validating the set of important attributes,
355 -- if Multiple Message detection is enabled and at least
356 -- one error has been found then abort further validation.
357 --
358 hr_multi_message.end_validation_set;
359 --
360 -- Validate Dependent Attributes
361 --
362 chk_all_lookups
363 (p_cwb_matrix_id => p_rec.cwb_matrix_id,
364 p_row_crit_cd => p_rec.row_crit_cd,
365 p_col_crit_cd => p_rec.col_crit_cd,
366 p_alct_by_cd => p_rec.alct_by_cd,
367 p_effective_date => p_effective_date,
368 p_object_version_number => p_rec.object_version_number);
369 --
370 hr_utility.set_location(' Leaving:'||l_proc, 10);
371 End insert_validate;
372 --
373 -- ----------------------------------------------------------------------------
374 -- |---------------------------< update_validate >----------------------------|
375 -- ----------------------------------------------------------------------------
376 Procedure update_validate
377 (p_effective_date in date
378 ,p_rec in ben_bcm_shd.g_rec_type
379 ) is
380 --
381 l_proc varchar2(72) := g_package||'update_validate';
382 --
383 Begin
384 hr_utility.set_location('Entering:'||l_proc, 5);
385 --
386 -- Call all supporting business operations
387 --
388 hr_api.validate_bus_grp_id
389 (p_business_group_id => p_rec.business_group_id
390 ,p_associated_column1 => ben_bcm_shd.g_tab_nam
391 || '.BUSINESS_GROUP_ID');
392 --
393 -- After validating the set of important attributes,
394 -- if Multiple Message detection is enabled and at least
395 -- one error has been found then abort further validation.
396 --
397 hr_multi_message.end_validation_set;
398 --
399 -- Validate Dependent Attributes
400 --
401 chk_all_lookups
402 (p_cwb_matrix_id => p_rec.cwb_matrix_id,
403 p_row_crit_cd => p_rec.row_crit_cd,
404 p_col_crit_cd => p_rec.col_crit_cd,
405 p_alct_by_cd => p_rec.alct_by_cd,
406 p_effective_date => p_effective_date,
407 p_object_version_number => p_rec.object_version_number);
408 --
409 --
410 chk_non_updateable_args
411 (p_effective_date => p_effective_date
412 ,p_rec => p_rec
413 );
414 --
415 --
416 hr_utility.set_location(' Leaving:'||l_proc, 10);
417 End update_validate;
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------< delete_validate >----------------------------|
421 -- ----------------------------------------------------------------------------
422 Procedure delete_validate
423 (p_rec in ben_bcm_shd.g_rec_type
424 ) is
425 --
426 l_proc varchar2(72) := g_package||'delete_validate';
427 --
428 Begin
429 hr_utility.set_location('Entering:'||l_proc, 5);
430 --
431 -- Call all supporting business operations
432 --
433 hr_utility.set_location(' Leaving:'||l_proc, 10);
434 End delete_validate;
435 --
436 end ben_bcm_bus;