DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PGT_BUS

Source


1 Package Body per_pgt_bus as
2 /* $Header: pepgtrhi.pkb 115.2 2003/06/05 07:38:23 cxsimpso noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pgt_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_hier_node_type_id           number         default null;
15 --
16 --  ---------------------------------------------------------------------------
17 --  |----------------------< set_security_group_id >--------------------------|
18 --  ---------------------------------------------------------------------------
19 --
20 Procedure set_security_group_id
21   (p_hier_node_type_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       from per_business_groups pbg
30          , per_gen_hier_node_types pgt
31      where pgt.hier_node_type_id = p_hier_node_type_id
32        and pbg.business_group_id = pgt.business_group_id;
33   --
34   -- Declare local variables
35   --
36   l_security_group_id number;
37   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
38   --
39 begin
40   --
41   hr_utility.set_location('Entering:'|| l_proc, 10);
42   --
43   -- Ensure that all the mandatory parameter are not null
44   --
45   hr_api.mandatory_arg_error
46     (p_api_name           => l_proc
47     ,p_argument           => 'hier_node_type_id'
48     ,p_argument_value     => p_hier_node_type_id
49     );
50   --
51   open csr_sec_grp;
52   fetch csr_sec_grp into l_security_group_id;
53   --
54   if csr_sec_grp%notfound then
55      --
56      close csr_sec_grp;
57      --
58      -- The primary key is invalid therefore we must error
59      --
60      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
61      hr_multi_message.add
62        (p_associated_column1
63         => nvl(p_associated_column1,'HIER_NODE_TYPE_ID')
64        );
65      --
66   else
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   end if;
75   --
76   hr_utility.set_location(' Leaving:'|| l_proc, 20);
77   --
78 end set_security_group_id;
79 --
80 --  ---------------------------------------------------------------------------
81 --  |---------------------< return_legislation_code >-------------------------|
82 --  ---------------------------------------------------------------------------
83 --
84 Function return_legislation_code
85   (p_hier_node_type_id                    in     number
86   )
87   Return Varchar2 Is
88   --
89   -- Declare cursor
90   --
91   cursor csr_leg_code is
92     select pbg.legislation_code
93       from per_business_groups pbg
94          , per_gen_hier_node_types pgt
95      where pgt.hier_node_type_id = p_hier_node_type_id
96        and pbg.business_group_id (+) = pgt.business_group_id;
97   --
98   -- Declare local variables
99   --
100   l_legislation_code  varchar2(150);
101   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
102   --
103 Begin
104   --
105   hr_utility.set_location('Entering:'|| l_proc, 10);
106   --
107   -- Ensure that all the mandatory parameter are not null
108   --
109   hr_api.mandatory_arg_error
110     (p_api_name           => l_proc
111     ,p_argument           => 'hier_node_type_id'
112     ,p_argument_value     => p_hier_node_type_id
113     );
114   --
115   if ( nvl(per_pgt_bus.g_hier_node_type_id, hr_api.g_number)
116        = p_hier_node_type_id) then
117     --
118     -- The legislation code has already been found with a previous
119     -- call to this function. Just return the value in the global
120     -- variable.
121     --
122     l_legislation_code := per_pgt_bus.g_legislation_code;
123     hr_utility.set_location(l_proc, 20);
124   else
125     --
126     -- The ID is different to the last call to this function
127     -- or this is the first call to this function.
128     --
129     open csr_leg_code;
130     fetch csr_leg_code into l_legislation_code;
131     --
132     if csr_leg_code%notfound then
133       --
134       -- The primary key is invalid therefore we must error
135       --
136       close csr_leg_code;
137       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
138       fnd_message.raise_error;
139     end if;
140     hr_utility.set_location(l_proc,30);
141     --
142     -- Set the global variables so the values are
143     -- available for the next call to this function.
144     --
145     close csr_leg_code;
146     per_pgt_bus.g_hier_node_type_id           := p_hier_node_type_id;
147     per_pgt_bus.g_legislation_code  := l_legislation_code;
148   end if;
149   hr_utility.set_location(' Leaving:'|| l_proc, 40);
150   return l_legislation_code;
151 end return_legislation_code;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------< chk_non_updateable_args >------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 --   This procedure is used to ensure that non updateable attributes have
160 --   not been updated. If an attribute has been updated an error is generated.
161 --
162 -- Pre Conditions:
163 --   g_old_rec has been populated with details of the values currently in
164 --   the database.
165 --
166 -- In Arguments:
167 --   p_rec has been populated with the updated values the user would like the
168 --   record set to.
169 --
170 -- Post Success:
171 --   Processing continues if all the non updateable attributes have not
172 --   changed.
173 --
174 -- Post Failure:
175 --   An application error is raised if any of the non updatable attributes
176 --   have been altered.
177 --
178 -- {End Of Comments}
179 -- ----------------------------------------------------------------------------
180 Procedure chk_non_updateable_args
181   (p_effective_date               in date
182   ,p_rec in per_pgt_shd.g_rec_type
183   ) IS
184 --
185   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
186 --
187 Begin
188   --
189   -- Only proceed with the validation if a row exists for the current
190   -- record in the HR Schema.
191   --
192   IF NOT per_pgt_shd.api_updating
193       (p_hier_node_type_id                 => p_rec.hier_node_type_id
194       ,p_object_version_number             => p_rec.object_version_number
195       ) THEN
196      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
197      fnd_message.set_token('PROCEDURE ', l_proc);
198      fnd_message.set_token('STEP ', '5');
199      fnd_message.raise_error;
200   END IF;
201   --
202   IF (per_pgt_shd.g_old_rec.child_node_type <> nvl(p_rec.child_node_type,hr_api.g_varchar2)) THEN
203      fnd_message.set_name('PER', 'HR_289899_PGT_CNTYPE_NO_UPD');
204      fnd_message.raise_error;
205   END IF;
206   --
207   IF (per_pgt_shd.g_old_rec.hierarchy_type <> nvl(p_rec.hierarchy_type,hr_api.g_varchar2)) THEN
208      fnd_message.set_name('PER', 'HR_289900_PGT_HTYPE_NO_UPD');
209      fnd_message.raise_error;
210   END IF;
211   --
212   IF (nvl(per_pgt_shd.g_old_rec.business_group_id,hr_api.g_number)
213          <> nvl(p_rec.business_group_id,hr_api.g_number)) THEN
214      fnd_message.set_name('PER', 'HR_289901_PGT_BG_NO_UPD');
215      fnd_message.raise_error;
216   END IF;
217   --
218 End chk_non_updateable_args;
219 
220 --
221 -- ----------------------------------------------------------------------------
222 -- |---------------------------< chk_hierarchy_type >----------------------------|
223 -- ----------------------------------------------------------------------------
224 --
225 -- {Start Of Comments}
226 --
227 -- Description:
228 --   Validates hierarchy_type and is called on insert only.
229 --
230 -- In Arguments:
231 --
232 -- Post Success:
233 --   Processing continues hierarchy_type is valid.
234 --
235 -- Post Failure:
236 --   An application error is raised if hierarchy_type is not valid.
237 --
238 Procedure chk_hierarchy_type (p_effective_date in date
239                              ,p_hierarchy_type in varchar2) IS
240 --
241   l_proc  varchar2(72) := g_package||'chk_hierarchy_type';
242 --
243 Begin
244   --
245   hr_utility.set_location('Entering:'||l_proc, 5);
246   --
247 
248   hr_api.mandatory_arg_error
249     (p_api_name           => l_proc
250     ,p_argument           => 'effective_date'
251     ,p_argument_value     => p_effective_date
252     );
253 
254   If p_hierarchy_type IS NOT NULL then
255     If HR_API.NOT_EXISTS_IN_HRSTANLOOKUPS(p_effective_date => p_effective_date
256                                          ,p_lookup_type    => 'HIERARCHY_TYPE'
257                                          ,p_lookup_code    => p_hierarchy_type) then
258       --
259       fnd_message.set_name('PER', 'HR_289902_PGT_HTYPE_INV');
260       fnd_message.raise_error;
261     End If;
262   Else
263     fnd_message.set_name('PER', 'HR_289903_PGT_HTYPE_NULL');
264     fnd_message.raise_error;
265   End If;
266   --
267   Exception
268    when app_exception.application_exception then
269      -- hierarchy_type requires independent validation,
270      -- catch any app exception raised above and place on stack or re-raise
271      If hr_multi_message.exception_add
272                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.HIERARCHY_TYPE') then
273        raise;
274      End If;
275   --
276   hr_utility.set_location('Leaving:'||l_proc, 50);
277   --
278 End chk_hierarchy_type;
279 --
280 --
281 -- ----------------------------------------------------------------------------
282 -- |-----------------------< chk_parent_child_node_type >---------------------|
283 -- ----------------------------------------------------------------------------
284 --
285 -- {Start Of Comments}
286 --
287 -- Description:
288 --   Validates the child node type and parent node_type as of the effective date
289 --   and within the hierarchy_type. Assumes a valid hierarchy_type. Called from
290 --   insert and update validate.
291 --
292 -- In Arguments:
293 --
294 -- Post Success:
295 --   Processing continues if valid.
296 --
297 -- Post Failure:
298 --   An application error is raised if invalid.
299 --
300 Procedure chk_parent_child_node_type
301                              (p_effective_date in date
302                              ,p_hier_node_type_id in number
303                              ,p_child_node_type in varchar2
304                              ,p_parent_node_type in varchar2
305                              ,p_hierarchy_type in varchar2) IS
306   --
307   -- CSR to test if node exists in hierarchy
308   --
309   CURSOR csr_node(l_node_type varchar2
310                  ,l_hierarchy_type varchar2) IS
311     SELECT 'X'
312     FROM per_gen_hier_node_types
313     WHERE child_node_type = l_node_type
314     AND hierarchy_type = l_hierarchy_type;
315   --
316   --
317   -- CSR to test if top node exists in hierarchy
318   --
319   CURSOR csr_top_node (l_hierarchy_type varchar2) IS
320     SELECT 'X'
321     FROM per_gen_hier_node_types
322     WHERE parent_node_type is null
323     AND hierarchy_type = l_hierarchy_type;
324   --
325   --
326   l_err_flag BOOLEAN := false;
327   l_err_parent_flag BOOLEAN := false;
328   l_proc  varchar2(72) := g_package||'chk_parent_child_node_type';
329   l_dummy varchar2(1) := null;
330 --
331 Begin
332   --
333   hr_utility.set_location('Entering:'||l_proc, 5);
334   --
335 
336   hr_api.mandatory_arg_error
337     (p_api_name           => l_proc
338     ,p_argument           => 'effective_date'
339     ,p_argument_value     => p_effective_date
340     );
341 
342     -- check child node is supplied
343     -- and a valid lookup code
344   If p_child_node_type IS NULL then
345       -- child node type requires independent validation here
346       fnd_message.set_name('PER', 'HR_289904_PGT_CNODE_TYPE_NULL');
347       hr_multi_message.add
348                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.CHILD_NODE_TYPE');
349   Else
350     --
351     -- Validate child_node_type on insert only (non-updateable) lookup code
352     --
353     If p_hier_node_type_id is null then
354       If hr_api.not_exists_in_hrstanlookups
355                               (p_effective_date => p_effective_date
356                               ,p_lookup_type    => 'HIERARCHY_NODE_TYPE'
357                               ,p_lookup_code    => p_child_node_type) then
358 
359         --
360         l_err_flag := true;
361         fnd_message.set_name('PER', 'HR_289906_PGT_CNODE_TYPE_INV');
362         -- independently validated
363         hr_multi_message.add
364                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.CHILD_NODE_TYPE');
365       End If;
366       --
367       hr_utility.set_location(l_proc, 10);
368       --
369       If not(l_err_flag) and
370         hr_multi_message.no_exclusive_error('PER_GEN_HIER_NODE_TYPES.HIERARCHY_TYPE') then
371         --
372         -- only proceed with validation if err not raised already on child_node
373         -- nor on hierarchy_type fields
374         --
375         -- check the child_node_type does not already exist in the hierarchy
379         Fetch csr_node into l_dummy;
376         -- (thus child_node + parent_node (where set) will be unique too)
377         --
378         Open csr_node(p_child_node_type, p_hierarchy_type);
380         If csr_node%found then
381           Close csr_node;
382           l_err_flag := TRUE;
383           fnd_message.set_name('PER', 'HR_289905_PGT_CNODE_NOT_UNQ');
384           -- conditionally independently validated
385           hr_multi_message.add
386                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.CHILD_NODE_TYPE');
387         Else
388           Close csr_node;
389         End if;
390         --
391         hr_utility.set_location(l_proc, 15);
392         --
393         -- check that the child_node is not the same as the parent node
394         --
395         If not(l_err_flag) and p_child_node_type = nvl(p_parent_node_type,-999) then
396           fnd_message.set_name('PER', 'HR_289907_PGT_CNODE_IS_PNODE');
397           -- conditionally independently validated
398           l_err_flag := TRUE;
399           hr_multi_message.add
400                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.CHILD_NODE_TYPE');
401         End If;
402 
403       End If;
404     End If;
405   End If;
406 
407 
408   hr_utility.set_location(l_proc, 20);
409   --
410   -- tests if parent node type is set
411   --
412   If p_parent_node_type IS NOT NULL then
413     -- validate for ins and upd
414     If (p_hier_node_type_id is null
415         or (p_hier_node_type_id is not null
416             and nvl(per_pgt_shd.g_old_rec.parent_node_type,hr_api.g_varchar2)
417             <> p_parent_node_type))
418     then
419       If hr_api.not_exists_in_hrstanlookups
420                          (p_effective_date => p_effective_date
421                          ,p_lookup_type    => 'HIERARCHY_NODE_TYPE'
422                          ,p_lookup_code    => p_parent_node_type) then
423         --
424         l_err_parent_flag := TRUE;
425         fnd_message.set_name('PER', 'HR_289908_PGT_PNODE_TYPE_INV');
426         -- independently validated
427         hr_multi_message.add
428                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.PARENT_NODE_TYPE');
429         --
430       End If;
431       --
432       hr_utility.set_location(l_proc, 30);
433       --
434       If not(l_err_parent_flag) and
435         hr_multi_message.no_exclusive_error('PER_GEN_HIER_NODE_TYPES.HIERARCHY_TYPE') then
436         --
437         -- only proceed with validation if err not raised already on parent_node
438         -- nor on hierarchy_type fields
439         --
440         -- check there is a child_node_type matching the parent_node_type
441         -- in the hierarchy already
442         Open csr_node(p_parent_node_type, p_hierarchy_type);
443         Fetch csr_node into l_dummy;
444         If csr_node%notfound then
445           Close csr_node;
446           fnd_message.set_name('PER', 'HR_289909_PGT_PNODE_NOT_CNODE');
447           hr_multi_message.add
448                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.PARENT_NODE_TYPE');
449         Else
450           Close csr_node;
451         End If;
452         hr_utility.set_location(l_proc, 35);
453 
454         -- conditionally check that the parent_node is not being updated to the same
455         -- value as the child node
456         If (not(l_err_flag) and not(l_err_parent_flag)) and
457             (p_hier_node_type_id is not null and
458             per_pgt_shd.g_old_rec.child_node_type = p_parent_node_type)
459         then
460           fnd_message.set_name('PER', 'HR_289907_PGT_CNODE_IS_PNODE');
461           hr_multi_message.add
462                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.PARENT_NODE_TYPE');
463         End If;
464       End If;
465     End If;
466   Else
467     hr_utility.set_location(l_proc, 40);
468     If (hr_multi_message.no_exclusive_error('PER_GEN_HIER_NODE_TYPES.HIERARCHY_TYPE')
469         and p_hier_node_type_id is null or (p_hier_node_type_id is not null
470          and per_pgt_shd.g_old_rec.parent_node_type IS NOT NULL )) then
471          -- parent node is null so if ins or upd and this isnt already top node
472          -- confirm that we can set this node as the top node
473          -- scope in the hierarchy
474        Open csr_top_node(p_hierarchy_type);
475        Fetch csr_top_node into l_dummy;
476        If csr_top_node%found then
477          Close csr_top_node;
478          fnd_message.set_name('PER', 'HR_289910_PGT_TOP_NODE_DUP');
479          hr_multi_message.add
480                (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.PARENT_NODE_TYPE');
481        Else
482          Close csr_top_node;
483        End If;
484     End If;
485   End If;
486   --
487   hr_utility.set_location('Leaving:'||l_proc, 50);
488    --
489 End chk_parent_child_node_type;
490 --
491 --
492 -- ----------------------------------------------------------------------------
493 -- |-----------------------< chk_child_value_set >----------------------------|
494 -- ----------------------------------------------------------------------------
495 --
496 -- {Start Of Comments}
497 --
498 -- Description:
499 --   Validates child_value_set and is called on insert and update.
500 --   Raises error if valueset is  being updated to a different value
501 --   and the scope is already used in a generic hierarchy.
502 --
503 -- In Arguments:
504 --
505 -- Post Success:
506 --   Processing continues if child_value_set is valid.
507 --
508 -- Post Failure:
509 --   An application error is raised if child_value_set is not valid.
510 --
511 Procedure chk_child_value_set(p_hier_node_type_id in number
512                             ,p_child_value_set in varchar2) IS
513 
517   WHERE flex_value_set_name = p_child_value_set;
514   CURSOR csr_vs IS
515   SELECT 'X'
516   FROM fnd_flex_value_sets
518 
519   CURSOR csr_node_used is
520   SELECT 'Y'
521   FROM per_gen_hierarchy_nodes
522   WHERE node_type = to_char(p_hier_node_type_id);
523 
524   --
525   l_proc  varchar2(72) := g_package||'chk_child_value_set';
526   l_dummy varchar2(1)  := null;
527   --
528 Begin
529   --
530   hr_utility.set_location('Entering:'||l_proc, 5);
531 
532   If p_child_value_set is null then
533     fnd_message.set_name('PER', 'HR_289911_PGT_CHILD_VS_NULL');
534     fnd_message.raise_error;
535   Else
536     If p_hier_node_type_id is null or
537        per_pgt_shd.g_old_rec.child_value_set <> p_child_value_set then
538         -- confirm that VS exist
539       Open csr_vs;
540       Fetch csr_vs into l_dummy;
541       If csr_vs%notfound then
542         Close csr_vs;
543         fnd_message.set_name('PER', 'HR_289912_PGT_CHILD_VS_INV');
544         fnd_message.raise_error;
545       Else
546         Close csr_vs;
547       End If;
548 
549       if p_hier_node_type_id is not null then
550       -- check that the VS may be updated
551       -- as not used in a generic hierarchy..
552         Open csr_node_used;
553         Fetch csr_node_used into l_dummy;
554         If csr_node_used%found then
555           Close csr_node_used;
556           fnd_message.set_name('PER', 'HR_289192_PER_CAL_VS_IN_USE');
557           fnd_message.raise_error;
558         Else
559           Close csr_node_used;
560         End If;
561       End if;
562 
563     End If;
564   End If;
565   --
566 Exception
567   when app_exception.application_exception then
568    If hr_multi_message.exception_add
569           (p_associated_column1 => 'PER_GEN_HIER_NODE_TYPES.CHILD_VALUE_SET') then
570      hr_utility.set_location('Leaving:'||l_proc, 40);
571      raise;
572    End If;
573  --
574  hr_utility.set_location('Leaving:'||l_proc, 50);
575  --
576 End chk_child_value_set;
577 --
578 -- ----------------------------------------------------------------------------
579 -- |---------------------------< insert_validate >----------------------------|
580 -- ----------------------------------------------------------------------------
581 Procedure insert_validate
582   (p_effective_date               in date
583   ,p_rec                          in per_pgt_shd.g_rec_type
584   ) is
585 --
586   l_proc  varchar2(72) := g_package||'insert_validate';
587 --
588 Begin
589   hr_utility.set_location('Entering:'||l_proc, 5);
590   --
591   -- Call all supporting business operations
592   --
593   -- EDIT_HERE: The following call to hr_api.validate_bus_grp_id
594   -- will only be valid when the business_group_id is not null.
595   -- As this column is defined as optional on the table then
596   -- different logic will be required to handle the null case.
597   -- If this is a start-up data entity then:
598   --    a) add code to stop null values being processed by this
599   --       row handler
600   -- If this is not a start-up data entity then either:
601   --    b) ignore the security_group_id value held in
602   --       client_info.  This includes performing lookup
603   --       validation against the HR_STANDARD_LOOKUPS view.
604   -- or c) (less likely) ensure the correct security_group_id
605   --       value is set in client_info.
606   -- Remove this comment when the edit has been completed.
607   -- Validate Important Attributes
608 
609   If p_rec.business_group_id is not null then
610     hr_api.validate_bus_grp_id
611       (p_business_group_id => p_rec.business_group_id
612       ,p_associated_column1 => per_pgt_shd.g_tab_nam
613                                 || '.BUSINESS_GROUP_ID');
614   End If;
615 
616   -- validate HIERARCHY_TYPE
617   chk_hierarchy_type(p_effective_date, p_rec.hierarchy_type);
618 
619   -- validate CHILD_NODE_TYPE, PARENT_NODE_TYPE
620   chk_parent_child_node_type
621                (p_effective_date     => p_effective_date
622                ,p_hier_node_type_id  => p_rec.hier_node_type_id
623                ,p_child_node_type    => p_rec.child_node_type
624                ,p_parent_node_type   => p_rec.parent_node_type
625                ,p_hierarchy_type     => p_rec.hierarchy_type);
626 
627   -- validate CHILD_VALUE_SET
628   chk_child_value_set(p_child_value_set    => p_rec.child_value_set
629                      ,p_hier_node_type_id  => p_rec.hier_node_type_id);
630   --
631   --
632   -- After validating the set of important attributes,
633   -- if Multiple Message detection is enabled and at least
634   -- one error has been found then abort further validation.
635   --
636   hr_multi_message.end_validation_set;
637   --
638   hr_utility.set_location(' Leaving:'||l_proc, 10);
639 End insert_validate;
640 --
641 -- ----------------------------------------------------------------------------
642 -- |---------------------------< update_validate >----------------------------|
643 -- ----------------------------------------------------------------------------
644 Procedure update_validate
645   (p_effective_date               in date
646   ,p_rec                          in per_pgt_shd.g_rec_type
647   ) is
648 --
649   l_proc  varchar2(72) := g_package||'update_validate';
650 --
651 Begin
652   hr_utility.set_location('Entering:'||l_proc, 5);
653   --
654   -- Call all supporting business operations
655   --
656    If p_rec.business_group_id is not null then
657      hr_api.validate_bus_grp_id
658       (p_business_group_id => p_rec.business_group_id
659       ,p_associated_column1 => per_pgt_shd.g_tab_nam
663 
660                                 || '.BUSINESS_GROUP_ID');
661    End If;
662 
664   -- validate CHILD_NODE_TYPE, PARENT_NODE_TYPE
665   chk_parent_child_node_type
666                (p_effective_date     => p_effective_date
667                ,p_hier_node_type_id  => p_rec.hier_node_type_id
668                ,p_child_node_type    => p_rec.child_node_type
669                ,p_parent_node_type   => p_rec.parent_node_type
670                ,p_hierarchy_type     => p_rec.hierarchy_type);
671 
672   -- validate CHILD_VALUE_SET
673   chk_child_value_set(p_child_value_set    => p_rec.child_value_set
674                      ,p_hier_node_type_id  => p_rec.hier_node_type_id);
675   --
676   -- After validating the set of important attributes,
677   -- if Multiple Message detection is enabled and at least
678   -- one error has been found then abort further validation.
679   --
680   hr_multi_message.end_validation_set;
681   --
682   -- Validate Dependent Attributes
683   --
684   chk_non_updateable_args
685     (p_effective_date              => p_effective_date
686       ,p_rec              => p_rec
687     );
688   --
689   --
690   hr_utility.set_location(' Leaving:'||l_proc, 10);
691 End update_validate;
692 --
693 -- ----------------------------------------------------------------------------
694 -- |---------------------------< delete_validate >----------------------------|
695 -- ----------------------------------------------------------------------------
696 Procedure delete_validate
697   (p_rec                          in per_pgt_shd.g_rec_type
698   ) is
699 
700   -- csr to see if any hierarchy nodes reference this scope
701   CURSOR csr_node_used is
702    select 'Y'
703     from per_gen_hierarchy_nodes
704     where node_type = to_char(p_rec.hier_node_type_id);
705 
706    l_proc  varchar2(72) := g_package||'delete_validate';
707    l_dummy varchar2(1);
708 --
709 Begin
710   hr_utility.set_location('Entering:'||l_proc, 5);
711   --
712   -- Call all supporting business operations
713   --
714   --
715   -- To validate that delete is allowed, check that:
716   -- 1) node_type is not referenced in is the lowest level (has no chilren) in its
717   --    node type hierarchy (or global)
718   -- 2) the node's type hierarchy is not used in a generic hierarchy already
719 
720   If 'Y' = hr_calendar_node_type_api.child_exists(p_hierarchy_type => p_rec.hierarchy_type
721                                                  ,p_child_node_type => p_rec.child_node_type) then
722     fnd_message.set_name('PER', 'HR_289913_PER_CAL_CHILD_EXISTS');
723     fnd_message.raise_error;
724   End if;
725 
726    -- bug 2982313 rework this to actually check if the scope record is being used in a generic hierarchy
727    -- rather than checking if hierarchy type has been used by the open .
728     --If 'Y' = hr_calendar_node_type_api.gen_hier_exists(p_hierarchy_type => p_rec.hierarchy_type) then
729     -- fnd_message.set_name('PER', 'HR_289914_PER_CAL_HIER_EXISTS');
730     -- fnd_message.raise_error;
731     --End if;
732   open csr_node_used;
733   fetch csr_node_used into l_dummy;
734   if csr_node_used%found then
735     close csr_node_used;
736     fnd_message.set_name('PER', 'HR_289914_PER_CAL_HIER_EXISTS');
737     fnd_message.raise_error;
738   else
739     close csr_node_used;
740   end if;
741   -- end bug 2982313.
742 
743 
744 
745   hr_utility.set_location(' Leaving:'||l_proc, 10);
746 End delete_validate;
747 --
748 end per_pgt_bus;