DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_APS_BUS

Source


1 Package Body irc_aps_bus as
2 /* $Header: irapsrhi.pkb 120.0.12000000.1 2007/03/23 11:45:59 vboggava noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_aps_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_profile_snapshot_id         number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_profile_snapshot_id                  in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id,
29            pbg.legislation_code
30       from per_business_groups_perf pbg
31          , irc_apl_profile_snapshots aps
32          , per_all_assignments_f  paf
33      where aps.profile_snapshot_id = p_profile_snapshot_id
34      and   paf.person_id           = aps.person_id
35      and   pbg.business_group_id   = paf.business_group_id;
36   --
37   -- Declare local variables
38   --
39   l_security_group_id number;
40   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
41   l_legislation_code  varchar2(150);
42   --
43 begin
44   --
45   hr_utility.set_location('Entering:'|| l_proc, 10);
46   --
47   -- Ensure that all the mandatory parameter are not null
48   --
49   hr_api.mandatory_arg_error
50     (p_api_name           => l_proc
51     ,p_argument           => 'profile_snapshot_id'
52     ,p_argument_value     => p_profile_snapshot_id
53     );
54   --
55   open csr_sec_grp;
56   fetch csr_sec_grp into l_security_group_id
57                        , l_legislation_code;
58   --
59   if csr_sec_grp%notfound then
60      --
61      close csr_sec_grp;
62      --
63      -- The primary key is invalid therefore we must error
64      --
65      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
66      hr_multi_message.add
67        (p_associated_column1
68         => nvl(p_associated_column1,'PROFILE_SNAPSHOT_ID')
69        );
70      --
71   else
72     close csr_sec_grp;
73     --
74     -- Set the security_group_id in CLIENT_INFO
75     --
76     hr_api.set_security_group_id
77       (p_security_group_id => l_security_group_id
78       );
79     --
80     -- Set the sessions legislation context in HR_SESSION_DATA
81     --
82     hr_api.set_legislation_context(l_legislation_code);
83   end if;
84   --
85   hr_utility.set_location(' Leaving:'|| l_proc, 20);
86   --
87 end set_security_group_id;
88 --
89 --  ---------------------------------------------------------------------------
90 --  |---------------------< return_legislation_code >-------------------------|
91 --  ---------------------------------------------------------------------------
92 --
93 Function return_legislation_code
94   (p_profile_snapshot_id                  in     number
95   )
96   Return Varchar2 Is
97   --
98   -- Declare cursor
99   --
100   cursor csr_leg_code is
101     select pbg.legislation_code
102       from per_business_groups_perf     pbg
103          , irc_apl_profile_snapshots	aps
104          , per_all_assignments_f	paf
105      where aps.profile_snapshot_id = p_profile_snapshot_id
106      and  paf.person_id		   = aps.person_id
107      and  pbg.business_group_id    = paf.business_group_id;
108   --
109   -- Declare local variables
110   --
111   l_legislation_code  varchar2(150);
112   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'|| l_proc, 10);
117   --
118   -- Ensure that all the mandatory parameter are not null
119   --
120   hr_api.mandatory_arg_error
121     (p_api_name           => l_proc
122     ,p_argument           => 'profile_snapshot_id'
123     ,p_argument_value     => p_profile_snapshot_id
124     );
125   --
126   if ( nvl(irc_aps_bus.g_profile_snapshot_id, hr_api.g_number)
127        = p_profile_snapshot_id) then
128     --
129     -- The legislation code has already been found with a previous
130     -- call to this function. Just return the value in the global
131     -- variable.
132     --
133     l_legislation_code := irc_aps_bus.g_legislation_code;
134     hr_utility.set_location(l_proc, 20);
135   else
136     --
137     -- The ID is different to the last call to this function
138     -- or this is the first call to this function.
139     --
140     open csr_leg_code;
141     fetch csr_leg_code into l_legislation_code;
142     --
143     if csr_leg_code%notfound then
144       --
145       -- The primary key is invalid therefore we must error
146       --
147       close csr_leg_code;
148       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
149       fnd_message.raise_error;
150     end if;
151     hr_utility.set_location(l_proc,30);
152     --
153     -- Set the global variables so the values are
154     -- available for the next call to this function.
155     --
156     close csr_leg_code;
157     irc_aps_bus.g_profile_snapshot_id         := p_profile_snapshot_id;
158     irc_aps_bus.g_legislation_code  := l_legislation_code;
159   end if;
160   hr_utility.set_location(' Leaving:'|| l_proc, 40);
161   return l_legislation_code;
162 end return_legislation_code;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |-----------------------< chk_non_updateable_args >------------------------|
166 -- ----------------------------------------------------------------------------
167 -- {Start Of Comments}
168 --
169 -- Description:
170 --   This procedure is used to ensure that non updateable attributes have
171 --   not been updated. If an attribute has been updated an error is generated.
172 --
173 -- Pre Conditions:
174 --   g_old_rec has been populated with details of the values currently in
175 --   the database.
176 --
177 -- In Arguments:
178 --   p_rec has been populated with the updated values the user would like the
179 --   record set to.
180 --
181 -- Post Success:
182 --   Processing continues if all the non updateable attributes have not
183 --   changed.
184 --
185 -- Post Failure:
186 --   An application error is raised if any of the non updatable attributes
187 --   have been altered.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure chk_non_updateable_args
192   (p_effective_date               in date
193   ,p_rec in irc_aps_shd.g_rec_type
194   ) IS
195 --
196   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
197 --
198 Begin
199   --
200   -- Only proceed with the validation if a row exists for the current
201   -- record in the HR Schema.
202   --
203   IF NOT irc_aps_shd.api_updating
204       (p_profile_snapshot_id               => p_rec.profile_snapshot_id
205       ,p_object_version_number             => p_rec.object_version_number
206       ) THEN
207      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
208      fnd_message.set_token('PROCEDURE ', l_proc);
209      fnd_message.set_token('STEP ', '5');
210      fnd_message.raise_error;
211   END IF;
212   --
213   -- EDIT_HERE: Add checks to ensure non-updateable args have
214   --            not been updated.
215   --
216 End chk_non_updateable_args;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |---------------------------< chk_person_id >-----------------------------|
220 -- ----------------------------------------------------------------------------
221 --
222 -- Description:
223 --   Verifies that the person_id exists in PER_ALL_PEOPLE_F.
224 --
225 -- Prerequisites:
226 --   Must be called as the first step in insert_validate.
227 --
228 -- In Arguments:
229 --   p_person_id
230 --
231 -- Post Success:
232 --   If person_id exists in PER_ALL_PEOPLE_F, then continue.
233 --
234 -- Post Failure:
235 --   If the person_id does not exists in PER_ALL_PEOPLE_F, then throw
236 --   an error indicating the same.
237 --
238 -- Access Status:
239 --   Internal Row Handler Use Only.
240 --
241 -- ----------------------------------------------------------------------------
242 procedure chk_person_id
243   (p_person_id             in  number
244   ,p_profile_snapshot_id   in
245                     irc_apl_profile_snapshots.profile_snapshot_id%TYPE
246   ,p_object_version_number  in
247                     irc_apl_profile_snapshots.object_version_number%TYPE
248   )
249 IS
250 --
251   l_proc              varchar2(72)  :=  g_package||'chk_person_id';
252   l_api_updating      boolean;
253   l_dummy             varchar2(1);
254   --
255   cursor person_exists(p_person_id number) is
256     select null
257     from per_all_people_f
258     where person_id = p_person_id;
259   --
260 Begin
261   --
262   hr_utility.set_location('Entering:'|| l_proc, 10);
263   --
264   l_api_updating := irc_aps_shd.api_updating
265   (p_profile_snapshot_id => p_profile_snapshot_id
266   ,p_object_version_number  => p_object_version_number
267   );
268   --
269   if ((l_api_updating and
270        nvl(irc_aps_shd.g_old_rec.person_id, hr_api.g_number) <>
271           nvl(p_person_id, hr_api.g_number)) or
272       (NOT l_api_updating)) then
273     hr_utility.set_location(l_proc, 20);
274     --
275     -- Check if p_person_id is not null
276     --
277     if p_person_id IS NOT NULL then
278       --
279       -- p_person_id must exist in PER_ALL_PEOPLE_F
280       --
281       open person_exists(p_person_id);
282       fetch person_exists into l_dummy;
283       --
284       if person_exists%notfound then
285         close person_exists;
286         hr_utility.set_location(l_proc, 30);
287         fnd_message.set_name('PER', 'IRC_412233_INV_OTA_ATTEMPT');
288         fnd_message.raise_error;
289       else
290         close person_exists;
291       end if;
292       --
293     end if;
294   end if;
295   hr_utility.set_location('Leaving: '||l_proc, 50);
296   exception
297     when app_exception.application_exception then
298       if hr_multi_message.exception_add
299         (p_associated_column1      => 'IRC_APL_PROFILE_SNAPSHOTS.PERSON_ID'
300         ) then
301         raise;
302       end if;
303 end chk_person_id;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------< insert_validate >----------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure insert_validate
309   (p_effective_date               in date
310   ,p_rec                          in irc_aps_shd.g_rec_type
311   ) is
312 --
313   l_proc  varchar2(72) := g_package||'insert_validate';
314 --
315 Begin
316   hr_utility.set_location('Entering:'||l_proc, 5);
317   --
318   -- Call all supporting business operations
319   --
320   --
321   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
322   --
323   -- Validate Dependent Attributes
324   --
325   chk_person_id
326   (p_person_id			=> p_rec.person_id
327   ,p_profile_snapshot_id	=> p_rec.profile_snapshot_id
328   ,p_object_version_number	=> p_rec.object_version_number
329   );
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End insert_validate;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------< update_validate >----------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure update_validate
338   (p_effective_date               in date
339   ,p_rec                          in irc_aps_shd.g_rec_type
340   ) is
341 --
342   l_proc  varchar2(72) := g_package||'update_validate';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call all supporting business operations
348   --
349   --
350   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
351   --
352   -- Validate Dependent Attributes
353   --
354   chk_non_updateable_args
355     (p_effective_date              => p_effective_date
356       ,p_rec              => p_rec
357     );
358   --
359   hr_utility.set_location(' Leaving:'||l_proc, 10);
360   --
361   chk_person_id
362   (p_person_id			=> p_rec.person_id
363   ,p_profile_snapshot_id	=> p_rec.profile_snapshot_id
364   ,p_object_version_number	=> p_rec.object_version_number
365   );
366   --
367   hr_utility.set_location(' Leaving:'||l_proc, 20);
368 End update_validate;
369 --
370 -- ----------------------------------------------------------------------------
371 -- |---------------------------< delete_validate >----------------------------|
372 -- ----------------------------------------------------------------------------
373 Procedure delete_validate
374   (p_rec                          in irc_aps_shd.g_rec_type
375   ) is
376 --
377   l_proc  varchar2(72) := g_package||'delete_validate';
378 --
379 Begin
380   hr_utility.set_location('Entering:'||l_proc, 5);
381   --
382   -- Call all supporting business operations
383   --
384   hr_utility.set_location(' Leaving:'||l_proc, 10);
385 End delete_validate;
386 --
387 end irc_aps_bus;