DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_APM_BUS

Source


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