DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_GOS_BUS

Source


1 Package Body ben_gos_bus as
2 /* $Header: begosrhi.pkb 120.0 2005/05/28 03:08:26 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_gos_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_gd_or_svc_typ_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 --   gd_or_svc_typ_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_gd_or_svc_typ_id(p_gd_or_svc_typ_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_gd_or_svc_typ_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_gos_shd.api_updating
47     (p_gd_or_svc_typ_id                => p_gd_or_svc_typ_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_gd_or_svc_typ_id,hr_api.g_number)
52      <>  ben_gos_shd.g_old_rec.gd_or_svc_typ_id) then
53     --
54     -- raise error as PK has changed
55     --
56     ben_gos_shd.constraint_error('BEN_GD_OR_SVC_TYP_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_gd_or_svc_typ_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       ben_gos_shd.constraint_error('BEN_GD_OR_SVC_TYP_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_gd_or_svc_typ_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_typ_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 --   gd_or_svc_typ_id PK of record being inserted or updated.
88 --   typ_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_typ_cd(p_gd_or_svc_typ_id                in number,
103                             p_typ_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_typ_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_gos_shd.api_updating
115     (p_gd_or_svc_typ_id                => p_gd_or_svc_typ_id,
116      p_object_version_number       => p_object_version_number);
117   --
118   if (l_api_updating
119       and p_typ_cd
120       <> nvl(ben_gos_shd.g_old_rec.typ_cd,hr_api.g_varchar2)
121       or not l_api_updating)
122       and p_typ_cd is not null then
123     --
124     -- check if value of lookup falls within lookup type.
125     --
126   hr_utility.set_location('In:'||l_proc||'lookup_code='||p_typ_cd,8);
127 
128     if hr_api.not_exists_in_hr_lookups
129           (p_lookup_type    => 'BEN_GD_R_SVC_TYP',
130            p_lookup_code    => p_typ_cd,
131            p_effective_date => p_effective_date) then
132       --
133       -- raise error as does not exist as lookup
134       --
135       fnd_message.set_name('PAY','HR_LOOKUP_DOES_NOT_EXIST');
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_typ_cd;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |--------------------------------< chk_name >------------------------------|
148 -- ----------------------------------------------------------------------------
149 --
150 -- Description
151 --   This procedure is used to check that the name is unique.
152 --
153 -- Pre Conditions
154 --   None.
155 --
156 -- In Parameters
157 --   gd_or_svc_typ_id PK of record being inserted or updated.
158 --   name is the name of the record been updeated or inserted.
159 --   business_group_id is the business group id of the record
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_name(p_gd_or_svc_typ_id            in number,
173                    p_name                        in varchar2,
174                    p_business_group_id           in number,
175                    p_object_version_number       in number) is
176   --
177   l_proc         varchar2(72) := g_package||'chk_name';
178   l_api_updating boolean;
179   l_exists       varchar2(1);
180   --
181   --
182   cursor csr_name is
183      select null
184         from BEN_GD_OR_SVC_TYP
185         where name = p_name
186           and gd_or_svc_typ_id <> nvl(p_gd_or_svc_typ_id, hr_api.g_number)
187           and business_group_id + 0 = p_business_group_id;
188   --
189 Begin
190   --
191   hr_utility.set_location('Entering:'||l_proc, 5);
192   --
193   l_api_updating := ben_gos_shd.api_updating
194     (p_gd_or_svc_typ_id         => p_gd_or_svc_typ_id,
195      p_object_version_number    => p_object_version_number);
196   --
197   if (l_api_updating
198       and p_name <> ben_gos_shd.g_old_rec.name) or
199       not l_api_updating then
200     --
201     hr_utility.set_location('Entering:'||l_proc, 10);
202     --
203     -- check if this name already exist
204     --
205     open csr_name;
206     fetch csr_name into l_exists;
207     if csr_name%found then
208       hr_utility.set_location('Entering:'||l_proc, 15);
209       close csr_name;
210       --
211       -- raise error as Name is not Unique
212       --
213       fnd_message.set_name('BEN','BEN_91009_NAME_NOT_UNIQUE');
214       fnd_message.raise_error;
215       --
216     end if;
217     --
218     close csr_name;
219     --
220   end if;
221   --
222   hr_utility.set_location('Leaving:'||l_proc, 20);
223   --
224 End chk_name;
225 --
226 
227 --
228 -- ----------------------------------------------------------------------------
229 -- |---------------------------< insert_validate >----------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure insert_validate(p_rec in ben_gos_shd.g_rec_type
232                          ,p_effective_date in date) is
233 --
234   l_proc  varchar2(72) := g_package||'insert_validate';
235 --
236 Begin
237   hr_utility.set_location('Entering:'||l_proc, 5);
238   --
239   -- Call all supporting business operations
240   --
241   --
242   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
243   --
244   chk_gd_or_svc_typ_id
245   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
246    p_object_version_number => p_rec.object_version_number);
247   --
248   chk_typ_cd
249   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
250    p_typ_cd         => p_rec.typ_cd,
251    p_effective_date        => p_effective_date,
252    p_object_version_number => p_rec.object_version_number);
253 --
254   chk_name
255   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
256    p_name                      => p_rec.name,
257    p_business_group_id         => p_rec.business_group_id,
258    p_object_version_number => p_rec.object_version_number);
259 --
260   hr_utility.set_location(' Leaving:'||l_proc, 10);
261 End insert_validate;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |---------------------------< update_validate >----------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure update_validate(p_rec in ben_gos_shd.g_rec_type
267                          ,p_effective_date in date) is
268 --
269   l_proc  varchar2(72) := g_package||'update_validate';
270 --
271 Begin
272   hr_utility.set_location('Entering:'||l_proc, 5);
273   --
274   -- Call all supporting business operations
275   --
276   --
277   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
278   --
279   chk_gd_or_svc_typ_id
280   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
281    p_object_version_number => p_rec.object_version_number);
282   --
283   chk_typ_cd
284   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
285    p_typ_cd         => p_rec.typ_cd,
286    p_effective_date        => p_effective_date,
287    p_object_version_number => p_rec.object_version_number);
288 --
289   chk_name
290   (p_gd_or_svc_typ_id          => p_rec.gd_or_svc_typ_id,
291    p_name                      => p_rec.name,
292    p_business_group_id         => p_rec.business_group_id,
293    p_object_version_number => p_rec.object_version_number);
294   --
295   hr_utility.set_location(' Leaving:'||l_proc, 10);
296 End update_validate;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |---------------------------< delete_validate >----------------------------|
300 -- ----------------------------------------------------------------------------
301 Procedure delete_validate(p_rec in ben_gos_shd.g_rec_type
302                          ,p_effective_date in date) is
303 --
304   l_proc  varchar2(72) := g_package||'delete_validate';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   -- Call all supporting business operations
310   --
311   hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End delete_validate;
313 --
314 --
315 --  ---------------------------------------------------------------------------
316 --  |---------------------< return_legislation_code >-------------------------|
317 --  ---------------------------------------------------------------------------
318 --
319 function return_legislation_code
320   (p_gd_or_svc_typ_id in number) return varchar2 is
321   --
322   -- Declare cursor
323   --
324   cursor csr_leg_code is
325     select a.legislation_code
326     from   per_business_groups a,
327            ben_gd_or_svc_typ b
328     where b.gd_or_svc_typ_id      = p_gd_or_svc_typ_id
329     and   a.business_group_id = b.business_group_id;
330   --
331   -- Declare local variables
332   --
333   l_legislation_code  varchar2(150);
334   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
335   --
336 begin
337   --
338   hr_utility.set_location('Entering:'|| l_proc, 10);
339   --
340   -- Ensure that all the mandatory parameter are not null
341   --
342   hr_api.mandatory_arg_error(p_api_name       => l_proc,
343                              p_argument       => 'gd_or_svc_typ_id',
344                              p_argument_value => p_gd_or_svc_typ_id);
345   --
346   open csr_leg_code;
347     --
348     fetch csr_leg_code into l_legislation_code;
349     --
350     if csr_leg_code%notfound then
351       --
352       close csr_leg_code;
353       --
354       -- The primary key is invalid therefore we must error
355       --
356       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
357       fnd_message.raise_error;
358       --
359     end if;
360     --
361   close csr_leg_code;
362   --
363   hr_utility.set_location(' Leaving:'|| l_proc, 20);
364   --
365   return l_legislation_code;
366   --
367 end return_legislation_code;
368 --
369 end ben_gos_bus;