[Home] [Help]
PACKAGE BODY: APPS.BEN_ACT_BUS
Source
4 -- ----------------------------------------------------------------------------
1 Package Body ben_act_bus as
2 /* $Header: beactrhi.pkb 120.0 2005/05/28 00:20:33 appldev noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_act_bus.'; -- Global package name
9 --
10 --
11 -- ---------------------------------------------------------------------------
12 -- |---------------------< return_legislation_code >-------------------------|
13 -- ---------------------------------------------------------------------------
14 --
15 -- Description:
16 -- Return the legislation code for a specific primary key value
17 --
18 -- Prerequisites:
19 -- The primary key identified by p_person_action_id already exists.
20 --
21 -- In Arguments:
22 -- p_person_action_id
23 --
24 -- Post Success:
25 -- If the value is found this function will return the values business
26 -- group legislation code.
27 --
28 -- Post Failure:
29 -- An error is raised if the value does not exist.
30 --
31 -- Access Status:
32 -- Internal Development Use Only.
33 --
34 function return_legislation_code
35 (p_person_action_id in number) return varchar2 is
36 --
37 -- Declare cursor
38 --
39 cursor csr_leg_code is
40 select bg.legislation_code
41 from per_business_groups_perf bg,
42 ben_benefit_actions bba, ben_person_actions bpa
43 where bba.benefit_action_id = bpa.benefit_action_id
44 and bba.business_group_id = bg.business_group_id
45 and bpa.person_action_id = p_person_action_id;
46 --
47 -- Declare local variables
48 --
49 l_legislation_code varchar2(150);
50 l_proc varchar2(72) := g_package||'return_legislation_code';
51 --
52 begin
53 --
54 hr_utility.set_location('Entering:'|| l_proc, 10);
55 --
56 -- Ensure that all the mandatory parameter are not null
57 --
58 hr_api.mandatory_arg_error(p_api_name => l_proc,
59 p_argument => 'person_action_id',
60 p_argument_value =>p_person_action_id);
61 --
62 open csr_leg_code;
63 --
64 fetch csr_leg_code into l_legislation_code;
65 --
66 if csr_leg_code%notfound then
67 --
68 close csr_leg_code;
69 --
70 -- The primary key is invalid therefore we must error
71 --
72 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
76 --
73 fnd_message.raise_error;
74 --
75 end if;
77 close csr_leg_code;
78 --
79 hr_utility.set_location(' Leaving:'|| l_proc, 20);
80 --
81 return l_legislation_code;
82 --
83 end return_legislation_code;
84 --
85 --
86 -- ----------------------------------------------------------------------------
87 -- |----------------------------< chk_person_action_id >----------------------|
88 -- ----------------------------------------------------------------------------
89 --
90 -- Description
91 -- This procedure is used to check that the primary key for the table
92 -- is created properly. It should be null on insert and
93 -- should not be able to be updated.
94 --
95 -- Pre Conditions
96 -- None.
97 --
98 -- In Parameters
99 -- person_action_id PK of record being inserted or updated.
100 -- object_version_number Object version number of record being
101 -- inserted or updated.
102 --
103 -- Post Success
104 -- Processing continues
105 --
106 -- Post Failure
107 -- Errors handled by the procedure
108 --
109 -- Access Status
110 -- Internal table handler use only.
111 --
112 Procedure chk_person_action_id(p_person_action_id in number,
113 p_object_version_number in number) is
114 --
115 l_proc varchar2(72) := g_package||'chk_person_action_id';
116 l_api_updating boolean;
117 --
118 Begin
119 --
120 hr_utility.set_location('Entering:'||l_proc, 5);
121 --
122 l_api_updating := ben_act_shd.api_updating
123 (p_person_action_id => p_person_action_id,
124 p_object_version_number => p_object_version_number);
125 --
126 if (l_api_updating
127 and nvl(p_person_action_id,hr_api.g_number)
128 <> ben_act_shd.g_old_rec.person_action_id) then
129 --
130 -- raise error as PK has changed
131 --
132 ben_act_shd.constraint_error('BEN_PERSON_ACTIONS_PK');
133 --
134 elsif not l_api_updating then
135 --
136 -- check if PK is null
137 --
138 if p_person_action_id is not null then
139 --
140 -- raise error as PK is not null
141 --
142 ben_act_shd.constraint_error('BEN_PERSON_ACTIONS_PK');
143 --
144 end if;
145 --
146 end if;
147 --
148 hr_utility.set_location('Leaving:'||l_proc, 10);
149 --
150 End chk_person_action_id;
151 --
152 -- ----------------------------------------------------------------------------
153 -- |-------------------------< chk_benefit_action_id >------------------------|
154 -- ----------------------------------------------------------------------------
155 --
156 -- Description
157 -- This procedure checks that a referenced foreign key actually exists
158 -- in the referenced table.
159 --
160 -- Pre-Conditions
161 -- None.
162 --
163 -- In Parameters
164 -- p_person_action_id PK
165 -- p_benefit_action_id ID of FK column
166 -- p_object_version_number object version number
167 --
168 -- Post Success
169 -- Processing continues
170 --
171 -- Post Failure
172 -- Error raised.
173 --
174 -- Access Status
175 -- Internal table handler use only.
176 --
177 Procedure chk_benefit_action_id (p_person_action_id in number,
178 p_benefit_action_id in number,
179 p_object_version_number in number) is
180 --
181 l_proc varchar2(72) := g_package||'chk_benefit_action_id';
182 l_api_updating boolean;
183 l_dummy varchar2(1);
184 --
185 cursor c1 is
186 select null
187 from ben_benefit_actions a
188 where a.benefit_action_id = p_benefit_action_id;
189 --
190 Begin
191 --
192 hr_utility.set_location('Entering:'||l_proc,5);
193 --
197 --
194 l_api_updating := ben_act_shd.api_updating
195 (p_person_action_id => p_person_action_id,
196 p_object_version_number => p_object_version_number);
198 if (l_api_updating
199 and nvl(p_benefit_action_id,hr_api.g_number)
200 <> nvl(ben_act_shd.g_old_rec.benefit_action_id,hr_api.g_number)
201 or not l_api_updating) then
202 --
203 -- check if benefit_action_id value exists in ben_benefit_actions table
204 --
205 open c1;
206 --
207 fetch c1 into l_dummy;
208 if c1%notfound then
209 --
210 close c1;
211 --
212 -- raise error as FK does not relate to PK in ben_benefit_actions
213 -- table.
214 --
215 ben_act_shd.constraint_error('BEN_PERSON_ACTIONS_FK1');
216 --
217 end if;
218 --
219 close c1;
220 --
221 end if;
222 --
223 hr_utility.set_location('Leaving:'||l_proc,10);
224 --
225 End chk_benefit_action_id;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |----------------------------< chk_action_status_cd >----------------------|
229 -- ----------------------------------------------------------------------------
230 --
231 -- Description
232 -- This procedure is used to check that the lookup value is valid.
233 --
234 -- Pre Conditions
235 -- None.
236 --
237 -- In Parameters
238 -- person_action_id PK of record being inserted or updated.
239 -- action_status_cd Value of lookup code.
240 -- effective_date effective date
241 -- object_version_number Object version number of record being
242 -- inserted or updated.
243 --
244 -- Post Success
245 -- Processing continues
246 --
247 -- Post Failure
248 -- Error handled by procedure
249 --
250 -- Access Status
251 -- Internal table handler use only.
252 --
253 Procedure chk_action_status_cd(p_person_action_id in number,
254 p_action_status_cd in varchar2,
255 p_effective_date in date,
256 p_object_version_number in number) is
257 --
258 l_proc varchar2(72) := g_package||'chk_action_status_cd';
259 l_api_updating boolean;
260 --
261 Begin
262 --
263 hr_utility.set_location('Entering:'||l_proc, 5);
264 --
265 l_api_updating := ben_act_shd.api_updating
266 (p_person_action_id => p_person_action_id,
267 p_object_version_number => p_object_version_number);
271 <> nvl(ben_act_shd.g_old_rec.action_status_cd,hr_api.g_varchar2)
268 --
269 if (l_api_updating
270 and p_action_status_cd
272 or not l_api_updating) then
273 --
274 -- check if value of lookup falls within lookup type.
275 --
276 --
277 if hr_api.not_exists_in_hr_lookups
278 (p_lookup_type => 'BEN_ACTN_STAT',
279 p_lookup_code => p_action_status_cd,
280 p_effective_date => p_effective_date) then
281 --
282 -- raise error as does not exist as lookup
283 --
284 fnd_message.set_name('BEN','BEN_91438_LOOKUP_VALUE_INVALID');
285 fnd_message.set_token('FIELD','ACTION_STATUS_CD');
286 fnd_message.set_token('TYPE','BEN_ACTN_STAT');
287 fnd_message.raise_error;
288 --
289 end if;
290 --
291 end if;
292 --
293 hr_utility.set_location('Leaving:'||l_proc,10);
294 --
295 end chk_action_status_cd;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------< insert_validate >----------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure insert_validate(p_rec in ben_act_shd.g_rec_type
301 ,p_effective_date in date) is
302 --
303 l_proc varchar2(72) := g_package||'insert_validate';
304 --
305 Begin
306 hr_utility.set_location('Entering:'||l_proc, 5);
307 --
308 -- Call all supporting business operations
309 --
310 --
311 --
312 chk_person_action_id
313 (p_person_action_id => p_rec.person_action_id,
314 p_object_version_number => p_rec.object_version_number);
315 --
316 chk_benefit_action_id
317 (p_person_action_id => p_rec.person_action_id,
318 p_benefit_action_id => p_rec.benefit_action_id,
319 p_object_version_number => p_rec.object_version_number);
320 --
321 chk_action_status_cd
322 (p_person_action_id => p_rec.person_action_id,
323 p_action_status_cd => p_rec.action_status_cd,
324 p_effective_date => p_effective_date,
325 p_object_version_number => p_rec.object_version_number);
326 --
327 hr_utility.set_location(' Leaving:'||l_proc, 10);
328 End insert_validate;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------< update_validate >----------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure update_validate(p_rec in ben_act_shd.g_rec_type
334 ,p_effective_date in date) is
335 --
336 l_proc varchar2(72) := g_package||'update_validate';
337 --
338 Begin
339 hr_utility.set_location('Entering:'||l_proc, 5);
340 --
341 -- Call all supporting business operations
342 --
343 --
344 --
345 chk_person_action_id
346 (p_person_action_id => p_rec.person_action_id,
347 p_object_version_number => p_rec.object_version_number);
348 --
349 chk_benefit_action_id
350 (p_person_action_id => p_rec.person_action_id,
351 p_benefit_action_id => p_rec.benefit_action_id,
352 p_object_version_number => p_rec.object_version_number);
353 --
354 chk_action_status_cd
355 (p_person_action_id => p_rec.person_action_id,
356 p_action_status_cd => p_rec.action_status_cd,
357 p_effective_date => p_effective_date,
358 p_object_version_number => p_rec.object_version_number);
359 --
360 hr_utility.set_location(' Leaving:'||l_proc, 10);
361 End update_validate;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |---------------------------< delete_validate >----------------------------|
365 -- ----------------------------------------------------------------------------
366 Procedure delete_validate(p_rec in ben_act_shd.g_rec_type
367 ,p_effective_date in date) is
368 --
369 l_proc varchar2(72) := g_package||'delete_validate';
370 --
371 Begin
372 hr_utility.set_location('Entering:'||l_proc, 5);
373 --
374 -- Call all supporting business operations
375 --
376 hr_utility.set_location(' Leaving:'||l_proc, 10);
377 End delete_validate;
378 --
379 end ben_act_bus;