DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BBP_BUS

Source


1 Package Body ben_bbp_bus as
2 /* $Header: bebbprhi.pkb 120.0 2005/05/28 00:34:03 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bbp_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-------------------------< chk_batch_parameter_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_parameter_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_parameter_id(p_batch_parameter_id          in number,
37                                  p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_batch_parameter_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_bbp_shd.api_updating
47     (p_batch_parameter_id          => p_batch_parameter_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_batch_parameter_id,hr_api.g_number)
52      <>  ben_bbp_shd.g_old_rec.batch_parameter_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_bbp_shd.constraint_error('BEN_BATCH_PARAMETER_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_batch_parameter_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_bbp_shd.constraint_error('BEN_BATCH_PARAMETER_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_batch_parameter_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |-------------------------< chk_batch_exe_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_parameter_id PK of record being inserted or updated.
88 --   batch_exe_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_batch_exe_cd(p_batch_parameter_id         in number,
103                            p_batch_exe_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_batch_exe_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_bbp_shd.api_updating
115     (p_batch_parameter_id          => p_batch_parameter_id,
116      p_object_version_number       => p_object_version_number);
117   --
118   if (l_api_updating
119       and p_batch_exe_cd
120       <> nvl(ben_bbp_shd.g_old_rec.batch_exe_cd,hr_api.g_varchar2)
121       or not l_api_updating)
122       and p_batch_exe_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    => 'BEN_BATCH_EXE',
128            p_lookup_code    => p_batch_exe_cd,
129            p_effective_date => p_effective_date) then
130       --
131       -- raise error as does not exist as lookup
132       --
133       fnd_message.set_name('BEN','BEN_91628_LOOKUP_TYPE_GENERIC');
134       fnd_message.set_token('FIELD','p_batch_exe_cd');
135       fnd_message.set_token('TYPE','BEN_BATCH_EXE');
136       fnd_message.raise_error;
137       --
138     end if;
139     --
140   end if;
141   --
142   hr_utility.set_location('Leaving:'||l_proc,10);
143   --
144 end chk_batch_exe_cd;
145 -- ----------------------------------------------------------------------------
146 -- |-------------------------< chk_batch_parameters >-------------------------|
147 -- ----------------------------------------------------------------------------
148 --
149 -- Description
150 --   This procedure is used to check that the lookup value is valid.
151 --
152 -- Pre Conditions
153 --   None.
154 --
155 -- In Parameters
156 --   batch_parameter_id    PK of record being inserted or updated.
157 --   thread_cnt_num        Number of threads.
158 --   max_err_num           Max number of errors.
159 --   chunk_size            Chunk size of threads.
160 --   object_version_number Object version number of record being
161 --                         inserted or updated.
162 --
163 -- Post Success
164 --   Processing continues
165 --
166 -- Post Failure
167 --   Error handled by procedure
168 --
169 -- Access Status
170 --   Internal table handler use only.
171 --
172 Procedure chk_batch_parameters(p_batch_parameter_id    in number,
173                                p_object_version_number in number,
174                                p_thread_cnt_num        in number,
175                                p_max_err_num           in number,
176                                p_chunk_size            in number) is
177   --
178   l_proc         varchar2(72) := g_package||'chk_batch_parameters';
179   l_api_updating boolean;
180   --
181 Begin
182   --
183   hr_utility.set_location('Entering:'||l_proc, 5);
184   --
185   l_api_updating := ben_bbp_shd.api_updating
186     (p_batch_parameter_id          => p_batch_parameter_id,
187      p_object_version_number       => p_object_version_number);
188   --
189   if (l_api_updating
190       and p_thread_cnt_num
191       <> nvl(ben_bbp_shd.g_old_rec.thread_cnt_num,hr_api.g_number)
192       or not l_api_updating)
193       and p_thread_cnt_num is not null then
194     --
195     -- check if thread count between 1 and 80.
196     --
197     if p_thread_cnt_num not between 1 and 80 then
198       --
199       -- raise error as too large a value for the number of threads.
200       --
201       fnd_message.set_name('BEN','BEN_91934_NUMBER_OF_THREADS');
202       fnd_message.raise_error;
203       --
204     end if;
205     --
206   end if;
207   --
208   if (l_api_updating
209       and p_max_err_num
210       <> nvl(ben_bbp_shd.g_old_rec.max_err_num,hr_api.g_number)
211       or not l_api_updating)
212       and p_max_err_num is not null then
213     --
214     -- check if thread count between 1 and 80.
215     --
216     if p_max_err_num not between 0 and 90000 then
217       --
218       -- raise error as too large a value for the number of errors.
219       --
220       fnd_message.set_name('BEN','BEN_91935_MAX_NUMBER_ERRORS');
221       fnd_message.raise_error;
222       --
223     end if;
224     --
225   end if;
226   --
227   if (l_api_updating
228       and p_chunk_size
229       <> nvl(ben_bbp_shd.g_old_rec.chunk_size,hr_api.g_number)
230       or not l_api_updating)
231       and p_chunk_size is not null then
232     --
233     -- check if thread count between 1 and 80.
234     --
235     if p_chunk_size not between 1 and 200 then
236       --
237       -- raise error as too large a value for the number of threads.
238       --
239       fnd_message.set_name('BEN','BEN_91936_CHUNK_SIZE');
240       fnd_message.raise_error;
241       --
242     end if;
243     --
244   end if;
245   --
246   hr_utility.set_location('Leaving:'||l_proc,10);
247   --
248 End chk_batch_parameters;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |-------------------------< chk_batch_exe_cd_unique >----------------------|
252 -- ----------------------------------------------------------------------------
253 --
254 -- Description
255 --   This procedure is used to check that the executable parameters have been
256 --   set once per business group.
257 --
258 -- Pre Conditions
259 --   None.
260 --
261 -- In Parameters
262 --   batch_parameter_id    PK of record being inserted or updated.
263 --   object_version_number Object version number of record being
264 --                         inserted or updated.
265 --   batch_exe_cd          executable lookup code
266 --   business_group_id     business group.
267 --
268 -- Post Success
269 --   Processing continues
270 --
271 -- Post Failure
272 --   Error handled by procedure
273 --
274 -- Access Status
275 --   Internal table handler use only.
276 --
277 Procedure chk_batch_exe_cd_unique(p_batch_parameter_id    in number,
278                                   p_object_version_number in number,
279                                   p_batch_exe_cd          in varchar2,
280                                   p_business_group_id     in number) is
281   --
282   l_proc         varchar2(72) := g_package||'chk_batch_exe_cd_unique';
283   l_api_updating boolean;
284   l_dummy        varchar2(1);
285   --
286   cursor c1 is
287     select null
288     from   ben_batch_parameter
289     where  business_group_id = p_business_group_id
290     and    batch_exe_cd = p_batch_exe_cd
291     and    batch_parameter_id <> nvl(p_batch_parameter_id,-1);
292   --
293 Begin
294   --
295   hr_utility.set_location('Entering:'||l_proc, 5);
296   --
297   l_api_updating := ben_bbp_shd.api_updating
298     (p_batch_parameter_id          => p_batch_parameter_id,
299      p_object_version_number       => p_object_version_number);
300   --
301   if (l_api_updating
302       and p_batch_exe_cd
303       <> nvl(ben_bbp_shd.g_old_rec.batch_exe_cd,hr_api.g_varchar2)
304       or not l_api_updating)
305       and p_batch_exe_cd is not null then
306     --
307     open c1;
308       --
309       fetch c1 into l_dummy;
310       if c1%found then
311         --
312         close c1;
313         fnd_message.set_name('BEN','BEN_91937_RECORD_ALREADY_SAVED');
314         fnd_message.raise_error;
315         --
316       end if;
317       --
318     close c1;
319     --
320   end if;
321   --
322   hr_utility.set_location('Leaving:'||l_proc,10);
323   --
324 End chk_batch_exe_cd_unique;
325 --
326 -- ----------------------------------------------------------------------------
327 -- |---------------------------< insert_validate >----------------------------|
328 -- ----------------------------------------------------------------------------
329 Procedure insert_validate(p_rec in ben_bbp_shd.g_rec_type
330                          ,p_effective_date in date) is
331 --
332   l_proc  varchar2(72) := g_package||'insert_validate';
333 --
334 Begin
335   hr_utility.set_location('Entering:'||l_proc, 5);
336   --
337   -- Call all supporting business operations
338   --
339   --
340   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
341   --
342   chk_batch_parameter_id
343   (p_batch_parameter_id    => p_rec.batch_parameter_id,
344    p_object_version_number => p_rec.object_version_number);
345   --
346   chk_batch_exe_cd
347   (p_batch_parameter_id    => p_rec.batch_parameter_id,
348    p_batch_exe_cd          => p_rec.batch_exe_cd,
349    p_effective_date        => p_effective_date,
350    p_object_version_number => p_rec.object_version_number);
351   --
352   chk_batch_parameters
353   (p_batch_parameter_id    => p_rec.batch_parameter_id,
354    p_object_version_number => p_rec.object_version_number,
355    p_thread_cnt_num        => p_rec.thread_cnt_num,
356    p_max_err_num           => p_rec.max_err_num,
357    p_chunk_size            => p_rec.chunk_size);
358   --
359   chk_batch_exe_cd_unique
360   (p_batch_parameter_id    => p_rec.batch_parameter_id,
361    p_object_version_number => p_rec.object_version_number,
362    p_business_group_id     => p_rec.business_group_id,
363    p_batch_exe_cd          => p_rec.batch_exe_cd);
364   --
365   hr_utility.set_location(' Leaving:'||l_proc, 10);
366 End insert_validate;
367 --
368 -- ----------------------------------------------------------------------------
369 -- |---------------------------< update_validate >----------------------------|
370 -- ----------------------------------------------------------------------------
371 Procedure update_validate(p_rec in ben_bbp_shd.g_rec_type
375 --
372                          ,p_effective_date in date) is
373 --
374   l_proc  varchar2(72) := g_package||'update_validate';
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Call all supporting business operations
380   --
381   --
382   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
383   --
384   chk_batch_parameter_id
385   (p_batch_parameter_id    => p_rec.batch_parameter_id,
386    p_object_version_number => p_rec.object_version_number);
387   --
388   chk_batch_exe_cd
389   (p_batch_parameter_id    => p_rec.batch_parameter_id,
390    p_batch_exe_cd          => p_rec.batch_exe_cd,
391    p_effective_date        => p_effective_date,
392    p_object_version_number => p_rec.object_version_number);
393   --
394   chk_batch_parameters
395   (p_batch_parameter_id    => p_rec.batch_parameter_id,
396    p_object_version_number => p_rec.object_version_number,
397    p_thread_cnt_num        => p_rec.thread_cnt_num,
398    p_max_err_num           => p_rec.max_err_num,
399    p_chunk_size            => p_rec.chunk_size);
400   --
401   chk_batch_exe_cd_unique
402   (p_batch_parameter_id    => p_rec.batch_parameter_id,
403    p_object_version_number => p_rec.object_version_number,
404    p_business_group_id     => p_rec.business_group_id,
405    p_batch_exe_cd          => p_rec.batch_exe_cd);
406   --
407   hr_utility.set_location(' Leaving:'||l_proc, 10);
408 End update_validate;
409 --
410 -- ----------------------------------------------------------------------------
411 -- |---------------------------< delete_validate >----------------------------|
412 -- ----------------------------------------------------------------------------
413 Procedure delete_validate(p_rec in ben_bbp_shd.g_rec_type
414                          ,p_effective_date in date) is
415 --
416   l_proc  varchar2(72) := g_package||'delete_validate';
417 --
418 Begin
419   hr_utility.set_location('Entering:'||l_proc, 5);
420   --
421   -- Call all supporting business operations
422   --
423   hr_utility.set_location(' Leaving:'||l_proc, 10);
424 End delete_validate;
425 --
426 --
427 --  ---------------------------------------------------------------------------
428 --  |---------------------< return_legislation_code >-------------------------|
429 --  ---------------------------------------------------------------------------
430 --
431 function return_legislation_code
432   (p_batch_parameter_id in number) return varchar2 is
433   --
434   -- Declare cursor
435   --
436   cursor csr_leg_code is
437     select a.legislation_code
438     from   per_business_groups a,
439            ben_batch_parameter b
440     where b.batch_parameter_id      = p_batch_parameter_id
441     and   a.business_group_id = b.business_group_id;
442   --
443   -- Declare local variables
444   --
445   l_legislation_code  varchar2(150);
446   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
447   --
448 begin
449   --
450   hr_utility.set_location('Entering:'|| l_proc, 10);
451   --
452   -- Ensure that all the mandatory parameter are not null
453   --
454   hr_api.mandatory_arg_error(p_api_name       => l_proc,
455                              p_argument       => 'batch_parameter_id',
456                              p_argument_value => p_batch_parameter_id);
457   --
458   open csr_leg_code;
459     --
460     fetch csr_leg_code into l_legislation_code;
461     --
462     if csr_leg_code%notfound then
463       --
464       close csr_leg_code;
465       --
466       -- The primary key is invalid therefore we must error
467       --
468       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
469       hr_utility.raise_error;
470       --
471     end if;
472     --
473   close csr_leg_code;
474   --
475   hr_utility.set_location(' Leaving:'|| l_proc, 20);
476   --
477   return l_legislation_code;
478   --
479 end return_legislation_code;
480 --
481 end ben_bbp_bus;