DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PER_BUS

Source


1 Package Body per_per_bus as
2 /* $Header: peperrhi.pkb 120.20.12020000.5 2013/05/16 10:39:02 srannama ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 --
9    g_package  varchar2(33) := '  per_per_bus.';  -- Global package name
10    g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- The following two global variables are only to be used by the
13 -- return_legislation_code function.
14 --
15 g_person_id number default null;
16 g_legislation_code varchar2(150) default null;
17 --
18 --  ---------------------------------------------------------------------------
19 --  |----------------------<  set_security_group_id  >------------------------|
20 --  ---------------------------------------------------------------------------
21 --
22   procedure set_security_group_id
23    (
24     p_person_id in per_all_people_f.person_id%TYPE
25    ,p_associated_column1 in varchar2 default null
26    ) as
27   --
28   -- Declare cursor
29   --
30   -- Bug Number  : 3009266.
31   -- Description : To let Phones row handler access person row hanlder for all persons
32   --               replaced per_people_f with per_all_people_f in this cursor.
33   --
34      cursor csr_sec_grp is
35      select hoi.org_information14, hoi.org_information9
36        from hr_organization_information hoi
37             , per_all_people_f per
38       where per.person_id = p_person_id
39         and hoi.organization_id = per.business_group_id
40         and hoi.org_information_context||'' = 'Business Group Information';
41   --
42   -- Local variables
43   --
44   l_security_group_id number;
45   l_legislation_code  varchar2(150);
46   l_proc              varchar2(72) := g_package||'set_security_group_id';
47   --
48   begin
49  if g_debug then
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(p_api_name       => l_proc,
56                              p_argument       => 'person_id',
57                              p_argument_value => p_person_id);
58   --
59   open csr_sec_grp;
60   fetch csr_sec_grp into l_security_group_id, l_legislation_code;
61   if csr_sec_grp%notfound then
62     close csr_sec_grp;
63     --
64     -- The primary key is invalid therefore we must error
65     --
66     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
67     hr_multi_message.add(p_associated_column1 =>
68                          nvl(p_associated_column1,'PERSON_ID'));
69   else
70     close csr_sec_grp;
71     --
72     -- Set the security_group_id in CLIENT_INFO
73     --
74     hr_api.set_security_group_id
75       (p_security_group_id => l_security_group_id
76       );
77     --
78     -- Set the sessions legislation context in HR_SESSION_DATA
79     --
80     hr_api.set_legislation_context(l_legislation_code);
81     --
82   end if;
83  if g_debug then
84   hr_utility.set_location(' Leaving:'|| l_proc, 20);
85  end if;
86   --
87 end set_security_group_id;
88 --  ---------------------------------------------------------------------------
89 --  |----------------------<  return_system_person_type  >--------------------|
90 --  ---------------------------------------------------------------------------
91 --
92 --  Description:
93 --    Checks that the person_type_id exists in per_person_types for the
94 --    business group and returns the value of system_person_type
95 --
96 --  Pre-conditions:
97 --    None
98 --
99 --  In Arguments:
100 --    p_person_type_id
101 --    p_business_group_id
102 --
103 --  Post Success:
104 --    If the person_type exists in PER_PERSON_TYPES for the business
105 --    group then
106 --    the value of system person type is returned and processing continues
107 --
108 --  Post Failure:
109 --    If the person_type does not exist in PER_PERSON_TYPES for the business
110 --    group then
111 --    an application error will be raised and processing is terminated
112 --
113 --  Access Status:
114 --    Internal Table Handler Use Only.
115 --
116 function return_system_person_type
117   (p_person_type_id           in  per_all_people_f.person_type_id%TYPE
118   ,p_business_group_id        in  per_all_people_f.business_group_id%TYPE)
119   return varchar2 is
120 --
121   l_person_type    varchar2(30);
122   l_proc           varchar2(72)  :=  g_package||'return_system_person_type';
123 --
124   cursor csr_chk_person_type is
125    select pet.system_person_type
126    from per_person_types pet
127    where p_person_type_id = pet.person_type_id
128      and p_business_group_id = pet.business_group_id + 0;
129 --
130 begin
131  if g_debug then
132   hr_utility.set_location('Entering:'|| l_proc, 1);
133  end if;
134   --
135   -- Check mandatory parameters have been set
136   --
137   hr_api.mandatory_arg_error
138     (p_api_name       => l_proc
139     ,p_argument       => 'person type id'
140     ,p_argument_value => p_person_type_id
141     );
142   --
143   hr_api.mandatory_arg_error
144     (p_api_name       => l_proc
145     ,p_argument       => 'business group id'
146     ,p_argument_value => p_business_group_id
147     );
148   --
149   -- Check if the previous system_person_type variable(g_previous_sys_per_type)
150   -- is null, if not then we already have the required value so just return it,
151   -- if so select it from the database before returning it.
152   --
153   if g_previous_sys_per_type is null then
154     --
155     --  Check that the person_type exists in PER_PERSON_TYPES for the business
156     --  group and return the system person type
157     --
158     open csr_chk_person_type;
159     fetch csr_chk_person_type into g_previous_sys_per_type;
160     If csr_chk_person_type%found then
161       close csr_chk_person_type;
162  if g_debug then
163       hr_utility.set_location(l_proc, 3);
164  end if;
165     else
166       --
167  if g_debug then
168       hr_utility.set_location(l_proc, 4);
169  end if;
170       --
171       close csr_chk_person_type;
172       -- Error: Invalid person type
173       hr_utility.set_message(801,'HR_7513_PER_TYPE_INVALID');
174       hr_utility.raise_error;
175     end if;
176   end if;
177  if g_debug then
178   hr_utility.set_location(' Leaving '||l_proc, 5);
179  end if;
180   return g_previous_sys_per_type;
181   exception
182     when app_exception.application_exception then
183       if hr_multi_message.exception_add
184       (p_associated_column1      => 'PER_ALL_PEOPLE_F.PERSON_TYPE_ID'
185       ) then
186  if g_debug then
187         hr_utility.set_location(' Leaving:'||l_proc, 6);
188  end if;
189         raise;
190     end if;
191  if g_debug then
192     hr_utility.set_location(' Leaving:'||l_proc,7);
193  end if;
194     -- call to stop proceeding further if there is an error in
195     -- system person type
196     --
197     hr_multi_message.end_validation_set;
198     --
199 end return_system_person_type;
200 --
201 --  ---------------------------------------------------------------------------
202 --  |--------------------------<  set_current_flags  >------------------------|
203 --  ---------------------------------------------------------------------------
204 --
205 --  Description:
206 --   Sets the value of p_current_employee_flag, p_current_applicant_flag and
207 --   p_current_emp_or_apl_flag according to the value of system person type.
208 --   This procedure is called directly on insert and from chk_person_type_id
209 --   on update, if a valid change in system person type occurs.
210 --
211 --  Pre-conditions:
212 --    None
213 --
214 --  In Arguments:
215 --    p_person_id
216 --    p_business_group_id
217 --    p_person_type_id
218 --    p_effective_date
219 --    p_object_version_number
220 --
221 --  Out Arguments:
222 --    p_current_employee_flag
223 --    p_current_applicant_flag
224 --    p_current_emp_or_apl_flag
225 --
226 --  Post Success:
227 --    If the system_person_type corresponding to the value of p_person_type_id
228 --    is 'EMP' or 'EMP_APL' then
229 --      p_current_employee_flag is set to 'Y' and processing continues
230 --    else
231 --      p_current_employee_flag is set to null and processing continues
232 --
233 --    If the system_person_type corresponding to the value of p_person_type_id
234 --    is 'APL','APL_EX_APL', 'EMP_APL' or 'EX_EMP_APL' then
235 --      p_current_applicant_flag is set to 'Y' and processing continues
236 --    else
237 --      p_current_applicant_flag is set to null and processing continues
238 --
239 --    If the system_person_type corresponding to the value of p_person_type_id
240 --    is 'EMP','APL','EMP_APL', EX_EMP_APL' or 'APL_EX_APL' then
241 --      p_current_emp_or_apl_flag is set to 'Y' and processing continues
242 --    else
243 --      p_current_emp_or_apl_flag is set to null and processing continues
244 --
245 --  Post Failure:
246 --   None
247 --
248 --  Access Status:
249 --    Internal Table Handler Use Only.
250 --
251 procedure set_current_flags
252   (p_person_id                in per_all_people_f.person_id%TYPE
253   ,p_business_group_id        in per_all_people_f.business_group_id%TYPE
254   ,p_person_type_id           in per_all_people_f.person_type_id%TYPE
255   ,p_current_employee_flag   out nocopy per_all_people_f.current_employee_flag%TYPE
256   ,p_current_applicant_flag  out nocopy per_all_people_f.current_applicant_flag%TYPE
257   ,p_current_emp_or_apl_flag out nocopy per_all_people_f.current_emp_or_apl_flag%TYPE
258   ,p_effective_date           in date
259   ,p_object_version_number    in per_all_people_f.object_version_number%TYPE) is
260 --
261   l_proc           varchar2(72)  :=  g_package||'set_current_flags';
262   l_api_updating        boolean;
263   l_system_person_type  varchar2(30);
264 --
265 begin
266  if g_debug then
267   hr_utility.set_location('Entering:'|| l_proc, 1);
268  end if;
269   --
270   -- Check mandatory parameters have been set
271   --
272   hr_api.mandatory_arg_error
273     (p_api_name       => l_proc
274     ,p_argument       => 'business group id'
275     ,p_argument_value => p_business_group_id
276     );
277   --
278   hr_api.mandatory_arg_error
279     (p_api_name       => l_proc
280     ,p_argument       => 'person type id'
281     ,p_argument_value => p_person_type_id
282     );
283   --
284   hr_api.mandatory_arg_error
285     (p_api_name       => l_proc
286     ,p_argument       => 'effective date'
287     ,p_argument_value => p_effective_date
288     );
289   --
290   --  Only proceed with validation if:
291   --  a) The current g_old_rec is current and
292   --  b) The person type id value has changed
293   --  c) A record is being inserted
294   --
295   l_api_updating := per_per_shd.api_updating
296     (p_person_id             => p_person_id
297     ,p_effective_date        => p_effective_date
298     ,p_object_version_number => p_object_version_number);
299   --
300   if ((l_api_updating and per_per_shd.g_old_rec.person_type_id
301     <> p_person_type_id) or
302     (NOT l_api_updating)) then
303     --
304  if g_debug then
305     hr_utility.set_location(l_proc, 2);
306  end if;
307     --
308     --  Populate l_system_person_type with the value of system person type
309     --
310     l_system_person_type := return_system_person_type(p_person_type_id
311                                                      ,p_business_group_id);
312     --
313  if g_debug then
314     hr_utility.set_location(l_proc, 3);
315  end if;
316     --
317     --  Check if the person is an employee
318     --
319     if l_system_person_type in ('EMP','EMP_APL') then
320       --
321  if g_debug then
322       hr_utility.set_location(l_proc, 4);
323  end if;
324       --
325       --  Person is an employee so set current employee flag to 'Y'
326       --
327       p_current_employee_flag := 'Y';
328     else
329       --
330  if g_debug then
331       hr_utility.set_location(l_proc, 5);
332  end if;
333       --
334       --  Person is not an employee so set to null
335       --
336       p_current_employee_flag := null;
337     end if;
338     --
339     --  Check if the person is an applicant
340     --
341     if l_system_person_type in ('APL','APL_EX_APL','EMP_APL','EX_EMP_APL') then
342       --
343  if g_debug then
344       hr_utility.set_location(l_proc, 6);
345  end if;
346       --
347       -- Person is an applicant so set current applicant flag to 'Y'
348       --
349       p_current_applicant_flag := 'Y';
350     else
351       --
352  if g_debug then
353       hr_utility.set_location(l_proc, 7);
354  end if;
355       --
356       --  Person is not an applicant so set to null
357       --
358       p_current_applicant_flag := null;
359     end if;
360     --
361     --  Check if the person is an employee or applicant
362     --
363     if l_system_person_type in ('EMP','APL','EMP_APL','EX_EMP_APL','APL_EX_APL')
364       then
365       --
366  if g_debug then
367       hr_utility.set_location(l_proc, 8);
368  end if;
369       --
370       --  Person is an employee or applicant so set current emp or apl flag
371       --  to 'Y'
372       --
373       p_current_emp_or_apl_flag := 'Y';
374     else
375       --
376       --  Person is not an employee or applicant so set to null
377       --
378  if g_debug then
379       hr_utility.set_location(l_proc, 9);
380  end if;
381       --
382       p_current_emp_or_apl_flag := null;
383       --
384     end if;
385  if g_debug then
386     hr_utility.set_location(l_proc, 10);
387  end if;
388   else
389  if g_debug then
390     hr_utility.set_location(l_proc, 11);
391  end if;
392     --
393     p_current_employee_flag := per_per_shd.g_old_rec.current_employee_flag;
394     p_current_applicant_flag := per_per_shd.g_old_rec.current_applicant_flag;
395     p_current_emp_or_apl_flag := per_per_shd.g_old_rec.current_emp_or_apl_flag;
396   end if;
397  if g_debug then
398     hr_utility.set_location(' Leaving:'|| l_proc, 12);
399  end if;
400 end set_current_flags;
401 --
402 --  ---------------------------------------------------------------------------
403 --  |------------------------<  chk_person_type_id >--------------------------|
404 --  ---------------------------------------------------------------------------
405 --
406 --  Description:
407 --    Checks that a person type id is valid
408 --
409 --  Pre-conditions:
410 --    1) p_current_employee_flag and p_current_emp_or_apl_flag must have been
411 --       set
412 --
413 --  In Arguments:
414 --    p_person_id
415 --    p_business_group_id
416 --    p_person_type_id
417 --    p_old_person_type_id
418 --    p_current_employee_flag
419 --    p_current_emp_or_apl_flag
420 --    p_effective_date
421 --    p_object_version_number
422 --    p_datetrack_mode
423 --
424 --  Post Success:
425 --    If the following cases are true then processing continues
426 --
427 --      a) person_type_id exists in per_person_types for the business group
428 --
429 --      b) system_person_type is one of:
430 --         APL, APL_EX_APL, EMP, EMP_APL, EX_APL, EX_EMP, EX_EMP_APL, OTHER
431 --
432 --         On insert only EMP, APL, and OTHER are permitted.
433 --
434 --      c) system_person_type undergoes one of the following transitions:
435 --         OTHER      to APL, EMP or OTHER
436 --         APL        to EMP, EMP_APL, EX_APL or APL
437 --         EX_APL     to APL_EX_APL or EX_APL, EMP
438 --         APL_EX_APL to EMP or APL_EX_APL, EMP_APL, EX_APL
439 --         EMP        to EMP_APL, EX_EMP or EMP
440 --         EMP_APL    to EMP or EMP_APL, EX_EMP_APL
441 --         EX_EMP     to EMP, EX_EMP_APL or EX_EMP
442 --         EX_EMP_APL to EMP_APL, EMP or EX_EMP_APL, EX_EMP
443 --
444 --      d) The value of system_person_type has changed and the
445 --         datetrack mode is UPDATE, CORRECTION or UPDATE_OVERRIDE (the
446 --         latter two under specific conditions).
447 --
448 --      e) The value of system_person_type has not changed and the
449 --         datetrack mode is UPDATE or CORRECTION.
450 --
451 --  Post Failure:
452 --    If any of the following cases are true then
453 --    an application error will be raised and processing is terminated
454 --
455 --      a) person_type_id does not exist in per_person_types for the business
456 --         group, or is not active
457 --
458 --      b) system_person_type is not as specified in (b) above.
459 --
460 --      c) The system_person_type transition is not as specified in (c)
461 --         above.
462 --
463 --      d) The value of system_person_type has changed and the
464 --         datetrack mode is UPDATE_CHANGE_INSERT, CORRECTION or
465 --         UPDATE_OVERRIDE (the latter two under specific conditions).
466 --
467 --      e) The value of system_person_type has not changed and the
468 --         datetrack mode is UPDATE_CHANGE_INSERT.
469 --
470 --  Access Status:
471 --    Internal Table Handler Use Only.
472 --
473 procedure chk_person_type_id
474   (p_person_id                in per_all_people_f.person_id%TYPE
475   ,p_business_group_id        in per_all_people_f.business_group_id%TYPE
476   ,p_person_type_id           in per_all_people_f.person_type_id%TYPE
477   ,p_old_person_type_id       in per_all_people_f.person_type_id%TYPE
478   ,p_current_employee_flag    in out nocopy per_all_people_f.current_employee_flag%TYPE
479   ,p_current_applicant_flag   in out nocopy per_all_people_f.current_employee_flag%TYPE
480   ,p_current_emp_or_apl_flag  in out nocopy per_all_people_f.current_emp_or_apl_flag%TYPE
481   ,p_effective_date           in date
482   ,p_validation_start_date    in date
483   ,p_object_version_number    in per_all_people_f.object_version_number%TYPE
484   ,p_datetrack_mode           in varchar2) is
485 --
486   l_exists                     varchar2(1);
487   l_new_system_person_type     varchar2(30);
488   l_old_system_person_type     varchar2(30);
489   l_proc           varchar2(72)  :=  g_package||'chk_person_type_id';
490   l_api_updating               boolean;
491   l_current_employee_flag      varchar2(1);
492   l_current_applicant_flag     varchar2(1);
493   l_current_emp_or_apl_flag    varchar2(1);
494   l_business_group_id          per_person_types.business_group_id%type;
495   l_active_flag                per_person_types.active_flag%type;
496   l_discard_varchar2           varchar2(100);
497   l_discard_number             number;
498   l_original_sys_type          per_person_types.system_person_type%type;
499 --
500   cursor
501     csr_person_type(l_person_type_id in per_all_people_f.person_type_id%type) is
502     select pet.system_person_type,
503       pet.business_group_id,
504       pet.active_flag
505     from per_person_types pet
506     where l_person_type_id = pet.person_type_id;
507 --
508 /*
509   cursor csr_system_type(l_start_date in date) is
510     select pet.system_person_type
511     from per_all_people_f per,
512     per_person_types pet
513     where per.person_id = p_person_id
514     and   l_start_date between per.effective_start_date
515              and     per.effective_end_date
516     and   pet.person_type_id = per.person_type_id;
517 */
518 --
519 begin
520  if g_debug then
521   hr_utility.set_location('Entering:'|| l_proc, 1);
522  end if;
523   --
524   -- Check mandatory parameters have been set
525   --
526   hr_api.mandatory_arg_error
527     (p_api_name       => l_proc
528     ,p_argument       => 'business group id'
529     ,p_argument_value => p_business_group_id
530     );
531   --
532   hr_api.mandatory_arg_error
533     (p_api_name       => l_proc
534     ,p_argument       => 'person type id'
535     ,p_argument_value => p_person_type_id
536     );
537   --
538   hr_api.mandatory_arg_error
539     (p_api_name       => l_proc
540     ,p_argument       => 'effective date'
541     ,p_argument_value => p_effective_date
542     );
543   --
544   -- The DateTrack mode UPDATE_OVERRIDE mode cannot be used if there is
545   -- a change of system person type after the effective date.
546   -- Note that this rule applies even if the person type is not being
547   -- changed in this transaction.
548   --
549   if p_datetrack_mode = 'UPDATE_OVERRIDE' then
550   --
551  if g_debug then
552     hr_utility.set_location(l_proc, 5);
553  end if;
554   --
555     per_per_bus.chk_system_pers_type
556     (p_person_id             => p_person_id
557     ,p_validation_start_date => p_validation_start_date
558     ,p_validation_end_date   => hr_api.g_eot
559     ,p_datetrack_mode        => p_datetrack_mode
560     ,p_effective_date        => p_effective_date
561     );
562   end if;
563   --
564   --  Only proceed with validation if:
565   --  a) The current g_old_rec is current and
566   --  b) The person type id value has changed
567   --  c) or a record is being inserted
568   --
569   l_api_updating := per_per_shd.api_updating
570     (p_person_id             => p_person_id
571     ,p_effective_date        => p_effective_date
572     ,p_object_version_number => p_object_version_number);
573   --
574   if ((l_api_updating and per_per_shd.g_old_rec.person_type_id <>
575     p_person_type_id) or
576     (NOT l_api_updating)) then
577     --
578     --  Perform Insert/Update Checks
579     --
580     --  Check if the person type id exists in per_person_types for the business
581     --  group
582     --
583     open csr_person_type(p_person_type_id);
584     fetch csr_person_type
585     into l_new_system_person_type,
586     l_business_group_id,
587     l_active_flag;
588     if csr_person_type%notfound then
589       close csr_person_type;
590       -- Error: Invalid person type
591       hr_utility.set_message(801, 'HR_7513_PER_TYPE_INVALID');
592       hr_utility.raise_error;
593     end if;
594     close csr_person_type;
595     if l_business_group_id <> p_business_group_id then
596       hr_utility.set_message(801, 'HR_7974_PER_TYPE_INV_BUS_GROUP');
597       hr_utility.raise_error;
598     elsif l_active_flag <> 'Y' then
599       hr_utility.set_message(801, 'HR_7973_PER_TYPE_NOT_ACTIVE');
600       hr_utility.raise_error;
601     end if;
602     --
603  if g_debug then
604     hr_utility.set_location(l_proc, 7);
605  end if;
606     --
607     -- If a new person is being inserted, then check that the system person
608     -- type is of a permitted value.
609     --
610     if p_datetrack_mode = 'INSERT' then
611       if l_new_system_person_type not in ('EMP', 'APL', 'OTHER') then
612         hr_utility.set_message(801, 'HR_7977_PER_INV_TYPE_FOR_INS');
613         hr_utility.raise_error;
614       end if;
615     end if;
616     --
617     --  Only proceed with validation if:
618     --  a) The current g_old_rec is current and
619     --  b) The person type id value has changed
620     --
621     if ((l_api_updating and per_per_shd.g_old_rec.person_type_id <>
622         p_person_type_id)) then
623       --
624       --  Perform Update Checks
625       --
626       --  Check the values of system person type in the old record for the
627       --  business group
628       --
629       open csr_person_type(p_old_person_type_id);
630       fetch csr_person_type
631       into l_old_system_person_type,
632       l_discard_number,
633       l_discard_varchar2;
634       close csr_person_type;
635  if g_debug then
636       hr_utility.set_location(l_proc, 9);
637  end if;
638       --
639       -- Check if DateTrack mode is valid
640       --
641       If l_new_system_person_type <> l_old_system_person_type then
642       --
643       -- system person type has changed so
644       -- update is allowed
645       -- update_change_insert is not allowed
646       --
647    -- ER FPT
648    if (p_datetrack_mode = 'UPDATE_CHANGE_INSERT')
649    then
650      if not (nvl(fnd_profile.value('HR_ALLOW_FPT_UPDATES'),'N') = 'Y')
651 	 then
652 	   hr_utility.set_message(801, 'HR_7724_PER_DT_MODE_SPT_CHANGE');
653 	   hr_utility.raise_error;
654 	 end if;
655    end if;
656         --
657    -- DateTrack mode CORRECTION is allowed, provided the system person
658    -- type hasn't already been changed on the effective start date of
659    -- the current row.
660    --
661    /*if p_datetrack_mode = 'CORRECTION' then
662           --
663           open CSR_System_type(p_validation_start_date-1);
664      fetch csr_system_type
665      into l_original_sys_type;
666      if csr_system_type%notfound then
667        close csr_system_type;
668        hr_utility.set_message(801, 'HR_7984_PER_NO_PREVIOUS_ROW');
669        hr_utility.raise_error;
670      end if;
671      close csr_system_type;
672      if l_original_sys_type <> l_old_system_person_type then
673              hr_utility.set_message(801, 'HR_7978_PER_TYPE_CHANGE');
674              hr_utility.raise_error;
675           end if;
676         end if;
677        */
678       end if;
679  if g_debug then
680       hr_utility.set_location(l_proc, 11);
681  end if;
682       --
683       -- Check that the system person type conversion is valid.
684       --
685       if (l_old_system_person_type = 'OTHER' and
686         l_new_system_person_type not in ('APL', 'EMP', 'OTHER'))
687       or (l_old_system_person_type = 'APL' and
688    l_new_system_person_type not in ('EMP', 'EMP_APL', 'EX_APL', 'APL'))
689       or (l_old_system_person_type = 'EX_APL' and
690      l_new_system_person_type not in ('EMP','APL_EX_APL', 'EX_APL'))
691       or (l_old_system_person_type = 'APL_EX_APL' and
692      l_new_system_person_type not in ('EMP','APL_EX_APL','EMP_APL','EX_APL'))
693       or (l_old_system_person_type = 'EMP' and
694     l_new_system_person_type not in ('EMP_APL', 'EX_EMP', 'EMP'))
695       or (l_old_system_person_type = 'EMP_APL' and
696      l_new_system_person_type not in ('EMP', 'EMP_APL','EX_EMP_APL'))
697       or (l_old_system_person_type = 'EX_EMP' and
698    l_new_system_person_type not in ('EMP', 'EX_EMP_APL', 'EX_EMP'))
699       or (l_old_system_person_type = 'EX_EMP_APL' and
700      l_new_system_person_type not in ('EMP_APL', 'EMP', 'EX_EMP_APL','EX_EMP'))
701       then
702    hr_utility.set_message(801, 'HR_7987_PER_INV_TYPE_CHANGE');
703    hr_utility.raise_error;
704       else
705  if g_debug then
706         hr_utility.set_location(l_proc, 12);
707  end if;
708    --
709    set_current_flags(p_person_id
710                         ,p_business_group_id
711                    ,p_person_type_id
712                    ,l_current_employee_flag
713               ,l_current_applicant_flag
714               ,l_current_emp_or_apl_flag
715               ,p_effective_date
716               ,p_object_version_number);
717      --
718    p_current_employee_flag := l_current_employee_flag;
719    p_current_applicant_flag := l_current_applicant_flag;
720    p_current_emp_or_apl_flag := l_current_emp_or_apl_flag;
721       end if;
722     end if;
723   end if;
724  if g_debug then
725   hr_utility.set_location(' Leaving:'|| l_proc, 13);
726  end if;
727   exception
728     when app_exception.application_exception then
729       if hr_multi_message.exception_add
730       (p_associated_column1      => 'PER_ALL_PEOPLE_F.PERSON_TYPE_ID'
731       ) then
732  if g_debug then
733         hr_utility.set_location(' Leaving:'||l_proc, 14);
734  end if;
735         raise;
736     end if;
737  if g_debug then
738     hr_utility.set_location(' Leaving:'||l_proc,15);
739  end if;
740     hr_multi_message.end_validation_set;
741 end chk_person_type_id;
742 --
743 --  ---------------------------------------------------------------------------
744 --  |------------------------<  chk_date_of_birth  >--------------------------|
745 --  ---------------------------------------------------------------------------
746 --
747 --  Description:
748 --    Checks that a date of birth value is valid
749 --
750 --  Pre-conditions:
751 --    None
752 --
753 --  In Arguments:
754 --    p_person_id
755 --    p_person_type_id
756 --    p_business_group_id
757 --    p_start_date
758 --    p_date_of_birth
759 --    p_effective_date
760 --    p_object_version_number
761 --
762 --  Out Arguments
763 --    p_dob_null_warning
764 --
765 --  Post Success:
766 --    If a date of birth <= the start date then
767 --    processing continues
768 --
769 --    If date of birth is null on insert when system person type is 'EMP' then
770 --    a warning is flagged and processing continues
771 --
772 --    If the persons age is between the minimum and maximum ages defined
773 --    for the business group then
774 --    processing continues
775 --
776 --  Post Failure:
777 --    If a date of birth > the start date then
778 --    an application error will be raised and processing is terminated
779 --
780 --    If the persons age is not between the minimum and maximum ages defined
781 --    for the business group then
782 --    an application error will be raised and processing is terminated
783 --
784 --    If the person type is EMP, and any assignment has its payroll component
785 --    set, then an application error will be raised and processing terminated
786 --    if the date of birth is updated to null.
787 --
788 --  Access Status:
789 --    Internal Table Handler Use Only.
790 --
791 procedure chk_date_of_birth
792   (p_person_id                in  per_all_people_f.person_id%TYPE
793   ,p_person_type_id           in  per_all_people_f.person_type_id%TYPE
794   ,p_business_group_id        in  per_all_people_f.business_group_id%TYPE
795   ,p_start_date               in  date
796   ,p_date_of_birth            in  date
797   ,p_dob_null_warning         out nocopy boolean
798   ,p_effective_date           in  date
799   ,p_validation_start_date    in  date
800   ,p_validation_end_date      in  date
801   ,p_object_version_number    in  per_all_people_f.object_version_number%TYPE) is
802 --
803   l_exists         varchar2(1);
804   l_proc           varchar2(72)  :=  g_package||'chk_date_of_birth';
805   l_api_updating   boolean;
806    /* Change for the bug 7001206 starts here */
807   -- l_age            number(3);    --852863
808   -- l_minimum_age    number(3);    --852863
809   -- l_maximum_age    number(3);    --852863
810 
811    l_age            number(4);
812    l_minimum_age    number(4);
813    l_maximum_age    number(4);
814    /* Change for the bug 7001206 ends here */
815   l_dob_st         boolean := false;
816   l_system_person_type varchar2(20);    --2273304
817   --
818   cursor csr_asg is
819     select null
820     from per_assignments_f asg
821     where asg.person_id = p_person_id
822     and   asg.effective_start_date <= p_validation_end_date
823     and   asg.effective_end_date >= p_validation_start_date
824     and   asg.payroll_id is not null;
825   --
826 begin
827  if g_debug then
828   hr_utility.set_location('Entering:'|| l_proc, 1);
829  end if;
830   --
831   -- Check mandatory parameters have been set
832   --
833   if hr_multi_message.no_exclusive_error
834      (p_check_column1      => 'PER_ALL_PEOPLE_F.START_DATE'
835      )
836   then
837     hr_api.mandatory_arg_error
838       (p_api_name       => l_proc
839       ,p_argument       => 'person type id'
840       ,p_argument_value => p_person_type_id
841       );
842     --
843     hr_api.mandatory_arg_error
844       (p_api_name       => l_proc
845       ,p_argument       => 'business group id'
846       ,p_argument_value => p_business_group_id
847       );
848     --
849     hr_api.mandatory_arg_error
850       (p_api_name       => l_proc
851       ,p_argument       => 'effective date'
852       ,p_argument_value => p_effective_date
853       );
854     --
855     hr_api.mandatory_arg_error
856       (p_api_name       => l_proc
857       ,p_argument       => 'validation start date'
858       ,p_argument_value => p_validation_start_date
859       );
860     --
861     hr_api.mandatory_arg_error
862       (p_api_name       => l_proc
863      ,p_argument       => 'validation end date'
864      ,p_argument_value => p_validation_end_date
865       );
866     --
867     p_dob_null_warning := false;
868     --
869     --  Only proceed with validation if:
870     --  a) The current g_old_rec is current and
871     --  b) The start date value has changed
872     --  c) a record is being inserted
873     --
874     l_api_updating := per_per_shd.api_updating
875       (p_person_id             => p_person_id
876       ,p_effective_date        => p_effective_date
877       ,p_object_version_number => p_object_version_number);
878     --
879     if ((l_api_updating and nvl(per_per_shd.g_old_rec.date_of_birth,
880                                 hr_api.g_date)
881       <> nvl(p_date_of_birth,hr_api.g_date)) or
882       (NOT l_api_updating)) then
883  if g_debug then
884       hr_utility.set_location(l_proc, 2);
885  end if;
886       --
887       --  Perform Insert/Update checks
888       --
889       --  Check if date of birth is greater than start date
890       --
891       if p_date_of_birth is not null then
892         if p_date_of_birth > p_start_date then
893           --  Error: The Date of Birth is greater than the start date
894           hr_utility.set_message(801, 'HR_6523_PERSON_DOB_GT_START');
895           l_dob_st := true;
896           hr_utility.raise_error;
897         end if;
898       end if;
899  if g_debug then
900       hr_utility.set_location(l_proc, 3);
901  end if;
902       --
903       --  Calculate persons age
904       --
905  if g_debug then
906       hr_utility.set_location(p_effective_date,10);
907  end if;
908  if g_debug then
909       hr_utility.set_location(p_date_of_birth,10);
910  end if;
911       l_age := trunc(months_between(p_effective_date,p_date_of_birth)/12);
912       --
913       --  Find the minimum and maximum ages allowed for the business group
914       --
915       per_people3_pkg.get_legislative_ages(p_business_group_id
916                                           ,l_minimum_age
917                                           ,l_maximum_age);
918       --
919  if g_debug then
920       hr_utility.set_location(l_proc, 4);
921  end if;
922       --
923       --  Check that the persons age is between the minimum and maximum allowed
924       --  for the business group.
925       --  This check should not be done if person is of type OTHER. <IJH 483393>
926       --
927       -- Bug# 2273304 Start Here
928       --
929       l_system_person_type := return_system_person_type
930       (p_person_type_id, p_business_group_id);
931       if l_age not between nvl(l_minimum_age,l_age) and
932                            nvl(l_maximum_age,l_age) and
933          ( l_system_person_type <> 'OTHER' and l_system_person_type <>'%APL') then
934           --  Error: Employees age must be between 'min' and 'max'
935           hr_utility.set_message(801, 'HR_7426_EMP_AGE_ILLEGAL');
936           hr_utility.set_message_token('MIN',to_char(l_minimum_age));
937           hr_utility.set_message_token('MAX',to_char(l_maximum_age));
938           hr_utility.raise_error;
939       end if;
940       --
941       --Bug# 2273304 End Here
942       --
943       --
944       -- Only proceed with validation if:
945       --  a) a record is being inserted
946       --
947       if NOT l_api_updating then
948         --
949         --  Perform Insert check
950         --
951  if g_debug then
952         hr_utility.set_location(l_proc, 5);
953  end if;
954         --
955       end if;
956       --
957       -- Disallow updating of date of birth to null if person type is EMP and
958       -- any assignment has its payroll component set.
959       --
960       if l_api_updating
961       and return_system_person_type(p_person_type_id, p_business_group_id) in
962                ('EMP','EX_EMP','EMP_APL','EX_EMP_APL')
963       and p_date_of_birth is null then
964  if g_debug then
965         hr_utility.set_location(l_proc, 6);
966  end if;
967         open csr_asg;
968         fetch csr_asg into l_exists;
969         if csr_asg%notfound then
970         close csr_asg;
971           p_dob_null_warning := TRUE;
972  if g_debug then
973           hr_utility.set_location(l_proc, 7);
974  end if;
975         else
976      close csr_asg;
977           hr_utility.set_message(801, 'HR_7950_PPM_NULL_DOB');
978           hr_utility.raise_error;
979         end if;
980       end if;
981     End if;
982     --  Raise warning if date of birth is null and system person type is 'EMP'
983     --
984       If return_system_person_type
985       (p_person_type_id, p_business_group_id) = 'EMP' and
986        p_date_of_birth is null then
987        p_dob_null_warning := TRUE;
988       end if;
989     end if;
990  if g_debug then
991   hr_utility.set_location(' Leaving:'|| l_proc, 8);
992  end if;
993   exception
994   when app_exception.application_exception then
995     If not l_dob_st then
996       if hr_multi_message.exception_add
997       (p_associated_column1      => 'PER_ALL_PEOPLE_F.DATE_OF_BIRTH'
998       ) then
999  if g_debug then
1000         hr_utility.set_location(' Leaving:'||l_proc, 9);
1001  end if;
1002         raise;
1003       end if;
1004     Else
1005       if hr_multi_message.exception_add
1006           (p_associated_column1      => 'PER_ALL_PEOPLE_F.DATE_OF_BIRTH'
1007           ,p_associated_column2      => 'PER_ALL_PEOPLE_F.START_DATE'
1008           ) then
1009  if g_debug then
1010             hr_utility.set_location(' Leaving:'||l_proc, 10);
1011  end if;
1012             raise;
1013       end if;
1014     End if;
1015  if g_debug then
1016     hr_utility.set_location(' Leaving:'||l_proc,11);
1017  end if;
1018 end chk_date_of_birth;
1019 --
1020 --  ---------------------------------------------------------------------------
1021 --  |-----------------------< chk_marital_status  >--------------------------|
1022 --  ---------------------------------------------------------------------------
1023 --
1024 --  Description:
1025 --    - Validates that the marital status exists as a lookup code on
1026 --      HR_LOOKUPS for the lookup type 'MAR_STATUS' with an enabled
1027 --      flag set to 'Y' and the effective start date of the person between
1028 --      start date active and end date active on HR_LOOKUPS.
1029 --
1030 --  Pre-conditions:
1031 --    None
1032 --
1033 --  In Arguments:
1034 --    p_person_id
1035 --    p_marital_status
1036 --    p_effective_date
1037 --    p_validation_start_date
1038 --    p_validation_end_date
1039 --    p_object_version_number
1040 --
1041 --  Post Success:
1042 --    Processing continues if:
1043 --      - marital status exists as a lookup code in HR_LOOKUPS
1044 --        for the lookup type 'MAR_STATUS' where the enabled
1045 --        flag is 'Y' and the effective start date of the person
1046 --        is between start date active and end date active on HR_LOOKUPS.
1047 --
1048 --  Post Failure:
1049 --    An application error is raised and processing is terminated if:
1050 --      - marital status does'nt exist as a lookup code in HR_LOOKUPS
1051 --        for the lookup type 'MAR_STATUS' where the enabled
1052 --        flag is 'Y' and the effective start date of the person
1053 --        is between start date active and end date active on HR_LOOKUPS.
1054 --
1055 --  Access Status:
1056 --    Internal Table Handler Use Only.
1057 --
1058 procedure chk_marital_status
1059   (p_person_id                in     per_all_people_f.person_id%TYPE
1060   ,p_marital_status           in     per_all_people_f.marital_status%TYPE
1061   ,p_effective_date           in     date
1062   ,p_validation_start_date    in     date
1063   ,p_validation_end_date      in     date
1064   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
1065   )
1066 is
1067   --
1068   l_exists         varchar2(1);
1069   l_proc           varchar2(72)  :=  g_package||'chk_marital_status';
1070   l_api_updating   boolean;
1071   --
1072 begin
1073  if g_debug then
1074   hr_utility.set_location('Entering:'|| l_proc, 10);
1075  end if;
1076   --
1077   -- Check mandatory parameters have been set
1078   --
1079   hr_api.mandatory_arg_error
1080     (p_api_name       => l_proc
1081     ,p_argument       => 'effective date'
1082     ,p_argument_value => p_effective_date
1083     );
1084   --
1085   hr_api.mandatory_arg_error
1086     (p_api_name       =>  l_proc
1087     ,p_argument       =>  'validation_start_date'
1088     ,p_argument_value =>  p_validation_start_date
1089     );
1090   --
1091   hr_api.mandatory_arg_error
1092     (p_api_name        =>  l_proc
1093     ,p_argument       =>  'validation_end_date'
1094     ,p_argument_value =>  p_validation_end_date
1095     );
1096  if g_debug then
1097   hr_utility.set_location(l_proc, 20);
1098  end if;
1099   --
1100   --  Only proceed with validation if:
1101   --  a) The current g_old_rec is current and
1102   --  b) The marital status value has changed
1103   --  c) a record is being inserted
1104   --
1105   l_api_updating := per_per_shd.api_updating
1106     (p_person_id             => p_person_id
1107     ,p_effective_date        => p_effective_date
1108     ,p_object_version_number => p_object_version_number
1109     );
1110   if ((l_api_updating
1111       and nvl(per_per_shd.g_old_rec.marital_status, hr_api.g_varchar2)
1112       <> nvl(p_marital_status,hr_api.g_varchar2))
1113     or
1114       (NOT l_api_updating))
1115   then
1116  if g_debug then
1117     hr_utility.set_location(l_proc, 40);
1118  end if;
1119     --
1120     -- Check if marital status is set
1121     --
1122     If p_marital_status is not null then
1123       --
1124       -- Check that the marital status exists in hr_lookups for the
1125       -- lookup type 'MAR_STATUS' with an enabled flag set to 'Y' and that
1126       -- the effective start date of the person is between start date
1127       -- active and end date active in hr_lookups.
1128       --
1129       if hr_api.not_exists_in_dt_hr_lookups
1130         (p_effective_date        => p_effective_date
1131         ,p_validation_start_date => p_validation_start_date
1132         ,p_validation_end_date   => p_validation_end_date
1133         ,p_lookup_type           => 'MAR_STATUS'
1134         ,p_lookup_code           => p_marital_status
1135         )
1136       then
1137         --
1138         hr_utility.set_message(801, 'HR_7518_PER_M_STATUS_INVALID');
1139         hr_utility.raise_error;
1140         --
1141       end if;
1142     end if;
1143  if g_debug then
1144     hr_utility.set_location(l_proc, 60);
1145  end if;
1146     --
1147   end if;
1148  if g_debug then
1149   hr_utility.set_location(' Leaving:'|| l_proc, 70);
1150  end if;
1151   exception
1152     when app_exception.application_exception then
1153       if hr_multi_message.exception_add
1154       (p_associated_column1      => 'PER_ALL_PEOPLE_F.MARITAL_STATUS'
1155       ) then
1156  if g_debug then
1157         hr_utility.set_location(' Leaving:'||l_proc, 80);
1158  end if;
1159         raise;
1160       end if;
1161  if g_debug then
1162   hr_utility.set_location(' Leaving:'||l_proc,90);
1163  end if;
1164 end chk_marital_status;
1165 --
1166 --  ---------------------------------------------------------------------------
1167 --  |-----------------------< chk_party_id >----------------------------------|
1168 --  ---------------------------------------------------------------------------
1169 --
1170 --  Description:
1171 --    - Validates that the party exists as a party in HZ_PARTIES.
1172 --
1173 --  Pre-conditions:
1174 --    None
1175 --
1176 --  In Arguments:
1177 --    p_person_id
1178 --    p_party_id
1179 --    p_effective_date
1180 --    p_object_version_number
1181 --
1182 --  Post Success:
1183 --    Processing continues if:
1184 --      - party_id is null or party exists in hz_parties.
1185 --
1186 --  Post Failure:
1187 --    An application error is raised and processing is terminated if:
1188 --      - party_id does not exist in HZ_PARTIES.
1189 --
1190 --  Access Status:
1191 --    Internal Table Handler Use Only.
1192 --
1193 procedure chk_party_id
1194   (p_person_id                in     per_all_people_f.person_id%TYPE
1195   ,p_party_id                 in     number
1196   ,p_effective_date           in     date
1197   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
1198   )
1199 is
1200   --
1201   l_exists         varchar2(1);
1202   l_proc           varchar2(72)  :=  g_package||'chk_party_id';
1203   l_api_updating   boolean;
1204   --
1205   cursor c1 is
1206     select null
1207     from   hz_parties
1208     where  party_id = p_party_id;
1209   --
1210 begin
1211  if g_debug then
1212   hr_utility.set_location('Entering:'|| l_proc, 10);
1213  end if;
1214   --
1215   -- Check mandatory parameters have been set
1216   --
1217   hr_api.mandatory_arg_error
1218     (p_api_name       => l_proc
1219     ,p_argument       => 'effective date'
1220     ,p_argument_value => p_effective_date
1221     );
1222   --
1223  if g_debug then
1224   hr_utility.set_location(l_proc, 20);
1225  end if;
1226   --
1227   --  Only proceed with validation if:
1228   --  a) The current g_old_rec is current and
1229   --  b) The party value has changed
1230   --  c) a record is being inserted
1231   --
1232   l_api_updating := per_per_shd.api_updating
1233     (p_person_id             => p_person_id
1234     ,p_effective_date        => p_effective_date
1235     ,p_object_version_number => p_object_version_number
1236     );
1237   if ((l_api_updating
1238       and nvl(per_per_shd.g_old_rec.party_id, hr_api.g_number)
1239       <> nvl(p_party_id,hr_api.g_number))
1240     or
1241       (NOT l_api_updating))
1242   then
1243  if g_debug then
1244     hr_utility.set_location(l_proc, 40);
1245  end if;
1246     --
1247     -- Check if party is set
1248     --
1249     If p_party_id is not null then
1250       --
1251       -- Check that the party_id exists in HZ_PARTIES.
1252       --
1253         open c1;
1254         fetch c1 into l_exists;
1255         if c1%notfound then
1256           --
1257           close c1;
1258           hr_utility.set_message(800, 'PER_289342_PARTY_ID_INVALID');
1259           hr_utility.raise_error;
1260           --
1261         end if;
1262         --
1263       close c1;
1264       --
1265     end if;
1266     --
1267  if g_debug then
1268     hr_utility.set_location(l_proc, 60);
1269  end if;
1270     --
1271   end if;
1272  if g_debug then
1273   hr_utility.set_location(' Leaving:'|| l_proc, 70);
1274  end if;
1275   exception
1276     when app_exception.application_exception then
1277       if hr_multi_message.exception_add
1278       (p_associated_column1      => 'PER_ALL_PEOPLE_F.PARTY_ID'
1279       ) then
1280  if g_debug then
1281         hr_utility.set_location(' Leaving:'||l_proc, 80);
1282  end if;
1283         raise;
1284       end if;
1285  if g_debug then
1286     hr_utility.set_location(' Leaving:'||l_proc,90);
1287  end if;
1288 end chk_party_id;
1289 --
1290 --  ---------------------------------------------------------------------------
1291 --  |-----------------------<  chk_nationality  >-----------------------------|
1292 --  ---------------------------------------------------------------------------
1293 --
1294 --  Description:
1295 --    Checks that a nationality value is valid
1296 --    - Validates that the nationality exists as a lookup code on
1297 --      HR_LOOKUPS for the lookup type 'NATIONALITY' with an enabled
1298 --      flag set to 'Y' and the effective start date of the person between
1299 --      start date active and end date active on HR_LOOKUPS.
1300 --
1301 --  Pre-conditions:
1302 --    None
1303 --
1304 --  In Arguments:
1305 --    p_person_id
1306 --    p_nationality
1307 --    p_effective_date
1308 --    p_validation_start_date
1309 --    p_validation_end_date
1310 --    p_object_version_number
1311 --
1312 --  Post Success:
1313 --    Processing continues if:
1314 --      - nationality exists as a lookup code in HR_LOOKUPS
1315 --        for the lookup type 'NATIONALITY' where the enabled
1316 --        flag is 'Y' and the effective start date of the person
1317 --        is between start date active and end date active on HR_LOOKUPS.
1318 --
1319 --  Post Failure:
1320 --    An application error is raised and processing is terminated if:
1321 --      - nationality does'nt exist as a lookup code in HR_LOOKUPS
1322 --        for the lookup type 'NATIONALITY' where the enabled
1323 --        flag is 'Y' and the effective start date of the person
1324 --        is between start date active and end date active on HR_LOOKUPS.
1325 --
1326 --  Access Status:
1327 --    Internal Table Handler Use Only.
1328 --
1329 procedure chk_nationality
1330   (p_person_id                in     per_all_people_f.person_id%TYPE
1331   ,p_nationality              in     per_all_people_f.nationality%TYPE
1332   ,p_effective_date           in     date
1333   ,p_validation_start_date    in     date
1334   ,p_validation_end_date      in     date
1335   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
1336   )
1337 is
1338   --
1339   l_exists         varchar2(1);
1340   l_proc           varchar2(72)  :=  g_package||'chk_nationality';
1341   l_api_updating   boolean;
1342   --
1343 begin
1344  if g_debug then
1345   hr_utility.set_location('Entering:'|| l_proc, 10);
1346  end if;
1347   --
1348   -- Check mandatory parameters have been set
1349   --
1350   hr_api.mandatory_arg_error
1351     (p_api_name       => l_proc
1352     ,p_argument       => 'effective date'
1353     ,p_argument_value => p_effective_date
1354     );
1355   --
1356   hr_api.mandatory_arg_error
1357     (p_api_name       =>  l_proc
1358     ,p_argument       =>  'validation_start_date'
1359     ,p_argument_value =>  p_validation_start_date
1360     );
1361   --
1362   hr_api.mandatory_arg_error
1363     (p_api_name        =>  l_proc
1364     ,p_argument       =>  'validation_end_date'
1365     ,p_argument_value =>  p_validation_end_date
1366     );
1367   --  Only proceed with validation if:
1368   --  a) The current g_old_rec is current and
1369   --  b) The nationality value has changed
1370   --  c) A record is being inserted
1371   --
1372   l_api_updating := per_per_shd.api_updating
1373     (p_person_id             => p_person_id
1374     ,p_effective_date        => p_effective_date
1375     ,p_object_version_number => p_object_version_number
1376     );
1377   if ((l_api_updating
1378       and nvl(per_per_shd.g_old_rec.nationality, hr_api.g_varchar2)
1379       <> nvl(p_nationality,hr_api.g_varchar2))
1380     or
1381       (NOT l_api_updating))
1382   then
1383  if g_debug then
1384     hr_utility.set_location(l_proc, 40);
1385  end if;
1386     --
1387     --  Check if nationality is set
1388     --
1389     if p_nationality is not null then
1390       --
1391       -- Check that the nationality exists in hr_lookups for the
1392       -- lookup type 'NATIONALITY' with an enabled flag set to 'Y' and that
1393       -- the effective start date of the person is between start date
1394       -- active and end date active in hr_lookups.
1395       --
1396       if hr_api.not_exists_in_dt_hr_lookups
1397         (p_effective_date        => p_effective_date
1398         ,p_validation_start_date => p_validation_start_date
1399         ,p_validation_end_date   => p_validation_end_date
1400         ,p_lookup_type           => 'NATIONALITY'
1401         ,p_lookup_code           => p_nationality
1402         )
1403       then
1404         --
1405         hr_utility.set_message(801, 'HR_7522_PER_NATION_INVALID');
1406         hr_utility.raise_error;
1407         --
1408       end if;
1409  if g_debug then
1410       hr_utility.set_location(l_proc, 50);
1411  end if;
1412       --
1413     end if;
1414   end if;
1415  if g_debug then
1416   hr_utility.set_location(' Leaving:'|| l_proc, 60);
1417  end if;
1418   exception
1419     when app_exception.application_exception then
1420       if hr_multi_message.exception_add
1421       (p_associated_column1      => 'PER_ALL_PEOPLE_F.NATIONALITY'
1422       ) then
1423  if g_debug then
1424         hr_utility.set_location(' Leaving:'||l_proc, 70);
1425  end if;
1426         raise;
1427       end if;
1428  if g_debug then
1429   hr_utility.set_location(' Leaving:'||l_proc,80);
1430  end if;
1431 end chk_nationality;
1432 
1433 -- start for bug 6241572, a new overloaded procedure is created with
1434 -- p_region_of_birth, p_country_of_birth and p_nationality parameters.
1435 
1436 procedure chk_national_identifier
1437   (p_person_id                in  per_all_people_f.person_id%TYPE
1438   ,p_business_group_id        in  per_all_people_f.business_group_id%TYPE
1439   ,p_national_identifier      in  per_all_people_f.national_identifier%TYPE
1440   ,p_date_of_birth            in  date
1441   ,p_sex                      in  per_all_people_f.sex%TYPE
1442   ,p_effective_date           in  date
1443   ,p_object_version_number    in  per_all_people_f.object_version_number%TYPE
1444   ,p_legislation_code         in  per_business_groups.legislation_code%TYPE
1445   ,p_person_type_id           in  per_all_people_f.person_type_id%TYPE) is
1446 
1447 	-- declaring those variable which are not present in the previous
1448 	-- chk_national_identifier
1449 
1450   l_region_of_birth			  per_all_people_f.region_of_birth%TYPE;
1451   l_country_of_birth      per_all_people_f.country_of_birth%TYPE;
1452   l_nationality           per_all_people_f.nationality%TYPE;
1453 
1454 begin
1455 	--calling chk_nation_identifier
1456 
1457   per_per_bus.chk_national_identifier
1458   (p_person_id                => p_person_id,
1459    p_business_group_id        => p_business_group_id,
1460    p_national_identifier      => p_national_identifier,
1461    p_date_of_birth            => p_date_of_birth,
1462    p_sex                      => p_sex,
1463    p_effective_date           => p_effective_date,
1464    p_object_version_number    => p_object_version_number,
1465    p_legislation_code         => p_legislation_code,
1466    p_person_type_id           => p_person_type_id,
1467    p_region_of_birth          => l_region_of_birth,
1468    p_country_of_birth         => l_country_of_birth,
1469    p_nationality              => l_nationality);
1470 
1471 end;
1472 
1473 --end for bug 6241572
1474 --
1475 --  ---------------------------------------------------------------------------
1476 --  |-------------------<  chk_national_identifier  >-------------------------|
1477 --  ---------------------------------------------------------------------------
1478 --
1479 --  Description:
1480 --    Calls process hr_person.validate_national_identifier
1481 --
1482 --  Pre-conditions:
1483 --    Business Group id must be valid
1484 --
1485 --  In Arguments:
1486 --    p_person_id
1487 --    p_business_group_id
1488 --    p_national_identifier
1489 --    p_date_of_birth
1490 --    p_sex
1491 --    p_effective_date
1492 --    p_object_version_number
1493 --    p_legislation_code
1494 --    p_person_type_id            - Bug 1642707.
1495 --
1496 --  Post Success:
1497 --    If the national identifier is valid then
1498 --    processing continues
1499 --
1500 --  Post Failure:
1501 --    If the national identifier is not valid then
1502 --    an application error is raised and processing is terminated
1503 --
1504 --  Access Status:
1505 --    Internal Table Handler Use Only.
1506 --
1507 procedure chk_national_identifier
1508   (p_person_id                in  per_all_people_f.person_id%TYPE
1509   ,p_business_group_id        in  per_all_people_f.business_group_id%TYPE
1510   ,p_national_identifier      in  per_all_people_f.national_identifier%TYPE
1511   ,p_date_of_birth            in  date
1512   ,p_sex                      in  per_all_people_f.sex%TYPE
1513   ,p_effective_date           in  date
1514   ,p_object_version_number    in  per_all_people_f.object_version_number%TYPE
1515   ,p_legislation_code         in  per_business_groups.legislation_code%TYPE
1516   ,p_person_type_id           in  per_all_people_f.person_type_id%TYPE
1517 
1518   --added new parameter for bug 6241572
1519   ,p_region_of_birth          in  per_all_people_f.region_of_birth%TYPE default NULL
1520   ,p_country_of_birth         in  per_all_people_f.country_of_birth%TYPE default NULL
1521   ,p_nationality              in  per_all_people_f.nationality%TYPE) is
1522 
1523 --
1524   l_exists            varchar2(1);
1525   l_proc              varchar2(72)  :=  g_package||'chk_national_identifier';
1526   l_api_updating      boolean;
1527   l_valid_ni          varchar2(240);
1528   l_warning           varchar2(1)   := 'N';
1529   l_prof_val          varchar2(50) ;  -- #4069243
1530 --
1531 begin
1532  if g_debug then
1533   hr_utility.set_location('Entering:'|| l_proc, 1);
1534  end if;
1535   --
1536   -- Check mandatory parameters have been set
1537   --
1538   hr_api.mandatory_arg_error
1539     (p_api_name       => l_proc
1540     ,p_argument       => 'business group id'
1541     ,p_argument_value => p_business_group_id
1542     );
1543   --
1544   hr_api.mandatory_arg_error
1545     (p_api_name       => l_proc
1546     ,p_argument       => 'effective date'
1547     ,p_argument_value => p_effective_date
1548     );
1549   --
1550   --  Only proceed with validation if:
1551   --  a) The current g_old_rec is current and
1552   --  b) national identifier has changed
1553   --  c) A record is being inserted
1554   --
1555   l_api_updating := per_per_shd.api_updating
1556     (p_person_id             => p_person_id
1557     ,p_effective_date        => p_effective_date
1558     ,p_object_version_number => p_object_version_number);
1559   --
1560   if ((l_api_updating and nvl(per_per_shd.g_old_rec.national_identifier,
1561                               hr_api.g_varchar2)
1562     <> nvl(p_national_identifier,hr_api.g_varchar2)) or
1563     (NOT l_api_updating)) then
1564     --
1565  if g_debug then
1566     hr_utility.set_location(l_proc, 2);
1567  end if;
1568     --
1569     --  If national identifier is not null then
1570     --  Call process to validate national identifier
1571     --  (If validation is successful, but returns different format
1572     --  raise error)
1573     --
1574     if p_national_identifier is not null then
1575     l_valid_ni := hr_ni_chk_pkg.validate_national_identifier(
1576                       p_national_identifier => p_national_identifier,
1577                       p_birth_date          => p_date_of_birth,
1578                       p_gender              => p_sex,
1579                       p_person_id           => p_person_id,
1580                  p_business_group_id   => p_business_group_id,
1581                       p_legislation_code    => p_legislation_code,
1582                       p_session_date        => p_effective_date,
1583                       p_warning             => l_warning,
1584                       p_person_type_id      => p_person_type_id,
1585                                                                     --change for bug 6241572
1586 		      p_region_of_birth     => p_region_of_birth,
1587                       p_country_of_birth    => p_country_of_birth,
1588                       p_nationality         => p_nationality );
1589       --
1590 --
1591 --
1592 --  3807899 - Modified the 'or' condition to 'and'
1593 --            Also modified the value used to set the token 'RETURNED_VALUE' to l_valid_ni
1594 --            instead of '123-45-789'
1595 --
1596     if fnd_profile.value('PER_NATIONAL_IDENTIFIER_VALIDATION') <> 'NONE' and fnd_profile.value('PER_NATIONAL_IDENTIFIER_VALIDATION') <> 'WARN' then
1597     -- #932657
1598       if l_valid_ni <> p_national_identifier then
1599         hr_utility.set_message(800, 'HR_52765_PER_INV_NI_FORMAT');
1600         hr_utility.set_message_token('P_N_I', p_national_identifier);
1601         hr_utility.set_message_token('RETURNED_VALUE', l_valid_ni); --3807899
1602    hr_utility.raise_error;
1603       end if;
1604      end if;
1605       -- 4069243 start
1606        l_prof_val := fnd_profile.value ('PER_NI_UNIQUE_ERROR_WARNING');
1607 
1608         hr_ni_chk_pkg.check_ni_unique
1609           (p_national_identifier => p_national_identifier
1610           ,p_person_id => p_person_id
1611           ,p_business_group_id =>p_business_group_id
1612           ,p_raise_error_or_warning => nvl(l_prof_val,'WARNING'));
1613       -- 4069243 end
1614     end if;
1615     --
1616   end if;
1617  if g_debug then
1618   hr_utility.set_location(' Leaving:'|| l_proc, 3);
1619  end if;
1620   exception
1621     when app_exception.application_exception then
1622       if hr_multi_message.exception_add
1623       (p_associated_column1      => 'PER_ALL_PEOPLE_F.NATIONAL_IDENTIFIER'
1624       ) then
1625  if g_debug then
1626         hr_utility.set_location(' Leaving:'||l_proc, 4);
1627  end if;
1628         raise;
1629       end if;
1630  if g_debug then
1631      hr_utility.set_location(' Leaving:'||l_proc,5);
1632  end if;
1633 end chk_national_identifier;
1634 --
1635 --  ---------------------------------------------------------------------------
1636 --  |-----------------------<  chk_employee_number  >-------------------------|
1637 --  ---------------------------------------------------------------------------
1638 --
1639 --  Description:
1640 --    Checks that an employee value is valid
1641 --
1642 --  Pre-conditions:
1643 --    p_person_type_id must be valid
1644 --    p_business_group_id must be valid for p_person_id
1645 --    p_national_identifier must be valid
1646 --
1647 --  In Arguments:
1648 --    p_person_id
1649 --    p_business_group_id
1650 --    p_person_type_id
1651 --    p_employee_number
1652 --    p_national_identifier
1653 --    p_effective_date
1654 --    p_object_version_number
1655 --
1656 --  Post Success:
1657 --    If system person type is 'EMP', 'EX_EMP', 'EMP_APL' or 'EX_EMP_APL' then
1658 --    employee number is defined based on employee number generation method as
1659 --    follows :
1660 --
1661 --        If employee number is not null and employee number generation method
1662 --        is 'Manual' then processing continues.
1663 --        If employee number is null and employee number generation method is
1664 --        'Automatic' then employee number is generated and processing
1665 --        continues.
1666 --        If employee number is null and national identifier is not null and
1667 --        the employee number generation method is 'National identifier' then
1668 --        employee number is set to national identifier and processing
1669 --        continues.
1670 --
1671 --    If the employee number is unique within the business group then
1672 --    processing continues
1673 --
1674 --  Post Failure:
1675 --    If system person type is 'EMP', 'EX_EMP', 'EMP_APL' or 'EX_EMP_APL' then
1676 --    If employee number is null then
1677 --    an application error will be raised and processing is terminated
1678 --
1679 --    If system person type is anything other than 'EMP', 'EX_EMP', 'EMP_APL'
1680 --    or 'EX_EMP_APL' then
1681 --    If employee number is not null then
1682 --    an application error will be raised and processing is terminated
1683 --
1684 --    If the employee number is not unique within the business group then
1685 --    an application error will be raised and processing is terminated
1686 --
1687 --  Access Status:
1688 --    Internal Table Handler Use Only.
1689 --
1690 procedure chk_employee_number
1691   (p_person_id                in     per_all_people_f.person_id%TYPE
1692   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
1693   ,p_person_type_id           in     per_all_people_f.person_type_id%TYPE
1694   ,p_employee_number          in out nocopy per_all_people_f.employee_number%TYPE
1695   ,p_national_identifier      in     per_all_people_f.national_identifier%TYPE
1696   ,p_effective_date           in     date
1697   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE)
1698 is
1699 begin
1700     chk_employee_number
1701   (p_person_id              => p_person_id
1702   ,p_business_group_id      => p_business_group_id
1703   ,p_person_type_id         => p_person_type_id
1704   ,p_employee_number        => p_employee_number
1705   ,p_national_identifier    => p_national_identifier
1706   ,p_effective_date         => p_effective_date
1707   ,p_object_version_number  => p_object_version_number
1708   ,p_party_id               => null
1709   ,p_date_of_birth          => null
1710   ,p_start_date             => null
1711   );
1712 end chk_employee_number;
1713 --
1714 -- Overloaded
1715 --
1716 procedure chk_employee_number
1717   (p_person_id                in     per_all_people_f.person_id%TYPE
1718   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
1719   ,p_person_type_id           in     per_all_people_f.person_type_id%TYPE
1720   ,p_employee_number          in out nocopy per_all_people_f.employee_number%TYPE
1721   ,p_national_identifier      in     per_all_people_f.national_identifier%TYPE
1722   ,p_effective_date           in     date
1723   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
1724   ,p_party_id                 in     per_all_people_f.party_id%TYPE
1725   ,p_date_of_birth            in     per_all_people_f.date_of_birth%TYPE
1726   ,p_start_date               in     per_periods_of_service.date_start%TYPE)
1727 is
1728 --
1729   l_exists           varchar2(1);
1730   l_proc             varchar2(72)  :=  g_package||'chk_employee_number';
1731   l_api_updating     boolean;
1732   l_applicant_number per_all_people_f.applicant_number%TYPE;
1733   l_npw_number       per_all_people_f.npw_number%TYPE;
1734   l_gen_method       varchar2(1);
1735   l_emp_ni           boolean       := false;
1736 --
1737   cursor csr_gen_method is
1738     select pbg.method_of_generation_emp_num
1739     from per_business_groups pbg
1740     where pbg.business_group_id = p_business_group_id;
1741 --
1742 -- Declare the function emp_sys_per_type_change
1743 --
1744   function emp_sys_per_type_change
1745                (p_new_person_type_id      numeric
1746                ,p_old_person_type_id      numeric
1747                ,p_business_group_id       numeric)
1748   return boolean is
1749   --
1750   l_new_system_person_type   per_person_types.system_person_type%TYPE;
1751   l_old_system_person_type   per_person_types.system_person_type%TYPE;
1752   l_return_status            boolean;
1753   l_proc                     varchar2(25) := 'emp_sys_per_type_change';
1754   --
1755   -- Cursor to get the system_person_type for the 'old' person_type_id
1756   --
1757   cursor get_old_sys_per_type is
1758          select system_person_type
1759          from   per_person_types
1760          where  person_type_id    = p_old_person_type_id
1761          and    business_group_id = p_business_group_id;
1762   --
1763   begin
1764     --
1765  if g_debug then
1766     hr_utility.set_location('Entering '||l_proc,10);
1767  end if;
1768     --
1769     -- Assume we have not changed the system_person_type, so set return
1770     -- variable to FALSE.
1771     --
1772     l_return_status := false;
1773     --
1774     -- Check the person_type_id has actually changed
1775     --
1776     if p_new_person_type_id <> p_old_person_type_id then
1777       --
1778  if g_debug then
1779       hr_utility.set_location(l_proc, 20);
1780  end if;
1781       --
1782       -- Get the system_person_type for the 'new' person_type_id
1783       --
1784       l_new_system_person_type := return_system_person_type
1785                                  (p_person_type_Id    =>p_new_person_type_id
1786                                  ,p_business_group_id =>p_business_group_id
1787                                  );
1788  if g_debug then
1789       hr_utility.set_location(l_proc, 30);
1790  end if;
1791       --
1792       -- Get the system_person_type for the 'old' person_type_id
1793       --
1794       open get_old_sys_per_type;
1795       fetch get_old_sys_per_type into l_old_system_person_type;
1796       close get_old_sys_per_type;
1797       --
1798       -- If the system_person_type's have changed then check the transition
1799       -- to see if the employee number needs to be validated/generated
1800       --
1801       if ((l_old_system_person_type = 'OTHER' and
1802            l_new_system_person_type = 'EMP')
1803           or
1804           (l_old_system_person_type = 'APL' and
1805            l_new_system_person_type in ('EMP','EMP_APL'))
1806           or
1807           (l_old_system_person_type = 'APL_EX_APL' and
1808            l_new_system_person_type = 'EMP')
1809           or
1810           (l_old_system_person_type = 'EX_APL' and         -- 4100548
1811            l_new_system_person_type = 'EMP')
1812            ) then
1813         --
1814  if g_debug then
1815         hr_utility.set_location(l_proc, 40);
1816  end if;
1817         --
1818         l_return_status := true;
1819       end if;
1820  if g_debug then
1821       hr_utility.set_location(l_proc, 50);
1822  end if;
1823     end if;
1824  if g_debug then
1825     hr_utility.set_location(' Leaving '||l_proc, 60);
1826  end if;
1827     return l_return_status;
1828   end emp_sys_per_type_change;
1829 --
1830 -- Declare the function emp_ni_change
1831 --
1832   function emp_ni_change
1833                (p_new_ni            varchar2
1834                ,p_old_ni            varchar2
1835                ,p_gen_method        varchar2)
1836   return boolean is
1837   --
1838   l_return_status boolean := FALSE;
1839   l_proc          varchar2(30) := 'emp_ni_change';
1840   --
1841   begin
1842  if g_debug then
1843     hr_utility.set_location('Entering '||l_proc,10);
1844  end if;
1845     --
1846     if p_gen_method  = 'N' and
1847        p_new_ni     <> p_old_ni then
1848  if g_debug then
1849       hr_utility.set_location(l_proc,20);
1850  end if;
1851       l_return_status := TRUE;
1852     end if;
1853  if g_debug then
1854     hr_utility.set_location(' Leaving '||l_proc,30);
1855  end if;
1856     return l_return_status;
1857   end emp_ni_change;
1858 --
1859 begin
1860  if g_debug then
1861   hr_utility.set_location('Entering:'|| l_proc, 10);
1862  end if;
1863   if hr_multi_message.no_exclusive_error
1864         (p_check_column1      => 'PER_ALL_PEOPLE_F.NATIONAL_IDENTIFIER'
1865         )
1866   then
1867     --
1868     -- Check mandatory parameters have been set
1869     --
1870     hr_api.mandatory_arg_error
1871       (p_api_name       => l_proc
1872       ,p_argument       => 'business group id'
1873       ,p_argument_value => p_business_group_id
1874       );
1875     --
1876     hr_api.mandatory_arg_error
1877       (p_api_name       => l_proc
1878       ,p_argument       => 'person type id'
1879       ,p_argument_value => p_person_type_id
1880       );
1881     --
1882     hr_api.mandatory_arg_error
1883       (p_api_name       => l_proc
1884       ,p_argument       => 'effective date'
1885       ,p_argument_value => p_effective_date
1886       );
1887     --
1888     --  Only proceed with validation if:
1889     --  a) The current g_old_rec is current and
1890     --  b) The employee number value has changed
1891     --  c) The system_person_type has changed in such a way that emp number is
1892     --     now required.
1893     --  d) The NI has changed and the generation method for emp num is 'N'
1894     --  e) a record is being inserted
1895     --
1896     l_api_updating := per_per_shd.api_updating
1897       (p_person_id             => p_person_id
1898       ,p_effective_date        => p_effective_date
1899       ,p_object_version_number => p_object_version_number);
1900     --
1901     -- Get the generation method
1902     --
1903     open csr_gen_method;
1904     fetch csr_gen_method into l_gen_method;
1905     close csr_gen_method;
1906  if g_debug then
1907     hr_utility.set_location(l_proc, 20);
1908  end if;
1909     --
1910     -- Need to validate/generate the employee number if the employee number
1911     -- has changed or if the system person type has changed in such a way
1912     -- that an employee number is now required or if the NI number has changed
1913     -- and the generation method is 'N'.
1914     --
1915     if ((l_api_updating and (nvl(per_per_shd.g_old_rec.employee_number,
1916                               hr_api.g_varchar2) <>
1917                           nvl(p_employee_number, hr_api.g_varchar2)
1918                       or  emp_sys_per_type_change
1919                                    (p_person_type_id
1920                                    ,per_per_shd.g_old_rec.person_type_id
1921                                    ,p_business_group_id)
1922                       or  emp_ni_change
1923                                    (p_national_identifier
1924                                    ,per_per_shd.g_old_rec.national_identifier
1925                                    ,l_gen_method)))
1926       or
1927      (NOT l_api_updating)) then
1928       --
1929  if g_debug then
1930       hr_utility.set_location(l_proc, 30);
1931  end if;
1932       --
1933       -- If we are updating and the employee number has actually changed then
1934       -- ensure the number generation method is not automatic.
1935       --
1936       if l_api_updating  and
1937          nvl(per_per_shd.g_old_rec.employee_number, hr_api.g_varchar2) <>
1938                             nvl(p_employee_number, hr_api.g_varchar2) and
1939          l_gen_method = 'A'
1940            and (not g_global_transfer_in_process
1941                 OR
1942                    (g_global_transfer_in_process
1943                     and (PER_BG_NUMBERING_METHOD_PKG.Get_PersonNumber_Formula
1944                             ('EMP',p_effective_date) is not null))
1945                     and per_per_shd.g_old_rec.employee_number is not null)
1946       then
1947         hr_utility.set_message(801, 'HR_51239_PER_INV_EMP_UPD');
1948         hr_utility.raise_error;
1949       end if;
1950 if g_debug then
1951       hr_utility.set_location(l_proc, 50);
1952  end if;
1953       --
1954       --  Perform employee number validation as required by number generation
1955       --  method for the business group, and ensure that it is
1956       --  unique within the business group.
1957       --
1958       if return_system_person_type(p_person_type_id, p_business_group_id) in
1959         ('EMP','EX_EMP', 'EMP_APL','EX_EMP_APL') then
1960         --
1961 if g_debug then
1962         hr_utility.set_location(l_proc, 60);
1963  end if;
1964         --
1965         -- If generation method is 'A' ensure employee number IN is set null
1966         --
1967         if l_gen_method = 'A' and
1968            p_employee_number is not null
1969            and (not g_global_transfer_in_process
1970                 OR
1971                    (g_global_transfer_in_process
1972                     and (PER_BG_NUMBERING_METHOD_PKG.Get_PersonNumber_Formula
1973                             ('EMP',p_effective_date) is not null)))
1974         then
1975           --
1976           hr_utility.set_message(801,'HR_51240_PER_EMP_NUM_NOT_NULL');
1977           hr_utility.raise_error;
1978         end if;
1979 if g_debug then
1980         hr_utility.set_location(l_proc, 70);
1981  end if;
1982         --
1983         -- If generation method is 'N' ensure employee number IN is set null
1984         -- on insert.
1985         --
1986         if l_gen_method = 'N' and
1987            NOT l_api_updating and
1988            p_employee_number <> p_national_identifier then
1989           --
1990           hr_utility.set_message(801,'HR_51241_PER_EMP_NUM_NOT_NULL');
1991           l_emp_ni := true;
1992           hr_utility.raise_error;
1993         end if;
1994 if g_debug then
1995         hr_utility.set_location(l_proc, 80);
1996  end if;
1997         --
1998         -- If generation method is 'N' ensure national identifier IN is not null
1999         --
2000         if l_gen_method = 'N' and
2001            p_national_identifier is null then
2002           --
2003           hr_utility.set_message(801,'HR_51242_PER_NAT_ID_NULL');
2004           l_emp_ni := true;
2005           hr_utility.raise_error;
2006         end if;
2007 if g_debug then
2008         hr_utility.set_location(l_proc, 90);
2009  end if;
2010         --
2011         -- Call number generation routine.
2012         --
2013         if l_gen_method = 'A'
2014            and nvl(fnd_profile.value('PER_GLOBAL_EMP_NUM'),'N') = 'Y'
2015            and ( PER_BG_NUMBERING_METHOD_PKG.Get_PersonNumber_Formula
2016                       ('EMP',p_effective_date)) is null
2017            and p_employee_number is not null
2018            and g_global_transfer_in_process then
2019            --
2020            -- For global transfers we allow passing employee number if numbering
2021            -- is by global sequence ONLY
2022            -- The expectation is that the number will be same as original BG record
2023            -- If it is not set then we assume normal rules should apply
2024            --
2025            null;
2026            --
2027         else
2028           hr_person.generate_number(p_current_employee    => 'Y'
2029                                    ,p_current_applicant   => 'N'
2030                                    ,p_current_npw         => 'N'
2031                                    ,p_national_identifier => p_national_identifier
2032                                    ,p_business_group_id   => p_business_group_id
2033                                    ,p_person_id           => p_person_id
2034                                    ,p_employee_number     => p_employee_number
2035                                    ,p_applicant_number    => l_applicant_number
2036                                    ,p_npw_number          => l_npw_number
2037                                    ,p_effective_date      => p_effective_date
2038                                    ,p_party_id            => p_party_id
2039                                    ,p_date_of_birth       => p_date_of_birth
2040                                    ,p_start_date          => p_effective_date);
2041         end if;
2042         --
2043 if g_debug then
2044         hr_utility.set_location(l_proc, 100);
2045  end if;
2046         --
2047         --  Check uniqueness of generated number if not generated automatically
2048         --
2049         if l_gen_method <> 'A' then
2050           --
2051 if g_debug then
2052           hr_utility.set_location(l_proc, 104);
2053  end if;
2054           --
2055           hr_person.validate_unique_number
2056                                  (p_person_id         => p_person_id
2057                                  ,p_business_group_id => p_business_group_id
2058                                  ,p_employee_number   => p_employee_number
2059                                  ,p_applicant_number  => null
2060                                  ,p_npw_number        => null
2061                                  ,p_current_employee  => 'Y'
2062                                  ,p_current_applicant => 'N'
2063                                  ,p_current_npw       => 'N');
2064           --
2065 if g_debug then
2066           hr_utility.set_location(l_proc, 108);
2067  end if;
2068           --
2069         end if;
2070         --
2071 if g_debug then
2072         hr_utility.set_location(l_proc, 110);
2073  end if;
2074         --
2075       else
2076         --
2077         --  System person type is not 'EMP','EX_EMP','EMP_APL' or 'EX_EMP_APL'
2078         --  so employee number must be null
2079         --
2080 if g_debug then
2081         hr_utility.set_location(l_proc, 120);
2082  end if;
2083         --
2084         if p_employee_number is not null then
2085           --  Error: You cannot enter an employee number for this person type
2086           hr_utility.set_message(801, 'HR_7523_PER_EMP_NO_NOT_NULL');
2087           hr_utility.raise_error;
2088         end if;
2089         --
2090 if g_debug then
2091         hr_utility.set_location(l_proc, 130);
2092  end if;
2093         --
2094       end if;
2095     end if;
2096   end if;
2097 if g_debug then
2098   hr_utility.set_location(' Leaving:'|| l_proc, 140);
2099  end if;
2100     exception
2101       when app_exception.application_exception then
2102     -- if error is not because of national identifier
2103       if not l_emp_ni
2104       then
2105         if hr_multi_message.exception_add
2106         (p_associated_column1      => 'PER_ALL_PEOPLE_F.EMPLOYEE_NUMBER'
2107         ) then
2108 if g_debug then
2109           hr_utility.set_location(' Leaving:'||l_proc, 150);
2110  end if;
2111           raise;
2112         end if;
2113       else
2114        if hr_multi_message.exception_add
2115            (p_associated_column1 => 'PER_ALL_PEOPLE_F.EMPLOYEE_NUMBER'
2116            ,p_associated_column2 => 'PER_ALL_PEOPLE_F.NATIONAL_IDENTIFIER'
2117            ) then
2118 if g_debug then
2119              hr_utility.set_location(' Leaving:'||l_proc, 160);
2120  end if;
2121              raise;
2122         end if;
2123       end if;
2124 if g_debug then
2125   hr_utility.set_location(' Leaving:'||l_proc,170);
2126  end if;
2127 end chk_employee_number;
2128 --
2129 --  ---------------------------------------------------------------------------
2130 --  |-----------------------<  chk_npw_number  >------------------------------|
2131 --  ---------------------------------------------------------------------------
2132 --
2133 --  Description:
2134 --    Checks that cwk number value is valid
2135 --
2136 --  Pre-conditions:
2137 --    p_person_type_id must be valid
2138 --    p_business_group_id must be valid for p_person_id
2139 --    p_national_identifier must be valid
2140 --
2141 --  In Arguments:
2142 --    p_person_id
2143 --    p_business_group_id
2144 --    p_current_npw_flag
2145 --    p_npw_number
2146 --    p_national_identifier
2147 --    p_effective_date
2148 --    p_object_version_number
2149 --
2150 --  Post Success:
2151 --    If current_npw_flag = Y or there exists a previous CWK record on PTU,
2152 --    npw number is defined based on cwk number generation method as
2153 --    follows :
2154 --
2155 --        If npw number is not null and cwk number generation method
2156 --        is 'Manual' then processing continues.
2157 --        If npw number is null and cwk number generation method is
2158 --        'Automatic' then npw number is generated and processing
2159 --        continues.
2160 --        If npw number is null and national identifier is not null and
2161 --        the cwk number generation method is 'National identifier' then
2162 --        npw number is set to national identifier and processing
2163 --        continues.
2164 --
2165 --    If the npw number is unique within the business group then
2166 --    processing continues
2167 --
2168 --  Post Failure:
2169 --    If current_npw_flag = 'Y' or there exists a previous CWK record on PTU
2170 --    If npw number is null then
2171 --    an application error will be raised and processing is terminated
2172 --
2173 --    If current_npw_flag = N or (is null and no previous CWK record exists on PTU)
2174 --    If npw number is not null then
2175 --    an application error will be raised and processing is terminated
2176 --
2177 --    If the npw number is not unique within the business group then
2178 --    an application error will be raised and processing is terminated
2179 --
2180 --  Access Status:
2181 --    Internal Development Use Only.
2182 --
2183 procedure chk_npw_number
2184   (p_person_id                in     per_all_people_f.person_id%TYPE
2185   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
2186   ,p_current_npw_flag         in     per_all_people_f.current_npw_flag%TYPE
2187   ,p_npw_number               in out nocopy per_all_people_f.npw_number%TYPE
2188   ,p_national_identifier      in     per_all_people_f.national_identifier%TYPE
2189   ,p_effective_date           in     date
2190   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
2191 )
2192 is
2193 begin
2194   chk_npw_number
2195   (p_person_id              => p_person_id
2196   ,p_business_group_id      => p_business_group_id
2197   ,p_current_npw_flag       => p_current_npw_flag
2198   ,p_npw_number             => p_npw_number
2199   ,p_national_identifier    => p_national_identifier
2200   ,p_effective_date         => p_effective_date
2201   ,p_object_version_number  => p_object_version_number
2202   ,p_party_id               => null
2203   ,p_date_of_birth          => null
2204   ,p_start_date             => null
2205   );
2206 end chk_npw_number;
2207 --
2208 procedure chk_npw_number
2209   (p_person_id                in     per_all_people_f.person_id%TYPE
2210   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
2211   ,p_current_npw_flag         in     per_all_people_f.current_npw_flag%TYPE
2212   ,p_npw_number               in out nocopy per_all_people_f.npw_number%TYPE
2213   ,p_national_identifier      in     per_all_people_f.national_identifier%TYPE
2214   ,p_effective_date           in     date
2215   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
2216   ,p_party_id                 in     per_all_people_f.party_id%TYPE
2217   ,p_date_of_birth            in     per_all_people_f.date_of_birth%TYPE
2218   ,p_start_date               in     date
2219 )
2220 is
2221 --
2222   l_proc             varchar2(72)  :=  g_package||'chk_npw_number';
2223   l_exists           varchar2(1);
2224   l_api_updating     boolean;
2225   l_applicant_number per_all_people_f.applicant_number%TYPE;
2226   l_employee_number  per_all_people_f.employee_number%TYPE;
2227   l_gen_method       varchar2(1);
2228   l_npw_ni           boolean       := false;
2229 --
2230   cursor csr_gen_method is
2231     select pbg.method_of_generation_cwk_num
2232     from per_business_groups pbg
2233     where pbg.business_group_id = p_business_group_id;
2234 --
2235 -- Declare the function emp_ni_change
2236 --
2237   function npw_ni_change
2238                (p_new_ni            varchar2
2239                ,p_old_ni            varchar2
2240                ,p_gen_method        varchar2)
2241   return boolean is
2242   --
2243   l_return_status boolean := FALSE;
2244   l_proc          varchar2(30) := 'npw_ni_change';
2245   --
2246   begin
2247 if g_debug then
2248     hr_utility.set_location('Entering '||l_proc,10);
2249  end if;
2250     --
2251     if p_gen_method  = 'N' and
2252        p_new_ni     <> p_old_ni then
2253 if g_debug then
2254       hr_utility.set_location(l_proc,20);
2255  end if;
2256       l_return_status := TRUE;
2257     end if;
2258 if g_debug then
2259     hr_utility.set_location(' Leaving '||l_proc,30);
2260  end if;
2261     return l_return_status;
2262   end npw_ni_change;
2263 --
2264 begin
2265 if g_debug then
2266   hr_utility.set_location('Entering:'|| l_proc, 10);
2267  end if;
2268   if hr_multi_message.no_exclusive_error
2269         (p_check_column1      => 'PER_ALL_PEOPLE_F.NATIONAL_IDENTIFIER'
2270         )
2271   then
2272     --
2273     -- Check mandatory parameters have been set
2274     --
2275     hr_api.mandatory_arg_error
2276       (p_api_name       => l_proc
2277       ,p_argument       => 'business group id'
2278       ,p_argument_value => p_business_group_id
2279       );
2280     --
2281     hr_api.mandatory_arg_error
2282       (p_api_name       => l_proc
2283       ,p_argument       => 'effective date'
2284       ,p_argument_value => p_effective_date
2285       );
2286     --
2287     --  Only proceed with validation if:
2288     --  a) The current g_old_rec is current and
2289     --  b) The npw number value has changed
2290     --  c) The current_npw_flag has changed in such a way that npw_number is
2291     --     now required.
2292     --  d) The NI has changed and the generation method for npw num is 'N'
2293     --  e) a record is being inserted
2294     --
2295     l_api_updating := per_per_shd.api_updating
2296       (p_person_id             => p_person_id
2297       ,p_effective_date        => p_effective_date
2298       ,p_object_version_number => p_object_version_number);
2299     --
2300     -- Get the generation method
2301     --
2302     open csr_gen_method;
2303     fetch csr_gen_method into l_gen_method;
2304     close csr_gen_method;
2305 if g_debug then
2306     hr_utility.set_location(l_proc, 20);
2307  end if;
2308     --
2309     --
2310     -- Need to validate/generate the npw number if the npw number
2311     -- has changed or if the current_npw_flag has changed in such a way
2312     -- that an npw number is now required or if the NI number has changed
2313     -- and the generation method is 'N'.
2314     --
2315     if ((l_api_updating and (nvl(per_per_shd.g_old_rec.npw_number,
2316                               hr_api.g_varchar2) <>
2317                           nvl(p_npw_number, hr_api.g_varchar2)
2318                       or (p_current_npw_flag = 'Y'
2319                           and per_per_shd.g_old_rec.current_npw_flag is null)
2320                       or  npw_ni_change
2321                                    (p_national_identifier
2322                                    ,per_per_shd.g_old_rec.national_identifier
2323                                    ,l_gen_method)))
2324       or
2325      (NOT l_api_updating)) then
2326       --
2327 if g_debug then
2328       hr_utility.set_location(l_proc, 30);
2329  end if;
2330       --
2331       -- If we are updating and the npw number has actually changed then
2332       -- ensure the number generation method is not automatic.
2333       --
2334       if l_api_updating  and
2335          nvl(per_per_shd.g_old_rec.npw_number, hr_api.g_varchar2) <>
2336                             nvl(p_npw_number, hr_api.g_varchar2) and
2337          l_gen_method = 'A' then
2338 		 -- ER FPT
2339 		 if not ((nvl(fnd_profile.value('HR_ALLOW_FPT_UPDATES'),'N') = 'Y') and per_per_shd.g_old_rec.npw_number is null) then
2340           hr_utility.set_message(800, 'HR_289657_PER_INV_CWK_UPD');
2341           hr_utility.raise_error;
2342 		end if;
2343       end if;
2344 if g_debug then
2345       hr_utility.set_location(l_proc, 50);
2346  end if;
2347       --
2348       --  Perform npw number validation as required by number generation
2349       --  method for the business group, and ensure that it is
2350       --  unique within the business group.
2351       --
2352       if p_current_npw_flag = 'Y' then
2353         --
2354 if g_debug then
2355         hr_utility.set_location(l_proc, 60);
2356  end if;
2357         --
2358         -- If generation method is not specified then error: ct. may not have upgraded
2359         -- BG info
2360         if l_gen_method is null then
2361           --
2362           hr_utility.set_message(800,'PER_289634_CWK_GEN_NOT_NULL');
2363           hr_utility.raise_error;
2364         end if;
2365 if g_debug then
2366         hr_utility.set_location(l_proc, 60);
2367  end if;
2368         --
2369         -- If generation method is 'A' ensure npw number IN is set null
2370         -- or has not changed from its previous value (fixes 2876274)
2371         --
2372         if l_gen_method = 'A' and
2373            p_npw_number is not null and
2374 
2375            p_npw_number <> nvl(per_per_shd.g_old_rec.npw_number,hr_api.g_varchar2) then
2376           -- ER FPT
2377 		  if not ((nvl(fnd_profile.value('HR_ALLOW_FPT_UPDATES'),'N') = 'Y') and per_per_shd.g_old_rec.npw_number is null) then
2378             hr_utility.set_message(800,'PER_289635_CWK_NUM_NOT_NULL');
2379             hr_utility.raise_error;
2380 		  end if;
2381         end if;
2382 if g_debug then
2383         hr_utility.set_location(l_proc, 70);
2384  end if;
2385         --
2386         -- If generation method is 'N' ensure npw number IN is set null
2387         -- on insert.
2388         --
2389         if l_gen_method = 'N' and
2390            NOT l_api_updating and
2391            p_npw_number <> p_national_identifier then
2392           --
2393           hr_utility.set_message(800,'PER_289636_CWK_NUM_NOT_NULL');
2394           l_npw_ni := true;
2395           hr_utility.raise_error;
2396         end if;
2397 if g_debug then
2398         hr_utility.set_location(l_proc, 80);
2399  end if;
2400         --
2401         -- If generation method is 'N' ensure national identifier IN is not null
2402         --
2403         if l_gen_method = 'N' and
2404            p_national_identifier is null then
2405           --
2406           hr_utility.set_message(800,'PER_289637_CWK_NAT_ID_NULL');
2407           l_npw_ni := true;
2408           hr_utility.raise_error;
2409         end if;
2410 if g_debug then
2411         hr_utility.set_location(l_proc, 90);
2412  end if;
2413         --
2414         -- Call number generation routine.
2415         --
2416         hr_person.generate_number(p_current_employee    => 'N'
2417                                  ,p_current_applicant   => 'N'
2418                                  ,p_current_npw         => 'Y'
2419                                  ,p_national_identifier => p_national_identifier
2420                                  ,p_business_group_id   => p_business_group_id
2421                                  ,p_person_id           => p_person_id
2422                                  ,p_employee_number     => l_employee_number
2423                                  ,p_applicant_number    => l_applicant_number
2424                                  ,p_npw_number          => p_npw_number
2425                                  ,p_effective_date      => p_effective_date
2426                                  ,p_party_id            => p_party_id
2427                                  ,p_date_of_birth       => p_date_of_birth
2428                                  ,p_start_date          => p_effective_date);
2429 
2430         --
2431 if g_debug then
2432         hr_utility.set_location(l_proc, 100);
2433  end if;
2434         --
2435         --  Check uniqueness of generated number if not generated automatically
2436         --
2437         if l_gen_method <> 'A' then
2438           --
2439 if g_debug then
2440           hr_utility.set_location(l_proc, 104);
2441  end if;
2442           --
2443           hr_person.validate_unique_number
2444                                  (p_person_id         => p_person_id
2445                                  ,p_business_group_id => p_business_group_id
2446                                  ,p_employee_number   => null
2447                                  ,p_applicant_number  => null
2448                                  ,p_npw_number        => p_npw_number
2449                                  ,p_current_employee  => 'N'
2450                                  ,p_current_applicant => 'N'
2451                                  ,p_current_npw       => 'Y');
2452           --
2453 if g_debug then
2454           hr_utility.set_location(l_proc, 108);
2455  end if;
2456           --
2457         end if;
2458         --
2459 if g_debug then
2460         hr_utility.set_location(l_proc, 110);
2461  end if;
2462         --
2463       else
2464         --
2465         --  current_npw_flag is null, so npw number must be null
2466         --
2467 if g_debug then
2468         hr_utility.set_location(l_proc, 120);
2469  end if;
2470         --
2471         if p_npw_number is not null then
2472           --  Error: You cannot enter an npw number for this person type
2473           hr_utility.set_message(800, 'PER_289638_CWK_NUM_NOT_NULL');
2474           hr_utility.raise_error;
2475         end if;
2476         --
2477 if g_debug then
2478         hr_utility.set_location(l_proc, 130);
2479  end if;
2480         --
2481       end if;
2482     end if;
2483   end if;
2484 if g_debug then
2485   hr_utility.set_location(' Leaving:'|| l_proc, 140);
2486  end if;
2487     exception
2488       when app_exception.application_exception then
2489     -- if error is not because of national identifier
2490       if not l_npw_ni
2491       then
2492         if hr_multi_message.exception_add
2493         (p_associated_column1      => 'PER_ALL_PEOPLE_F.NPW_NUMBER'
2494         ) then
2495 if g_debug then
2496           hr_utility.set_location(' Leaving:'||l_proc, 150);
2497  end if;
2498           raise;
2499         end if;
2500       else
2501        if hr_multi_message.exception_add
2502            (p_associated_column1 => 'PER_ALL_PEOPLE_F.NPW_NUMBER'
2503            ,p_associated_column2 => 'PER_ALL_PEOPLE_F.NATIONAL_IDENTIFIER'
2504            ) then
2505 if g_debug then
2506              hr_utility.set_location(' Leaving:'||l_proc, 160);
2507  end if;
2508              raise;
2509         end if;
2510       end if;
2511 if g_debug then
2512   hr_utility.set_location(' Leaving:'||l_proc,170);
2513  end if;
2514 end chk_npw_number;
2515 --
2516 --  ---------------------------------------------------------------------------
2517 --  |-------------------< chk_expense_check_send_to_addr  >-------------------|
2518 --  ---------------------------------------------------------------------------
2519 --
2520 --  Description:
2521 --    - Validates that the expense check send to address exists as a lookup
2522 --      code on HR_LOOKUPS for the lookup type 'HOME_OFFICE' with an enabled
2523 --      flag set to 'Y' and the effective start date of the person between
2524 --      start date active and end date active on HR_LOOKUPS.
2525 --
2526 --  Pre-conditions:
2527 --    None
2528 --
2529 --  In Arguments:
2530 --    p_person_id
2531 --    p_expense_check_send_to_addres
2532 --    p_validation_start_date
2533 --    p_validation_end_date
2534 --    p_object_version_number
2535 --
2536 --  Post Success:
2537 --    Processing continues if:
2538 --      - expense check send to address exists as a lookup code in HR_LOOKUPS
2539 --        for the lookup type 'HOME_OFFICE' where the enabled flag is 'Y' and
2540 --        the effective start date of the person is between start date active
2541 --        and end date active on HR_LOOKUPS.
2542 --
2543 --  Post Failure:
2544 --    An application error is raised and processing is terminated if:
2545 --      - expense check send to address does'nt exist as a lookup code in
2546 --        HR_LOOKUPS for the lookup type 'HOME_OFFICE' where the enabled
2547 --        flag is 'Y' and the effective start date of the person
2548 --        is between start date active and end date active on HR_LOOKUPS.
2549 --
2550 --  Access Status:
2551 --    Internal Table Handler Use Only.
2552 --
2553 procedure chk_expense_check_send_to_addr
2554   (p_person_id                in     per_all_people_f.person_id%TYPE
2555   ,p_expense_check_send_to_addres in     per_all_people_f.expense_check_send_to_address%TYPE
2556   ,p_effective_date           in     date
2557   ,p_validation_start_date    in     date
2558   ,p_validation_end_date      in     date
2559   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
2560   )
2561 is
2562   --
2563   l_exists         varchar2(1);
2564   l_proc           varchar2(72)  :=  g_package||'chk_expense_check_send_to_addr';
2565   l_api_updating   boolean;
2566   --
2567 begin
2568 if g_debug then
2569   hr_utility.set_location('Entering:'|| l_proc, 10);
2570  end if;
2571   --
2572   -- Check mandatory parameters have been set
2573   --
2574   hr_api.mandatory_arg_error
2575     (p_api_name       => l_proc
2576     ,p_argument       => 'effective date'
2577     ,p_argument_value => p_effective_date
2578     );
2579   --
2580   hr_api.mandatory_arg_error
2581     (p_api_name       =>  l_proc
2582     ,p_argument       =>  'validation_start_date'
2583     ,p_argument_value =>  p_validation_start_date
2584     );
2585   --
2586   hr_api.mandatory_arg_error
2587     (p_api_name        =>  l_proc
2588     ,p_argument       =>  'validation_end_date'
2589     ,p_argument_value =>  p_validation_end_date
2590     );
2591 if g_debug then
2592   hr_utility.set_location(l_proc, 20);
2593  end if;
2594   --
2595   --  Only proceed with validation if:
2596   --  a) The current g_old_rec is current and
2597   --  b) The expense check send to address value has changed
2598   --  c) a record is being inserted
2599   --
2600   l_api_updating := per_per_shd.api_updating
2601     (p_person_id             => p_person_id
2602     ,p_effective_date        => p_effective_date
2603     ,p_object_version_number => p_object_version_number
2604     );
2605 if g_debug then
2606   hr_utility.set_location(l_proc, 30);
2607  end if;
2608   --
2609   if ((l_api_updating
2610       and nvl(per_per_shd.g_old_rec.expense_check_send_to_address,
2611           hr_api.g_varchar2)
2612       <> nvl(p_expense_check_send_to_addres,hr_api.g_varchar2))
2613     or
2614       (NOT l_api_updating))
2615   then
2616 if g_debug then
2617     hr_utility.set_location(l_proc, 40);
2618  end if;
2619     --
2620     -- Check if expense check send to address is set
2621     --
2622     If p_expense_check_send_to_addres is not null then
2623       --
2624       -- Check that the expense check send to address exists in hr_lookups for the
2625       -- lookup type 'HOME_OFFICE' with an enabled flag set to 'Y' and that
2626       -- the effective start date of the person is between start date
2627       -- active and end date active in hr_lookups.
2628       --
2629       if hr_api.not_exists_in_dt_hr_lookups
2630         (p_effective_date        => p_effective_date
2631         ,p_validation_start_date => p_validation_start_date
2632         ,p_validation_end_date   => p_validation_end_date
2633         ,p_lookup_type           => 'HOME_OFFICE'
2634         ,p_lookup_code           => p_expense_check_send_to_addres
2635         )
2636       then
2637         --
2638         hr_utility.set_message(801, 'HR_51251_PER_CHECK_SEND_ADR');
2639         hr_utility.raise_error;
2640         --
2641       end if;
2642 if g_debug then
2643       hr_utility.set_location(l_proc, 50);
2644  end if;
2645       --
2646     end if;
2647 if g_debug then
2648     hr_utility.set_location(l_proc, 60);
2649  end if;
2650     --
2651   end if;
2652 if g_debug then
2653   hr_utility.set_location(' Leaving:'|| l_proc, 70);
2654  end if;
2655   exception
2656     when app_exception.application_exception then
2657       if hr_multi_message.exception_add
2658       (p_associated_column1      => 'PER_ALL_PEOPLE_F.EXPENSE_CHECK_SEND_TO_ADDRESS'
2659       ) then
2660 if g_debug then
2661         hr_utility.set_location(' Leaving:'||l_proc, 80);
2662  end if;
2663         raise;
2664       end if;
2665 if g_debug then
2666     hr_utility.set_location(' Leaving:'||l_proc,90);
2667  end if;
2668 
2669 end chk_expense_check_send_to_addr;
2670 --
2671 --  ---------------------------------------------------------------------------
2672 --  |-----------------------<  chk_sex_title  >-------------------------------|
2673 --  ---------------------------------------------------------------------------
2674 --
2675 --  Description:
2676 --    - Validates that the sex exists as a lookup code on
2677 --      HR_LOOKUPS for the lookup type 'SEX' with an enabled
2678 --      flag set to 'Y' and the effective start date of the person between
2679 --      start date active and end date active on HR_LOOKUPS.
2680 --    - Validates that the title exists as a lookup code on
2681 --      HR_LOOKUPS for the lookup type 'TITLE' with an enabled
2682 --      flag set to 'Y' and the effective start date of the person between
2683 --      start date active and end date active on HR_LOOKUPS.
2684 --
2685 --  Pre-conditions:
2686 --    A valid person type
2687 --
2688 --  In Arguments:
2689 --    p_person_id
2690 --    p_business_group_id
2691 --    p_person_type_id
2692 --    p_title
2693 --    p_sex
2694 --    p_effective_date
2695 --    p_validation_start_date
2696 --    p_validation_end_date
2697 --    p_object_version_number
2698 --
2699 --  Post Success:
2700 --    Processing continues if:
2701 --      - a sex exists as a lookup code in HR_LOOKUPS for the lookup type
2702 --        'SEX' where the enabled flag is 'Y' and the effective start
2703 --        date of the person is between start date active and end date
2704 --        active on HR_LOOKUPS.
2705 --      - a title exists as a lookup code in HR_LOOKUPS for the lookup type
2706 --        'TITLE' where the enabled flag is 'Y' and the effective start
2707 --        date of the person is between start date active and end date
2708 --        active on HR_LOOKUPS.
2709 --      - a sex value is 'M' and the title value is not 'MISS','MRS.',
2710 --        'MS.'
2711 --      - a sex value is 'F' and the title value is 'MR'.
2712 --      - the related system person type is 'EMP' and a sex value is
2713 --        set.
2714 --
2715 --  Post Failure:
2716 --    An application error is raised and processing is terminated if:
2717 --      - a sex does'nt exist as a lookup code in HR_LOOKUPS for the lookup
2718 --        type 'SEX' where the enabled flag is 'Y' and the effective start
2719 --        date of the person is between start date active and end date
2720 --        active on HR_LOOKUPS.
2721 --      - a title does'nt exist as a lookup code in HR_LOOKUPS for the lookup
2722 --        type 'TITLE' where the enabled flag is 'Y' and the effective start
2723 --        date of the person is between start date active and end date
2724 --        active on HR_LOOKUPS.
2725 --      - a sex value is 'M' and the title value is 'MISS','MRS.', 'MS.'
2726 --      - a sex value is 'F' and the title value is 'MR.'
2727 --      - the related system person type is 'EMP' and a sex value is not
2728 --        set.
2729 --
2730 --  Access Status:
2731 --    Internal Table Handler Use Only.
2732 --
2733 procedure chk_sex_title
2734   (p_person_id                in     per_all_people_f.person_id%TYPE
2735   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
2736   ,p_person_type_id           in     per_all_people_f.person_type_id%TYPe
2737   ,p_title                    in     per_all_people_f.title%TYPE
2738   ,p_sex                      in     per_all_people_f.sex%TYPE
2739   ,p_effective_date           in     date
2740   ,p_validation_start_date    in     date
2741   ,p_validation_end_date      in     date
2742   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
2743   )
2744 is
2745   --
2746   l_exists         varchar2(1);
2747   l_proc           varchar2(72)  :=  g_package||'chk_sex_title';
2748   l_api_updating   boolean;
2749   l_lookup_type    varchar2(30);
2750   --
2751 begin
2752 if g_debug then
2753   hr_utility.set_location('Entering:'|| l_proc, 10);
2754  end if;
2755   --
2756   -- Check mandatory parameters have been set
2757   --
2758   hr_api.mandatory_arg_error
2759     (p_api_name       => l_proc
2760     ,p_argument       => 'effective date'
2761     ,p_argument_value => p_effective_date
2762     );
2763   --
2764   hr_api.mandatory_arg_error
2765     (p_api_name       =>  l_proc
2766     ,p_argument       =>  'validation_start_date'
2767     ,p_argument_value =>  p_validation_start_date
2768     );
2769   --
2770   hr_api.mandatory_arg_error
2771     (p_api_name        =>  l_proc
2772     ,p_argument       =>  'validation_end_date'
2773     ,p_argument_value =>  p_validation_end_date
2774     );
2775 if g_debug then
2776   hr_utility.set_location(l_proc, 20);
2777  end if;
2778   --
2779   --  Only proceed with validation if:
2780   --  a) The current g_old_rec is current and
2781   --  b) The sex value has changed
2782   --  c) The title value has changed
2783   --  d)A record is being inserted
2784   --
2785   l_api_updating := per_per_shd.api_updating
2786     (p_person_id             => p_person_id
2787     ,p_effective_date        => p_effective_date
2788     ,p_object_version_number => p_object_version_number
2789     );
2790 if g_debug then
2791   hr_utility.set_location(l_proc, 30);
2792  end if;
2793   --
2794   if ((l_api_updating
2795         and nvl(per_per_shd.g_old_rec.sex, hr_api.g_varchar2)
2796         <> nvl(p_sex,hr_api.g_varchar2))
2797       or
2798         (l_api_updating and nvl(per_per_shd.g_old_rec.title,hr_api.g_varchar2)
2799         <> nvl(p_title,hr_api.g_varchar2))
2800     or
2801       (NOT l_api_updating))
2802     then
2803 if g_debug then
2804     hr_utility.set_location(l_proc, 40);
2805  end if;
2806     --
2807     -- Check if title is set
2808     --
2809     If p_title is not null then
2810       --
2811       -- Check that the title exists in hr_lookups for the lookup type
2812       -- 'TITLE' with an enabled flag set to 'Y' and that the effective
2813       -- start date of the person is between start date active and end
2814       -- date active in hr_lookups.
2815       --
2816       if hr_api.not_exists_in_dt_hr_lookups
2817          (p_effective_date        => p_effective_date
2818          ,p_validation_start_date => p_validation_start_date
2819          ,p_validation_end_date   => p_validation_end_date
2820          ,p_lookup_type           => 'TITLE'
2821          ,p_lookup_code           => p_title
2822          )
2823       then
2824         --
2825         hr_utility.set_message(801, 'HR_7512_PER_TITLE_INVALID');
2826         hr_multi_message.add
2827    (p_associated_column1      => 'PER_ALL_PEOPLE_F.TITLE'
2828    );
2829       --
2830       end if;
2831 if g_debug then
2832       hr_utility.set_location(l_proc, 50);
2833  end if;
2834       --
2835     end if;
2836     --
2837     --  Check if sex is set
2838     --
2839     If p_sex is not null then
2840       --
2841       -- Check that the sex exists in hr_lookups for the lookup type
2842       -- 'SEX' with an enabled flag set to 'Y' and that the effective
2843       -- start date of the person is between start date active and end
2844       -- date active in hr_lookups.
2845       --
2846       if hr_api.not_exists_in_dt_hr_lookups
2847         (p_effective_date        => p_effective_date
2848         ,p_validation_start_date => p_validation_start_date
2849         ,p_validation_end_date   => p_validation_end_date
2850         ,p_lookup_type           => 'SEX'
2851         ,p_lookup_code           => p_sex
2852         )
2853       then
2854         --
2855         hr_utility.set_message(801, 'HR_7511_PER_SEX_INVALID');
2856         hr_multi_message.add
2857    (p_associated_column1      => 'PER_ALL_PEOPLE_F.SEX'
2858    );
2859         --
2860       end if;
2861 if g_debug then
2862       hr_utility.set_location(l_proc, 40);
2863  end if;
2864       --
2865       -- Check if title is set
2866       --
2867       If p_title is not null then
2868         --
2869         --  Check that title is consistent with sex
2870         --
2871         If p_sex = 'M' and
2872            p_title in ('MISS','MRS.','MS.') then
2873           --  Error: Values for Sex and Title are inconsistent.
2874           hr_utility.set_message(801, 'HR_6527_PERSON_SEX_AND_TITLE');
2875           hr_multi_message.add
2876      (p_associated_column1      => 'PER_ALL_PEOPLE_F.TITLE'
2877      ,p_associated_column2      => 'PER_ALL_PEOPLE_F.SEX'
2878      );
2879         end if;
2880 if g_debug then
2881         hr_utility.set_location(l_proc, 70);
2882  end if;
2883         --
2884         If p_sex = 'F' and
2885            p_title = 'MR.' then
2886           --  Error: Values for Sex and Title are inconsistent.
2887           hr_utility.set_message(801, 'HR_6527_PERSON_SEX_AND_TITLE');
2888           hr_multi_message.add
2889      (p_associated_column1      => 'PER_ALL_PEOPLE_F.TITLE'
2890      ,p_associated_column2      => 'PER_ALL_PEOPLE_F.SEX'
2891      );
2892         end if;
2893 if g_debug then
2894         hr_utility.set_location(l_proc, 80);
2895  end if;
2896         --
2897       end if;
2898     else
2899       --
2900       --  If sex is null check if system person type contains 'EMP'
2901       --
2902       if instr(return_system_person_type(p_person_type_id,
2903                                          p_business_group_id),'EMP') <> 0 then
2904         --  Error: You must enter sex for an employee.
2905         hr_utility.set_message(801, 'HR_6524_EMP_MANDATORY_SEX');
2906         hr_multi_message.add
2907    (p_associated_column1      => 'PER_ALL_PEOPLE_F.SEX'
2908    );
2909       end if;
2910 if g_debug then
2911       hr_utility.set_location(l_proc, 90);
2912  end if;
2913       --
2914     end if;
2915 if g_debug then
2916     hr_utility.set_location(' Leaving:'|| l_proc, 130);
2917  end if;
2918   end if;
2919 end chk_sex_title;
2920 --
2921 --  ---------------------------------------------------------------------------
2922 --  |-------------------------<  chk_town_of_birth >--------------------------|
2923 --  ---------------------------------------------------------------------------
2924 --
2925 --  Description:
2926 --    Checks that the town of birth parameter corresponds to a valid lookup value if
2927 --    there a row in pay_legislative_field_info for the current legislation code
2928 --    and the field_name of 'TOWN_OF_BIRTH'. (If no row exists in PLFI table then
2929 --    assume this field is free text and under the current legislation is not validated).
2930 --
2931 --  Pre-conditions:
2932 --
2933 --  In Arguments:
2934 --    p_person_id
2935 --    p_town_of_birth
2936 --    p_effective_date
2937 --    p_validation_start_date  in date
2938 --    p_validation_end_date    in date
2939 --    p_legislation_code
2940 --
2941 --  Post Success:
2942 --    On insert/update if a town of birth value exists then
2943 --    processing continues
2944 --
2945 --  Post Failure:
2946 --    On insert/update if a town of birth value does not exist
2947 --    then an application error will be raised and processing is
2948 --    terminated
2949 --
2950 --  Access Status:
2951 --    Internal Row Handler Use Only.
2952 --
2953 procedure chk_town_of_birth
2954   (p_person_id              in per_all_people_f.person_id%TYPE,
2955    p_town_of_birth          in per_all_people_f.town_of_birth%TYPE,
2956    p_effective_date         in date,
2957    p_validation_start_date  in date,
2958    p_validation_end_date    in date,
2959    p_legislation_code       in per_business_groups.legislation_code%TYPE) is
2960 --
2961 --
2962   CURSOR csr_plfi is
2963   SELECT rule_type
2964   FROM pay_legislative_field_info plfi
2965   WHERE upper(plfi.field_name) = 'TOWN_OF_BIRTH'
2966   AND plfi.legislation_code = p_legislation_code;
2967 --
2968   l_exists         varchar2(1);
2969   l_lookup_type    hr_lookups.lookup_type%TYPE;
2970   l_proc           varchar2(72);
2971   --
2972 begin
2973 if g_debug then
2974  l_proc  :=  g_package||'chk_town_of_birth';
2975   hr_utility.set_location('Entering:'|| l_proc, 1);
2976  end if;
2977   if p_town_of_birth IS NOT NULL then
2978   --
2979   --  Only proceed with validation if:
2980   --  a) rec is being inserted or
2981   --  b) rec is updating and the g_old_rec is not current value
2982   --
2983     if ((p_person_id is null)
2984      OR
2985        ((p_person_id is not null) and
2986       nvl(p_town_of_birth,hr_api.g_varchar2) <> nvl(per_per_shd.g_old_rec.town_of_birth,hr_api.g_varchar2))) then
2987       --
2988 if g_debug then
2989       hr_utility.set_location(l_proc, 2);
2990  end if;
2991       --
2992       open csr_plfi;
2993       fetch csr_plfi into l_lookup_type;
2994       if csr_plfi%found then
2995         close csr_plfi;
2996         -- attempt to decode the lookup type returned from plfi record
2997       -- with the p_town_of_birth lookup_value supplied to the api.
2998         if hr_api.not_exists_in_dt_hr_lookups
2999         (p_effective_date        => p_effective_date
3000         ,p_validation_start_date => p_validation_start_date
3001         ,p_validation_end_date   => p_validation_end_date
3002         ,p_lookup_type           => l_lookup_type
3003         ,p_lookup_code           => p_town_of_birth
3004         )
3005       then
3006           --  Error: Invalid town lookup_value has been passed.
3007         hr_utility.set_message_token('TOWN_CODE', p_town_of_birth);
3008           hr_utility.set_message(800, 'PER_52619_TOWN_NOT_FOUND)');
3009           hr_utility.raise_error;
3010       end if;
3011       else
3012         close csr_plfi;
3013     end if;
3014     end if;
3015   end if;
3016   --
3017 if g_debug then
3018   hr_utility.set_location(' Leaving:'|| l_proc, 3);
3019  end if;
3020   exception
3021     when app_exception.application_exception then
3022       if hr_multi_message.exception_add
3023       (p_associated_column1      => 'PER_ALL_PEOPLE_F.TOWN_OF_BIRTH'
3024       ) then
3025 if g_debug then
3026         hr_utility.set_location(' Leaving:'||l_proc, 4);
3027  end if;
3028         raise;
3029       end if;
3030 if g_debug then
3031   hr_utility.set_location(' Leaving:'||l_proc,5);
3032  end if;
3033 end chk_town_of_birth;
3034 --
3035 --  ---------------------------------------------------------------------------
3036 --  |-------------------------<  chk_region_of_birth >-------------------------|
3037 --  ---------------------------------------------------------------------------
3038 --
3039 --  Description:
3040 --    Checks that the region of birth parameter corresponds to a valid lookup value if
3041 --    there a row in pay_legislative_field_info for the current legislation code
3042 --    and the field_name of 'REGION_OF_BIRTH'. (If no row exists in PLFI table then
3043 --    assume this field is free text and under the current legislation is not validated).
3044 --
3045 --  Pre-conditions:
3046 --
3047 --  In Arguments:
3048 --    p_person_id
3049 --    p_region_of_birth
3050 --    p_effective_date
3051 --    p_validation_start_date
3052 --    p_validation_end_date
3053 --    p_legislation_code
3054 --
3055 --  Post Success:
3056 --    On insert/update if a region of birth value exists then
3057 --    processing continues
3058 --
3059 --  Post Failure:
3060 --    On insert/update if a region of birth value does not exist
3061 --    then an application error will be raised and processing is
3062 --    terminated
3063 --
3064 --  Access Status:
3065 --    Internal Row Handler Use Only.
3066 --
3067 procedure chk_region_of_birth
3068   (p_person_id              in per_all_people_f.person_id%TYPE,
3069    p_region_of_birth        in per_all_people_f.region_of_birth%TYPE,
3070    p_effective_date         in date,
3071    p_validation_start_date  in date,
3072    p_validation_end_date    in date,
3073    p_legislation_code       in per_business_groups.legislation_code%TYPE) is
3074 --
3075 --
3076   CURSOR csr_plfi is
3077   SELECT rule_type
3078   FROM pay_legislative_field_info plfi
3079   WHERE upper(plfi.field_name) = 'REGION_OF_BIRTH'
3080   AND plfi.legislation_code = p_legislation_code;
3081 --
3082   l_exists         varchar2(1);
3083   l_lookup_type    hr_lookups.lookup_type%TYPE;
3084   l_proc           varchar2(72);
3085   --
3086 begin
3087 if g_debug then
3088  l_proc :=  g_package||'chk_region_of_birth';
3089   hr_utility.set_location('Entering:'|| l_proc, 1);
3090  end if;
3091   if p_region_of_birth IS NOT NULL then
3092   --
3093   --  Only proceed with validation if:
3094   --  a) rec is being inserted or
3095   --  b) rec is updating and the g_old_rec is not current value
3096   --
3097     if ((p_person_id is null)
3098      OR
3099        ((p_person_id is not null) and
3100       nvl(p_region_of_birth,hr_api.g_varchar2) <> nvl(per_per_shd.g_old_rec.region_of_birth,hr_api.g_varchar2))) then
3101       --
3102 if g_debug then
3103       hr_utility.set_location(l_proc, 2);
3104  end if;
3105       --
3106       open csr_plfi;
3107       fetch csr_plfi into l_lookup_type;
3108       if csr_plfi%found then
3109         close csr_plfi;
3110         -- attempt to decode the lookup type returned from plfi record
3111       -- with the p_region_of_birth lookup_value supplied to the api.
3112         if hr_api.not_exists_in_dt_hr_lookups
3113         (p_effective_date        => p_effective_date
3114         ,p_validation_start_date => p_validation_start_date
3115         ,p_validation_end_date   => p_validation_end_date
3116         ,p_lookup_type           => l_lookup_type
3117         ,p_lookup_code           => p_region_of_birth
3118         )
3119       then
3120           --  Error: Invalid region lookup_value has been passed.
3121         hr_utility.set_message_token('REGION_CODE', p_region_of_birth);
3122           hr_utility.set_message(800, 'PER_52620_REGION_NOT_FOUND)');
3123           hr_utility.raise_error;
3124       end if;
3125       else
3126         close csr_plfi;
3127     end if;
3128     end if;
3129   end if;
3130   --
3131 if g_debug then
3132   hr_utility.set_location(' Leaving:'|| l_proc, 3);
3133  end if;
3134   exception
3135     when app_exception.application_exception then
3136       if hr_multi_message.exception_add
3137       (p_associated_column1      => 'PER_ALL_PEOPLE_F.REGION_OF_BIRTH'
3138       ) then
3139 if g_debug then
3140         hr_utility.set_location(' Leaving:'||l_proc, 4);
3141  end if;
3142         raise;
3143       end if;
3144 if g_debug then
3145   hr_utility.set_location(' Leaving:'||l_proc,5);
3146  end if;
3147 end chk_region_of_birth;
3148 --
3149 --  ---------------------------------------------------------------------------
3150 --  |----------------------<  chk_country_of_birth >--------------------------|
3151 --  ---------------------------------------------------------------------------
3152 --
3153 --  Description:
3154 --    Checks that a country of birth value (country short code) is valid
3155 --
3156 --  Pre-conditions:
3157 --
3158 --  In Arguments:
3159 --    p_person_id
3160 --    p_country_of_birth
3161 --
3162 --  Post Success:
3163 --    On insert/update if a country of birth value exists then
3164 --    processing continues
3165 --
3166 --  Post Failure:
3167 --    On insert/update if a country of birth value does not exist
3168 --    then an application error will be raised and processing is
3169 --    terminated
3170 --
3171 --  Access Status:
3172 --    Internal Row Handler Use Only.
3173 --
3174 procedure chk_country_of_birth
3175   (p_person_id                in per_all_people_f.person_id%TYPE,
3176    p_country_of_birth         in per_all_people_f.country_of_birth%TYPE) is
3177 --
3178   l_exists         varchar2(1);
3179   l_proc           varchar2(72);
3180 --
3181 -- cursor to attempt to match the country short code.
3182 --
3183   cursor csr_country is
3184   Select null
3185   from fnd_territories_vl ftv
3186   where ftv.territory_code = p_country_of_birth;
3187 --
3188 begin
3189 if g_debug then
3190  l_proc :=  g_package||'chk_country_of_birth';
3191   hr_utility.set_location('Entering:'|| l_proc, 1);
3192  end if;
3193   if p_country_of_birth IS NOT NULL then
3194   --
3195   --  Only proceed with validation if:
3196   --  a) rec is being inserted or
3197   --  b) rec is updating and the g_old_rec is not current value
3198   --
3199     if ((p_person_id is null)
3200      OR
3201        ((p_person_id is not null) and
3202       nvl(p_country_of_birth,hr_api.g_varchar2) <> nvl(per_per_shd.g_old_rec.country_of_birth,hr_api.g_varchar2))) then
3203       --
3204 if g_debug then
3205       hr_utility.set_location(l_proc, 2);
3206  end if;
3207       --
3208       open csr_country;
3209       fetch csr_country into l_exists;
3210       if csr_country%notfound then
3211         close csr_country;
3212         --  Error: Invalid country short code
3213       hr_utility.set_message_token('COUNTRY_CODE', p_country_of_birth);
3214         hr_utility.set_message(800, 'PER_52618_COUNTRY_NOT_FOUND');
3215         hr_utility.raise_error;
3216       end if;
3217       close csr_country;
3218     end if;
3219   end if;
3220   --
3221 if g_debug then
3222   hr_utility.set_location(' Leaving:'|| l_proc, 3);
3223  end if;
3224   exception
3225     when app_exception.application_exception then
3226       if hr_multi_message.exception_add
3227       (p_associated_column1      => 'PER_ALL_PEOPLE_F.COUNTRY_OF_BIRTH'
3228       ) then
3229 if g_debug then
3230         hr_utility.set_location(' Leaving:'||l_proc, 4);
3231  end if;
3232         raise;
3233       end if;
3234 if g_debug then
3235   hr_utility.set_location(' Leaving:'||l_proc,5);
3236  end if;
3237 end chk_country_of_birth;
3238 --
3239 --  ---------------------------------------------------------------------------
3240 --  |------------------------<  chk_start_date >------------------------------|
3241 --  ---------------------------------------------------------------------------
3242 --
3243 --  Description:
3244 --    Checks that a start date value is valid
3245 --
3246 --  Pre-conditions:
3247 --
3248 --  In Arguments:
3249 --    p_person_id
3250 --    p_start_date
3251 --    p_effective_date
3252 --    p_object_version_number
3253 --
3254 --  Post Success:
3255 --    On insert if a start date is the same as effective date then
3256 --    processing continues
3257 --
3258 --    On update if a start date is the same as the minimum effective start date
3259 --    then processing continues
3260 --
3261 --  Post Failure:
3262 --    On insert if a start date is not the same as the effective
3263 --    date then an application error will be raised and processing is
3264 --    terminated
3265 --
3266 --    On update if a start date is not the same as the minimum effective start
3267 --    date then an application error will be raised and processing is
3268 --    terminated
3269 --
3270 --  Access Status:
3271 --    Internal Table Handler Use Only.
3272 --
3273 procedure chk_start_date
3274   (p_person_id                in per_all_people_f.person_id%TYPE
3275   ,p_start_date               in date
3276   ,p_effective_date           in date
3277   ,p_object_version_number    in per_all_people_f.object_version_number%TYPE) is
3278 --
3279   l_exists         varchar2(1);
3280   l_proc           varchar2(72)  :=  g_package||'chk_start_date';
3281   l_api_updating   boolean;
3282   l_min_date       date;
3283 --
3284 -- Find the earliest effective start date for the person
3285 --
3286   cursor csr_chk_min_date is
3287   Select min(effective_start_date)
3288   from per_all_people_f
3289   where p_person_id = person_id;
3290 --
3291 begin
3292 if g_debug then
3293   hr_utility.set_location('Entering:'|| l_proc, 1);
3294  end if;
3295   --
3296   -- Check mandatory parameters have been set
3297   --
3298   hr_api.mandatory_arg_error
3299     (p_api_name       => l_proc
3300     ,p_argument       => 'start date'
3301     ,p_argument_value => p_start_date
3302     );
3303   --
3304   hr_api.mandatory_arg_error
3305     (p_api_name       => l_proc
3306     ,p_argument       => 'effective date'
3307     ,p_argument_value => p_effective_date
3308     );
3309   --
3310   --  Only proceed with validation if:
3311   --  a) The current g_old_rec is current and
3312   --  b) The start date value has changed
3313   --  c) A record is being inserted
3314   --
3315   l_api_updating := per_per_shd.api_updating
3316     (p_person_id             => p_person_id
3317     ,p_effective_date        => p_effective_date
3318     ,p_object_version_number => p_object_version_number);
3319   --
3320   if NOT l_api_updating then
3321     --
3322     -- On insert check that start date equals effective date
3323     --
3324 if g_debug then
3325     hr_utility.set_location(l_proc, 2);
3326  end if;
3327     --
3328     if p_start_date <> p_effective_date then
3329       --  Error: Invalid Start Date
3330       hr_utility.set_message(801, 'HR_7514_PER_START_DATE_INVALID');
3331       hr_utility.raise_error;
3332     end if;
3333   elsif(l_api_updating and per_per_shd.g_old_rec.start_date <>
3334         p_start_date) then
3335     --
3336     --  On update check if start date is the same as the earliest effective
3337     --  start date
3338     --
3339 if g_debug then
3340     hr_utility.set_location(l_proc, 3);
3341  end if;
3342     --
3343     open csr_chk_min_date;
3344     fetch csr_chk_min_date into l_min_date;
3345     if p_start_date <> l_min_date then
3346       close csr_chk_min_date;
3347       --  Error: Invalid start date
3348 
3349       hr_utility.set_message(801, 'HR_7514_PER_START_DATE_INVALID');
3350       hr_utility.raise_error;
3351     end if;
3352     close csr_chk_min_date;
3353   end if;
3354 if g_debug then
3355   hr_utility.set_location(' Leaving:'|| l_proc, 4);
3356  end if;
3357   exception
3358     when app_exception.application_exception then
3359       if hr_multi_message.exception_add
3360       (p_associated_column1      => 'PER_ALL_PEOPLE_F.START_DATE'
3361       ) then
3362 if g_debug then
3363         hr_utility.set_location(' Leaving:'||l_proc, 5);
3364  end if;
3365         raise;
3366       end if;
3367 if g_debug then
3368     hr_utility.set_location(' Leaving:'||l_proc,6);
3369  end if;
3370 
3371 end chk_start_date;
3372 --
3373 --  ---------------------------------------------------------------------------
3374 --  |--------------------<  chk_orig_and_start_dates >------------------------|
3375 --  ---------------------------------------------------------------------------
3376 --
3377 --  Description:
3378 --    - Validates that for person type of 'EMP','EMP_APL','EX_EMP' or
3379 --      'EX_EMP_APL' the original date of hire is the same of earlier
3380 --      than the earliest per_periods_of_service start date.
3381 --      For any other person type a warning is raised if an original
3382 --      date of hire is entered.
3383 --
3384 --  Pre-conditions:
3385 --    Valid p_person_id.
3386 --
3387 --  In Arguments:
3388 --    p_person_id
3389 --    p_person_type_id
3390 --    p_business_group_id
3391 --    p_original_date_of_hire
3392 --    p_effective_date
3393 --    p_start_date
3394 --    p_object_version_number
3395 --
3396 --  Out Arguments:
3397 --    p_orig_hire_warning
3398 --
3399 --  Post Success:
3400 --    Processing continues if:
3401 --      - person_type is 'EMP','EMP_APL','EX_EMP' or 'EX_EMP_APL'
3402 --        and original_date_of_hire is on or before the start date
3403 --      - person_type is not 'EMP','EMP_APL','EX_EMP','EX_EMP_APL'
3404 --        and original_date_of_hire is not entered
3405 --      - person_type is not 'EMP','EMP_APL','EX_EMP','EX_EMP_APL'
3406 --        and original_date_of_hire is enter and the warning
3407 --        message is acknowledged.
3408 --
3409 --  Post Failure:
3410 --    An application error is raised and processing is terminated if:
3411 --      - person_type is 'EMP','EMP_APL','EX_EMP' or 'EX_EMP_APL' and
3412 --        the original_date_of_hire is later than the start_date.
3413 --
3414 --  Access Status:
3415 --    Internal Table Handler Use Only.
3416 --
3417 procedure chk_orig_and_start_dates
3418   (p_person_id             in     per_all_people_f.person_id%TYPE
3419   ,p_person_type_id        in     per_all_people_f.person_type_id%TYPE
3420   ,p_business_group_id     in     per_all_people_f.business_group_id%TYPE
3421   ,p_original_date_of_hire in     per_all_people_f.original_date_of_hire%TYPE
3422   ,p_start_date            in     per_all_people_f.start_date%TYPE
3423   ,p_effective_date        in     date
3424   ,p_object_version_number in     per_all_people_f.object_version_number%TYPE
3425   ,p_orig_hire_warning     out nocopy    boolean
3426   ) is
3427 --
3428 l_proc          varchar2(72) ;
3429 l_system_person_type varchar2(72) := return_system_person_type
3430                                      (p_person_type_id
3431                                      ,p_business_group_id);
3432 l_earliest_date date;
3433 --
3434 cursor csr_earliest_date is
3435 select min(date_start)
3436 from per_periods_of_service
3437 where p_person_id = person_id;
3438 
3439 -- added for the bug 5402099
3440 l_earliest_date1 date;
3441 cursor original_date_of_hire_ppf is
3442 select original_date_of_hire from per_all_people_f where
3443 person_id=p_person_id and
3444 p_original_date_of_hire between effective_start_date and effective_end_date ;
3445 -- end of bug 5402099
3446 --
3447 begin
3448   --
3449 p_orig_hire_warning := FALSE;
3450   --
3451 if g_debug then
3452  l_proc :=  g_package||'chk_orig_and_start_dates';
3453   hr_utility.set_location('Entering:'|| l_proc,5);
3454  end if;
3455 --
3456   if p_original_date_of_hire is NOT NULL then
3457     if (nvl(per_per_shd.g_old_rec.original_date_of_hire,hr_api.g_date)
3458       <> nvl(p_original_date_of_hire, hr_api.g_date)) or
3459       (per_per_shd.g_old_rec.start_date <> p_start_date) then
3460 --
3461       if l_system_person_type in ('EMP','EMP_APL','EX_EMP','EX_EMP_APL') then
3462 --
3463         if (p_person_id is null and
3464           (nvl(p_original_date_of_hire,hr_api.g_date) > p_start_date)) then
3465           hr_utility.set_message(800,'PER_52474_PER_ORIG_ST_DATE');
3466           hr_multi_message.add
3467           (p_associated_column1 => 'PER_ALL_PEOPLE_F.ORIGINAL_DATE_OF_HIRE'
3468           ,p_associated_column2 => 'PER_ALL_PEOPLE_F.START_DATE'
3469           );
3470 --
3471        elsif p_person_id is not null then
3472           open csr_earliest_date;
3473           fetch csr_earliest_date into l_earliest_date;
3474 	  -- added for the bug 5402099
3475 	     open original_date_of_hire_ppf ;
3476              fetch original_date_of_hire_ppf into l_earliest_date1;
3477              hr_utility.set_location('l_earliest_date1:'|| l_earliest_date1,10);
3478              if l_earliest_date1 is null then
3479                  l_earliest_date:=p_original_date_of_hire;
3480                  hr_utility.set_location('l_earliest_date:'|| l_earliest_date,15);
3481                  close original_date_of_hire_ppf;
3482               else
3483                  close original_date_of_hire_ppf;
3484               end if;
3485            -- end of  bug 5402099
3486           if (nvl(p_original_date_of_hire,hr_api.g_date) > l_earliest_date) then
3487   /* 1352469 Replaced with above IF statement
3488             if ((l_earliest_date <= p_start_date) and
3489               (nvl(p_original_date_of_hire,hr_api.g_date) > l_earliest_date))
3490               or ((l_earliest_date > p_start_date) and
3491                 (nvl(p_original_date_of_hire,hr_api.g_date) > p_start_date)) then
3492   */
3493             hr_utility.set_message(800,'PER_52474_PER_ORIG_ST_DATE');
3494             close csr_earliest_date;
3495             hr_multi_message.add
3496             (p_associated_column1 => 'PER_ALL_PEOPLE_F.ORIGINAL_DATE_OF_HIRE'
3497             );
3498           else
3499             close csr_earliest_date;
3500           end if;
3501         end if;
3502 --
3503       elsif l_system_person_type not in ('EMP','EMP_APL','EX_EMP','EX_EMP_APL')
3504         then p_orig_hire_warning := TRUE;
3505       end if;
3506     end if;
3507   end if;
3508   --
3509 if g_debug then
3510   hr_utility.set_location(' Leaving:'||l_proc, 10);
3511  end if;
3512 --
3513 end chk_orig_and_start_dates;
3514 --
3515 --  ---------------------------------------------------------------------------
3516 --  |---------------------<  chk_GB_per_information >-------------------------|
3517 --  ---------------------------------------------------------------------------
3518 --
3519 --  Description:
3520 --    - Checks that the values held in developer descriptive flexfields
3521 --      are valid for a category of 'GB'
3522 --    - Validates that per information3  and per information11 to 20 are null.
3523 --    - Validates that per information2, 4 ,9 and 10 exists as a lookup code on
3524 --      HR_LOOKUPS for the lookup type 'YES_NO' with an enabled flag set to 'Y'
3525 --      and the effective start date of the person between start date active
3526 --      and end date active on HR_LOOKUPS.
3527 --    - Validates that per information1 exists as a lookup code on HR_LOOKUPS
3528 --      for the lookup type 'ETH_TYPE' with an enabled flag set to 'Y' and the
3529 --      effective start date of the person between start date active and end
3530 --      date active on HR_LOOKUPS.
3531 --    - Validates that per information5 is less than or equal to 30 characters
3532 --      and in uppercase.
3533 --
3534 --  Pre-conditions:
3535 --    A GB per information category
3536 --
3537 --  In Arguments:
3538 --    p_person_id
3539 --    p_per_information_category
3540 --    p_per_information1
3541 --    p_per_information2
3542 --    p_per_information3
3543 --    p_per_information4
3544 --    p_per_information5
3545 --    p_per_information6
3546 --    p_per_information7
3547 --    p_per_information8
3548 --    p_per_information9
3549 --    p_per_information10
3550 --    p_per_information11
3551 --    p_per_information12
3552 --    p_per_information13
3553 --    p_per_information14
3554 --    p_per_information15
3555 --    p_per_information16
3556 --    p_per_information17
3557 --    p_per_information18
3558 --    p_per_information19
3559 --    p_per_information20
3560 --    p_effective_date
3561 --    p_validation_start_date
3562 --    p_validation_end_date
3563 --    p_object_version_number
3564 --
3565 --  Post Success:
3566 --    Processing continues if:
3567 --      - per_information3 and per_information11 to 20 values are null
3568 --      - per information2, 4 , 9 and 10 exists as a lookup code in HR_LOOKUPS
3569 --        for the lookup type 'YES_NO' where the enabled flag is 'Y'
3570 --        and the effective start date of the person is between start
3571 --        date active and end date active on HR_LOOKUPS.
3572 --      - per information1 exists as a lookup code in HR_LOOKUPS
3573 --        for the lookup type 'ETH_TYPE' where the enabled flag is 'Y'
3574 --        and the effective start date of the person is between start
3575 --        date active and end date active on HR_LOOKUPS.
3576 --      - per_information5 is less than or equal to 30 characters long
3577 --        and upper case.
3578 --
3579 --  Post Failure:
3580 --    An application error is raised and processing is terminated if:
3581 --      - any of per_information3 and per_information10 to 20 values are
3582 --        not null.
3583 --      - any of per information2, 4,9 and 10 does'nt exist as a lookup code
3584 --        in HR_LOOKUPS for the lookup type 'YES_NO' where the enabled flag
3585 --        is 'Y' and the effective start date of the person is between start
3586 --        date active and end date active on HR_LOOKUPS.
3587 --      - per information1 does'nt exist as a lookup code in HR_LOOKUPS
3588 --        for the lookup type 'ETH_TYPE' where the enabled flag is 'Y'
3589 --        and the effective start date of the person is between start
3590 --        date active and end date active on HR_LOOKUPS.
3591 --      - per_information5 is not less than or equal to 30 characters long
3592 --        or not upper case.
3593 --
3594 --  Access Status:
3595 --    Internal Table Handler Use Only.
3596 --
3597 procedure chk_GB_per_information
3598   (p_person_id                in     per_all_people_f.person_id%TYPE
3599   ,p_per_information_category in     per_all_people_f.per_information_category%TYPE
3600   ,p_per_information1         in     per_all_people_f.per_information1%TYPE
3601   ,p_per_information2         in     per_all_people_f.per_information2%TYPE
3602   ,p_per_information3         in     per_all_people_f.per_information3%TYPE
3603   ,p_per_information4         in     per_all_people_f.per_information4%TYPE
3604   ,p_per_information5         in     per_all_people_f.per_information5%TYPE
3605   ,p_per_information6         in     per_all_people_f.per_information6%TYPE
3606   ,p_per_information7         in     per_all_people_f.per_information7%TYPE
3607   ,p_per_information8         in     per_all_people_f.per_information8%TYPE
3608   ,p_per_information9         in     per_all_people_f.per_information9%TYPE
3609   ,p_per_information10        in     per_all_people_f.per_information10%TYPE
3610   ,p_per_information11        in     per_all_people_f.per_information11%TYPE
3611   ,p_per_information12        in     per_all_people_f.per_information12%TYPE
3612   ,p_per_information13        in     per_all_people_f.per_information13%TYPE
3613   ,p_per_information14        in     per_all_people_f.per_information14%TYPE
3614   ,p_per_information15        in     per_all_people_f.per_information15%TYPE
3615   ,p_per_information16        in     per_all_people_f.per_information16%TYPE
3616   ,p_per_information17        in     per_all_people_f.per_information17%TYPE
3617   ,p_per_information18        in     per_all_people_f.per_information18%TYPE
3618   ,p_per_information19        in     per_all_people_f.per_information19%TYPE
3619   ,p_per_information20        in     per_all_people_f.per_information20%TYPE
3620   ,p_per_information21        in     per_all_people_f.per_information21%TYPE
3621   ,p_per_information22        in     per_all_people_f.per_information22%TYPE
3622   ,p_per_information23        in     per_all_people_f.per_information23%TYPE
3623   ,p_per_information24        in     per_all_people_f.per_information24%TYPE
3624   ,p_per_information25        in     per_all_people_f.per_information25%TYPE
3625   ,p_per_information26        in     per_all_people_f.per_information26%TYPE
3626   ,p_per_information27        in     per_all_people_f.per_information27%TYPE
3627   ,p_per_information28        in     per_all_people_f.per_information28%TYPE
3628   ,p_per_information29        in     per_all_people_f.per_information29%TYPE
3629   ,p_per_information30        in     per_all_people_f.per_information30%TYPE
3630   ,p_effective_date           in     date
3631   ,p_validation_start_date    in     date
3632   ,p_validation_end_date      in     date
3633   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
3634   )
3635 is
3636   --
3637   l_exists         varchar2(1);
3638   l_error          exception;
3639   l_proc           varchar2(72)  :=  g_package||'chk_GB_per_information';
3640   l_api_updating   boolean;
3641   l_lookup_type    varchar2(30);
3642   l_info_attribute number(2);
3643   l_per_information6 per_all_people_f.per_information6%TYPE;
3644   l_per_information7 per_all_people_f.per_information7%TYPE;
3645   l_per_information8 per_all_people_f.per_information8%TYPE;
3646   l_output           varchar2(150);
3647   l_rgeflg           varchar2(10);
3648   --
3649 begin
3650 if g_debug then
3651   hr_utility.set_location('Entering:'|| l_proc, 10);
3652  end if;
3653   --
3654   -- Check the mandatory parameters
3655   --
3656    hr_api.mandatory_arg_error
3657     (p_api_name       =>  l_proc
3658     ,p_argument       =>  'effective_date'
3659     ,p_argument_value =>  p_effective_date
3660     );
3661   --
3662   hr_api.mandatory_arg_error
3663     (p_api_name       =>  l_proc
3664     ,p_argument       =>  'validation_start_date'
3665     ,p_argument_value =>  p_validation_start_date
3666     );
3667   --
3668   hr_api.mandatory_arg_error
3669     (p_api_name        =>  l_proc
3670     ,p_argument       =>  'validation_end_date'
3671     ,p_argument_value =>  p_validation_end_date
3672     );
3673 if g_debug then
3674   hr_utility.set_location(l_proc,20);
3675  end if;
3676   --
3677   -- We know the per_information_category is GB, so check the rest of
3678   -- the per_information fields within this context.
3679   --
3680   --  Check if the per_information1 value exists in hr_lookups
3681   --  where the lookup_type is 'ETH_TYPE'
3682   --
3683   if p_per_information1 is not null then
3684     --
3685     -- Check that per information1 exists in hr_lookups for the
3686     -- lookup type 'ETH_TYPE' with an enabled flag set to 'Y' and that
3687     -- the effective start date of the person is between start date
3688     -- active and end date active in hr_lookups.
3689     --
3690     if hr_api.not_exists_in_dt_hr_lookups
3691       (p_effective_date        => p_effective_date
3692       ,p_validation_start_date => p_validation_start_date
3693       ,p_validation_end_date   => p_validation_end_date
3694       ,p_lookup_type           => 'ETH_TYPE'
3695       ,p_lookup_code           => p_per_information1
3696       )
3697     then
3698       --
3699       hr_utility.set_message(801, 'HR_7524_PER_INFO1_INVALID');
3700       hr_utility.raise_error;
3701       --
3702     end if;
3703 if g_debug then
3704     hr_utility.set_location(l_proc,30);
3705  end if;
3706     --
3707   end if;
3708 if g_debug then
3709   hr_utility.set_location(l_proc,40);
3710  end if;
3711   --
3712   --  Check if the per_information2 value exists in hr_lookups
3713   --  where the lookup_type is 'YES_NO'
3714   --
3715   if p_per_information2 is not null then
3716     --
3717     -- Check that per information2 exists in hr_lookups for the
3718     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
3719     -- the effective start date of the person is between start date
3720     -- active and end date active in hr_lookups.
3721     --
3722     if hr_api.not_exists_in_dt_hr_lookups
3723       (p_effective_date        => p_effective_date
3724       ,p_validation_start_date => p_validation_start_date
3725       ,p_validation_end_date   => p_validation_end_date
3726       ,p_lookup_type           => 'YES_NO'
3727       ,p_lookup_code           => p_per_information2
3728       )
3729     then
3730       --
3731       hr_utility.set_message(801, 'HR_7525_PER_INFO2_INVALID');
3732       hr_utility.raise_error;
3733       --
3734     end if;
3735  if g_debug then
3736     hr_utility.set_location(l_proc,50);
3737  end if;
3738     --
3739   end if;
3740  if g_debug then
3741   hr_utility.set_location(l_proc,60);
3742  end if;
3743   --
3744   --  Check if the per_information4 value exists in hr_lookups
3745   --  where the lookup_type is 'YES_NO'
3746   --
3747   if p_per_information4 is not null then
3748     --
3749     -- Check that per information4 exists in hr_lookups for the
3750     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
3751     -- the effective start date of the person is between start date
3752     -- active and end date active in hr_lookups.
3753     --
3754     if hr_api.not_exists_in_dt_hr_lookups
3755       (p_effective_date        => p_effective_date
3756       ,p_validation_start_date => p_validation_start_date
3757       ,p_validation_end_date   => p_validation_end_date
3758       ,p_lookup_type           => 'YES_NO'
3759       ,p_lookup_code           => p_per_information4
3760       )
3761     then
3762       --
3763       hr_utility.set_message(801, 'HR_7526_PER_INFO4_INVALID');
3764       hr_utility.raise_error;
3765       --
3766     end if;
3767  if g_debug then
3768     hr_utility.set_location(l_proc,70);
3769  end if;
3770     --
3771   end if;
3772  if g_debug then
3773   hr_utility.set_location(l_proc,80);
3774  end if;
3775   --
3776   -- Check if p_per_information5 is greater than 30 characters long
3777   --
3778   if p_per_information5 is not null then
3779     if length(p_per_information5) > 30 then
3780       --  Error: Work Permit (PER_INFORMATION5) cannot be longer than
3781       --         30 characters
3782       hr_utility.set_message(801, 'HR_7527_PER_INFO5_LENGTH');
3783       hr_utility.raise_error;
3784     end if;
3785  if g_debug then
3786     hr_utility.set_location(l_proc,90);
3787  end if;
3788     --
3789     --  Check if p_per_information5 is not upper case
3790     --
3791     --if p_per_information5 <> upper(p_per_information5) then
3792       --  Error: Enter the Work Permit value (PER_INFORMATION5) in
3793       --         upper case
3794       --hr_utility.set_message(801, 'HR_7528_PER_INFO5_CASE');
3795       --hr_utility.raise_error;
3796     --end if;
3797  --if g_debug then
3798     --hr_utility.set_location(l_proc,100);
3799  --end if;
3800   end if;
3801  if g_debug then
3802   hr_utility.set_location(l_proc,110);
3803  end if;
3804   --
3805   -- Check if p_per_information6 is in the range 0 - 99.
3806   --
3807   if p_per_information6 is not null then
3808     --
3809     l_per_information6 := p_per_information6;
3810     hr_chkfmt.checkformat(value   => l_per_information6
3811                          ,format  => 'I'
3812                          ,output  => l_output
3813                          ,minimum => NULL
3814                          ,maximum => NULL
3815                          ,nullok  => 'Y'
3816                          ,rgeflg  => l_rgeflg
3817                          ,curcode => NULL);
3818  if g_debug then
3819     hr_utility.set_location(l_proc,120);
3820  end if;
3821     --
3822     if to_number(l_per_information6) < 0  or
3823        to_number(l_per_information6) > 99 then
3824       --  Error: Additional pension years (PER_INFORMATION6) not in the
3825       --         range 0 - 99.
3826       hr_utility.set_message(801, 'HR_51272_PER_INFO6_INVALID');
3827       hr_utility.raise_error;
3828     end if;
3829  if g_debug then
3830     hr_utility.set_location(l_proc,130);
3831  end if;
3832   end if;
3833  if g_debug then
3834   hr_utility.set_location(l_proc, 140);
3835  end if;
3836   --
3837   -- Check if p_per_information7 is in the range 1 - 11.
3838   --
3839   if p_per_information7 is not null then
3840     --
3841     l_per_information7 := p_per_information7;
3842     hr_chkfmt.checkformat(value   => l_per_information7
3843                          ,format  => 'I'
3844                          ,output  => l_output
3845                          ,minimum => NULL
3846                          ,maximum => NULL
3847                          ,nullok  => 'Y'
3848                          ,rgeflg  => l_rgeflg
3849                          ,curcode => NULL);
3850  if g_debug then
3851     hr_utility.set_location(l_proc, 150);
3852  end if;
3853     --
3854     if to_number(l_per_information7) < 1  or
3855        to_number(l_per_information7) > 11 then
3856       --  Error: Additional pension months (PER_INFORMATION7) not in the
3857       --         range 1 - 11.
3858       hr_utility.set_message(801, 'HR_51273_PER_INFO7_INVALID');
3859       hr_utility.raise_error;
3860     end if;
3861  if g_debug then
3862     hr_utility.set_location(l_proc,160);
3863  end if;
3864   end if;
3865  if g_debug then
3866   hr_utility.set_location(l_proc, 170);
3867  end if;
3868   --
3869   -- Check if p_per_information8 is number.
3870   --
3871   if p_per_information8 is not null then
3872     --
3873     l_per_information8 := p_per_information8;
3874     hr_chkfmt.checkformat(value   => l_per_information8
3875                          ,format  => 'I'
3876                          ,output  => l_output
3877                          ,minimum => NULL
3878                          ,maximum => NULL
3879                          ,nullok  => 'Y'
3880                          ,rgeflg  => l_rgeflg
3881                          ,curcode => NULL);
3882  if g_debug then
3883     hr_utility.set_location(l_proc,180);
3884  end if;
3885   end if;
3886  if g_debug then
3887   hr_utility.set_location(l_proc, 190);
3888  end if;
3889   --
3890   --  Check if the per_information9 value exists in hr_lookups
3891   --  where the lookup_type is 'YES_NO'
3892   --
3893   if p_per_information9 is not null then
3894     --
3895     -- Check that per information9 exists in hr_lookups for the
3896     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
3897     -- the effective start date of the person is between start date
3898     -- active and end date active in hr_lookups.
3899     --
3900     if hr_api.not_exists_in_dt_hr_lookups
3901       (p_effective_date        => p_effective_date
3902       ,p_validation_start_date => p_validation_start_date
3903       ,p_validation_end_date   => p_validation_end_date
3904       ,p_lookup_type           => 'YES_NO'
3905       ,p_lookup_code           => p_per_information9
3906       )
3907     then
3908       --
3909       hr_utility.set_message(801, 'HR_51274_PER_INFO9_INVALID');
3910       hr_utility.raise_error;
3911       --
3912     end if;
3913  if g_debug then
3914     hr_utility.set_location(l_proc,200);
3915  end if;
3916     --
3917   end if;
3918  if g_debug then
3919   hr_utility.set_location(l_proc,210);
3920  end if;
3921 
3922   -- ***** Start new code for bug 2236999 **************
3923 
3924   if p_per_information10 is not null then
3925      --
3926      -- Check that per information10 exists in hr_lookups for the
3927      -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
3928      -- the effective start date of the person is between start date
3929      -- active and end date active in hr_lookups.
3930      --
3931     if hr_api.not_exists_in_dt_hr_lookups
3932       (p_effective_date        => p_effective_date
3933       ,p_validation_start_date => p_validation_start_date
3934       ,p_validation_end_date   => p_validation_end_date
3935       ,p_lookup_type           => 'YES_NO'
3936       ,p_lookup_code           => p_per_information10
3937       )
3938      then
3939      --
3940      hr_utility.set_message(801, 'HR_78105_PER_INFO10_INVALID');
3941      hr_utility.raise_error;
3942      --
3943      end if;
3944 
3945      --
3946   end if;
3947 
3948   --***** End new code for bug 2236999 **************
3949   --
3950   --  Check if any of the remaining per_information parameters are not
3951   --  null
3952   --  (developer descriptive flexfields not used for GB)
3953   --
3954   if p_per_information3 is not null then
3955     l_info_attribute := 3;
3956     raise l_error;
3957 
3958  -- ***** Start commented code for bug 2236999 **************
3959   /* elsif p_per_information10 is not null then
3960     l_info_attribute := 10;
3961     raise l_error;*/
3962  -- ***** End commented code for bug 2236999  **************
3963 
3964  -- ***** Start commented code for bug 5606753 **************
3965    /*elsif p_per_information11 is not null then
3966     l_info_attribute := 11;
3967     raise l_error; */
3968   -- ***** End commented code for bug 5606753  **************
3969   -- ***** Start commented code for bug 5917391 *************
3970   /*elsif p_per_information12 is not null then
3971     l_info_attribute := 12;
3972     raise l_error;
3973   elsif p_per_information13 is not null then
3974     l_info_attribute := 13;
3975     raise l_error;
3976   elsif p_per_information14 is not null then
3977     l_info_attribute := 14;
3978     raise l_error;*/
3979   -- ***** End commented code for bug 5917391 ************
3980   elsif p_per_information15 is not null then
3981     l_info_attribute := 15;
3982     raise l_error;
3983   elsif p_per_information16 is not null then
3984     l_info_attribute := 16;
3985     raise l_error;
3986   elsif p_per_information17 is not null then
3987     l_info_attribute := 17;
3988     raise l_error;
3989   elsif p_per_information18 is not null then
3990     l_info_attribute := 18;
3991     raise l_error;
3992   elsif p_per_information19 is not null then
3993     l_info_attribute := 19;
3994     raise l_error;
3995   elsif p_per_information20 is not null then
3996     l_info_attribute := 20;
3997     raise l_error;
3998   elsif p_per_information21 is not null then
3999     l_info_attribute := 21;
4000     raise l_error;
4001   elsif p_per_information22 is not null then
4002     l_info_attribute := 22;
4003     raise l_error;
4004   elsif p_per_information23 is not null then
4005     l_info_attribute := 23;
4006     raise l_error;
4007   elsif p_per_information24 is not null then
4008     l_info_attribute := 24;
4009     raise l_error;
4010 -- Commenting null check for p_per_information25, p_per_information26 as
4011 -- these are used for Employee Referral Functionality
4012   /*elsif p_per_information25 is not null then
4013     l_info_attribute := 25;
4014     raise l_error;
4015   elsif p_per_information26 is not null then
4016     l_info_attribute := 26;
4017     raise l_error;*/
4018 -- End of Commenting for Employee Referral
4019   elsif p_per_information27 is not null then
4020     l_info_attribute := 27;
4021     raise l_error;
4022   elsif p_per_information28 is not null then
4023     l_info_attribute := 28;
4024     raise l_error;
4025   elsif p_per_information29 is not null then
4026     l_info_attribute := 29;
4027     raise l_error;
4028   elsif p_per_information30 is not null then
4029     l_info_attribute := 30;
4030     raise l_error;
4031   end if;
4032  if g_debug then
4033   hr_utility.set_location(' Leaving:'|| l_proc, 220);
4034  end if;
4035 exception
4036     when l_error then
4037       --  Error: Do not enter PER_INFORMATION99 for this legislation
4038       hr_utility.set_message(801, 'HR_7529_PER_INFO_NOT_NULL');
4039       hr_utility.set_message_token('NUM',to_char(l_info_attribute));
4040       hr_utility.raise_error;
4041 end chk_GB_per_information;
4042 --
4043 --  ---------------------------------------------------------------------------
4044 --  |---------------------<  chk_US_per_information >-------------------------|
4045 --  ---------------------------------------------------------------------------
4046 --
4047 --  Description:
4048 --    - Checks that the values held in developer descriptive flexfields
4049 --      are valid for a category of 'US'.
4050 --    - Validates that per information6 and 9 exist as a lookup code on
4051 --      HR_LOOKUPS for the lookup type 'YES_NO' with an enabled flag
4052 --      set to 'Y' and the effective start date of the person between start
4053 --      date active and end date active on HR_LOOKUPS.
4054 --    - Validates that per information1 exists as a lookup code on HR_LOOKUPS
4055 --      for the lookup type 'US_ETHNIC_GROUP' with an enabled flag set to 'Y'
4056 --      and the effective start date of the person between start date active
4057 --      and end date active on HR_LOOKUPS.
4058 --    - Validates that per information2 exists as a lookup code on HR_LOOKUPS
4059 --      for the lookup type 'PER_US_I9_STATE' with an enabled flag set to 'Y'
4060 --      and the effective start date of the person between start date active
4061 --      and end date active on HR_LOOKUPS.
4062 --    - Validates that per information4 exists as a lookup code on HR_LOOKUPS
4063 --      for the lookup type 'US_VISA_TYPE' with an enabled flag set to 'Y'
4064 --      and the effective start date of the person between start date active
4065 --      and end date active on HR_LOOKUPS.
4066 --    - Validates that per information5 exists as a lookup code on HR_LOOKUPS
4067 --      for the lookup type 'US_VETERAN_STATUS' with an enabled flag set to 'Y'
4068 --      and the effective start date of the person between start date active
4069 --      and end date active on HR_LOOKUPS.
4070 --    - Validates that per information7 exists as a lookup code on HR_LOOKUPS
4071 --      for the lookup type 'US_NEW_HIRE_STATUS' with an enabled flag set to 'Y'
4072 --      and the effective start date of the person between start date active
4073 --      and end date active on HR_LOOKUPS.
4074 --    - Validates that when per information7 is set to 'EXCL' that per
4075 --      information8 exists as a lookup code on HR_LOOKUPS for the lookup type
4076 --      'US_NEW_HIRE_EXCEPTIONS' with an enabled flag set to 'Y' and the
4077 --      effective start date of the person between start date active and end
4078 --      date active on HR_LOOKUPS.
4079 --    - Validates that per information10 exists as a lookup code on
4080 --      HR_LOOKUPS for the lookup type 'YES_NO' with an enabled flag
4081 --      set to 'Y' and the effective start date of the person between start
4082 --      date active and end date active on HR_LOOKUPS.
4083 --
4084 --  Pre-conditions:
4085 --    None
4086 --
4087 --  In Arguments:
4088 --    p_person_id
4089 --    p_per_information_category
4090 --    p_per_information1
4091 --    p_per_information2
4092 --    p_per_information3
4093 --    p_per_information4
4094 --    p_per_information5
4095 --    p_per_information6
4096 --    p_per_information7
4097 --    p_per_information8
4098 --    p_per_information9
4099 --    p_per_information10
4100 --    p_per_information11
4101 --    p_per_information12
4102 --    p_per_information13
4103 --    p_per_information14
4104 --    p_per_information15
4105 --    p_per_information16
4106 --    p_per_information17
4107 --    p_per_information18
4108 --    p_per_information19
4109 --    p_per_information20
4110 --    p_per_information21
4111 --    p_per_information22
4112 --    p_per_information23
4113 --    p_per_information24
4114 --    p_per_information25
4115 --    p_per_information26
4116 --    p_per_information27
4117 --    p_per_information28
4118 --    p_per_information29
4119 --    p_per_information30
4120 --    p_effective_date
4121 --    p_validation_start_date
4122 --    p_validation_end_date
4123 --    p_object_version_number
4124 --    p_api_updating
4125 --
4126 --  Post Success:
4127 --    Processing continues if:
4128 --      - per information6 and 9 exist as a lookup code in HR_LOOKUPS
4129 --        for the lookup type 'YES_NO' where the enabled flag is 'Y' and
4130 --        the effective start date of the person is between start date
4131 --        active and end date active on HR_LOOKUPS.
4132 --      - per information1 exists as a lookup code in HR_LOOKUPS
4133 --        for the lookup type 'US_ETHNIC_GROUP' where the enabled flag is
4134 --        'Y' and the effective start date of the person is between start
4135 --        date active and end date active on HR_LOOKUPS.
4136 --      - per information2 exists as a lookup code in HR_LOOKUPS
4137 --        for the lookup type 'PER_US_I9_STATE' where the enabled flag is
4138 --        'Y' and the effective start date of the person is between start
4139 --        date active and end date active on HR_LOOKUPS.
4140 --      - per information3 is a valid date and 11 characters long.
4141 --      - per information4 exists as a lookup code in HR_LOOKUPS
4142 --        for the lookup type 'US_VISA_TYPE' where the enabled flag is
4143 --        'Y' and the effective start date of the person is between start
4144 --        date active and end date active on HR_LOOKUPS.
4145 --      - per information5 exists as a lookup code in HR_LOOKUPS
4146 --        for the lookup type 'US_VETERAN_STATUS' where the enabled flag is
4147 --        'Y' and the effective start date of the person is between start
4148 --        date active and end date active on HR_LOOKUPS.
4149 --      - per information7 exists as a lookup code in HR_LOOKUPS
4150 --        for the lookup type 'US_NEW_HIRE_STATUS' where the enabled flag is
4151 --        'Y' and the effective start date of the person is between start
4152 --        date active and end date active on HR_LOOKUPS.
4153 --      - when per information7 is set to 'EXCL' and per information8 exists
4154 --        as a lookup code in HR_LOOKUPS for the lookup type
4155 --        'US_NEW_HIRE_EXCEPTIONS' where the enabled flag is 'Y' and the
4156 --        effective start date of the person is between start date active
4157 --        and end date active on HR_LOOKUPS.
4158 --
4159 --     9) per_information9 value exists in hr_lookups
4160 --        where lookup_type = 'YES_NO'
4161 --
4162 --    10) per information10 exists as a lookup code in HR_LOOKUPS
4163 --        for the lookup type 'YES_NO' where the enabled flag is 'Y' and
4164 --        the effective start date of the person is between start date
4165 --        active and end date active on HR_LOOKUPS.
4166 --
4167 --    11) per_information11 to 20 values are null
4168 --
4169 --  Post Failure:
4170 --    An application error is raised and processing is terminated if:
4171 --      - per information6 and 9 does not exist as a lookup code in
4172 --        HR_LOOKUPS for the lookup type 'YES_NO' where the
4173 --        enabled flag is 'Y' and the effective start date of the person
4174 --        is between start date active and end date active on HR_LOOKUPS.
4175 --      - per information1 doesn't exist as a lookup code in HR_LOOKUPS
4176 --        for the lookup type 'US_ETHNIC_GROUP' where the enabled flag is
4177 --        'Y' and the effective start date of the person is between start
4178 --        date active and end date active on HR_LOOKUPS.
4179 --      - per information2 doesn't exist as a lookup code in HR_LOOKUPS
4180 --        for the lookup type 'PER_US_I9_STATE' where the enabled flag is
4181 --        'Y' and the effective start date of the person is between start
4182 --        date active and end date active on HR_LOOKUPS.
4183 --      - per information3 value is an invalid date or less than 11
4184 --        characters long.
4185 --      - per information4 doesn't exist as a lookup code in HR_LOOKUPS
4186 --        for the lookup type 'US_VISA_TYPE' where the enabled flag is
4187 --        'Y' and the effective start date of the person is between start
4188 --        date active and end date active on HR_LOOKUPS.
4189 --      - per information5 doesn't exist as a lookup code in HR_LOOKUPS
4190 --        for the lookup type 'US_VETERAN_STATUS' where the enabled flag is
4191 --        'Y' and the effective start date of the person is between start
4192 --        date active and end date active on HR_LOOKUPS.
4193 --      - per information7 doesn't exist as a lookup code in HR_LOOKUPS
4194 --        for the lookup type 'US_NEW_HIRE_STATUS' where the enabled flag is
4195 --        'Y' and the effective start date of the person is between start
4196 --        date active and end date active on HR_LOOKUPS.
4197 --      - per information8 doesn't exist as a lookup code in HR_LOOKUPS
4198 --        for the lookup type 'US_NEW_HIRE_EXCEPTION' where the enabled flag is
4199 --        'Y' and the effective start date of the person is between start
4200 --        date active and end date active on HR_LOOKUPS.
4201 --      - when per information7 is set to 'EXCL' and per information8 doesn't
4202 --        exist as a lookup code in HR_LOOKUPS for the lookup type
4203 --        'US_NEW_HIRE_EXCEPTIONS' where the enabled flag is 'Y' and the
4204 --        effective start date of the person is between start date active
4205 --        and end date active on HR_LOOKUPS.
4206 --
4207 --     9) per_information9 value does not exists in hr_lookups
4208 --        where lookup_type = 'YES_NO'
4209 --
4210 --    10) per information10 does not exist as a lookup code in HR_LOOKUPS
4211 --        for the lookup type 'YES_NO' where the enabled flag is 'Y' and
4212 --        the effective start date of the person is between start date
4213 --        active and end date active on HR_LOOKUPS.
4214 --
4215 --    11) per_information11 to 20 values are not null
4216 --
4217 --  Access Status:
4218 --    Internal Table Handler Use Only.
4219 --
4220 procedure chk_US_per_information
4221   (p_person_id                in     per_all_people_f.person_id%TYPE
4222   ,p_per_information_category in     per_all_people_f.per_information_category%TYPE
4223   ,p_per_information1         in     per_all_people_f.per_information1%TYPE
4224   ,p_per_information2         in     per_all_people_f.per_information2%TYPE
4225   ,p_per_information3         in     per_all_people_f.per_information3%TYPE
4226   ,p_per_information4         in     per_all_people_f.per_information4%TYPE
4227   ,p_per_information5         in     per_all_people_f.per_information5%TYPE
4228   ,p_per_information6         in     per_all_people_f.per_information6%TYPE
4229   ,p_per_information7         in     per_all_people_f.per_information7%TYPE
4230   ,p_per_information8         in     per_all_people_f.per_information8%TYPE
4231   ,p_per_information9         in     per_all_people_f.per_information9%TYPE
4232   ,p_per_information10        in     per_all_people_f.per_information10%TYPE
4233   ,p_per_information11        in     per_all_people_f.per_information11%TYPE
4234   ,p_per_information12        in     per_all_people_f.per_information12%TYPE
4235   ,p_per_information13        in     per_all_people_f.per_information13%TYPE
4236   ,p_per_information14        in     per_all_people_f.per_information14%TYPE
4237   ,p_per_information15        in     per_all_people_f.per_information15%TYPE
4238   ,p_per_information16        in     per_all_people_f.per_information16%TYPE
4239   ,p_per_information17        in     per_all_people_f.per_information17%TYPE
4240   ,p_per_information18        in     per_all_people_f.per_information18%TYPE
4241   ,p_per_information19        in     per_all_people_f.per_information19%TYPE
4242   ,p_per_information20        in     per_all_people_f.per_information20%TYPE
4243   ,p_per_information21        in     per_all_people_f.per_information21%TYPE
4244   ,p_per_information22        in     per_all_people_f.per_information22%TYPE
4245   ,p_per_information23        in     per_all_people_f.per_information23%TYPE
4246   ,p_per_information24        in     per_all_people_f.per_information24%TYPE
4247   ,p_per_information25        in     per_all_people_f.per_information25%TYPE
4248   ,p_per_information26        in     per_all_people_f.per_information26%TYPE
4249   ,p_per_information27        in     per_all_people_f.per_information27%TYPE
4250   ,p_per_information28        in     per_all_people_f.per_information28%TYPE
4251   ,p_per_information29        in     per_all_people_f.per_information29%TYPE
4252   ,p_per_information30        in     per_all_people_f.per_information30%TYPE
4253   ,p_effective_date           in     date
4254   ,p_validation_start_date    in     date
4255   ,p_validation_end_date      in     date
4256   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
4257   ,p_api_updating             in     boolean
4258   )
4259 is
4260   --
4261   l_exists           varchar2(1);
4262   l_error            exception;
4263   l_temp_error       exception;
4264   l_proc             varchar2(72)  :=  g_package||'chk_US_per_information';
4265   l_lookup_type      varchar2(30);
4266   l_info_attribute   number(2);
4267   l_per_information3 per_all_people_f.per_information3%TYPE;
4268   l_output           varchar2(150);
4269   l_rgeflg           varchar2(10);
4270 --
4271 begin
4272  if g_debug then
4273   hr_utility.set_location('Entering:'|| l_proc, 10);
4274  end if;
4275   --
4276   -- Check the mandatory parameters
4277   --
4278    hr_api.mandatory_arg_error
4279     (p_api_name       =>  l_proc
4280     ,p_argument       =>  'effective_date'
4281     ,p_argument_value =>  p_effective_date
4282     );
4283   --
4284   hr_api.mandatory_arg_error
4285     (p_api_name       =>  l_proc
4286     ,p_argument       =>  'validation_start_date'
4287     ,p_argument_value =>  p_validation_start_date
4288     );
4289   --
4290   hr_api.mandatory_arg_error
4291     (p_api_name        =>  l_proc
4292     ,p_argument       =>  'validation_end_date'
4293     ,p_argument_value =>  p_validation_end_date
4294     );
4295  if g_debug then
4296   hr_utility.set_location(l_proc,20);
4297  end if;
4298   --
4299   -- We know the per_information_category is US, so check the rest of
4300   -- the per_information fields within this context.
4301   --
4302   -- Check if the value for per information1 is set on insert or has
4303   -- changed on update.
4304   --
4305   if (((nvl(p_per_information1,hr_api.g_varchar2)
4306         <> nvl(per_per_shd.g_old_rec.per_information1,hr_api.g_varchar2)
4307         and p_api_updating)
4308       or (NOT p_api_updating))
4309     and p_per_information1 is not null)
4310   then
4311     --
4312     -- Check that per information1 exists in hr_lookups for the
4313     -- lookup type 'US_ETHNIC_GROUP' with an enabled flag set to 'Y'
4314     -- and that the effective start date of the person is between start
4315     -- date active and end date active in hr_lookups.
4316     --
4317     if hr_api.not_exists_in_dt_hr_lookups
4318       (p_effective_date        => p_effective_date
4319       ,p_validation_start_date => p_validation_start_date
4320       ,p_validation_end_date   => p_validation_end_date
4321       ,p_lookup_type           => 'US_ETHNIC_GROUP'
4322       ,p_lookup_code           => p_per_information1
4323       )
4324     then
4325       --
4326       hr_utility.set_message(801, 'HR_7524_PER_INFO1_INVALID');
4327       hr_utility.raise_error;
4328       --
4329     end if;
4330  if g_debug then
4331     hr_utility.set_location(l_proc,30);
4332  end if;
4333     --
4334   end if;
4335  if g_debug then
4336   hr_utility.set_location( l_proc, 40);
4337  end if;
4338   --
4339   -- Check if the value for per information2 is set on insert or has
4340   -- changed on update.
4341   --
4342   if (((nvl(p_per_information2,hr_api.g_varchar2) <>
4343         nvl(per_per_shd.g_old_rec.per_information2,hr_api.g_varchar2)
4344                      and p_api_updating) or
4345        (NOT p_api_updating)) and
4346         p_per_information2 is not null)
4347   then
4348     --
4349     -- Check that per information2 exists in hr_lookups for the
4350     -- lookup type 'PER_US_I9_STATE' with an enabled flag set to 'Y' and that
4351     -- the effective start date of the person is between start date
4352     -- active and end date active in hr_lookups.
4353     --
4354     if hr_api.not_exists_in_dt_hr_lookups
4355       (p_effective_date        => p_effective_date
4356       ,p_validation_start_date => p_validation_start_date
4357       ,p_validation_end_date   => p_validation_end_date
4358       ,p_lookup_type           => 'PER_US_I9_STATE'
4359       ,p_lookup_code           => p_per_information2
4360       )
4361     then
4362       --
4363       hr_utility.set_message(801, 'HR_51243_PER_INFO2_INVALID');
4364       hr_utility.raise_error;
4365       --
4366     end if;
4367  if g_debug then
4368     hr_utility.set_location(l_proc,50);
4369  end if;
4370     --
4371   end if;
4372  if g_debug then
4373   hr_utility.set_location(l_proc, 60);
4374  end if;
4375   --
4376   -- Check if the value for per information3 is set on insert or has
4377   -- changed on update.
4378   --
4379   if (((nvl(p_per_information3,hr_api.g_varchar2) <>
4380         nvl(per_per_shd.g_old_rec.per_information3,hr_api.g_varchar2)
4381                      and p_api_updating) or
4382        (NOT p_api_updating)) and
4383         p_per_information3 is not null)
4384   then
4385     --
4386     --  Check if the per_information3 value is an 11 character date
4387     --  field.
4388     --
4389     l_per_information3 := p_per_information3;
4390     hr_chkfmt.changeformat(input   => l_per_information3
4391                ,output  => l_output
4392                          ,format  => 'D'
4393                          ,curcode => NULL);
4394  if g_debug then
4395     hr_utility.set_location(l_proc, 70);
4396  end if;
4397   end if;
4398  if g_debug then
4399   hr_utility.set_location(l_proc, 80);
4400  end if;
4401   --
4402   -- Check if the value for per information4 is set on insert or has
4403   -- changed on update.
4404   --
4405   if (((nvl(p_per_information4,hr_api.g_varchar2) <>
4406         nvl(per_per_shd.g_old_rec.per_information4,hr_api.g_varchar2)
4407                      and p_api_updating) or
4408        (NOT p_api_updating)) and
4409         p_per_information4 is not null)
4410   then
4411     --
4412     -- Check that per information4 exists in hr_lookups for the
4413     -- lookup type 'US_VISA_TYPE' with an enabled flag set to 'Y'
4414     -- and that the effective start date of the person is between start
4415     -- date active and end date active in hr_lookups.
4416     --
4417     if hr_api.not_exists_in_dt_hr_lookups
4418       (p_effective_date        => p_effective_date
4419       ,p_validation_start_date => p_validation_start_date
4420       ,p_validation_end_date   => p_validation_end_date
4421       ,p_lookup_type           => 'US_VISA_TYPE'
4422       ,p_lookup_code           => p_per_information4
4423       )
4424     then
4425       --
4426       hr_utility.set_message(801, 'HR_51245_PER_INFO4_INVALID');
4427       hr_utility.raise_error;
4428       --
4429     end if;
4430  if g_debug then
4431     hr_utility.set_location(l_proc,90);
4432  end if;
4433     --
4434   end if;
4435  if g_debug then
4436   hr_utility.set_location(l_proc, 100);
4437  end if;
4438   --
4439   -- Check if the value for per information5 is set on insert or has
4440   -- changed on update.
4441   --
4442   if (((nvl(p_per_information5,hr_api.g_varchar2) <>
4443         nvl(per_per_shd.g_old_rec.per_information5,hr_api.g_varchar2)
4444                      and p_api_updating) or
4445        (NOT p_api_updating)) and
4446         p_per_information5 is not null)
4447   then
4448     --
4449     -- Check that per information5 exists in hr_lookups for the
4450     -- lookup type 'US_VISA_TYPE' with an enabled flag set to 'Y'
4451     -- and that the effective start date of the person is between start
4452     -- date active and end date active in hr_lookups.
4453     --
4454     if hr_api.not_exists_in_dt_hr_lookups
4455       (p_effective_date        => p_effective_date
4456       ,p_validation_start_date => p_validation_start_date
4457       ,p_validation_end_date   => p_validation_end_date
4458       ,p_lookup_type           => 'US_VETERAN_STATUS'
4459       ,p_lookup_code           => p_per_information5
4460       )
4461     then
4462       --
4463       hr_utility.set_message(801, 'HR_51246_PER_INFO5_INVALID');
4464       hr_utility.raise_error;
4465       --
4466     end if;
4467  if g_debug then
4468     hr_utility.set_location(l_proc,110);
4469  end if;
4470     --
4471   end if;
4472  if g_debug then
4473   hr_utility.set_location( l_proc, 120);
4474  end if;
4475   --
4476   -- Check if the value for per information6 is set on insert or has
4477   -- changed on update.
4478   --
4479   if (((nvl(p_per_information6,hr_api.g_varchar2) <>
4480         nvl(per_per_shd.g_old_rec.per_information6,hr_api.g_varchar2)
4481                      and p_api_updating) or
4482        (NOT p_api_updating)) and
4483         p_per_information6 is not null)
4484   then
4485     --
4486     -- Check that per information6 exists in hr_lookups for the
4487     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
4488     -- the effective start date of the person is between start date
4489     -- active and end date active in hr_lookups.
4490     --
4491     if hr_api.not_exists_in_dt_hr_lookups
4492       (p_effective_date        => p_effective_date
4493       ,p_validation_start_date => p_validation_start_date
4494       ,p_validation_end_date   => p_validation_end_date
4495       ,p_lookup_type           => 'YES_NO'
4496       ,p_lookup_code           => p_per_information6
4497       )
4498     then
4499       --
4500       hr_utility.set_message(801, 'HR_51247_PER_INFO6_INVALID');
4501       hr_utility.raise_error;
4502       --
4503     end if;
4504  if g_debug then
4505     hr_utility.set_location(l_proc, 130);
4506  end if;
4507     --
4508   end if;
4509  if g_debug then
4510   hr_utility.set_location( l_proc, 140);
4511  end if;
4512   --
4513   -- Check if the value for per information7 is set on insert or has
4514   -- changed on update.
4515   --
4516   if (((nvl(p_per_information7,hr_api.g_varchar2) <>
4517         nvl(per_per_shd.g_old_rec.per_information7,hr_api.g_varchar2)
4518                      and p_api_updating) or
4519        (NOT p_api_updating)) and
4520         p_per_information7 is not null)
4521   then
4522     --
4523     -- Check that per information7 exists in hr_lookups for the
4524     -- lookup type 'US_NEW_HIRE_STATUS' with an enabled flag set to 'Y'
4525     -- and that the effective start date of the person is between start
4526     -- date active and end date active in hr_lookups.
4527     --
4528     if hr_api.not_exists_in_dt_hr_lookups
4529       (p_effective_date        => p_effective_date
4530       ,p_validation_start_date => p_validation_start_date
4531       ,p_validation_end_date   => p_validation_end_date
4532       ,p_lookup_type           => 'US_NEW_HIRE_STATUS'
4533       ,p_lookup_code           => p_per_information7
4534       )
4535     then
4536       --
4537       hr_utility.set_message(801, 'HR_51285_PER_INFO7_INVALID');
4538       hr_utility.raise_error;
4539       --
4540     end if;
4541  if g_debug then
4542     hr_utility.set_location(l_proc,150);
4543  end if;
4544     --
4545   end if;
4546  if g_debug then
4547   hr_utility.set_location( l_proc, 160);
4548  end if;
4549   --
4550   -- Check if the value for per information8 is set on insert or has
4551   -- changed on update.
4552   --
4553   if (((nvl(p_per_information8,hr_api.g_varchar2) <>
4554         nvl(per_per_shd.g_old_rec.per_information8,hr_api.g_varchar2)
4555                      and p_api_updating) or
4556        (NOT p_api_updating)) and
4557         p_per_information8 is not null)
4558   then
4559     --
4560     -- Check if per information7 is 'EXCL'
4561     --
4562     if nvl(p_per_information7,hr_api.g_varchar2) <> 'EXCL'
4563     then
4564       --
4565       -- Error: Field must be null because per_info7 is not 'EXCL'
4566       --
4567       hr_utility.set_message(801, 'HR_51286_PER_INFO8_NOT_NULL');
4568       hr_utility.raise_error;
4569     else
4570       --
4571       -- Check that per information7 exists in hr_lookups for the
4572       -- lookup type 'US_NEW_HIRE_EXCEPTIONS' with an enabled flag set to 'Y'
4573       -- and that the effective start date of the person is between start
4574       -- date active and end date active in hr_lookups.
4575       --
4576       if hr_api.not_exists_in_dt_hr_lookups
4577         (p_effective_date        => p_effective_date
4578         ,p_validation_start_date => p_validation_start_date
4579         ,p_validation_end_date   => p_validation_end_date
4580         ,p_lookup_type           => 'US_NEW_HIRE_EXCEPTIONS'
4581         ,p_lookup_code           => p_per_information8
4582         )
4583       then
4584         --
4585         hr_utility.set_message(801, 'HR_51287_PER_INFO8_INVALID');
4586         hr_utility.raise_error;
4587         --
4588       end if;
4589  if g_debug then
4590       hr_utility.set_location( l_proc, 170);
4591  end if;
4592       --
4593     end if;
4594   end if;
4595  if g_debug then
4596   hr_utility.set_location( l_proc, 180);
4597  end if;
4598   --
4599   -- Check if the value for per information9 is set on insert or has
4600   -- changed on update.
4601   --
4602   if (((nvl(p_per_information9,hr_api.g_varchar2) <>
4603         nvl(per_per_shd.g_old_rec.per_information9,hr_api.g_varchar2)
4604                      and p_api_updating) or
4605        (NOT p_api_updating)) and
4606         p_per_information9 is not null)
4607   then
4608     --
4609     -- Check that per information9 exists in hr_lookups for the
4610     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
4611     -- the effective start date of the person is between start date
4612     -- active and end date active in hr_lookups.
4613     --
4614     if hr_api.not_exists_in_dt_hr_lookups
4615       (p_effective_date        => p_effective_date
4616       ,p_validation_start_date => p_validation_start_date
4617       ,p_validation_end_date   => p_validation_end_date
4618       ,p_lookup_type           => 'YES_NO'
4619       ,p_lookup_code           => p_per_information9
4620       )
4621     then
4622       --
4623       hr_utility.set_message(801, 'HR_51288_PER_INFO9_INVALID');
4624       hr_utility.raise_error;
4625       --
4626     end if;
4627  if g_debug then
4628     hr_utility.set_location(l_proc, 190);
4629  end if;
4630     --
4631   end if;
4632  if g_debug then
4633   hr_utility.set_location( l_proc, 200);
4634  end if;
4635   --
4636   if (((nvl(p_per_information10,hr_api.g_varchar2) <>
4637         nvl(per_per_shd.g_old_rec.per_information10,hr_api.g_varchar2)
4638                      and p_api_updating) or
4639        (NOT p_api_updating)) and
4640         p_per_information10 is not null)
4641   then
4642     --
4643     -- Check that per information10 exists in hr_lookups for the
4644     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
4645     -- the effective start date of the person is between start date
4646     -- active and end date active in hr_lookups.
4647     --
4648     if hr_api.not_exists_in_dt_hr_lookups
4649       (p_effective_date        => p_effective_date
4650       ,p_validation_start_date => p_validation_start_date
4651       ,p_validation_end_date   => p_validation_end_date
4652       ,p_lookup_type           => 'YES_NO'
4653       ,p_lookup_code           => p_per_information10
4654       )
4655     then
4656       --
4657       hr_utility.set_message(801, 'PER_52390_PER_INFO10_INVALID');
4658       hr_utility.raise_error;
4659       --
4660     end if;
4661  if g_debug then
4662     hr_utility.set_location(l_proc,210);
4663  end if;
4664     --
4665   end if;
4666  if g_debug then
4667   hr_utility.set_location(l_proc,220);
4668  end if;
4669 
4670 
4671   --  Check if any of the remaining per_information parameters are not
4672   --  null
4673   --  (developer descriptive flexfields not used for US)
4674   --
4675 
4676   -- TM removed check for p_per_information10 now that it is being used.
4677   -- Removed check for p_per_infomation11 for the bug#
4678 
4679   /* if p_per_information11 is not null then
4680     l_info_attribute := 11;
4681     raise l_error;*/
4682   -- ***** Start commented code for bug 5917391 *************
4683   /*if p_per_information12 is not null then
4684     l_info_attribute := 12;
4685     raise l_error;
4686   elsif p_per_information13 is not null then
4687     l_info_attribute := 13;
4688     raise l_error;
4689   elsif p_per_information14 is not null then
4690     l_info_attribute := 14;
4691     raise l_error;*/
4692   -- ***** End commented code for bug 5917391 *************
4693   if p_per_information15 is not null then
4694     l_info_attribute := 15;
4695     raise l_error;
4696   elsif p_per_information16 is not null then
4697     l_info_attribute := 16;
4698     raise l_error;
4699   elsif p_per_information17 is not null then
4700     l_info_attribute := 17;
4701     raise l_error;
4702   elsif p_per_information18 is not null then
4703     l_info_attribute := 18;
4704     raise l_error;
4705   elsif p_per_information19 is not null then
4706     l_info_attribute := 19;
4707     raise l_error;
4708   elsif p_per_information20 is not null then
4709     l_info_attribute := 20;
4710     raise l_error;
4711  -- end if;
4712   elsif p_per_information21 is not null then
4713     l_info_attribute := 21;
4714     raise l_error;
4715   elsif p_per_information22 is not null then
4716     l_info_attribute := 22;
4717     raise l_error;
4718   elsif p_per_information23 is not null then
4719     l_info_attribute := 23;
4720     raise l_error;
4721   elsif p_per_information24 is not null then
4722     l_info_attribute := 24;
4723     raise l_error;
4724 -- Commenting null check for p_per_information25, p_per_information26 as
4725 -- these are used for Employee Referral Functionality
4726 --  Removed check for p_per_infomation25 for the bug# 8722991. Also reverted Employee Referral Check.
4727 --  elsif p_per_information25 is not null then
4728 --    l_info_attribute := 25;
4729 --    raise l_error;
4730   elsif p_per_information26 is not null then
4731     l_info_attribute := 26;
4732     raise l_error;
4733 -- End of Commenting for Employee Referral
4734   elsif p_per_information27 is not null then
4735     l_info_attribute := 27;
4736     raise l_error;
4737   elsif p_per_information28 is not null then
4738     l_info_attribute := 28;
4739     raise l_error;
4740   elsif p_per_information29 is not null then
4741     l_info_attribute := 29;
4742     raise l_error;
4743   elsif p_per_information30 is not null then
4744     l_info_attribute := 30;
4745     raise l_error;
4746   end if;
4747  if g_debug then
4748   hr_utility.set_location('Leaving:'|| l_proc, 230);
4749  end if;
4750 exception
4751     when l_error then
4752       --  Error: Do not enter PER_INFORMATION99 for this legislation
4753       hr_utility.set_message(801, 'HR_7529_PER_INFO_NOT_NULL');
4754       hr_utility.set_message_token('NUM',to_char(l_info_attribute));
4755       hr_utility.raise_error;
4756 end chk_US_per_information;
4757 --
4758 -- ----------------------------------------------------------------------------
4759 -- |------------------------<chk_JP_per_information  >------------------------|
4760 -- ----------------------------------------------------------------------------
4761 
4762 procedure chk_JP_per_information
4763   (p_person_id                in     per_all_people_f.person_id%TYPE
4764   ,p_per_information_category in     per_all_people_f.per_information_category%TYPE
4765   ,p_per_information1         in     per_all_people_f.per_information1%TYPE
4766   ,p_per_information2         in     per_all_people_f.per_information2%TYPE
4767   ,p_per_information3         in     per_all_people_f.per_information3%TYPE
4768   ,p_per_information4         in     per_all_people_f.per_information4%TYPE
4769   ,p_per_information5         in     per_all_people_f.per_information5%TYPE
4770   ,p_per_information6         in     per_all_people_f.per_information6%TYPE
4771   ,p_per_information7         in     per_all_people_f.per_information7%TYPE
4772   ,p_per_information8         in     per_all_people_f.per_information8%TYPE
4773   ,p_per_information9         in     per_all_people_f.per_information9%TYPE
4774   ,p_per_information10        in     per_all_people_f.per_information10%TYPE
4775   ,p_per_information11        in     per_all_people_f.per_information11%TYPE
4776   ,p_per_information12        in     per_all_people_f.per_information12%TYPE
4777   ,p_per_information13        in     per_all_people_f.per_information13%TYPE
4778   ,p_per_information14        in     per_all_people_f.per_information14%TYPE
4779   ,p_per_information15        in     per_all_people_f.per_information15%TYPE
4780   ,p_per_information16        in     per_all_people_f.per_information16%TYPE
4781   ,p_per_information17        in     per_all_people_f.per_information17%TYPE
4782   ,p_per_information18        in     per_all_people_f.per_information18%TYPE
4783   ,p_per_information19        in     per_all_people_f.per_information19%TYPE
4784   ,p_per_information20        in     per_all_people_f.per_information20%TYPE
4785   ,p_per_information21        in     per_all_people_f.per_information21%TYPE
4786   ,p_per_information22        in     per_all_people_f.per_information22%TYPE
4787   ,p_per_information23        in     per_all_people_f.per_information23%TYPE
4788   ,p_per_information24        in     per_all_people_f.per_information24%TYPE
4789   ,p_per_information25        in     per_all_people_f.per_information25%TYPE
4790   ,p_per_information26        in     per_all_people_f.per_information26%TYPE
4791   ,p_per_information27        in     per_all_people_f.per_information27%TYPE
4792   ,p_per_information28        in     per_all_people_f.per_information28%TYPE
4793   ,p_per_information29        in     per_all_people_f.per_information29%TYPE
4794   ,p_per_information30        in     per_all_people_f.per_information30%TYPE
4795   ,p_effective_date           in     date
4796   ,p_validation_start_date    in     date
4797   ,p_validation_end_date      in     date
4798   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
4799   ) is
4800 
4801   l_error          exception;
4802   l_proc           varchar2(72)  :=  g_package||'chk_JP_per_information';
4803   l_info_attribute number(2);
4804   --
4805 begin
4806  if g_debug then
4807   hr_utility.set_location('Entering:'|| l_proc, 10);
4808  end if;
4809   --
4810   -- Check the mandatory parameters
4811   --
4812    hr_api.mandatory_arg_error
4813     (p_api_name       =>  l_proc
4814     ,p_argument       =>  'effective_date'
4815     ,p_argument_value =>  p_effective_date
4816     );
4817   --
4818   hr_api.mandatory_arg_error
4819     (p_api_name       =>  l_proc
4820     ,p_argument       =>  'validation_start_date'
4821     ,p_argument_value =>  p_validation_start_date
4822     );
4823   --
4824   hr_api.mandatory_arg_error
4825     (p_api_name        =>  l_proc
4826     ,p_argument       =>  'validation_end_date'
4827     ,p_argument_value =>  p_validation_end_date
4828     );
4829  if g_debug then
4830   hr_utility.set_location(l_proc,20);
4831  end if;
4832   --
4833   -- We know the per_information_category is JP, so check the rest of
4834   -- the per_information fields within this context.
4835   --
4836   --  Check if the per_information1 value exists in hr_lookups
4837   --  where the lookup_type is 'YES_NO'
4838   --
4839   if p_per_information1 is not null then
4840     --
4841     -- Check that per information1 exists in hr_lookups for the
4842     -- lookup type 'YES_NO' with an enabled flag set to 'Y' and that
4843     -- the effective start date of the person is between start date
4844     -- active and end date active in hr_lookups.
4845     --
4846     if hr_api.not_exists_in_dt_hr_lookups
4847       (p_effective_date        => p_effective_date
4848       ,p_validation_start_date => p_validation_start_date
4849       ,p_validation_end_date   => p_validation_end_date
4850       ,p_lookup_type           => 'YES_NO'
4851       ,p_lookup_code           => p_per_information1
4852       )
4853     then
4854       --
4855       hr_utility.set_message(801, 'HR_72022_PER_INFO1_INVALID');
4856       hr_utility.raise_error;
4857       --
4858     end if;
4859  if g_debug then
4860     hr_utility.set_location(l_proc,30);
4861  end if;
4862     --
4863   end if;
4864  if g_debug then
4865   hr_utility.set_location(l_proc,40);
4866  end if;
4867   --
4868   --  Check if the per_information2 value exists in hr_lookups
4869   --  where the lookup_type is 'JP_TERM_LOCAL_TAX_PAYMENT_TYPE'
4870   --
4871   if p_per_information2 is not null then
4872     --
4873     -- Check that per information2 exists in hr_lookups for the
4874     -- lookup type 'JP_TERM_LOCAL_TAX_PAYMENT_TYPE' with an enabled
4875     -- flag set to 'Y' and that
4876     -- the effective start date of the person is between start date
4877     -- active and end date active in hr_lookups.
4878     --
4879     if hr_api.not_exists_in_dt_hr_lookups
4880       (p_effective_date        => p_effective_date
4881       ,p_validation_start_date => p_validation_start_date
4882       ,p_validation_end_date   => p_validation_end_date
4883       ,p_lookup_type           => 'JP_TERM_LOCAL_TAX_PAYMENT_TYPE'
4884       ,p_lookup_code           => p_per_information2
4885       )
4886     then
4887       --
4888       hr_utility.set_message(801, 'HR_72023_PER_INFO2_INVALID');
4889       hr_utility.raise_error;
4890       --
4891     end if;
4892  if g_debug then
4893     hr_utility.set_location(l_proc,50);
4894  end if;
4895     --
4896   end if;
4897  if g_debug then
4898   hr_utility.set_location(l_proc,60);
4899  end if;
4900   --
4901   --
4902   --  Check if any of the remaining per_information parameters are not
4903   --  null
4904   --  (developer descriptive flexfields not used for JP)
4905   --
4906 
4907   if p_per_information3 is not null then
4908     l_info_attribute := 3;
4909     raise l_error;
4910   elsif p_per_information4 is not null then
4911     l_info_attribute := 4;
4912     raise l_error;
4913   elsif p_per_information5 is not null then
4914     l_info_attribute := 5;
4915     raise l_error;
4916   elsif p_per_information6 is not null then
4917     l_info_attribute := 6;
4918     raise l_error;
4919   elsif p_per_information7 is not null then
4920     l_info_attribute := 7;
4921     raise l_error;
4922   elsif p_per_information8 is not null then
4923     l_info_attribute := 8;
4924     raise l_error;
4925   elsif p_per_information9 is not null then
4926     l_info_attribute := 9;
4927     raise l_error;
4928   elsif p_per_information10 is not null then
4929     l_info_attribute := 10;
4930     raise l_error;
4931   elsif p_per_information11 is not null then
4932     l_info_attribute := 11;
4933     raise l_error;
4934   elsif p_per_information12 is not null then
4935     l_info_attribute := 12;
4936     raise l_error;
4937   elsif p_per_information13 is not null then
4938     l_info_attribute := 13;
4939     raise l_error;
4940   elsif p_per_information14 is not null then
4941     l_info_attribute := 14;
4942     raise l_error;
4943   elsif p_per_information15 is not null then
4944     l_info_attribute := 15;
4945     raise l_error;
4946   elsif p_per_information16 is not null then
4947     l_info_attribute := 16;
4948     raise l_error;
4949   elsif p_per_information17 is not null then
4950     l_info_attribute := 17;
4951     raise l_error;
4952   end if;
4953  if g_debug then
4954   hr_utility.set_location(' Leaving:'|| l_proc, 210);
4955  end if;
4956 exception
4957     when l_error then
4958       hr_utility.set_message(801, 'HR_7529_PER_INFO_NOT_NULL');
4959       hr_utility.set_message_token('NUM',to_char(l_info_attribute));
4960       hr_utility.raise_error;
4961 end chk_JP_per_information;
4962 --
4963 --
4964 -- -----------------------------------------------------------------------------
4965 -- |-------------------------------< chk_ddf >---------------------------------|
4966 -- -----------------------------------------------------------------------------
4967 --
4968 procedure chk_ddf
4969   (p_rec   in per_per_shd.g_rec_type) is
4970 --
4971   l_proc       varchar2(72);
4972   l_error      exception;
4973 --
4974 Begin
4975  if g_debug then
4976   l_proc := g_package||'chk_ddf';
4977   hr_utility.set_location('Entering:'||l_proc, 5);
4978  end if;
4979   --
4980   -- Check if the row is being inserted or updated and a
4981   -- value has changed
4982   --
4983   if (p_rec.person_id is null)
4984     or ((p_rec.person_id is not null)
4985     and
4986     nvl(per_per_shd.g_old_rec.per_information_category, hr_api.g_varchar2) <>
4987     nvl(p_rec.per_information_category, hr_api.g_varchar2) or
4988     nvl(per_per_shd.g_old_rec.per_information1, hr_api.g_varchar2) <>
4989     nvl(p_rec.per_information1, hr_api.g_varchar2) or
4990     nvl(per_per_shd.g_old_rec.per_information2, hr_api.g_varchar2) <>
4991     nvl(p_rec.per_information2, hr_api.g_varchar2) or
4992     nvl(per_per_shd.g_old_rec.per_information3, hr_api.g_varchar2) <>
4993     nvl(p_rec.per_information3, hr_api.g_varchar2) or
4994     nvl(per_per_shd.g_old_rec.per_information4, hr_api.g_varchar2) <>
4995     nvl(p_rec.per_information4, hr_api.g_varchar2) or
4996     nvl(per_per_shd.g_old_rec.per_information5, hr_api.g_varchar2) <>
4997     nvl(p_rec.per_information5, hr_api.g_varchar2) or
4998     nvl(per_per_shd.g_old_rec.per_information6, hr_api.g_varchar2) <>
4999     nvl(p_rec.per_information6, hr_api.g_varchar2) or
5000     nvl(per_per_shd.g_old_rec.per_information7, hr_api.g_varchar2) <>
5001     nvl(p_rec.per_information7, hr_api.g_varchar2) or
5002     nvl(per_per_shd.g_old_rec.per_information8, hr_api.g_varchar2) <>
5003     nvl(p_rec.per_information8, hr_api.g_varchar2) or
5004     nvl(per_per_shd.g_old_rec.per_information9, hr_api.g_varchar2) <>
5005     nvl(p_rec.per_information9, hr_api.g_varchar2) or
5006     nvl(per_per_shd.g_old_rec.per_information10, hr_api.g_varchar2) <>
5007     nvl(p_rec.per_information10, hr_api.g_varchar2) or
5008     nvl(per_per_shd.g_old_rec.per_information11, hr_api.g_varchar2) <>
5009     nvl(p_rec.per_information11, hr_api.g_varchar2) or
5010     nvl(per_per_shd.g_old_rec.per_information12, hr_api.g_varchar2) <>
5011     nvl(p_rec.per_information12, hr_api.g_varchar2) or
5012     nvl(per_per_shd.g_old_rec.per_information13, hr_api.g_varchar2) <>
5013     nvl(p_rec.per_information13, hr_api.g_varchar2) or
5014     nvl(per_per_shd.g_old_rec.per_information14, hr_api.g_varchar2) <>
5015     nvl(p_rec.per_information14, hr_api.g_varchar2) or
5016     nvl(per_per_shd.g_old_rec.per_information15, hr_api.g_varchar2) <>
5017     nvl(p_rec.per_information15, hr_api.g_varchar2) or
5018     nvl(per_per_shd.g_old_rec.per_information16, hr_api.g_varchar2) <>
5019     nvl(p_rec.per_information16, hr_api.g_varchar2) or
5020     nvl(per_per_shd.g_old_rec.per_information17, hr_api.g_varchar2) <>
5021     nvl(p_rec.per_information17, hr_api.g_varchar2) or
5022     nvl(per_per_shd.g_old_rec.per_information18, hr_api.g_varchar2) <>
5023     nvl(p_rec.per_information18, hr_api.g_varchar2) or
5024     nvl(per_per_shd.g_old_rec.per_information19, hr_api.g_varchar2) <>
5025     nvl(p_rec.per_information19, hr_api.g_varchar2) or
5026     nvl(per_per_shd.g_old_rec.per_information20, hr_api.g_varchar2) <>
5027     nvl(p_rec.per_information20, hr_api.g_varchar2) or
5028     nvl(per_per_shd.g_old_rec.per_information21, hr_api.g_varchar2) <>
5029     nvl(p_rec.per_information21, hr_api.g_varchar2) or
5030     nvl(per_per_shd.g_old_rec.per_information22, hr_api.g_varchar2) <>
5031     nvl(p_rec.per_information22, hr_api.g_varchar2) or
5032     nvl(per_per_shd.g_old_rec.per_information23, hr_api.g_varchar2) <>
5033     nvl(p_rec.per_information23, hr_api.g_varchar2) or
5034     nvl(per_per_shd.g_old_rec.per_information24, hr_api.g_varchar2) <>
5035     nvl(p_rec.per_information24, hr_api.g_varchar2) or
5036     nvl(per_per_shd.g_old_rec.per_information25, hr_api.g_varchar2) <>
5037     nvl(p_rec.per_information25, hr_api.g_varchar2) or
5038     nvl(per_per_shd.g_old_rec.per_information26, hr_api.g_varchar2) <>
5039     nvl(p_rec.per_information26, hr_api.g_varchar2) or
5040     nvl(per_per_shd.g_old_rec.per_information27, hr_api.g_varchar2) <>
5041     nvl(p_rec.per_information27, hr_api.g_varchar2) or
5042     nvl(per_per_shd.g_old_rec.per_information28, hr_api.g_varchar2) <>
5043     nvl(p_rec.per_information28, hr_api.g_varchar2) or
5044     nvl(per_per_shd.g_old_rec.per_information29, hr_api.g_varchar2) <>
5045     nvl(p_rec.per_information29, hr_api.g_varchar2) or
5046     nvl(per_per_shd.g_old_rec.per_information30, hr_api.g_varchar2) <>
5047     nvl(p_rec.per_information30, hr_api.g_varchar2))
5048   then
5049     --
5050     hr_dflex_utility.ins_or_upd_descflex_attribs
5051       (p_appl_short_name    => 'PER'
5052       ,p_descflex_name      => 'Person Developer DF'
5053       ,p_attribute_category => p_rec.per_information_category
5054       ,p_attribute1_name    => 'PER_INFORMATION1'
5055       ,p_attribute1_value   => p_rec.per_information1
5056       ,p_attribute2_name    => 'PER_INFORMATION2'
5057       ,p_attribute2_value   => p_rec.per_information2
5058       ,p_attribute3_name    => 'PER_INFORMATION3'
5059       ,p_attribute3_value   => p_rec.per_information3
5060       ,p_attribute4_name    => 'PER_INFORMATION4'
5061       ,p_attribute4_value   => p_rec.per_information4
5062       ,p_attribute5_name    => 'PER_INFORMATION5'
5063       ,p_attribute5_value   => p_rec.per_information5
5064       ,p_attribute6_name    => 'PER_INFORMATION6'
5065       ,p_attribute6_value   => p_rec.per_information6
5066       ,p_attribute7_name    => 'PER_INFORMATION7'
5067       ,p_attribute7_value   => p_rec.per_information7
5068       ,p_attribute8_name    => 'PER_INFORMATION8'
5069       ,p_attribute8_value   => p_rec.per_information8
5070       ,p_attribute9_name    => 'PER_INFORMATION9'
5071       ,p_attribute9_value   => p_rec.per_information9
5072       ,p_attribute10_name   => 'PER_INFORMATION10'
5073       ,p_attribute10_value  => p_rec.per_information10
5074       ,p_attribute11_name   => 'PER_INFORMATION11'
5075       ,p_attribute11_value  => p_rec.per_information11
5076       ,p_attribute12_name   => 'PER_INFORMATION12'
5077       ,p_attribute12_value  => p_rec.per_information12
5078       ,p_attribute13_name   => 'PER_INFORMATION13'
5079       ,p_attribute13_value  => p_rec.per_information13
5080       ,p_attribute14_name   => 'PER_INFORMATION14'
5081       ,p_attribute14_value  => p_rec.per_information14
5082       ,p_attribute15_name   => 'PER_INFORMATION15'
5083       ,p_attribute15_value  => p_rec.per_information15
5084       ,p_attribute16_name   => 'PER_INFORMATION16'
5085       ,p_attribute16_value  => p_rec.per_information16
5086       ,p_attribute17_name   => 'PER_INFORMATION17'
5087       ,p_attribute17_value  => p_rec.per_information17
5088       ,p_attribute18_name   => 'PER_INFORMATION18'
5089       ,p_attribute18_value  => p_rec.per_information18
5090       ,p_attribute19_name   => 'PER_INFORMATION19'
5091       ,p_attribute19_value  => p_rec.per_information19
5092       ,p_attribute20_name   => 'PER_INFORMATION20'
5093       ,p_attribute20_value  => p_rec.per_information20
5094       ,p_attribute21_name   => 'PER_INFORMATION21'
5095       ,p_attribute21_value  => p_rec.per_information21
5096       ,p_attribute22_name   => 'PER_INFORMATION22'
5097       ,p_attribute22_value  => p_rec.per_information22
5098       ,p_attribute23_name   => 'PER_INFORMATION23'
5099       ,p_attribute23_value  => p_rec.per_information23
5100       ,p_attribute24_name   => 'PER_INFORMATION24'
5101       ,p_attribute24_value  => p_rec.per_information24
5102       ,p_attribute25_name   => 'PER_INFORMATION25'
5103       ,p_attribute25_value  => p_rec.per_information25
5104       ,p_attribute26_name   => 'PER_INFORMATION26'
5105       ,p_attribute26_value  => p_rec.per_information26
5106       ,p_attribute27_name   => 'PER_INFORMATION27'
5107       ,p_attribute27_value  => p_rec.per_information27
5108       ,p_attribute28_name   => 'PER_INFORMATION28'
5109       ,p_attribute28_value  => p_rec.per_information28
5110       ,p_attribute29_name   => 'PER_INFORMATION29'
5111       ,p_attribute29_value  => p_rec.per_information29
5112       ,p_attribute30_name   => 'PER_INFORMATION30'
5113       ,p_attribute30_value  => p_rec.per_information30
5114       );
5115     --
5116   end if;
5117   --
5118  if g_debug then
5119   hr_utility.set_location(' Leaving:'||l_proc, 10);
5120  end if;
5121 end chk_ddf;
5122 --  ---------------------------------------------------------------------------
5123 --  |-----------------------<  chk_per_information >--------------------------|
5124 --  ---------------------------------------------------------------------------
5125 --
5126 --  Description:
5127 --    Checks that the values held in developer descriptive flexfields
5128 --    are valid
5129 --
5130 --    This routine calls separate local validation procedures to perform
5131 --    validation for each specific category. At present the suppported
5132 --    categories are 'GB', 'US' and 'JP'
5133 
5134 --  Pre-conditions:
5135 --    None
5136 --
5137 --  In Arguments:
5138 --    p_person_id
5139 --    p_per_information_category
5140 --    p_per_information1
5141 --    p_per_information2
5142 --    p_per_information3
5143 --    p_per_information4
5144 --    p_per_information5
5145 --    p_per_information6
5146 --    p_per_information7
5147 --    p_per_information8
5148 --    p_per_information9
5149 --    p_per_information10
5150 --    p_per_information11
5151 --    p_per_information12
5152 --    p_per_information13
5153 --    p_per_information14
5154 --    p_per_information15
5155 --    p_per_information16
5156 --    p_per_information17
5157 --    p_per_information18
5158 --    p_per_information19
5159 --    p_per_information20
5160 --    p_per_information21
5161 --    p_per_information22
5162 --    p_per_information23
5163 --    p_per_information24
5164 --    p_per_information25
5165 --    p_per_information26
5166 --    p_per_information27
5167 --    p_per_information28
5168 --    p_per_information29
5169 --    p_per_information30
5170 --    p_effective_date
5171 --    p_object_version_number
5172 --
5173 --  Post Success:
5174 --    If the value in per_information_category value is 'GB' or 'US' then
5175 --    processing continues
5176 --
5177 --  Post Failure:
5178 --    If the value in per_information_category value is not 'GB' or 'US' then
5179 --    an application error will be raised and processing is terminated
5180 --
5181 --  Access Status:
5182 --    Internal Table Handler Use Only.
5183 --
5184 procedure chk_per_information
5185   (p_rec             in out nocopy per_per_shd.g_rec_type
5186   ,p_effective_date           in     date
5187   ,p_validation_start_date    in     date
5188   ,p_validation_end_date      in     date) is
5189 --
5190   l_exists         varchar2(1);
5191   l_error          exception;
5192   l_proc           varchar2(72)  :=  g_package||'chk_per_information';
5193   l_api_updating   boolean;
5194   l_lookup_type    varchar2(30);
5195   l_info_attribute number(2);
5196 --
5197 begin
5198  if g_debug then
5199   hr_utility.set_location('Entering:'|| l_proc, 10);
5200  end if;
5201   --
5202   -- Check mandatory parameters have been set
5203   --
5204   hr_api.mandatory_arg_error
5205     (p_api_name       => l_proc
5206     ,p_argument       => 'effective date'
5207     ,p_argument_value => p_effective_date
5208     );
5209   --
5210   hr_api.mandatory_arg_error
5211     (p_api_name       =>  l_proc
5212     ,p_argument       =>  'validation_start_date'
5213     ,p_argument_value =>  p_validation_start_date
5214     );
5215   --
5216   hr_api.mandatory_arg_error
5217     (p_api_name        =>  l_proc
5218     ,p_argument       =>  'validation_end_date'
5219     ,p_argument_value =>  p_validation_end_date
5220     );
5221  if g_debug then
5222   hr_utility.set_location(l_proc, 20);
5223  end if;
5224   --
5225   --  Only proceed with validation if:
5226   --  a) The current g_old_rec is current and
5227   --  b) Any of the per_information (developer descriptive flex) values have
5228   --     changed
5229   --  c) A record is being inserted
5230   --
5231   l_api_updating := per_per_shd.api_updating
5232     (p_person_id             => p_rec.person_id
5233     ,p_effective_date        => p_effective_date
5234     ,p_object_version_number => p_rec.object_version_number
5235     );
5236  if g_debug then
5237   hr_utility.set_location(l_proc, 30);
5238  end if;
5239   --
5240   if ((l_api_updating and nvl(per_per_shd.g_old_rec.per_information_category,
5241                               hr_api.g_varchar2)
5242     <> nvl(p_rec.per_information_category,hr_api.g_varchar2)) or
5243     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information1,
5244                             hr_api.g_varchar2)
5245     <> nvl(p_rec.per_information1,hr_api.g_varchar2)) or
5246     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information2,
5247                             hr_api.g_varchar2)
5248     <> nvl(p_rec.per_information2,hr_api.g_varchar2)) or
5249     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information3,
5250                             hr_api.g_varchar2)
5251     <> nvl(p_rec.per_information3,hr_api.g_varchar2)) or
5252     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information4,
5253                             hr_api.g_varchar2)
5254     <> nvl(p_rec.per_information4,hr_api.g_varchar2)) or
5255     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information5,
5256                             hr_api.g_varchar2)
5257     <> nvl(p_rec.per_information5,hr_api.g_varchar2)) or
5258     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information6,
5259                             hr_api.g_varchar2)
5260     <> nvl(p_rec.per_information6,hr_api.g_varchar2)) or
5261     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information7,
5262                             hr_api.g_varchar2)
5263     <> nvl(p_rec.per_information7,hr_api.g_varchar2)) or
5264     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information8,
5265                             hr_api.g_varchar2)
5266     <> nvl(p_rec.per_information8,hr_api.g_varchar2)) or
5267     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information9,
5268                             hr_api.g_varchar2)
5269     <> nvl(p_rec.per_information9,hr_api.g_varchar2)) or
5270     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information10,
5271                             hr_api.g_varchar2)
5272     <> nvl(p_rec.per_information10,hr_api.g_varchar2)) or
5273     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information11,
5274                             hr_api.g_varchar2)
5275     <> nvl(p_rec.per_information11,hr_api.g_varchar2)) or
5276     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information12,
5277                             hr_api.g_varchar2)
5278     <> nvl(p_rec.per_information12,hr_api.g_varchar2)) or
5279     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information13,
5280                             hr_api.g_varchar2)
5281     <> nvl(p_rec.per_information13,hr_api.g_varchar2)) or
5282     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information14,
5283                             hr_api.g_varchar2)
5284     <> nvl(p_rec.per_information14,hr_api.g_varchar2)) or
5285     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information15,
5286                             hr_api.g_varchar2)
5287     <> nvl(p_rec.per_information15,hr_api.g_varchar2)) or
5288     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information16,
5289                             hr_api.g_varchar2)
5290     <> nvl(p_rec.per_information16,hr_api.g_varchar2)) or
5291     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information17,
5292                             hr_api.g_varchar2)
5293     <> nvl(p_rec.per_information17,hr_api.g_varchar2)) or
5294     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information18,
5295                             hr_api.g_varchar2)
5296     <> nvl(p_rec.per_information18,hr_api.g_varchar2)) or
5297     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information19,
5298                             hr_api.g_varchar2)
5299     <> nvl(p_rec.per_information19,hr_api.g_varchar2)) or
5300     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information20,
5301                             hr_api.g_varchar2)
5302     <> nvl(p_rec.per_information20,hr_api.g_varchar2)) or
5303     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information21,
5304                             hr_api.g_varchar2)
5305     <> nvl(p_rec.per_information21,hr_api.g_varchar2)) or
5306     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information22,
5307                             hr_api.g_varchar2)
5308     <> nvl(p_rec.per_information22,hr_api.g_varchar2)) or
5309     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information23,
5310                             hr_api.g_varchar2)
5311     <> nvl(p_rec.per_information23,hr_api.g_varchar2)) or
5312     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information24,
5313                             hr_api.g_varchar2)
5314     <> nvl(p_rec.per_information24,hr_api.g_varchar2)) or
5315     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information25,
5316                             hr_api.g_varchar2)
5317     <> nvl(p_rec.per_information25,hr_api.g_varchar2)) or
5318     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information26,
5319                             hr_api.g_varchar2)
5320     <> nvl(p_rec.per_information26,hr_api.g_varchar2)) or
5321     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information27,
5322                             hr_api.g_varchar2)
5323     <> nvl(p_rec.per_information27,hr_api.g_varchar2)) or
5324     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information28,
5325                             hr_api.g_varchar2)
5326     <> nvl(p_rec.per_information28,hr_api.g_varchar2)) or
5327     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information29,
5328                             hr_api.g_varchar2)
5329     <> nvl(p_rec.per_information29,hr_api.g_varchar2)) or
5330     (l_api_updating and nvl(per_per_shd.g_old_rec.per_information30,
5331                             hr_api.g_varchar2)
5332     <> nvl(p_rec.per_information30,hr_api.g_varchar2)) or
5333     (NOT l_api_updating))
5334   then
5335  if g_debug then
5336     hr_utility.set_location(l_proc, 40);
5337  end if;
5338     --
5339     --  Check if the per_information_category is 'GB' or 'US' calling
5340     --  the appropriate validation routine or generating an error
5341     --
5342 --    If p_rec.per_information_category is not null then
5343       If p_rec.per_information_category = 'GB' then
5344         --
5345         -- GB specific validation.
5346         --
5347         per_per_bus.chk_GB_per_information
5348           (p_person_id                 => p_rec.person_id
5349           ,p_per_information_category  => p_rec.per_information_category
5350           ,p_per_information1          => p_rec.per_information1
5351           ,p_per_information2          => p_rec.per_information2
5352           ,p_per_information3          => p_rec.per_information3
5353           ,p_per_information4          => p_rec.per_information4
5354           ,p_per_information5          => p_rec.per_information5
5355           ,p_per_information6          => p_rec.per_information6
5356           ,p_per_information7          => p_rec.per_information7
5357           ,p_per_information8          => p_rec.per_information8
5358           ,p_per_information9          => p_rec.per_information9
5359           ,p_per_information10         => p_rec.per_information10
5360           ,p_per_information11         => p_rec.per_information11
5361           ,p_per_information12         => p_rec.per_information12
5362           ,p_per_information13         => p_rec.per_information13
5363           ,p_per_information14         => p_rec.per_information14
5364           ,p_per_information15         => p_rec.per_information15
5365           ,p_per_information16         => p_rec.per_information16
5366           ,p_per_information17         => p_rec.per_information17
5367           ,p_per_information18         => p_rec.per_information18
5368           ,p_per_information19         => p_rec.per_information19
5369           ,p_per_information20         => p_rec.per_information20
5370           ,p_per_information21         => p_rec.per_information21
5371           ,p_per_information22         => p_rec.per_information22
5372           ,p_per_information23         => p_rec.per_information23
5373           ,p_per_information24         => p_rec.per_information24
5374           ,p_per_information25         => p_rec.per_information25
5375           ,p_per_information26         => p_rec.per_information26
5376           ,p_per_information27         => p_rec.per_information27
5377           ,p_per_information28         => p_rec.per_information28
5378           ,p_per_information29         => p_rec.per_information29
5379           ,p_per_information30         => p_rec.per_information30
5380           ,p_validation_start_date     => p_validation_start_date
5381           ,p_validation_end_date       => p_validation_end_date
5382           ,p_effective_date            => p_effective_date
5383           ,p_object_version_number     => p_rec.object_version_number
5384           );
5385  if g_debug then
5386           hr_utility.set_location(l_proc, 50);
5387  end if;
5388           --
5389       elsif p_rec.per_information_category = 'US' then
5390         --
5391         -- US specific validation.
5392         --
5393         per_per_bus.chk_US_per_information
5394           (p_person_id                 => p_rec.person_id
5395           ,p_per_information_category  => p_rec.per_information_category
5396           ,p_per_information1          => p_rec.per_information1
5397           ,p_per_information2          => p_rec.per_information2
5398           ,p_per_information3          => p_rec.per_information3
5399           ,p_per_information4          => p_rec.per_information4
5400           ,p_per_information5          => p_rec.per_information5
5401           ,p_per_information6          => p_rec.per_information6
5402           ,p_per_information7          => p_rec.per_information7
5403           ,p_per_information8          => p_rec.per_information8
5404           ,p_per_information9          => p_rec.per_information9
5405           ,p_per_information10         => p_rec.per_information10
5406           ,p_per_information11         => p_rec.per_information11
5407           ,p_per_information12         => p_rec.per_information12
5408           ,p_per_information13         => p_rec.per_information13
5409           ,p_per_information14         => p_rec.per_information14
5410           ,p_per_information15         => p_rec.per_information15
5411           ,p_per_information16         => p_rec.per_information16
5412           ,p_per_information17         => p_rec.per_information17
5413           ,p_per_information18         => p_rec.per_information18
5414           ,p_per_information19         => p_rec.per_information19
5415           ,p_per_information20         => p_rec.per_information20
5416           ,p_per_information21         => p_rec.per_information21
5417           ,p_per_information22         => p_rec.per_information22
5418           ,p_per_information23         => p_rec.per_information23
5419           ,p_per_information24         => p_rec.per_information24
5420           ,p_per_information25         => p_rec.per_information25
5421           ,p_per_information26         => p_rec.per_information26
5422           ,p_per_information27         => p_rec.per_information27
5423           ,p_per_information28         => p_rec.per_information28
5424           ,p_per_information29         => p_rec.per_information29
5425           ,p_per_information30         => p_rec.per_information30
5426           ,p_effective_date            => p_effective_date
5427           ,p_validation_start_date     => p_validation_start_date
5428           ,p_validation_end_date       => p_validation_end_date
5429           ,p_object_version_number     => p_rec.object_version_number
5430           ,p_api_updating              => l_api_updating
5431           );
5432  if g_debug then
5433           hr_utility.set_location(l_proc, 60);
5434  end if;
5435           --
5436 /*      elsif p_rec.per_information_category = 'JP' then
5437         --
5438         -- JP specific validation
5439         --
5440         per_per_bus.chk_JP_per_information
5441           (p_person_id                 => p_rec.person_id
5442           ,p_per_information_category  => p_rec.per_information_category
5443           ,p_per_information1          => p_rec.per_information1
5444           ,p_per_information2          => p_rec.per_information2
5445           ,p_per_information3          => p_rec.per_information3
5446           ,p_per_information4          => p_rec.per_information4
5447           ,p_per_information5          => p_rec.per_information5
5448           ,p_per_information6          => p_rec.per_information6
5449           ,p_per_information7          => p_rec.per_information7
5450           ,p_per_information8          => p_rec.per_information8
5451           ,p_per_information9          => p_rec.per_information9
5452           ,p_per_information10         => p_rec.per_information10
5453           ,p_per_information11         => p_rec.per_information11
5454           ,p_per_information12         => p_rec.per_information12
5455           ,p_per_information13         => p_rec.per_information13
5456           ,p_per_information14         => p_rec.per_information14
5457           ,p_per_information15         => p_rec.per_information15
5458           ,p_per_information16         => p_rec.per_information16
5459           ,p_per_information17         => p_rec.per_information17
5460           ,p_per_information18         => p_rec.per_information18
5461           ,p_per_information19         => p_rec.per_information19
5462           ,p_per_information20         => p_rec.per_information20
5463           ,p_per_information21         => p_rec.per_information21
5464           ,p_per_information22         => p_rec.per_information22
5465           ,p_per_information23         => p_rec.per_information23
5466           ,p_per_information24         => p_rec.per_information24
5467           ,p_per_information25         => p_rec.per_information25
5468           ,p_per_information26         => p_rec.per_information26
5469           ,p_per_information27         => p_rec.per_information27
5470           ,p_per_information28         => p_rec.per_information28
5471           ,p_per_information29         => p_rec.per_information29
5472           ,p_per_information30         => p_rec.per_information30
5473           ,p_validation_start_date     => p_validation_start_date
5474           ,p_validation_end_date       => p_validation_end_date
5475           ,p_effective_date            => p_effective_date
5476           ,p_object_version_number     => p_rec.object_version_number
5477           );
5478  if g_debug then
5479           hr_utility.set_location(l_proc, 70);
5480  end if;
5481           -- */
5482       else
5483            per_per_bus.chk_ddf(p_rec => p_rec);
5484       end if;
5485 --    end if;
5486   end if;
5487  if g_debug then
5488   hr_utility.set_location(' Leaving:'|| l_proc, 100);
5489  end if;
5490 exception
5491     when l_error then
5492       --  Error: Do not enter PER_INFORMATION99 for this legislation
5493       hr_utility.set_message(801, 'HR_7529_PER_INFO_NOT_NULL');
5494       hr_utility.set_message_token('NUM',to_char(l_info_attribute));
5495       hr_multi_message.add;
5496    -- hr_utility.raise_error;
5497 end chk_per_information;
5498 --
5499 /* Bug#3613987 - Removed chk_JP_names procedure
5500 --  ---------------------------------------------------------------------------
5501 --  |------------------------<  chk_JP_names  >--------------------------|
5502 --  ---------------------------------------------------------------------------
5503 --
5504 --  Description:
5505 --    Checks that a name values are kana
5506 --
5507 --  Pre-conditions:
5508 --    None
5509 --
5510 --  In Arguments:
5511 --    p_person_id
5512 --    p_effective_date
5513 --    p_object_version_number
5514 --    p_first_name
5515 --    p_last_name
5516 --    p_per_information18
5517 --    p_per_information19
5518 --
5519 --  Out Arguments
5520 --    p_full_name
5521 --
5522 --  Post Success:
5523 --    If a name contains only single byte characters then process continues.
5524 --    It returns value to p_full_name calling return_JP_fullname
5525 --
5526 --  Post Failure:
5527 --    If a name contains any double byte characters then process is terminated.
5528 --
5529 --  Access Status:
5530 --    Internal Table Handler Use Only.
5531 --
5532 procedure chk_JP_names
5533   (p_person_id                in  per_all_people_f.person_id%TYPE
5534   ,p_effective_date           in  date
5535   ,p_object_version_number    in  per_all_people_f.object_version_number%TYPE
5536   ,p_first_name               in  per_all_people_f.first_name%TYPE
5537   ,p_last_name                in  per_all_people_f.last_name%TYPE
5538   ,p_per_information18        in  per_all_people_f.per_information18%TYPE
5539   ,p_per_information19        in  per_all_people_f.per_information19%TYPE) is
5540   --,p_full_name                out nocopy per_all_people_f.full_name%TYPE) is -- bug# 2689366
5541   --
5542   l_last_name     per_all_people_f.last_name%TYPE;
5543   l_first_name    per_all_people_f.first_name%TYPE;
5544   l_proc                varchar2(72) ;
5545   l_api_updating     boolean;
5546   l_output        varchar2(150);
5547   l_rgeflg     varchar2(10);
5548   --
5549 begin
5550  if g_debug then
5551   l_proc :=  g_package||'chk_JP_names';
5552   hr_utility.set_location('Entering:'|| l_proc, 1);
5553  end if;
5554   --
5555   if hr_multi_message.no_exclusive_error
5556     (p_check_column1      => 'PER_ALL_PEOPLE_F.LAST_NAME'
5557     )
5558   then
5559     l_api_updating := per_per_shd.api_updating
5560       (p_person_id             => p_person_id
5561       ,p_effective_date        => p_effective_date
5562       ,p_object_version_number => p_object_version_number);
5563     --
5564     --  Only proceed with validation if:
5565     --  a) The current g_old_rec is current and
5566     --  b) The start date value has changed
5567     --  c) a record is being inserted
5568     --
5569     --
5570  if g_debug then
5571       hr_utility.set_location(l_proc, 2);
5572  end if;
5573     --
5574     if ((l_api_updating
5575          and nvl(per_per_shd.g_old_rec.last_name, hr_api.g_varchar2)
5576          <> nvl(p_last_name,hr_api.g_varchar2))
5577        or
5578          (NOT l_api_updating)) then
5579       --
5580       --  Perform Insert/Update checks
5581       --
5582       l_last_name := p_last_name;
5583       hr_chkfmt.checkformat(value   => l_last_name
5584             ,format  => 'KANA'
5585             ,output  => l_output
5586             ,minimum => NULL
5587             ,maximum => NULL
5588             ,nullok  => 'N'
5589             ,rgeflg  => l_rgeflg
5590             ,curcode => NULL);
5591     end if;
5592     --
5593  if g_debug then
5594       hr_utility.set_location(l_proc, 3);
5595  end if;
5596     --
5597     if ((l_api_updating
5598          and nvl(per_per_shd.g_old_rec.first_name, hr_api.g_varchar2)
5599          <> nvl(p_first_name,hr_api.g_varchar2))
5600        or
5601          (NOT l_api_updating)) then
5602       --
5603       --  Perform Insert/Update checks
5604       --
5605       l_first_name := p_first_name;
5606       hr_chkfmt.checkformat(value   => l_first_name
5607                            ,format  => 'KANA'
5608                            ,output  => l_output
5609                            ,minimum => NULL
5610                            ,maximum => NULL
5611                            ,nullok  => 'Y'
5612                            ,rgeflg  => l_rgeflg
5613                            ,curcode => NULL);
5614     end if;
5615   end if;
5616     --
5617  if g_debug then
5618       hr_utility.set_location(' Leaving:'|| l_proc, 5);
5619  end if;
5620   exception
5621      when app_exception.application_exception then
5622       if hr_multi_message.exception_add
5623              (p_associated_column1      => 'PER_ALL_PEOPLE_F.LAST_NAME'
5624             ,p_associated_column2      => 'PER_ALL_PEOPLE_F.FIRST_NAME'
5625             ) then
5626  if g_debug then
5627          hr_utility.set_location(' Leaving:'||l_proc, 6);
5628  end if;
5629          raise;
5630        end if;
5631  if g_debug then
5632      hr_utility.set_location(' Leaving:'||l_proc,7);
5633  end if;
5634 end chk_JP_names;
5635 */
5636 --
5637 --  ---------------------------------------------------------------------------
5638 --  |-----------------------<  return_full_name  >----------------------------|
5639 --  ---------------------------------------------------------------------------
5640 --
5641 --  Description:
5642 --    Calls process hr_person.derive_full_name which constructs the full name
5643 --
5644 --  Pre-conditions:
5645 --    The value of p_title and p_date_of_birth must be valid
5646 --
5647 --  In Arguments:
5648 --    p_person_id
5649 --    p_business_group_id
5650 --    p_first_name
5651 --    p_middle_names
5652 --    p_last_name
5653 --    p_known_as
5654 --    p_title
5655 --    p_date_of_birth
5656 --    p_full_name
5657 --    p_suffix
5658 --    p_effective_date
5659 --    p_object_version_number
5660 --    p_pre_name_adjunct
5661 --
5662 --  Out Arguments
5663 --    p_full_name
5664 --    p_name_combination_warning
5665 --
5666 --  Post Success:
5667 --    The full name is set to the concatenated string  and processing continues
5668 --
5669 --    If the combination of full name and date of birth already exists then
5670 --    a warning is flagged and processing continues
5671 --
5672 --  Post Failure:
5673 --    None
5674 --
5675 --  Access Status:
5676 --    Internal Table Handler Use Only.
5677 --
5678 -- For bug # 486308, added p_suffix.
5679 --
5680 -- For bug # 2689366, added p_per_information18 and p_per_information19
5681 --
5682 procedure return_full_name
5683    (p_person_id                in  per_all_people_f.person_id%TYPE
5684    ,p_business_group_id        in  per_all_people_f.business_group_id%type
5685    ,p_first_name               in  per_all_people_f.first_name%TYPE
5686    ,p_middle_names             in  per_all_people_f.middle_names%TYPE
5687    ,p_last_name                in  per_all_people_f.last_name%TYPE
5688    ,p_known_as                 in  per_all_people_f.known_as%TYPE
5689    ,p_title                    in  per_all_people_f.title%TYPE
5690    ,p_date_of_birth            in  per_all_people_f.date_of_birth%TYPE
5691    ,p_suffix                   in  per_all_people_f.suffix%TYPE
5692    ,p_pre_name_adjunct         in  per_all_people_f.pre_name_adjunct%TYPE
5693    ,p_effective_date           in  date
5694    ,p_object_version_number    in  per_all_people_f.object_version_number%TYPE
5695    ,p_previous_last_name per_all_people_f.previous_last_name%TYPE DEFAULT NULL
5696    ,p_email_address      per_all_people_f.email_address%TYPE DEFAULT NULL
5697    ,p_employee_number    per_all_people_f.employee_number%TYPE DEFAULT NULL
5698    ,p_applicant_number   per_all_people_f.applicant_number%TYPE DEFAULT NULL
5699    ,p_npw_number         per_all_people_f.npw_number%TYPE DEFAULT NULL
5700    ,p_per_information1   per_all_people_f.per_information1%TYPE DEFAULT NULL
5701    ,p_per_information2   per_all_people_f.per_information2%TYPE DEFAULT NULL
5702    ,p_per_information3   per_all_people_f.per_information3%TYPE DEFAULT NULL
5703    ,p_per_information4   per_all_people_f.per_information4%TYPE DEFAULT NULL
5704    ,p_per_information5   per_all_people_f.per_information5%TYPE DEFAULT NULL
5705    ,p_per_information6   per_all_people_f.per_information6%TYPE DEFAULT NULL
5706    ,p_per_information7   per_all_people_f.per_information7%TYPE DEFAULT NULL
5707    ,p_per_information8   per_all_people_f.per_information8%TYPE DEFAULT NULL
5708    ,p_per_information9   per_all_people_f.per_information9%TYPE DEFAULT NULL
5709    ,p_per_information10  per_all_people_f.per_information10%TYPE DEFAULT NULL
5710    ,p_per_information11  per_all_people_f.per_information11%TYPE DEFAULT NULL
5711    ,p_per_information12  per_all_people_f.per_information12%TYPE DEFAULT NULL
5712    ,p_per_information13  per_all_people_f.per_information13%TYPE DEFAULT NULL
5713    ,p_per_information14  per_all_people_f.per_information14%TYPE DEFAULT NULL
5714    ,p_per_information15  per_all_people_f.per_information15%TYPE DEFAULT NULL
5715    ,p_per_information16  per_all_people_f.per_information16%TYPE DEFAULT NULL
5716    ,p_per_information17  per_all_people_f.per_information17%TYPE DEFAULT NULL
5717    ,p_per_information18  per_all_people_f.per_information18%TYPE DEFAULT NULL
5718    ,p_per_information19  per_all_people_f.per_information19%TYPE DEFAULT NULL
5719    ,p_per_information20  per_all_people_f.per_information20%TYPE DEFAULT NULL
5720    ,p_per_information21  per_all_people_f.per_information21%TYPE DEFAULT NULL
5721    ,p_per_information22  per_all_people_f.per_information22%TYPE DEFAULT NULL
5722    ,p_per_information23  per_all_people_f.per_information23%TYPE DEFAULT NULL
5723    ,p_per_information24  per_all_people_f.per_information24%TYPE DEFAULT NULL
5724    ,p_per_information25  per_all_people_f.per_information25%TYPE DEFAULT NULL
5725    ,p_per_information26  per_all_people_f.per_information26%TYPE DEFAULT NULL
5726    ,p_per_information27  per_all_people_f.per_information27%TYPE DEFAULT NULL
5727    ,p_per_information28  per_all_people_f.per_information28%TYPE DEFAULT NULL
5728    ,p_per_information29  per_all_people_f.per_information29%TYPE DEFAULT NULL
5729    ,p_per_information30  per_all_people_f.per_information30%TYPE DEFAULT NULL
5730    ,p_attribute1         per_all_people_f.attribute1%TYPE DEFAULT NULL
5731    ,p_attribute2         per_all_people_f.attribute2%TYPE DEFAULT NULL
5732    ,p_attribute3         per_all_people_f.attribute3%TYPE DEFAULT NULL
5733    ,p_attribute4         per_all_people_f.attribute4%TYPE DEFAULT NULL
5734    ,p_attribute5         per_all_people_f.attribute5%TYPE DEFAULT NULL
5735    ,p_attribute6         per_all_people_f.attribute6%TYPE DEFAULT NULL
5736    ,p_attribute7         per_all_people_f.attribute7%TYPE DEFAULT NULL
5737    ,p_attribute8         per_all_people_f.attribute8%TYPE DEFAULT NULL
5738    ,p_attribute9         per_all_people_f.attribute9%TYPE DEFAULT NULL
5739    ,p_attribute10        per_all_people_f.attribute10%TYPE DEFAULT NULL
5740    ,p_attribute11        per_all_people_f.attribute11%TYPE DEFAULT NULL
5741    ,p_attribute12        per_all_people_f.attribute12%TYPE DEFAULT NULL
5742    ,p_attribute13        per_all_people_f.attribute13%TYPE DEFAULT NULL
5743    ,p_attribute14        per_all_people_f.attribute14%TYPE DEFAULT NULL
5744    ,p_attribute15        per_all_people_f.attribute15%TYPE DEFAULT NULL
5745    ,p_attribute16        per_all_people_f.attribute16%TYPE DEFAULT NULL
5746    ,p_attribute17        per_all_people_f.attribute17%TYPE DEFAULT NULL
5747    ,p_attribute18        per_all_people_f.attribute18%TYPE DEFAULT NULL
5748    ,p_attribute19        per_all_people_f.attribute19%TYPE DEFAULT NULL
5749    ,p_attribute20        per_all_people_f.attribute20%TYPE DEFAULT NULL
5750    ,p_attribute21        per_all_people_f.attribute21%TYPE DEFAULT NULL
5751    ,p_attribute22        per_all_people_f.attribute22%TYPE DEFAULT NULL
5752    ,p_attribute23        per_all_people_f.attribute23%TYPE DEFAULT NULL
5753    ,p_attribute24        per_all_people_f.attribute24%TYPE DEFAULT NULL
5754    ,p_attribute25        per_all_people_f.attribute25%TYPE DEFAULT NULL
5755    ,p_attribute26        per_all_people_f.attribute26%TYPE DEFAULT NULL
5756    ,p_attribute27        per_all_people_f.attribute27%TYPE DEFAULT NULL
5757    ,p_attribute28        per_all_people_f.attribute28%TYPE DEFAULT NULL
5758    ,p_attribute29        per_all_people_f.attribute29%TYPE DEFAULT NULL
5759    ,p_attribute30        per_all_people_f.attribute30%TYPE DEFAULT NULL
5760    ,p_full_name          OUT NOCOPY per_all_people_f.full_name%TYPE
5761    ,p_order_name         OUT NOCOPY per_all_people_f.order_name%TYPE
5762    ,p_global_name        OUT NOCOPY per_all_people_f.global_name%TYPE
5763    ,p_local_name         OUT NOCOPY per_all_people_f.local_name%TYPE
5764    ,p_duplicate_flag     OUT NOCOPY VARCHAR2
5765    ,p_name_combination_warning out nocopy boolean) is
5766 --
5767   l_exists            varchar2(1);
5768   l_proc              varchar2(72)  :=  g_package||'return_full_name';
5769   l_api_updating              boolean;
5770   l_duplicate_flag            varchar2(1);
5771   l_full_name                 varchar2(240);
5772   l_order_name                varchar2(240);
5773   l_global_name               varchar2(240);
5774   l_local_name                varchar2(240);
5775 --
5776 begin
5777  if g_debug then
5778   hr_utility.set_location('Entering:'|| l_proc, 10);
5779  end if;
5780   --
5781   -- Check mandatory parameters have been set
5782   --
5783     hr_api.mandatory_arg_error
5784       (p_api_name       => l_proc
5785       ,p_argument       => 'business group id'
5786       ,p_argument_value => p_business_group_id
5787       );
5788     --
5789     hr_api.mandatory_arg_error
5790       (p_api_name       => l_proc
5791       ,p_argument       => 'effective date'
5792       ,p_argument_value => p_effective_date
5793       );
5794     --
5795     -- Check if the last name is set.
5796     --
5797     if p_last_name is null then
5798       --
5799       hr_utility.set_message(801, 'PER_52076_PER_NULL_LAST_NAME');
5800       hr_utility.raise_error;
5801       --
5802     end if;
5803     --
5804   if hr_multi_message.no_all_inclusive_error
5805                (p_check_column1      => 'PER_ALL_PEOPLE_F.TITLE'
5806                ,p_check_column2      => 'PER_ALL_PEOPLE_F.DATE_OF_BIRTH'
5807                )
5808   then
5809     p_name_combination_warning := false;
5810     --
5811     --  Only proceed with validation if:
5812     --  a) The current g_old_rec is current and
5813     --  b) last name has changed
5814     --  c) title has changed
5815     --  d) first name has changed
5816     --  d) middle names have changed
5817     --  e) known as values has changed
5818     --  f) date of birth has changed
5819     --  g) A record is being inserted
5820     --
5821     l_api_updating := per_per_shd.api_updating
5822     (p_person_id             => p_person_id
5823     ,p_effective_date        => p_effective_date
5824     ,p_object_version_number => p_object_version_number);
5825     --
5826     if ((l_api_updating and nvl(per_per_shd.g_old_rec.last_name,
5827                                 hr_api.g_varchar2)
5828       <> nvl(p_last_name,hr_api.g_varchar2)) or
5829       (l_api_updating and nvl(per_per_shd.g_old_rec.title,
5830                                 hr_api.g_varchar2)
5831       <> nvl(p_title,hr_api.g_varchar2)) or
5832       (l_api_updating and nvl(per_per_shd.g_old_rec.first_name,
5833                                 hr_api.g_varchar2)
5834       <> nvl(p_first_name,hr_api.g_varchar2)) or
5835       (l_api_updating and nvl(per_per_shd.g_old_rec.middle_names,
5836                                 hr_api.g_varchar2)
5837       <> nvl(p_middle_names,hr_api.g_varchar2)) or
5838       (l_api_updating and nvl(per_per_shd.g_old_rec.suffix,
5839                                 hr_api.g_varchar2)
5840       <> nvl(p_suffix,hr_api.g_varchar2)) or
5841       (l_api_updating and nvl(per_per_shd.g_old_rec.known_as,
5842                                 hr_api.g_varchar2)
5843       <> nvl(p_known_as,hr_api.g_varchar2)) or
5844       (l_api_updating and nvl(per_per_shd.g_old_rec.date_of_birth,
5845                                 hr_api.g_date)
5846       <> nvl(p_date_of_birth,hr_api.g_date)) or
5847       (l_api_updating and nvl(per_per_shd.g_old_rec.pre_name_adjunct,
5848                                 hr_api.g_varchar2)
5849       <> nvl(p_pre_name_adjunct,hr_api.g_varchar2)) or
5850       (l_api_updating and nvl(per_per_shd.g_old_rec.employee_number,
5851                                 hr_api.g_varchar2)
5852       <> nvl(p_employee_number,hr_api.g_varchar2)) or
5853       (l_api_updating and nvl(per_per_shd.g_old_rec.applicant_number,
5854                                 hr_api.g_varchar2)
5855       <> nvl(p_applicant_number,hr_api.g_varchar2)) or
5856       (l_api_updating and nvl(per_per_shd.g_old_rec.npw_number,
5857                                 hr_api.g_varchar2)
5858       <> nvl(p_npw_number,hr_api.g_varchar2)) or
5859       (l_api_updating and nvl(per_per_shd.g_old_rec.email_address,
5860                                 hr_api.g_varchar2)
5861       <> nvl(p_email_address,hr_api.g_varchar2)) or
5862       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information1,
5863                                 hr_api.g_varchar2)
5864       <> nvl(p_per_information1,hr_api.g_varchar2)) or
5865       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information2,
5866                                 hr_api.g_varchar2)
5867       <> nvl(p_per_information2,hr_api.g_varchar2)) or
5868       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information3,
5869                                 hr_api.g_varchar2)
5870       <> nvl(p_per_information3,hr_api.g_varchar2)) or
5871       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information4,
5872                                 hr_api.g_varchar2)
5873       <> nvl(p_per_information4,hr_api.g_varchar2)) or
5874       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information5,
5875                                 hr_api.g_varchar2)
5876       <> nvl(p_per_information5,hr_api.g_varchar2)) or
5877       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information6,
5878                                 hr_api.g_varchar2)
5879       <> nvl(p_per_information6,hr_api.g_varchar2)) or
5880       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information7,
5881                                 hr_api.g_varchar2)
5882       <> nvl(p_per_information7,hr_api.g_varchar2)) or
5883       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information8,
5884                                 hr_api.g_varchar2)
5885       <> nvl(p_per_information8,hr_api.g_varchar2)) or
5886       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information9,
5887                                 hr_api.g_varchar2)
5888       <> nvl(p_per_information9,hr_api.g_varchar2)) or
5889       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information10,
5890                                 hr_api.g_varchar2)
5891       <> nvl(p_per_information10,hr_api.g_varchar2)) or
5892       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information11,
5893                                 hr_api.g_varchar2)
5894       <> nvl(p_per_information11,hr_api.g_varchar2)) or
5895       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information12,
5896                                 hr_api.g_varchar2)
5897       <> nvl(p_per_information12,hr_api.g_varchar2)) or
5898       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information13,
5899                                 hr_api.g_varchar2)
5900       <> nvl(p_per_information13,hr_api.g_varchar2)) or
5901       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information14,
5902                                 hr_api.g_varchar2)
5903       <> nvl(p_per_information14,hr_api.g_varchar2)) or
5904       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information15,
5905                                 hr_api.g_varchar2)
5906       <> nvl(p_per_information15,hr_api.g_varchar2)) or
5907       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information16,
5908                                 hr_api.g_varchar2)
5909       <> nvl(p_per_information16,hr_api.g_varchar2)) or
5910       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information17,
5911                                 hr_api.g_varchar2)
5912       <> nvl(p_per_information17,hr_api.g_varchar2)) or
5913       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information18,
5914                                 hr_api.g_varchar2)
5915       <> nvl(p_per_information18,hr_api.g_varchar2)) or
5916       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information19,
5917                                 hr_api.g_varchar2)
5918       <> nvl(p_per_information19,hr_api.g_varchar2)) or
5919       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information20,
5920                                 hr_api.g_varchar2)
5921       <> nvl(p_per_information20,hr_api.g_varchar2)) or
5922       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information21,
5923                                 hr_api.g_varchar2)
5924       <> nvl(p_per_information21,hr_api.g_varchar2)) or
5925       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information22,
5926                                 hr_api.g_varchar2)
5927       <> nvl(p_per_information22,hr_api.g_varchar2)) or
5928       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information23,
5929                                 hr_api.g_varchar2)
5930       <> nvl(p_per_information23,hr_api.g_varchar2)) or
5931       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information24,
5932                                 hr_api.g_varchar2)
5933       <> nvl(p_per_information24,hr_api.g_varchar2)) or
5934       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information25,
5935                                 hr_api.g_varchar2)
5936       <> nvl(p_per_information25,hr_api.g_varchar2)) or
5937       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information26,
5938                                 hr_api.g_varchar2)
5939       <> nvl(p_per_information26,hr_api.g_varchar2)) or
5940       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information27,
5941                                 hr_api.g_varchar2)
5942       <> nvl(p_per_information27,hr_api.g_varchar2)) or
5943       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information28,
5944                                 hr_api.g_varchar2)
5945       <> nvl(p_per_information28,hr_api.g_varchar2)) or
5946       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information29,
5947                                 hr_api.g_varchar2)
5948       <> nvl(p_per_information29,hr_api.g_varchar2)) or
5949       (l_api_updating and nvl(per_per_shd.g_old_rec.per_information30,
5950                                 hr_api.g_varchar2)
5951       <> nvl(p_per_information30,hr_api.g_varchar2)) or
5952       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute1,
5953                                 hr_api.g_varchar2)
5954       <> nvl(p_attribute1,hr_api.g_varchar2)) or
5955       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute2,
5956                                 hr_api.g_varchar2)
5957       <> nvl(p_attribute2,hr_api.g_varchar2)) or
5958       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute3,
5959                                 hr_api.g_varchar2)
5960       <> nvl(p_attribute3,hr_api.g_varchar2)) or
5961       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute4,
5962                                 hr_api.g_varchar2)
5963       <> nvl(p_attribute4,hr_api.g_varchar2)) or
5964       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute5,
5965                                 hr_api.g_varchar2)
5966       <> nvl(p_attribute5,hr_api.g_varchar2)) or
5967       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute6,
5968                                 hr_api.g_varchar2)
5969       <> nvl(p_attribute6,hr_api.g_varchar2)) or
5970       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute7,
5971                                 hr_api.g_varchar2)
5972       <> nvl(p_attribute7,hr_api.g_varchar2)) or
5973       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute8,
5974                                 hr_api.g_varchar2)
5975       <> nvl(p_attribute8,hr_api.g_varchar2)) or
5976       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute9,
5977                                 hr_api.g_varchar2)
5978       <> nvl(p_attribute9,hr_api.g_varchar2)) or
5979       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute10,
5980                                 hr_api.g_varchar2)
5981       <> nvl(p_attribute10,hr_api.g_varchar2)) or
5982       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute11,
5983                                 hr_api.g_varchar2)
5984       <> nvl(p_attribute11,hr_api.g_varchar2)) or
5985       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute12,
5986                                 hr_api.g_varchar2)
5987       <> nvl(p_attribute12,hr_api.g_varchar2)) or
5988       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute13,
5989                                 hr_api.g_varchar2)
5990       <> nvl(p_attribute13,hr_api.g_varchar2)) or
5991       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute14,
5992                                 hr_api.g_varchar2)
5993       <> nvl(p_attribute14,hr_api.g_varchar2)) or
5994       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute15,
5995                                 hr_api.g_varchar2)
5996       <> nvl(p_attribute15,hr_api.g_varchar2)) or
5997       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute16,
5998                                 hr_api.g_varchar2)
5999       <> nvl(p_attribute16,hr_api.g_varchar2)) or
6000       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute17,
6001                                 hr_api.g_varchar2)
6002       <> nvl(p_attribute17,hr_api.g_varchar2)) or
6003       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute18,
6004                                 hr_api.g_varchar2)
6005       <> nvl(p_attribute18,hr_api.g_varchar2)) or
6006       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute19,
6007                                 hr_api.g_varchar2)
6008       <> nvl(p_attribute19,hr_api.g_varchar2)) or
6009       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute20,
6010                                 hr_api.g_varchar2)
6011       <> nvl(p_attribute20,hr_api.g_varchar2)) or
6012       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute21,
6013                                 hr_api.g_varchar2)
6014       <> nvl(p_attribute21,hr_api.g_varchar2)) or
6015       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute22,
6016                                 hr_api.g_varchar2)
6017       <> nvl(p_attribute22,hr_api.g_varchar2)) or
6018       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute23,
6019                                 hr_api.g_varchar2)
6020       <> nvl(p_attribute23,hr_api.g_varchar2)) or
6021       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute24,
6022                                 hr_api.g_varchar2)
6023       <> nvl(p_attribute24,hr_api.g_varchar2)) or
6024       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute25,
6025                                 hr_api.g_varchar2)
6026       <> nvl(p_attribute25,hr_api.g_varchar2)) or
6027       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute26,
6028                                 hr_api.g_varchar2)
6029       <> nvl(p_attribute26,hr_api.g_varchar2)) or
6030       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute27,
6031                                 hr_api.g_varchar2)
6032       <> nvl(p_attribute27,hr_api.g_varchar2)) or
6033       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute28,
6034                                 hr_api.g_varchar2)
6035       <> nvl(p_attribute28,hr_api.g_varchar2)) or
6036       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute29,
6037                                 hr_api.g_varchar2)
6038       <> nvl(p_attribute29,hr_api.g_varchar2)) or
6039       (l_api_updating and nvl(per_per_shd.g_old_rec.attribute30,
6040                                 hr_api.g_varchar2)
6041       <> nvl(p_attribute30,hr_api.g_varchar2)) or
6042       (NOT l_api_updating)) then
6043       --
6044       if g_debug then
6045          hr_utility.set_location(l_proc, 20);
6046       end if;
6047       --
6048       l_duplicate_flag := 'N';
6049       --
6050       --  Call process to contruct full name
6051       --
6052       hr_person_name.derive_person_names
6053       (p_format_name        =>  NULL,    -- derice all names
6054        p_business_group_id  =>  p_business_group_id,
6055        p_person_id          =>  p_person_id,
6056        p_first_name         =>  p_first_name,
6057        p_middle_names       =>  p_middle_names,
6058        p_last_name          =>  p_last_name,
6059        p_known_as           =>  p_known_as,
6060        p_title              =>  p_title,
6061        p_suffix             =>  p_suffix,
6062        p_pre_name_adjunct   =>  p_pre_name_adjunct,
6063        p_date_of_birth      =>  p_date_of_birth,
6064        p_previous_last_name =>  p_previous_last_name  ,
6065        p_email_address      =>  p_email_address  ,
6066        p_employee_number    =>  p_employee_number  ,
6067        p_applicant_number   =>  p_applicant_number  ,
6068        p_npw_number         =>  p_npw_number  ,
6069        p_per_information1   =>  p_per_information1  ,
6070        p_per_information2   =>  p_per_information2  ,
6071        p_per_information3   =>  p_per_information3  ,
6072        p_per_information4   =>  p_per_information4  ,
6073        p_per_information5   =>  p_per_information5  ,
6074        p_per_information6   =>  p_per_information6  ,
6075        p_per_information7   =>  p_per_information7  ,
6076        p_per_information8   =>  p_per_information8  ,
6077        p_per_information9   =>  p_per_information9  ,
6078        p_per_information10  =>  p_per_information10  ,
6079        p_per_information11  =>  p_per_information11  ,
6080        p_per_information12  =>  p_per_information12  ,
6081        p_per_information13  =>  p_per_information13  ,
6082        p_per_information14  =>  p_per_information14  ,
6083        p_per_information15  =>  p_per_information15  ,
6084        p_per_information16  =>  p_per_information16  ,
6085        p_per_information17  =>  p_per_information17  ,
6086        p_per_information18  =>  p_per_information18  ,
6087        p_per_information19  =>  p_per_information19  ,
6088        p_per_information20  =>  p_per_information20  ,
6089        p_per_information21  =>  p_per_information21  ,
6090        p_per_information22  =>  p_per_information22  ,
6091        p_per_information23  =>  p_per_information23  ,
6092        p_per_information24  =>  p_per_information24  ,
6093        p_per_information25  =>  p_per_information25  ,
6094        p_per_information26  =>  p_per_information26  ,
6095        p_per_information27  =>  p_per_information27  ,
6096        p_per_information28  =>  p_per_information28  ,
6097        p_per_information29  =>  p_per_information29  ,
6098        p_per_information30  =>  p_per_information30  ,
6099        p_attribute1         =>  p_attribute1  ,
6100        p_attribute2         =>  p_attribute2  ,
6101        p_attribute3         =>  p_attribute3  ,
6102        p_attribute4         =>  p_attribute4  ,
6103        p_attribute5         =>  p_attribute5  ,
6104        p_attribute6         =>  p_attribute6  ,
6105        p_attribute7         =>  p_attribute7  ,
6106        p_attribute8         =>  p_attribute8  ,
6107        p_attribute9         =>  p_attribute9  ,
6108        p_attribute10        =>  p_attribute10  ,
6109        p_attribute11        =>  p_attribute11  ,
6110        p_attribute12        =>  p_attribute12  ,
6111        p_attribute13        =>  p_attribute13  ,
6112        p_attribute14        =>  p_attribute14  ,
6113        p_attribute15        =>  p_attribute15  ,
6114        p_attribute16        =>  p_attribute16  ,
6115        p_attribute17        =>  p_attribute17  ,
6116        p_attribute18        =>  p_attribute18  ,
6117        p_attribute19        =>  p_attribute19  ,
6118        p_attribute20        =>  p_attribute20  ,
6119        p_attribute21        =>  p_attribute21  ,
6120        p_attribute22        =>  p_attribute22  ,
6121        p_attribute23        =>  p_attribute23,
6122        p_attribute24        =>  p_attribute24,
6123        p_attribute25        =>  p_attribute25,
6124        p_attribute26        =>  p_attribute26,
6125        p_attribute27        =>  p_attribute27,
6126        p_attribute28        =>  p_attribute28,
6127        p_attribute29        =>  p_attribute29,
6128        p_attribute30        =>  p_attribute30,
6129        p_full_name          => l_full_name,
6130        p_order_name         => l_order_name,
6131        p_global_name        => l_global_name,
6132        p_local_name         => l_local_name,
6133        p_duplicate_flag     => l_duplicate_flag
6134        );
6135 
6136       --hr_person.derive_full_name(p_first_name         =>  p_first_name
6137       --                          ,p_middle_names       =>  p_middle_names
6138       --                          ,p_last_name          =>  p_last_name
6139       --                          ,p_known_as           =>  p_known_as
6140       --                          ,p_title              =>  p_title
6141       --                          ,p_suffix             =>  p_suffix
6142       --                          ,p_pre_name_adjunct   =>  p_pre_name_adjunct
6143       --                          ,p_date_of_birth      =>  p_date_of_birth
6144       --                          ,p_person_id          =>  p_person_id
6145       --                          ,p_business_group_id  =>  p_business_group_id
6146       --                          ,p_full_name          =>  l_full_name
6147       --                          ,p_duplicate_flag     =>  l_duplicate_flag
6148       --                          ,p_per_information18  =>  p_per_information18
6149       --                          ,p_per_information19  =>  p_per_information19
6150       --                          );
6151       --
6152       p_full_name   := l_full_name;
6153       p_order_name  := l_order_name;
6154       p_global_name := l_global_name;
6155       p_local_name  := l_local_name;
6156       --
6157       if l_duplicate_flag = 'Y' then
6158         p_name_combination_warning := TRUE;
6159         if g_debug then
6160              hr_utility.set_location(l_proc,25);
6161         end if;
6162       end if;
6163       --
6164       if g_debug then
6165          hr_utility.set_location(l_proc, 30);
6166       end if;
6167     else
6168       --
6169       -- We are not updating the name so we must return the current full_name
6170       --
6171       p_full_name   := per_per_shd.g_old_rec.full_name;
6172       p_order_name  := per_per_shd.g_old_rec.order_name;
6173       p_global_name := per_per_shd.g_old_rec.global_name;
6174       p_local_name  := per_per_shd.g_old_rec.local_name;
6175     end if;
6176   end if;
6177  if g_debug then
6178   hr_utility.set_location(' Leaving:'|| l_proc, 40);
6179  end if;
6180   exception
6181     when app_exception.application_exception then
6182       if hr_multi_message.exception_add
6183       (p_associated_column1      => 'PER_ALL_PEOPLE_F.LAST_NAME'
6184       ) then
6185  if g_debug then
6186         hr_utility.set_location(' Leaving:'||l_proc, 50);
6187  end if;
6188         raise;
6189       end if;
6190  if g_debug then
6191      hr_utility.set_location(' Leaving:'||l_proc,60);
6192  end if;
6193 end return_full_name;
6194 --  ---------------------------------------------------------------------------
6195 --  |-----------------------<  chk_applicant_number  >------------------------|
6196 --  ---------------------------------------------------------------------------
6197 --
6198 --  Description:
6199 --    Checks that applicant number is valid on insert and delete based on
6200 --    applicant number generation method.
6201 --
6202 --    Some specific tests are performed in this procedure and then if all
6203 --    is still okay the hr_person.generate_number routine is called to
6204 --    finish of the validation/generation process.
6205 --
6206 --  Pre-conditions:
6207 --    Valid person_id
6208 --    Valid current_applicant_flag
6209 --    Valid current_employee_flag
6210 --    Valid business_group_id
6211 --    Valid person_type_id
6212 --
6213 --  In Arguments:
6214 --    p_person_id
6215 --    p_applicant_number
6216 --    p_business_group_id
6217 --    p_current_applicant
6218 --    p_effective_date
6219 --    p_object_version_number
6220 --
6221 --  Post Success:
6222 --
6223 --  If the following conditions apply then an applicant_number is generated
6224 --  and processing continues :
6225 --
6226 --   a) Applicant number must be not null if system person type is 'APL',
6227 --      'APL_EX_APL','EMP_APL','EX_EMP_APL'.
6228 --
6229 --   b) Applicant number must not be modified to null if the system person
6230 --      type is 'EMP' or 'EX_EMP' and the applicant number is not null
6231 --
6232 --   c) Applicant number must be null if the system person type is 'EMP' and
6233 --      no previous changes to system person type exist
6234 --
6235 --   d) Applicant number must be null if the system person type is 'OTHER'
6236 --
6237 --   e) Applicant number is mandatory in Manual generation mode
6238 --
6239 --   f) Number generation mode of associated business group id can only
6240 --      be 'A' or 'M'
6241 --
6242 --   g) Applicant number can only be updated in generation mode 'M'
6243 --
6244 --   h) Applicant number must be unique within the business group
6245 --
6246 --  Post Failure:
6247 --
6248 --  If the following conditions apply then processing fails :
6249 --
6250 --   a) Applicant number is not null, system person type is 'OTHER'
6251 --
6252 --   b) Applicant number has changed from not null to null and the system
6253 --      person type is 'EMP' or 'EX_EMP'
6254 --
6255 --   c) Applicant number updated when generation mode is 'A'
6256 --
6257 --   d) Applicant number is not null, system person type is 'EMP' and
6258 --      no historic changes in system person type exist for this person.
6259 --      i.e they are 'EMP' now and have always been an 'EMP'.
6260 --
6261 --   e) Applicant number is null when generation mode is 'M'
6262 --
6263 --  Access Status:
6264 --    Internal Table Handler Use Only.
6265 --
6266 procedure chk_applicant_number
6267   (p_person_id                in     per_all_people_f.person_id%TYPE
6268   ,p_applicant_number         in out nocopy per_all_people_f.applicant_number%TYPE
6269   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
6270   ,p_current_applicant        in     per_all_people_f.current_applicant_flag%TYPE
6271   ,p_person_type_id           in     per_all_people_f.person_type_id%TYPE
6272   ,p_effective_date           in     date
6273   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
6274   )
6275   is
6276 begin
6277    chk_applicant_number
6278   (p_person_id              => p_person_id
6279   ,p_applicant_number       => p_applicant_number
6280   ,p_business_group_id      => p_business_group_id
6281   ,p_current_applicant      => p_current_applicant
6282   ,p_person_type_id         => p_person_type_id
6283   ,p_effective_date         => p_effective_date
6284   ,p_object_version_number  => p_object_version_number
6285   ,p_party_id               => null
6286   ,p_date_of_birth          => null
6287   ,p_start_date             => null
6288   );
6289 end chk_applicant_number;
6290 --
6291 --
6292 procedure chk_applicant_number
6293   (p_person_id                in     per_all_people_f.person_id%TYPE
6294   ,p_applicant_number         in out nocopy per_all_people_f.applicant_number%TYPE
6295   ,p_business_group_id        in     per_all_people_f.business_group_id%TYPE
6296   ,p_current_applicant        in     per_all_people_f.current_applicant_flag%TYPE
6297   ,p_person_type_id           in     per_all_people_f.person_type_id%TYPE
6298   ,p_effective_date           in     date
6299   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
6300   ,p_party_id                 in     per_all_people_f.party_id%TYPE
6301   ,p_date_of_birth            in     per_all_people_f.date_of_birth%TYPE
6302   ,p_start_date               in     date
6303   )
6304   is
6305 --
6306   l_proc               varchar2(72)  :=  g_package||'chk_applicant_number';
6307   l_api_updating       boolean;
6308   l_gen_method         per_business_groups.method_of_generation_emp_num%TYPE;
6309   l_system_person_type per_person_types.system_person_type%TYPE;
6310   l_employee_number    per_all_people_f.employee_number%TYPE;
6311   l_npw_number         per_all_people_f.npw_number%TYPE;
6312   l_apl_sys                  boolean := false;
6313 --
6314 -- Cursor to get number generation method for Bus Group
6315 --
6316   cursor csr_gen_meth is
6317     select pbg.method_of_generation_apl_num
6318     from per_business_groups pbg
6319     where pbg.business_group_id = p_business_group_id;
6320 --
6321 --
6322 -- Declare the function apl_sys_per_type_change
6323 --
6324   function apl_sys_per_type_change
6325                (p_new_person_type_id      numeric
6326                ,p_old_person_type_id      numeric
6327                ,p_business_group_id       numeric)
6328   return boolean is
6329   --
6330   l_new_system_person_type   per_person_types.system_person_type%TYPE;
6331   l_old_system_person_type   per_person_types.system_person_type%TYPE;
6332   l_return_status            boolean;
6333   l_proc                     varchar2(25) := 'apl_sys_per_type_change';
6334   --
6335   -- Cursor to get the system_person_type for the 'old' person_type_id
6336   --
6337   cursor get_old_sys_per_type is
6338          select system_person_type
6339          from   per_person_types
6340          where  person_type_id    = p_old_person_type_id
6341          and    business_group_id = p_business_group_id;
6342   --
6343   begin
6344     --
6345  if g_debug then
6346     hr_utility.set_location('Entering '||l_proc,10);
6347  end if;
6348     --
6349     -- Assume we have not changed the system_person_type, so set return
6350     -- variable to FALSE.
6351     --
6352     l_return_status := false;
6353     --
6354     -- Check the person_type_id has actually changed
6355     --
6356     if p_new_person_type_id <> p_old_person_type_id then
6357       --
6358  if g_debug then
6359       hr_utility.set_location(l_proc, 20);
6360  end if;
6361       --
6362       -- Get the system_person_type for the 'new' person_type_id
6363       --
6364       l_new_system_person_type := return_system_person_type
6365                                  (p_person_type_Id    =>p_new_person_type_id
6366                                  ,p_business_group_id =>p_business_group_id
6367                                  );
6368  if g_debug then
6369       hr_utility.set_location(l_proc, 30);
6370  end if;
6371       --
6372       -- Get the system_person_type for the 'old' person_type_id
6373       --
6374       open get_old_sys_per_type;
6375       fetch get_old_sys_per_type into l_old_system_person_type;
6376       close get_old_sys_per_type;
6377       --
6378       -- If the system_person_type's have changed then check the transition
6379       -- to see if the applicant number needs to be validated/generated
6380       --
6381       if ((l_old_system_person_type = 'OTHER' and
6382            l_new_system_person_type = 'APL')
6383           or
6384           (l_old_system_person_type = 'EMP' and
6385            l_new_system_person_type = 'EMP_APL')
6386           or
6387           (l_old_system_person_type = 'EX_EMP' and
6388            l_new_system_person_type = 'EX_EMP_APL')) then
6389         --
6390  if g_debug then
6391         hr_utility.set_location(l_proc, 40);
6392  end if;
6393         --
6394         l_return_status := true;
6395       end if;
6396  if g_debug then
6397       hr_utility.set_location(l_proc, 50);
6398  end if;
6399     end if;
6400  if g_debug then
6401     hr_utility.set_location(' Leaving '||l_proc, 60);
6402  end if;
6403     return l_return_status;
6404   end apl_sys_per_type_change;
6405 --
6406 begin
6407  if g_debug then
6408   hr_utility.set_location('Entering:'|| l_proc, 1);
6409  end if;
6410   --
6411   -- Check mandatory parameters have been set
6412   --
6413   hr_api.mandatory_arg_error
6414     (p_api_name       => l_proc
6415     ,p_argument       => 'business group id'
6416     ,p_argument_value => p_business_group_id
6417     );
6418   --
6419   hr_api.mandatory_arg_error
6420     (p_api_name       => l_proc
6421     ,p_argument       => 'effective date'
6422     ,p_argument_value => p_effective_date
6423     );
6424   --
6425   -- Check if the person is being updated
6426   --
6427   --  Only proceed with validation if:
6428   --  a) The current g_old_rec is current and
6429   --  b) The applicant number value has changed
6430   --  c) a record is being inserted
6431   --
6432   l_api_updating := per_per_shd.api_updating
6433         (p_person_id              => p_person_id
6434         ,p_effective_date         => p_effective_date
6435         ,p_object_version_number  => p_object_version_number);
6436  if g_debug then
6437   hr_utility.set_location(l_proc, 2);
6438  end if;
6439   --
6440   -- Need to validate/generate the applicant number if the applicant number
6441   -- has changed or if the system person type has changed in such a way
6442   -- that an applicant number is now required.
6443   --
6444   if ((l_api_updating and
6445               (nvl(per_per_shd.g_old_rec.applicant_number,
6446                    hr_api.g_varchar2) <>
6447                nvl(p_applicant_number, hr_api.g_varchar2)
6448                or   apl_sys_per_type_change
6449                                 (p_person_type_id
6450                                 ,per_per_shd.g_old_rec.person_type_id
6451                                 ,p_business_group_id)))
6452        or
6453       (NOT l_api_updating)) then
6454       --
6455  if g_debug then
6456       hr_utility.set_location(l_proc, 3);
6457  end if;
6458       --
6459       --  Get the generation method for applicant numbers for the
6460       --  business group
6461       --
6462       open csr_gen_meth;
6463       fetch csr_gen_meth into l_gen_method;
6464       close csr_gen_meth;
6465  if g_debug then
6466       hr_utility.set_location(l_proc, 4);
6467  end if;
6468       --
6469       --  Get the system person type for the type id
6470       --
6471       l_system_person_type := return_system_person_type
6472                                    (p_person_type_id    => p_person_type_id
6473                                    ,p_business_group_id => p_business_group_id
6474                                    );
6475  if g_debug then
6476       hr_utility.set_location(l_proc, 5);
6477  end if;
6478       --
6479       --  If system_person_type is OTHER, applicant number must be NULL
6480       --
6481       if (l_system_person_type = 'OTHER' and
6482           p_applicant_number is not null) then
6483         hr_utility.set_message(801, 'HR_51199_PER_APP_NOT_NULL');
6484         l_apl_sys := true;
6485         hr_utility.raise_error;
6486       end if;
6487  if g_debug then
6488       hr_utility.set_location(l_proc, 6);
6489  end if;
6490       --
6491       --  If system person type is EMP, applicant number must be NULL
6492       --  on insert
6493       --
6494       if (NOT l_api_updating and
6495           l_system_person_type = 'EMP' and
6496           p_applicant_number is not null) then
6497         hr_utility.set_message(801, 'HR_51202_PER_APL_NOT_NULL');
6498         l_apl_sys := true;
6499         hr_utility.raise_error;
6500       end if;
6501  if g_debug then
6502       hr_utility.set_location(l_proc, 7);
6503  end if;
6504       --
6505       --  If system person type is EMP or EX_EMP and we are updating then
6506       --  applicant number cannot change to null
6507       --
6508       if (l_api_updating) then
6509         if (l_system_person_type in ('EMP','EX_EMP') and
6510             per_per_shd.g_old_rec.applicant_number is not null and
6511             p_applicant_number is null) then
6512           hr_utility.set_message(801, 'HR_51200_PER_APL_NOT_NULL_UPD');
6513           l_apl_sys := true;
6514           hr_utility.raise_error;
6515         end if;
6516  if g_debug then
6517         hr_utility.set_location(l_proc, 8);
6518  end if;
6519       end if;
6520  if g_debug then
6521       hr_utility.set_location(l_proc, 9);
6522  end if;
6523       --
6524       --  Check that on update with Automatic number generation
6525       --  the applicant number is not changed.
6526       --
6527       if (l_api_updating and
6528           nvl(per_per_shd.g_old_rec.applicant_number,hr_api.g_varchar2) <>
6529                nvl(p_applicant_number, hr_api.g_varchar2)  and
6530           l_gen_method = 'A') then
6531         hr_utility.set_message(801, 'HR_51201_PER_INV_APL_UPD');
6532         hr_utility.raise_error;
6533       end if;
6534  if g_debug then
6535       hr_utility.set_location(l_proc,11);
6536  end if;
6537       --
6538       --  On update, If system person type is EMP and no previous sys per
6539       --  type change then applicant number must be null
6540       --
6541       if (l_api_updating and
6542           l_system_person_type = 'EMP' and
6543           NOT hr_person.chk_prev_person_type
6544              (p_system_person_type   => l_system_person_type
6545              ,p_person_id            => p_person_id
6546              ,p_business_group_id    => p_business_group_id
6547              ,p_effective_start_date => p_effective_date) and
6548           p_applicant_number is not null) then
6549         hr_utility.set_message(801, 'HR_51202_PER_APP_NOT_NULL_SPT');
6550         l_apl_sys := true;
6551         hr_utility.raise_error;
6552       end if;
6553  if g_debug then
6554       hr_utility.set_location(l_proc,12);
6555  end if;
6556       --
6557       --  Now call the generate routine. We are either in insert mode
6558       --  or updating a manually generated applicant number
6559       --
6560       hr_person.generate_number(p_current_employee    => 'N'
6561                                ,p_current_applicant   => p_current_applicant
6562                                ,p_current_npw         => 'N'
6563                                ,p_national_identifier => NULL
6564                                ,p_business_group_id   => p_business_group_id
6565                                ,p_person_id           => p_person_id
6566                                ,p_employee_number     => l_employee_number
6567                                ,p_applicant_number    => p_applicant_number
6568                                ,p_npw_number          => l_npw_number
6569                                ,p_effective_date      => p_effective_date
6570                                ,p_party_id            => p_party_id
6571                                ,p_date_of_birth       => p_date_of_birth
6572                                ,p_start_date          => p_effective_date);
6573 
6574  if g_debug then
6575       hr_utility.set_location(l_proc,13);
6576  end if;
6577       --
6578       --  Check uniqueness of generated number
6579       --
6580       if l_gen_method <> 'A' then
6581         --
6582  if g_debug then
6583         hr_utility.set_location(l_proc,14);
6584  end if;
6585         --
6586         hr_person.validate_unique_number
6587                                   (p_person_id         => p_person_id
6588                                   ,p_business_group_id => p_business_group_id
6589                                   ,p_employee_number   => null
6590                                   ,p_applicant_number  => p_applicant_number
6591                                   ,p_npw_number        => null
6592                                   ,p_current_employee  => 'N'
6593                                   ,p_current_applicant => p_current_applicant
6594                                   ,p_current_npw       => 'N');
6595         --
6596  if g_debug then
6597         hr_utility.set_location(l_proc,15);
6598  end if;
6599         --
6600       end if;
6601       --
6602   end if;
6603  if g_debug then
6604   hr_utility.set_location(' Leaving:'|| l_proc,16);
6605  end if;
6606   exception
6607     when app_exception.application_exception then
6608     if not l_apl_sys
6609     then
6610       if hr_multi_message.exception_add
6611       (p_associated_column1      => 'PER_ALL_PEOPLE_F.APPLICANT_NUMBER'
6612       ) then
6613  if g_debug then
6614         hr_utility.set_location(' Leaving:'||l_proc, 17);
6615  end if;
6616         raise;
6617       end if;
6618     else
6619        if hr_multi_message.exception_add
6620         (p_associated_column1  => 'PER_ALL_PEOPLE_F.APPLICANT_NUMBER'
6621         ,p_associated_column2  => 'PER_ALL_PEOPLE_F.PERSON_TYPE_ID'
6622         ) then
6623  if g_debug then
6624           hr_utility.set_location(' Leaving:'||l_proc, 17);
6625  end if;
6626           raise;
6627       end if;
6628     end if;
6629  if g_debug then
6630   hr_utility.set_location(' Leaving:'||l_proc,18);
6631  end if;
6632 end chk_applicant_number;
6633 --
6634 --  ---------------------------------------------------------------------------
6635 --  |--------------------<  chk_date_emp_data_verified  >---------------------|
6636 --  ---------------------------------------------------------------------------
6637 --
6638 --  Description:
6639 --    Checks that date employee data verified is always null on insert. On
6640 --    update date employee data verified cannot be set to a not null value.
6641 --    However, a not null value for date employee data verified is permissable
6642 --    when other attributes apart from date employee data verified are being
6643 --    set.
6644 --
6645 --  Pre-conditions:
6646 --    Valid person_id
6647 --
6648 --  In Arguments:
6649 --    p_person_id
6650 --    p_date_employee_data_verified
6651 --    p_effective_start_date
6652 --    p_object_version_number
6653 --
6654 --  Post Success:
6655 --    If date_employee_data_verified is after the effective_start_date
6656 --    of the person record then process succeeds
6657 --
6658 --  Post Failure:
6659 --    If date_employee_data_verified is before the effective_start_date of
6660 --    the person record an application error will be raised and processing
6661 --    is terminated
6662 --
6663 --  Access Status:
6664 --    Internal Table Handler Use Only.
6665 --
6666 procedure chk_date_emp_data_verified
6667   (p_person_id                   in per_all_people_f.person_id%TYPE
6668   ,p_date_employee_data_verified in
6669    per_all_people_f.date_employee_data_verified%TYPE
6670   ,p_effective_start_date        in date
6671   ,p_object_version_number       in per_all_people_f.object_version_number%TYPE
6672   )
6673   is
6674 --
6675   l_proc             varchar2(72);
6676   l_api_updating     boolean;
6677 --
6678 begin
6679  if g_debug then
6680   l_proc :=  g_package||'chk_date_employee_data_verified';
6681   hr_utility.set_location('Entering:'|| l_proc, 1);
6682  end if;
6683   --
6684   -- Check if the person is being updated
6685   --
6686   l_api_updating := per_per_shd.api_updating
6687         (p_person_id              => p_person_id
6688         ,p_effective_date         => p_effective_start_date
6689         ,p_object_version_number  => p_object_version_number);
6690  if g_debug then
6691   hr_utility.set_location(l_proc, 2);
6692  end if;
6693   --
6694   if ((l_api_updating and
6695        nvl(per_per_shd.g_old_rec.date_employee_data_verified,
6696        hr_api.g_date) <> nvl(p_date_employee_data_verified,
6697        hr_api.g_date)) or (NOT l_api_updating)) then
6698     --
6699  if g_debug then
6700     hr_utility.set_location(l_proc, 3);
6701  end if;
6702     --
6703     --  Check that date employee data verified is valid
6704     --
6705     -- The date_employee_data_verified can be earlier than the
6706     -- effective_starte_date. Bug# 2775438.
6707 
6708     --if p_date_employee_data_verified is not null and
6709     --  p_date_employee_data_verified < p_effective_start_date then
6710       --  Error: Invalid value
6711     --  hr_utility.set_message(801, 'HR_51256_PER_DTE_EMP_DTE_START');
6712     --  hr_utility.raise_error;
6713     --end if;
6714 
6715     --
6716  if g_debug then
6717     hr_utility.set_location(l_proc, 4);
6718  end if;
6719   end if;
6720  if g_debug then
6721   hr_utility.set_location(' Leaving:'|| l_proc, 5);
6722  end if;
6723   exception
6724     when app_exception.application_exception then
6725       if hr_multi_message.exception_add
6726       (p_associated_column1  => 'PER_ALL_PEOPLE_F.DATE_EMPLOYEE_DATA_VERIFIED'
6727       ,p_associated_column2  => 'PER_ALL_PEOPLE_F.EFFECTIVE_START_DATE'
6728       ) then
6729  if g_debug then
6730         hr_utility.set_location(' Leaving:'||l_proc, 6);
6731  end if;
6732         raise;
6733       end if;
6734  if g_debug then
6735   hr_utility.set_location(' Leaving:'||l_proc,7);
6736  end if;
6737 end chk_date_emp_data_verified;
6738 --
6739 --  ---------------------------------------------------------------------------
6740 --  |-----------------------<  chk_vendor_id  >-------------------------------|
6741 --  ---------------------------------------------------------------------------
6742 --
6743 --  Description:
6744 --    Checks that vendor id is valid.
6745 --
6746 --  Pre-conditions:
6747 --    Valid person_id
6748 --
6749 --  In Arguments:
6750 --    p_person_id
6751 --    p_vendor_id
6752 --    p_effective_date
6753 --    p_object_version_number
6754 --
6755 --  Post Success:
6756 --    If vendor id is null and system person type is not one of  'EMP',
6757 --    'EMP_APL','EX_EMP',EX_EMP_APL then process succeeds.
6758 --    If vendor id is not null, system person type is one of 'EMP','EMP_APL',
6759 --    'EX_EMP','EX_EMP_APL' and vendor id exists in lookup table then process
6760 --    succeeds.
6761 --
6762 --  Post Failure:
6763 --    If vendor id is not null and system person type is not one of  'EMP',
6764 --    'EMP_APL','EX_EMP',EX_EMP_APL then process is terminated.
6765 --    If vendor id is not null, system person type is one of 'EMP','EMP_APL',
6766 --    'EX_EMP','EX_EMP_APL' and vendor id does not exists in lookup table then
6767 --    process is terminated.
6768 --
6769 --  Access Status:
6770 --    Internal Table Handler Use Only.
6771 --
6772 procedure chk_vendor_id
6773   (p_person_id                in per_all_people_f.person_id%TYPE
6774   ,p_vendor_id                in per_all_people_f.vendor_id%TYPE
6775   ,p_person_type_id           in per_all_people_f.person_type_id%TYPE
6776   ,p_business_group_id        in per_all_people_f.business_group_id%TYPE
6777   ,p_effective_date           in date
6778   ,p_object_version_number    in per_all_people_f.object_version_number%TYPE
6779   ) is
6780   --
6781   l_proc                  varchar2(72);
6782   l_api_updating          boolean;
6783   l_exists                varchar2(1);
6784   --
6785   -- Cursor to validate vendor_id in PO_VENDORS table.
6786   --
6787   cursor csr_chk_vendor is
6788      select null
6789      from   po_vendors
6790      where  vendor_id = p_vendor_id;
6791   --
6792 begin
6793  if g_debug then
6794   l_proc := g_package||'chk_vendor_id';
6795   hr_utility.set_location('Entering:'|| l_proc, 10);
6796  end if;
6797   --
6798   -- Check if the person is being updated
6799   --
6800   l_api_updating := per_per_shd.api_updating
6801         (p_person_id              => p_person_id
6802         ,p_effective_date         => p_effective_date
6803         ,p_object_version_number  => p_object_version_number);
6804  if g_debug then
6805   hr_utility.set_location(l_proc, 20);
6806  end if;
6807   --
6808   if ((l_api_updating and
6809        nvl(per_per_shd.g_old_rec.vendor_id, hr_api.g_number) <>
6810        nvl(p_vendor_id, hr_api.g_number)) or
6811       (NOT l_api_updating)) then
6812    --
6813  if g_debug then
6814    hr_utility.set_location(l_proc, 30);
6815  end if;
6816    --
6817    --  Check the system person type and validate as appropriate.
6818    --
6819    if  return_system_person_type(p_person_type_id,p_business_group_id)
6820           in ('EMP','EMP_APL','EX_EMP','EX_EMP_APL') then
6821      --
6822      -- Vendor id can be null, but if it is not null then it must exist
6823      -- in the PO_VENDORS table.
6824      --
6825      if p_vendor_id is not null then
6826  if g_debug then
6827        hr_utility.set_location(l_proc, 40);
6828  end if;
6829        open csr_chk_vendor;
6830        fetch csr_chk_vendor into l_exists;
6831        if csr_chk_vendor%notfound then
6832          close csr_chk_vendor;
6833          --
6834          -- Error : Invalid vendor id
6835          --
6836          hr_utility.set_message(801,'HR_51249_PER_INVALID_VENDOR');
6837          hr_utility.raise_error;
6838        end if;
6839        close csr_chk_vendor;
6840  if g_debug then
6841        hr_utility.set_location(l_proc, 50);
6842  end if;
6843      end if;
6844    else
6845      --
6846  if g_debug then
6847      hr_utility.set_location(l_proc, 60);
6848  end if;
6849      --
6850      -- Vendor id must be null.
6851      --
6852      if p_vendor_id is not null then
6853        --
6854        --  Error : Vendor must be null
6855        --
6856        hr_utility.set_message(801, 'HR_51250_PER_VENDOR_NOT_NULL');
6857        hr_utility.raise_error;
6858      end if;
6859  if g_debug then
6860      hr_utility.set_location(l_proc, 70);
6861  end if;
6862    end if;
6863   end if;
6864   --
6865  if g_debug then
6866   hr_utility.set_location(' Leaving:'|| l_proc, 80);
6867  end if;
6868   exception
6869     when app_exception.application_exception then
6870       if hr_multi_message.exception_add
6871       (p_associated_column1      => 'PER_ALL_PEOPLE_F.VENDOR_ID'
6872       ) then
6873  if g_debug then
6874         hr_utility.set_location(' Leaving:'||l_proc, 90);
6875  end if;
6876         raise;
6877       end if;
6878  if g_debug then
6879      hr_utility.set_location(' Leaving:'||l_proc,100);
6880  end if;
6881 end chk_vendor_id;
6882 --
6883 --  ---------------------------------------------------------------------------
6884 --  |------------------------------< chk_suffix >-----------------------------|
6885 --  ---------------------------------------------------------------------------
6886 --
6887 --  Description:
6888 --    - No validation
6889 --
6890 --  Pre-conditions:
6891 --    None
6892 --
6893 --  In Arguments:
6894 --    p_person_id
6895 --    p_marital_status
6896 --    p_effective_date
6897 --    p_object_version_number
6898 --
6899 --  Post Success:
6900 --    Processing continues if:
6901 --
6902 --  Post Failure:
6903 --    An application error is raised and processing is terminated if:
6904 --
6905 --  Access Status:
6906 --    Internal Table Handler Use Only.
6907 --
6908 procedure chk_suffix
6909   (p_person_id                in     per_all_people_f.person_id%TYPE
6910   ,p_suffix                   in     per_all_people_f.suffix%TYPE
6911   ,p_effective_date           in     date
6912   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
6913   )
6914 is
6915   --
6916   l_exists         varchar2(1);
6917   l_proc           varchar2(72)  :=  g_package||'chk_marital_status';
6918   l_api_updating   boolean;
6919   --
6920 begin
6921  if g_debug then
6922   hr_utility.set_location('Entering:'|| l_proc, 10);
6923  end if;
6924   --
6925   -- Check mandatory parameters have been set
6926   --
6927   hr_api.mandatory_arg_error
6928     (p_api_name       => l_proc
6929     ,p_argument       => 'effective date'
6930     ,p_argument_value => p_effective_date
6931     );
6932   --
6933  if g_debug then
6934   hr_utility.set_location(l_proc, 20);
6935  end if;
6936   --
6937   --  Only proceed with validation if:
6938   --  a) The current g_old_rec is current and
6939   --  b) The suffix value has changed
6940   --  c) a record is being inserted
6941   --
6942   l_api_updating := per_per_shd.api_updating
6943     (p_person_id             => p_person_id
6944     ,p_effective_date        => p_effective_date
6945     ,p_object_version_number => p_object_version_number
6946     );
6947  if g_debug then
6948   hr_utility.set_location(l_proc, 30);
6949  end if;
6950   --
6951   if ((l_api_updating
6952       and nvl(per_per_shd.g_old_rec.suffix, hr_api.g_varchar2)
6953       <> nvl(p_suffix,hr_api.g_varchar2))
6954     or
6955       (NOT l_api_updating))
6956   then
6957  if g_debug then
6958     hr_utility.set_location(l_proc, 40);
6959  end if;
6960     --
6961   end if;
6962  if g_debug then
6963   hr_utility.set_location(' Leaving:'|| l_proc, 70);
6964  end if;
6965 end chk_suffix;
6966 --
6967 --  ---------------------------------------------------------------------------
6968 --  |---------------------------< chk_work_telephone >------------------------|
6969 --  ---------------------------------------------------------------------------
6970 --
6971 --  Description:
6972 --    Checks that work_telephone is null. Work Telephone is now stored on the
6973 --    per_phones table.
6974 --
6975 --  Pre-conditions:
6976 --    None
6977 --
6978 --  In Arguments:
6979 --    p_work_telephone
6980 --
6981 --  Post Success:
6982 --    Processing continues
6983 --
6984 --  Post Failure:
6985 --    An application error is raised and processing is terminated
6986 --
6987 --  Access Status:
6988 --    Internal Table Handler Use Only.
6989 --
6990 procedure chk_work_telephone
6991   (p_person_id                in     per_all_people_f.person_id%TYPE
6992   ,p_work_telephone           in     per_all_people_f.work_telephone%TYPE
6993   ,p_effective_date           in     date
6994   ,p_object_version_number    in     per_all_people_f.object_version_number%TYPE
6995   )
6996 is
6997   --
6998   l_proc           varchar2(72);
6999   l_api_updating   boolean;
7000   --
7001 begin
7002  if g_debug then
7003   l_proc :=  g_package||'chk_work_telephone';
7004   hr_utility.set_location('Entering:'|| l_proc, 10);
7005  end if;
7006 
7007   l_api_updating := per_per_shd.api_updating
7008     (p_person_id             => p_person_id
7009     ,p_effective_date        => p_effective_date
7010     ,p_object_version_number => p_object_version_number
7011     );
7012  if g_debug then
7013   hr_utility.set_location(l_proc, 30);
7014  end if;
7015   --
7016   if ((l_api_updating
7017       and nvl(per_per_shd.g_old_rec.work_telephone, hr_api.g_varchar2)
7018       <> nvl(p_work_telephone,hr_api.g_varchar2))
7019     or
7020       (NOT l_api_updating))
7021   then
7022     --
7023     -- Check parameter is null
7024     --
7025  if g_debug then
7026     hr_utility.set_location('Work Number is:'|| p_work_telephone, 15);
7027  end if;
7028     if p_work_telephone is not null then
7029          hr_utility.set_message(801, 'HR_52217_PER_INVALID_PHONE');
7030          hr_utility.raise_error;
7031     end if;
7032   end if;
7033  if g_debug then
7034   hr_utility.set_location(' Leaving:'|| l_proc, 70);
7035  end if;
7036   exception
7037     when app_exception.application_exception then
7038       if hr_multi_message.exception_add
7039       (p_associated_column1      => 'PER_ALL_PEOPLE_F.WORK_TELEPHONE'
7040       ) then
7041  if g_debug then
7042         hr_utility.set_location(' Leaving:'||l_proc, 80);
7043  end if;
7044         raise;
7045       end if;
7046  if g_debug then
7047     hr_utility.set_location(' Leaving:'||l_proc,90);
7048  end if;
7049 end chk_work_telephone;
7050 --
7051 --  Fix 3573040
7052 --  Added new procedure chk_per_information_category
7053 --
7054 --  ---------------------------------------------------------------------------
7055 --  |-------------------<  chk_per_information_category  >--------------------|
7056 --  ---------------------------------------------------------------------------
7057 --
7058 --  Description:
7059 --    Checks if the information category has the valid legislation
7060 --
7061 --  In Arguments:
7062 --    p_per_information_category
7063 --    p_legislation_code
7064 --
7065 --  Post Success:
7066 --    If p_per_information_category is not null and it matches the legislation
7067 --    corresponding to the business group then the process succeeds.
7068 --    If p_per_information_category is null and a valid DDF context exists for
7069 --    the legislation of the business group, then the corresponding legislation
7070 --    is set for p_per_information_category
7071 --
7072 --  Post Failure:
7073 --    If p_per_information_category is not null and it does not match the
7074 --    legislation corresponding to the business group then the process fails.
7075 --
7076 --  Access Status:
7077 --    Internal Table Handler Use Only.
7078 --
7079 procedure chk_per_information_category
7080   (p_per_information_category in out nocopy per_all_people_f.per_information_category%TYPE
7081   ,p_legislation_code             in per_business_groups.legislation_code%TYPE
7082   ) is
7083 --
7084    l_ddf_exists varchar2(1);
7085 --
7086 begin
7087    -- Bug fix 38383715. Modified if condition.
7088    if p_per_information_category is not null
7089       and p_per_information_category <> p_legislation_code then
7090          hr_utility.set_message( 800, 'PER_449162_INFO_CATEGORY' );
7091          hr_utility.raise_error;
7092    else
7093          PER_PEOPLE3_PKG.get_ddf_exists
7094          ( p_legislation_code => p_legislation_code
7095          , p_ddf_exists       => l_ddf_exists );
7096          if l_ddf_exists = 'Y' then
7097             p_per_information_category := p_legislation_code;
7098          else
7099             p_per_information_category := null;
7100          end if;
7101    end if;
7102 end chk_per_information_category;
7103 --
7104 --  ---------------------------------------------------------------------------
7105 --  |------------------------<  chk_delete >----------------------------|
7106 --  ---------------------------------------------------------------------------
7107 --
7108 --  Description:
7109 --    Validates that rows may be deleted from per_all_people_f
7110 --
7111 --  Pre-conditions:
7112 --    None
7113 --
7114 --  In Arguments:
7115 --    p_person_id
7116 --    p_business_group_id
7117 --    p_person_type_id
7118 --    p_effective_date
7119 --    p_datetrack_mode
7120 --
7121 --  Post Success:
7122 --    If a row may be deleted then
7123 --    processing continues
7124 --
7125 --  Post Failure:
7126 --    If future changes to person type exist and datetrack mode is delete next
7127 --    change or delete future change
7128 --    an application error will be raised and processing is terminated
7129 --
7130 --    See perper.bru for full list of failure conditions handled by
7131 --    hr_person_delete.weak_predel_validation
7132 --    hr_person_delete.moderate_predel_validation and
7133 --
7134 --  Access Status:
7135 --    Internal Table Handler Use Only.
7136 --
7137 procedure chk_delete
7138   (p_person_id          in per_all_people_f.person_id%TYPE
7139   ,p_business_group_id  in per_all_people_f.business_group_id%TYPE
7140   ,p_person_type_id     in per_all_people_f.person_type_id%TYPE
7141   ,p_effective_date     in   date
7142   ,p_datetrack_mode     in   varchar2) is
7143 --
7144   l_exists             varchar2(1);
7145   l_proc               varchar2(72)  :=  g_package||'chk_delete';
7146   l_system_person_type varchar2(30);
7147 --
7148 --  check if future changes to system person type exist
7149 --
7150   cursor csr_chk_future_changes
7151     (c_system_person_type    per_person_types.system_person_type%TYPE
7152     )
7153   is
7154   select   null
7155     from   sys.dual
7156     where exists
7157       (select   null
7158        from     per_all_people_f ppf,
7159                 per_person_types ppt
7160        where    ppf.effective_start_date > p_effective_date
7161      and      ppf.person_id = p_person_id
7162        and      ppt.person_type_id = ppf.person_type_id
7163        and      ppt.system_person_type <> c_system_person_type
7164       );
7165 --
7166 begin
7167  if g_debug then
7168   hr_utility.set_location('Entering:'|| l_proc, 10);
7169  end if;
7170   --
7171   -- Check mandatory parameters have been set
7172   --
7173   hr_api.mandatory_arg_error
7174     (p_api_name       => l_proc
7175     ,p_argument       => 'business group id'
7176     ,p_argument_value => p_business_group_id
7177     );
7178   --
7179   hr_api.mandatory_arg_error
7180     (p_api_name       => l_proc
7181     ,p_argument       => 'person type id'
7182     ,p_argument_value => p_person_type_id
7183     );
7184   --
7185   hr_api.mandatory_arg_error
7186     (p_api_name       => l_proc
7187     ,p_argument       => 'effective date'
7188     ,p_argument_value => p_effective_date
7189     );
7190   --
7191   hr_api.mandatory_arg_error
7192     (p_api_name       => l_proc
7193     ,p_argument       => 'datetrack mode'
7194     ,p_argument_value => p_datetrack_mode
7195     );
7196  if g_debug then
7197   hr_utility.set_location(l_proc, 20);
7198  end if;
7199   --
7200   --  If delete mode is DELETE_NEXT_CHANGE or FUTURE_CHANGE
7201   --  check if rows exist in PER_PEOPLE_F where the system person type has
7202   --  changed
7203   --
7204   if p_datetrack_mode in ('DELETE_NEXT_CHANGE','FUTURE_CHANGE')
7205   then
7206     --
7207     l_system_person_type := return_system_person_type
7208                               (p_person_type_id,
7209                               p_business_group_id
7210                               );
7211     open csr_chk_future_changes(l_system_person_type);
7212     fetch csr_chk_future_changes into l_exists;
7213     if csr_chk_future_changes%found then
7214       close csr_chk_future_changes;
7215       --  Error: Delete not allowed
7216       hr_utility.set_message(801, 'HR_7726_PER_DEL_NOT_ALLOWED');
7217       hr_utility.raise_error;
7218     end if;
7219     close csr_chk_future_changes;
7220  if g_debug then
7221     hr_utility.set_location(l_proc, 20);
7222  end if;
7223   end if;
7224   --
7225  if g_debug then
7226   hr_utility.set_location(l_proc, 3);
7227  end if;
7228   --
7229   --  If delete mode in ('ZAP','DELETE','DELETE_NEXT_CHANGE',
7230   --                     'FUTURE_CHANGE') then
7231   --  carry out weak and moderate delete checks
7232   --
7233   -- if  p_datetrack_mode in ('ZAP','DELETE','DELETE_NEXT_CHANGE',
7234   -- 'FUTURE_CHANGE') then
7235   --
7236   if p_datetrack_mode in ('ZAP','DELETE') then
7237     --
7238     -- Fix for 3908271 starts here.
7239     -- Comment out the following calls.
7240     --
7241     /*
7242     hr_person_delete.weak_predel_validation(p_person_id  => p_person_id
7243                                            ,p_session_date => p_effective_date);
7244     hr_person_delete.moderate_predel_validation(p_person_id  => p_person_id
7245                                            ,p_session_date => p_effective_date);
7246     */
7247     --
7248     -- Call hr_person_internal procedures.
7249     --
7250     hr_person_internal.weak_predel_validation(p_person_id  => p_person_id
7251                                            ,p_effective_date => p_effective_date);
7252     hr_person_internal.strong_predel_validation(p_person_id  => p_person_id
7253                                            ,p_effective_date => p_effective_date);
7254     --
7255     -- Fix for 3908271 ends here.
7256     --
7257   end if;
7258   --
7259  if g_debug then
7260   hr_utility.set_location(' Leaving:'|| l_proc, 4);
7261  end if;
7262 end chk_delete;
7263 --
7264 -- ----------------------------------------------------------------------------
7265 -- |----------------------< check_non_updateable_args >-----------------------|
7266 -- ----------------------------------------------------------------------------
7267 -- {Start Of Comments}
7268 --
7269 -- Description:
7270 --   This procedure is used to ensure that non updatetable attributes have
7271 --   not been updated. If an attribute has been updated an error is generated.
7272 --
7273 -- Pre Conditions:
7274 --   g_old_rec has been populated with details of the values currently in
7275 --   the database.
7276 --
7277 -- In Arguments:
7278 --   p_rec has been populated with the updated values the user would like the
7279 --   record set to.
7280 --
7281 -- Post Success:
7282 --   Processing continues if all the non updateable attributes have not
7283 --   changed.
7284 --
7285 -- Post Failure:
7286 --   An application error is raised if any of the non updatable attributes
7287 --   (business_group_id)
7288 --   have been altered.
7289 --
7290 -- Access Status:
7291 --   Internal Development Use Only.
7292 -- {End Of Comments}
7293 -- ----------------------------------------------------------------------------
7294 Procedure check_non_updateable_args(p_rec in per_per_shd.g_rec_type
7295                                    ,p_effective_date in date) is
7296 --
7297   l_proc     varchar2(72) := g_package||'check_non_updateable_args';
7298 --
7299 Begin
7300  if g_debug then
7301    hr_utility.set_location('Entering:'||l_proc, 5);
7302  end if;
7303 --
7304 -- Only proceed with validation if a row exists for
7305 -- the current record in the HR Schema
7306 --
7307   if not per_per_shd.api_updating
7308     (p_person_id                  => p_rec.person_id
7309     ,p_effective_date             => p_effective_date
7310     ,p_object_version_number      => p_rec.object_version_number) then
7311     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
7312     hr_utility.set_message_token('PROCEDURE', l_proc);
7313     hr_utility.set_message_token('STEP', '5');
7314   end if;
7315   --
7316  if g_debug then
7317   hr_utility.set_location(l_proc, 6);
7318  end if;
7319   --
7320   if nvl(p_rec.business_group_id, hr_api.g_number) <>
7321      nvl(per_per_shd.g_old_rec.business_group_id, hr_api.g_number) then
7322      hr_api.argument_changed_error
7323      (
7324       p_api_name   => l_proc
7325      ,p_argument   => 'BUSINESS_GROUP_ID'
7326      ,p_base_table => per_per_shd.g_tab_nam
7327      );
7328   end if;
7329  if g_debug then
7330   hr_utility.set_location(' Leaving '||l_proc, 7);
7331  end if;
7332   --
7333 end check_non_updateable_args;
7334 --
7335 -- ----------------------------------------------------------------------------
7336 -- |--------------------------< dt_update_validate >--------------------------|
7337 -- ----------------------------------------------------------------------------
7338 -- {Start Of Comments}
7339 --
7340 -- Description:
7341 --   This procedure is used for referential integrity of datetracked
7342 --   parent entities when a datetrack update operation is taking place
7343 --   and where there is no cascading of update defined for this entity.
7344 --
7345 -- Pre Conditions:
7346 --   This procedure is called from the update_validate.
7347 --
7348 -- In Arguments:
7349 --
7350 -- Post Success:
7351 --   Processing continues.
7352 --
7353 -- Post Failure:
7354 --
7355 -- Developer Implementation Notes:
7356 --   This procedure should not need maintenance unless the HR Schema model
7357 --   changes.
7358 --
7359 -- Access Status:
7360 --   Internal Table Handler Use Only.
7361 --
7362 -- {End Of Comments}
7363 -- ----------------------------------------------------------------------------
7364 Procedure dt_update_validate
7365             (
7366         p_datetrack_mode           in varchar2,
7367              p_validation_start_date        in date,
7368         p_validation_end_date      in date) Is
7369 --
7370   l_proc     varchar2(72) := g_package||'dt_update_validate';
7371 --l_integrity_error Exception;
7372   l_table_name     all_tables.table_name%TYPE;
7373 --
7374 Begin
7375  if g_debug then
7376   hr_utility.set_location('Entering:'||l_proc, 5);
7377  end if;
7378   --
7379   -- Ensure that the p_datetrack_mode argument is not null
7380   --
7381   hr_api.mandatory_arg_error
7382     (p_api_name       => l_proc,
7383      p_argument       => 'datetrack_mode',
7384      p_argument_value => p_datetrack_mode);
7385   --
7386   -- Only perform the validation if the datetrack update mode is valid
7387   --
7388   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
7389     --
7390     --
7391     -- Ensure the arguments are not null
7392     --
7393     hr_api.mandatory_arg_error
7394       (p_api_name       => l_proc,
7395        p_argument       => 'validation_start_date',
7396        p_argument_value => p_validation_start_date);
7397     --
7398     hr_api.mandatory_arg_error
7399       (p_api_name       => l_proc,
7400        p_argument       => 'validation_end_date',
7401        p_argument_value => p_validation_end_date);
7402     --
7403     --
7404     --
7405   End If;
7406   --
7407  if g_debug then
7408   hr_utility.set_location(' Leaving:'||l_proc, 10);
7409  end if;
7410 Exception
7411   /*When l_integrity_error Then
7412     --
7413     -- A referential integrity check was violated therefore
7414     -- we must error
7415     --
7416     hr_utility.set_message(801, 'HR_7216_DT_UPD_INTEGRITY_ERR');
7417     hr_utility.set_message_token('TABLE_NAME', l_table_name);
7418     hr_utility.raise_error;*/
7419   When Others Then
7420     --
7421     -- An unhandled or unexpected error has occurred which
7422     -- we must report
7423     --
7424     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
7425     hr_utility.set_message_token('PROCEDURE', l_proc);
7426     hr_utility.set_message_token('STEP','15');
7427     hr_utility.raise_error;
7428 End dt_update_validate;
7429 --
7430 -- ----------------------------------------------------------------------------
7431 -- |--------------------------< dt_delete_validate >--------------------------|
7432 -- ----------------------------------------------------------------------------
7433 -- {Start Of Comments}
7434 --
7435 -- Description:
7436 --   This procedure is used for referential integrity of datetracked
7437 --   child entities when either a datetrack DELETE or ZAP is in operation
7438 --   and where there is no cascading of delete defined for this entity.
7439 --   For the datetrack mode of DELETE or ZAP we must ensure that no
7440 --   datetracked child rows exist between the validation start and end
7441 --   dates.
7442 --
7443 -- Pre Conditions:
7444 --   This procedure is called from the delete_validate.
7445 --
7446 -- In Arguments:
7447 --
7448 -- Post Success:
7449 --   Processing continues.
7450 --
7451 -- Post Failure:
7452 --   If a row exists by determining the returning Boolean value from the
7453 --   generic dt_api.rows_exist function then we must supply an error via
7454 --   the use of the local exception handler l_rows_exist.
7455 --
7456 -- Developer Implementation Notes:
7457 --   This procedure should not need maintenance unless the HR Schema model
7458 --   changes.
7459 --
7460 -- Access Status:
7461 --   Internal Table Handler Use Only.
7462 --
7463 -- {End Of Comments}
7464 -- ----------------------------------------------------------------------------
7465 Procedure dt_delete_validate
7466             (p_person_id      in number,
7467              p_datetrack_mode    in varchar2,
7468         p_validation_start_date  in date,
7469         p_validation_end_date in date) Is
7470 --
7471   l_proc varchar2(72)   := g_package||'dt_delete_validate';
7472 --l_rows_exist Exception;
7473   l_table_name all_tables.table_name%TYPE;
7474 --
7475 Begin
7476  if g_debug then
7477   hr_utility.set_location('Entering:'||l_proc, 5);
7478  end if;
7479   --
7480   -- Ensure that the p_datetrack_mode argument is not null
7481   --
7482   hr_api.mandatory_arg_error
7483     (p_api_name       => l_proc,
7484      p_argument       => 'datetrack_mode',
7485      p_argument_value => p_datetrack_mode);
7486   --
7487   -- Only perform the validation if the datetrack mode is either
7488   -- DELETE or ZAP
7489   --
7490   If (p_datetrack_mode = 'DELETE' or
7491       p_datetrack_mode = 'ZAP') then
7492     --
7493     --
7494     -- Ensure the arguments are not null
7495     --
7496     hr_api.mandatory_arg_error
7497       (p_api_name       => l_proc,
7498        p_argument       => 'validation_start_date',
7499        p_argument_value => p_validation_start_date);
7500     --
7501     hr_api.mandatory_arg_error
7502       (p_api_name       => l_proc,
7503        p_argument       => 'validation_end_date',
7504        p_argument_value => p_validation_end_date);
7505     --
7506     hr_api.mandatory_arg_error
7507       (p_api_name       => l_proc,
7508        p_argument       => 'person_id',
7509        p_argument_value => p_person_id);
7510     --
7511     --
7512     if (dt_api.rows_exist
7513        (p_base_table_name => 'per_contracts_f',
7514         p_base_key_column => 'person_id',
7515         p_base_key_value => p_person_id,
7516         p_from_date => p_validation_start_date,
7517         p_to_date => p_validation_end_date)) then
7518         l_table_name := 'contracts';
7519         hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
7520         hr_utility.set_message_token('TABLE_NAME', l_table_name);
7521         hr_multi_message.add;
7522     --  raise l_rows_exist;
7523     end if;
7524     --
7525     --
7526   End If;
7527   --
7528  if g_debug then
7529   hr_utility.set_location(' Leaving:'||l_proc, 10);
7530  end if;
7531 Exception
7532   /*When l_rows_exist Then
7533     --
7534     -- A referential integrity check was violated therefore
7535     -- we must error
7536     --
7537     hr_utility.set_message(801, 'HR_7215_DT_CHILD_EXISTS');
7538     hr_utility.set_message_token('TABLE_NAME', l_table_name);
7539     hr_utility.raise_error;*/
7540   When Others Then
7541     --
7542     -- An unhandled or unexpected error has occurred which
7543     -- we must report
7544     --
7545     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
7546     hr_utility.set_message_token('PROCEDURE', l_proc);
7547     hr_utility.set_message_token('STEP','15');
7548     hr_utility.raise_error;
7549 End dt_delete_validate;
7550 --
7551 -- -----------------------------------------------------------------------
7552 -- |------------------------------< chk_df >-----------------------------|
7553 -- -----------------------------------------------------------------------
7554 --
7555 -- Description:
7556 --   Validates the all Descriptive Flexfield values.
7557 --
7558 -- Pre-conditions:
7559 --   All other columns have been validated. Must be called as the
7560 --   last step from insert_validate and update_validate.
7561 --
7562 -- In Arguments:
7563 --   p_rec
7564 --
7565 -- Post Success:
7566 --   If the Descriptive Flexfield structure column and data values are
7567 --   all valid this procedure will end normally and processing will
7568 --   continue.
7569 --
7570 -- Post Failure:
7571 --   If the Descriptive Flexfield structure column value or any of
7572 --   the data values are invalid then an application error is raised as
7573 --   a PL/SQL exception.
7574 --
7575 -- Access Status:
7576 --   Internal Row Handler Use Only.
7577 --
7578 procedure chk_df
7579   (p_rec in per_per_shd.g_rec_type) is
7580 --
7581   l_proc     varchar2(72);
7582 --
7583 begin
7584  if g_debug then
7585    l_proc    := g_package||'chk_df';
7586   hr_utility.set_location('Entering:'||l_proc, 10);
7587  end if;
7588   --
7589   if ((p_rec.person_id is not null) and (
7590     nvl(per_per_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
7591     nvl(p_rec.attribute_category, hr_api.g_varchar2) or
7592     nvl(per_per_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
7593     nvl(p_rec.attribute1, hr_api.g_varchar2) or
7594     nvl(per_per_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
7595     nvl(p_rec.attribute2, hr_api.g_varchar2) or
7596     nvl(per_per_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
7597     nvl(p_rec.attribute3, hr_api.g_varchar2) or
7598     nvl(per_per_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
7599     nvl(p_rec.attribute4, hr_api.g_varchar2) or
7600     nvl(per_per_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
7601     nvl(p_rec.attribute5, hr_api.g_varchar2) or
7602     nvl(per_per_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
7603     nvl(p_rec.attribute6, hr_api.g_varchar2) or
7604     nvl(per_per_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
7605     nvl(p_rec.attribute7, hr_api.g_varchar2) or
7606     nvl(per_per_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
7607     nvl(p_rec.attribute8, hr_api.g_varchar2) or
7608     nvl(per_per_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
7609     nvl(p_rec.attribute9, hr_api.g_varchar2) or
7610     nvl(per_per_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
7611     nvl(p_rec.attribute10, hr_api.g_varchar2) or
7612     nvl(per_per_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
7613     nvl(p_rec.attribute11, hr_api.g_varchar2) or
7614     nvl(per_per_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
7615     nvl(p_rec.attribute12, hr_api.g_varchar2) or
7616     nvl(per_per_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
7617     nvl(p_rec.attribute13, hr_api.g_varchar2) or
7618     nvl(per_per_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
7619     nvl(p_rec.attribute14, hr_api.g_varchar2) or
7620     nvl(per_per_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
7621     nvl(p_rec.attribute15, hr_api.g_varchar2) or
7622     nvl(per_per_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
7623     nvl(p_rec.attribute16, hr_api.g_varchar2) or
7624     nvl(per_per_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
7625     nvl(p_rec.attribute17, hr_api.g_varchar2) or
7626     nvl(per_per_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
7627     nvl(p_rec.attribute18, hr_api.g_varchar2) or
7628     nvl(per_per_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
7629     nvl(p_rec.attribute19, hr_api.g_varchar2) or
7630     nvl(per_per_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
7631     nvl(p_rec.attribute20, hr_api.g_varchar2) or
7632     nvl(per_per_shd.g_old_rec.attribute21, hr_api.g_varchar2) <>
7633     nvl(p_rec.attribute21, hr_api.g_varchar2) or
7634     nvl(per_per_shd.g_old_rec.attribute22, hr_api.g_varchar2) <>
7635     nvl(p_rec.attribute22, hr_api.g_varchar2) or
7636     nvl(per_per_shd.g_old_rec.attribute23, hr_api.g_varchar2) <>
7637     nvl(p_rec.attribute23, hr_api.g_varchar2) or
7638     nvl(per_per_shd.g_old_rec.attribute24, hr_api.g_varchar2) <>
7639     nvl(p_rec.attribute24, hr_api.g_varchar2) or
7640     nvl(per_per_shd.g_old_rec.attribute25, hr_api.g_varchar2) <>
7641     nvl(p_rec.attribute25, hr_api.g_varchar2) or
7642     nvl(per_per_shd.g_old_rec.attribute26, hr_api.g_varchar2) <>
7643     nvl(p_rec.attribute26, hr_api.g_varchar2) or
7644     nvl(per_per_shd.g_old_rec.attribute27, hr_api.g_varchar2) <>
7645     nvl(p_rec.attribute27, hr_api.g_varchar2) or
7646     nvl(per_per_shd.g_old_rec.attribute28, hr_api.g_varchar2) <>
7647     nvl(p_rec.attribute28, hr_api.g_varchar2) or
7648     nvl(per_per_shd.g_old_rec.attribute29, hr_api.g_varchar2) <>
7649     nvl(p_rec.attribute29, hr_api.g_varchar2) or
7650     nvl(per_per_shd.g_old_rec.attribute30, hr_api.g_varchar2) <>
7651     nvl(p_rec.attribute30, hr_api.g_varchar2)))
7652     or (p_rec.person_id is null) then
7653    --
7654    -- Only execute the validation if absolutely necessary:
7655    -- a) During update, the structure column value or any
7656    --    of the attribute values have actually changed.
7657    -- b) During insert.
7658    --
7659    hr_dflex_utility.ins_or_upd_descflex_attribs
7660      (p_appl_short_name     => 'PER'
7661       ,p_descflex_name      => 'PER_PEOPLE'
7662       ,p_attribute_category => p_rec.attribute_category
7663       ,p_attribute1_name    => 'ATTRIBUTE1'
7664       ,p_attribute1_value   => p_rec.attribute1
7665       ,p_attribute2_name    => 'ATTRIBUTE2'
7666       ,p_attribute2_value   => p_rec.attribute2
7667       ,p_attribute3_name    => 'ATTRIBUTE3'
7668       ,p_attribute3_value   => p_rec.attribute3
7669       ,p_attribute4_name    => 'ATTRIBUTE4'
7670       ,p_attribute4_value   => p_rec.attribute4
7671       ,p_attribute5_name    => 'ATTRIBUTE5'
7672       ,p_attribute5_value   => p_rec.attribute5
7673       ,p_attribute6_name    => 'ATTRIBUTE6'
7674       ,p_attribute6_value   => p_rec.attribute6
7675       ,p_attribute7_name    => 'ATTRIBUTE7'
7676       ,p_attribute7_value   => p_rec.attribute7
7677       ,p_attribute8_name    => 'ATTRIBUTE8'
7678       ,p_attribute8_value   => p_rec.attribute8
7679       ,p_attribute9_name    => 'ATTRIBUTE9'
7680       ,p_attribute9_value   => p_rec.attribute9
7681       ,p_attribute10_name   => 'ATTRIBUTE10'
7682       ,p_attribute10_value  => p_rec.attribute10
7683       ,p_attribute11_name   => 'ATTRIBUTE11'
7684       ,p_attribute11_value  => p_rec.attribute11
7685       ,p_attribute12_name   => 'ATTRIBUTE12'
7686       ,p_attribute12_value  => p_rec.attribute12
7687       ,p_attribute13_name   => 'ATTRIBUTE13'
7688       ,p_attribute13_value  => p_rec.attribute13
7689       ,p_attribute14_name   => 'ATTRIBUTE14'
7690       ,p_attribute14_value  => p_rec.attribute14
7691       ,p_attribute15_name   => 'ATTRIBUTE15'
7692       ,p_attribute15_value  => p_rec.attribute15
7693       ,p_attribute16_name   => 'ATTRIBUTE16'
7694       ,p_attribute16_value  => p_rec.attribute16
7695       ,p_attribute17_name   => 'ATTRIBUTE17'
7696       ,p_attribute17_value  => p_rec.attribute17
7697       ,p_attribute18_name   => 'ATTRIBUTE18'
7698       ,p_attribute18_value  => p_rec.attribute18
7699       ,p_attribute19_name   => 'ATTRIBUTE19'
7700       ,p_attribute19_value  => p_rec.attribute19
7701       ,p_attribute20_name   => 'ATTRIBUTE20'
7702       ,p_attribute20_value  => p_rec.attribute20
7703       ,p_attribute21_name   => 'ATTRIBUTE21'
7704       ,p_attribute21_value  => p_rec.attribute21
7705       ,p_attribute22_name   => 'ATTRIBUTE22'
7706       ,p_attribute22_value  => p_rec.attribute22
7707       ,p_attribute23_name   => 'ATTRIBUTE23'
7708       ,p_attribute23_value  => p_rec.attribute23
7709       ,p_attribute24_name   => 'ATTRIBUTE24'
7710       ,p_attribute24_value  => p_rec.attribute24
7711       ,p_attribute25_name   => 'ATTRIBUTE25'
7712       ,p_attribute25_value  => p_rec.attribute25
7713       ,p_attribute26_name   => 'ATTRIBUTE26'
7714       ,p_attribute26_value  => p_rec.attribute26
7715       ,p_attribute27_name   => 'ATTRIBUTE27'
7716       ,p_attribute27_value  => p_rec.attribute27
7717       ,p_attribute28_name   => 'ATTRIBUTE28'
7718       ,p_attribute28_value  => p_rec.attribute28
7719       ,p_attribute29_name   => 'ATTRIBUTE29'
7720       ,p_attribute29_value  => p_rec.attribute29
7721       ,p_attribute30_name   => 'ATTRIBUTE30'
7722       ,p_attribute30_value  => p_rec.attribute30
7723       );
7724   end if;
7725   --
7726  if g_debug then
7727   hr_utility.set_location(' Leaving:'||l_proc, 20);
7728  end if;
7729 
7730 end chk_df;
7731 --
7732 -- ----------------------------------------------------------------------------
7733 -- |---------------------------< insert_validate >----------------------------|
7734 -- ----------------------------------------------------------------------------
7735 Procedure insert_validate
7736    (p_rec             in out nocopy per_per_shd.g_rec_type,
7737     p_effective_date     in date,
7738     p_datetrack_mode     in varchar2,
7739     p_validation_start_date    in date,
7740     p_validation_end_date      in date,
7741          p_name_combination_warning out nocopy boolean,
7742          p_dob_null_warning         out nocopy boolean,
7743          p_orig_hire_warning        out nocopy boolean) is
7744 --
7745   l_proc varchar2(72);
7746   l_legislation_code        per_business_groups.legislation_code%TYPE;
7747 --
7748   l_first_name  per_all_people_f.first_name%TYPE;
7749   l_last_name   per_all_people_f.last_name%TYPE;
7750   l_output  varchar2(150);
7751   l_rgeflg  varchar2(10);
7752   l_duplicate_flag varchar2(1);
7753 --
7754   cursor csr_bg is
7755     select legislation_code
7756     from per_business_groups pbg
7757     where pbg.business_group_id = p_rec.business_group_id;
7758 --
7759 -- Added for 3104595 starts here
7760   cursor csr_bg_start_date is
7761     select date_from
7762       from per_business_groups pbg
7763      where pbg.business_group_id = p_rec.business_group_id;
7764   --
7765   l_bg_start_date    date;
7766 -- Added for 3104595 ends here
7767 --
7768 --
7769 Begin
7770  if g_debug then
7771   l_proc  := g_package||'insert_validate';
7772   hr_utility.set_location('Entering:'||l_proc, 10);
7773  end if;
7774   --
7775   -- Set global variable used to improve calling of return_system_status_type
7776   -- when called multiple times on same pass through the validation process.
7777   -- A null value indicates that the function has not been called on this pass
7778   -- through the validation process.
7779   --
7780   g_previous_sys_per_type := NULL;
7781   --
7782   -- Check that no unsupported attributes have been set.
7783   --
7784   per_per_bus1.chk_unsupported_attributes
7785     (p_person_id             =>  p_rec.person_id
7786     ,p_fast_path_employee    =>  p_rec.fast_path_employee
7787     ,p_order_name            =>  p_rec.order_name
7788     ,p_projected_start_date  =>  p_rec.projected_start_date
7789     ,p_rehire_authorizor     =>  p_rec.rehire_authorizor
7790     ,p_effective_date        =>  p_effective_date
7791     ,p_object_version_number =>  p_rec.object_version_number
7792     );
7793   --
7794   -- Call all supporting business operations
7795   -- Mapping to the appropriate Business Rules in perper.bru is provided.
7796   --
7797   --  Validate Business Group Id
7798   --
7799   hr_api.validate_bus_grp_id
7800   (p_business_group_id => p_rec.business_group_id
7801   ,p_associated_column1 => per_per_shd.g_tab_nam || '.BUSINESS_GROUP_ID'
7802   );
7803   hr_multi_message.end_validation_set;
7804  if g_debug then
7805   hr_utility.set_location(l_proc, 20);
7806  end if;
7807   --
7808   -- Validate Correspondence Language
7809   --
7810   per_per_bus1.chk_correspondence_language
7811     (p_person_id                  =>  p_rec.person_id
7812     ,p_effective_date             =>  p_effective_date
7813     ,p_correspondence_language    =>  p_rec.correspondence_language
7814     ,p_object_version_number      =>  p_rec.object_version_number);
7815   --
7816   -- Added for 3104595 starts here
7817      open csr_bg_start_date;
7818      fetch csr_bg_start_date  into  l_bg_start_date;
7819 -- Modified the check condition as part of fix 5407679
7820      if csr_bg_start_date%found then
7821         if l_bg_start_date > p_rec.effective_start_date then
7822            fnd_message.set_name('PER','HR_52383_EFF_DATE_RANGE');
7823            fnd_message.raise_error;
7824         end if;
7825      end if;
7826      close csr_bg_start_date;
7827 --
7828 -- Added for 3104595 ends here
7829 --
7830   --
7831   -- Validate FTE capacity
7832   --
7833   per_per_bus1.chk_fte_capacity
7834     (p_person_id              =>  p_rec.person_id
7835     ,p_effective_date         =>  p_effective_date
7836     ,p_fte_capacity           =>  p_rec.fte_capacity
7837     ,p_object_version_number  =>  p_rec.object_version_number);
7838   --
7839   -- Validate Background Check Status
7840   --
7841   per_per_bus1.chk_BACKGROUND_CHECK_STATUS
7842     (p_person_id                   =>  p_rec.person_id
7843     ,p_BACKGROUND_CHECK_STATUS     =>  p_rec.BACKGROUND_CHECK_STATUS
7844     ,p_effective_date              =>  p_effective_date
7845     ,p_validation_start_date       =>  p_validation_start_date
7846     ,p_validation_end_date         =>  p_validation_end_date
7847     ,p_object_version_number       =>  p_rec.object_version_number
7848     );
7849  if g_debug then
7850   hr_utility.set_location(l_proc, 30);
7851  end if;
7852   --
7853   -- Validate Blood Type
7854   --
7855   per_per_bus1.chk_blood_type
7856     (p_person_id                   =>  p_rec.person_id
7857     ,p_blood_type                  =>  p_rec.blood_type
7858     ,p_effective_date              =>  p_effective_date
7859     ,p_validation_start_date       =>  p_validation_start_date
7860     ,p_validation_end_date         =>  p_validation_end_date
7861     ,p_object_version_number       =>  p_rec.object_version_number
7862     );
7863  if g_debug then
7864   hr_utility.set_location(l_proc, 40);
7865  end if;
7866   --
7867   -- Validate Student Status
7868   --
7869   per_per_bus1.chk_student_status
7870     (p_person_id                   =>  p_rec.person_id
7871     ,p_student_status              =>  p_rec.student_status
7872     ,p_effective_date              =>  p_effective_date
7873     ,p_validation_start_date       =>  p_validation_start_date
7874     ,p_validation_end_date         =>  p_validation_end_date
7875     ,p_object_version_number       =>  p_rec.object_version_number
7876     );
7877  if g_debug then
7878   hr_utility.set_location(l_proc, 50);
7879  end if;
7880   --
7881   -- Validate Work Schedule
7882   --
7883   per_per_bus1.chk_work_schedule
7884     (p_person_id             =>  p_rec.person_id
7885     ,p_work_schedule         =>  p_rec.work_schedule
7886     ,p_effective_date        =>  p_effective_date
7887     ,p_validation_start_date =>  p_validation_start_date
7888     ,p_validation_end_date   =>  p_validation_end_date
7889     ,p_object_version_number =>  p_rec.object_version_number
7890     );
7891  if g_debug then
7892   hr_utility.set_location(l_proc, 60);
7893  end if;
7894   --
7895   -- Validate Rehire Recommendation
7896   --
7897   per_per_bus1.chk_rehire_recommendation
7898     (p_person_id             =>  p_rec.person_id
7899     ,p_rehire_recommendation =>  p_rec.rehire_recommendation
7900     ,p_effective_date        =>  p_effective_date
7901     ,p_validation_start_date =>  p_validation_start_date
7902     ,p_validation_end_date   =>  p_validation_end_date
7903     ,p_object_version_number =>  p_rec.object_version_number
7904     );
7905  if g_debug then
7906   hr_utility.set_location(l_proc, 70);
7907  end if;
7908   --
7909   -- Validate Benefit Group Id
7910   --
7911   per_per_bus1.chk_benefit_group_id
7912     (p_person_id             =>  p_rec.person_id
7913     ,p_benefit_group_id      =>  p_rec.benefit_group_id
7914     ,p_effective_date        =>  p_effective_date
7915     ,p_object_version_number =>  p_rec.object_version_number
7916     );
7917  if g_debug then
7918   hr_utility.set_location(l_proc, 80);
7919  end if;
7920   --
7921   -- Validate Receipt of Death Certificate date.
7922   --
7923   per_per_bus1.chk_date_death_and_rcpt_cert
7924     (p_person_id             =>  p_rec.person_id
7925     ,p_receipt_of_death_cert_date =>  p_rec.receipt_of_death_cert_date
7926     ,p_effective_date        =>  p_effective_date
7927     ,p_object_version_number =>  p_rec.object_version_number
7928     ,p_date_of_death         =>  p_rec.date_of_death
7929     );
7930  if g_debug then
7931   hr_utility.set_location(l_proc, 90);
7932  end if;
7933   --
7934   -- Validate the dependent's adoption date.
7935   --
7936   per_per_bus1.chk_birth_adoption_date
7937     (p_person_id             =>  p_rec.person_id
7938     ,p_dpdnt_adoption_date   =>  p_rec.dpdnt_adoption_date
7939     ,p_date_of_birth         =>  p_rec.date_of_birth
7940     ,p_effective_date        =>  p_effective_date
7941     ,p_object_version_number =>  p_rec.object_version_number
7942     );
7943  if g_debug then
7944   hr_utility.set_location(l_proc, 100);
7945  end if;
7946   --
7947   -- Validate registered disabled flag.
7948   --
7949   per_per_bus1.chk_rd_flag
7950     (p_person_id             =>  p_rec.person_id
7951     ,p_registered_disabled_flag =>  p_rec.registered_disabled_flag
7952     ,p_effective_date        =>  p_effective_date
7953     ,p_validation_start_date =>  p_validation_start_date
7954     ,p_validation_end_date   =>  p_validation_end_date
7955     ,p_object_version_number =>  p_rec.object_version_number
7956     );
7957  if g_debug then
7958   hr_utility.set_location(l_proc, 110);
7959  end if;
7960   --
7961   -- Validate Date of Death.
7962   --
7963   per_per_bus1.chk_date_of_death
7964     (p_person_id             =>  p_rec.person_id
7965     ,p_date_of_death         =>  p_rec.date_of_death
7966     ,p_date_of_birth         =>  p_rec.date_of_birth
7967     ,p_effective_date        =>  p_effective_date
7968     ,p_object_version_number =>  p_rec.object_version_number
7969     );
7970  if g_debug then
7971   hr_utility.set_location(l_proc, 120);
7972  end if;
7973     --
7974     -- Validate uses tobacco flag.
7975     --
7976   per_per_bus1.chk_uses_tobacco
7977     (p_person_id             =>  p_rec.person_id
7978     ,p_uses_tobacco_flag     =>  p_rec.uses_tobacco_flag
7979     ,p_effective_date        =>  p_effective_date
7980     ,p_validation_start_date =>  p_validation_start_date
7981     ,p_validation_end_date   =>  p_validation_end_date
7982     ,p_object_version_number =>  p_rec.object_version_number
7983      );
7984  if g_debug then
7985   hr_utility.set_location(l_proc, 125);
7986  end if;
7987 
7988   --
7989   chk_orig_and_start_dates
7990     (p_person_id             =>  p_rec.person_id
7991     ,p_person_type_id        =>  p_rec.person_type_id
7992     ,p_business_group_id     =>  p_rec.business_group_id
7993     ,p_original_date_of_hire =>  p_rec.original_date_of_hire
7994     ,p_start_date            =>  p_rec.start_date
7995     ,p_effective_date        =>  p_effective_date
7996     ,p_object_version_number =>  p_rec.object_version_number
7997     ,p_orig_hire_warning     =>  p_orig_hire_warning
7998     );
7999  if g_debug then
8000   hr_utility.set_location(l_proc, 130);
8001  end if;
8002   --
8003   --  Validate Person Type ID
8004   --
8005   chk_person_type_id
8006     (p_person_id                =>  p_rec.person_id
8007     ,p_business_group_id        =>  p_rec.business_group_id
8008     ,p_person_type_id           =>  p_rec.person_type_id
8009     ,p_old_person_type_id       =>  p_rec.person_type_id
8010     ,p_current_employee_flag    =>  p_rec.current_employee_flag
8011     ,p_current_applicant_flag   =>  p_rec.current_applicant_flag
8012     ,p_current_emp_or_apl_flag  =>  p_rec.current_emp_or_apl_flag
8013     ,p_effective_date           =>  p_effective_date
8014     ,p_validation_start_date    =>  p_validation_start_date
8015     ,p_object_version_number    =>  p_rec.object_version_number
8016     ,p_datetrack_mode           =>  p_datetrack_mode
8017     );
8018  if g_debug then
8019   hr_utility.set_location(l_proc, 30);
8020  end if;
8021   --
8022   -- Set current flags
8023   --
8024   set_current_flags
8025     (p_person_id                =>  p_rec.person_id
8026     ,p_business_group_id        =>  p_rec.business_group_id
8027     ,p_person_type_id           =>  p_rec.person_type_id
8028     ,p_current_employee_flag    =>  p_rec.current_employee_flag
8029     ,p_current_applicant_flag   =>  p_rec.current_applicant_flag
8030     ,p_current_emp_or_apl_flag  =>  p_rec.current_emp_or_apl_flag
8031     ,p_effective_date           =>  p_effective_date
8032     ,p_object_version_number    =>  p_rec.object_version_number
8033     );
8034  if g_debug then
8035   hr_utility.set_location(l_proc, 40);
8036  end if;
8037   --
8038   -- Validate National Identifier
8039   --
8040   open csr_bg;
8041   fetch csr_bg into l_legislation_code;
8042   close csr_bg;
8043   chk_national_identifier
8044     (p_person_id                =>  p_rec.person_id
8045     ,p_business_group_id        =>  p_rec.business_group_id
8046     ,p_national_identifier      =>  p_rec.national_identifier
8047     ,p_date_of_birth            =>  p_rec.date_of_birth
8048     ,p_sex                      =>  p_rec.sex
8049     ,p_effective_date           =>  p_effective_date
8050     ,p_object_version_number    =>  p_rec.object_version_number
8051     ,p_legislation_code         =>  l_legislation_code
8052     ,p_person_type_id           =>  p_rec.person_type_id
8053 
8054     --changed for bug 6241572
8055     ,p_region_of_birth          => p_rec.region_of_birth
8056     ,p_country_of_birth         => p_rec.country_of_birth
8057     ,p_nationality              => p_rec.nationality
8058 
8059     );
8060     --
8061  if g_debug then
8062   hr_utility.set_location(l_proc, 50);
8063  end if;
8064   --
8065   -- Validate Employee Number
8066   --
8067   chk_employee_number
8068     (p_person_id                =>  p_rec.person_id
8069     ,p_business_group_id        =>  p_rec.business_group_id
8070     ,p_person_type_id           =>  p_rec.person_type_id
8071     ,p_employee_number          =>  p_rec.employee_number
8072     ,p_national_identifier      =>  p_rec.national_identifier
8073     ,p_effective_date           =>  p_effective_date
8074     ,p_object_version_number    =>  p_rec.object_version_number
8075     ,p_party_id                 =>  p_rec.party_id
8076     ,p_date_of_birth            =>  p_rec.date_of_birth
8077     ,p_start_date               =>  p_rec.effective_start_date
8078     );
8079  if g_debug then
8080   hr_utility.set_location(l_proc, 60);
8081  end if;
8082   --
8083   chk_npw_number
8084     (p_person_id                =>  p_rec.person_id
8085     ,p_business_group_id        =>  p_rec.business_group_id
8086     ,p_current_npw_flag         =>  p_rec.current_npw_flag
8087     ,p_npw_number               =>  p_rec.npw_number
8088     ,p_national_identifier      =>  p_rec.national_identifier
8089     ,p_effective_date           =>  p_effective_date
8090     ,p_object_version_number    =>  p_rec.object_version_number
8091     ,p_party_id                 =>  p_rec.party_id
8092     ,p_date_of_birth            =>  p_rec.date_of_birth
8093     ,p_start_date               =>  p_rec.effective_start_date
8094     );
8095  if g_debug then
8096   hr_utility.set_location(l_proc, 65);
8097  end if;
8098   --
8099   chk_expense_check_send_to_addr
8100     (p_person_id                =>  p_rec.person_id
8101     ,p_expense_check_send_to_addres =>  p_rec.expense_check_send_to_address
8102     ,p_effective_date           =>  p_effective_date
8103     ,p_validation_start_date    =>  p_validation_start_date
8104     ,p_validation_end_date      =>  p_validation_end_date
8105     ,p_object_version_number    =>  p_rec.object_version_number
8106     );
8107  if g_debug then
8108   hr_utility.set_location(l_proc, 70);
8109  end if;
8110   --
8111   -- Validate Start Date
8112   --
8113   chk_start_date
8114     (p_person_id                =>  p_rec.person_id
8115     ,p_start_date               =>  p_rec.start_date
8116     ,p_effective_date           =>  p_effective_date
8117     ,p_object_version_number    =>  p_rec.object_version_number
8118     );
8119  if g_debug then
8120   hr_utility.set_location(l_proc, 80);
8121  end if;
8122   --
8123   -- Validate Nationality
8124   --
8125   chk_nationality
8126     (p_person_id                =>  p_rec.person_id
8127     ,p_nationality              =>  p_rec.nationality
8128     ,p_effective_date           =>  p_effective_date
8129     ,p_validation_start_date    =>  p_validation_start_date
8130     ,p_validation_end_date      =>  p_validation_end_date
8131     ,p_object_version_number    =>  p_rec.object_version_number
8132     );
8133  if g_debug then
8134   hr_utility.set_location(l_proc, 90);
8135  end if;
8136   --
8137   -- Validate Marital Status
8138   --
8139   chk_marital_status
8140     (p_person_id                =>  p_rec.person_id
8141     ,p_marital_status           =>  p_rec.marital_status
8142     ,p_effective_date           =>  p_effective_date
8143     ,p_validation_start_date    =>  p_validation_start_date
8144     ,p_validation_end_date      =>  p_validation_end_date
8145     ,p_object_version_number    =>  p_rec.object_version_number
8146     );
8147  if g_debug then
8148   hr_utility.set_location(l_proc, 100);
8149  end if;
8150   --
8151   chk_party_id
8152     (p_person_id                =>  p_rec.person_id
8153     ,p_party_id                 =>  p_rec.party_id
8154     ,p_effective_date           =>  p_effective_date
8155     ,p_object_version_number    =>  p_rec.object_version_number);
8156   --
8157   -- Validate Sex and Title
8158   --
8159   chk_sex_title
8160     (p_person_id                =>  p_rec.person_id
8161     ,p_business_group_id        =>  p_rec.business_group_id
8162     ,p_person_type_id           =>  p_rec.person_type_id
8163     ,p_title                    =>  p_rec.title
8164     ,p_sex                      =>  p_rec.sex
8165     ,p_effective_date           =>  p_effective_date
8166     ,p_validation_start_date    =>  p_validation_start_date
8167     ,p_validation_end_date      =>  p_validation_end_date
8168     ,p_object_version_number    =>  p_rec.object_version_number
8169     );
8170  if g_debug then
8171   hr_utility.set_location(l_proc, 110);
8172  end if;
8173   --
8174   -- Validate Date of Birth
8175   --
8176   chk_date_of_birth
8177     (p_person_id                =>  p_rec.person_id
8178     ,p_person_type_id           =>  p_rec.person_type_id
8179     ,p_business_group_id        =>  p_rec.business_group_id
8180     ,p_start_date               =>  p_rec.start_date
8181     ,p_date_of_birth            =>  p_rec.date_of_birth
8182     ,p_dob_null_warning         =>  p_dob_null_warning
8183     ,p_effective_date           =>  p_effective_date
8184     ,p_validation_start_date    =>  p_validation_start_date
8185     ,p_validation_end_date      =>  p_validation_end_date
8186     ,p_object_version_number    =>  p_rec.object_version_number
8187     );
8188   --
8189   -- Validate Town of Birth
8190   --
8191   chk_town_of_birth
8192     (p_person_id                =>  p_rec.person_id
8193     ,p_town_of_birth            =>  p_rec.town_of_birth
8194     ,p_effective_date           =>  p_effective_date
8195     ,p_validation_start_date    =>  p_validation_start_date
8196     ,p_validation_end_date      =>  p_validation_end_date
8197     ,p_legislation_code         =>  l_legislation_code
8198     );
8199   --
8200   -- Validate Region of Birth
8201   --
8202   chk_region_of_birth
8203     (p_person_id                =>  p_rec.person_id
8204     ,p_region_of_birth          =>  p_rec.region_of_birth
8205     ,p_effective_date           =>  p_effective_date
8206     ,p_validation_start_date    =>  p_validation_start_date
8207     ,p_validation_end_date      =>  p_validation_end_date
8208     ,p_legislation_code         =>  l_legislation_code
8209     );
8210   --
8211   -- Validate Country of Birth
8212   --
8213   chk_country_of_birth
8214     (p_person_id                =>  p_rec.person_id
8215     ,p_country_of_birth         =>  p_rec.country_of_birth
8216     );
8217 
8218   -- Fix 3573040
8219   -- Derive per_information_category parameter internally
8220   --
8221   chk_per_information_category
8222      (p_per_information_category  => p_rec.per_information_category
8223      ,p_legislation_code         =>  l_legislation_code
8224      );
8225   --
8226   -- Set Full Name, Order Name, List Names (Global and Local)
8227   --
8228   return_full_name
8229    (p_person_id                 =>  p_rec.person_id
8230    ,p_business_group_id         =>  p_rec.business_group_id
8231    ,p_first_name                =>  p_rec.first_name
8232    ,p_middle_names              =>  p_rec.middle_names
8233    ,p_last_name                 =>  p_rec.last_name
8234    ,p_known_as                  =>  p_rec.known_as
8235    ,p_title                     =>  p_rec.title
8236    ,p_date_of_birth             =>  p_rec.date_of_birth
8237    ,p_suffix                    =>  p_rec.suffix
8238    ,p_pre_name_adjunct          =>  p_rec.pre_name_adjunct
8239    ,p_effective_date            =>  p_effective_date
8240    ,p_object_version_number     =>  p_rec.object_version_number,
8241     p_previous_last_name        => p_rec.previous_last_name,
8242     p_email_address      =>  p_rec.email_address  ,
8243     p_employee_number    =>  p_rec.employee_number  ,
8244     p_applicant_number   =>  p_rec.applicant_number  ,
8245     p_npw_number         =>  p_rec.npw_number  ,
8246     p_per_information1   =>  p_rec.per_information1  ,
8247     p_per_information2   =>  p_rec.per_information2  ,
8248     p_per_information3   =>  p_rec.per_information3  ,
8249     p_per_information4   =>  p_rec.per_information4  ,
8250     p_per_information5   =>  p_rec.per_information5  ,
8251     p_per_information6   =>  p_rec.per_information6  ,
8252     p_per_information7   =>  p_rec.per_information7  ,
8253     p_per_information8   =>  p_rec.per_information8  ,
8254     p_per_information9   =>  p_rec.per_information9  ,
8255     p_per_information10  =>  p_rec.per_information10  ,
8256     p_per_information11  =>  p_rec.per_information11  ,
8257     p_per_information12  =>  p_rec.per_information12  ,
8258     p_per_information13  =>  p_rec.per_information13  ,
8259     p_per_information14  =>  p_rec.per_information14  ,
8260     p_per_information15  =>  p_rec.per_information15  ,
8261     p_per_information16  =>  p_rec.per_information16  ,
8262     p_per_information17  =>  p_rec.per_information17  ,
8263     p_per_information18  =>  p_rec.per_information18  ,
8264     p_per_information19  =>  p_rec.per_information19  ,
8265     p_per_information20  =>  p_rec.per_information20  ,
8266     p_per_information21  =>  p_rec.per_information21  ,
8267     p_per_information22  =>  p_rec.per_information22  ,
8268     p_per_information23  =>  p_rec.per_information23  ,
8269     p_per_information24  =>  p_rec.per_information24  ,
8270     p_per_information25  =>  p_rec.per_information25  ,
8271     p_per_information26  =>  p_rec.per_information26  ,
8272     p_per_information27  =>  p_rec.per_information27  ,
8273     p_per_information28  =>  p_rec.per_information28  ,
8274     p_per_information29  =>  p_rec.per_information29  ,
8275     p_per_information30  =>  p_rec.per_information30  ,
8276     p_attribute1         =>  p_rec.attribute1  ,
8277     p_attribute2         =>  p_rec.attribute2  ,
8278     p_attribute3         =>  p_rec.attribute3  ,
8279     p_attribute4         =>  p_rec.attribute4  ,
8280     p_attribute5         =>  p_rec.attribute5  ,
8281     p_attribute6         =>  p_rec.attribute6  ,
8282     p_attribute7         =>  p_rec.attribute7  ,
8283     p_attribute8         =>  p_rec.attribute8  ,
8284     p_attribute9         =>  p_rec.attribute9  ,
8285     p_attribute10        =>  p_rec.attribute10  ,
8286     p_attribute11        =>  p_rec.attribute11  ,
8287     p_attribute12        =>  p_rec.attribute12  ,
8288     p_attribute13        =>  p_rec.attribute13  ,
8289     p_attribute14        =>  p_rec.attribute14  ,
8290     p_attribute15        =>  p_rec.attribute15  ,
8291     p_attribute16        =>  p_rec.attribute16  ,
8292     p_attribute17        =>  p_rec.attribute17  ,
8293     p_attribute18        =>  p_rec.attribute18  ,
8294     p_attribute19        =>  p_rec.attribute19  ,
8295     p_attribute20        =>  p_rec.attribute20  ,
8296     p_attribute21        =>  p_rec.attribute21  ,
8297     p_attribute22        =>  p_rec.attribute22  ,
8298     p_attribute23        =>  p_rec.attribute23,
8299     p_attribute24        =>  p_rec.attribute24,
8300     p_attribute25        =>  p_rec.attribute25,
8301     p_attribute26        =>  p_rec.attribute26,
8302     p_attribute27        =>  p_rec.attribute27,
8303     p_attribute28        =>  p_rec.attribute28,
8304     p_attribute29        =>  p_rec.attribute29,
8305     p_attribute30        =>  p_rec.attribute30,
8306     p_full_name          =>  p_rec.full_name,
8307     p_order_name         =>  p_rec.order_name,
8308     p_global_name        =>  p_rec.global_name,
8309     p_local_name         =>  p_rec.local_name
8310    ,p_duplicate_flag     =>  l_duplicate_flag
8311    ,p_name_combination_warning => p_name_combination_warning
8312     );
8313 
8314  if g_debug then
8315   hr_utility.set_location(l_proc, 130);
8316  end if;
8317 /* Bug#3613987 - Removed chk_JP_names procedure
8318   --
8319   -- Create full_name for JP legislation
8320   --
8321   if l_legislation_code = 'JP' then
8322   --
8323     chk_JP_names
8324     (p_person_id             => p_rec.person_id
8325     ,p_effective_date        => p_effective_date
8326     ,p_object_version_number => p_rec.object_version_number
8327     ,p_first_name            => p_rec.first_name
8328     ,p_last_name             => p_rec.last_name
8329     ,p_per_information18     => p_rec.per_information18
8330     ,p_per_information19     => p_rec.per_information19);
8331     --,p_full_name             => p_rec.full_name );  -- bug# 2689366
8332   --
8333   end if;
8334 */
8335  if g_debug then
8336   hr_utility.set_location(l_proc, 145);
8337  end if;
8338   --
8339   -- Validate Applicant Number
8340   --
8341   chk_applicant_number
8342     (p_person_id                 =>  p_rec.person_id
8343     ,p_applicant_number          =>  p_rec.applicant_number
8344     ,p_business_group_id         =>  p_rec.business_group_id
8345     ,p_current_applicant         =>  p_rec.current_applicant_flag
8346     ,p_person_type_id            =>  p_rec.person_type_id
8347     ,p_effective_date            =>  p_effective_date
8348     ,p_object_version_number     =>  p_rec.object_version_number
8349     ,p_party_id                  =>  p_rec.party_id
8350     ,p_date_of_birth             =>  p_rec.date_of_birth
8351     ,p_start_date                =>  null
8352     );
8353  if g_debug then
8354   hr_utility.set_location(l_proc, 150);
8355  end if;
8356   --
8357   -- Validate Date Employee Data Verified
8358   --
8359   chk_date_emp_data_verified
8360     (p_person_id                   =>  p_rec.person_id
8361     ,p_date_employee_data_verified =>  p_rec.date_employee_data_verified
8362     ,p_effective_start_date        =>  p_validation_start_date
8363     ,p_object_version_number       =>  p_rec.object_version_number
8364     );
8365  if g_debug then
8366   hr_utility.set_location(l_proc, 160);
8367  end if;
8368   --
8369   --
8370   -- Validate Vendor Id
8371   --
8372   chk_vendor_id
8373     (p_person_id                   =>  p_rec.person_id
8374     ,p_vendor_id                   =>  p_rec.vendor_id
8375     ,p_person_type_id              =>  p_rec.person_type_id
8376     ,p_business_group_id           =>  p_rec.business_group_id
8377     ,p_effective_date              =>  p_effective_date
8378     ,p_object_version_number       =>  p_rec.object_version_number
8379     );
8380  if g_debug then
8381   hr_utility.set_location(l_proc, 180);
8382  end if;
8383   --
8384   chk_suffix
8385     (p_person_id                   => p_rec.person_id
8386     ,p_suffix                      => p_rec.suffix
8387     ,p_effective_date              => p_effective_date
8388     ,p_object_version_number       => p_rec.object_version_number
8389     );
8390  if g_debug then
8391   hr_utility.set_location(l_proc, 190);
8392  end if;
8393   --
8394   -- Validate work telephone
8395   --
8396   chk_work_telephone
8397   (p_person_id                =>   p_rec.person_id
8398   ,p_work_telephone           =>   p_rec.work_telephone
8399   ,p_effective_date           =>   p_effective_date
8400   ,p_object_version_number    =>   p_rec.object_version_number
8401   );
8402   --
8403   -- Validate benefit medical coverage dates
8404   --
8405   per_per_bus1.chk_coord_ben_med_cvg_dates
8406   (p_coord_ben_med_cvg_strt_dt => p_rec.coord_ben_med_cvg_strt_dt
8407   ,p_coord_ben_med_cvg_end_dt  => p_rec.coord_ben_med_cvg_end_dt
8408   );
8409   --
8410   -- Validate benefit medical details
8411   --
8412   per_per_bus1.chk_coord_ben_med_details
8413   (p_coord_ben_med_cvg_strt_dt    => p_rec.coord_ben_med_cvg_strt_dt
8414   ,p_coord_ben_med_cvg_end_dt     => p_rec.coord_ben_med_cvg_end_dt
8415   ,p_coord_ben_med_ext_er         => p_rec.coord_ben_med_ext_er
8416   ,p_coord_ben_med_pl_name        => p_rec.coord_ben_med_pl_name
8417   ,p_coord_ben_med_insr_crr_name  => p_rec.coord_ben_med_insr_crr_name
8418   ,p_coord_ben_med_insr_crr_ident => p_rec.coord_ben_med_insr_crr_ident
8419   );
8420   --
8421   -- Check other benefit coverage rules
8422   --
8423   per_per_bus1.chk_other_coverages
8424   (p_attribute10                 => p_rec.attribute10
8425   ,p_coord_ben_med_insr_crr_name => p_rec.coord_ben_med_insr_crr_name
8426   ,p_coord_ben_med_cvg_end_dt    => p_rec.coord_ben_med_cvg_end_dt
8427   ,p_coord_ben_no_cvg_flag       => p_rec.coord_ben_no_cvg_flag
8428   ,p_effective_date              => p_effective_date
8429   );
8430   --
8431   -- Validate Developer Descriptive Flexfields
8432   --
8433   chk_per_information
8434     (p_rec         =>  p_rec
8435     ,p_effective_date            =>  p_effective_date
8436     ,p_validation_start_date     =>  p_validation_start_date
8437     ,p_validation_end_date       =>  p_validation_end_date
8438     );
8439  if g_debug then
8440   hr_utility.set_location(l_proc, 200);
8441  end if;
8442   --
8443   -- Validate flex fields.
8444   --
8445   per_per_bus.chk_df(p_rec => p_rec);
8446  if g_debug then
8447   hr_utility.set_location(l_proc, 210);
8448  end if;
8449   --
8450  if g_debug then
8451   hr_utility.set_location(' Leaving:'||l_proc, 10000);
8452  end if;
8453 End insert_validate;
8454 --
8455 -- ----------------------------------------------------------------------------
8456 -- |---------------------------< update_validate >----------------------------|
8457 -- ----------------------------------------------------------------------------
8458 Procedure update_validate
8459    (p_rec          in out nocopy per_per_shd.g_rec_type,
8460     p_effective_date  in date,
8461     p_datetrack_mode  in varchar2,
8462     p_validation_start_date in date,
8463     p_validation_end_date   in date,
8464          p_name_combination_warning   out nocopy boolean,
8465          p_dob_null_warning           out nocopy boolean,
8466          p_orig_hire_warning          out nocopy boolean) is
8467 --
8468   l_proc varchar2(72);
8469   l_legislation_code        per_business_groups.legislation_code%TYPE;
8470 --
8471   l_first_name  per_all_people_f.first_name%TYPE;
8472   l_last_name   per_all_people_f.last_name%TYPE;
8473   l_output      varchar2(150);
8474   l_rgeflg      varchar2(10);
8475   l_duplicate_flag varchar2(1);
8476 --
8477   cursor csr_bg is
8478     select legislation_code
8479     from per_business_groups pbg
8480     where pbg.business_group_id = p_rec.business_group_id;
8481 --
8482 Begin
8483  if g_debug then
8484   l_proc := g_package||'update_validate';
8485   hr_utility.set_location('Entering:'||l_proc, 10);
8486  end if;
8487   --
8488   -- Set global variable used to improve calling of return_system_status_type
8489   -- when called multiple times on same pass through the validation process.
8490   -- A null value indicates that the function has not been called on this pass
8491   -- through the validation process.
8492   --
8493   g_previous_sys_per_type := NULL;
8494   --
8495   --  Validate Business Group Id
8496   --
8497   hr_api.validate_bus_grp_id
8498   (p_business_group_id => p_rec.business_group_id
8499   ,p_associated_column1 => per_per_shd.g_tab_nam || '.BUSINESS_GROUP_ID'
8500   );
8501   hr_multi_message.end_validation_set;
8502   --
8503   --
8504   -- Check that no unsupported attributes have been set.
8505   --
8506   per_per_bus1.chk_unsupported_attributes
8507     (p_person_id             =>  p_rec.person_id
8508     ,p_fast_path_employee    =>  p_rec.fast_path_employee
8509     ,p_order_name            =>  p_rec.order_name
8510     ,p_projected_start_date  =>  p_rec.projected_start_date
8511     ,p_rehire_authorizor     =>  p_rec.rehire_authorizor
8512     ,p_effective_date        =>  p_effective_date
8513     ,p_object_version_number =>  p_rec.object_version_number
8514     );
8515   --
8516   -- Validate Correspondence Language
8517   --
8518   per_per_bus1.chk_correspondence_language
8519     (p_person_id                  =>  p_rec.person_id
8520     ,p_effective_date             =>  p_effective_date
8521     ,p_correspondence_language    =>  p_rec.correspondence_language
8522     ,p_object_version_number      =>  p_rec.object_version_number);
8523   --
8524   -- Validate FTE capacity
8525   --
8526   per_per_bus1.chk_fte_capacity
8527     (p_person_id              =>  p_rec.person_id
8528     ,p_effective_date         =>  p_effective_date
8529     ,p_fte_capacity           =>  p_rec.fte_capacity
8530     ,p_object_version_number  =>  p_rec.object_version_number);
8531   --
8532   -- Validate Background Check Status
8533   --
8534   per_per_bus1.chk_BACKGROUND_CHECK_STATUS
8535     (p_person_id                   =>  p_rec.person_id
8536     ,p_BACKGROUND_CHECK_STATUS     =>  p_rec.BACKGROUND_CHECK_STATUS
8537     ,p_effective_date              =>  p_effective_date
8538     ,p_validation_start_date       =>  p_validation_start_date
8539     ,p_validation_end_date         =>  p_validation_end_date
8540     ,p_object_version_number       =>  p_rec.object_version_number
8541     );
8542  if g_debug then
8543   hr_utility.set_location(l_proc, 30);
8544  end if;
8545   --
8546   -- Validate Blood Type
8547   --
8548   per_per_bus1.chk_blood_type
8549     (p_person_id                   =>  p_rec.person_id
8550     ,p_blood_type                  =>  p_rec.blood_type
8551     ,p_effective_date              =>  p_effective_date
8552     ,p_validation_start_date       =>  p_validation_start_date
8553     ,p_validation_end_date         =>  p_validation_end_date
8554     ,p_object_version_number       =>  p_rec.object_version_number
8555     );
8556  if g_debug then
8557   hr_utility.set_location(l_proc, 40);
8558  end if;
8559   --
8560   -- Validate Student Status
8561   --
8562   per_per_bus1.chk_student_status
8563     (p_person_id                   =>  p_rec.person_id
8564     ,p_student_status              =>  p_rec.student_status
8565     ,p_effective_date              =>  p_effective_date
8566     ,p_validation_start_date       =>  p_validation_start_date
8567     ,p_validation_end_date         =>  p_validation_end_date
8568     ,p_object_version_number       =>  p_rec.object_version_number
8569     );
8570  if g_debug then
8571   hr_utility.set_location(l_proc, 50);
8572  end if;
8573   --
8574   -- Validate Work Schedule
8575   --
8576   per_per_bus1.chk_work_schedule
8577     (p_person_id             =>  p_rec.person_id
8578     ,p_work_schedule         =>  p_rec.work_schedule
8579     ,p_effective_date        =>  p_effective_date
8580     ,p_validation_start_date =>  p_validation_start_date
8581     ,p_validation_end_date   =>  p_validation_end_date
8582     ,p_object_version_number =>  p_rec.object_version_number
8583     );
8584  if g_debug then
8585   hr_utility.set_location(l_proc, 60);
8586  end if;
8587   --
8588   -- Validate Rehire Recommendation
8589   --
8590   per_per_bus1.chk_rehire_recommendation
8591     (p_person_id             =>  p_rec.person_id
8592     ,p_rehire_recommendation =>  p_rec.rehire_recommendation
8593     ,p_effective_date        =>  p_effective_date
8594     ,p_validation_start_date =>  p_validation_start_date
8595     ,p_validation_end_date   =>  p_validation_end_date
8596     ,p_object_version_number =>  p_rec.object_version_number
8597     );
8598  if g_debug then
8599   hr_utility.set_location(l_proc, 70);
8600  end if;
8601   --
8602   -- Validate Benefit Group Id
8603   --
8604   per_per_bus1.chk_benefit_group_id
8605     (p_person_id             =>  p_rec.person_id
8606     ,p_benefit_group_id      =>  p_rec.benefit_group_id
8607     ,p_effective_date        =>  p_effective_date
8608     ,p_object_version_number =>  p_rec.object_version_number
8609     );
8610  if g_debug then
8611   hr_utility.set_location(l_proc, 80);
8612  end if;
8613   --
8614   -- Validate Receipt of Death Certificate date.
8615   --
8616   per_per_bus1.chk_date_death_and_rcpt_cert
8617     (p_person_id             =>  p_rec.person_id
8618     ,p_receipt_of_death_cert_date =>  p_rec.receipt_of_death_cert_date
8619     ,p_effective_date        =>  p_effective_date
8620     ,p_object_version_number =>  p_rec.object_version_number
8621     ,p_date_of_death         =>  p_rec.date_of_death
8622     );
8623  if g_debug then
8624   hr_utility.set_location(l_proc, 90);
8625  end if;
8626   --
8627   -- Validate the dependent's adoption date.
8628   --
8629   per_per_bus1.chk_birth_adoption_date
8630     (p_person_id             =>  p_rec.person_id
8631     ,p_dpdnt_adoption_date   =>  p_rec.dpdnt_adoption_date
8632     ,p_date_of_birth         =>  p_rec.date_of_birth
8633     ,p_effective_date        =>  p_effective_date
8634     ,p_object_version_number =>  p_rec.object_version_number
8635     );
8636  if g_debug then
8637   hr_utility.set_location(l_proc, 100);
8638  end if;
8639   --
8640   -- Validate registered disabled flag.
8641   --
8642   per_per_bus1.chk_rd_flag
8643     (p_person_id             =>  p_rec.person_id
8644     ,p_registered_disabled_flag =>  p_rec.registered_disabled_flag
8645     ,p_effective_date        =>  p_effective_date
8646     ,p_validation_start_date =>  p_validation_start_date
8647     ,p_validation_end_date   =>  p_validation_end_date
8648     ,p_object_version_number =>  p_rec.object_version_number
8649     );
8650  if g_debug then
8651   hr_utility.set_location(l_proc, 110);
8652  end if;
8653   --
8654   -- Validate Date of Death.
8655   --
8656   per_per_bus1.chk_date_of_death
8657     (p_person_id             =>  p_rec.person_id
8658     ,p_date_of_death         =>  p_rec.date_of_death
8659     ,p_date_of_birth         =>  p_rec.date_of_birth
8660     ,p_effective_date        =>  p_effective_date
8661     ,p_object_version_number =>  p_rec.object_version_number
8662     );
8663  if g_debug then
8664   hr_utility.set_location(l_proc, 120);
8665  end if;
8666   --
8667   -- Validate uses tobacco flag.
8668   --
8669   per_per_bus1.chk_uses_tobacco
8670     (p_person_id             =>  p_rec.person_id
8671     ,p_uses_tobacco_flag     =>  p_rec.uses_tobacco_flag
8672     ,p_effective_date        =>  p_effective_date
8673     ,p_validation_start_date =>  p_validation_start_date
8674     ,p_validation_end_date   =>  p_validation_end_date
8675     ,p_object_version_number =>  p_rec.object_version_number
8676      );
8677  if g_debug then
8678    hr_utility.set_location(l_proc, 125);
8679  end if;
8680   --
8681   chk_orig_and_start_dates
8682      (p_person_id             => p_rec.person_id
8683      ,p_person_type_id        => p_rec.person_type_id
8684      ,p_business_group_id     => p_rec.business_group_id
8685      ,p_original_date_of_hire => p_rec.original_date_of_hire
8686      ,p_start_date            => p_rec.start_date
8687      ,p_effective_date        => p_effective_date
8688      ,p_object_version_number => p_rec.object_version_number
8689      ,p_orig_hire_warning     => p_orig_hire_warning
8690      );
8691  if g_debug then
8692    hr_utility.set_location(l_proc, 130);
8693  end if;
8694 --
8695   -- Call all supporting business operations
8696   -- Mapping to the appropriate Business Rules in perper.bru is provided.
8697   --
8698   --  Validate Person Type ID
8699   --
8700   chk_person_type_id
8701     (p_person_id                =>  p_rec.person_id
8702     ,p_business_group_id        =>  p_rec.business_group_id
8703     ,p_person_type_id           =>  p_rec.person_type_id
8704     ,p_old_person_type_id       =>  per_per_shd.g_old_rec.person_type_id
8705     ,p_current_employee_flag    =>  p_rec.current_employee_flag
8706     ,p_current_applicant_flag   =>  p_rec.current_applicant_flag
8707     ,p_current_emp_or_apl_flag  =>  p_rec.current_emp_or_apl_flag
8708     ,p_effective_date           =>  p_effective_date
8709     ,p_validation_start_date    =>  p_validation_start_date
8710     ,p_object_version_number    =>  p_rec.object_version_number
8711     ,p_datetrack_mode           =>  p_datetrack_mode
8712     );
8713  if g_debug then
8714   hr_utility.set_location(l_proc, 20);
8715  end if;
8716   --
8717   --
8718   -- Validate National Identifier
8719   --
8720   open csr_bg;
8721   fetch csr_bg into l_legislation_code;
8722   close csr_bg;
8723   chk_national_identifier
8724     (p_person_id                =>  p_rec.person_id
8725     ,p_business_group_id        =>  p_rec.business_group_id
8726     ,p_national_identifier      =>  p_rec.national_identifier
8727     ,p_date_of_birth            =>  p_rec.date_of_birth
8728     ,p_sex                      =>  p_rec.sex
8729     ,p_effective_date           =>  p_effective_date
8730     ,p_object_version_number    =>  p_rec.object_version_number
8731     ,p_legislation_code         =>  l_legislation_code
8732     ,p_person_type_id           =>  p_rec.person_type_id
8733 
8734     --changed for bu 6241572
8735     ,p_region_of_birth          => p_rec.region_of_birth
8736     ,p_country_of_birth         => p_rec.country_of_birth
8737     ,p_nationality              => p_rec.nationality
8738     );
8739     --
8740  if g_debug then
8741   hr_utility.set_location(l_proc, 30);
8742  end if;
8743   --
8744   -- Validate Employee Number
8745   --
8746   chk_employee_number
8747     (p_person_id                =>  p_rec.person_id
8748     ,p_business_group_id        =>  p_rec.business_group_id
8749     ,p_person_type_id           =>  p_rec.person_type_id
8750     ,p_employee_number          =>  p_rec.employee_number
8751     ,p_national_identifier      =>  p_rec.national_identifier
8752     ,p_effective_date           =>  p_effective_date
8753     ,p_object_version_number    =>  p_rec.object_version_number
8754     ,p_party_id                 =>  p_rec.party_id
8755     ,p_date_of_birth            =>  p_rec.date_of_birth
8756     ,p_start_date               =>  null
8757     );
8758  if g_debug then
8759   hr_utility.set_location(l_proc, 40);
8760  end if;
8761   --
8762   chk_npw_number
8763     (p_person_id                =>  p_rec.person_id
8764     ,p_business_group_id        =>  p_rec.business_group_id
8765     ,p_current_npw_flag         =>  p_rec.current_npw_flag
8766     ,p_npw_number               =>  p_rec.npw_number
8767     ,p_national_identifier      =>  p_rec.national_identifier
8768     ,p_effective_date           =>  p_effective_date
8769     ,p_object_version_number    =>  p_rec.object_version_number
8770     ,p_party_id                 =>  p_rec.party_id
8771     ,p_date_of_birth            =>  p_rec.date_of_birth
8772     ,p_start_date               =>  null
8773     );
8774  if g_debug then
8775   hr_utility.set_location(l_proc, 43);
8776  end if;
8777   --
8778   chk_expense_check_send_to_addr
8779     (p_person_id                =>  p_rec.person_id
8780     ,p_expense_check_send_to_addres =>  p_rec.expense_check_send_to_address
8781     ,p_effective_date           =>  p_effective_date
8782     ,p_validation_start_date    =>  p_validation_start_date
8783     ,p_validation_end_date      =>  p_validation_end_date
8784     ,p_object_version_number    =>  p_rec.object_version_number
8785     );
8786  if g_debug then
8787   hr_utility.set_location('Entering:'||l_proc, 45);
8788  end if;
8789   --
8790   -- Validate Start Date
8791   --
8792   chk_start_date
8793     (p_person_id                =>  p_rec.person_id
8794     ,p_start_date               =>  p_rec.start_date
8795     ,p_effective_date           =>  p_effective_date
8796     ,p_object_version_number    =>  p_rec.object_version_number
8797     );
8798  if g_debug then
8799   hr_utility.set_location(l_proc, 50);
8800  end if;
8801   --
8802   -- Validate Nationality
8803   --
8804   chk_nationality
8805     (p_person_id                =>  p_rec.person_id
8806     ,p_nationality              =>  p_rec.nationality
8807     ,p_effective_date           =>  p_effective_date
8808     ,p_validation_start_date    =>  p_validation_start_date
8809     ,p_validation_end_date      =>  p_validation_end_date
8810     ,p_object_version_number    =>  p_rec.object_version_number
8811     );
8812  if g_debug then
8813   hr_utility.set_location(l_proc, 60);
8814  end if;
8815   --
8816   chk_party_id
8817     (p_person_id                =>  p_rec.person_id
8818     ,p_party_id                 =>  p_rec.party_id
8819     ,p_effective_date           =>  p_effective_date
8820     ,p_object_version_number    =>  p_rec.object_version_number);
8821   --
8822   -- Validate Marital Status
8823   --
8824   chk_marital_status
8825     (p_person_id                =>  p_rec.person_id
8826     ,p_marital_status           =>  p_rec.marital_status
8827     ,p_effective_date           =>  p_effective_date
8828     ,p_validation_start_date    =>  p_validation_start_date
8829     ,p_validation_end_date      =>  p_validation_end_date
8830     ,p_object_version_number    =>  p_rec.object_version_number
8831     );
8832  if g_debug then
8833   hr_utility.set_location(l_proc, 70);
8834  end if;
8835   --
8836   -- Validate Sex and Title
8837   --
8838   chk_sex_title
8839     (p_person_id                =>  p_rec.person_id
8840     ,p_business_group_id        =>  p_rec.business_group_id
8841     ,p_person_type_id           =>  p_rec.person_type_id
8842     ,p_title                    =>  p_rec.title
8843     ,p_sex                      =>  p_rec.sex
8844     ,p_effective_date           =>  p_effective_date
8845     ,p_validation_start_date    =>  p_validation_start_date
8846     ,p_validation_end_date      =>  p_validation_end_date
8847     ,p_object_version_number    =>  p_rec.object_version_number
8848     );
8849  if g_debug then
8850   hr_utility.set_location(l_proc, 80);
8851  end if;
8852   --
8853   -- Validate Date of Birth
8854   --
8855   chk_date_of_birth
8856     (p_person_id                =>  p_rec.person_id
8857     ,p_person_type_id           =>  p_rec.person_type_id
8858     ,p_business_group_id        =>  p_rec.business_group_id
8859     ,p_start_date               =>  p_rec.start_date
8860     ,p_date_of_birth            =>  p_rec.date_of_birth
8861     ,p_dob_null_warning         =>  p_dob_null_warning
8862     ,p_effective_date           =>  p_effective_date
8863     ,p_validation_start_date    =>  p_validation_start_date
8864     ,p_validation_end_date      =>  p_validation_end_date
8865     ,p_object_version_number    =>  p_rec.object_version_number
8866     );
8867  if g_debug then
8868   hr_utility.set_location(l_proc, 90);
8869  end if;
8870   --
8871   -- Validate Town of Birth
8872   --
8873   chk_town_of_birth
8874     (p_person_id                =>  p_rec.person_id
8875     ,p_town_of_birth            =>  p_rec.town_of_birth
8876     ,p_effective_date           =>  p_effective_date
8877     ,p_validation_start_date    =>  p_validation_start_date
8878     ,p_validation_end_date      =>  p_validation_end_date
8879     ,p_legislation_code         =>  l_legislation_code
8880     );
8881   --
8882   -- Validate Region of Birth
8883   --
8884   chk_region_of_birth
8885     (p_person_id                =>  p_rec.person_id
8886     ,p_region_of_birth          =>  p_rec.region_of_birth
8887     ,p_effective_date           =>  p_effective_date
8888     ,p_validation_start_date    =>  p_validation_start_date
8889     ,p_validation_end_date      =>  p_validation_end_date
8890     ,p_legislation_code         =>  l_legislation_code
8891     );
8892   --
8893   -- Validate Country of Birth
8894   --
8895   chk_country_of_birth
8896     (p_person_id                =>  p_rec.person_id
8897     ,p_country_of_birth         =>  p_rec.country_of_birth
8898     );
8899   -- Fix 3573040
8900   -- Derive per_information_category parameter internally
8901   --
8902   chk_per_information_category
8903      (p_per_information_category  => p_rec.per_information_category
8904      ,p_legislation_code         =>  l_legislation_code
8905      );
8906   --
8907   -- Set Full Name, Order Name, List Names (Global and Local)
8908   --
8909   return_full_name
8910    (p_person_id                 =>  p_rec.person_id
8911    ,p_business_group_id         =>  p_rec.business_group_id
8912    ,p_first_name                =>  p_rec.first_name
8913    ,p_middle_names              =>  p_rec.middle_names
8914    ,p_last_name                 =>  p_rec.last_name
8915    ,p_known_as                  =>  p_rec.known_as
8916    ,p_title                     =>  p_rec.title
8917    ,p_date_of_birth             =>  p_rec.date_of_birth
8918    ,p_suffix                    =>  p_rec.suffix
8919    ,p_pre_name_adjunct          =>  p_rec.pre_name_adjunct
8920    ,p_effective_date            =>  p_effective_date
8921    ,p_object_version_number     =>  p_rec.object_version_number,
8922     p_previous_last_name        =>  p_rec.previous_last_name,
8923     p_email_address      =>  p_rec.email_address  ,
8924     p_employee_number    =>  p_rec.employee_number  ,
8925     p_applicant_number   =>  p_rec.applicant_number  ,
8926     p_npw_number         =>  p_rec.npw_number  ,
8927     p_per_information1   =>  p_rec.per_information1  ,
8928     p_per_information2   =>  p_rec.per_information2  ,
8929     p_per_information3   =>  p_rec.per_information3  ,
8930     p_per_information4   =>  p_rec.per_information4  ,
8931     p_per_information5   =>  p_rec.per_information5  ,
8932     p_per_information6   =>  p_rec.per_information6  ,
8933     p_per_information7   =>  p_rec.per_information7  ,
8934     p_per_information8   =>  p_rec.per_information8  ,
8935     p_per_information9   =>  p_rec.per_information9  ,
8936     p_per_information10  =>  p_rec.per_information10  ,
8937     p_per_information11  =>  p_rec.per_information11  ,
8938     p_per_information12  =>  p_rec.per_information12  ,
8939     p_per_information13  =>  p_rec.per_information13  ,
8940     p_per_information14  =>  p_rec.per_information14  ,
8941     p_per_information15  =>  p_rec.per_information15  ,
8942     p_per_information16  =>  p_rec.per_information16  ,
8943     p_per_information17  =>  p_rec.per_information17  ,
8944     p_per_information18  =>  p_rec.per_information18  ,
8945     p_per_information19  =>  p_rec.per_information19  ,
8946     p_per_information20  =>  p_rec.per_information20  ,
8947     p_per_information21  =>  p_rec.per_information21  ,
8948     p_per_information22  =>  p_rec.per_information22  ,
8949     p_per_information23  =>  p_rec.per_information23  ,
8950     p_per_information24  =>  p_rec.per_information24  ,
8951     p_per_information25  =>  p_rec.per_information25  ,
8952     p_per_information26  =>  p_rec.per_information26  ,
8953     p_per_information27  =>  p_rec.per_information27  ,
8954     p_per_information28  =>  p_rec.per_information28  ,
8955     p_per_information29  =>  p_rec.per_information29  ,
8956     p_per_information30  =>  p_rec.per_information30  ,
8957     p_attribute1         =>  p_rec.attribute1  ,
8958     p_attribute2         =>  p_rec.attribute2  ,
8959     p_attribute3         =>  p_rec.attribute3  ,
8960     p_attribute4         =>  p_rec.attribute4  ,
8961     p_attribute5         =>  p_rec.attribute5  ,
8962     p_attribute6         =>  p_rec.attribute6  ,
8963     p_attribute7         =>  p_rec.attribute7  ,
8964     p_attribute8         =>  p_rec.attribute8  ,
8965     p_attribute9         =>  p_rec.attribute9  ,
8966     p_attribute10        =>  p_rec.attribute10  ,
8967     p_attribute11        =>  p_rec.attribute11  ,
8968     p_attribute12        =>  p_rec.attribute12  ,
8969     p_attribute13        =>  p_rec.attribute13  ,
8970     p_attribute14        =>  p_rec.attribute14  ,
8971     p_attribute15        =>  p_rec.attribute15  ,
8972     p_attribute16        =>  p_rec.attribute16  ,
8973     p_attribute17        =>  p_rec.attribute17  ,
8974     p_attribute18        =>  p_rec.attribute18  ,
8975     p_attribute19        =>  p_rec.attribute19  ,
8976     p_attribute20        =>  p_rec.attribute20  ,
8977     p_attribute21        =>  p_rec.attribute21  ,
8978     p_attribute22        =>  p_rec.attribute22  ,
8979     p_attribute23        =>  p_rec.attribute23,
8980     p_attribute24        =>  p_rec.attribute24,
8981     p_attribute25        =>  p_rec.attribute25,
8982     p_attribute26        =>  p_rec.attribute26,
8983     p_attribute27        =>  p_rec.attribute27,
8984     p_attribute28        =>  p_rec.attribute28,
8985     p_attribute29        =>  p_rec.attribute29,
8986     p_attribute30        =>  p_rec.attribute30,
8987     p_full_name          =>  p_rec.full_name,
8988     p_order_name         =>  p_rec.order_name,
8989     p_global_name        =>  p_rec.global_name,
8990     p_local_name         =>  p_rec.local_name
8991    ,p_duplicate_flag     =>  l_duplicate_flag
8992    ,p_name_combination_warning  =>  p_name_combination_warning
8993     );
8994 
8995  if g_debug then
8996   hr_utility.set_location(l_proc, 100);
8997  end if;
8998   --
8999   -- Validate benefit medical coverage dates
9000   --
9001   per_per_bus1.chk_coord_ben_med_cvg_dates
9002   (p_coord_ben_med_cvg_strt_dt => p_rec.coord_ben_med_cvg_strt_dt
9003   ,p_coord_ben_med_cvg_end_dt  => p_rec.coord_ben_med_cvg_end_dt
9004   );
9005   --
9006   -- Validate benefit medical details
9007   --
9008   per_per_bus1.chk_coord_ben_med_details
9009   (p_coord_ben_med_cvg_strt_dt    => p_rec.coord_ben_med_cvg_strt_dt
9010   ,p_coord_ben_med_cvg_end_dt     => p_rec.coord_ben_med_cvg_end_dt
9011   ,p_coord_ben_med_ext_er         => p_rec.coord_ben_med_ext_er
9012   ,p_coord_ben_med_pl_name        => p_rec.coord_ben_med_pl_name
9013   ,p_coord_ben_med_insr_crr_name  => p_rec.coord_ben_med_insr_crr_name
9014   ,p_coord_ben_med_insr_crr_ident => p_rec.coord_ben_med_insr_crr_ident
9015   );
9016   --
9017   -- Check other benefit coverage rules
9018   --
9019   per_per_bus1.chk_other_coverages
9020   (p_attribute10                 => p_rec.attribute10
9021   ,p_coord_ben_med_insr_crr_name => p_rec.coord_ben_med_insr_crr_name
9022   ,p_coord_ben_med_cvg_end_dt    => p_rec.coord_ben_med_cvg_end_dt
9023   ,p_coord_ben_no_cvg_flag       => p_rec.coord_ben_no_cvg_flag
9024   ,p_effective_date              => p_effective_date
9025   );
9026   --
9027   -- Validate Developer Descriptive Flexfields
9028   --
9029   chk_per_information
9030     (p_rec         =>  p_rec
9031     ,p_effective_date            =>  p_effective_date
9032     ,p_validation_start_date     =>  p_validation_start_date
9033     ,p_validation_end_date       =>  p_validation_end_date
9034     );
9035   --
9036  if g_debug then
9037   hr_utility.set_location(l_proc, 110);
9038  end if;
9039 /* Bug#3613987 - Removed chk_JP_names procedure
9040   --
9041   -- Create full_name for JP legislation
9042   --
9043   if l_legislation_code = 'JP' then
9044   --
9045     chk_JP_names
9046     (p_person_id             => p_rec.person_id
9047     ,p_effective_date        => p_effective_date
9048     ,p_object_version_number => p_rec.object_version_number
9049     ,p_first_name            => p_rec.first_name
9050     ,p_last_name             => p_rec.last_name
9051     ,p_per_information18     => p_rec.per_information18
9052     ,p_per_information19     => p_rec.per_information19);
9053     --,p_full_name             => p_rec.full_name );  -- bug# 2689366 --
9054   --
9055   end if;
9056 */
9057  if g_debug then
9058   hr_utility.set_location(l_proc, 145);
9059  end if;
9060   --
9061   -- Validate Applicant Number
9062   --
9063   chk_applicant_number
9064     (p_person_id                 =>  p_rec.person_id
9065     ,p_applicant_number          =>  p_rec.applicant_number
9066     ,p_business_group_id         =>  p_rec.business_group_id
9067     ,p_current_applicant         =>  p_rec.current_applicant_flag
9068     ,p_person_type_id            =>  p_rec.person_type_id
9069     ,p_effective_date            =>  p_effective_date
9070     ,p_object_version_number     =>  p_rec.object_version_number
9071     ,p_party_id                  =>  p_rec.party_id
9072     ,p_date_of_birth             =>  p_rec.date_of_birth
9073     ,p_start_date                =>  null
9074     );
9075  if g_debug then
9076   hr_utility.set_location(l_proc, 120);
9077  end if;
9078   --
9079   -- Validate Date Employee Data Verified
9080   --
9081   chk_date_emp_data_verified
9082     (p_person_id                   =>  p_rec.person_id
9083     ,p_date_employee_data_verified =>  p_rec.date_employee_data_verified
9084     ,p_effective_start_date        =>  p_validation_start_date
9085     ,p_object_version_number       =>  p_rec.object_version_number
9086     );
9087  if g_debug then
9088   hr_utility.set_location(l_proc, 130);
9089  end if;
9090   --
9091   -- Validate Vendor Id
9092   --
9093   chk_vendor_id
9094     (p_person_id                   =>  p_rec.person_id
9095     ,p_vendor_id                   =>  p_rec.vendor_id
9096     ,p_person_type_id              =>  p_rec.person_type_id
9097     ,p_business_group_id           =>  p_rec.business_group_id
9098     ,p_effective_date              =>  p_effective_date
9099     ,p_object_version_number       =>  p_rec.object_version_number
9100     );
9101  if g_debug then
9102   hr_utility.set_location(l_proc, 150);
9103  end if;
9104   --
9105   chk_suffix
9106     (p_person_id                   => p_rec.person_id
9107     ,p_suffix                      => p_rec.suffix
9108     ,p_effective_date              => p_effective_date
9109     ,p_object_version_number       => p_rec.object_version_number
9110     );
9111  if g_debug then
9112   hr_utility.set_location(l_proc, 160);
9113  end if;
9114   --
9115   -- Validate work telephone
9116   --
9117   chk_work_telephone
9118   (p_person_id                =>   p_rec.person_id
9119   ,p_work_telephone           =>   p_rec.work_telephone
9120   ,p_effective_date           =>   p_effective_date
9121   ,p_object_version_number    =>   p_rec.object_version_number
9122   );
9123   --
9124   -- Call the datetrack update integrity operation
9125   --
9126   dt_update_validate
9127     (p_datetrack_mode                => p_datetrack_mode,
9128      p_validation_start_date       => p_validation_start_date,
9129      p_validation_end_date      => p_validation_end_date
9130     );
9131  if g_debug then
9132   hr_utility.set_location(l_proc, 170);
9133  end if;
9134   --
9135   --
9136   -- Validate flex fields.
9137   --
9138   per_per_bus.chk_df(p_rec => p_rec);
9139  if g_debug then
9140   hr_utility.set_location(l_proc, 180);
9141  end if;
9142   --
9143  if g_debug then
9144   hr_utility.set_location(' Leaving:'||l_proc, 10000);
9145  end if;
9146 End update_validate;
9147 --
9148 -- ----------------------------------------------------------------------------
9149 -- |---------------------------< delete_validate >----------------------------|
9150 -- ----------------------------------------------------------------------------
9151 Procedure delete_validate
9152    (p_rec          in per_per_shd.g_rec_type,
9153     p_effective_date  in date,
9154     p_datetrack_mode  in varchar2,
9155     p_validation_start_date in date,
9156     p_validation_end_date   in date) is
9157 --
9158   l_proc varchar2(72);
9159 --
9160 Begin
9161  if g_debug then
9162   l_proc := g_package||'delete_validate';
9163   hr_utility.set_location('Entering:'||l_proc, 5);
9164  end if;
9165   --
9166   -- Set global variable used to improve calling of return_system_status_type
9167   -- when called multiple times on same pass through the validation process.
9168   -- A null value indicates that the function has not been called on this pass
9169   -- through the validation process.
9170   --
9171   g_previous_sys_per_type := NULL;
9172   --
9173   -- Call all supporting business operations. Mapping to the appropriate
9174   -- business rules on perper.bru is provided
9175   --
9176   -- check if delete operations are allowed
9177   --
9178   chk_delete
9179     (p_person_id                   =>  p_rec.person_id
9180     ,p_person_type_id              =>  per_per_shd.g_old_rec.person_type_id
9181     ,p_business_group_id           =>  per_per_shd.g_old_rec.business_group_id
9182     ,p_effective_date              =>  p_effective_date
9183     ,p_datetrack_mode              =>  p_datetrack_mode
9184    );
9185   --
9186   dt_delete_validate
9187     (p_datetrack_mode      => p_datetrack_mode,
9188      p_validation_start_date  => p_validation_start_date,
9189      p_validation_end_date => p_validation_end_date,
9190      p_person_id     => p_rec.person_id);
9191   --
9192  if g_debug then
9193   hr_utility.set_location(' Leaving:'||l_proc, 10);
9194  end if;
9195 End delete_validate;
9196 --
9197 -- ---------------------------------------------------------------------------|
9198 -- |---------------------------< chk_person_type>-----------------------------|
9199 -- ----------------------------------------------------------------------------
9200 --
9201 procedure chk_person_type
9202   (p_person_type_id     in out nocopy number
9203   ,p_business_group_id  in     number
9204   ,p_expected_sys_type  in     varchar2) is
9205 --
9206   l_system_person_type per_person_types.system_person_type%type;
9207   l_active_flag        per_person_types.active_flag%type;
9208   l_business_group_id  per_person_types.business_group_id%type;
9209   l_proc               varchar2(30);
9210 --
9211   -- Bug fix 3632363. cursor modified to improve performance.
9212   cursor csr_get_default is
9213     select pet.person_type_id
9214     from per_person_types pet
9215     where pet.system_person_type = p_expected_sys_type
9216     and   pet.business_group_id  = p_business_group_id
9217     and   pet.active_flag = 'Y'
9218     and   pet.default_flag = 'Y';
9219 --
9220   cursor csr_person_type is
9221     select pet.system_person_type,
9222       pet.active_flag,
9223       pet.business_group_id
9224     from per_person_types pet
9225     where pet.person_type_id = p_person_type_id;
9226   --
9227 begin
9228  if g_debug then
9229   l_proc := 'chk_person_type';
9230   hr_utility.set_location(' Entering '||l_proc,10);
9231  end if;
9232   --
9233   -- Validate the specified business group
9234   --
9235   hr_api.validate_bus_grp_id
9236     (p_business_group_id =>  p_business_group_id
9237     ,p_associated_column1 => per_per_shd.g_tab_nam || '.BUSINESS_GROUP_ID'
9238     );
9239   hr_multi_message.end_validation_set;
9240  if g_debug then
9241   hr_utility.set_location(l_proc,20);
9242  end if;
9243   --
9244   -- If the person type hasn't been specified or is set to the system default
9245   -- hr_api.g_number, then fetch the default for
9246   -- the business group and system type.
9247   --
9248   if (p_person_type_id is null or p_person_type_id = hr_api.g_number) then
9249  if g_debug then
9250     hr_utility.set_location(l_proc,30);
9251  end if;
9252     --
9253     -- Get the required default person type
9254     --
9255     open csr_get_default;
9256     fetch csr_get_default
9257     into p_person_type_id;
9258     if csr_get_default%notfound then
9259       close csr_get_default;
9260       hr_utility.set_message(801, 'HR_7972_PER_NO_DEFAULT_TYPE');
9261       hr_utility.raise_error;
9262     end if;
9263     close csr_get_default;
9264  if g_debug then
9265     hr_utility.set_location(l_proc,40);
9266  end if;
9267   else
9268  if g_debug then
9269     hr_utility.set_location(l_proc,50);
9270  end if;
9271     --
9272     -- Validate the specified person type.
9273     --
9274     open csr_person_type;
9275     fetch csr_person_type
9276     into l_system_person_type,
9277          l_active_flag,
9278     l_business_group_id;
9279     if csr_person_type%notfound then
9280       close csr_person_type;
9281       hr_utility.set_message(801, 'HR_7513_PER_TYPE_INVALID');
9282       hr_utility.raise_error;
9283     end if;
9284     close csr_person_type;
9285  if g_debug then
9286     hr_utility.set_location(l_proc,60);
9287  end if;
9288     --
9289     if l_active_flag <> 'Y' then
9290       hr_utility.set_message(801, 'HR_7973_PER_TYPE_NOT_ACTIVE');
9291       hr_utility.raise_error;
9292     elsif l_business_group_id <> p_business_group_id then
9293       hr_utility.set_message(801, 'HR_7974_PER_TYPE_INV_BUS_GROUP');
9294       hr_utility.raise_error;
9295     elsif l_system_person_type <> p_expected_sys_type then
9296       hr_utility.set_message(801, 'HR_7970_PER_WRONG_SYS_TYPE');
9297       hr_utility.set_message_token('SYSTYPE', p_expected_sys_type);
9298       hr_utility.raise_error;
9299     end if;
9300  if g_debug then
9301     hr_utility.set_location(l_proc,70);
9302  end if;
9303   end if;
9304 end chk_person_type;
9305 --
9306 --  ---------------------------------------------------------------------------
9307 --  |---------------------< return_legislation_code >-------------------------|
9308 --  ---------------------------------------------------------------------------
9309 --
9310 function return_legislation_code
9311   (p_person_id              in number
9312   ) return varchar2 is
9313   --
9314   -- Declare cursor
9315   -- Bug 14074720
9316   cursor csr_leg_code is
9317     SELECT o3.org_information9
9318     FROM hr_organization_information o3
9319     WHERE o3.org_information_context = 'Business Group Information'
9320     AND o3.organization_id IN
9321     (
9322         SELECT business_group_id
9323         FROM per_all_people_f
9324         WHERE person_id = p_person_id
9325         and rownum = 1);
9326   --
9327   -- Declare local variables
9328   --
9329   l_legislation_code  varchar2(150);
9330   l_proc              varchar2(72) ;
9331 begin
9332  if g_debug then
9333    l_proc :=  g_package||'return_legislation_code';
9334   hr_utility.set_location('Entering:'|| l_proc, 10);
9335  end if;
9336   --
9337   -- HR/TCA merge allows person_id to be null
9338   --
9339   if p_person_id is null then
9340     g_person_id := p_person_id;
9341     l_legislation_code := NULL;
9342  if g_debug then
9343     hr_utility.set_location(l_proc, 15);
9344  end if;
9345   --
9346   -- Ensure that all the mandatory parameter are not null
9347   --
9348   --hr_api.mandatory_arg_error(p_api_name       => l_proc,
9349   --                          p_argument       => 'person_id',
9350   --                         p_argument_value => p_person_id);
9351   --
9352   else
9353   if nvl(g_person_id, hr_api.g_number) = p_person_id then
9354     --
9355     -- The legislation code has already been found with a previous
9356     -- call to this function. Just return the value in the global
9357     -- variable.
9358     --
9359     l_legislation_code := g_legislation_code;
9360  if g_debug then
9361     hr_utility.set_location(l_proc, 20);
9362  end if;
9363   else
9364     --
9365     -- The ID is different to the last call to this function
9366     -- or this is the first call to this function.
9367     --
9368   open csr_leg_code;
9369   fetch csr_leg_code into l_legislation_code;
9370   if csr_leg_code%notfound then
9371     close csr_leg_code;
9372     --
9373     -- The primary key is invalid therefore we must error
9374     --
9375     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
9376     hr_utility.raise_error;
9377   end if;
9378   --
9379   close csr_leg_code;
9380  if g_debug then
9381   hr_utility.set_location(' Leaving:'|| l_proc, 20);
9382  end if;
9383   --
9384     g_person_id := p_person_id;
9385     g_legislation_code := l_legislation_code;
9386   end if;
9387   end if;  -- HR/TCA merge
9388  if g_debug then
9389   hr_utility.set_location(' Leaving:'|| l_proc, 25);
9390  end if;
9391   --
9392   return l_legislation_code;
9393 end return_legislation_code;
9394 --
9395 -- ----------------------------------------------------------------------------
9396 -- |------------------------< chk_system_pers_type>---------------------------|
9397 -- ----------------------------------------------------------------------------
9398 --
9399 procedure chk_system_pers_type
9400   (p_person_id              in number
9401   ,p_validation_start_date  in date
9402   ,p_validation_end_date    in date
9403   ,p_datetrack_mode         in varchar2
9404   ,p_effective_date         in date
9405   )
9406   is
9407 --
9408    l_exists         varchar2(1);
9409    l_person_type    varchar2(30);
9410    l_proc           varchar2(72)  :=  g_package||'chk_system_pers_type';
9411 --
9412    cursor csr_get_system_person_type is
9413      select   ppt.system_person_type
9414      from     per_all_people_f ppf
9415      ,        per_person_types ppt
9416      where    p_effective_date between ppf.effective_start_date
9417                                    and ppf.effective_end_date
9418      and      ppf.person_id = p_person_id
9419      and      ppt.person_type_id = ppf.person_type_id;
9420 --
9421    cursor csr_chk_future_changes is
9422      select   null
9423      from     sys.dual
9424      where exists(select   null
9425                   from     per_all_people_f ppf
9426                   ,        per_person_types ppt
9427                   where    ppf.effective_start_date between
9428                                                     p_validation_start_date
9429                                                 and p_validation_end_date
9430                   and      ppf.person_id = p_person_id
9431                   and      ppt.person_type_id = ppf.person_type_id
9432                   and      ppt.system_person_type <> l_person_type);
9433 
9434 --
9435 begin
9436  if g_debug then
9437   hr_utility.set_location('Entering:'|| l_proc, 1);
9438  end if;
9439   --
9440   -- Check mandatory parameters have been set
9441   --
9442   hr_api.mandatory_arg_error
9443     (p_api_name       => l_proc
9444     ,p_argument       => 'person_id'
9445     ,p_argument_value => p_person_id
9446     );
9447   --
9448   hr_api.mandatory_arg_error
9449     (p_api_name       => l_proc
9450     ,p_argument       => 'validation_start_date'
9451     ,p_argument_value => p_validation_start_date
9452     );
9453   --
9454   hr_api.mandatory_arg_error
9455     (p_api_name       => l_proc
9456     ,p_argument       => 'validation_end_date'
9457     ,p_argument_value => p_validation_end_date
9458     );
9459   --
9460  if g_debug then
9461   hr_utility.set_location(l_proc, 2);
9462  end if;
9463   --
9464   -- Get current value for system_person_type (i.e. as of the
9465   -- effective date)
9466   --
9467   open csr_get_system_person_type;
9468   fetch csr_get_system_person_type into l_person_type;
9469   close csr_get_system_person_type;
9470   --
9471  if g_debug then
9472   hr_utility.set_location(l_proc, 3);
9473  end if;
9474   --
9475   -- Check that no future changes exist for the person type
9476   --
9477   open csr_chk_future_changes;
9478   fetch csr_chk_future_changes into l_exists;
9479   if csr_chk_future_changes%found then
9480     close csr_chk_future_changes;
9481     hr_utility.set_message(801, 'HR_7979_PER_SYS_PERS_TYP_CHANG');
9482     hr_utility.raise_error;
9483   end if;
9484   close csr_chk_future_changes;
9485   --
9486  if g_debug then
9487   hr_utility.set_location(' Leaving:'|| l_proc, 4);
9488  end if;
9489 end chk_system_pers_type;
9490 --
9491 end per_per_bus;