DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPD_BUS

Source


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