1 Package Body pqh_def_bus as
2 /* $Header: pqdefrhi.pkb 115.3 2002/12/12 22:52:53 sgoyal noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_def_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_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_wrkplc_vldtn_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_vldtns def
31 where def.wrkplc_vldtn_id = p_wrkplc_vldtn_id
32 and pbg.business_group_id = def.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_id'
48 ,p_argument_value => p_wrkplc_vldtn_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_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_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_vldtns def
95 where def.wrkplc_vldtn_id = p_wrkplc_vldtn_id
96 and pbg.business_group_id = def.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_id'
112 ,p_argument_value => p_wrkplc_vldtn_id
113 );
114 --
115 if ( nvl(pqh_def_bus.g_wrkplc_vldtn_id, hr_api.g_number)
116 = p_wrkplc_vldtn_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_def_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_def_bus.g_wrkplc_vldtn_id := p_wrkplc_vldtn_id;
147 pqh_def_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_def_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_def_shd.api_updating
193 (p_wrkplc_vldtn_id => p_rec.wrkplc_vldtn_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 If p_rec.Employment_type <> pqh_def_shd.g_old_rec.Employment_type Then
206 hr_utility.set_message(8302, 'PQH_DE_NONUPD_VALDTN_EMP');
207 fnd_message.raise_error;
208 End If;
209
210 If p_rec.Remuneration_Regulation <> pqh_def_shd.g_old_rec.Remuneration_Regulation Then
211 hr_utility.set_message(8302, 'PQH_DE_NONUPD_VALDTN_RRN');
212 fnd_message.raise_error;
213 End If;
214 End chk_non_updateable_args;
215 --
216
217 Procedure Chk_Unique_Validation_Name
218 (p_rec in pqh_def_shd.g_rec_type) is
219 --
220
221 Cursor Vldtn_Name is
222 Select Validation_Name
223 from Pqh_De_Wrkplc_Vldtns
224 Where Validation_Name like P_Rec.Validation_Name
225 and Business_Group_Id = P_Rec.Business_Group_Id;
226
227 l_Validation_Name Pqh_De_Wrkplc_Vldtns.Validation_Name%TYPE;
228 l_proc varchar2(72) := g_package || 'Unique_Validation_Name';
229
230 Begin
231 hr_utility.set_location(l_proc, 10);
232 Open Vldtn_Name;
233 Fetch VLdtn_Name into l_Validation_Name;
234 If Vldtn_name%fOUND Then
235 hr_utility.set_message(8302, 'PQH_DE_DUPVAL_VALDTN_DEF');
236 Close Vldtn_Name;
237 fnd_message.raise_error;
238 End If;
239 Close Vldtn_Name;
240 Exception
241 when app_exception.application_exception then
242 if hr_multi_message.exception_add
243 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTNS.Validation_Name'
244 ) then
245 hr_utility.set_location(' Leaving:'||l_proc,60);
246 raise;
247 end if;
248 hr_utility.set_location(' Leaving:'||l_proc,70);
249 End Chk_Unique_Validation_Name;
250
251 Procedure Ckh_Emp_Type
252 (p_rec in pqh_def_shd.g_rec_type) is
253 --
254 l_proc varchar2(72) := g_package||'Ckh_Emp_Type';
255 Begin
256 hr_utility.set_location(l_proc, 10);
257 If p_rec.Employment_type Not in ('WC','BC','BE') Then
258 hr_utility.set_message(8302, 'PQH_DE_EMPTYP_VALDTN_DEF');
259 hr_utility.raise_error;
260 End If;
261 Exception
262 when app_exception.application_exception then
263 if hr_multi_message.exception_add
264 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTNS.Employment_Type'
265 ) then
266 hr_utility.set_location(' Leaving:'||l_proc,60);
267 raise;
268 end if;
269 hr_utility.set_location(' Leaving:'||l_proc,70);
270 End Ckh_Emp_Type;
271
272 Procedure Ckh_Remuneration
273 (p_rec in pqh_def_shd.g_rec_type) is
274 --
275 l_proc varchar2(72) := g_package||'Ckh_Emp_Type';
276 Begin
277 hr_utility.set_location(l_proc, 10);
278 If nvl(p_rec.REMUNERATION_REGULATION ,'XX') Not in ('CP','AP') Then
279 hr_utility.set_message(8302, 'PQH_DE_REMRGU_VALDTN_DEF');
280 hr_utility.raise_error;
281 End If;
282 Exception
283 when app_exception.application_exception then
284 if hr_multi_message.exception_add
285 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTNS.REMUNERATION_REGULATION') then
286 hr_utility.set_location(' Leaving:'||l_proc,60);
287 raise;
288 end if;
289 hr_utility.set_location(' Leaving:'||l_proc,70);
290 End Ckh_Remuneration;
291
292 Procedure Chk_delete
293 (p_rec in pqh_def_shd.g_rec_type) is
294
295 l_proc varchar2(72) := g_package||'Ckh_Delete';
296 Cursor Del is
297 Select '1' from
298 Pqh_De_Wrkplc_Vldtn_Vers
299 Where Wrkplc_Vldtn_Id = P_rec.Wrkplc_Vldtn_Id;
300
301 l_Status Varchar2(1);
302 Begin
303 Open Del;
304 Fetch Del into l_Status;
305 If Del%Found Then
306 Close Del;
307 hr_utility.set_message(8302, 'PQH_WRKVLD_PRE_DEL');
308 hr_utility.raise_error;
309 End If;
310 Close Del;
311 Exception
312 when app_exception.application_exception then
313 if hr_multi_message.exception_add
314 (p_associated_column1 => 'PQH_DE_WRKPLC_VLDTNS.WRKPLC_VLDTN_ID'
315 ) then
316 hr_utility.set_location(' Leaving:'||l_proc,60);
317 raise;
318 end if;
319 hr_utility.set_location(' Leaving:'||l_proc,70);
320 End Chk_Delete;
321
322 -- ----------------------------------------------------------------------------
323 -- |---------------------------< insert_validate >----------------------------|
324 -- ----------------------------------------------------------------------------
325 Procedure insert_validate
326 (p_effective_date in date
327 ,p_rec in pqh_def_shd.g_rec_type
328 ) is
329 --
330 l_proc varchar2(72) := g_package||'insert_validate';
331 --
332 Begin
333 hr_utility.set_location('Entering:'||l_proc, 5);
334 --
335 -- Call all supporting business operations
336 --
337 hr_api.validate_bus_grp_id
338 (p_business_group_id => p_rec.business_group_id
339 ,p_associated_column1 => pqh_def_shd.g_tab_nam
340 || '.BUSINESS_GROUP_ID');
341 --
342 -- After validating the set of important attributes,
343 -- if Multiple Message detection is enabled and at least
344 -- one error has been found then abort further validation.
345 --
346 hr_multi_message.end_validation_set;
347
348 hr_utility.set_location('Entering:'||l_proc, 10);
349
350 Chk_Unique_Validation_Name(P_Rec);
351
352 hr_utility.set_location('Entering:'||l_proc, 15);
353
354 Ckh_Remuneration(p_rec);
355
356 hr_utility.set_location('Entering:'||l_proc, 20);
357
358 Ckh_Emp_Type(p_rec);
359
360
361 --
362 -- Validate Dependent Attributes
363 --
364 --
365 hr_utility.set_location(' Leaving:'||l_proc, 10);
366 End insert_validate;
367 --
368 -- ----------------------------------------------------------------------------
369 -- |---------------------------< update_validate >----------------------------|
370 -- ----------------------------------------------------------------------------
371 Procedure update_validate
372 (p_effective_date in date
373 ,p_rec in pqh_def_shd.g_rec_type) is
374 --
375 l_proc varchar2(72) := g_package||'update_validate';
376 --
377 Begin
378 hr_utility.set_location('Entering:'||l_proc, 5);
379 --
380 -- Call all supporting business operations
381 --
382 hr_api.validate_bus_grp_id
383 (p_business_group_id => p_rec.business_group_id
384 ,p_associated_column1 => pqh_def_shd.g_tab_nam
385 || '.BUSINESS_GROUP_ID');
386 --
387 -- After validating the set of important attributes,
388 -- if Multiple Message detection is enabled and at least
389 -- one error has been found then abort further validation.
390 --
391
392 hr_utility.set_location('Entering:'||l_proc, 10);
393
394 hr_multi_message.end_validation_set;
395
396 Chk_Unique_Validation_Name(P_Rec);
397 --
398 -- Validate Dependent Attributes
399 --
400 chk_non_updateable_args
404 --
401 (p_effective_date => p_effective_date
402 ,p_rec => p_rec
403 );
405 --
406 hr_utility.set_location(' Leaving:'||l_proc, 10);
407 End update_validate;
408 --
409 -- ----------------------------------------------------------------------------
410 -- |---------------------------< delete_validate >----------------------------|
411 -- ----------------------------------------------------------------------------
412 Procedure delete_validate
413 (p_rec in pqh_def_shd.g_rec_type
414 ) is
415 --
416 l_proc varchar2(72) := g_package||'delete_validate';
417 --
418 Begin
419 hr_utility.set_location('Entering:'||l_proc, 5);
420 --
421 -- Call all supporting business operations
422 --
423 hr_utility.set_location(' Leaving:'||l_proc, 10);
424
425 Chk_delete (p_rec);
426
427 End delete_validate;
428 --
429 end pqh_def_bus;