1 Package Body pqh_rss_bus as
2 /* $Header: pqrssrhi.pkb 115.9 2002/12/13 13:57:40 joward noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rss_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_result_set_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_result_set_id in number
22 ,p_associated_column1 in varchar2 default null
23 ) is
24 --
25 -- Declare cursor
26 --
27 -- EDIT_HERE In the following cursor statement add join(s) between
28 -- pqh_de_result_sets and PER_BUSINESS_GROUPS
29 -- so that the security_group_id for
30 -- the current business group context can be derived.
31 -- Remove this comment when the edit has been completed.
32 cursor csr_sec_grp is
33 select pbg.security_group_id
34 from per_business_groups pbg
35 , pqh_de_result_sets rss
36 -- , EDIT_HERE table_name(s) 333
37 where rss.result_set_id = p_result_set_id;
38 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
39 --
40 -- Declare local variables
41 --
42 l_security_group_id number;
43 l_proc varchar2(72) := g_package||'set_security_group_id';
44 --
45 begin
46 --
47 hr_utility.set_location('Entering:'|| l_proc, 10);
48 --
49 -- Ensure that all the mandatory parameter are not null
50 --
51 hr_api.mandatory_arg_error
52 (p_api_name => l_proc
53 ,p_argument => 'result_set_id'
54 ,p_argument_value => p_result_set_id
55 );
56 --
57 open csr_sec_grp;
58 fetch csr_sec_grp into l_security_group_id;
59 --
60 if csr_sec_grp%notfound then
61 --
62 close csr_sec_grp;
63 --
64 -- The primary key is invalid therefore we must error
65 --
66 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
67 hr_multi_message.add
68 (p_associated_column1
69 => nvl(p_associated_column1,'RESULT_SET_ID')
70 );
71 --
72 else
73 close csr_sec_grp;
74 --
75 -- Set the security_group_id in CLIENT_INFO
76 --
77 hr_api.set_security_group_id
78 (p_security_group_id => l_security_group_id
79 );
80 end if;
81 --
82 hr_utility.set_location(' Leaving:'|| l_proc, 20);
83 --
84 end set_security_group_id;
85 --
86 -- ---------------------------------------------------------------------------
87 -- |---------------------< return_legislation_code >-------------------------|
88 -- ---------------------------------------------------------------------------
89 --
90 Function return_legislation_code
91 (p_result_set_id in number
92 )
93 Return Varchar2 Is
94 --
95 -- Declare cursor
96 --
97 -- EDIT_HERE In the following cursor statement add join(s) between
98 -- pqh_de_result_sets and PER_BUSINESS_GROUPS
99 -- so that the legislation_code for
100 -- the current business group context can be derived.
101 -- Remove this comment when the edit has been completed.
102 cursor csr_leg_code is
103 select pbg.legislation_code
104 from per_business_groups pbg
105 , pqh_de_result_sets rss
106 -- , EDIT_HERE table_name(s) 333
107 where rss.result_set_id = p_result_set_id;
108 -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
109 --
110 -- Declare local variables
111 --
112 l_legislation_code varchar2(150);
113 l_proc varchar2(72) := g_package||'return_legislation_code';
114 --
115 Begin
116 --
117 hr_utility.set_location('Entering:'|| l_proc, 10);
118 --
119 -- Ensure that all the mandatory parameter are not null
120 --
121 hr_api.mandatory_arg_error
122 (p_api_name => l_proc
123 ,p_argument => 'result_set_id'
124 ,p_argument_value => p_result_set_id
125 );
126 --
127 if ( nvl(pqh_rss_bus.g_result_set_id, hr_api.g_number)
128 = p_result_set_id) then
129 --
130 -- The legislation code has already been found with a previous
131 -- call to this function. Just return the value in the global
132 -- variable.
133 --
134 l_legislation_code := pqh_rss_bus.g_legislation_code;
135 hr_utility.set_location(l_proc, 20);
136 else
137 --
138 -- The ID is different to the last call to this function
139 -- or this is the first call to this function.
140 --
141 open csr_leg_code;
142 fetch csr_leg_code into l_legislation_code;
143 --
144 if csr_leg_code%notfound then
145 --
146 -- The primary key is invalid therefore we must error
147 --
148 close csr_leg_code;
149 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
150 fnd_message.raise_error;
151 end if;
152 hr_utility.set_location(l_proc,30);
153 --
154 -- Set the global variables so the values are
155 -- available for the next call to this function.
156 --
157 close csr_leg_code;
158 pqh_rss_bus.g_result_set_id := p_result_set_id;
159 pqh_rss_bus.g_legislation_code := l_legislation_code;
160 end if;
161 hr_utility.set_location(' Leaving:'|| l_proc, 40);
162 return l_legislation_code;
163 end return_legislation_code;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-----------------------< chk_non_updateable_args >------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 -- This procedure is used to ensure that non updateable attributes have
172 -- not been updated. If an attribute has been updated an error is generated.
173 --
174 -- Pre Conditions:
175 -- g_old_rec has been populated with details of the values currently in
176 -- the database.
177 --
178 -- In Arguments:
179 -- p_rec has been populated with the updated values the user would like the
180 -- record set to.
181 --
182 -- Post Success:
183 -- Processing continues if all the non updateable attributes have not
184 -- changed.
185 --
186 -- Post Failure:
187 -- An application error is raised if any of the non updatable attributes
188 -- have been altered.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure chk_non_updateable_args
193 (p_effective_date in date
194 ,p_rec in pqh_rss_shd.g_rec_type
195 ) IS
196 --
197 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
198
199 --
200 Begin
201 --
202 -- Only proceed with the validation if a row exists for the current
203 -- record in the HR Schema.
204 --
205 IF NOT pqh_rss_shd.api_updating
206 (p_result_set_id => p_rec.result_set_id
207 ,p_object_version_number => p_rec.object_version_number
208 ) THEN
209 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
210 fnd_message.set_token('PROCEDURE ', l_proc);
211 fnd_message.set_token('STEP ', '5');
212 fnd_message.raise_error;
213 END IF;
214 --
215 -- EDIT_HERE: Add checks to ensure non-updateable args have
216 -- not been updated.
217 --
218 IF nvl(p_rec.Grade_id, hr_api.g_number) <>
219 nvl(pqh_RSS_shd.g_old_rec.Grade_id, hr_api.g_number) THEN
220 hr_utility.set_message(8302, 'PQH_DE_NONUPD_GRADE_ID');
221 fnd_message.raise_error;
222
223 END IF;
224
225 End chk_non_updateable_args;
226
227 -- ----------------------------------------------------------------------------
228 -- |---------------------------< Chk_Grade_id >-------------------------------|
229 -- ----------------------------------------------------------------------------
230 Procedure Chk_Grade_id
231 (p_rec in pqh_rss_shd.g_rec_type) is
232 --
233 Cursor c_Grade_id is
234 Select Grade_id
235 from per_grades
236 Where Grade_id = p_rec.Grade_id;
237 l_Grade_id PQH_DE_RESULT_SETS.Grade_id%TYPE;
238
239 l_proc varchar2(72) := g_package || 'Check_Grade_id';
240 Begin
241 hr_utility.set_location(l_proc, 10);
242 Open c_Grade_id;
243 Fetch c_Grade_id into l_Grade_id;
244 If c_Grade_id%notfound Then
245 hr_utility.set_message(8302, 'PQH_DE_Check_Grade_id');
246 Close c_Grade_id;
247 fnd_message.raise_error;
248 End If;
249 Close c_Grade_id;
250 Exception
251 when app_exception.application_exception then
252 if hr_multi_message.exception_add
253 (p_associated_column1 => 'PQH_DE_RESULT_SETS.Grade_id'
254 ) then
255 hr_utility.set_location(' Leaving:'||l_proc,60);
256 raise;
257 end if;
258 hr_utility.set_location(' Leaving:'||l_proc,70);
259 End Chk_Grade_id;
260 -- ----------------------------------------------------------------------------
261 -- |----------------------< Chk_CIVIL_SERVANTS_Grade_id >---------------------|
262 -- ----------------------------------------------------------------------------
263
264 Procedure Chk_CIVIL_SERVANTS_Grade_id
265 (p_effective_date in date ,
266 p_rec in pqh_rss_shd.g_rec_type) is
267 --
268 Cursor c_CIVIL_SERVANTS_Grade_id is
269 SELECT
270 pg.NAME
271 FROM
272 per_gen_hierarchy pgh,
273 per_gen_hierarchy_versions pghv,
274 per_gen_hierarchy_nodes pghn,
275 PER_GEN_HIERARCHY_NODES pghn1 ,
276 PER_GEN_HIERARCHY_NODES pghn2 ,
277 PER_GEN_HIERARCHY_NODES pghn3 ,
278 PER_GEN_HIERARCHY_NODES pghn4 ,
279 PER_GEN_HIERARCHY_NODES pghn5 ,
280 PER_GEN_HIERARCHY_NODES pghn6 ,
281 PER_GRADES_VL pg
282 WHERE pgh.TYPE='REMUNERATION_REGULATION'
283 and pgh.HIERARCHY_ID=pghv.HIERARCHY_ID
284 and p_Effective_Date between pghv.Date_from and Nvl(pghv.Date_To,Trunc(Sysdate))
285 and pghv.HIERARCHY_VERSION_ID=pghn.HIERARCHY_VERSION_ID
286 and pghn.NODE_TYPE='PAY_GRADE'
287 and pghn.PARENT_HIERARCHY_NODE_ID = pghn1.HIERARCHY_NODE_ID
288 and pghn1.NODE_TYPE='TATIGKEIT'
289 and pghn1.PARENT_HIERARCHY_NODE_ID = pghn2.HIERARCHY_NODE_ID
290 and pghn2.PARENT_HIERARCHY_NODE_ID = pghn3.HIERARCHY_NODE_ID
291 and pghn3.PARENT_HIERARCHY_NODE_ID = pghn4.HIERARCHY_NODE_ID
292 and pghn4.PARENT_HIERARCHY_NODE_ID = pghn5.HIERARCHY_NODE_ID
293 and pghn5.PARENT_HIERARCHY_NODE_ID = pghn6.HIERARCHY_NODE_ID
294 and pghn6.ENTITY_ID = 'BE'
295 and pg.GRADE_ID = pghn.ENTITY_ID
296 union all
297 select pg.NAME
298 from
299 per_gen_hierarchy pgh,
300 per_gen_hierarchy_versions pghv,
301 per_gen_hierarchy_nodes pghn,
302 PER_GEN_HIERARCHY_NODES pghn1 ,
303 PER_GEN_HIERARCHY_NODES pghn2 ,
304 PER_GEN_HIERARCHY_NODES pghn3 ,
305 PER_GEN_HIERARCHY_NODES pghn4 ,
306 PER_GEN_HIERARCHY_NODES pghn5 ,
307 PER_GEN_HIERARCHY_NODES pghn6 ,
308 PER_GEN_HIERARCHY_NODES pghn7 ,
309 PER_GRADES_VL pg
310 where pgh.TYPE='REMUNERATION_REGULATION'
311 and pgh.HIERARCHY_ID=pghv.HIERARCHY_ID
312 and p_Effective_Date between pghv.Date_from and Nvl(pghv.Date_To,Trunc(Sysdate))
313 and pghv.HIERARCHY_VERSION_ID=pghn.HIERARCHY_VERSION_ID
314 and pghn.NODE_TYPE='PAY_GRADE'
315 and pghn.PARENT_HIERARCHY_NODE_ID = pghn1.HIERARCHY_NODE_ID
316 and pghn1.NODE_TYPE='TYPE_OF_SERVICE'
317 and pghn1.PARENT_HIERARCHY_NODE_ID = pghn2.HIERARCHY_NODE_ID
318 and pghn2.PARENT_HIERARCHY_NODE_ID = pghn3.HIERARCHY_NODE_ID
319 and pghn3.PARENT_HIERARCHY_NODE_ID = pghn4.HIERARCHY_NODE_ID
320 and pghn4.PARENT_HIERARCHY_NODE_ID = pghn5.HIERARCHY_NODE_ID
321 and pghn5.PARENT_HIERARCHY_NODE_ID = pghn6.HIERARCHY_NODE_ID
322 and pghn6.PARENT_HIERARCHY_NODE_ID = pghn7.HIERARCHY_NODE_ID
323 and pghn7.ENTITY_ID = 'BE';
324
325 l_CIVIL_SERVANTS_Grade_id per_grades.name%TYPE;
326 l_proc varchar2(72) := g_package || 'Check_CIVIL_Grade_id';
327
328 Begin
329 hr_utility.set_location(l_proc, 10);
330 Open c_CIVIL_SERVANTS_Grade_id;
331 Fetch c_CIVIL_SERVANTS_Grade_id into l_CIVIL_SERVANTS_Grade_id;
332 If c_CIVIL_SERVANTS_Grade_id%notfound Then
333 hr_utility.set_message(8302, 'PQH_DE_CIVIL_SERVANTS_Grade_id');
334 Close c_CIVIL_SERVANTS_Grade_id;
335 fnd_message.raise_error;
336 End If;
337 Close c_CIVIL_SERVANTS_Grade_id;
338 Exception
339 when app_exception.application_exception then
340 if hr_multi_message.exception_add
341 (p_associated_column1 => 'PQH_DE_RESULT_SETS.Grade_id'
342 ) then
343 hr_utility.set_location(' Leaving:'||l_proc,60);
344 raise;
345 end if;
346 hr_utility.set_location(' Leaving:'||l_proc,70);
347 End Chk_CIVIL_SERVANTS_Grade_id;
348
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------< Chk_gradual_value_numbers >------------------|
351 -- ----------------------------------------------------------------------------
352 Procedure Chk_gradual_value_numbers
353 (p_rec in pqh_rss_shd.g_rec_type) is
354 --
355 Cursor c_gradual_value_numbers is
356 Select '1'
357 from pqh_de_result_sets
358 Where (GRADUAL_VALUE_NUMBER_FROM = p_rec.GRADUAL_VALUE_NUMBER_FROM
359 or GRADUAL_VALUE_NUMBER_FROM = p_rec.GRADUAL_VALUE_NUMBER_to
360 or GRADUAL_VALUE_NUMBER_to = p_rec.GRADUAL_VALUE_NUMBER_FROM
361 or GRADUAL_VALUE_NUMBER_to = p_rec.GRADUAL_VALUE_NUMBER_to
362 or GRADUAL_VALUE_NUMBER_FROM between p_rec.GRADUAL_VALUE_NUMBER_FROM and p_rec.GRADUAL_VALUE_NUMBER_to
363 or GRADUAL_VALUE_NUMBER_to between p_rec.GRADUAL_VALUE_NUMBER_FROM and p_rec.GRADUAL_VALUE_NUMBER_to)
364 and result_set_id <> p_rec.result_set_id;
365
366 l_gradual_value_numbers PQH_DE_RESULT_SETS.GRADUAL_VALUE_NUMBER_FROM%TYPE;
367
368 l_proc varchar2(72) := g_package || 'Chk_gradual_value_numbers';
369
370 Begin
371 hr_utility.set_location(l_proc, 10);
372
373 if to_number(p_rec.GRADUAL_VALUE_NUMBER_FROM) < 0 or to_number(p_rec.GRADUAL_VALUE_NUMBER_TO) < 0 then
374 hr_utility.set_message(8302, 'PQH_DE_GRADUAL_NUM_NEG');
375 fnd_message.raise_error;
376 End If;
377
378 if to_number(p_rec.GRADUAL_VALUE_NUMBER_FROM) > to_number(p_rec.GRADUAL_VALUE_NUMBER_TO) then
379 hr_utility.set_message(8302, 'PQH_DE_Gradual_value');
380 fnd_message.raise_error;
381 End If;
382
383
384
385 Open c_gradual_value_numbers;
386 Fetch c_gradual_value_numbers into l_gradual_value_numbers;
387 If c_gradual_value_numbers%found Then
388 hr_utility.set_message(8302, 'PQH_DE_GRADUAL_EXIST');
389 Close c_gradual_value_numbers;
390 fnd_message.raise_error;
391 End If;
392 Close c_gradual_value_numbers;
393 Exception
394
395 when app_exception.application_exception then
396 if hr_multi_message.exception_add
397 (p_associated_column1 => 'PQH_DE_RESULT_SETS.GRADUAL_VALUE_NUMBER_FROM'
398 ) then
399 hr_utility.set_location(' Leaving:'||l_proc,60);
400 raise;
401 end if;
402 hr_utility.set_location(' Leaving:'||l_proc,70);
403 End Chk_gradual_value_numbers;
404 --
405 -- ----------------------------------------------------------------------------
406 -- |---------------------------< insert_validate >----------------------------|
407 -- ----------------------------------------------------------------------------
408 Procedure insert_validate
409 (p_effective_date in date
410 ,p_rec in pqh_rss_shd.g_rec_type
411 ) is
412 --
413 l_proc varchar2(72) := g_package||'insert_validate';
414 --
415 Begin
416 hr_utility.set_location('Entering:'||l_proc, 5);
417 --
418 -- Call all supporting business operations
419 --
420 --
421 -- EDIT_HERE: As this table does not have a mandatory business_group_id
422 -- column, ensure client_info is populated by calling a suitable
423 -- ???_???_bus.set_security_group_id procedure, or add one of the following
424 -- comments:
425 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
426 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
427 --
428 -- Validate Dependent Attributes
429 --
430 Chk_gradual_value_numbers(P_Rec);
431 -- Chk_Grade_id(P_Rec);
432 --
433 -- Chk_CIVIL_SERVANTS_Grade_id(p_effective_date,P_Rec);
434 --
435 hr_utility.set_location(' Leaving:'||l_proc, 10);
436
437 End insert_validate;
438 --
439 -- ----------------------------------------------------------------------------
440 -- |---------------------------< update_validate >----------------------------|
441 -- ----------------------------------------------------------------------------
442 Procedure update_validate
443 (p_effective_date in date
444 ,p_rec in pqh_rss_shd.g_rec_type
445 ) is
446 --
447 l_proc varchar2(72) := g_package||'update_validate';
448 --
449 Begin
450 hr_utility.set_location('Entering:'||l_proc, 5);
451 --
452 -- Call all supporting business operations
453 --
454 --
455 -- EDIT_HERE: As this table does not have a mandatory business_group_id
456 -- column, ensure client_info is populated by calling a suitable
457 -- ???_???_bus.set_security_group_id procedure, or add one of the following
458 -- comments:
459 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
460 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
461 --
462 -- Validate Dependent Attributes
463 --
464 Chk_gradual_value_numbers(P_Rec);
465
466 chk_non_updateable_args
467 (p_effective_date => p_effective_date
468 ,p_rec => p_rec
469 );
470 --
471 --
472 hr_utility.set_location(' Leaving:'||l_proc, 10);
473 End update_validate;
474 --
475 -- ----------------------------------------------------------------------------
476 -- |---------------------------< delete_validate >----------------------------|
477 -- ----------------------------------------------------------------------------
478 Procedure delete_validate
479 (p_rec in pqh_rss_shd.g_rec_type
480 ) is
481 --
482 l_proc varchar2(72) := g_package||'delete_validate';
483 --
484 Begin
485 hr_utility.set_location('Entering:'||l_proc, 5);
486 --
487 -- Call all supporting business operations
488 --
489 hr_utility.set_location(' Leaving:'||l_proc, 10);
490 End delete_validate;
491 --
492 end pqh_rss_bus;