[Home] [Help]
PACKAGE BODY: APPS.BEN_XFI_BUS
Source
1 Package Body ben_xfi_bus as
2 /* $Header: bexfirhi.pkb 120.0 2005/05/28 12:33:36 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xfi_bus.'; -- Global package name
9 g_legislation_code varchar2(30) := NULL;
10 --
11 -- ---------------------------------------------------------------------------
12 -- |----------------------< set_security_group_id >--------------------------|
13 -- ---------------------------------------------------------------------------
14 --
15 Procedure set_security_group_id
16 (p_ext_file_id in number
17 ) is
18 --
19 -- Declare cursor
20 --
21 cursor csr_sec_grp is
22 select pbg.security_group_id
23 from per_business_groups pbg
24 , ben_ext_file xfi
25 where xfi.ext_file_id = p_ext_file_id
26 and pbg.business_group_id = xfi.business_group_id;
27 --
28 -- Declare local variables
29 --
30 l_security_group_id number;
31 l_proc varchar2(72) := g_package||'set_security_group_id';
32 --
33 begin
34 --
35 hr_utility.set_location('Entering:'|| l_proc, 10);
36 --
37 -- Ensure that all the mandatory parameter are not null
38 --
39 hr_api.mandatory_arg_error
40 (p_api_name => l_proc
41 ,p_argument => 'ext_file_id'
42 ,p_argument_value => p_ext_file_id
43 );
44 --
45 open csr_sec_grp;
46 fetch csr_sec_grp into l_security_group_id;
47 --
48 if csr_sec_grp%notfound then
49 --
50 close csr_sec_grp;
51 --
52 -- The primary key is invalid therefore we must error
53 --
54 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
55 fnd_message.raise_error;
56 --
57 end if;
58 close csr_sec_grp;
59 --
60 -- Set the security_group_id in CLIENT_INFO
61 --
62 hr_api.set_security_group_id
63 (p_security_group_id => l_security_group_id
64 );
65 --
66 hr_utility.set_location(' Leaving:'|| l_proc, 20);
67 --
68 end set_security_group_id;
69 --
70 --
71 -- ----------------------------------------------------------------------------
72 -- |------< chk_ext_file_id >------|
73 -- ----------------------------------------------------------------------------
74 --
75 -- Description
76 -- This procedure is used to check that the primary key for the table
77 -- is created properly. It should be null on insert and
78 -- should not be able to be updated.
79 --
80 -- Pre Conditions
81 -- None.
82 --
83 -- In Parameters
84 -- ext_file_id PK of record being inserted or updated.
85 -- object_version_number Object version number of record being
86 -- inserted or updated.
87 --
88 -- Post Success
89 -- Processing continues
90 --
91 -- Post Failure
92 -- Errors handled by the procedure
93 --
94 -- Access Status
95 -- Internal table handler use only.
96 --
97 Procedure chk_ext_file_id(p_ext_file_id in number,
98 p_object_version_number in number) is
99 --
100 l_proc varchar2(72) := g_package||'chk_ext_file_id';
101 l_api_updating boolean;
102 --
103 Begin
104 --
105 hr_utility.set_location('Entering:'||l_proc, 5);
106 --
107 l_api_updating := ben_xfi_shd.api_updating
108 (p_ext_file_id => p_ext_file_id,
109 p_object_version_number => p_object_version_number);
110 --
111 if (l_api_updating
112 and nvl(p_ext_file_id,hr_api.g_number)
113 <> ben_xfi_shd.g_old_rec.ext_file_id) then
114 --
115 -- raise error as PK has changed
116 --
117 ben_xfi_shd.constraint_error('BEN_EXT_FILE_PK');
118 --
119 elsif not l_api_updating then
120 --
121 -- check if PK is null
122 --
123 if p_ext_file_id is not null then
124 --
125 -- raise error as PK is not null
126 --
127 ben_xfi_shd.constraint_error('BEN_EXT_FILE_PK');
128 --
129 end if;
130 --
131 end if;
132 --
133 hr_utility.set_location('Leaving:'||l_proc, 10);
134 --
135 End chk_ext_file_id;
136 --
137 -- ----------------------------------------------------------------------------
138 -- |------------------------< chk_name_unique >---------------------------------|
139 -- ----------------------------------------------------------------------------
140 --
141 -- Description
142 -- ensure that an extract file must have a name and not two extract file have the same name
143 --
144 -- Pre Conditions
145 -- None.
146 --
147 -- In Parameters
148 -- p_name is extract name
149 -- p_ext_file_id is extract file id
150 -- p_business_group_id
151 --
152 -- Post Success
153 -- Processing continues
154 --
155 -- Post Failure
156 -- Errors handled by the procedure
157 --
158 -- Access Status
159 -- Internal table handler use only.
160 --
161 -- ----------------------------------------------------------------------------
162 Procedure chk_name_unique
163 (p_ext_file_id in number
164 ,p_name in varchar2
165 ,p_business_group_id in number
166 ,p_legislation_code in varchar2)
167 is
168 l_proc varchar2(72) := g_package||'chk_name_unique';
169 l_dummy char(1);
170 cursor c1 is select null
171 from ben_ext_file
172 Where ext_file_id <> nvl(p_ext_file_id,-1)
173 and name = p_name
174 and ( (business_group_id is null -- is global
175 and legislation_code is null
176 )
177 or -- is legilsation specific and not bg specific
178 (legislation_code is not null
179 and business_group_id is null
180 and legislation_code = p_legislation_code)
181 or -- is business group specific
182 (business_group_id is not null
183 and business_group_id = p_business_group_id)
184 )
185 ;
186 --
187 Begin
188 hr_utility.set_location('Entering:'||l_proc, 5);
189 --
190 if p_name is null then
191 fnd_message.set_name('BEN','BEN_91783_NAME_NULL');
192 fnd_message.raise_error;
193 end if;
194 open c1;
195 fetch c1 into l_dummy;
196 if c1%found then
197 close c1;
198 fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
199 fnd_message.raise_error;
200 end if;
201 --
202 hr_utility.set_location('Leaving:'||l_proc, 15);
203 End chk_name_unique;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |----------------------< chk_startup_action >------------------------------|
207 -- ----------------------------------------------------------------------------
208 --
209 -- Description:
210 -- This procedure will check that the current action is allowed according
211 -- to the current startup mode.
212 --
213 -- ----------------------------------------------------------------------------
214 PROCEDURE chk_startup_action
215 (p_insert IN boolean
216 ,p_business_group_id IN number
217 ,p_legislation_code IN varchar2
218 ,p_legislation_subgroup IN varchar2 DEFAULT NULL) IS
219 --
220 BEGIN
221 --
222 -- Call the supporting procedure to check startup mode
223 --
224 IF (p_insert) THEN
225 --
226 -- Call procedure to check startup_action for inserts.
227 --
228 hr_startup_data_api_support.chk_startup_action
229 (p_generic_allowed => TRUE
230 ,p_startup_allowed => TRUE
231 ,p_user_allowed => TRUE
232 ,p_business_group_id => p_business_group_id
233 ,p_legislation_code => p_legislation_code
234 ,p_legislation_subgroup => p_legislation_subgroup
235 );
236 ELSE
237 --
238 -- Call procedure to check startup_action for updates and deletes.
239 --
240 hr_startup_data_api_support.chk_upd_del_startup_action
241 (p_generic_allowed => TRUE
242 ,p_startup_allowed => TRUE
243 ,p_user_allowed => TRUE
244 ,p_business_group_id => p_business_group_id
245 ,p_legislation_code => p_legislation_code
246 ,p_legislation_subgroup => p_legislation_subgroup
247 );
248 END IF;
249 --
250 END chk_startup_action;
251 --
252 --
253 -- ----------------------------------------------------------------------------
254 -- |---------------------------< insert_validate >----------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure insert_validate(p_rec in ben_xfi_shd.g_rec_type) is
257 --
258 l_proc varchar2(72) := g_package||'insert_validate';
259 --
260 Begin
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 --
263 -- Call all supporting business operations
264 --
265 --
266 chk_startup_action(True
267 ,p_rec.business_group_id
268 ,p_rec.legislation_code);
269 IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP') THEN
270 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate bus_grp
271 END IF;
272 --
273 chk_ext_file_id
274 (p_ext_file_id => p_rec.ext_file_id,
275 p_object_version_number => p_rec.object_version_number);
276 --
277 chk_name_unique
278 (p_ext_file_id => p_rec.ext_file_id,
279 p_name => p_rec.name,
280 p_business_group_id => p_rec.business_group_id,
281 p_legislation_code => p_rec.legislation_code);
282 hr_utility.set_location(' Leaving:'||l_proc, 10);
283 End insert_validate;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------< update_validate >----------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure update_validate(p_rec in ben_xfi_shd.g_rec_type) is
289 --
290 l_proc varchar2(72) := g_package||'update_validate';
291 --
292 Begin
293 hr_utility.set_location('Entering:'||l_proc, 5);
294 --
295 -- Call all supporting business operations
296 --
297 chk_startup_action(False
298 ,p_rec.business_group_id
299 ,p_rec.legislation_code);
300 IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP') THEN
301 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate bus_grp
302 END IF;
303 --
304 chk_ext_file_id
305 (p_ext_file_id => p_rec.ext_file_id,
306 p_object_version_number => p_rec.object_version_number);
307 --
308 chk_name_unique
309 (p_ext_file_id => p_rec.ext_file_id,
310 p_name => p_rec.name,
311 p_business_group_id => p_rec.business_group_id,
312 p_legislation_code => p_rec.legislation_code);
313 hr_utility.set_location(' Leaving:'||l_proc, 10);
314 End update_validate;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------< delete_validate >----------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure delete_validate(p_rec in ben_xfi_shd.g_rec_type) is
320 --
321 l_proc varchar2(72) := g_package||'delete_validate';
322 --
323 Begin
324 hr_utility.set_location('Entering:'||l_proc, 5);
325 --
326 -- Call all supporting business operations
327 --
328 --
329 chk_startup_action(False
330 ,ben_xfi_shd.g_old_rec.business_group_id
331 ,ben_xfi_shd.g_old_rec.legislation_code);
332 --
333 hr_utility.set_location(' Leaving:'||l_proc, 10);
334 End delete_validate;
335 --
336 --
337 -- ---------------------------------------------------------------------------
338 -- |---------------------< return_legislation_code >-------------------------|
339 -- ---------------------------------------------------------------------------
340 --
341 function return_legislation_code
342 (p_ext_file_id in number) return varchar2 is
343 --
344 -- Declare cursor
345 --
346 cursor csr_leg_code is
347 select a.legislation_code
348 from per_business_groups a,
349 ben_ext_file b
350 where b.ext_file_id = p_ext_file_id
351 and a.business_group_id(+) = b.business_group_id;
352 --
353 -- Declare local variables
354 --
355 l_legislation_code varchar2(150);
356 l_proc varchar2(72) := g_package||'return_legislation_code';
357 --
358 begin
359 --
360 hr_utility.set_location('Entering:'|| l_proc, 10);
361 --
362 -- Ensure that all the mandatory parameter are not null
363 --
364 hr_api.mandatory_arg_error(p_api_name => l_proc,
365 p_argument => 'ext_file_id',
366 p_argument_value => p_ext_file_id);
367 --
368 open csr_leg_code;
369 --
370 fetch csr_leg_code into l_legislation_code;
371 --
372 if csr_leg_code%notfound then
373 --
374 close csr_leg_code;
375 --
376 -- The primary key is invalid therefore we must error
377 --
378 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
379 fnd_message.raise_error;
380 --
381 end if;
382 --
383 close csr_leg_code;
384 --
385 hr_utility.set_location(' Leaving:'|| l_proc, 20);
386 --
387 return l_legislation_code;
388 --
389 end return_legislation_code;
390 --
391 end ben_xfi_bus;