DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_AMO_BUS

Source


1 Package Body pay_amo_bus as
2 /* $Header: pyamorhi.pkb 120.0.12000000.1 2007/01/17 15:29:33 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33);  -- 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_module_id                   number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_module_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          , pay_au_modules amo
32      where amo.module_id = p_module_id
33        and pbg.business_group_id (+) = amo.business_group_id;
34   --
35   -- Declare local variables
36   --
37   l_security_group_id number;
38   l_proc              varchar2(72);
39   l_legislation_code  varchar2(150);
40   --
41 begin
42   --
43   l_proc :=  g_package||'set_security_group_id';
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           => 'module_id'
52     ,p_argument_value     => p_module_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,'MODULE_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_module_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          , pay_au_modules amo
104      where amo.module_id = p_module_id
105        and pbg.business_group_id (+) = amo.business_group_id;
106   --
107   -- Declare local variables
108   --
109   l_legislation_code  varchar2(150);
110   l_proc              varchar2(72);
111   --
112 Begin
113   --
114   l_proc :=  g_package||'return_legislation_code';
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           => 'module_id'
123     ,p_argument_value     => p_module_id
124     );
125   --
126   if ( nvl(pay_amo_bus.g_module_id, hr_api.g_number)
127        = p_module_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 := pay_amo_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     pay_amo_bus.g_module_id                   := p_module_id;
158     pay_amo_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_rec in pay_amo_shd.g_rec_type
193   ) IS
194 --
195   l_proc     varchar2(72);
196 --
197 Begin
198   --
199   l_proc := g_package || 'chk_non_updateable_args';
200   --
201   -- Only proceed with the validation if a row exists for the current
202   -- record in the HR Schema.
203   --
204   IF NOT pay_amo_shd.api_updating
205       (p_module_id                         => p_rec.module_id
206       ,p_object_version_number             => p_rec.object_version_number
207       ) THEN
208      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
209      fnd_message.set_token('PROCEDURE ', l_proc);
210      fnd_message.set_token('STEP ', '5');
211      fnd_message.raise_error;
212   END IF;
213   --
214   -- EDIT_HERE: Add checks to ensure non-updateable args have
215   --            not been updated.
216   --
217 End chk_non_updateable_args;
218 --
219 -- ---------------------------------------------------------------------------
220 -- |---------------------< chk_legislation_code >----------------------------|
221 -- ---------------------------------------------------------------------------
222 PROCEDURE chk_legislation_code
223   (p_legislation_code                  in     varchar2
224   ) IS
225   l_proc     varchar2(72);
226 --
227 Begin
228   --
229   l_proc := g_package || 'chk_legislation_code';
230   --
231   -- Only proceed with the validation if a row exists for the current
232   -- record in the HR Schema.
233   -- To check if the legislation is 'AU' or 'NZ'
234   if p_legislation_code is null then
235     fnd_message.set_name('PAY', 'HR_AU_MISSING_LEGISLATION_CODE');
236     fnd_message.raise_error;
237   end if;
238   --
239   if not (p_legislation_code = 'AU' or p_legislation_code = 'NZ') then
240     fnd_message.set_name('PAY', 'PAY_33177_LEG_CODE_INVALID');
241     fnd_message.raise_error;
242   end if;
243   --
244 End chk_legislation_code;
245 --
246 -- ---------------------------------------------------------------------------
247 -- |---------------------< chk_business_group_id >---------------------------|
248 -- ---------------------------------------------------------------------------
249 -- {Start Of Comments}
250 --
251 --  Description:
252 --    Check the business group id existl for choosen legislation code
253 --
254 --  Prerequisites:
255 --
256 --  In Arguments:
257 --    p_legislation_code
258 --    p_business_group_id
259 --
260 --
261 --  Post Success:
262 --    processing continues as no error is raised.
263 --
264 --  Post Failure:
265 --    An error is raised if mismatch the legislation code  and business group id
266 --
267 --  Access Status:
268 --    Internal Development Use Only.
269 --
270 -- {End Of Comments}
271 -- ---------------------------------------------------------------------------
272 PROCEDURE chk_business_group_id
273   (p_legislation_code                  in     varchar2
274   ,p_business_group_id                 in     number
275   ) IS
276 --
277   l_proc          varchar2(72);
278   l_dummy_number  number;
279 --
280   cursor csr_valid_bgd_leg(
281                      p_leg_code   varchar2,
282                      p_bg_id      number) is
283   select 1
284   from per_business_groups pbg
285   where pbg.business_group_id = p_bg_id
286   and   pbg.legislation_code  = p_leg_code;
287 --
288 Begin
289   l_proc := g_package || 'chk_business_group_id';
290   --
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   if p_business_group_id is not null then
294     open csr_valid_bgd_leg(p_legislation_code,
295                            p_business_group_id);
296     fetch csr_valid_bgd_leg into l_dummy_number;
297     --
298     if csr_valid_bgd_leg%notfound then
299       --
300       --
301       close csr_valid_bgd_leg;
302       fnd_message.set_name('PAY','HR_33586_INVALID_BG_LEG_COMBI');
303       fnd_message.raise_error;
304     end if;
305     --
306     --
307   end if;
308   --
309   hr_utility.set_location(' Leaving:'||l_proc, 10);
310 End chk_business_group_id;
311 --
312 --
313 -- ----------------------------------------------------------------------------
314 -- |---------------------------< insert_validate >----------------------------|
315 -- ----------------------------------------------------------------------------
316 Procedure insert_validate
317   (p_rec                          in pay_amo_shd.g_rec_type
318   ) is
319 --
320   l_proc  varchar2(72);
321 --
322 Begin
323   l_proc := g_package||'insert_validate';
324   --
325   hr_utility.set_location('Entering:'||l_proc, 5);
326   --
327   -- Call all supporting business operations
328   --
329   chk_legislation_code(p_rec.legislation_code);
330   chk_business_group_id(p_rec.legislation_code,
331                         p_rec.business_group_id);
332   --
333   --
334   -- Validate Dependent Attributes
335   --
336   --
337   hr_utility.set_location(' Leaving:'||l_proc, 10);
338 End insert_validate;
339 --
340 -- ----------------------------------------------------------------------------
341 -- |---------------------------< update_validate >----------------------------|
342 -- ----------------------------------------------------------------------------
343 Procedure update_validate
344   (p_rec                          in pay_amo_shd.g_rec_type
345   ) is
346 --
347   l_proc  varchar2(72);
348 --
349 Begin
350   l_proc := g_package||'update_validate';
351   --
352   hr_utility.set_location('Entering:'||l_proc, 5);
353   --
354   -- Call all supporting business operations
355   --
356   --
357   chk_legislation_code(p_rec.legislation_code);
358   chk_business_group_id(p_rec.legislation_code,
359                         p_rec.business_group_id);
360   --
361   -- Validate Dependent Attributes
362   --
363   chk_non_updateable_args
364     (p_rec              => p_rec
365     );
366   --
367   --
368   hr_utility.set_location(' Leaving:'||l_proc, 10);
369 End update_validate;
370 --
371 -- ----------------------------------------------------------------------------
372 -- |---------------------------< delete_validate >----------------------------|
373 -- ----------------------------------------------------------------------------
374 Procedure delete_validate
375   (p_rec                          in pay_amo_shd.g_rec_type
376   ) is
377 --
378   l_proc  varchar2(72);
379 --
380 Begin
381   l_proc := g_package||'delete_validate';
382   --
383   hr_utility.set_location('Entering:'||l_proc, 5);
384   --
385   --
386   -- Call all supporting business operations
387   --
388   hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End delete_validate;
390 --
391 begin
392   g_package := '  pay_amo_bus.';  -- Global package name
393 end pay_amo_bus;