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