DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_APR_BUS

Source


1 Package Body pay_apr_bus as
2 /* $Header: pyaprrhi.pkb 120.0.12000000.1 2007/01/17 15:39:22 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_process_id                  number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_process_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_processes apr
32      where apr.process_id = p_process_id
33        and pbg.business_group_id (+) = apr.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           => 'process_id'
52     ,p_argument_value     => p_process_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,'PROCESS_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_process_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_processes apr
104      where apr.process_id = p_process_id
105        and pbg.business_group_id (+) = apr.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           => 'process_id'
123     ,p_argument_value     => p_process_id
124     );
125   --
126   if ( nvl(pay_apr_bus.g_process_id, hr_api.g_number)
127        = p_process_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_apr_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_apr_bus.g_process_id                  := p_process_id;
158     pay_apr_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 -- ----------------------------------------------------------------------------
166 -- |-----------------------< chk_non_updateable_args >------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 --   This procedure is used to ensure that non updateable attributes have
172 --   not been updated. If an attribute has been updated an error is generated.
173 --
174 -- Pre Conditions:
175 --   g_old_rec has been populated with details of the values currently in
176 --   the database.
177 --
178 -- In Arguments:
179 --   p_rec has been populated with the updated values the user would like the
180 --   record set to.
181 --
182 -- Post Success:
183 --   Processing continues if all the non updateable attributes have not
184 --   changed.
185 --
186 -- Post Failure:
187 --   An application error is raised if any of the non updatable attributes
188 --   have been altered.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure chk_non_updateable_args
193   (p_rec in pay_apr_shd.g_rec_type
194   ) IS
195 --
196   l_proc     varchar2(72);
197 --
198 Begin
199   --
200   l_proc     := g_package || 'chk_non_updateable_args';
201   --
202   -- Only proceed with the validation if a row exists for the current
203   -- record in the HR Schema.
204   --
205   IF NOT pay_apr_shd.api_updating
206       (p_process_id                        => p_rec.process_id
207       ,p_object_version_number             => p_rec.object_version_number
208       ) THEN
209      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
210      fnd_message.set_token('PROCEDURE ', l_proc);
211      fnd_message.set_token('STEP ', '5');
212      fnd_message.raise_error;
213   END IF;
214   --
215   -- EDIT_HERE: Add checks to ensure non-updateable args have
216   --            not been updated.
217   --
218 End chk_non_updateable_args;
219 --
220 --
221 -- ---------------------------------------------------------------------------
222 -- |---------------------< chk_legislation_code >-------------------------|
223 -- ---------------------------------------------------------------------------
224 PROCEDURE chk_legislation_code
225   (p_legislation_code                  in     varchar2
226   ) IS
227   l_proc     varchar2(72);
228 --
229 Begin
230   --
231   l_proc     := g_package || 'chk_legislation_code';
232   --
233   -- Only proceed with the validation if a row exists for the current
234   -- record in the HR Schema.
235   -- To check if the legislation is 'AU' or 'NZ'
236   if p_legislation_code is null then
237     fnd_message.set_name('PAY', 'HR_AU_MISSING_LEGISLATION_CODE');
238     fnd_message.raise_error;
239   end if;
240   --
241   if not (p_legislation_code = 'AU' or p_legislation_code = 'NZ') then
242     fnd_message.set_name('PAY', 'PAY_33177_LEG_CODE_INVALID');
243     fnd_message.raise_error;
244   end if;
245   --
246 End chk_legislation_code;
247 --
248 --
249 -- ---------------------------------------------------------------------------
250 -- |---------------------< chk_business_group_id >---------------------------|
251 -- ---------------------------------------------------------------------------
252 PROCEDURE chk_business_group_id
253   (p_legislation_code                  in     varchar2
254   ,p_business_group_id                 in     number
255   ) IS
256 --
257   l_proc          varchar2(72);
258   l_dummy_number  number;
259 --
260   cursor csr_valid_bgd_leg(
261                      p_leg_code   varchar2,
262                      p_bg_id      number) is
263   select 1
264   from per_business_groups pbg
265   where pbg.business_group_id = p_bg_id
266   and   pbg.legislation_code  = p_leg_code;
267 --
268 Begin
269   l_proc          := g_package || 'chk_business_group_id';
270   --
271   if p_business_group_id is not null then
272     open csr_valid_bgd_leg(p_legislation_code,
273                            p_business_group_id);
274     fetch csr_valid_bgd_leg into l_dummy_number;
275     --
276     if csr_valid_bgd_leg%notfound then
277       --
278       --
279       close csr_valid_bgd_leg;
280       fnd_message.set_name('PAY','HR_33586_INVALID_BG_LEG_COMBI');
281       fnd_message.raise_error;
282     end if;
283     --
284     --
285   end if;
286 End chk_business_group_id;
287 --
288 --
289 -- ---------------------------------------------------------------------------
290 -- |---------------------< chk_enabled_flag >--------------------------------|
291 -- ---------------------------------------------------------------------------
292 PROCEDURE chk_enabled_flag
293   (p_enabled_flag                  in     varchar2
294   ) IS
295   l_proc     varchar2(72);
296 --
297 Begin
298   --
299   l_proc :=  g_package || 'chk_enabled_flag';
300   --
301   -- Only proceed with the validation if a row exists for the current
302   -- record in the HR Schema.
303   -- To check if the enabled flag is 'Y' or 'N'
304   if not (p_enabled_flag = 'Y' or p_enabled_flag = 'N') then
305     fnd_message.set_name('PER', 'PER_52500_INV_YES_NO_FLAG');
306     fnd_message.raise_error;
307   end if;
308   --
309 End chk_enabled_flag;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------< insert_validate >----------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure insert_validate
315   (p_rec                          in pay_apr_shd.g_rec_type
316   ) is
317 --
318   l_proc  varchar2(72);
319 --
320 Begin
321   --
322   l_proc  := g_package||'insert_validate';
323   --
324   hr_utility.set_location('Entering:'||l_proc, 5);
325   --
326   -- Call all supporting business operations
327   --
328   chk_legislation_code(p_rec.legislation_code);
329   chk_business_group_id(p_rec.legislation_code,
330                         p_rec.business_group_id);
331   chk_enabled_flag(p_rec.enabled_flag);
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_apr_shd.g_rec_type
345   ) is
346 --
347   l_proc  varchar2(72);
348 --
349 Begin
350   --
351   l_proc  := g_package||'update_validate';
352   --
353   hr_utility.set_location('Entering:'||l_proc, 5);
354   --
355   -- Call all supporting business operations
356   --
357   --
358   chk_legislation_code(p_rec.legislation_code);
359   chk_business_group_id(p_rec.legislation_code,
360                         p_rec.business_group_id);
361   chk_enabled_flag(p_rec.enabled_flag);
362   --
363   --
364   -- Validate Dependent Attributes
365   --
366   chk_non_updateable_args
367     (p_rec              => p_rec
368     );
369   --
370   --
371   hr_utility.set_location(' Leaving:'||l_proc, 10);
372 End update_validate;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------< delete_validate >----------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure delete_validate
378   (p_rec                          in pay_apr_shd.g_rec_type
379   ) is
380 --
381   l_proc  varchar2(72);
382 --
383 Begin
384   --
385   l_proc  := g_package||'delete_validate';
386   --
387   hr_utility.set_location('Entering:'||l_proc, 5);
388   --
389   --
390 null;
391   --
392   -- Call all supporting business operations
393   --
394   hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End delete_validate;
396 --
397 begin
398   g_package  := '  pay_apr_bus.';  -- Global package name
399 end pay_apr_bus;