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