DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPE_BUS

Source


1 Package Body ben_cpe_bus as
2 /* $Header: becperhi.pkb 120.0 2005/05/28 01:12:31 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_cpe_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_copy_entity_result_id       number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_copy_entity_result_id                in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   -- EDIT_HERE  In the following cursor statement add join(s) between
28   -- ben_copy_entity_results and PER_BUSINESS_GROUPS_PERF
29   -- so that the security_group_id for
30   -- the current business group context can be derived.
31   -- Remove this comment when the edit has been completed.
32   cursor csr_sec_grp is
33     select pbg.security_group_id,
34            pbg.legislation_code
35       from per_business_groups_perf pbg
36          , ben_copy_entity_results cpe
37       --   , EDIT_HERE table_name(s) 333
38      where cpe.copy_entity_result_id = p_copy_entity_result_id;
39       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
40   --
41   -- Declare local variables
42   --
43   l_security_group_id number;
44   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
45   l_legislation_code  varchar2(150);
46   --
47 begin
48   --
49   hr_utility.set_location('Entering:'|| l_proc, 10);
50   --
51   -- Ensure that all the mandatory parameter are not null
52   --
53   hr_api.mandatory_arg_error
54     (p_api_name           => l_proc
55     ,p_argument           => 'copy_entity_result_id'
56     ,p_argument_value     => p_copy_entity_result_id
57     );
58   --
59   open csr_sec_grp;
60   fetch csr_sec_grp into l_security_group_id
61                        , l_legislation_code;
62   --
63   if csr_sec_grp%notfound then
64      --
65      close csr_sec_grp;
66      --
67      -- The primary key is invalid therefore we must error
68      --
69      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
70      hr_multi_message.add
71        (p_associated_column1
72         => nvl(p_associated_column1,'COPY_ENTITY_RESULT_ID')
73        );
74      --
75   else
76     close csr_sec_grp;
77     --
78     -- Set the security_group_id in CLIENT_INFO
79     --
80     hr_api.set_security_group_id
81       (p_security_group_id => l_security_group_id
82       );
83     --
84     -- Set the sessions legislation context in HR_SESSION_DATA
85     --
86     hr_api.set_legislation_context(l_legislation_code);
87   end if;
88   --
89   hr_utility.set_location(' Leaving:'|| l_proc, 20);
90   --
91 end set_security_group_id;
92 --
93 --  ---------------------------------------------------------------------------
94 --  |---------------------< return_legislation_code >-------------------------|
95 --  ---------------------------------------------------------------------------
96 --
97 Function return_legislation_code
98   (p_copy_entity_result_id                in     number
99   )
100   Return Varchar2 Is
101   --
102   -- Declare cursor
103   --
104   -- EDIT_HERE  In the following cursor statement add join(s) between
105   -- ben_copy_entity_results and PER_BUSINESS_GROUPS_PERF
106   -- so that the legislation_code for
107   -- the current business group context can be derived.
108   -- Remove this comment when the edit has been completed.
109   cursor csr_leg_code is
110     select pbg.legislation_code
111       from per_business_groups_perf     pbg
112          , ben_copy_entity_results cpe
113       --   , EDIT_HERE table_name(s) 333
114      where cpe.copy_entity_result_id = p_copy_entity_result_id;
115       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
116   --
117   -- Declare local variables
118   --
119   l_legislation_code  varchar2(150);
120   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
121   --
122 Begin
123   --
124   hr_utility.set_location('Entering:'|| l_proc, 10);
125   --
126   -- Ensure that all the mandatory parameter are not null
127   --
128   hr_api.mandatory_arg_error
129     (p_api_name           => l_proc
130     ,p_argument           => 'copy_entity_result_id'
131     ,p_argument_value     => p_copy_entity_result_id
132     );
133   --
134   if ( nvl(ben_cpe_bus.g_copy_entity_result_id, hr_api.g_number)
135        = p_copy_entity_result_id) then
136     --
137     -- The legislation code has already been found with a previous
138     -- call to this function. Just return the value in the global
139     -- variable.
140     --
141     l_legislation_code := ben_cpe_bus.g_legislation_code;
142     hr_utility.set_location(l_proc, 20);
143   else
144     --
145     -- The ID is different to the last call to this function
146     -- or this is the first call to this function.
147     --
148     open csr_leg_code;
149     fetch csr_leg_code into l_legislation_code;
150     --
151     if csr_leg_code%notfound then
152       --
153       -- The primary key is invalid therefore we must error
154       --
155       close csr_leg_code;
156       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
157       fnd_message.raise_error;
158     end if;
159     hr_utility.set_location(l_proc,30);
160     --
161     -- Set the global variables so the values are
162     -- available for the next call to this function.
163     --
164     close csr_leg_code;
165     ben_cpe_bus.g_copy_entity_result_id       := p_copy_entity_result_id;
166     ben_cpe_bus.g_legislation_code  := l_legislation_code;
167   end if;
168   hr_utility.set_location(' Leaving:'|| l_proc, 40);
169   return l_legislation_code;
170 end return_legislation_code;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |-----------------------< chk_non_updateable_args >------------------------|
174 -- ----------------------------------------------------------------------------
175 -- {Start Of Comments}
176 --
177 -- Description:
178 --   This procedure is used to ensure that non updateable attributes have
179 --   not been updated. If an attribute has been updated an error is generated.
180 --
181 -- Pre Conditions:
182 --   g_old_rec has been populated with details of the values currently in
183 --   the database.
184 --
185 -- In Arguments:
186 --   p_rec has been populated with the updated values the user would like the
187 --   record set to.
188 --
189 -- Post Success:
190 --   Processing continues if all the non updateable attributes have not
191 --   changed.
192 --
193 -- Post Failure:
194 --   An application error is raised if any of the non updatable attributes
195 --   have been altered.
196 --
197 -- {End Of Comments}
198 -- ----------------------------------------------------------------------------
199 Procedure chk_non_updateable_args
200   (p_effective_date               in date
201   ,p_rec in ben_cpe_shd.g_rec_type
202   ) IS
203 --
204   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
205 --
206 Begin
207   --
208   -- Only proceed with the validation if a row exists for the current
209   -- record in the HR Schema.
210   --
211   IF NOT ben_cpe_shd.api_updating
212       (p_copy_entity_result_id             => p_rec.copy_entity_result_id
213       ,p_object_version_number             => p_rec.object_version_number
214       ) THEN
215      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
216      fnd_message.set_token('PROCEDURE ', l_proc);
217      fnd_message.set_token('STEP ', '5');
218      fnd_message.raise_error;
219   END IF;
220   --
221   -- EDIT_HERE: Add checks to ensure non-updateable args have
222   --            not been updated.
223   --
224 End chk_non_updateable_args;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |---------------------------< insert_validate >----------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure insert_validate
230   (p_effective_date               in date
231   ,p_rec                          in ben_cpe_shd.g_rec_type
232   ) 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   -- EDIT_HERE: As this table does not have a mandatory business_group_id
243   -- column, ensure client_info is populated by calling a suitable
244   -- ???_???_bus.set_security_group_id procedure, or add one of the following
245   -- comments:
246   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
247   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
248   --
249   -- Validate Dependent Attributes
250   --
251   --
252   hr_utility.set_location(' Leaving:'||l_proc, 10);
253 End insert_validate;
254 --
255 -- ----------------------------------------------------------------------------
256 -- |---------------------------< update_validate >----------------------------|
257 -- ----------------------------------------------------------------------------
258 Procedure update_validate
259   (p_effective_date               in date
260   ,p_rec                          in ben_cpe_shd.g_rec_type
261   ) is
262 --
263   l_proc  varchar2(72) := g_package||'update_validate';
264 --
265 Begin
266   hr_utility.set_location('Entering:'||l_proc, 5);
267   --
268   -- Call all supporting business operations
269   --
270   --
271   -- EDIT_HERE: As this table does not have a mandatory business_group_id
272   -- column, ensure client_info is populated by calling a suitable
273   -- ???_???_bus.set_security_group_id procedure, or add one of the following
274   -- comments:
275   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
276   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
277   --
278   -- Validate Dependent Attributes
279   --
280   chk_non_updateable_args
281     (p_effective_date              => p_effective_date
282       ,p_rec              => p_rec
283     );
284   --
285   --
286   hr_utility.set_location(' Leaving:'||l_proc, 10);
287 End update_validate;
288 --
289 -- ----------------------------------------------------------------------------
290 -- |---------------------------< delete_validate >----------------------------|
291 -- ----------------------------------------------------------------------------
292 Procedure delete_validate
293   (p_rec                          in ben_cpe_shd.g_rec_type
294   ) is
295 --
296   l_proc  varchar2(72) := g_package||'delete_validate';
297 --
298 Begin
299   hr_utility.set_location('Entering:'||l_proc, 5);
300   --
301   -- Call all supporting business operations
302   --
303   hr_utility.set_location(' Leaving:'||l_proc, 10);
304 End delete_validate;
305 --
306 end ben_cpe_bus;