DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BPI_BUS

Source


1 Package Body ben_bpi_bus as
2 /* $Header: bebpirhi.pkb 115.5 2002/12/16 11:53:30 vsethi ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bpi_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< chk_batch_proc_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_proc_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_proc_id(p_batch_proc_id               in number,
37                             p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_batch_proc_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_bpi_shd.api_updating
47     (p_batch_proc_id               => p_batch_proc_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_batch_proc_id,hr_api.g_number)
52      <>  ben_bpi_shd.g_old_rec.batch_proc_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_bpi_shd.constraint_error('BEN_BATCH_PROC_INFO_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_batch_proc_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_bpi_shd.constraint_error('BEN_BATCH_PROC_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_proc_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |-----------------------< chk_benefit_action_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_batch_proc_id PK
89 --   p_benefit_action_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 --
101 Procedure chk_benefit_action_id (p_batch_proc_id         in number,
102                                  p_benefit_action_id     in number,
103                                  p_object_version_number in number) is
104   --
105   l_proc         varchar2(72) := g_package||'chk_benefit_action_id';
106   l_api_updating boolean;
107   l_dummy        varchar2(1);
108   --
109   cursor c1 is
110     select null
111     from   ben_benefit_actions a
112     where  a.benefit_action_id = p_benefit_action_id;
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'||l_proc,5);
117   --
118   l_api_updating := ben_bpi_shd.api_updating
119      (p_batch_proc_id           => p_batch_proc_id,
120       p_object_version_number   => p_object_version_number);
121   --
122   if (l_api_updating
123      and nvl(p_benefit_action_id,hr_api.g_number)
124      <> nvl(ben_bpi_shd.g_old_rec.benefit_action_id,hr_api.g_number)
125      or not l_api_updating) then
126     --
127     -- check if benefit_action_id value exists in ben_benefit_actions 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_benefit_actions
137         -- table.
138         --
139         ben_bpi_shd.constraint_error('BEN_BATCH_PROC_INFO_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_benefit_action_id;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |---------------------------< insert_validate >----------------------------|
153 -- ----------------------------------------------------------------------------
154 Procedure insert_validate(p_rec in ben_bpi_shd.g_rec_type) is
155 --
156   l_proc  varchar2(72) := g_package||'insert_validate';
157 --
158 Begin
159   hr_utility.set_location('Entering:'||l_proc, 5);
160   --
161   -- Call all supporting business operations
162   --
163   --
164   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
165   --
166   chk_batch_proc_id
167   (p_batch_proc_id         => p_rec.batch_proc_id,
168    p_object_version_number => p_rec.object_version_number);
169   --
170   chk_benefit_action_id
171   (p_batch_proc_id         => p_rec.batch_proc_id,
172    p_benefit_action_id     => p_rec.benefit_action_id,
173    p_object_version_number => p_rec.object_version_number);
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End insert_validate;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |---------------------------< update_validate >----------------------------|
180 -- ----------------------------------------------------------------------------
181 Procedure update_validate(p_rec in ben_bpi_shd.g_rec_type) is
182 --
183   l_proc  varchar2(72) := g_package||'update_validate';
184 --
185 Begin
186   hr_utility.set_location('Entering:'||l_proc, 5);
187   --
188   -- Call all supporting business operations
189   --
190   --
191   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
192   --
193   chk_batch_proc_id
194   (p_batch_proc_id         => p_rec.batch_proc_id,
195    p_object_version_number => p_rec.object_version_number);
196   --
197   chk_benefit_action_id
198   (p_batch_proc_id         => p_rec.batch_proc_id,
199    p_benefit_action_id     => p_rec.benefit_action_id,
200    p_object_version_number => p_rec.object_version_number);
201   --
202   hr_utility.set_location(' Leaving:'||l_proc, 10);
203 End update_validate;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |---------------------------< delete_validate >----------------------------|
207 -- ----------------------------------------------------------------------------
208 Procedure delete_validate(p_rec in ben_bpi_shd.g_rec_type) is
209 --
210   l_proc  varchar2(72) := g_package||'delete_validate';
211 --
212 Begin
213   hr_utility.set_location('Entering:'||l_proc, 5);
214   --
215   -- Call all supporting business operations
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End delete_validate;
219 --
220 --
221 --  ---------------------------------------------------------------------------
222 --  |---------------------< return_legislation_code >-------------------------|
223 --  ---------------------------------------------------------------------------
224 --
225 function return_legislation_code
226   (p_batch_proc_id in number) return varchar2 is
227   --
228   -- Declare cursor
229   --
230   cursor csr_leg_code is
231     select a.legislation_code
232     from   per_business_groups a,
233            ben_batch_proc_info b
234     where b.batch_proc_id      = p_batch_proc_id
235     and   a.business_group_id = b.business_group_id;
236   --
237   -- Declare local variables
238   --
239   l_legislation_code  varchar2(150);
240   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
241   --
242 begin
243   --
244   hr_utility.set_location('Entering:'|| l_proc, 10);
245   --
246   -- Ensure that all the mandatory parameter are not null
247   --
248   hr_api.mandatory_arg_error(p_api_name       => l_proc,
249                              p_argument       => 'batch_proc_id',
250                              p_argument_value => p_batch_proc_id);
251   --
252   open csr_leg_code;
253     --
254     fetch csr_leg_code into l_legislation_code;
255     --
256     if csr_leg_code%notfound then
257       --
258       close csr_leg_code;
259       --
260       -- The primary key is invalid therefore we must error
261       --
262       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
263       hr_utility.raise_error;
264       --
265     end if;
266     --
267   close csr_leg_code;
268   --
269   hr_utility.set_location(' Leaving:'|| l_proc, 20);
270   --
271   return l_legislation_code;
272   --
273 end return_legislation_code;
274 --
275 end ben_bpi_bus;