1 Package Body per_abt_bus as
2 /* $Header: peabtrhi.pkb 120.1 2005/10/10 04:12 bshukla noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_abt_bus.'; -- Global package name
9 --
10 -- The first 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_absence_attendance_type_id number default null;
15 g_language varchar2(4) default null;
16 g_business_group_id number(15); -- For validating translation;
17 --
18 -- ---------------------------------------------------------------------------
19 -- |---------------------< return_legislation_code >-------------------------|
20 -- ---------------------------------------------------------------------------
21 --
22 Function return_legislation_code
23 (p_absence_attendance_type_id in number
24 ,p_language in varchar2
25 )
26 Return Varchar2 Is
27 --
28 -- Declare cursor
29 --
30 cursor csr_leg_code is
31 select pbg.legislation_code
32 from per_business_groups_perf pbg
33 , per_absence_attendance_types abb
34 where abb.absence_attendance_type_id = p_absence_attendance_type_id
35 and pbg.business_group_id (+) = abb.business_group_id;
36 --
37 -- Declare local variables
38 --
39 l_legislation_code varchar2(150);
40 l_proc varchar2(72) := g_package||'return_legislation_code';
41 --
42 Begin
43 --
44 hr_utility.set_location('Entering:'|| l_proc, 10);
45 --
46 -- Ensure that all the mandatory parameter are not null
47 --
48 hr_api.mandatory_arg_error
49 (p_api_name => l_proc
50 ,p_argument => 'absence_attendance_type_id'
51 ,p_argument_value => p_absence_attendance_type_id
52 );
53 --
54 --
55 if (( nvl(per_abt_bus.g_absence_attendance_type_id, hr_api.g_number)
56 = p_absence_attendance_type_id)
57 and ( nvl(per_abt_bus.g_language, hr_api.g_varchar2)
58 = p_language)) then
59 --
60 -- The legislation code has already been found with a previous
61 -- call to this function. Just return the value in the global
62 -- variable.
63 --
64 l_legislation_code := per_abt_bus.g_legislation_code;
65 hr_utility.set_location(l_proc, 20);
66 else
67 --
68 -- The ID is different to the last call to this function
69 -- or this is the first call to this function.
70 --
71 open csr_leg_code;
72 fetch csr_leg_code into l_legislation_code;
73 --
74 if csr_leg_code%notfound then
75 --
76 -- The primary key is invalid therefore we must error
77 --
78 close csr_leg_code;
79 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
80 fnd_message.raise_error;
81 end if;
82 hr_utility.set_location(l_proc,30);
83 --
84 -- Set the global variables so the values are
85 -- available for the next call to this function.
86 --
87 close csr_leg_code;
88 per_abt_bus.g_absence_attendance_type_id := p_absence_attendance_type_id;
89 per_abt_bus.g_language := p_language;
90 per_abt_bus.g_legislation_code := l_legislation_code;
91 end if;
92 hr_utility.set_location(' Leaving:'|| l_proc, 40);
93 return l_legislation_code;
94 end return_legislation_code;
95 --
96 -- ----------------------------------------------------------------------------
97 -- |-----------------------< chk_non_updateable_args >------------------------|
98 -- ----------------------------------------------------------------------------
99 -- {Start Of Comments}
100 --
101 -- Description:
102 -- This procedure is used to ensure that non updateable attributes have
103 -- not been updated. If an attribute has been updated an error is generated.
104 --
105 -- Pre Conditions:
106 -- g_old_rec has been populated with details of the values currently in
107 -- the database.
108 --
109 -- In Arguments:
110 -- p_rec has been populated with the updated values the user would like the
111 -- record set to.
112 --
113 -- Post Success:
114 -- Processing continues if all the non updateable attributes have not
115 -- changed.
116 --
117 -- Post Failure:
118 -- An application error is raised if any of the non updatable attributes
119 -- have been altered.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure chk_non_updateable_args
124 (p_rec in per_abt_shd.g_rec_type
125 ) IS
126 --
127 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
128 --
129 Begin
130 --
131 -- Only proceed with the validation if a row exists for the current
132 -- record in the HR Schema.
133 --
134 IF NOT per_abt_shd.api_updating
135 (p_absence_attendance_type_id => p_rec.absence_attendance_type_id
136 ,p_language => p_rec.language
137 ) THEN
138 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
139 fnd_message.set_token('PROCEDURE ', l_proc);
140 fnd_message.set_token('STEP ', '5');
141 fnd_message.raise_error;
142 END IF;
143 --
144 --
145 End chk_non_updateable_args;
146 --
147 -- ----------------------------------------------------------------------------
148 -- |---------------------------< chk_name >------------------------------------|
149 -- ----------------------------------------------------------------------------
150 -- Developer Implementation Notes:
151 -- Similar validation is performed in validate_translation, called only by the form
152 -- Any changes will need to be maintinaed in both places.
153 --
154 Procedure chk_name
155 (p_rec in per_abt_shd.g_rec_type
156 ,p_absence_attendance_type_id in number
157 ) is
158 --
159 l_proc varchar2(72) := g_package||'chk_name';
160 l_api_updating boolean;
161 l_dummy number;
162 --
163 -- Use p_absence_attendance_type_id in this check since this variable is always set
164 -- p_rec value for the id is not set on insert
165 --
166 cursor csr_chk_unique_name is
167 select 1
168 from per_absence_attendance_types abb, per_abs_attendance_types_tl abt
169 where abt.absence_attendance_type_id <> p_absence_attendance_type_id
170 and abt.language = p_rec.language
171 and abt.name = p_rec.name
172 and abb.absence_attendance_type_id = abt.absence_attendance_type_id
173 and (abb.business_group_id is null
174 or (abb.business_group_id is not null and abb.business_group_id in
175 (select nvl(x.business_group_id,abb.business_group_id)
176 from per_absence_attendance_types x
177 where x.absence_attendance_type_id = p_absence_attendance_type_id)));
178 --
179 Begin
180 hr_utility.set_location('Entering:'||l_proc,10);
181 hr_utility.set_location('Entering:'||to_char(p_absence_attendance_type_id),11);
182 --
183 -- Use p_rec.absence_attendance_type_id in this check since this is null on insert
184 -- p_absence_attendance_type_id is not null and causes error.
185 --
186 l_api_updating := per_abt_shd.api_updating
187 (p_absence_attendance_type_id => p_rec.absence_attendance_type_id
188 ,p_language => p_rec.language );
189 --
190 if ((l_api_updating and
191 per_abt_shd.g_old_rec.name <> p_rec.name) or
192 (not l_api_updating)) then
193 open csr_chk_unique_name;
194 fetch csr_chk_unique_name into l_dummy;
195 if csr_chk_unique_name%found then
196 close csr_chk_unique_name;
197 fnd_message.set_name('PER','HR_7806_DEF_ABS_EXISTS');
198 fnd_message.raise_error;
199 else
200 close csr_chk_unique_name;
201 end if;
202 end if;
203 hr_utility.set_location('Leaving:'||l_proc,70);
204 exception
205 when app_exception.application_exception then
206 if hr_multi_message.exception_add
207 (p_associated_column1 => 'PER_ABS_ATTENDANCE_TYPES_TL.NAME'
208 ) then
209 hr_utility.set_location('Leaving:'||l_proc,80);
210 raise;
211 end if;
212 hr_utility.set_location('Leaving:'||l_proc,90);
213 End chk_name;
214 --
215 -- ----------------------------------------------------------------------------
216 -- |---------------------------< chk_delete >---------------------------------|
217 -- ----------------------------------------------------------------------------
218 Procedure chk_delete
219 (p_absence_attendance_type_id in number
220 ) is
221 --
222 l_proc varchar2(72) := g_package||'chk_delete';
223 --
224 Begin
225 hr_utility.set_location('Entering:'||l_proc, 5);
226 --
227 -- No additional validation required
228 --
229 null;
230 --
231 hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End chk_delete;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |---------------------------< insert_validate >----------------------------|
236 -- ----------------------------------------------------------------------------
237 Procedure insert_validate
238 (p_rec in per_abt_shd.g_rec_type
239 ,p_absence_attendance_type_id in number
240 ) is
241 --
242 l_proc varchar2(72) := g_package||'insert_validate';
243 --
244 Begin
245 hr_utility.set_location('Entering:'||l_proc, 5);
246 --
247 -- Call all supporting business operations
248 --
249 --
250 -- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS.
251 --
252 -- Validate Dependent Attributes
253 --
254 per_abt_bus.chk_name
255 ( p_rec => p_rec
256 , p_absence_attendance_type_id => p_absence_attendance_type_id
257 );
258 --
259 hr_utility.set_location(' Leaving:'||l_proc, 10);
260 End insert_validate;
261 --
262 -- ----------------------------------------------------------------------------
263 -- |---------------------------< update_validate >----------------------------|
264 -- ----------------------------------------------------------------------------
265 Procedure update_validate
266 (p_rec in per_abt_shd.g_rec_type
267 ) is
268 --
269 l_proc varchar2(72) := g_package||'update_validate';
270 --
271 Begin
272 hr_utility.set_location('Entering:'||l_proc, 5);
273 --
274 -- Call all supporting business operations
275 --
276 --
277 -- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS
278 --
279 -- Validate Dependent Attributes
280 --
281 chk_non_updateable_args
282 (p_rec => p_rec
283 );
284 --
285 per_abt_bus.chk_name
286 ( p_rec => p_rec
287 , p_absence_attendance_type_id => p_rec.absence_attendance_type_id
288 );
289 --
290 hr_utility.set_location(' Leaving:'||l_proc, 10);
291 End update_validate;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |---------------------------< delete_validate >----------------------------|
295 -- ----------------------------------------------------------------------------
296 Procedure delete_validate
297 (p_rec in per_abt_shd.g_rec_type
298 ) is
299 --
300 l_proc varchar2(72) := g_package||'delete_validate';
301 --
302 Begin
303 hr_utility.set_location('Entering:'||l_proc, 5);
304 --
305 -- Call all supporting business operations
306 --
307 per_abt_bus.chk_delete
308 ( p_absence_attendance_type_id => p_rec.absence_attendance_type_id );
309 --
310 hr_utility.set_location(' Leaving:'||l_proc, 10);
311 End delete_validate;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |---------------------------< set_translation_globals >--------------------|
315 -- ----------------------------------------------------------------------------
316 -- Developer Implementation Notes:
317 --
318 Procedure set_translation_globals
319 (p_business_group_id in number
320 ) IS
321 begin
322 g_business_group_id := p_business_group_id;
323 end set_translation_globals;
324 --
325 -- ----------------------------------------------------------------------------
326 -- |---------------------------< validate_translation >------------------------|
327 -- ----------------------------------------------------------------------------
328 Procedure validate_translation
329 (p_absence_attendance_type_id in number
330 ,p_language in varchar2
331 ,p_name in varchar2
332 ) IS
333 --
334 l_proc varchar2(72) := g_package||'validate_translation';
335 l_dummy number;
336 --
337 cursor csr_chk_unique_name is
338 select 1
339 from per_absence_attendance_types abb, per_abs_attendance_types_tl abt
340 where (p_absence_attendance_type_id is null
341 or p_absence_attendance_type_id <> abt.absence_attendance_type_id)
342 and abt.language = p_language
343 and abt.name = p_name
344 and abb.absence_attendance_type_id = abt.absence_attendance_type_id
345 and (abb.business_group_id is null
346 or (abb.business_group_id is not null
347 and abb.business_group_id =
348 nvl(per_abt_bus.g_business_group_id,abb.business_group_id)));
349 --
350 BEGIN
351 --
352 hr_utility.set_location('Entering:'||l_proc,5);
353 --
354 open csr_chk_unique_name;
355 fetch csr_chk_unique_name into l_dummy;
356 if csr_chk_unique_name%found then
357 close csr_chk_unique_name;
358 fnd_message.set_name('PER','HR_7806_DEF_ABS_EXISTS');
359 fnd_message.raise_error;
360 else
361 close csr_chk_unique_name;
362 end if;
363 --
364 hr_utility.set_location('Leaving:'||l_proc,10);
365 --
366 end validate_translation;
367 --
368 end per_abt_bus;