DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PPE_BUS

Source


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