1 Package Body pqh_lvl_bus as
2 /* $Header: pqlvlrhi.pkb 115.2 2002/12/03 00:08:45 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_lvl_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_wrkplc_vldtn_lvlnum_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_wrkplc_vldtn_lvlnum_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 from per_business_groups pbg
30 , pqh_de_wrkplc_vldtn_lvlnums lvl
31 where lvl.wrkplc_vldtn_lvlnum_id = p_wrkplc_vldtn_lvlnum_id
32 and pbg.business_group_id = lvl.business_group_id;
33 --
34 -- Declare local variables
35 --
36 l_security_group_id number;
37 l_proc varchar2(72) := g_package||'set_security_group_id';
38 --
39 begin
40 --
41 hr_utility.set_location('Entering:'|| l_proc, 10);
42 --
43 -- Ensure that all the mandatory parameter are not null
44 --
45 hr_api.mandatory_arg_error
46 (p_api_name => l_proc
47 ,p_argument => 'wrkplc_vldtn_lvlnum_id'
48 ,p_argument_value => p_wrkplc_vldtn_lvlnum_id
49 );
50 --
51 open csr_sec_grp;
52 fetch csr_sec_grp into l_security_group_id;
53 --
54 if csr_sec_grp%notfound then
55 --
56 close csr_sec_grp;
57 --
58 -- The primary key is invalid therefore we must error
59 --
60 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61 hr_multi_message.add
62 (p_associated_column1
63 => nvl(p_associated_column1,'WRKPLC_VLDTN_LVLNUM_ID')
64 );
65 --
66 else
67 close csr_sec_grp;
68 --
69 -- Set the security_group_id in CLIENT_INFO
70 --
71 hr_api.set_security_group_id
72 (p_security_group_id => l_security_group_id
73 );
74 end if;
75 --
76 hr_utility.set_location(' Leaving:'|| l_proc, 20);
77 --
78 end set_security_group_id;
79 --
80 -- ---------------------------------------------------------------------------
81 -- |---------------------< return_legislation_code >-------------------------|
82 -- ---------------------------------------------------------------------------
83 --
84 Function return_legislation_code
85 (p_wrkplc_vldtn_lvlnum_id in number
86 )
87 Return Varchar2 Is
88 --
89 -- Declare cursor
90 --
91 cursor csr_leg_code is
92 select pbg.legislation_code
93 from per_business_groups pbg
94 , pqh_de_wrkplc_vldtn_lvlnums lvl
95 where lvl.wrkplc_vldtn_lvlnum_id = p_wrkplc_vldtn_lvlnum_id
96 and pbg.business_group_id = lvl.business_group_id;
97 --
98 -- Declare local variables
99 --
100 l_legislation_code varchar2(150);
101 l_proc varchar2(72) := g_package||'return_legislation_code';
102 --
103 Begin
104 --
105 hr_utility.set_location('Entering:'|| l_proc, 10);
106 --
107 -- Ensure that all the mandatory parameter are not null
108 --
109 hr_api.mandatory_arg_error
110 (p_api_name => l_proc
111 ,p_argument => 'wrkplc_vldtn_lvlnum_id'
112 ,p_argument_value => p_wrkplc_vldtn_lvlnum_id
113 );
114 --
115 if ( nvl(pqh_lvl_bus.g_wrkplc_vldtn_lvlnum_id, hr_api.g_number)
116 = p_wrkplc_vldtn_lvlnum_id) then
117 --
118 -- The legislation code has already been found with a previous
119 -- call to this function. Just return the value in the global
120 -- variable.
121 --
122 l_legislation_code := pqh_lvl_bus.g_legislation_code;
123 hr_utility.set_location(l_proc, 20);
124 else
125 --
126 -- The ID is different to the last call to this function
127 -- or this is the first call to this function.
128 --
129 open csr_leg_code;
130 fetch csr_leg_code into l_legislation_code;
131 --
132 if csr_leg_code%notfound then
133 --
134 -- The primary key is invalid therefore we must error
135 --
136 close csr_leg_code;
137 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
138 fnd_message.raise_error;
139 end if;
140 hr_utility.set_location(l_proc,30);
141 --
142 -- Set the global variables so the values are
143 -- available for the next call to this function.
144 --
145 close csr_leg_code;
146 pqh_lvl_bus.g_wrkplc_vldtn_lvlnum_id := p_wrkplc_vldtn_lvlnum_id;
147 pqh_lvl_bus.g_legislation_code := l_legislation_code;
148 end if;
149 hr_utility.set_location(' Leaving:'|| l_proc, 40);
150 return l_legislation_code;
151 end return_legislation_code;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------< chk_non_updateable_args >------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 -- This procedure is used to ensure that non updateable attributes have
160 -- not been updated. If an attribute has been updated an error is generated.
161 --
162 -- Pre Conditions:
163 -- g_old_rec has been populated with details of the values currently in
164 -- the database.
165 --
166 -- In Arguments:
167 -- p_rec has been populated with the updated values the user would like the
168 -- record set to.
169 --
170 -- Post Success:
171 -- Processing continues if all the non updateable attributes have not
172 -- changed.
173 --
174 -- Post Failure:
175 -- An application error is raised if any of the non updatable attributes
176 -- have been altered.
177 --
178 -- {End Of Comments}
179 -- ----------------------------------------------------------------------------
180 Procedure chk_non_updateable_args
181 (p_effective_date in date
182 ,p_rec in pqh_lvl_shd.g_rec_type
183 ) IS
184 --
185 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
186 --
187 Begin
188 --
189 -- Only proceed with the validation if a row exists for the current
190 -- record in the HR Schema.
191 --
192 IF NOT pqh_lvl_shd.api_updating
193 (p_wrkplc_vldtn_lvlnum_id => p_rec.wrkplc_vldtn_lvlnum_id
194 ,p_object_version_number => p_rec.object_version_number
195 ) THEN
196 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
197 fnd_message.set_token('PROCEDURE ', l_proc);
198 fnd_message.set_token('STEP ', '5');
199 fnd_message.raise_error;
200 END IF;
201 --
202 -- EDIT_HERE: Add checks to ensure non-updateable args have
203 -- not been updated.
204 --
205 End chk_non_updateable_args;
206
207 Procedure chk_Lvl_Num
208 (p_Level_Number_Id in Number) IS
209 --
210 l_proc varchar2(72) := g_package || 'chk_Lvl_Num';
211 --
212 Cursor Lvlnum is
213 Select '1'
214 From PQH_DE_LEVEL_NUMBERS
215 Where LEVEL_NUMBER_ID = p_Level_Number_Id;
216 l_Result Varchar2(1);
217 Begin
218 Open Lvlnum;
219 Fetch Lvlnum into l_Result;
220 If Lvlnum%NOTFOUND Then
221 Close Lvlnum;
222 hr_utility.set_message(8302,'PQH_DE_LVLNUM_VALDTN_LVL');
223 hr_utility.raise_error;
224 End If;
225 Close Lvlnum;
226 Exception
227 when app_exception.application_exception then
228 if hr_multi_message.exception_add
229 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTN_LVLNUMS.LEVEL_NUMBER_ID'
230 ) then
231 hr_utility.set_location(' Leaving:'||l_proc,60);
232 raise;
233 end if;
234 hr_utility.set_location(' Leaving:'||l_proc,70);
235 End chk_Lvl_Num;
236
237 Procedure chk_Lvl_Code
238 (p_rec in pqh_lvl_shd.g_rec_type) IS
239 --
240 l_proc varchar2(72) := g_package || 'chk_Lvl_Code';
241 --
242 Cursor Lvlcode is
243 Select '1'
244 From PQH_DE_LEVEL_CODES
245 Where LEVEL_NUMBER_ID = p_Rec.Level_Number_Id and
246 Level_Code_Id = p_Rec.Level_Code_Id;
247
248 l_Result Varchar2(1);
249 Begin
250 Open LvlCode;
251 Fetch LvlCode into l_Result;
252 If Lvlcode%NOTFOUND Then
253 Close Lvlcode;
254 hr_utility.set_message(8302,'PQH_DE_LVLCOD_VALDTN_LVL');
255 hr_utility.raise_error;
256 End If;
257 Close Lvlcode;
258 Exception
259 when app_exception.application_exception then
260 if hr_multi_message.exception_add
261 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTN_LVLNUMS.LEVEL_CODE_ID'
262 ) then
263 hr_utility.set_location(' Leaving:'||l_proc,60);
264 raise;
265 end if;
266 hr_utility.set_location(' Leaving:'||l_proc,70);
267 End chk_Lvl_Code;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |---------------------------< insert_validate >----------------------------|
271 -- ----------------------------------------------------------------------------
272 Procedure insert_validate
273 (p_effective_date in date
274 ,p_rec in pqh_lvl_shd.g_rec_type
275 ) is
276 --
277 l_proc varchar2(72) := g_package||'insert_validate';
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Call all supporting business operations
283 --
284 hr_api.validate_bus_grp_id
285 (p_business_group_id => p_rec.business_group_id
286 ,p_associated_column1 => pqh_lvl_shd.g_tab_nam
287 || '.BUSINESS_GROUP_ID');
288 --
289 -- After validating the set of important attributes,
290 -- if Multiple Message detection is enabled and at least
291 -- one error has been found then abort further validation.
292 --
293 hr_multi_message.end_validation_set;
294 --
295 -- Validate Dependent Attributes
296 --
297 chk_Lvl_Num(p_Rec.Level_Number_Id);
298
299 chk_Lvl_Code(p_rec);
300 --
301 hr_utility.set_location(' Leaving:'||l_proc, 10);
302 End insert_validate;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------< update_validate >----------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure update_validate
308 (p_effective_date in date
309 ,p_rec in pqh_lvl_shd.g_rec_type
310 ) is
311 --
312 l_proc varchar2(72) := g_package||'update_validate';
313 --
314 Begin
315 hr_utility.set_location('Entering:'||l_proc, 5);
316 --
317 -- Call all supporting business operations
318 --
319 hr_api.validate_bus_grp_id
320 (p_business_group_id => p_rec.business_group_id
321 ,p_associated_column1 => pqh_lvl_shd.g_tab_nam
322 || '.BUSINESS_GROUP_ID');
323 --
324 -- After validating the set of important attributes,
325 -- if Multiple Message detection is enabled and at least
326 -- one error has been found then abort further validation.
327 --
328 hr_multi_message.end_validation_set;
329 --
330 -- Validate Dependent Attributes
331 --
332 chk_non_updateable_args
333 (p_effective_date => p_effective_date
334 ,p_rec => p_rec
335 );
336
337 chk_Lvl_Num(p_Rec.Level_Number_Id);
338
339 chk_Lvl_Code(p_rec);
340 --
341 --
342 hr_utility.set_location(' Leaving:'||l_proc, 10);
343 End update_validate;
344 --
345 -- ----------------------------------------------------------------------------
346 -- |---------------------------< delete_validate >----------------------------|
347 -- ----------------------------------------------------------------------------
348 Procedure delete_validate
349 (p_rec in pqh_lvl_shd.g_rec_type
350 ) is
351 --
352 l_proc varchar2(72) := g_package||'delete_validate';
353 --
354 Begin
355 hr_utility.set_location('Entering:'||l_proc, 5);
356 --
357 -- Call all supporting business operations
358 --
359 hr_utility.set_location(' Leaving:'||l_proc, 10);
360 End delete_validate;
361 --
362 end pqh_lvl_bus;