1 Package Body pqh_etm_bus as
2 /* $Header: pqetmrhi.pkb 115.4 2002/11/27 23:43:21 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_etm_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_ent_minutes_id number default null;
15 --
16 -- ---------------------------------------------------------------------------
17 -- |----------------------< set_security_group_id >--------------------------|
18 -- ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21 (p_ent_minutes_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_ent_minutes etm
31 where etm.ent_minutes_id = p_ent_minutes_id
32 and pbg.business_group_id = etm.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 => 'ent_minutes_id'
48 ,p_argument_value => p_ent_minutes_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,'ENT_MINUTES_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_ent_minutes_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_ent_minutes etm
95 where etm.ent_minutes_id = p_ent_minutes_id
96 and pbg.business_group_id (+) = etm.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 => 'ent_minutes_id'
112 ,p_argument_value => p_ent_minutes_id
113 );
114 --
115 if ( nvl(pqh_etm_bus.g_ent_minutes_id, hr_api.g_number)
116 = p_ent_minutes_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_etm_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_etm_bus.g_ent_minutes_id := p_ent_minutes_id;
147 pqh_etm_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_etm_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_etm_shd.api_updating
193 (p_ent_minutes_id => p_rec.ent_minutes_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 IF nvl(p_rec.ENT_MINUTES_CD, hr_api.g_varchar2) <>
203 nvl(pqh_etm_shd.g_old_rec.ENT_MINUTES_CD, hr_api.g_varchar2) THEN
204 hr_utility.set_message(8302, 'DE_PQH_NONUPD_ENT_CD');
205 fnd_message.raise_error;
206 END IF;
207
208 IF nvl(p_rec.TARIFF_GROUP_CD, hr_api.g_varchar2) <>
209 nvl(pqh_etm_shd.g_old_rec.TARIFF_GROUP_CD, hr_api.g_varchar2) THEN
210 hr_utility.set_message(8302, 'DE_PQH_NONUPD_TARIFF_CD');
211 fnd_message.raise_error;
212 END IF;
213
214
215 --
216 -- EDIT_HERE: Add checks to ensure non-updateable args have
217 -- not been updated.
218 --
219 End chk_non_updateable_args;
220
221 -- ----------------------------------------------------------------------------
222 -- |-----------------------< Chk_TFF_CD_HR_LOOKUP >---------------------------|
223 -- ----------------------------------------------------------------------------
224
225 Procedure Chk_TFF_CD_HR_LOOKUP
226 (p_rec in pqh_ETM_shd.g_rec_type) is
227 --
228 Cursor c_TFF_CD_HR_LOOKUP is
229 Select '1'
230 from hr_lookups
231 Where LOOKUP_TYPE = 'DE_PQH_TARIFF_GROUP_TYPE'
232 AND LOOKUP_CODE = p_rec.Tariff_group_CD;
233
234 L_status Varchar2(1);
235 l_proc varchar2(1000) := g_package || 'UNIQUE_ENT_MIN_TFF_CD';
236 Begin
237 hr_utility.set_location(l_proc, 10);
238 Open c_TFF_CD_HR_LOOKUP;
239 Fetch c_TFF_CD_HR_LOOKUP into L_status;
240 If c_TFF_CD_HR_LOOKUP%notfound Then
241 hr_utility.set_message(8302, 'DE_PQH_TARIFF_CODE');
242 Close c_TFF_CD_HR_LOOKUP;
243 fnd_message.raise_error;
244 End If;
245 Close c_TFF_CD_HR_LOOKUP;
246 Exception
247 when app_exception.application_exception then
248 if hr_multi_message.exception_add
249 (p_associated_column1 => 'PQH_DE_ENT_MINUTES.Tariff_group_CD'
250 ) then
251 hr_utility.set_location(' Leaving:'||l_proc,60);
252 raise;
253 end if;
254 hr_utility.set_location(' Leaving:'||l_proc,70);
255 End Chk_TFF_CD_HR_LOOKUP;
256
257 -- ----------------------------------------------------------------------------
258 -- |-----------------------< Chk_unique_ENT_Desc >-----------------------------|
259 -- ----------------------------------------------------------------------------
260
261 Procedure Chk_unique_ENT_Desc
262 (p_rec in pqh_ETM_shd.g_rec_type) is
263 --
264 Cursor c_unique_ENT_Desc is
265 Select '1'
266 from PQH_DE_ENT_MINUTES
267 Where DESCRIPTION = p_rec.DESCRIPTION
268 and Business_group_id = p_rec.Business_group_id ;
269
270 L_status Varchar2(1);
271 l_proc varchar2(1000) := g_package || 'UNIQUE_unique_ENT_Desc';
272 Begin
273 hr_utility.set_location(l_proc, 10);
274 Open c_unique_ENT_Desc;
275 Fetch c_unique_ENT_Desc into L_status;
276 If c_unique_ENT_Desc%found Then
277 hr_utility.set_message(8302, 'DE_PQH_unique_ENT_Desc');
278 Close c_unique_ENT_Desc;
279 fnd_message.raise_error;
280 End If;
281 Close c_unique_ENT_Desc;
282 Exception
283 when app_exception.application_exception then
284 if hr_multi_message.exception_add
285 (p_associated_column1 => 'PQH_DE_ENT_MINUTES.DESCRIPTION'
286 ) then
287 hr_utility.set_location(' Leaving:'||l_proc,60);
288 raise;
289 end if;
290 hr_utility.set_location(' Leaving:'||l_proc,70);
291 End Chk_unique_ENT_Desc;
292
293 -- ----------------------------------------------------------------------------
294 -- |-----------------------< Chk_ENT_MIN_TFF_CD >------------------------------|
295 -- ----------------------------------------------------------------------------
296
297 Procedure Chk_ENT_MIN_TFF_CD
298 (p_rec in pqh_ETM_shd.g_rec_type) is
299 --
300 Cursor c_ENT_MIN_TFF_CD is
301 Select '1'
302 from PQH_DE_ENT_MINUTES
303 Where ENT_MINUTES_CD = p_rec.ENT_MINUTES_CD
304 AND Tariff_group_CD = p_rec.Tariff_group_CD;
305
306 L_status Varchar2(1);
307 l_proc varchar2(1000) := g_package || 'UNIQUE_ENT_MIN_TFF_CD';
308 Begin
309 hr_utility.set_location(l_proc, 10);
310 Open c_ENT_MIN_TFF_CD;
311 Fetch c_ENT_MIN_TFF_CD into L_status;
312 If c_ENT_MIN_TFF_CD%found Then
313 hr_utility.set_message(8302, 'PQH_DE_ENT_MINUTES_DUP');
314 Close c_ENT_MIN_TFF_CD;
315 fnd_message.raise_error;
316 End If;
317 Close c_ENT_MIN_TFF_CD;
318 Exception
319 when app_exception.application_exception then
320 if hr_multi_message.exception_add
321 (p_associated_column1 => 'PQH_DE_ENT_MINUTES.ENT_MINUTES_CD'
322 ) then
323 hr_utility.set_location(' Leaving:'||l_proc,60);
324 raise;
325 end if;
326 hr_utility.set_location(' Leaving:'||l_proc,70);
327 End Chk_ENT_MIN_TFF_CD;
328 --
329 -- ----------------------------------------------------------------------------
330 -- |---------------------------< insert_validate >----------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure insert_validate
333 (p_effective_date in date
334 ,p_rec in pqh_etm_shd.g_rec_type
335 ) is
336 --
337 l_proc varchar2(72) := g_package||'insert_validate';
338 --
339 Begin
340 hr_utility.set_location('Entering:'||l_proc, 5);
341 --
342 -- Call all supporting business operations
343 --
344 -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
345 -- will only be valid when the business_group_id is not null.
346 -- As this column is defined as optional on the table then
347 -- different logic will be required to handle the null case.
348 -- If this is a start-up data entity then:
349 -- a) add code to stop null values being processed by this
350 -- row handler
351 -- If this is not a start-up data entity then either:
352 -- b) ignore the security_group_id value held in
353 -- client_info. This includes performing lookup
354 -- validation against the HR_STANDARD_LOOKUPS view.
355 -- or c) (less likely) ensure the correct security_group_id
356 -- value is set in client_info.
357 -- Remove this comment when the edit has been completed.
358 -- Validate Important Attributes
359
360 If p_rec.business_group_id is not null then
361 hr_api.validate_bus_grp_id
362 (p_business_group_id => p_rec.business_group_id
363 ,p_associated_column1 => pqh_etm_shd.g_tab_nam
364 || '.BUSINESS_GROUP_ID');
365 end if;
366
367 --
368 -- After validating the set of important attributes,
369 -- if Multiple Message detection is enabled and at least
370 -- one error has been found then abort further validation.
371 --
372 hr_multi_message.end_validation_set;
373 --
374 -- Validate Dependent Attributes
375 --
376 --
377 Chk_TFF_CD_HR_LOOKUP(P_REC);
378 Chk_ENT_MIN_TFF_CD (P_Rec);
379 Chk_unique_ENT_Desc(P_Rec);
380 hr_utility.set_location(' Leaving:'||l_proc, 10);
381 End insert_validate;
382 --
383 -- ----------------------------------------------------------------------------
384 -- |---------------------------< update_validate >----------------------------|
385 -- ----------------------------------------------------------------------------
386 Procedure update_validate
387 (p_effective_date in date
388 ,p_rec in pqh_etm_shd.g_rec_type
389 ) is
390 --
391 l_proc varchar2(72) := g_package||'update_validate';
392 --
393 Begin
394 hr_utility.set_location('Entering:'||l_proc, 5);
395 --
396 -- Call all supporting business operations
397 --
398 -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
399 -- will only be valid when the business_group_id is not null.
400 -- As this column is defined as optional on the table then
401 -- different logic will be required to handle the null case.
402 -- If this is a start-up data entity then:
403 -- a) add code to stop null values being processed by this
404 -- row handler
405 -- If this is not a start-up data entity then either:
406 -- b) ignore the security_group_id value held in
407 -- client_info. This includes performing lookup
408 -- validation against the HR_STANDARD_LOOKUPS view.
409 -- or c) (less likely) ensure the correct security_group_id
410 -- value is set in client_info.
411 -- Remove this comment when the edit has been completed.
412 -- Validate Important Attributes
413 If p_rec.business_group_id is not null then
414 hr_api.validate_bus_grp_id
415 (p_business_group_id => p_rec.business_group_id
416 ,p_associated_column1 => pqh_etm_shd.g_tab_nam
417 || '.BUSINESS_GROUP_ID');
418 end if;
419
420 --
421 -- After validating the set of important attributes,
422 -- if Multiple Message detection is enabled and at least
423 -- one error has been found then abort further validation.
424 --
425 hr_multi_message.end_validation_set;
426 --
427 -- Validate Dependent Attributes
428 --
429
430 chk_non_updateable_args
431 (p_effective_date => p_effective_date
432 ,p_rec => p_rec
433 );
434
435 Chk_TFF_CD_HR_LOOKUP(P_REC);
436 Chk_unique_ENT_Desc(P_Rec);
437 --
438 --
439 hr_utility.set_location(' Leaving:'||l_proc, 10);
440 End update_validate;
441 --
442 -- ----------------------------------------------------------------------------
443 -- |---------------------------< delete_validate >----------------------------|
444 -- ----------------------------------------------------------------------------
445 Procedure delete_validate
446 (p_rec in pqh_etm_shd.g_rec_type
447 ) is
448 --
449 l_proc varchar2(72) := g_package||'delete_validate';
450 --
451 Begin
452 hr_utility.set_location('Entering:'||l_proc, 5);
453 --
454 -- Call all supporting business operations
455 --
456 hr_utility.set_location(' Leaving:'||l_proc, 10);
457 End delete_validate;
458 --
459 end pqh_etm_bus;