1 Package Body pqh_lcd_bus as
2 /* $Header: pqlcdrhi.pkb 115.4 2002/12/03 00:07:48 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_lcd_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_level_code_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_level_code_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_level_codes 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_level_codes lcd
36 -- , EDIT_HERE table_name(s) 333
37 where lcd.level_code_id = p_level_code_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 => 'level_code_id'
54 ,p_argument_value => p_level_code_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,'LEVEL_CODE_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_level_code_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_level_codes 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_level_codes lcd
106 -- , EDIT_HERE table_name(s) 333
107 where lcd.level_code_id = p_level_code_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 => 'level_code_id'
124 ,p_argument_value => p_level_code_id
125 );
126 --
127 if ( nvl(pqh_lcd_bus.g_level_code_id, hr_api.g_number)
128 = p_level_code_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_lcd_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_lcd_bus.g_level_code_id := p_level_code_id;
159 pqh_lcd_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_rec in pqh_lcd_shd.g_rec_type
194 ) IS
195 --
196 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
197
198 --
199 Begin
200 --
201 -- Only proceed with the validation if a row exists for the current
202 -- record in the HR Schema.
203 --
204 IF NOT pqh_lcd_shd.api_updating
205 (p_level_code_id => p_rec.level_code_id
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 -- EDIT_HERE: Add checks to ensure non-updateable args have
215 -- not been updated.
216 --
217 IF nvl(p_rec.level_code, hr_api.g_varchar2) <>
218 nvl(pqh_lcd_shd.g_old_rec.level_code, hr_api.g_varchar2) THEN
219 hr_utility.set_message(8302, 'PQH_DE_NONUPD_LEVEL_CODE');
220 fnd_message.raise_error;
221 END IF;
222
223
224
225 End chk_non_updateable_args;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |-----------------------< Chk_delete >-------------------------------------|
229 -- ----------------------------------------------------------------------------
230
231 Procedure Chk_delete
232 (p_rec in pqh_lcd_shd.g_rec_type) is
233 l_proc varchar2(72) := g_package||'Ckh_Delete';
234 Cursor Del is
235 select '1' from PQH_DE_WRKPLC_VLDTN_LVLNUMS
236 where LEVEL_NUMBER_ID = pqh_lcd_shd.g_old_rec.LEVEL_NUMBER_ID
237 and LEVEL_CODE_ID = pqh_lcd_shd.g_old_rec.LEVEL_CODE_ID;
238 l_Status Varchar2(1);
239 Begin
240 Open Del;
241 Fetch Del into l_Status;
242 If Del%Found Then
243 Close Del;
244 hr_utility.set_message(8302, 'PQH_LVLCD_PRE_DEL');
245 hr_utility.raise_error;
246 End If;
247 Close Del;
248 Exception
249 when app_exception.application_exception then
250 if hr_multi_message.exception_add
251 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTN_LVLNUMS.LEVEL_CODE_ID'
252 ) then
253 hr_utility.set_location(' Leaving:'||l_proc,60);
254 raise;
255 end if;
256 hr_utility.set_location(' Leaving:'||l_proc,70);
257 End Chk_Delete;
258 -- ----------------------------------------------------------------------------
259 -- |-----------------------< Chk_LEVEL_NUMBER_ID >----------------------------|
260 -- ----------------------------------------------------------------------------
261
262 Procedure Chk_LEVEL_NUMBER_ID
263 (p_rec in pqh_lcd_shd.g_rec_type) is
264 l_proc varchar2(72) := g_package||'Ckh_LEVEL_NUMBER_ID';
265 Cursor c_LEVEL_NUMBER_ID is
266 select '1' from PQH_DE_LEVEL_NUMBERS a, PQH_DE_LEVEL_codes b
267 where a.LEVEL_NUMBER_ID = p_rec.LEVEL_NUMBER_ID
268 and a.LEVEL_NUMBER_ID = b.LEVEL_NUMBER_ID
269 and b.LEVEL_CODE = p_rec.level_code;
270
271 l_LEVEL_NUMBER_ID PQH_DE_LEVEL_NUMBERS.LEVEL_NUMBER_ID%TYPE;
272
273 Begin
274 hr_utility.set_location(l_proc, 10);
275 Open c_LEVEL_NUMBER_ID;
276 Fetch c_LEVEL_NUMBER_ID into l_LEVEL_NUMBER_ID;
277 If c_LEVEL_NUMBER_ID%found Then
278 hr_utility.set_message(8302, 'PQH_DE_NOEXIST_LEVEL_NUMBER_ID');
279 Close c_LEVEL_NUMBER_ID;
280 fnd_message.raise_error;
281 End If;
282 Close c_LEVEL_NUMBER_ID;
283 Exception
284 when app_exception.application_exception then
285 if hr_multi_message.exception_add
286 (p_associated_column1 => 'PQH_DE_LEVEL_NUMBERS.LEVEL_NUMBER_ID'
287 ) then
288 hr_utility.set_location(' Leaving:'||l_proc,60);
289 raise;
290 end if;
291 hr_utility.set_location(' Leaving:'||l_proc,70);
292 End Chk_LEVEL_NUMBER_ID;
293 -- ----------------------------------------------------------------------------
294 -- |-----------------------< Chk_Unique_Level_Code >--------------------------|
295 -- ----------------------------------------------------------------------------
296
297 Procedure Chk_Unique_Level_Code
298 (p_rec in pqh_lcd_shd.g_rec_type) is
299 --
300 Cursor c_Level_Code is
301 Select Level_Code
302 from PQH_DE_Level_Codes
303 Where Level_Code = p_rec.Level_Code;
304 l_Level_Code PQH_DE_Level_Codes.Level_Code%TYPE;
305 l_proc varchar2(72) := g_package || 'Unique_Level_Code';
306 Begin
307 hr_utility.set_location(l_proc, 10);
308 Open c_Level_Code;
309 Fetch c_Level_Code into l_Level_Code;
310 If c_Level_Code%ROWCOUNT > 0 Then
311 hr_utility.set_message(8302, 'PQH_DE_DUPVAL_Level_Code');
312 Close c_Level_Code;
313 fnd_message.raise_error;
314 End If;
315 Close c_Level_Code;
316 Exception
317 when app_exception.application_exception then
318 if hr_multi_message.exception_add
319 (p_associated_column1 => 'PQH_DE_Level_Codes.Level_Code'
320 ) then
321 hr_utility.set_location(' Leaving:'||l_proc,60);
322 raise;
323 end if;
324 hr_utility.set_location(' Leaving:'||l_proc,70);
325 End Chk_Unique_Level_Code;
326
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------< insert_validate >----------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure insert_validate
331 (p_rec in pqh_lcd_shd.g_rec_type
332 ) is
333 --
334 l_proc varchar2(72) := g_package||'insert_validate';
335 --
336 Begin
337 hr_utility.set_location('Entering:'||l_proc, 5);
338 --
339 -- Call all supporting business operations
340 --
341 --
342 -- EDIT_HERE: As this table does not have a mandatory business_group_id
343 -- column, ensure client_info is populated by calling a suitable
344 -- ???_???_bus.set_security_group_id procedure, or add one of the following
345 -- comments:
346 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
347 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
348 --
349 -- Validate Dependent Attributes
350 --
351 Chk_Unique_Level_Code (p_rec);
352 Chk_LEVEL_NUMBER_ID (p_rec);
353 --
354 hr_utility.set_location(' Leaving:'||l_proc, 10);
355 End insert_validate;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------< update_validate >----------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure update_validate
361 (p_rec in pqh_lcd_shd.g_rec_type
362 ) is
363 --
364 l_proc varchar2(72) := g_package||'update_validate';
365 --
366 Begin
367 hr_utility.set_location('Entering:'||l_proc, 5);
368 --
369 -- Call all supporting business operations
370 --
371 --
372 -- EDIT_HERE: As this table does not have a mandatory business_group_id
373 -- column, ensure client_info is populated by calling a suitable
374 -- ???_???_bus.set_security_group_id procedure, or add one of the following
375 -- comments:
376 -- "-- No business group context. HR_STANDARD_LOOKUPS used for validation."
377 -- "-- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS."
378 --
379 -- Validate Dependent Attributes
380 --
381 chk_non_updateable_args
382 (p_rec => p_rec
383 );
384 --
385 --
386 hr_utility.set_location(' Leaving:'||l_proc, 10);
387 End update_validate;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |---------------------------< delete_validate >----------------------------|
391 -- ----------------------------------------------------------------------------
392 Procedure delete_validate
393 (p_rec in pqh_lcd_shd.g_rec_type
394 ) is
395 --
396 l_proc varchar2(72) := g_package||'delete_validate';
397 --
398 Begin
399 hr_utility.set_location('Entering:'||l_proc, 5);
400 --
401 -- Call all supporting business operations
402 --
403 Chk_delete(p_rec);
404 hr_utility.set_location(' Leaving:'||l_proc, 10);
405 End delete_validate;
406 --
407 end pqh_lcd_bus;