DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_RTS_BUS

Source


1 Package Body ben_rts_bus as
2 /* $Header: bertsrhi.pkb 120.1 2006/01/09 14:37 maagrawa noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_rts_bus.';  -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- The following two global variables are only to be
12 -- used by the return_legislation_code function.
13 --
14 g_legislation_code            varchar2(150)  default null;
15 g_group_per_in_ler_id         number         default null;
16 g_pl_id                       number         default null;
17 g_oipl_id                     number         default null;
18 /* Commenting the following procedures thinking that they are not required.
19    If these are required, this could should be un-commented and modified
20    to fetch the right values.
21 --
22 --  ---------------------------------------------------------------------------
23 --  |----------------------< set_security_group_id >--------------------------|
24 --  ---------------------------------------------------------------------------
25 --
26 Procedure set_security_group_id
27   (p_group_per_in_ler_id                  in number
28   ,p_pl_id                                in number
29   ,p_oipl_id                              in number
30   ,p_associated_column1                   in varchar2 default null
31   ,p_associated_column2                   in varchar2 default null
32   ,p_associated_column3                   in varchar2 default null
33   ) is
34   --
35   -- Declare cursor
36   --
37   -- EDIT_HERE  In the following cursor statement add join(s) between
38   -- ben_cwb_person_rates and PER_BUSINESS_GROUPS_PERF
39   -- so that the security_group_id for
40   -- the current business group context can be derived.
41   -- Remove this comment when the edit has been completed.
42   cursor csr_sec_grp is
43     select pbg.security_group_id,
44            pbg.legislation_code
45       from per_business_groups_perf pbg
46          , ben_cwb_person_rates rts
50        and rts.oipl_id = p_oipl_id;
47       --   , EDIT_HERE table_name(s) 333
48      where rts.group_per_in_ler_id = p_group_per_in_ler_id
49        and rts.pl_id = p_pl_id
51       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
52   --
53   -- Declare local variables
54   --
55   l_security_group_id number;
56   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
57   l_legislation_code  varchar2(150);
58   --
59 begin
60   --
61   hr_utility.set_location('Entering:'|| l_proc, 10);
62   --
63   -- Ensure that all the mandatory parameter are not null
64   --
65  hr_api.mandatory_arg_error
66     (p_api_name           => l_proc
67     ,p_argument           => 'group_per_in_ler_id'
68     ,p_argument_value     => p_group_per_in_ler_id
69     );
70   hr_api.mandatory_arg_error
71     (p_api_name           => l_proc
72     ,p_argument           => 'pl_id'
73     ,p_argument_value     => p_pl_id
74     );
75   hr_api.mandatory_arg_error
76     (p_api_name           => l_proc
77     ,p_argument           => 'oipl_id'
78     ,p_argument_value     => p_oipl_id
79     );
80   --
81   open csr_sec_grp;
82   fetch csr_sec_grp into l_security_group_id
83                        , l_legislation_code;
84   --
85   if csr_sec_grp%notfound then
86      --
87      close csr_sec_grp;
88      --
89      -- The primary key is invalid therefore we must error
90      --
91      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
92      hr_multi_message.add
93        (p_associated_column1
94         => nvl(p_associated_column1,'GROUP_PER_IN_LER_ID')
95       ,p_associated_column2
96         => nvl(p_associated_column2,'PL_ID')
97       ,p_associated_column3
98         => nvl(p_associated_column3,'OIPL_ID')
99        );
100      --
101   else
102     close csr_sec_grp;
103     --
104     -- Set the security_group_id in CLIENT_INFO
105     --
106     hr_api.set_security_group_id
107       (p_security_group_id => l_security_group_id
108       );
109     --
110     -- Set the sessions legislation context in HR_SESSION_DATA
111     --
112     hr_api.set_legislation_context(l_legislation_code);
113   end if;
114   --
115   hr_utility.set_location(' Leaving:'|| l_proc, 20);
116   --
117 end set_security_group_id;
118 --
119 --  ---------------------------------------------------------------------------
120 --  |---------------------< return_legislation_code >-------------------------|
121 --  ---------------------------------------------------------------------------
122 --
123 Function return_legislation_code
124   (p_group_per_in_ler_id                  in     number
125   ,p_pl_id                                in     number
126   ,p_oipl_id                              in     number
127   )
128   Return Varchar2 Is
129   --
130   -- Declare cursor
131   --
132   -- EDIT_HERE  In the following cursor statement add join(s) between
133   -- ben_cwb_person_rates and PER_BUSINESS_GROUPS_PERF
134   -- so that the legislation_code for
135   -- the current business group context can be derived.
136   -- Remove this comment when the edit has been completed.
137   cursor csr_leg_code is
138     select pbg.legislation_code
139       from per_business_groups_perf     pbg
140          , ben_cwb_person_rates rts
141       --   , EDIT_HERE table_name(s) 333
142      where rts.group_per_in_ler_id = p_group_per_in_ler_id
143        and rts.pl_id = p_pl_id
144        and rts.oipl_id = p_oipl_id;
145       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
146   --
147   -- Declare local variables
148   --
149   l_legislation_code  varchar2(150);
150   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
151   --
152 Begin
153   --
154   hr_utility.set_location('Entering:'|| l_proc, 10);
155   --
156   -- Ensure that all the mandatory parameter are not null
157   --
158   hr_api.mandatory_arg_error
159     (p_api_name           => l_proc
160     ,p_argument           => 'group_per_in_ler_id'
161     ,p_argument_value     => p_group_per_in_ler_id
162     );
163   hr_api.mandatory_arg_error
164     (p_api_name           => l_proc
165     ,p_argument           => 'pl_id'
166     ,p_argument_value     => p_pl_id
167     );
168   hr_api.mandatory_arg_error
169     (p_api_name           => l_proc
170     ,p_argument           => 'oipl_id'
171     ,p_argument_value     => p_oipl_id
172     );
173   --
174   if (( nvl(ben_rts_bus.g_group_per_in_ler_id, hr_api.g_number)
175        = p_group_per_in_ler_id)
176   and ( nvl(ben_rts_bus.g_pl_id, hr_api.g_number)
177        = p_pl_id)
178   and ( nvl(ben_rts_bus.g_oipl_id, hr_api.g_number)
179        = p_oipl_id)) then
180     --
181     -- The legislation code has already been found with a previous
182     -- call to this function. Just return the value in the global
183     -- variable.
184     --
185     l_legislation_code := ben_rts_bus.g_legislation_code;
186     hr_utility.set_location(l_proc, 20);
187   else
188     --
189     -- The ID is different to the last call to this function
190     -- or this is the first call to this function.
191     --
192     open csr_leg_code;
193     fetch csr_leg_code into l_legislation_code;
194     --
195     if csr_leg_code%notfound then
196       --
197       -- The primary key is invalid therefore we must error
198       --
199       close csr_leg_code;
200       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
201       fnd_message.raise_error;
202     end if;
203     hr_utility.set_location(l_proc,30);
204     --
208     close csr_leg_code;
205     -- Set the global variables so the values are
206     -- available for the next call to this function.
207     --
209     ben_rts_bus.g_group_per_in_ler_id         := p_group_per_in_ler_id;
210     ben_rts_bus.g_pl_id                       := p_pl_id;
211     ben_rts_bus.g_oipl_id                     := p_oipl_id;
212     ben_rts_bus.g_legislation_code  := l_legislation_code;
213   end if;
214   hr_utility.set_location(' Leaving:'|| l_proc, 40);
215   return l_legislation_code;
216 end return_legislation_code;
217      End of commented code. */
218 --
219 -- ----------------------------------------------------------------------------
220 -- |-----------------------< chk_non_updateable_args >------------------------|
221 -- ----------------------------------------------------------------------------
222 -- {Start Of Comments}
223 --
224 -- Description:
225 --   This procedure is used to ensure that non updateable attributes have
226 --   not been updated. If an attribute has been updated an error is generated.
227 --
228 -- Pre Conditions:
229 --   g_old_rec has been populated with details of the values currently in
230 --   the database.
231 --
232 -- In Arguments:
233 --   p_rec has been populated with the updated values the user would like the
234 --   record set to.
235 --
236 -- Post Success:
237 --   Processing continues if all the non updateable attributes have not
238 --   changed.
239 --
240 -- Post Failure:
241 --   An application error is raised if any of the non updatable attributes
242 --   have been altered.
243 --
244 -- {End Of Comments}
245 -- ----------------------------------------------------------------------------
246 Procedure chk_non_updateable_args
247   (p_rec in ben_rts_shd.g_rec_type
248   ) IS
249 --
250   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
251 --
252 Begin
253   --
254   -- Only proceed with the validation if a row exists for the current
255   -- record in the HR Schema.
256   --
257   IF NOT ben_rts_shd.api_updating
258       (p_group_per_in_ler_id               => p_rec.group_per_in_ler_id
259       ,p_pl_id                             => p_rec.pl_id
260       ,p_oipl_id                           => p_rec.oipl_id
261       ,p_object_version_number             => p_rec.object_version_number
262       ) THEN
263      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
264      fnd_message.set_token('PROCEDURE ', l_proc);
265      fnd_message.set_token('STEP ', '5');
266      fnd_message.raise_error;
267   END IF;
268   --
269   if nvl(p_rec.group_per_in_ler_id, hr_api.g_number) <>
270                                 ben_rts_shd.g_old_rec.group_per_in_ler_id then
271       hr_api.argument_changed_error
272       (p_api_name => l_proc
273       ,p_argument => 'GROUP_PER_IN_LER_ID'
274       ,p_base_table => ben_rts_shd.g_tab_nam
275       );
276   end if;
277   --
278   if nvl(p_rec.pl_id, hr_api.g_number) <>
279                                 ben_rts_shd.g_old_rec.pl_id then
280       hr_api.argument_changed_error
281       (p_api_name => l_proc
282       ,p_argument => 'PL_ID'
283       ,p_base_table => ben_rts_shd.g_tab_nam
284       );
285   end if;
286   --
287   if nvl(p_rec.oipl_id, hr_api.g_number) <>
288                                 ben_rts_shd.g_old_rec.oipl_id then
289       hr_api.argument_changed_error
290       (p_api_name => l_proc
291       ,p_argument => 'OIPL_ID'
292       ,p_base_table => ben_rts_shd.g_tab_nam
293       );
294   end if;
295   --
296 End chk_non_updateable_args;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |---------------------------< insert_validate >----------------------------|
300 -- ----------------------------------------------------------------------------
301 Procedure insert_validate
302   (p_rec                          in ben_rts_shd.g_rec_type
303   ) is
304 --
305   l_proc  varchar2(72) := g_package||'insert_validate';
306 --
307 Begin
308   if g_debug then
309      hr_utility.set_location('Entering:'||l_proc, 5);
310   end if;
311   --
312   -- No validations are required.
313   --
314   if g_debug then
315      hr_utility.set_location(' Leaving:'||l_proc, 10);
316   end if;
317 End insert_validate;
318 --
319 -- ----------------------------------------------------------------------------
320 -- |---------------------------< update_validate >----------------------------|
321 -- ----------------------------------------------------------------------------
322 Procedure update_validate
323   (p_rec                          in ben_rts_shd.g_rec_type
324   ) is
325 --
326   l_proc  varchar2(72) := g_package||'update_validate';
327 --
328 Begin
329   if g_debug then
330      hr_utility.set_location('Entering:'||l_proc, 5);
331   end if;
332   --
333   chk_non_updateable_args
334     (p_rec              => p_rec
335     );
336   --
337   --
338   if g_debug then
339      hr_utility.set_location(' Leaving:'||l_proc, 10);
340   end if;
341 End update_validate;
342 --
343 -- ----------------------------------------------------------------------------
344 -- |---------------------------< delete_validate >----------------------------|
345 -- ----------------------------------------------------------------------------
346 Procedure delete_validate
347   (p_rec                          in ben_rts_shd.g_rec_type
348   ) is
349 --
353   if g_debug then
350   l_proc  varchar2(72) := g_package||'delete_validate';
351 --
352 Begin
354      hr_utility.set_location('Entering:'||l_proc, 5);
355   end if;
356   --
357   -- No validations required
358   --
359   if g_debug then
360      hr_utility.set_location(' Leaving:'||l_proc, 10);
361   end if;
362 End delete_validate;
363 --
364 end ben_rts_bus;