DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PEV_BUS

Source


1 Package Body pay_pev_bus as
2 /* $Header: pypperhi.pkb 120.1.12010000.1 2008/07/27 23:25:17 appldev ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_pev_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_process_event_id            number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_process_event_id                     in number
22   ) is
23   --
24   -- Declare cursor
25   --
26   cursor csr_sec_grp is
27     select pbg.security_group_id
28       from per_business_groups pbg
29          , pay_process_events pev
30      where pev.process_event_id = p_process_event_id
31        and pbg.business_group_id = pev.business_group_id;
32   --
33   -- Declare local variables
34   --
35   l_security_group_id number;
36   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
37   --
38 begin
39   --
40   hr_utility.set_location('Entering:'|| l_proc, 10);
41   --
42   -- Ensure that all the mandatory parameter are not null
43   --
44   hr_api.mandatory_arg_error
45     (p_api_name           => l_proc
46     ,p_argument           => 'process_event_id'
47     ,p_argument_value     => p_process_event_id
48     );
49   --
50   open csr_sec_grp;
51   fetch csr_sec_grp into l_security_group_id;
52   --
53   if csr_sec_grp%notfound then
54      --
55      close csr_sec_grp;
56      --
60      fnd_message.raise_error;
57      -- The primary key is invalid therefore we must error
58      --
59      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61      --
62   end if;
63   close csr_sec_grp;
64   --
65   -- Set the security_group_id in CLIENT_INFO
66   --
67   hr_api.set_security_group_id
68     (p_security_group_id => l_security_group_id
69     );
70   --
71   hr_utility.set_location(' Leaving:'|| l_proc, 20);
72   --
73 end set_security_group_id;
74 --
75 --  ---------------------------------------------------------------------------
76 --  |---------------------< return_legislation_code >-------------------------|
77 --  ---------------------------------------------------------------------------
78 --
79 Function return_legislation_code
80   (p_process_event_id                     in     number
81   )
82   Return Varchar2 Is
83   --
84   -- Declare cursor
85   --
86   cursor csr_leg_code is
87     select pbg.legislation_code
88       from per_business_groups pbg
89          , pay_process_events pev
90      where pev.process_event_id = p_process_event_id
91        and pbg.business_group_id (+) = pev.business_group_id;
92   --
93   -- Declare local variables
94   --
95   l_legislation_code  varchar2(150);
96   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
97   --
98 Begin
99   --
100   hr_utility.set_location('Entering:'|| l_proc, 10);
101   --
102   -- Ensure that all the mandatory parameter are not null
103   --
104   hr_api.mandatory_arg_error
105     (p_api_name           => l_proc
106     ,p_argument           => 'process_event_id'
107     ,p_argument_value     => p_process_event_id
108     );
109   --
110   if ( nvl(pay_pev_bus.g_process_event_id, hr_api.g_number)
111        = p_process_event_id) then
112     --
113     -- The legislation code has already been found with a previous
114     -- call to this function. Just return the value in the global
115     -- variable.
116     --
117     l_legislation_code := pay_pev_bus.g_legislation_code;
118     hr_utility.set_location(l_proc, 20);
119   else
120     --
121     -- The ID is different to the last call to this function
122     -- or this is the first call to this function.
123     --
124     open csr_leg_code;
125     fetch csr_leg_code into l_legislation_code;
126     --
127     if csr_leg_code%notfound then
128       --
129       -- The primary key is invalid therefore we must error
130       --
131       close csr_leg_code;
132       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
133       fnd_message.raise_error;
134     end if;
135     hr_utility.set_location(l_proc,30);
136     --
137     -- Set the global variables so the values are
138     -- available for the next call to this function.
139     --
140     close csr_leg_code;
141     pay_pev_bus.g_process_event_id  := p_process_event_id;
142     pay_pev_bus.g_legislation_code  := l_legislation_code;
143   end if;
144   hr_utility.set_location(' Leaving:'|| l_proc, 40);
145   return l_legislation_code;
146 end return_legislation_code;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |-----------------------< chk_non_updateable_args >------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 --   This procedure is used to ensure that non updateable attributes have
155 --   not been updated. If an attribute has been updated an error is generated.
156 --
157 -- Pre Conditions:
158 --   g_old_rec has been populated with details of the values currently in
159 --   the database.
160 --
161 -- In Arguments:
162 --   p_rec has been populated with the updated values the user would like the
163 --   record set to.
164 --
165 -- Post Success:
166 --   Processing continues if all the non updateable attributes have not
167 --   changed.
168 --
169 -- Post Failure:
170 --   An application error is raised if any of the non updatable attributes
171 --   have been altered.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure chk_non_updateable_args
176   (p_rec in pay_pev_shd.g_rec_type
177   ) IS
178 --
179   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
180   l_error    EXCEPTION;
181   l_argument varchar2(30);
182 --
183 Begin
184   --
185   -- Only proceed with the validation if a row exists for the current
186   -- record in the HR Schema.
187   --
188   IF NOT pay_pev_shd.api_updating
189       (p_process_event_id                     => p_rec.process_event_id
190       ,p_object_version_number                => p_rec.object_version_number
191       ) THEN
192      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
193      fnd_message.set_token('PROCEDURE ', l_proc);
194      fnd_message.set_token('STEP ', '5');
195      fnd_message.raise_error;
196   END IF;
197   --
198   --
199   -- p_assignment_id
200   --
201   if nvl(p_rec.assignment_id, hr_api.g_number) <>
202      nvl(pay_pev_shd.g_old_rec.assignment_id, hr_api.g_number)
203   then
204     l_argument := 'p_assignment_id';
205     raise l_error;
206   end if;
207   --
208   -- p_effective_date
209   --
210   if nvl(p_rec.effective_date, hr_api.g_date) <>
211      nvl(pay_pev_shd.g_old_rec.effective_date, hr_api.g_date)
212   then
213     l_argument := 'p_effective_date';
214     raise l_error;
215   end if;
216   --
217   -- p_change_type
218   --
219   if nvl(p_rec.change_type, hr_api.g_varchar2) <>
220      nvl(pay_pev_shd.g_old_rec.change_type, hr_api.g_varchar2)
221   then
222     l_argument := 'p_change_type';
223     raise l_error;
224   end if;
225   --
226   if nvl(p_rec.business_group_id, hr_api.g_number) <>
227      nvl(pay_pev_shd.g_old_rec.business_group_id, hr_api.g_number)
228   then
229     l_argument := 'business_group_id';
230     raise l_error;
231   end if;
232   --
233   EXCEPTION
234     WHEN l_error THEN
235        hr_api.argument_changed_error
236          (p_api_name => l_proc
237          ,p_argument => l_argument);
238     WHEN OTHERS THEN
239        RAISE;
240 End chk_non_updateable_args;
241 --
242 -- ----------------------------------------------------------------------------
243 -- |-----------------------< chk_change_type >------------------------|
244 -- ----------------------------------------------------------------------------
245 -- {Start Of Comments}
246 --
247 -- Description:
248 --   This procedure is used to ensure that the change type is valid for
249 --   continuous calc.
250 --
251 -- Pre Conditions:
252 --
253 -- In Arguments:
254 --   p_rec has been populated with the updated values the user would like the
255 --   record set to.
256 --
257 -- Post Success:
258 --   Processing continues if the change type is valid
259 --
260 -- Post Failure:
261 --   An application error is raised if any of the change_type is not
262 --   valid
263 --
264 -- {End Of Comments}
265 -- ----------------------------------------------------------------------------
266 Procedure chk_change_type
267   (p_rec in pay_pev_shd.g_rec_type
268   ) IS
269 --
270   l_proc        varchar2(72) := g_package || 'chk_change_type';
271   l_error       EXCEPTION;
272   l_argument    varchar2(30);
273   --
274 --
275 Begin
276   --
277   if hr_api.not_exists_in_hrstanlookups(p_effective_date => p_rec.effective_date
278                                        ,p_lookup_type    => 'PROCESS_EVENT_TYPE'
279                                        ,p_lookup_code    => p_rec.change_type) then
280     --
281     -- The change_type for this record is not recognised
282     --
283     fnd_message.set_name('PAY','HR_xxxx_INVALID_EVENT_TYPE');
284     fnd_message.raise_error;
285   end if;
286   hr_utility.set_location(l_proc,30);
287   --
288   -- Set the global variables so the values are
289   -- available for the next call to this function.
290   --
291 end chk_change_type;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |-----------------------< chk_status >------------------------|
295 -- ----------------------------------------------------------------------------
296 -- {Start Of Comments}
297 --
298 -- Description:
299 --   This procedure is used to ensure that the status code is valid for
300 --   continuous calc.
301 --
302 -- Pre Conditions:
303 --
304 -- In Arguments:
305 --   p_rec has been populated with the updated values the user would like the
306 --   record set to.
307 --
308 -- Post Success:
309 --   Processing continues if the status code is valid
310 --
311 -- Post Failure:
312 --   An application error is raised if any of the status is not
313 --   valid
314 --
315 -- {End Of Comments}
316 -- ----------------------------------------------------------------------------
317 Procedure chk_status
318   (p_rec in pay_pev_shd.g_rec_type
319   ) IS
320 --
321   l_proc        varchar2(72) := g_package || 'chk_status';
322   l_error       EXCEPTION;
323   l_argument    varchar2(30);
324   --
325 --
326 Begin
327   --
328   if hr_api.not_exists_in_hrstanlookups(p_rec.effective_date,
329                                         'PROCESS_EVENT_STATUS',
330                                         p_rec.status) then
331     --
332     -- The status for this record is not recognised
333     --
334     fnd_message.set_name('PAY','HR_xxxx_INVALID_STATUS_TYPE');
335     fnd_message.raise_error;
336   end if;
337 
338   hr_utility.set_location(l_proc,30);
339   --
340   -- Set the global variables so the values are
341   -- available for the next call to this function.
342   --
343 end chk_status;
344 --
345 -- ----------------------------------------------------------------------------
346 -- |---------------------------< insert_validate >----------------------------|
347 -- ----------------------------------------------------------------------------
348 Procedure insert_validate
349   (p_rec                          in pay_pev_shd.g_rec_type
350   ) is
351 --
352   l_proc  varchar2(72) := g_package||'insert_validate';
353 --
354 Begin
355   hr_utility.set_location('Entering:'||l_proc, 5);
356   --
357   --hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
358   --
359   chk_change_type
360     (p_rec              => p_rec
361     );
362   --
363   chk_status
364     (p_rec              => p_rec
365     );
366   --
367   hr_utility.set_location(' Leaving:'||l_proc, 10);
368 End insert_validate;
369 --
370 -- ----------------------------------------------------------------------------
371 -- |---------------------------< update_validate >----------------------------|
372 -- ----------------------------------------------------------------------------
373 Procedure update_validate
374   (p_rec                          in pay_pev_shd.g_rec_type
375   ) is
376 --
377   l_proc  varchar2(72) := g_package||'update_validate';
378 --
379 Begin
380   hr_utility.set_location('Entering:'||l_proc, 5);
381   --
382   --hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
383   --
384   chk_non_updateable_args
385     (p_rec              => p_rec
386     );
387   --
388   chk_change_type
389     (p_rec              => p_rec
390     );
391   --
392   chk_status
393     (p_rec              => p_rec
394     );
395   --
396   hr_utility.set_location(' Leaving:'||l_proc, 10);
397 End update_validate;
398 --
399 -- ----------------------------------------------------------------------------
400 -- |---------------------------< delete_validate >----------------------------|
401 -- ----------------------------------------------------------------------------
402 Procedure delete_validate
403   (p_rec                          in pay_pev_shd.g_rec_type
404   ) is
405 --
406   l_proc  varchar2(72) := g_package||'delete_validate';
407 --
408 Begin
409   hr_utility.set_location('Entering:'||l_proc, 5);
410   --
411   -- Call all supporting business operations
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 10);
414 End delete_validate;
415 --
416 end pay_pev_bus;