DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AMM_BUS

Source


1 Package Body hr_amm_bus as
2 /* $Header: hrammrhi.pkb 115.3 2002/12/05 12:45:03 apholt noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_amm_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_authoria_mapping_id         number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_authoria_mapping_id                  in number
22   ,p_associated_column1                   in varchar2 default null
23   ) is
24   --
25   --
26   -- Declare local variables
27   --
28   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
29   --
30 begin
31   --
32   hr_utility.set_location('Entering:'|| l_proc, 10);
33   --
34   -- Ensure that all the mandatory parameter are not null
35   --
36   hr_api.mandatory_arg_error
37     (p_api_name           => l_proc
38     ,p_argument           => 'authoria_mapping_id'
39     ,p_argument_value     => p_authoria_mapping_id
40     );
41   --
42   -- CLIENT_INFO not set. No lookup validation or joins to HR_LOOKUPS.
43   --
44   hr_utility.set_location(' Leaving:'|| l_proc, 20);
45   --
46 end set_security_group_id;
47 --
48 --
49 -- ----------------------------------------------------------------------------
50 -- |-----------------------< chk_non_updateable_args >------------------------|
51 -- ----------------------------------------------------------------------------
52 -- {Start Of Comments}
53 --
54 -- Description:
55 --   This procedure is used to ensure that non updateable attributes have
56 --   not been updated. If an attribute has been updated an error is generated.
57 --
58 -- Pre Conditions:
59 --   g_old_rec has been populated with details of the values currently in
60 --   the database.
61 --
62 -- In Arguments:
63 --   p_rec has been populated with the updated values the user would like the
64 --   record set to.
65 --
66 -- Post Success:
67 --   Processing continues if all the non updateable attributes have not
68 --   changed.
69 --
70 -- Post Failure:
71 --   An application error is raised if any of the non updatable attributes
72 --   have been altered.
73 --
74 -- {End Of Comments}
75 -- ----------------------------------------------------------------------------
76 Procedure chk_non_updateable_args
77   (p_rec in hr_amm_shd.g_rec_type
78   ) IS
79 --
80   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
81 --
82 Begin
83   --
84   -- Only proceed with the validation if a row exists for the current
85   -- record in the HR Schema.
86   --
87   IF NOT hr_amm_shd.api_updating
88       (p_authoria_mapping_id               => p_rec.authoria_mapping_id
89       ,p_object_version_number             => p_rec.object_version_number
90       ) THEN
91      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
92      fnd_message.set_token('PROCEDURE ', l_proc);
93      fnd_message.set_token('STEP ', '5');
94      fnd_message.raise_error;
95   END IF;
96   --
97   -- Add checks to ensure non-updateable args have not been updated.
98   --
99   -- all columns are updateable.
100   --
101 End chk_non_updateable_args;
102 
103 --
104 -- ----------------------------------------------------------------------------
105 -- |------------------------------< chk_pl_id >-------------------------------|
106 -- ----------------------------------------------------------------------------
107 --
108 --  Description :
109 --      Validates that a pl_id exists in the table ben_pl_f
110 --
111 --  Pre-conditions:
112 --     None
113 --
114 --   In Arguments :
115 --      p_pl_id
116 --
117 --  Post Success :
118 --     If a row does exist in ben_pl_f for the given pl_id then
119 --     processing continues
120 --
121 --  Post Failure :
122 --       If a row does not exist in ben_pl_f for the given pl_id then
123 --       an application error will be raised and processing is terminated
124 --
125 --   Access Status :
126 --      Internal Table Handler Use only.
127 --
128 --    {End of Comments}
129 --  ---------------------------------------------------------------------------
130 procedure chk_pl_id
131     (p_pl_id in number) is
132 --
133     l_exists	varchar2(1);
134     l_proc	varchar2(72) := g_package||'chk_pl_id';
135 --
136   cursor csr_valid_plan is
137 	select 'Y'
138 	from ben_pl_f
139 	where pl_id = p_pl_id;
140 --
141 begin
142   hr_utility.set_location('Entering: '|| l_proc, 1);
143   --
144   -- Check mandatory parameters have been set
145   --
146   hr_api.mandatory_arg_error
147       (p_api_name	=> l_proc,
148        p_argument	=> 'pl_id',
149        p_argument_value => p_pl_id
150       );
151   --
152   hr_utility.set_location(l_proc, 2);
153   --
154   -- Check that the pl_id is in ben_pl_f
155   --
156   open csr_valid_plan;
157   fetch csr_valid_plan into l_exists;
158   if csr_valid_plan%notfound then
159     close csr_valid_plan;
160     hr_utility.set_message(801, 'HR_nnn_PLAN_NOT_EXIST');
161     hr_utility.raise_error;
162   end if;
163   close csr_valid_plan;
164   --
165   hr_utility.set_location(l_proc, 3);
166   --
167   hr_utility.set_location(' Leaving: '|| l_proc, 4);
168 end chk_pl_id;
169 --
170 --
171 -- ----------------------------------------------------------------------------
172 -- |---------------------------< chk_plip_id >---------------------------|
173 -- ----------------------------------------------------------------------------
174 --
175 --  Description :
176 --      Validates that a plip_id exists in the table ben_pgm_f
177 --
178 --  Pre-conditions:
179 --     None
180 --
181 --   In Arguments :
182 --      p_plip_id
183 --
184 --  Post Success :
185 --     If a row does exist in ben_pgm_f for the given plip_id or the
186 --     plip_id is null then processing continues
187 --
188 --  Post Failure :
189 --       If a row does not exist in ben_pgm_f for the given plip_id then
190 --       an application error will be raised and processing is terminated
191 --
192 --   Access Status :
193 --      Internal Table Handler Use only.
194 --
195 --    {End of Comments}
196 --  ---------------------------------------------------------------------------
197 procedure chk_plip_id
198     (p_plip_id in number) is
199 --
200     l_exists	varchar2(1);
201     l_proc	varchar2(72) := g_package||'chk_plip_id';
202 --
203   cursor csr_valid_program is
204 	select 'Y'
205 	from ben_plip_f
206 	where plip_id = p_plip_id;
207 --
208 begin
209   hr_utility.set_location('Entering: '|| l_proc, 1);
210   --
211   --
212   hr_utility.set_location(l_proc, 2);
213   --
214   -- Check that the plip_id is in ben_pgm_f
215   -- unless the plip_id is null
216   --
217   if (p_plip_id is not null) then
218     open csr_valid_program;
219     fetch csr_valid_program into l_exists;
220     if csr_valid_program%notfound then
221       close csr_valid_program;
222       hr_utility.set_message(801, 'HR_nnn_PROGRAM_NOT_EXIST');
223       hr_utility.raise_error;
224     end if;
225     close csr_valid_program;
226   end if;
227   --
228   hr_utility.set_location(l_proc, 3);
229   --
230   hr_utility.set_location(' Leaving: '|| l_proc, 4);
231 end chk_plip_id;
232 --
233 
234 --
235 -- ----------------------------------------------------------------------------
236 -- |---------------------------< chk_open_enrollment_flag >-------------------|
237 -- ----------------------------------------------------------------------------
238 --
239 --  Description :
240 --      Validates that the open_enrollment_flag is either Y or N
241 --
242 --  Pre-conditions:
243 --     None
244 --
245 --   In Arguments :
246 --      p_open_enrollment_flag
247 --
248 --  Post Success :
249 --     If the open_enrollment_flag is either Y or N then
250 --     processing continues
251 --
252 --  Post Failure :
253 --       If the open_enrollment_flag is neither Y or N then
254 --       an application error will be raised and processing is terminated
255 --
256 --   Access Status :
257 --      Internal Table Handler Use only.
258 --
259 --    {End of Comments}
260 --  ---------------------------------------------------------------------------
261 procedure chk_open_enrollment_flag
262     (p_open_enrollment_flag in varchar2) is
263 --
264     l_exists	varchar2(1);
265     l_proc	varchar2(72) := g_package||'chk_open_enrollment_flag';
266 --
267 begin
268   hr_utility.set_location('Entering: '|| l_proc, 1);
269   --
270   -- Check mandatory parameters have been set
271   --
272   hr_api.mandatory_arg_error
273       (p_api_name	=> l_proc,
274        p_argument	=> 'open_enrollment_flag',
275        p_argument_value => p_open_enrollment_flag
276       );
277   --
278   hr_utility.set_location(l_proc, 2);
279   --
280   -- Check that the open_enrollment_flag is either Y or N
281   --
282   if not (p_open_enrollment_flag = 'Y'
283           or
284           p_open_enrollment_flag = 'N') then
285     hr_utility.set_message(801, 'HR_nnn_FLAG_NOT_SET');
286     hr_utility.raise_error;
287   end if;
288   --
289   hr_utility.set_location(l_proc, 3);
290   --
291   hr_utility.set_location(' Leaving: '|| l_proc, 4);
292 end chk_open_enrollment_flag;
293 --
294 
295 --
296 -- ----------------------------------------------------------------------------
297 -- |---------------------------< chk_target_page >----------------------------|
298 -- ----------------------------------------------------------------------------
299 --
300 --  Description :
301 --      Validates that the target_page is not null
302 --
303 --  Pre-conditions:
304 --     None
305 --
306 --   In Arguments :
307 --      p_target_page
308 --
309 --  Post Success :
310 --     If the target_page is non-null then
311 --     processing continues
312 --
313 --  Post Failure :
314 --       If the target_page is null then
315 --       an application error will be raised and processing is terminated
316 --
317 --   Access Status :
318 --      Internal Table Handler Use only.
319 --
320 --    {End of Comments}
321 --  ---------------------------------------------------------------------------
322 procedure chk_target_page
323     (p_target_page in varchar2) is
324 --
325     l_exists	varchar2(1);
326     l_proc	varchar2(72) := g_package||'chk_target_page';
327 --
328 begin
329   hr_utility.set_location('Entering: '|| l_proc, 1);
330   --
331   -- Check mandatory parameters have been set
332   --
333   hr_api.mandatory_arg_error
334       (p_api_name	=> l_proc,
335        p_argument	=> 'target_page',
336        p_argument_value => p_target_page
337       );
338   --
339   hr_utility.set_location(l_proc, 2);
340   --
341   --
342   hr_utility.set_location(l_proc, 3);
343   --
344   hr_utility.set_location(' Leaving: '|| l_proc, 4);
345 end chk_target_page;
346 --
347 
348 --
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------< chk_unique_ins >-----------------------------|
351 -- ----------------------------------------------------------------------------
352 --
353 --  Description :
354 --      Validates that the combination of pl_id,
355 --      plip_id and open_enrollment_flag is unique.
359 --
356 --
357 --  Pre-conditions:
358 --     None
360 --   In Arguments :
361 --      p_pl_id
362 --      p_plip_id
363 --      p_open_enrollment_flag
364 --
365 --  Post Success :
366 --     If the combination of pl_id,
367 --     plip_id and open_enrollment_flag is unique then
368 --     processing continues
369 --
370 --  Post Failure :
371 --     If the combination of pl_id,
372 --     plip_id and open_enrollment_flag is not unique then
373 --     an application error will be raised and processing is terminated
374 --
375 --   Access Status :
376 --      Internal Table Handler Use only.
377 --
378 --    {End of Comments}
379 --  ---------------------------------------------------------------------------
380 procedure chk_unique_ins
381     (
382      p_pl_id                 in number
383     ,p_plip_id               in number
384     ,p_open_enrollment_flag  in varchar2) is
385 --
386     l_exists	varchar2(1);
387     l_proc	varchar2(72) := g_package||'chk_unique_ins';
388 
389     cursor csr_chk_unique is
390       select null
391       from  hr_authoria_mappings
392       where pl_id            = p_pl_id
393         and nvl(plip_id,-924926578) = nvl(p_plip_id,-924926578)
394         and open_enrollment_flag = p_open_enrollment_flag;
395 
396 --
397 begin
398   hr_utility.set_location('Entering: '|| l_proc, 1);
399   --
400   open csr_chk_unique;
401   fetch csr_chk_unique into l_exists;
402   if csr_chk_unique%found then
403     close csr_chk_unique;
404     hr_utility.set_message(801, 'HR_nnn_MAPPING_EXISTS');
405     hr_utility.raise_error;
406   end if;
407   close csr_chk_unique;
408   --
409   hr_utility.set_location(l_proc, 2);
410   --
411   --
412   hr_utility.set_location(l_proc, 3);
413   --
414   hr_utility.set_location(' Leaving: '|| l_proc, 4);
415 end chk_unique_ins;
416 --
417 
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------< chk_unique_upd >-----------------------------|
421 -- ----------------------------------------------------------------------------
422 --
423 --  Description :
424 --      Validates that the combination of pl_id,
425 --      plip_id and open_enrollment_flag is unique.
426 --
427 --  Pre-conditions:
428 --     None
429 --
430 --   In Arguments :
431 --      p_pl_id
432 --      p_plip_id
433 --      p_open_enrollment_flag
434 --
435 --  Post Success :
436 --     If the combination of pl_id,
437 --     plip_id and open_enrollment_flag is unique then
438 --     processing continues
439 --
440 --  Post Failure :
441 --     If the combination of pl_id,
442 --     plip_id and open_enrollment_flag is not unique then
443 --     an application error will be raised and processing is terminated
444 --
445 --   Access Status :
446 --      Internal Table Handler Use only.
447 --
448 --    {End of Comments}
449 --  ---------------------------------------------------------------------------
450 procedure chk_unique_upd
451     (
452      p_pl_id                 in number
453     ,p_plip_id               in number
454     ,p_open_enrollment_flag  in varchar2
455     ,p_authoria_mapping_id   in number) is
456 --
457     l_exists	varchar2(1);
458     l_proc	varchar2(72) := g_package||'chk_unique_upd';
459 
460     cursor csr_chk_unique is
461       select null
462       from  hr_authoria_mappings
463       where pl_id            = p_pl_id
464         and nvl(plip_id,-924926578) = nvl(p_plip_id,-924926578)
465         and open_enrollment_flag = p_open_enrollment_flag
466         and authoria_mapping_id <> p_authoria_mapping_id;
467 --
468 begin
469   hr_utility.set_location('Entering: '|| l_proc, 1);
470   --
471   open csr_chk_unique;
472   fetch csr_chk_unique into l_exists;
473   if csr_chk_unique%found then
474     close csr_chk_unique;
475     hr_utility.set_message(801, 'HR_nnn_MAPPING_EXISTS');
476     hr_utility.raise_error;
477   end if;
478   close csr_chk_unique;
479   --
480   hr_utility.set_location(l_proc, 2);
481   --
482   --
483   hr_utility.set_location(l_proc, 3);
484   --
485   hr_utility.set_location(' Leaving: '|| l_proc, 4);
486 end chk_unique_upd;
487 --
488 
489 --
490 -- ----------------------------------------------------------------------------
491 -- |---------------------------< insert_validate >----------------------------|
492 -- ----------------------------------------------------------------------------
493 Procedure insert_validate
494   (p_rec                          in hr_amm_shd.g_rec_type
495   ) is
496 --
497   l_proc  varchar2(72) := g_package||'insert_validate';
498 --
499 Begin
500   hr_utility.set_location('Entering:'||l_proc, 5);
501   --
502   -- Call all supporting business operations
503 
504   -- validate pl_id
505   --
506   chk_pl_id (p_pl_id => p_rec.pl_id);
507 
508   -- validate plip_id
509   --
510   chk_plip_id (p_plip_id => p_rec.plip_id);
511 
512   -- validate open_enrollment_flag
513   --
514   chk_open_enrollment_flag (
515     p_open_enrollment_flag => p_rec.open_enrollment_flag);
516 
517   -- validate target_page
518   --
519   chk_target_page (p_target_page => p_rec.target_page);
520 
521   -- validate unique_ins
522   --
523   chk_unique_ins
524     (
525      p_pl_id            => p_rec.pl_id
526     ,p_plip_id          => p_rec.plip_id
527     ,p_open_enrollment_flag => p_rec.open_enrollment_flag
528     );
529   --
530   --
531   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS.
532   --
533   --
534   hr_utility.set_location(' Leaving:'||l_proc, 10);
535 End insert_validate;
536 --
537 -- ----------------------------------------------------------------------------
538 -- |---------------------------< update_validate >----------------------------|
539 -- ----------------------------------------------------------------------------
540 Procedure update_validate
541   (p_rec                          in hr_amm_shd.g_rec_type
542   ) is
543 --
544   l_proc  varchar2(72) := g_package||'update_validate';
545 --
546 Begin
547   hr_utility.set_location('Entering:'||l_proc, 5);
548   --
549   -- Call all supporting business operations
550 
551   -- validate pl_id
552   --
553   chk_pl_id (p_pl_id => p_rec.pl_id);
554 
555   -- validate plip_id
556   --
557   chk_plip_id (p_plip_id => p_rec.plip_id);
558 
559   -- validate open_enrollment_flag
560   --
561   chk_open_enrollment_flag (
562     p_open_enrollment_flag => p_rec.open_enrollment_flag);
563 
564   -- validate target_page
565   --
566   chk_target_page (p_target_page => p_rec.target_page);
567 
568   -- validate unique_upd
569   --
570   chk_unique_upd
571     (
572      p_pl_id            => p_rec.pl_id
573     ,p_plip_id          => p_rec.plip_id
574     ,p_open_enrollment_flag => p_rec.open_enrollment_flag
575     ,p_authoria_mapping_id  => p_rec.authoria_mapping_id
576     );
577 
578   --
579   -- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS.
580   --
581   chk_non_updateable_args
582     (p_rec              => p_rec
583     );
584   --
585   --
586   hr_utility.set_location(' Leaving:'||l_proc, 10);
587 End update_validate;
588 --
589 -- ----------------------------------------------------------------------------
590 -- |---------------------------< delete_validate >----------------------------|
591 -- ----------------------------------------------------------------------------
592 Procedure delete_validate
593   (p_rec                          in hr_amm_shd.g_rec_type
594   ) is
595 --
596   l_proc  varchar2(72) := g_package||'delete_validate';
597 --
598 Begin
599   hr_utility.set_location('Entering:'||l_proc, 5);
600   --
601   -- Call all supporting business operations
602   --
603   hr_utility.set_location(' Leaving:'||l_proc, 10);
604 End delete_validate;
605 --
606 end hr_amm_bus;