DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HPH_BUS

Source


1 Package Body hxc_hph_bus as
2 /* $Header: hxchphrhi.pkb 120.2.12000000.2 2007/03/16 13:22:54 rchennur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_hph_bus.';  -- Global package name
9 g_debug	   boolean	:= hr_utility.debug_enabled;
10 --
11 -- The following two global variables are only to be
12 -- used by the return_legislation_code function.
13 --
14 g_legislation_code            varchar2(150)  default null;
15 g_pref_hierarchy_id           number         default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_pref_hierarchy_id                    in number
23   ) is
24   --
25   -- Declare cursor
26   --
27   -- EDIT_HERE  In the following cursor statement add join(s) between
28   -- hxc_pref_hierarchies and PER_BUSINESS_GROUPS
29   -- so that the security_group_id for
30   -- the current business group context can be derived.
31   -- Remove this comment when the edit has been completed.
32   cursor csr_sec_grp is
33     select pbg.security_group_id
34       from per_business_groups pbg
35          , hxc_pref_hierarchies hph
36       --   , EDIT_HERE table_name(s) 333
37      where hph.pref_hierarchy_id = p_pref_hierarchy_id;
38       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
39   --
40   -- Declare local variables
41   --
42   l_security_group_id number;
43   l_proc              varchar2(72) ;
44   --
45 begin
46   --
47   g_debug:=hr_utility.debug_enabled;
48   if g_debug then
49 	l_proc :=  g_package||'set_security_group_id';
50 	hr_utility.set_location('Entering:'|| l_proc, 10);
51   end if;
52   --
53   -- Ensure that all the mandatory parameter are not null
54   --
55   hr_api.mandatory_arg_error
56     (p_api_name           => l_proc
57     ,p_argument           => 'pref_hierarchy_id'
58     ,p_argument_value     => p_pref_hierarchy_id
59     );
60   --
61   open csr_sec_grp;
62   fetch csr_sec_grp into l_security_group_id;
63   --
64   if csr_sec_grp%notfound then
65      --
66      close csr_sec_grp;
67      --
68      -- The primary key is invalid therefore we must error
69      --
70      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
71      fnd_message.raise_error;
72      --
73   end if;
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   if g_debug then
83 	hr_utility.set_location(' Leaving:'|| l_proc, 20);
84   end if;
85   --
86 end set_security_group_id;
87 --
88 --  ---------------------------------------------------------------------------
89 --  |---------------------< return_legislation_code >-------------------------|
90 --  ---------------------------------------------------------------------------
91 --
92 Function return_legislation_code
93   (p_pref_hierarchy_id                    in     number
94   )
95   Return Varchar2 Is
96   --
97   -- Declare cursor
98   --
99   -- EDIT_HERE  In the following cursor statement add join(s) between
100   -- hxc_pref_hierarchies and PER_BUSINESS_GROUPS
101   -- so that the legislation_code for
102   -- the current business group context can be derived.
103   -- Remove this comment when the edit has been completed.
104   cursor csr_leg_code is
105     select pbg.legislation_code
106       from per_business_groups     pbg
107          , hxc_pref_hierarchies hph
108       --   , EDIT_HERE table_name(s) 333
109      where hph.pref_hierarchy_id = p_pref_hierarchy_id;
110       -- and pbg.business_group_id = EDIT_HERE 333.business_group_id;
111   --
112   -- Declare local variables
113   --
114   l_legislation_code  varchar2(150);
115   l_proc              varchar2(72);
116   --
117 Begin
118   --
119   g_debug:=hr_utility.debug_enabled;
120   if g_debug then
121 	l_proc  :=  g_package||'return_legislation_code';
122 	hr_utility.set_location('Entering:'|| l_proc, 10);
123   end if;--
124   -- Ensure that all the mandatory parameter are not null
125   --
126   hr_api.mandatory_arg_error
127     (p_api_name           => l_proc
128     ,p_argument           => 'pref_hierarchy_id'
129     ,p_argument_value     => p_pref_hierarchy_id
130     );
131   --
132   if ( nvl(hxc_hph_bus.g_pref_hierarchy_id, hr_api.g_number)
133        = p_pref_hierarchy_id) then
134     --
135     -- The legislation code has already been found with a previous
136     -- call to this function. Just return the value in the global
137     -- variable.
138     --
139     l_legislation_code := hxc_hph_bus.g_legislation_code;
140     if g_debug then
141 	hr_utility.set_location(l_proc, 20);
142     end if;
143   else
144     --
145     -- The ID is different to the last call to this function
146     -- or this is the first call to this function.
147     --
148     open csr_leg_code;
149     fetch csr_leg_code into l_legislation_code;
150     --
151     if csr_leg_code%notfound then
152       --
153       -- The primary key is invalid therefore we must error
154       --
155       close csr_leg_code;
156       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
157       fnd_message.raise_error;
158     end if;
159     if g_debug then
160 	hr_utility.set_location(l_proc,30);
161     end if;
162     --
163     -- Set the global variables so the values are
164     -- available for the next call to this function.
165     --
166     close csr_leg_code;
167     hxc_hph_bus.g_pref_hierarchy_id := p_pref_hierarchy_id;
168     hxc_hph_bus.g_legislation_code  := l_legislation_code;
169   end if;
170   if g_debug then
171 	hr_utility.set_location(' Leaving:'|| l_proc, 40);
172   end if;
173   return l_legislation_code;
174 end return_legislation_code;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |------------------------------< chk_df >----------------------------------|
178 -- ----------------------------------------------------------------------------
179 --
180 -- Description:
181 --   Validates all the Descriptive Flexfield values.
182 --
183 -- Prerequisites:
184 --   All other columns have been validated.  Must be called as the
185 --   last step from insert_validate and update_validate.
186 --
187 -- In Arguments:
188 --   p_rec
189 --
190 -- Post Success:
191 --   If the Descriptive Flexfield structure column and data values are
192 --   all valid this procedure will end normally and processing will
193 --   continue.
194 --
195 -- Post Failure:
196 --   If the Descriptive Flexfield structure column value or any of
197 --   the data values are invalid then an application error is raised as
198 --   a PL/SQL exception.
199 --
200 -- Access Status:
201 --   Internal Row Handler Use Only.
202 --
203 -- ----------------------------------------------------------------------------
204 procedure chk_df
205   (p_rec in hxc_hph_shd.g_rec_type
206   ) is
207 --
208   l_proc   varchar2(72);
209 --
210 begin
211   g_debug:=hr_utility.debug_enabled;
212   if g_debug then
213 	l_proc := g_package || 'chk_df';
214 	hr_utility.set_location('Entering:'||l_proc,10);
215   end if;
216   --
217   if ((p_rec.pref_hierarchy_id is not null)  and (
218     nvl(hxc_hph_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
219     nvl(p_rec.attribute_category, hr_api.g_varchar2)  or
220     nvl(hxc_hph_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
221     nvl(p_rec.attribute1, hr_api.g_varchar2)  or
222     nvl(hxc_hph_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
223     nvl(p_rec.attribute2, hr_api.g_varchar2)  or
224     nvl(hxc_hph_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
225     nvl(p_rec.attribute3, hr_api.g_varchar2)  or
226     nvl(hxc_hph_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
227     nvl(p_rec.attribute4, hr_api.g_varchar2)  or
228     nvl(hxc_hph_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
229     nvl(p_rec.attribute5, hr_api.g_varchar2)  or
230     nvl(hxc_hph_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
231     nvl(p_rec.attribute6, hr_api.g_varchar2)  or
232     nvl(hxc_hph_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
233     nvl(p_rec.attribute7, hr_api.g_varchar2)  or
234     nvl(hxc_hph_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
235     nvl(p_rec.attribute8, hr_api.g_varchar2)  or
236     nvl(hxc_hph_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
237     nvl(p_rec.attribute9, hr_api.g_varchar2)  or
238     nvl(hxc_hph_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
239     nvl(p_rec.attribute10, hr_api.g_varchar2)  or
240     nvl(hxc_hph_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
241     nvl(p_rec.attribute11, hr_api.g_varchar2)  or
242     nvl(hxc_hph_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
243     nvl(p_rec.attribute12, hr_api.g_varchar2)  or
244     nvl(hxc_hph_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
245     nvl(p_rec.attribute13, hr_api.g_varchar2)  or
246     nvl(hxc_hph_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
247     nvl(p_rec.attribute14, hr_api.g_varchar2)  or
248     nvl(hxc_hph_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
249     nvl(p_rec.attribute15, hr_api.g_varchar2)  or
250     nvl(hxc_hph_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
251     nvl(p_rec.attribute16, hr_api.g_varchar2)  or
252     nvl(hxc_hph_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
253     nvl(p_rec.attribute17, hr_api.g_varchar2)  or
254     nvl(hxc_hph_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
255     nvl(p_rec.attribute18, hr_api.g_varchar2)  or
256     nvl(hxc_hph_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
257     nvl(p_rec.attribute19, hr_api.g_varchar2)  or
258     nvl(hxc_hph_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
259     nvl(p_rec.attribute20, hr_api.g_varchar2)  or
260     nvl(hxc_hph_shd.g_old_rec.attribute21, hr_api.g_varchar2) <>
261     nvl(p_rec.attribute21, hr_api.g_varchar2)  or
262     nvl(hxc_hph_shd.g_old_rec.attribute22, hr_api.g_varchar2) <>
263     nvl(p_rec.attribute22, hr_api.g_varchar2)  or
264     nvl(hxc_hph_shd.g_old_rec.attribute23, hr_api.g_varchar2) <>
265     nvl(p_rec.attribute23, hr_api.g_varchar2)  or
266     nvl(hxc_hph_shd.g_old_rec.attribute24, hr_api.g_varchar2) <>
267     nvl(p_rec.attribute24, hr_api.g_varchar2)  or
268     nvl(hxc_hph_shd.g_old_rec.attribute25, hr_api.g_varchar2) <>
269     nvl(p_rec.attribute25, hr_api.g_varchar2)  or
270     nvl(hxc_hph_shd.g_old_rec.attribute26, hr_api.g_varchar2) <>
271     nvl(p_rec.attribute26, hr_api.g_varchar2)  or
272     nvl(hxc_hph_shd.g_old_rec.attribute27, hr_api.g_varchar2) <>
273     nvl(p_rec.attribute27, hr_api.g_varchar2)  or
274     nvl(hxc_hph_shd.g_old_rec.attribute28, hr_api.g_varchar2) <>
275     nvl(p_rec.attribute28, hr_api.g_varchar2)  or
276     nvl(hxc_hph_shd.g_old_rec.attribute29, hr_api.g_varchar2) <>
277     nvl(p_rec.attribute29, hr_api.g_varchar2)  or
278     nvl(hxc_hph_shd.g_old_rec.attribute30, hr_api.g_varchar2) <>
279     nvl(p_rec.attribute30, hr_api.g_varchar2)  ))
280     or (p_rec.pref_hierarchy_id is null)  then
281     --
282     -- Only execute the validation if absolutely necessary:
283     -- a) During update, the structure column value or any
284     --    of the attribute values have actually changed.
285     -- b) During insert.
286     --
287     hr_dflex_utility.ins_or_upd_descflex_attribs
288       (p_appl_short_name                 => 'HXC'
289      -- ,p_descflex_name                   => 'EDIT_HERE: Enter descflex name'
290       ,p_descflex_name                   => 'OTC PREFERENCES'
291      -- ,p_attribute_category              => 'ATTRIBUTE_CATEGORY'
292       ,p_attribute_category              => p_rec.attribute_category
293       ,p_attribute1_name                 => 'ATTRIBUTE1'
294       ,p_attribute1_value                => p_rec.attribute1
295       ,p_attribute2_name                 => 'ATTRIBUTE2'
296       ,p_attribute2_value                => p_rec.attribute2
297       ,p_attribute3_name                 => 'ATTRIBUTE3'
298       ,p_attribute3_value                => p_rec.attribute3
299       ,p_attribute4_name                 => 'ATTRIBUTE4'
300       ,p_attribute4_value                => p_rec.attribute4
301       ,p_attribute5_name                 => 'ATTRIBUTE5'
302       ,p_attribute5_value                => p_rec.attribute5
303       ,p_attribute6_name                 => 'ATTRIBUTE6'
304       ,p_attribute6_value                => p_rec.attribute6
305       ,p_attribute7_name                 => 'ATTRIBUTE7'
306       ,p_attribute7_value                => p_rec.attribute7
307       ,p_attribute8_name                 => 'ATTRIBUTE8'
308       ,p_attribute8_value                => p_rec.attribute8
309       ,p_attribute9_name                 => 'ATTRIBUTE9'
310       ,p_attribute9_value                => p_rec.attribute9
311       ,p_attribute10_name                => 'ATTRIBUTE10'
312       ,p_attribute10_value               => p_rec.attribute10
313       ,p_attribute11_name                => 'ATTRIBUTE11'
314       ,p_attribute11_value               => p_rec.attribute11
315       ,p_attribute12_name                => 'ATTRIBUTE12'
316       ,p_attribute12_value               => p_rec.attribute12
317       ,p_attribute13_name                => 'ATTRIBUTE13'
318       ,p_attribute13_value               => p_rec.attribute13
319       ,p_attribute14_name                => 'ATTRIBUTE14'
320       ,p_attribute14_value               => p_rec.attribute14
321       ,p_attribute15_name                => 'ATTRIBUTE15'
322       ,p_attribute15_value               => p_rec.attribute15
323       ,p_attribute16_name                => 'ATTRIBUTE16'
324       ,p_attribute16_value               => p_rec.attribute16
325       ,p_attribute17_name                => 'ATTRIBUTE17'
326       ,p_attribute17_value               => p_rec.attribute17
327       ,p_attribute18_name                => 'ATTRIBUTE18'
328       ,p_attribute18_value               => p_rec.attribute18
329       ,p_attribute19_name                => 'ATTRIBUTE19'
330       ,p_attribute19_value               => p_rec.attribute19
331       ,p_attribute20_name                => 'ATTRIBUTE20'
332       ,p_attribute20_value               => p_rec.attribute20
333       ,p_attribute21_name                => 'ATTRIBUTE21'
334       ,p_attribute21_value               => p_rec.attribute21
335       ,p_attribute22_name                => 'ATTRIBUTE22'
336       ,p_attribute22_value               => p_rec.attribute22
337       ,p_attribute23_name                => 'ATTRIBUTE23'
338       ,p_attribute23_value               => p_rec.attribute23
339       ,p_attribute24_name                => 'ATTRIBUTE24'
340       ,p_attribute24_value               => p_rec.attribute24
341       ,p_attribute25_name                => 'ATTRIBUTE25'
342       ,p_attribute25_value               => p_rec.attribute25
343       ,p_attribute26_name                => 'ATTRIBUTE26'
344       ,p_attribute26_value               => p_rec.attribute26
345       ,p_attribute27_name                => 'ATTRIBUTE27'
346       ,p_attribute27_value               => p_rec.attribute27
347       ,p_attribute28_name                => 'ATTRIBUTE28'
348       ,p_attribute28_value               => p_rec.attribute28
349       ,p_attribute29_name                => 'ATTRIBUTE29'
350       ,p_attribute29_value               => p_rec.attribute29
351       ,p_attribute30_name                => 'ATTRIBUTE30'
352       ,p_attribute30_value               => p_rec.attribute30
353       );
354   end if;
355   --
356   if g_debug then
357 	hr_utility.set_location(' Leaving:'||l_proc,20);
358   end if;
359 end chk_df;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |-----------------------< chk_non_updateable_args >------------------------|
363 -- ----------------------------------------------------------------------------
364 -- {Start Of Comments}
365 --
366 -- Description:
367 --   This procedure is used to ensure that non updateable attributes have
368 --   not been updated. If an attribute has been updated an error is generated.
369 --
370 -- Pre Conditions:
371 --   g_old_rec has been populated with details of the values currently in
372 --   the database.
373 --
374 -- In Arguments:
375 --   p_rec has been populated with the updated values the user would like the
376 --   record set to.
377 --
378 -- Post Success:
379 --   Processing continues if all the non updateable attributes have not
380 --   changed.
381 --
382 -- Post Failure:
383 --   An application error is raised if any of the non updatable attributes
384 --   have been altered.
385 --
386 -- {End Of Comments}
387 -- ----------------------------------------------------------------------------
388 Procedure chk_non_updateable_args
389   (p_effective_date               in date
390   ,p_rec in hxc_hph_shd.g_rec_type
391   ) IS
392 --
393   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
394   l_error    EXCEPTION;
395   l_argument varchar2(30);
396 --
397 Begin
398   --
399   -- Only proceed with the validation if a row exists for the current
400   -- record in the HR Schema.
401   --
402   IF NOT hxc_hph_shd.api_updating
403       (p_pref_hierarchy_id                    => p_rec.pref_hierarchy_id
404       ,p_object_version_number                => p_rec.object_version_number
405       ) THEN
406      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
407      fnd_message.set_token('PROCEDURE ', l_proc);
408      fnd_message.set_token('STEP ', '5');
409      fnd_message.raise_error;
410   END IF;
411   --
412   -- EDIT_HERE: Add checks to ensure non-updateable args have
413   --            not been updated.
414   --
415   EXCEPTION
416     WHEN l_error THEN
417        hr_api.argument_changed_error
418          (p_api_name => l_proc
419          ,p_argument => l_argument);
420     WHEN OTHERS THEN
421        RAISE;
422 End chk_non_updateable_args;
423 --
424 -- ----------------------------------------------------------------------------
425 -- |-----------------------------< chk_name >---------------------------------|
426 -- ----------------------------------------------------------------------------
427 -- {Start Of Comments}
428 --
429 -- Description:
430 -- This procedure ensures that a valid and a unique Preference Hierarchy name
431 -- has been entered for a parent.i.e., No two children of a parent can have the
432 -- same name.
433 --
434 -- Pre Conditions:
435 --   None
436 --
437 -- In Arguments:
438 --   name
439 --   parent_pref_hierarchy_id
440 --   object_version_number
441 --
442 -- Post Success:
443 --   Processing continues if a valid and a unique name has been entered for a
444 --   parent
445 --
446 -- Post Failure:
447 --   An application error is raised if the child name is not unique
448 --
449 -- {End Of Comments}
450 -- ----------------------------------------------------------------------------
451 Procedure chk_name
452   (
453 p_name in hxc_pref_hierarchies.name%TYPE,
454 p_business_group_id in hxc_pref_hierarchies.business_group_id%TYPE,
455 p_parent_pref_hierarchy_id in hxc_pref_hierarchies.parent_pref_hierarchy_id%TYPE
456 ,
457 p_object_version_number in hxc_pref_hierarchies.object_version_number%TYPE
458   ) IS
459 --
460   l_proc  varchar2(72);
461 --
462 -- cursor to check that a duplicate child pref hierarchy name is not entered
463 --
464 CURSOR  csr_chk_name IS
465 SELECT 'error'
466 FROM    sys.dual
467 WHERE EXISTS (
468        SELECT  'x'
469        FROM    hxc_pref_hierarchies hph
470        WHERE   upper(hph.name) = upper(p_name)
471        AND     hph.object_version_number <> NVL(p_object_version_number, -1)
472        AND     (business_group_id = p_business_group_id or business_group_id is null)
473        AND     level = 1
474        START WITH hph.parent_pref_hierarchy_id = p_parent_pref_hierarchy_id
475        CONNECT BY PRIOR hph.pref_hierarchy_id = hph.parent_pref_hierarchy_id);
476 --
477  l_error varchar2(5) := NULL;
478 --
479 BEGIN
480   g_debug:=hr_utility.debug_enabled;
481   if g_debug then
482 	l_proc := g_package||'chk_name';
483 	hr_utility.set_location('Entering:'||l_proc, 5);
484   end if;
485 --
486 -- Raise error if name is NULL as it is a mandatory field.
487 --
488 IF p_name IS NULL
489 THEN
490 --
491       hr_utility.set_message(809, 'HXC_0077_HPH_PREF_NAME_MAND');
492       hr_utility.raise_error;
493 --
494 END IF;
495   if g_debug then
496 	hr_utility.set_location('Processing:'||l_proc, 10);
497   end if;
498 --
499 -- Raise an error if the child preference hierarchy name is not unique
500 --
501   OPEN  csr_chk_name;
502   FETCH csr_chk_name INTO l_error;
503   CLOSE csr_chk_name;
504 --
505 IF l_error IS NOT NULL
506 THEN
507 --
508       hr_utility.set_message(809, 'HXC_0078_HPH_DUP_PREF_NAME');
509       hr_utility.raise_error;
510 --
511 END IF;
512 --
513   if g_debug then
514 	hr_utility.set_location('Leaving:'||l_proc, 20);
515   end if;
516 --
517 END chk_name;
518 
519 
520 PROCEDURE chk_rules_evaluation_pref (
521           p_pref_code   VARCHAR2
522         , p_attribute1  VARCHAR2
523         , p_attribute2  VARCHAR2 ) IS
524 
525 BEGIN
526 
527 IF ( p_pref_code = 'TC_W_RULES_EVALUATION' )
528 THEN
529 
530 	IF ( p_attribute1 = 'Y' )
531 	THEN
532 		IF ( p_attribute2 IS NULL )
533 		THEN
534 		      hr_utility.set_message(809, 'HXC_HPH_RULES_EVALUATION');
535 		      hr_utility.raise_error;
536 		END IF;
537 	END IF;
538 
539 END IF;
540 
541 END chk_rules_evaluation_pref;
542 
543 PROCEDURE chk_days_hours_factor (
544           p_pref_code   VARCHAR2
545         , p_attribute1  VARCHAR2
546         , p_attribute2  VARCHAR2 ) IS
547 BEGIN
548 IF ( p_pref_code = 'TS_PER_DAYS_TO_HOURS' )
549 THEN
550         IF ( p_attribute1 is not null ) and (p_attribute2 is null)
551         THEN
552                       hr_utility.set_message(809, 'HXC_DAYS_HOURS');
553                       hr_utility.raise_error;
554         END IF;
555 END IF;
556 END chk_days_hours_factor;
557 
558 
559 PROCEDURE chk_tk_person_name_number (
560           p_pref_code   VARCHAR2
561         , p_attribute2  VARCHAR2
562         , p_attribute3  VARCHAR2 ) IS
563 BEGIN
564 IF ( p_pref_code = 'TK_TCARD_SETUP' )
565 THEN
566         IF ( p_attribute2 = 'N' ) and (p_attribute3 = 'N')
567         THEN
568                       hr_utility.set_message(809, 'HXC_TK_PERSON_NAME_NUMBER');
569                       hr_utility.raise_error;
570         END IF;
571 END IF;
572 END chk_tk_person_name_number;
573 
574 PROCEDURE chk_tk_audit_segments (
575           p_pref_code   VARCHAR2
576         , p_attribute1  VARCHAR2
577         , p_attribute2  VARCHAR2
578         , p_attribute3  VARCHAR2
579         , p_attribute4 VARCHAR2 ) IS
580 BEGIN
581 IF ( p_pref_code = 'TK_TCARD_CLA' )
582 THEN
583         IF ( p_attribute1 = 'Y' )
584        and ( p_attribute2 is Null or
585              p_attribute3 is Null or
586 	     (p_attribute4 is Null and p_attribute3 <>'NONE'))
587         THEN
588                       hr_utility.set_message(809, 'HXC_TK_AUDIT_SEG_REQ');
589                       hr_utility.raise_error;
590         END IF;
591 END IF;
592 END chk_tk_audit_segments;
593 
594 --
595 -- -----------------------------------------------------------------------------------
596 -- |-----------------------------< get_top_level_id >---------------------------------|
597 -- -----------------------------------------------------------------------------------
598 -- {Start Of Comments}
599 --
600 -- Description:
601 -- This function return the top level id of a particular none in the hierarchy
602 --
603 function get_top_level_id(p_pref_id in number)
604  return number is
605 
606 --Performance Fix
607 /*cursor csr_top  (p_preference_id number) is
608 select parent_pref_hierarchy_id
609 from hxc_pref_hierarchies hph
610 where pref_hierarchy_id = p_preference_id;*/
611 
612 cursor csr_top (p_preference_id number) is
613 select top_level_parent_id                 --Performance Fix
614 from hxc_pref_hierarchies hph
615 where pref_hierarchy_id = p_preference_id;
616 
617 l_parent_id  number;
618 l_temp_parent_id  number;
619 
620 Begin
621 
622 l_parent_id := null;
623 
624   OPEN  csr_top (p_pref_id) ;
625   FETCH csr_top INTO l_parent_id;
626   CLOSE csr_top;
627 
628   if l_parent_id is null then
629      l_parent_id := p_pref_id;
630   end if;
631 
632 --Performance Fix
633 /*  l_temp_parent_id := l_parent_id;
634 
635   WHILE l_temp_parent_id is not null LOOP
636    OPEN  csr_top (l_temp_parent_id) ;
637    FETCH csr_top INTO l_temp_parent_id;
638    CLOSE csr_top;
639    if l_temp_parent_id is not null then
640      l_parent_id := l_temp_parent_id;
641    end if;
642   END LOOP;*/
643 
644 return l_parent_id;
645 
646 end;
647 --
648 -- -------------------------------------------------------------------------------------
649 -- |-----------------------------< get_top_level_name >---------------------------------|
650 -- ------------------------------------------------------------------------------------
651 -- {Start Of Comments}
652 --
653 -- Description:
654 -- This function return the top level id of a particular none in the hierarchy
655 --
656 function get_top_level_name(p_pref_id in number)
657  return varchar2 is
658 
659 --Performance Fix
660 /*cursor csr_top  (p_preference_id number) is
661 select parent_pref_hierarchy_id ,name
662 from hxc_pref_hierarchies hph
663 where pref_hierarchy_id = p_preference_id;*/
664 
665 cursor csr_top (p_preference_id number) is
666 select hph.name
667 from hxc_pref_hierarchies hph
668     ,hxc_pref_hierarchies hph1
669 where hph.pref_hierarchy_id = hph1.top_level_parent_id  --Performance Fix
670   and hph1.pref_hierarchy_id = p_preference_id;
671 
672 l_parent_id  number;
673 l_parent_name varchar2(80);
674 
675 l_temp_parent_id  number;
676 l_temp_parent_name varchar2(80);
677 
678 Begin
679 
680 l_parent_id := null;
681 l_parent_name := null;
682 
683   OPEN  csr_top (p_pref_id) ;
684   FETCH csr_top INTO l_parent_name;
685   CLOSE csr_top;
686 
687 --Performance Fix
688 /*  l_temp_parent_id := l_parent_id;
689 
690   WHILE l_temp_parent_id is not null LOOP
691    OPEN  csr_top (l_temp_parent_id) ;
692    FETCH csr_top INTO l_temp_parent_id,l_temp_parent_name;
693    CLOSE csr_top;
694    if l_temp_parent_id is not null then
695      l_parent_id := l_temp_parent_id;
696      l_parent_name := l_temp_parent_name;
697    end if;
698   END LOOP;*/
699 
700 return l_parent_name;
701 
702 end;
703 --
704 -- ----------------------------------------------------------------------------
705 -- |-----------------------------< chk_pref_code >---------------------------------|
706 -- ----------------------------------------------------------------------------
707 -- {Start Of Comments}
708 --
709 -- Description:
710 -- This procedure ensures that a valid and a unique Preference Hierarchy code
711 -- has been entered for a parent.i.e., No two children from the top levelparent
712 -- can have the same pref code.
713 --
714 -- Pre Conditions:
715 --   None
716 --
717 -- In Arguments:
718 --   name
719 --   parent_pref_hierarchy_id
720 --   object_version_number
721 --
722 -- Post Success:
723 --   Processing continues if a valid and a unique name has been entered for a
724 --   parent
725 --
726 -- Post Failure:
727 --   An application error is raised if the child name is not unique
728 --
729 -- {End Of Comments}
730 -- ----------------------------------------------------------------------------
731 Procedure chk_pref_code
732   (
733 p_pref_code in hxc_pref_hierarchies.attribute_category%TYPE,
734 p_parent_pref_hierarchy_id in hxc_pref_hierarchies.parent_pref_hierarchy_id%TYPE,
735 p_pref_hierarchy_id in hxc_pref_hierarchies.pref_hierarchy_id%TYPE,
736 p_object_version_number in hxc_pref_hierarchies.object_version_number%TYPE
737   ) IS
738 --
739   l_proc  varchar2(72);
740 --
741 -- cursor to check that a duplicate child pref hierarchy name is not entered
742 --
743 
744 CURSOR  csr_chk_code IS
745 SELECT 'error'
746 FROM    sys.dual
747 WHERE EXISTS (
748        SELECT  'x'
749        FROM    hxc_pref_hierarchies hph
750        WHERE   hph.attribute_category = p_pref_code
751        and     hph.pref_hierarchy_id <> p_pref_hierarchy_id
752        START WITH hph.parent_pref_hierarchy_id = hxc_hph_bus.get_top_level_id(p_parent_pref_hierarchy_id)
753        CONNECT BY PRIOR hph.pref_hierarchy_id = hph.parent_pref_hierarchy_id);
754 
755 CURSOR  csr_chk_code2 IS
756 SELECT 'error'
757 FROM    sys.dual
758 WHERE EXISTS (
759        SELECT  'x'
760        FROM    hxc_pref_hierarchies hph
761        WHERE   hph.attribute_category is not null
762        and     hph.pref_hierarchy_id = p_parent_pref_hierarchy_id);
763 
764 --
765  l_error varchar2(5) := NULL;
766  l_error2 varchar2(5) := NULL;
767 --
768 BEGIN
769   g_debug:=hr_utility.debug_enabled;
770   if g_debug then
771 	l_proc := g_package||'chk_code';
772 	hr_utility.set_location('Entering:'||l_proc, 5);
773   end if;
774 --
775 -- Raise error if name is NULL as it is a mandatory field.
776 --
777 IF p_pref_code IS NOT NULL THEN
778 --
779   if g_debug then
780 	hr_utility.set_location('Processing:'||l_proc, 10);
781   end if;
782 --
783 -- Raise an error if the child preference hierarchy name is not unique
784 --
785   OPEN  csr_chk_code;
786   FETCH csr_chk_code INTO l_error;
787   CLOSE csr_chk_code;
788 --
789 IF l_error IS NOT NULL
790 THEN
791 --
792       hr_utility.set_message(809, 'HXC_HPH_DUP_PREF_CODE');
793       hr_utility.raise_error;
794 --
795 END IF;
796 --
797 END IF;
798 --
799   OPEN  csr_chk_code2;
800   FETCH csr_chk_code2 INTO l_error2;
801   CLOSE csr_chk_code2;
802 --
803 IF l_error2 IS NOT NULL
804 THEN
805 --
806       hr_utility.set_message(809, 'HXC_HPH_NOT_PREF_PARENT');
807       hr_utility.raise_error;
808 --
809 END IF;
810   if g_debug then
811 	hr_utility.set_location('Leaving:'||l_proc, 20);
812   end if;
813 --
814 
815 END chk_pref_code;
816 --
817 --
818 -- ----------------------------------------------------------------------------
819 -- |-----------------------------< chk_top_node >-----------------------------|
820 -- ----------------------------------------------------------------------------
821 -- {Start Of Comments}
822 --
823 -- Description:
824 -- This procedure ensures that a valid and a unique Top Node Preference name
825 -- has been entered
826 --
827 -- Pre Conditions:
828 --   None
829 --
830 -- In Arguments:
831 --   name
832 --   object_version_number
833 --
834 -- Post Success:
835 --   Processing continues if a valid and a unique top node name has been
836 --   entered
837 --
838 -- Post Failure:
839 --   An application error is raised if the top node name is not unique
840 --
841 -- {End Of Comments}
842 -- ----------------------------------------------------------------------------
843 Procedure chk_top_node
844   (
845 p_name in hxc_pref_hierarchies.name%TYPE,
846 p_business_group_id in hxc_pref_hierarchies.business_group_id%TYPE,
847 p_object_version_number in hxc_pref_hierarchies.object_version_number%TYPE
848   ) IS
849 --
850   l_proc  varchar2(72);
851 --
852 -- cursor to check that a duplicate top node name is not entered
853 --
854 CURSOR  csr_chk_top_node IS
855 SELECT 'error'
856 FROM    sys.dual
857 WHERE EXISTS (
858        SELECT  'x'
859        FROM    hxc_pref_hierarchies hph
860        WHERE   hph.name = p_name
861        AND     (business_group_id = p_business_group_id or business_group_id is null)
862        AND     hph.object_version_number <> NVL(p_object_version_number, -1)
863        AND     hph.parent_pref_hierarchy_id is null);
864 --
865  l_error varchar2(5) := NULL;
866 --
867 BEGIN
868   g_debug:=hr_utility.debug_enabled;
869   if g_debug then
870 	l_proc := g_package||'chk_top_node';
871 	hr_utility.set_location('Entering:'||l_proc, 5);
872   end if;
873 --
874 -- Raise an error if the top node preference name is not unique
875 --
876   OPEN  csr_chk_top_node;
877   FETCH csr_chk_top_node INTO l_error;
878   CLOSE csr_chk_top_node;
879 --
880 IF l_error IS NOT NULL
881 THEN
882 --
883       hr_utility.set_message(809, 'HXC_0149_HPH_TOP_NODE_EXIST');
884       hr_utility.raise_error;
885 --
886 END IF;
887 --
888   if g_debug then
889 	hr_utility.set_location('Leaving:'||l_proc, 5);
890   end if;
891 --
892 END chk_top_node;
893 --
894 -- ----------------------------------------------------------------------------
895 -- |-----------------------------< chk_preference >---------------------------|
896 -- ----------------------------------------------------------------------------
897 -- {Start Of Comments}
898 --
899 -- Description:
900 -- This procedure ensures that a single Hierarchy should not contain the same
901 -- preference twice (Preference Definition)
902 --
903 -- Pre Conditions:
904 --   None
905 --
906 -- In Arguments:
907 --   pref_definition_id
908 --   parent_pref_hierarchy_id
909 --   object_version_number
910 --
911 -- Post Success:
912 --   Processing continues if a valid and a unique preference has been entered
913 --   for the hierarchy
914 --
915 -- Post Failure:
916 --   An application error is raised if a unique preference is not entered for
917 --   that hierarchy
918 --
919 -- {End Of Comments}
920 -- ----------------------------------------------------------------------------
921 Procedure chk_preference
922   (
923 p_pref_definition_id in hxc_pref_hierarchies.pref_definition_id%TYPE,
924 p_bg_id NUMBER,
925 p_parent_pref_hierarchy_id in hxc_pref_hierarchies.parent_pref_hierarchy_id%TYPE
926 ,
927 p_object_version_number in hxc_pref_hierarchies.object_version_number%TYPE
928   ) IS
929 --
930   l_proc  varchar2(72);
931 --
932 -- cursor to check that a preference definition is not entered twice for a
933 -- single hierarchy
934 --
935 CURSOR  csr_chk_preference IS
936 SELECT 'error'
937 FROM    sys.dual
938 WHERE EXISTS (
939        SELECT  'x'
940        FROM    hxc_pref_hierarchies hph
941        WHERE   hph.pref_definition_id  = p_pref_definition_id
942        AND     NVL(hph.business_group_id,-1) = NVL(p_bg_id,-1)
943        AND     level = 2
944        AND     hph.object_version_number <> NVL(p_object_version_number, -1)
945        START WITH hph.pref_hierarchy_id = p_parent_pref_hierarchy_id
946        CONNECT BY PRIOR hph.pref_hierarchy_id = hph.parent_pref_hierarchy_id);
947 --
948  l_error varchar2(5) := NULL;
949 --
950 BEGIN
951 
952   g_debug:=hr_utility.debug_enabled;
953   if g_debug then
954 	l_proc := g_package||'chk_preference';
955 	hr_utility.set_location('Entering:'||l_proc, 5);
956   end if;
957 --
958 -- Raise an error if the child preference definition name is not unique
959 --
960   OPEN  csr_chk_preference;
961   FETCH csr_chk_preference INTO l_error;
962   CLOSE csr_chk_preference;
963 --
964 IF l_error IS NOT NULL
965 THEN
966 --
967       hr_utility.set_message(809, 'HXC_0147_HPH_DUP_PREF_DEF');
968       hr_utility.raise_error;
969 --
970 END IF;
971 --
972   if g_debug then
973 	hr_utility.set_location('Leaving:'||l_proc, 20);
974   end if;
975 --
976 END chk_preference;
977 --
978 --
979 -- ----------------------------------------------------------------------------
980 -- |-----------------------------< get_mapping_components >--------------------|
981 -- ----------------------------------------------------------------------------
982 -- {Start Of Comments}
983 --
984 -- Description:
985 -- This procedure returns the mapping component id of mapping components of a
986 -- particular alternate name type
987 --
988 --
989 -- In Arguments:
990 --   p_alias_type_id
991 --
992 -- InOut Arguments:
993 --   p_mapping_id_table
994 --
995 -- {End Of Comments}
996 -- ----------------------------------------------------------------------------
997 procedure get_mapping_components(p_alias_type_id in number,
998 				 p_mapping_id_table in out nocopy hxc_hph_shd.alias_mapping_table) is
999     cursor c_get_mapping_components (p_alias_type_id number) is
1000            select mapping_component_id
1001 	     from hxc_alias_type_components hac
1002 	    where hac.alias_type_id = p_alias_type_id;
1003     ind number;
1004 begin
1005 g_debug:=hr_utility.debug_enabled;
1006 if g_debug then
1007 	hr_utility.trace('Mappings are');
1008 end if;
1009     open c_get_mapping_components(p_alias_type_id);
1010     loop
1011        fetch c_get_mapping_components into ind;
1012          exit  when c_get_mapping_components%notfound;
1013        p_mapping_id_table(ind).mapping_id := ind;
1014        if g_debug then
1015 	hr_utility.trace('Mapping Id '|| ind);
1016        end if;
1017     end loop;
1018     close c_get_mapping_components;
1019 end get_mapping_components;
1020 -- ----------------------------------------------------------------------------
1021 -- |---------------------------< VALIDATE_ALIAS_DEFINITIONS >------------------|
1022 -- ----------------------------------------------------------------------------
1023 -- {Start Of Comments}
1024 --
1025 -- Description:
1026 -- Checks if the alternate names chosen have the same alternate name type,
1027 -- and also checks if the mappings defined for alternate name types are
1028 -- mutually exclusive.
1029 --
1030 -- In Arguments:
1031 --   p_alias_type_id_table
1032 --   p_index
1033 -- Return Value :
1034 -- 0 -Failure
1035 -- 1 -Success
1036 -- {End Of Comments}
1037 -- ----------------------------------------------------------------------------
1038 
1039 function VALIDATE_ALIAS_DEFINITIONS(p_alias_type_id_table in hxc_hph_shd.alias_type_id_table
1040 				   ,p_index in number) return number is
1041        key_mapping_id_table hxc_hph_shd.alias_mapping_table;
1042        key_alias_type_id hxc_alias_types.alias_type_id%type;
1043        l_alias_type_id hxc_alias_types.alias_type_id%type;
1044        l_mapping_id_table hxc_hph_shd.alias_mapping_table;
1045        i number;
1046        j number;
1047 begin
1048        g_debug:=hr_utility.debug_enabled;
1049        key_alias_type_id := p_alias_type_id_table(p_index).id;
1050        if (key_alias_type_id is not null) then
1051        if g_debug then
1052 	 hr_utility.trace('Key Alias Type Id' || key_alias_type_id);
1053        end if;
1054        get_mapping_components(key_alias_type_id,key_mapping_id_table);
1055        for i in 1..p_index-1 loop
1056            l_alias_type_id := p_alias_type_id_table(i).id;
1057 	   if g_debug then
1058 		hr_utility.trace('Validate_alias_definitions' || l_alias_type_id);
1059 	   end if;
1060 	   if (l_alias_type_id = key_alias_type_id) then
1061 	       return 0;
1062 	   else
1063 	       get_mapping_components(l_alias_type_id,l_mapping_id_table);
1064 	       j := key_mapping_id_table.first;
1065 	       if g_debug then
1066 		hr_utility.trace('Key Maping Id');
1067 	       end if;
1068 	       loop
1069 	          exit when not key_mapping_id_table.exists(j);
1070 		  if g_debug then
1071 			hr_utility.trace('Matching ID ');
1072 		  end if;
1073 		  if (l_mapping_id_table.exists(j)) then
1074 		     return 0;
1075 		  end if;
1076 		  j := key_mapping_id_table.next(j);
1077 	       end loop;
1078 	   end if;
1079        end loop;
1080        end if;
1081        return 1;
1082 end validate_alias_definitions;
1083 
1084 -- ----------------------------------------------------------------------------
1085 -- |-------------------------< populate_alias_type_id_table >-----------------|
1086 -- ----------------------------------------------------------------------------
1087 -- {Start Of Comments}
1088 --
1089 -- Description:
1090 -- Populates the pl/sql table with the alias_type_id of the alternate names
1091 -- choosen,
1092 --
1093 -- In Arguments:
1094 --   p_rec
1095 --
1096 -- In Out:
1097 -- p_alias_type_id_table
1098 --
1099 -- {End Of Comments}
1100 -- ----------------------------------------------------------------------------
1101 procedure populate_alias_type_id_table (p_rec in hxc_hph_shd.g_rec_type,
1102 					p_alias_type_id_table in out nocopy hxc_hph_shd.alias_type_id_table) is
1103 	cursor c_alias_type_id (p_alias_definition_id number) is
1104 	       select alias_type_id
1105 	         from hxc_alias_definitions had
1106 		where had.alias_definition_id = p_alias_definition_id;
1107 begin
1108   if (p_rec.attribute1 is not null) then
1109    open c_alias_type_id (p_rec.attribute1);
1110    fetch c_alias_type_id into p_alias_type_id_table(1).id;
1111    close c_alias_type_id;
1112   else
1113    p_alias_type_id_table(1).id := null;
1114   end if;
1115 
1116   if (p_rec.attribute2 is not null) then
1117    open c_alias_type_id (p_rec.attribute2);
1118    fetch c_alias_type_id into p_alias_type_id_table(2).id;
1119    close c_alias_type_id;
1120   else
1121    p_alias_type_id_table(2).id := null;
1122   end if;
1123 
1124   if (p_rec.attribute3 is not null) then
1125    open c_alias_type_id (p_rec.attribute3);
1126    fetch c_alias_type_id into p_alias_type_id_table(3).id;
1127    close c_alias_type_id;
1128   else
1129    p_alias_type_id_table(3).id := null;
1130   end if;
1131 
1132   if (p_rec.attribute4 is not null) then
1133    open c_alias_type_id (p_rec.attribute4);
1134    fetch c_alias_type_id into p_alias_type_id_table(4).id;
1135    close c_alias_type_id;
1136   else
1137    p_alias_type_id_table(4).id := null;
1138   end if;
1139 
1140   if (p_rec.attribute5 is not null) then
1141    open c_alias_type_id (p_rec.attribute5);
1142    fetch c_alias_type_id into p_alias_type_id_table(5).id;
1143    close c_alias_type_id;
1144   else
1145    p_alias_type_id_table(5).id := null;
1146   end if;
1147 
1148   if (p_rec.attribute6 is not null) then
1149    open c_alias_type_id (p_rec.attribute6);
1150    fetch c_alias_type_id into p_alias_type_id_table(6).id;
1151    close c_alias_type_id;
1152   else
1153    p_alias_type_id_table(6).id := null;
1154   end if;
1155 
1156   if (p_rec.attribute7 is not null) then
1157    open c_alias_type_id (p_rec.attribute7);
1158    fetch c_alias_type_id into p_alias_type_id_table(7).id;
1159    close c_alias_type_id;
1160   else
1161    p_alias_type_id_table(7).id := null;
1162   end if;
1163 
1164   if (p_rec.attribute8 is not null) then
1165    open c_alias_type_id (p_rec.attribute8);
1166    fetch c_alias_type_id into p_alias_type_id_table(8).id;
1167    close c_alias_type_id;
1168   else
1169    p_alias_type_id_table(8).id := null;
1170   end if;
1171 
1172   if (p_rec.attribute9 is not null) then
1173    open c_alias_type_id (p_rec.attribute9);
1174    fetch c_alias_type_id into p_alias_type_id_table(9).id;
1175    close c_alias_type_id;
1176   else
1177    p_alias_type_id_table(9).id := null;
1178   end if;
1179 
1180   if (p_rec.attribute10 is not null) then
1181    open c_alias_type_id (p_rec.attribute10);
1182    fetch c_alias_type_id into p_alias_type_id_table(10).id;
1183    close c_alias_type_id;
1184   else
1185    p_alias_type_id_table(10).id := null;
1186   end if;
1187 
1188   if (p_rec.attribute11 is not null) then
1189    open c_alias_type_id (p_rec.attribute11);
1190    fetch c_alias_type_id into p_alias_type_id_table(11).id;
1191    close c_alias_type_id;
1192   else
1193    p_alias_type_id_table(11).id := null;
1194   end if;
1195 
1196   if (p_rec.attribute12 is not null) then
1197    open c_alias_type_id (p_rec.attribute12);
1198    fetch c_alias_type_id into p_alias_type_id_table(12).id;
1199    close c_alias_type_id;
1200   else
1201    p_alias_type_id_table(12).id := null;
1202   end if;
1203 
1204   if (p_rec.attribute13 is not null) then
1205    open c_alias_type_id (p_rec.attribute13);
1206    fetch c_alias_type_id into p_alias_type_id_table(13).id;
1207    close c_alias_type_id;
1208   else
1209    p_alias_type_id_table(13).id := null;
1210   end if;
1211 
1212   if (p_rec.attribute14 is not null) then
1213    open c_alias_type_id (p_rec.attribute14);
1214    fetch c_alias_type_id into p_alias_type_id_table(14).id;
1215    close c_alias_type_id;
1216   else
1217    p_alias_type_id_table(14).id := null;
1218   end if;
1219 
1220   if (p_rec.attribute15 is not null) then
1221    open c_alias_type_id (p_rec.attribute15);
1222    fetch c_alias_type_id into p_alias_type_id_table(15).id;
1223    close c_alias_type_id;
1224   else
1225    p_alias_type_id_table(15).id := null;
1226   end if;
1227 
1228   if (p_rec.attribute16 is not null) then
1229    open c_alias_type_id (p_rec.attribute16);
1230    fetch c_alias_type_id into p_alias_type_id_table(16).id;
1231    close c_alias_type_id;
1232   else
1233    p_alias_type_id_table(16).id := null;
1234   end if;
1235 
1236   if (p_rec.attribute17 is not null) then
1237    open c_alias_type_id (p_rec.attribute17);
1238    fetch c_alias_type_id into p_alias_type_id_table(17).id;
1239    close c_alias_type_id;
1240   else
1241    p_alias_type_id_table(17).id := null;
1242   end if;
1243 
1244   if (p_rec.attribute18 is not null) then
1245    open c_alias_type_id (p_rec.attribute18);
1246    fetch c_alias_type_id into p_alias_type_id_table(18).id;
1247    close c_alias_type_id;
1248   else
1249    p_alias_type_id_table(18).id := null;
1250   end if;
1251 
1252   if (p_rec.attribute19 is not null) then
1253    open c_alias_type_id (p_rec.attribute19);
1254    fetch c_alias_type_id into p_alias_type_id_table(19).id;
1255    close c_alias_type_id;
1256   else
1257    p_alias_type_id_table(19).id := null;
1258   end if;
1259 
1260   if (p_rec.attribute20 is not null) then
1261    open c_alias_type_id (p_rec.attribute20);
1262    fetch c_alias_type_id into p_alias_type_id_table(20).id;
1263    close c_alias_type_id;
1264   else
1265    p_alias_type_id_table(20).id := null;
1266   end if;
1267 
1268   if (p_rec.attribute21 is not null) then
1269    open c_alias_type_id (p_rec.attribute21);
1270    fetch c_alias_type_id into p_alias_type_id_table(21).id;
1271    close c_alias_type_id;
1272   else
1273    p_alias_type_id_table(21).id := null;
1274   end if;
1275 
1276   if (p_rec.attribute22 is not null) then
1277    open c_alias_type_id (p_rec.attribute22);
1278    fetch c_alias_type_id into p_alias_type_id_table(22).id;
1279    close c_alias_type_id;
1280   else
1281    p_alias_type_id_table(22).id := null;
1282   end if;
1283 
1284   if (p_rec.attribute23 is not null) then
1285    open c_alias_type_id (p_rec.attribute23);
1286    fetch c_alias_type_id into p_alias_type_id_table(23).id;
1287    close c_alias_type_id;
1288   else
1289    p_alias_type_id_table(23).id := null;
1290   end if;
1291 
1292   if (p_rec.attribute24 is not null) then
1293    open c_alias_type_id (p_rec.attribute24);
1294    fetch c_alias_type_id into p_alias_type_id_table(24).id;
1295    close c_alias_type_id;
1296   else
1297    p_alias_type_id_table(24).id := null;
1298   end if;
1299 
1300   if (p_rec.attribute25 is not null) then
1301    open c_alias_type_id (p_rec.attribute25);
1302    fetch c_alias_type_id into p_alias_type_id_table(25).id;
1303    close c_alias_type_id;
1304   else
1305    p_alias_type_id_table(25).id := null;
1306   end if;
1307 
1308   if (p_rec.attribute26 is not null) then
1309    open c_alias_type_id (p_rec.attribute26);
1310    fetch c_alias_type_id into p_alias_type_id_table(26).id;
1311    close c_alias_type_id;
1312   else
1313    p_alias_type_id_table(26).id := null;
1314   end if;
1315 
1316   if (p_rec.attribute27 is not null) then
1317    open c_alias_type_id (p_rec.attribute27);
1318    fetch c_alias_type_id into p_alias_type_id_table(27).id;
1319    close c_alias_type_id;
1320   else
1321    p_alias_type_id_table(27).id := null;
1322   end if;
1323 
1324   if (p_rec.attribute28 is not null) then
1325    open c_alias_type_id (p_rec.attribute28);
1326    fetch c_alias_type_id into p_alias_type_id_table(28).id;
1327    close c_alias_type_id;
1328   else
1329    p_alias_type_id_table(28).id := null;
1330   end if;
1331 
1332   if (p_rec.attribute29 is not null) then
1333    open c_alias_type_id (p_rec.attribute29);
1334    fetch c_alias_type_id into p_alias_type_id_table(29).id;
1335    close c_alias_type_id;
1336   else
1337    p_alias_type_id_table(29).id := null;
1338   end if;
1339 
1340   if (p_rec.attribute30 is not null) then
1341    open c_alias_type_id (p_rec.attribute30);
1342    fetch c_alias_type_id into p_alias_type_id_table(30).id;
1343    close c_alias_type_id;
1344   else
1345    p_alias_type_id_table(30).id := null;
1346   end if;
1347 end populate_alias_type_id_table;
1348 
1349 -- ----------------------------------------------------------------------------
1350 -- |------------------------< validate_alias_mapping_names >------------------|
1351 -- ----------------------------------------------------------------------------
1352 -- {Start Of Comments}
1353 --
1354 -- Description:
1355 -- Checks if the mapping components choosen have the corresonding contexts are
1356 -- choosen.
1357 --
1358 -- In Arguments:
1359 --  p_alias_type_id_table
1360 --
1361 -- Return Value :
1362 -- 0 -Failure
1363 -- 1 -Success
1364 -- {End Of Comments}
1365 -- ----------------------------------------------------------------------------
1366 
1367 function validate_alias_mapping_names(p_alias_type_id_table in hxc_hph_shd.alias_type_id_table) return number is
1368 l_alias_mapping_name_table hxc_hph_shd.alias_mapping_name_table;
1369 n number;
1370 counter number := 1;
1371 l_Inputvalue_flag number := 0;
1372 l_CostSegment_flag number := 0;
1373 l_GrpSegment_flag number := 0;
1374 l_JobSegment_flag number := 0;
1375 l_PosSegment_flag number := 0;
1376 l_mapping_name varchar2(80);
1377 succ number := 0;
1378 cursor c_get_mapping_comp_name(p_alias_type_id number) is
1379      select name
1380        from hxc_alias_type_components hac,
1381             hxc_mapping_components hmc
1382       where hac.alias_type_id = p_alias_type_id
1383         and hac.mapping_component_id = hmc.mapping_component_id;
1384 
1385 begin
1386     g_debug:=hr_utility.debug_enabled;
1387     n := p_alias_type_id_table.first;
1388     loop
1389        if g_debug then
1390 	hr_utility.set_location('validate_alias_mapping_name' ,20);
1391        end if;
1392        exit when not p_alias_type_id_table.exists(n);
1393        open c_get_mapping_comp_name(p_alias_type_id_table(n).id);
1394        loop
1395           fetch c_get_mapping_comp_name into l_mapping_name;
1396 	  l_alias_mapping_name_table(counter).mapping_comp_name := l_mapping_name;
1397  	  exit when c_get_mapping_comp_name%notfound;
1398 	  counter := counter +1;
1399 	  if (l_mapping_name like 'InputValue%') then
1400 	      l_Inputvalue_flag := 1;
1401 	  --else if (l_mapping_name like 'CostSegment%') then
1402 	  --    l_CostSegment_flag := 1;
1403 	  --else if (l_mapping_name like 'GrpSegment%') then
1404 	  --    l_GrpSegment_flag := 1;
1405 	  --else if (l_mapping_name like 'JobSegment%') then
1406 	  --    l_JobSegment_flag := 1;
1407 	  --else if (l_mapping_name like 'PosSegment%') then
1408 	  --    l_PosSegment_flag := 1;
1409 	  --end if;
1410 	  --end if;
1411 	  --end if;
1412 	  --end if;
1413 	  end if;
1414        end loop;
1415 
1416 
1417        close c_get_mapping_comp_name;
1418        n := p_alias_type_id_table.next(n);
1419     end loop;
1420 
1421        n := l_alias_mapping_name_table.first;
1422        loop
1423 	   exit when not l_alias_mapping_name_table.exists(n);
1424 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1425 	   if g_debug then
1426 		hr_utility.trace('l_mapping_name' || l_mapping_name);
1427 	   end if;
1428 	   n := l_alias_mapping_name_table.next(n);
1429        end loop;
1430     if g_debug then
1431 	hr_utility.trace('l_Inputvalue_flag= ' || l_Inputvalue_flag);
1432     end if;
1433     if ( l_Inputvalue_flag= 1 ) then
1434         succ := 0;
1435         n := l_alias_mapping_name_table.first;
1436 	loop
1437 	   exit when not l_alias_mapping_name_table.exists(n);
1438 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1439 	   if (l_mapping_name = 'Dummy Element Context') then
1440 	       succ := 1;
1441 	   end if;
1442 	   n := l_alias_mapping_name_table.next(n);
1443 	 end loop;
1444          if (succ = 0) then
1445 	    return 0;
1446 	 end if;
1447     end if;
1448     /*
1449     if g_debug then
1450 	hr_utility.trace('l_costsegment_flag ' || l_costsegment_flag);
1451     end if;
1452     if (l_CostSegment_flag = 1 ) then
1453         succ := 0;
1454         n := l_alias_mapping_name_table.first;
1455 	loop
1456 	   exit when not l_alias_mapping_name_table.exists(n);
1457 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1458 	   if (l_mapping_name = 'Dummy Cost Context') then
1459 	       succ := 1;
1460 	   end if;
1461 	   n := l_alias_mapping_name_table.next(n);
1462 	 end loop;
1463 	 if g_debug then
1464 		hr_utility.trace('Succ: ' || succ);
1465          end if;
1466 	 if (succ = 0) then
1467 	    return 0;
1468 	 end if;
1469     end if;
1470         if g_debug then
1471 		hr_utility.trace('l_GrpSegment_flag ' || l_GrpSegment_flag);
1472 	end if;
1473     if (l_GrpSegment_flag = 1 ) then
1474         succ := 0;
1475         n := l_alias_mapping_name_table.first;
1476 	loop
1477 	   exit when not l_alias_mapping_name_table.exists(n);
1478 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1479 	   if (l_mapping_name = 'Dummy Grp Context') then
1480 	       succ := 1;
1481 	   end if;
1482 	   n := l_alias_mapping_name_table.next(n);
1483 	 end loop;
1484          if (succ = 0) then
1485 	    return 0;
1486 	 end if;
1487     end if;
1488         if g_debug then
1489 		hr_utility.trace('l_JobSegment_flag ' || l_JobSegment_flag);
1490 	end if;
1491     if (l_JobSegment_flag = 1 ) then
1492         succ := 0;
1493         n := l_alias_mapping_name_table.first;
1494 	loop
1495 	   exit when not l_alias_mapping_name_table.exists(n);
1496 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1497 	   if (l_mapping_name = 'Dummy Job Context') then
1498 	       succ := 1;
1499 	   end if;
1500 	   n := l_alias_mapping_name_table.next(n);
1501 	 end loop;
1502          if (succ = 0) then
1503 	    return 0;
1504 	 end if;
1505     end if;
1506         if g_debug then
1507 		hr_utility.trace('l_PosSegment_flag ' || l_PosSegment_flag);
1508 	end if;
1509     if (l_PosSegment_flag = 1 ) then
1510         succ := 0;
1511         n := l_alias_mapping_name_table.first;
1512 	loop
1513 	   exit when not l_alias_mapping_name_table.exists(n);
1514 	   l_mapping_name := l_alias_mapping_name_table(n).mapping_comp_name;
1515 	   if (l_mapping_name = 'Dummy Pos Context') then
1516 	       succ := 1;
1517 	   end if;
1518 	   n := l_alias_mapping_name_table.next(n);
1519 	 end loop;
1520          if (succ = 0) then
1521 	    return 0;
1522 	 end if;
1523     end if;
1524     */
1525     return 1;
1526 end validate_alias_mapping_names;
1527 
1528 procedure validate_alias (p_rec  in hxc_hph_shd.g_rec_type) is
1529 n number;
1530 succ number;
1531 l_alias_type_id_table hxc_hph_shd.alias_type_id_table;
1532 l_alias_mapping_name_table hxc_hph_shd.alias_mapping_name_table;
1533 begin
1534 g_debug:=hr_utility.debug_enabled;
1535 if g_debug then
1536 	hr_utility.trace('p_rec.attribute_category' ||p_rec.attribute_category);
1537 end if;
1538 if (p_rec.attribute_category = 'TK_TCARD_ATTRIBUTES_DEFINITION') then
1539 if g_debug then
1540 	hr_utility.set_location('validate_alias',20);
1541 end if;
1542     populate_alias_type_id_table(p_rec,l_alias_type_id_table);
1543     n := l_alias_type_id_table.first;
1544     loop
1545        if g_debug then
1546 		hr_utility.set_location('validate_alias',30);
1547        end if;
1548        exit when not l_alias_type_id_table.exists(n);
1549        if g_debug then
1550 		hr_utility.trace('n' || n);
1551        end if;
1552        succ := validate_alias_definitions(l_alias_type_id_table,n);
1553        if (succ =0) then
1554           hr_utility.set_message(809,'HXC_AN_DEFN_WRG');
1555 	  hr_utility.raise_error;
1556        end if;
1557        n:= l_alias_type_id_table.next(n);
1558     end loop;
1559     succ := validate_alias_mapping_names(l_alias_type_id_table);
1560     if (succ = 0) then
1561        hr_utility.set_message(809,'HXC_AN_DEFN_WRG');
1562        hr_utility.raise_error;
1563     end if;
1564  end if;
1565  end validate_alias;
1566 
1567 
1568 --
1569 --  -----------------------------------------------------------------
1570 --  |-----------------------< chk_legislation_code >----------------|
1571 --  -----------------------------------------------------------------
1572 --
1573 --  Description:
1574 --    Validate the legislation_code against the FND_TERRITORIES table.
1575 --
1576 --  Pre-Requisites:
1577 --    None
1578 --
1579 --  In Parameters:
1580 --    p_legislation_code
1581 --
1582 --  Post Success:
1583 --    Processing continues if the legislation_code is valid.
1584 --
1585 --  Post Failure:
1586 --    An application error is raised and processing is terminated if
1587 --    the legislation_code is invalid.
1588 --
1589 --  Access Status:
1590 --    Internal Row Handler Use Only.
1591 --
1592 Procedure chk_legislation_code
1593        (p_business_group_id           in      number,
1594         p_legislation_code           in      varchar2
1595        ) is
1596 --
1597 --   Local declarations
1598   l_proc               varchar2(72);
1599   l_territory_code     fnd_territories.territory_code%TYPE;
1600   l_lc                 per_business_groups.legislation_code%TYPE;
1601 --
1602 -- Setup cursor for valid legislation code check
1603   cursor csr_valid_legislation_code is
1604     select territory_code
1605     from fnd_territories ft
1606     where ft.territory_code = p_legislation_code;
1607 
1608 -- Setup cursor for valid legislation code for a particular business_group
1609   cursor csr_valid_bg_lc is
1610     select legislation_code
1611     from per_business_groups pbg
1612     where pbg.business_group_id = p_business_group_id
1613     and   pbg.legislation_code = p_legislation_code;
1614 
1615 --
1616 --
1617 begin
1618     g_debug:=hr_utility.debug_enabled;
1619     if g_debug then
1620 	l_proc := g_package||'chk_legislation_code';
1621 	hr_utility.set_location('Entering: '||l_proc,5);
1622     end if;
1623      --------------------------------
1624      -- Check legislation code is valid --
1625      --------------------------------
1626      if p_legislation_code is not null then
1627 
1628         open csr_valid_legislation_code;
1629         fetch csr_valid_legislation_code into l_territory_code;
1630         if csr_valid_legislation_code%notfound then
1631             close csr_valid_legislation_code;
1632             hr_utility.set_message(800,'PER_52123_AMD_LEG_CODE_INV');
1633             hr_utility.raise_error;
1634         end if; -- End cursor if
1635         close csr_valid_legislation_code;
1636 
1637         if p_business_group_id is not null then
1638            open csr_valid_bg_lc;
1639            fetch csr_valid_bg_lc into l_lc;
1640            if csr_valid_bg_lc%notfound then
1641               close csr_valid_bg_lc;
1642               hr_utility.set_message(800,'PER_52123_AMD_LEG_CODE_INV');
1643               hr_utility.raise_error;
1644            end if; -- End cursor if
1645            close csr_valid_bg_lc;
1646         end if;
1647 
1648      end if; -- end check
1649 
1650     if g_debug then
1651 	hr_utility.set_location('Leaving: '||l_proc,10);
1652     end if;
1653 end chk_legislation_code;
1654 --
1655 -- ----------------------------------------------------------------------------
1656 -- |---------------------------< insert_validate >----------------------------|
1657 -- ----------------------------------------------------------------------------
1658 Procedure insert_validate
1659   (p_effective_date               in date
1660   ,p_rec                          in hxc_hph_shd.g_rec_type
1661   ) is
1662 --
1663   l_proc  varchar2(72);
1664 --
1665 Begin
1666   g_debug:=hr_utility.debug_enabled;
1667   if g_debug then
1668 	l_proc := g_package||'insert_validate';
1669 	hr_utility.set_location('Entering:'||l_proc, 5);
1670   end if;
1671   --
1672   -- Call all supporting business operations
1673   --
1674   if g_debug then
1675 	hr_utility.set_location('Processing:'||l_proc, 10);
1676   end if;
1677   --
1678   -- Do check for duplicate pref hierarchy name
1679   --
1680   if g_debug then
1681 	hr_utility.trace('p_rec.attribute_category is ' || p_rec.attribute_category);
1682   end if;
1683   chk_name ( p_name => p_rec.name,
1684              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1685              p_business_group_id => p_rec.business_group_id,
1686              p_object_version_number => p_rec.object_version_number );
1687   --
1688   --
1689   -- Do check for duplicate pref hierarchy code
1690   --
1691   chk_pref_code( p_pref_code => p_rec.attribute_category,
1692              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1693              p_pref_hierarchy_id => p_rec.pref_hierarchy_id,
1694              p_object_version_number => p_rec.object_version_number );
1695   --
1696   chk_rules_evaluation_pref  (
1697                               p_pref_code => p_rec.attribute_category
1698                             , p_attribute1 => p_rec.attribute1
1699                             , p_attribute2 => p_rec.attribute2 );
1700   --
1701   chk_tk_person_name_number (
1702 				p_pref_code => p_rec.attribute_category,
1703 				p_attribute2 => p_rec.attribute2,
1704 				p_attribute3 => p_rec.attribute3);
1705 
1706    chk_tk_audit_segments (
1707 			  p_pref_code => p_rec.attribute_category,
1708 			  p_attribute1 => p_rec.attribute1,
1709 			  p_attribute2 => p_rec.attribute2,
1710 			  p_attribute3 => p_rec.attribute3,
1711 			  p_attribute4 => p_rec.attribute4);
1712 
1713 chk_days_hours_factor(
1714     p_pref_code => p_rec.attribute_category
1715    , p_attribute1 => p_rec.attribute1
1716    , p_attribute2 => p_rec.attribute2 );
1717 
1718 if g_debug then
1719 	hr_utility.set_location(' Leaving:'||l_proc, 10);
1720 	--
1721 	hr_utility.set_location('Processing:'||l_proc, 15);
1722 end if;
1723 
1724   IF ( p_rec.parent_pref_hierarchy_id is null )
1725   THEN
1726 
1727 	  -- Do check for duplicate top node if defining top node
1728 
1729 	  chk_top_node ( p_name => p_rec.name,
1730 	  		 p_business_group_id => p_rec.business_group_id,
1731 	                 p_object_version_number => p_rec.object_version_number );
1732 
1733   END IF;
1734 
1735   if g_debug then
1736 	hr_utility.set_location('Processing:'||l_proc, 20);
1737   end if;
1738   --
1739   -- Check that a single hierarchy does not contain the same preference twice
1740   --
1741   chk_preference ( p_pref_definition_id => p_rec.pref_definition_id,
1742              p_bg_id => p_rec.business_group_id,
1743              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1744              p_object_version_number => p_rec.object_version_number );
1745   --
1746   --
1747   if g_debug then
1748 	hr_utility.set_location(' Leaving:'||l_proc, 20);
1749   end if;
1750   --
1751   --
1752   -- EDIT_HERE: As this table does not have a mandatory business_group_id
1753   -- column, ensure client_info is populated by calling a suitable
1754   -- ???_???_bus.set_security_group_id procedure, or add one of the following
1755   -- comments:
1756   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
1757   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
1758   --
1759   --
1760     if p_rec.business_group_id is not null then
1761     hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1762   end if;
1763   -- Validate the legislation_code
1764        chk_legislation_code
1765        (p_business_group_id           => p_rec.business_group_id,
1766         p_legislation_code              => p_rec.legislation_code);
1767 --
1768   hxc_hph_bus.chk_df(p_rec);
1769   --
1770   hxc_hph_bus.validate_alias(p_rec);
1771   if g_debug then
1772 	hr_utility.set_location(' Leaving:'||l_proc, 10);
1773   end if;
1774 End insert_validate;
1775 --
1776 -- ----------------------------------------------------------------------------
1777 -- |---------------------------< update_validate >----------------------------|
1778 -- ----------------------------------------------------------------------------
1779 Procedure update_validate
1780   (p_effective_date               in date
1781   ,p_rec                          in hxc_hph_shd.g_rec_type
1782   ) is
1783 --
1784   l_proc  varchar2(72);
1785 --
1786 Begin
1787   g_debug:=hr_utility.debug_enabled;
1788   if g_debug then
1789 	l_proc := g_package||'update_validate';
1790 	hr_utility.set_location('Entering:'||l_proc, 5);
1791   end if;
1792   --
1793   -- Call all supporting business operations
1794   --
1795   --
1796   -- EDIT_HERE: As this table does not have a mandatory business_group_id
1797   -- column, ensure client_info is populated by calling a suitable
1798   -- ???_???_bus.set_security_group_id procedure, or add one of the following
1799   -- comments:
1800   -- "-- No business group context.  HR_STANDARD_LOOKUPS used for validation."
1801   -- "-- CLIENT_INFO not set.  No lookup validation or joins to HR_LOOKUPS."
1802   --
1803   chk_non_updateable_args
1804     (p_effective_date              => p_effective_date
1805       ,p_rec              => p_rec
1806     );
1807   --
1808   -- Do check for duplicate pref hierarchy name
1809   --
1810   if g_debug then
1811 	hr_utility.set_location('Processing:'||l_proc, 10);
1812   end if;
1813   --
1814   chk_name ( p_name => p_rec.name,
1815              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1816              p_business_group_id => p_rec.business_group_id,
1817              p_object_version_number => p_rec.object_version_number );
1818   --
1819   if g_debug then
1820 	hr_utility.set_location(' Leaving:'||l_proc, 10);
1821   end if;
1822   --
1823   -- Do check for duplicate pref hierarchy code
1824   --
1825   chk_pref_code( p_pref_code => p_rec.attribute_category,
1826              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1827              p_pref_hierarchy_id => p_rec.pref_hierarchy_id,
1828              p_object_version_number => p_rec.object_version_number );
1829 
1830   chk_rules_evaluation_pref  (
1831                               p_pref_code => p_rec.attribute_category
1832                             , p_attribute1 => p_rec.attribute1
1833                             , p_attribute2 => p_rec.attribute2 );
1834   --
1835   chk_tk_person_name_number (
1836                                 p_pref_code => p_rec.attribute_category,
1837                                 p_attribute2 => p_rec.attribute2,
1838                                 p_attribute3 => p_rec.attribute3);
1839 
1840    chk_tk_audit_segments (
1841 			  p_pref_code => p_rec.attribute_category,
1842 			  p_attribute1 => p_rec.attribute1,
1843 			  p_attribute2 => p_rec.attribute2,
1844 			  p_attribute3 => p_rec.attribute3,
1845 			  p_attribute4 => p_rec.attribute4);
1846 chk_days_hours_factor(
1847     p_pref_code => p_rec.attribute_category
1848    , p_attribute1 => p_rec.attribute1
1849    , p_attribute2 => p_rec.attribute2 );
1850 
1851   --
1852 if g_debug then
1853 	hr_utility.set_location('Processing:'||l_proc, 15);
1854 end if;
1855   IF ( p_rec.parent_pref_hierarchy_id is null )
1856   THEN
1857 
1858 	  -- Do check for duplicate top node
1859 
1860 	  chk_top_node ( p_name => p_rec.name,
1861 	  		 p_business_group_id => p_rec.business_group_id,
1862 	                 p_object_version_number => p_rec.object_version_number );
1863 
1864   END IF;
1865 
1866   if g_debug then
1867 	hr_utility.set_location('Processing:'||l_proc, 20);
1868   end if;
1869   --
1870   -- Check that a single hierarchy does not contain the same preference twice
1871   --
1872   chk_preference ( p_pref_definition_id => p_rec.pref_definition_id,
1873              p_bg_id => p_rec.business_group_id,
1874              p_parent_pref_hierarchy_id => p_rec.parent_pref_hierarchy_id,
1875              p_object_version_number => p_rec.object_version_number );
1876   --
1877   --
1878   if g_debug then
1879 	hr_utility.set_location(' Leaving:'||l_proc, 20);
1880   end if;
1881   --
1882   if p_rec.business_group_id is not null then
1883     hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
1884   end if;
1885   -- Validate the legislation_code
1886        chk_legislation_code
1887        (p_business_group_id           => p_rec.business_group_id,
1888         p_legislation_code              => p_rec.legislation_code);
1889   --
1890   hxc_hph_bus.chk_df(p_rec);
1891     hxc_hph_bus.validate_alias(p_rec);
1892   --
1893   if g_debug then
1894 	hr_utility.set_location(' Leaving:'||l_proc, 15);
1895   end if;
1896 End update_validate;
1897 --
1898 -- ----------------------------------------------------------------------------
1899 -- |---------------------------< delete_validate >----------------------------|
1900 -- ----------------------------------------------------------------------------
1901 Procedure delete_validate
1902   (p_rec                          in hxc_hph_shd.g_rec_type
1903   ) is
1904 --
1905   l_proc  varchar2(72);
1906 --
1907 Begin
1908   g_debug:=hr_utility.debug_enabled;
1909   if g_debug then
1910 	l_proc := g_package||'delete_validate';
1911 	hr_utility.set_location('Entering:'||l_proc, 5);
1912   end if;
1913   --
1914   -- Call all supporting business operations
1915   --
1916   if g_debug then
1917 	hr_utility.set_location(' Leaving:'||l_proc, 10);
1918   end if;
1919 End delete_validate;
1920 --
1921 end hxc_hph_bus;