DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SUC_BUS

Source


1 PACKAGE BODY per_suc_bus
2 AS
3 /* $Header: pesucrhi.pkb 120.1.12010000.9 2010/02/22 20:28:53 schowdhu ship $ */
4 --
5 -- ----------------------------------------------------------------------------
6 -- |                     Private Global Definitions                           |
7 -- ----------------------------------------------------------------------------
8 --
9    g_package   VARCHAR2 (33) := '  per_suc_bus.';                            -- Global package name
10 
11 --
12 -- ----------------------------------------------------------------------------
13 -- |-----------------------< chk_succession_plan_id >-------------------------|
14 -- ----------------------------------------------------------------------------
15 --
16 -- Description
17 --   This procedure is used to check that the primary key for the succession
18 --   planning table is created properly. It should be null on insert and
19 --   should not be able to be updated.
20 --
21 -- Pre Conditions
22 --   None.
23 --
24 -- In Parameters
25 --   succession_plan_id                 PK of record being inserted or updated.
26 --   object_version_number              Object version number of record being
27 --                                      inserted or updated.
28 --
29 -- Post Success
30 --   Processing continues
31 --
32 -- Post Failure
33 --   Errors handled by the procedure
34 --
35 -- Access Status
36 --   Internal and External use.
37 --
38    PROCEDURE chk_succession_plan_id (
39       p_succession_plan_id      IN   NUMBER,
40       p_object_version_number   IN   NUMBER
41    )
42    IS
43       --
44       l_proc           VARCHAR2 (72) := g_package || 'chk_succession_plan_id';
45       l_api_updating   BOOLEAN;
46    --
47    BEGIN
48       --
49       hr_utility.set_location ('Entering:' || l_proc, 5);
50       --
51       l_api_updating             :=
52          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
53                                    p_object_version_number      => p_object_version_number
54                                   );
55 
56       --
57       IF (    l_api_updating
58           AND NVL (p_succession_plan_id, hr_api.g_number) <>
59                                                             per_suc_shd.g_old_rec.succession_plan_id
60          )
61       THEN
62          --
63          -- raise error as PK has changed
64          --
65          per_suc_shd.constraint_error ('PER_SUCCESSION_PLANNING_PK');
66       --
67       ELSIF NOT l_api_updating
68       THEN
69          --
70          -- check if PK is null
71          --
72          IF p_succession_plan_id IS NOT NULL
73          THEN
74             --
75             -- raise error as PK is not null
76             --
77             per_suc_shd.constraint_error ('PER_SUCCESSION_PLANNING_PK');
78          --
79          END IF;
80       --
81       END IF;
82 
83       --
84       hr_utility.set_location (' Leaving:' || l_proc, 10);
85    --
86    END chk_succession_plan_id;
87 
88 -- ----------------------------------------------------------------------------
89 -- |----------------------------< chk_person_id >-----------------------------|
90 -- ----------------------------------------------------------------------------
91 --
92 -- Description
93 --   This procedure is used to check that the person_id exists as of effective
94 --   date.
95 --
96 -- Pre Conditions
97 --   None.
98 --
99 -- In Parameters
100 --   effective_date                     effective date
101 --   succession_plan_id                 PK of record being inserted or updated.
102 --   person_id                          id of person being inserted.
103 --   object_version_number              Object version number of record being
104 --                                      inserted or updated.
105 --
106 -- Post Success
107 --   Processing continues
108 --
109 -- Post Failure
110 --   Errors handled by the procedure
111 --
112 -- Access Status
113 --   Internal and External use.
114    PROCEDURE chk_person_id (
115       p_effective_date          IN   DATE,
116       p_succession_plan_id      IN   NUMBER,
117       p_person_id               IN   NUMBER,
118       p_object_version_number   IN   NUMBER
119    )
120    IS
121       --
122       l_proc           VARCHAR2 (72) := g_package || 'chk_person_id';
123       l_api_updating   BOOLEAN;
124       l_dummy          VARCHAR2 (1);
125 
126       --
127       CURSOR c1
128       IS
129          SELECT NULL
130            FROM per_people_f ppf, per_person_type_usages_f ptu, per_person_types ppt
131           WHERE ppf.person_id = p_person_id
132             AND TRUNC (SYSDATE) BETWEEN ppf.effective_start_date AND ppf.effective_end_date
133             AND ppf.person_id = ptu.person_id
134             AND TRUNC (SYSDATE) BETWEEN ptu.effective_start_date AND ptu.effective_end_date
135             AND ptu.person_type_id = ppt.person_type_id
136             AND (   ppt.system_person_type = 'EMP'
137                  OR ppt.system_person_type = 'APL'
138                  OR ppt.system_person_type = 'CWK'
139                 );
140    --
141    BEGIN
142       --
143       hr_utility.set_location ('Entering:' || l_proc, 5);
144       --
145       l_api_updating             :=
146          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
147                                    p_object_version_number      => p_object_version_number
148                                   );
149 
150       --
151       IF (       l_api_updating
152              AND NVL (p_person_id, hr_api.g_number) <>
153                                               NVL (per_suc_shd.g_old_rec.person_id, hr_api.g_number)
154           OR NOT l_api_updating
155          )
156       THEN
157          --
158          -- check if person_id is null
159          --
160          IF p_person_id IS NULL
161          THEN
162             --
163             -- raise error as this a mandatory requirement
164             --
165             hr_utility.set_message (801, 'HR_52784_SUC_CHK_PERSON_ID');
166             hr_utility.raise_error;
167          --
168          END IF;
169 
170          --
171          /*if l_api_updating then
172             --
173             -- raise error as the person can not be updated.
174             --
175             hr_utility.set_message(801,'HR_52785_SUC_CHK_PERSON_UPDATE');
176             hr_utility.raise_error;
177             --
178          end if;*/
179          --
180          -- check if the person_id exists as of effective date.
181          --
182          OPEN c1;
183 
184          --
185          FETCH c1
186           INTO l_dummy;
187 
188          --
189          IF c1%NOTFOUND
190          THEN
191             --
192             CLOSE c1;
193 
194             --
195             -- raise error as person does not exist.
196             --
197             hr_utility.set_message (801, 'HR_52786_SUC_CHK_PERSON_EXISTS');
198             hr_utility.raise_error;
199          --
200          END IF;
201 
202          --
203          CLOSE c1;
204       --
205       END IF;
206 
207       --
208       hr_utility.set_location (' Leaving:' || l_proc, 10);
209    --
210    END chk_person_id;
211 
212 --
213 -- ----------------------------------------------------------------------------
214 -- |----------------------------< chk_position_id >---------------------------|
215 -- ----------------------------------------------------------------------------
216 --
217 -- Description
218 --   This procedure is used to check that the position_id exists as of
219 --   effective date.
220 --
221 -- Pre Conditions
222 --   None.
223 --
224 -- In Parameters
225 --   effective_date                     effective date
226 --   succession_plan_id                 PK of record being inserted or updated.
227 --   position_id                        id of position being inserted.
228 --   object_version_number              Object version number of record being
229 --                                      inserted or updated.
230 -- Post Success
231 --   Processing continues
232 --
233 -- Post Failure
234 --   Errors handled by the procedure
235 --
236 -- Access Status
237 --   Internal and External use.
238    PROCEDURE chk_position_id (
239       p_effective_date          IN   DATE,
240       p_succession_plan_id      IN   NUMBER,
241       p_position_id             IN   NUMBER,
242       p_object_version_number   IN   NUMBER
243    )
244    IS
245       --
246       l_proc           VARCHAR2 (72) := g_package || 'chk_position_id';
247       l_api_updating   BOOLEAN;
248       l_dummy          VARCHAR2 (1);
249 
250       --
251       -- Changes 12-Oct-99 SCNair (per_positions to hr_positions_f) Date tracked positions req.
252       --
253       CURSOR c1
254       IS
255          SELECT NULL
256            FROM hr_positions_f per
257           WHERE per.position_id = NVL (p_position_id, -1)
258             AND p_effective_date BETWEEN per.effective_start_date AND per.effective_end_date
259             AND p_effective_date BETWEEN per.date_effective
260                                      AND NVL (hr_general.get_position_date_end (per.position_id),
261                                               hr_api.g_eot
262                                              );
263    --
264    BEGIN
265       --
266       hr_utility.set_location ('Entering:' || l_proc, 5);
267       --
268       l_api_updating             :=
269          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
270                                    p_object_version_number      => p_object_version_number
271                                   );
272 
273       --
274       IF (       l_api_updating
275              AND NVL (p_position_id, hr_api.g_number) <>
276                                             NVL (per_suc_shd.g_old_rec.position_id, hr_api.g_number)
277           OR NOT l_api_updating
278          )
279       THEN
280            --
281            -- check if position_id is null
282            --
283          /*  if p_position_id is null then
284              --
285              -- raise error as this a mandatory requirement
286              --
287              hr_utility.set_message(801,'HR_51998_SUC_CHK_POSITION_ID');
288              hr_utility.raise_error;
289              --
290            end if;*/
291            --
292          IF l_api_updating
293          THEN
294             --
295             -- raise error as the position_id can not be updated.
296             --
297             hr_utility.set_message (801, 'HR_51999_SUC_CHK_POS_UPDATE');
298             hr_utility.raise_error;
299          --
300          END IF;
301 
302          --
303          -- check if the position_id exists as of effective_date.
304          --
305          OPEN c1;
306 
307          --
308          FETCH c1
309           INTO l_dummy;
310 
311          --
312          IF c1%NOTFOUND
313          THEN
314             --
315             CLOSE c1;
316 
317             --
318             -- raise error as position does not exist as of effective date.
319             --
320             per_suc_shd.constraint_error ('PER_SUCCESSION_PLANNING_FK1');
321          --
322          END IF;
323 
324          --
325          CLOSE c1;
326       --
327       END IF;
328 
329       --
330       hr_utility.set_location (' Leaving:' || l_proc, 10);
331    --
332    END chk_position_id;
333 
334 --
335 -- ----------------------------------------------------------------------------
336 -- |----------------------------< chk_job_id >---------------------------|
337 -- ----------------------------------------------------------------------------
338 --
339 -- Description
340 --   This procedure is used to check that the job_id exists as of
341 --   effective date.
342 --
343 -- Pre Conditions
344 --   None.
345 --
346 -- In Parameters
347 --   effective_date                     effective date
348 --   succession_plan_id                 PK of record being inserted or updated.
349 --   job_id                             id of job being inserted.
350 --   object_version_number              Object version number of record being
351 --                                      inserted or updated.
352 -- Post Success
353 --   Processing continues
354 --
355 -- Post Failure
356 --   Errors handled by the procedure
357 --
358 -- Access Status
359 --   Internal and External use.
360    PROCEDURE chk_job_id (
361       p_effective_date          IN   DATE,
362       p_succession_plan_id      IN   NUMBER,
363       p_job_id                  IN   NUMBER,
364       p_object_version_number   IN   NUMBER
365    )
366    IS
367       --
368       l_proc           VARCHAR2 (72) := g_package || 'chk_job_id';
369       l_api_updating   BOOLEAN;
370       l_dummy          VARCHAR2 (1);
371 
372       --
373       --
374       CURSOR c1
375       IS
376          SELECT NULL
377            FROM per_jobs_vl per
378           WHERE per.job_id = NVL (p_job_id, -1)
379             AND p_effective_date BETWEEN per.date_from AND NVL (date_to, TRUNC (SYSDATE));
380    --
381    BEGIN
382       --
383       hr_utility.set_location ('Entering:' || l_proc, 5);
384       --
385       l_api_updating             :=
386          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
390       --
387                                    p_object_version_number      => p_object_version_number
388                                   );
389 
391       IF (       l_api_updating
392              AND NVL (p_job_id, hr_api.g_number) <>
393                                                  NVL (per_suc_shd.g_old_rec.job_id, hr_api.g_number)
394           OR NOT l_api_updating
395          )
396       THEN
397            --
398            -- check if job_id is null
399            --
400          /*  if p_job_id is null then
401              --
402              -- raise error as this a mandatory requirement
403              --
404              hr_utility.set_message(801,'HR_XXXXX_SUC_CHK_JOB_ID');
405              hr_utility.raise_error;
406              --
407            end if;*/
408            --
409          IF l_api_updating
410          THEN
411             --
412             -- raise error as the job_id can not be updated.
413             --
414             hr_utility.set_message (801, 'HR_50493_SUC_CHK_JOB_UPDATE');
415             hr_utility.raise_error;
416          --
417          END IF;
418 
419          --
420          -- check if the job_id exists as of effective_date.
421          --
422          OPEN c1;
423 
424          --
425          FETCH c1
426           INTO l_dummy;
427 
428          --
429          IF c1%NOTFOUND
430          THEN
431             --
432             CLOSE c1;
433 
434             --
435             -- raise error as job does not exist as of effective date.
436             --
437             per_suc_shd.constraint_error ('PER_SUCCESSION_PLANNING_FK2');
438          --
439          END IF;
440 
441          --
442          CLOSE c1;
443       --
444       END IF;
445 
446       --
447       hr_utility.set_location (' Leaving:' || l_proc, 10);
448    --
449    END chk_job_id;
450 
451 --
452 -- ----------------------------------------------------------------------------
453 -- |----------------------------< chk_successee >---------------------------|
454 -- ----------------------------------------------------------------------------
455 --
456 -- Description
457 --   This procedure is used to check that the successee_id exists as of
458 --   effective date.
459 --
460 -- Pre Conditions
461 --   None.
462 --
463 -- In Parameters
464 --   effective_date                     effective date
465 --   succession_plan_id                 PK of record being inserted or updated.
466 --   job_id                             id of job being inserted.
467 --   position_id                        id of position being inserted
468 --   successee_person_id                id of person being inserted (successee)
469 --   object_version_number              Object version number of record being
470 --                                      inserted or updated.
471 -- Post Success
472 --   Processing continues
473 --
474 -- Post Failure
475 --   Errors handled by the procedure
476 --
477 -- Access Status
478 --   Internal and External use.
479    PROCEDURE chk_successee (
480       p_effective_date          IN   DATE,
481       p_succession_plan_id      IN   NUMBER,
482       p_job_id                  IN   NUMBER,
483       p_position_id             IN   NUMBER,
484       p_successee_person_id     IN   NUMBER,
485       p_object_version_number   IN   NUMBER
486    )
487    IS
488       --
489       l_proc           VARCHAR2 (72) := g_package || 'chk_successee';
490       l_api_updating   BOOLEAN;
491       l_dummy          VARCHAR2 (1);
492       l_type           VARCHAR2 (3);                                              --succession type
493       l_notnulls       NUMBER        := 0;
494    --
495    --
496 
497    --
498    BEGIN
499       --
500       hr_utility.set_location ('Entering:' || l_proc, 5);
501       --
502       l_api_updating             :=
503          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
504                                    p_object_version_number      => p_object_version_number
505                                   );
506 
507       --
508       IF (    l_api_updating
509           AND NVL (p_successee_person_id, hr_api.g_number) <>
510                                     NVL (per_suc_shd.g_old_rec.successee_person_id, hr_api.g_number)
511          )
512       THEN
513          --
514          -- raise error as the person can not be updated.
515          --
516          hr_utility.set_message (801, 'HR_50494_SUC_CHK_SUCC_UPDATE');
517          hr_utility.raise_error;
518       --
519       END IF;
520 
521       --
522       IF (p_job_id IS NOT NULL)
523       THEN
524          l_type                     := 'JOB';
525          -- CHK_JOB_ID
526          --
527          chk_job_id (p_effective_date, p_succession_plan_id, p_job_id, p_object_version_number);
528          l_notnulls                 := l_notnulls + 1;
529       END IF;
530 
531       IF (p_position_id IS NOT NULL)
532       THEN
533          l_type                     := 'POS';
534          -- CHK_POSITION_ID
535          --
536          chk_position_id (p_effective_date,
537                           p_succession_plan_id,
538                           p_position_id,
539                           p_object_version_number
540                          );
541          l_notnulls                 := l_notnulls + 1;
542       END IF;
543 
547          -- CHK_SUCCESSEE_PERSON_ID
544       IF (p_successee_person_id IS NOT NULL)
545       THEN
546          l_type                     := 'EMP';
548          --
549          chk_person_id (p_effective_date,
550                         p_succession_plan_id,
551                         p_successee_person_id,
552                         p_object_version_number
553                        );
554          l_notnulls                 := l_notnulls + 1;
555       END IF;
556 
557       IF (l_notnulls = 0)
558       THEN
559          --
560          -- raise error as JOB OR POSITION OR SUCCESSEE PERSON ID IS MANDATORY
561          --
562          per_suc_shd.constraint_error ('HR_50495_SUC_CHK_SUC_MISSING');
563       ELSIF (l_notnulls > 1)
564       THEN
565          --
566            -- raise error as MORE THAN ONE SUCCESSEE ID IS ENTERED
567            --
568          per_suc_shd.constraint_error ('HR_50496_SUC_CHK_SUC_EXIST');
569       END IF;
570 
571       --
572       hr_utility.set_location (' Leaving:' || l_proc, 10);
573    --
574    END chk_successee;
575 
576 --
577 -- ----------------------------------------------------------------------------
578 -- |----------------------------< chk_successor >---------------------------|
579 -- ----------------------------------------------------------------------------
580 --
581 -- Description
582 --   This procedure is used to check that the successor exists as of
583 --   effective date and whether successee and successor are the same or login user is a successor
584 --
585 -- Pre Conditions
586 --   None.
587 --
588 -- In Parameters
589 --   effective_date                     effective date
590 --   succession_plan_id                 PK of record being inserted or updated.
591 --   job_id                             id of job being inserted.
592 --   object_version_number              Object version number of record being
593 --                                      inserted or updated.
594 -- Post Success
595 --   Processing continues
596 --
597 -- Post Failure
598 --   Errors handled by the procedure
599 --
600 -- Access Status
601 --   Internal and External use.
602    PROCEDURE chk_successor (
603       p_effective_date          IN   DATE,
604       p_succession_plan_id      IN   NUMBER,
605       p_person_id               IN   NUMBER,
606       p_job_id                  IN   NUMBER,
607       p_position_id             IN   NUMBER,
608       p_person_rank             IN   NUMBER,
609       p_successee_person_id     IN   NUMBER,
610       p_object_version_number   IN   NUMBER,
611       p_start_date              IN   DATE
612    )
613    IS
614       --
615       l_proc           VARCHAR2 (72) := g_package || 'chk_successor';
616       l_api_updating   BOOLEAN;
617       l_dummy          VARCHAR2 (1);
618 
619        --
620       -- cursor to check duplication of ranking for the same successee
621       CURSOR c1
622       IS
623          SELECT NULL
624            FROM per_succession_planning per
625           WHERE per.succession_plan_id <> NVL (p_succession_plan_id, -1)
626             AND (   (p_position_id IS NOT NULL AND per.position_id = p_position_id)
627                  OR (p_job_id IS NOT NULL AND per.job_id = p_job_id)
628                  OR (    p_successee_person_id IS NOT NULL
629                      AND per.successee_person_id = p_successee_person_id
630                     )
631                 )
632             AND per.person_rank = p_person_rank
633             AND p_start_date BETWEEN NVL (per.start_date, hr_api.g_eot)
634                                  AND NVL (per.end_date, hr_api.g_eot);
635 
636       -- cursor to check duplication of successors for the same successee
637       CURSOR c2
638       IS
639          SELECT NULL
640            FROM per_succession_planning per
641           WHERE per.succession_plan_id <> NVL (p_succession_plan_id, -1)
642             AND (   (p_position_id IS NOT NULL AND per.position_id = p_position_id)
643                  OR (p_job_id IS NOT NULL AND per.job_id = p_job_id)
644                  OR (    p_successee_person_id IS NOT NULL
645                      AND per.successee_person_id = p_successee_person_id
646                     )
647                 )
648             AND per.person_id = p_person_id
649             AND p_start_date BETWEEN NVL (per.start_date, hr_api.g_eot)
650                                  AND NVL (per.end_date, hr_api.g_eot);
651    BEGIN
652       --
653       hr_utility.set_location ('Entering:' || l_proc, 5);
654       --
655       l_api_updating             :=
656          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
657                                    p_object_version_number      => p_object_version_number
658                                   );
659 
660       --
661       IF (       l_api_updating
662              AND NVL (p_person_id, hr_api.g_number) <>
663                                               NVL (per_suc_shd.g_old_rec.person_id, hr_api.g_number)
664           OR NOT l_api_updating
665          )
666       THEN
667          --
668 
669          --
670          IF l_api_updating
671          THEN
672             --
673             -- raise error as the person_id can not be updated.
674             --
675             hr_utility.set_message (801, 'HR_50497_SUC_CHK_SUC_UPDATE');
676             hr_utility.raise_error;
677          --
678          END IF;
679 
680          -- CHK_SUCCESSOR_ID
681          --
682          chk_person_id (p_effective_date, p_succession_plan_id, p_person_id,
686          THEN
683                         p_object_version_number);
684 
685          IF (p_person_id = NVL (p_successee_person_id, -1))
687             --
688               -- raise error as successee and successor are the same person
689               --
690             hr_utility.set_message (800, 'HR_50498_SUC_CHK_SAME_PERSON');
691             hr_utility.raise_error;
692          END IF;
693 
694          IF (p_person_id = fnd_global.employee_id)
695          THEN
696             --
697               -- raise error as login user cannot make himself a successor
698               --
699             hr_utility.set_message (800, 'HR_50499_SUC_CHK_LOGIN_USE');
700             hr_utility.raise_error;
701          END IF;
702 
703          -- check duplication of ranking for the same successee
704          OPEN c1;
705 
706          FETCH c1
707           INTO l_dummy;
708 
709          IF c1%FOUND
710          THEN
711             CLOSE c1;
712 
713             -- raise error as succession plan records overlap.
714             --
715             hr_utility.set_message (800, 'HR_33467_SUC_CHK_SAME_RANK');
716             hr_utility.raise_error;
717          --
718          END IF;
719 
720          --
721          CLOSE c1;
722 
723          -- check duplication of successors for the same successee
724          OPEN c2;
725 
726          FETCH c2
727           INTO l_dummy;
728 
729          IF c2%FOUND
730          THEN
731             CLOSE c2;
732 
733             -- raise error as succession plan records overlap.
734             --
735             hr_utility.set_message (800, 'HR_33468_SUC_SAME_SUCCESSOR');
736             hr_utility.raise_error;
737          --
738          END IF;
739 
740          --
741          CLOSE c2;
742       END IF;
743 
744       --
745       hr_utility.set_location (' Leaving:' || l_proc, 10);
746    --
747    END chk_successor;
748 
749 -- ----------------------------------------------------------------------------
750 -- |-----------------------------< chk_time_scale >---------------------------|
751 -- ----------------------------------------------------------------------------
752 --
753 -- Description
754 --   This procedure is used to check that the potential lookup falles within
755 --   the per_time_scales lookup.
756 --
757 -- Pre Conditions
758 --   None.
759 --
760 -- In Parameters
761 --   succession_plan_id                 PK of record being inserted or updated.
762 --   time_scale                         potential lookup.
763 --   object_version_number              Object version number of record being
764 --                                      inserted or updated.
765 --   effective_date                     effective date
766 --
767 -- Post Success
768 --   Processing continues
769 --
770 -- Post Failure
771 --   Error handled by procedure
772 --
773 -- Access Status
774 --   Internal and External use.
775 --
776    PROCEDURE chk_time_scale (
777       p_succession_plan_id      IN   NUMBER,
778       p_time_scale              IN   VARCHAR2,
779       p_object_version_number   IN   NUMBER,
780       p_effective_date          IN   DATE
781    )
782    IS
783       --
784       l_proc           VARCHAR2 (72) := g_package || 'chk_time_scale';
785       l_api_updating   BOOLEAN;
786    --
787    BEGIN
788       --
789       hr_utility.set_location ('Entering:' || l_proc, 5);
790       hr_utility.set_location ('p_effective_date:' || p_effective_date, 5);
791       hr_utility.set_location ('p_time_scale:' || p_time_scale, 5);
792       --
793       l_api_updating             :=
794          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
795                                    p_object_version_number      => p_object_version_number
796                                   );
797 
798       --
799       IF (       l_api_updating
800              AND NVL (p_time_scale, hr_api.g_varchar2) <>
801                                            NVL (per_suc_shd.g_old_rec.time_scale, hr_api.g_varchar2)
802           OR NOT l_api_updating
803          )
804       THEN
805          --
806          --
807          -- check if value of time scale lookup falls within lookup.
808          -- LOV name changed for bug 8478347
809          IF     hr_api.not_exists_in_hr_lookups (p_lookup_type         => 'READINESS_LEVEL',
810                                                  p_lookup_code         => p_time_scale,
811                                                  p_effective_date      => p_effective_date
812                                                 )
813             AND hr_api.not_exists_in_hr_lookups (p_lookup_type         => 'PER_TIME_SCALES',
814                                                  p_lookup_code         => p_time_scale,
815                                                  p_effective_date      => p_effective_date
816                                                 )
817          THEN
818             --
819             -- raise error as does not exist as lookup
820             --
821             hr_utility.set_message (801, 'HR_52001_SUC_CHK_TIME_SCALE');
822             hr_utility.raise_error;
823          --
824          END IF;
825       --
826       END IF;
827 
828       --
829       hr_utility.set_location ('Leaving:' || l_proc, 10);
830    --
831    END chk_time_scale;
832 
833 -- ----------------------------------------------------------------------------
837 -- Description
834 -- |----------------------------< chk_start_date >----------------------------|
835 -- ----------------------------------------------------------------------------
836 --
838 --   This procedure is used to check that the start_date has been populated.
839 --
840 -- Pre Conditions
841 --   None.
842 --
843 -- In Parameters
844 --   succession_plan_id                 PK of record being inserted or updated.
845 --   start_date                         start date of succession plan record.
846 --   object_version_number              Object version number of record being
847 --                                      inserted or updated.
848 -- Post Success
849 --   Processing continues
850 --
851 -- Post Failure
852 --   Errors handled by the procedure
853 --
854 -- Access Status
855 --   Internal and External use.
856    PROCEDURE chk_start_date (
857       p_succession_plan_id      IN   NUMBER,
858       p_start_date              IN   DATE,
859       p_object_version_number   IN   NUMBER
860    )
861    IS
862       --
863       l_proc           VARCHAR2 (72) := g_package || 'chk_start_date';
864       l_api_updating   BOOLEAN;
865    --
866    BEGIN
867       --
868       hr_utility.set_location ('Entering:' || l_proc, 5);
869       --
870       l_api_updating             :=
871          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
872                                    p_object_version_number      => p_object_version_number
873                                   );
874 
875       --
876       IF (       l_api_updating
877              AND NVL (p_start_date, hr_api.g_date) <>
878                                                NVL (per_suc_shd.g_old_rec.start_date, hr_api.g_date)
879           OR NOT l_api_updating
880          )
881       THEN
882          --
883          -- check if start date is null
884          --
885          IF p_start_date IS NULL
886          THEN
887             --
888             -- raise error as this a mandatory requirement
889             --
890             hr_utility.set_message (801, 'HR_52002_SUC_CHK_START_DATE');
891             hr_utility.raise_error;
892          --
893          END IF;
894       --
895       END IF;
896 
897       --
898       hr_utility.set_location (' Leaving:' || l_proc, 10);
899    --
900    END chk_start_date;
901 
902 -- ----------------------------------------------------------------------------
903 -- |----------------------------< chk_end_date >------------------------------|
904 -- ----------------------------------------------------------------------------
905 --
906 -- Description
907 --   This procedure is used to check that the end date is later than the
908 --   start date.
909 --
910 -- Pre Conditions
911 --   None.
912 --
913 -- In Parameters
914 --   succession_plan_id                 PK of record being inserted or updated.
915 --   start_date                         start date of succession plan record.
916 --   end_date                           end date of succession plan record.
917 --   object_version_number              Object version number of record being
918 --                                      inserted or updated.
919 -- Post Success
920 --   Processing continues
921 --
922 -- Post Failure
923 --   Errors handled by the procedure
924 --
925 -- Access Status
926 --   Internal and External use.
927    PROCEDURE chk_end_date (
928       p_succession_plan_id      IN   NUMBER,
929       p_start_date              IN   DATE,
930       p_end_date                IN   DATE,
931       p_object_version_number   IN   NUMBER
932    )
933    IS
934       --
935       l_proc           VARCHAR2 (72) := g_package || 'chk_end_date';
936       l_api_updating   BOOLEAN;
937    --
938    BEGIN
939       --
940       hr_utility.set_location ('Entering:' || l_proc, 5);
941       --
942       l_api_updating             :=
943          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
944                                    p_object_version_number      => p_object_version_number
945                                   );
946 
947       --
948       IF (       l_api_updating
949              AND (   NVL (p_start_date, hr_api.g_date) <>
950                                                NVL (per_suc_shd.g_old_rec.start_date, hr_api.g_date)
951                   OR NVL (p_end_date, hr_api.g_date) <>
952                                                  NVL (per_suc_shd.g_old_rec.end_date, hr_api.g_date)
953                  )
954           OR NOT l_api_updating
955          )
956       THEN
957          --
958          -- check if end date is greater than start date
959          --
960          IF p_start_date > NVL (p_end_date, hr_api.g_eot)
961          THEN
962             --
963             -- raise error as start date should be less than or equal to end date.
964             --
965             hr_utility.set_message (801, 'HR_52003_SUC_CHK_END_DATE');
966             hr_utility.raise_error;
967          --
968          END IF;
969       --
970       END IF;
971 
972       --
973       hr_utility.set_location (' Leaving:' || l_proc, 10);
974    --
975    END chk_end_date;
976 
977 -- ----------------------------------------------------------------------------
978 -- |----------------------< chk_available_for_promotion >---------------------|
979 -- ----------------------------------------------------------------------------
980 --
981 -- Description
985 -- Pre Conditions
982 --   This procedure is used to check that the available_for_promotion field
983 --   falls within the 'YES_NO' lookup.
984 --
986 --   None.
987 --
988 -- In Parameters
989 --   succession_plan_id                 PK of record being inserted or updated.
990 --   available_for_promotion            available_for_promotion lookup.
991 --   object_version_number              Object version number of record being
992 --                                      inserted or updated.
993 --   effective_date                     effective date
994 --
995 -- Post Success
996 --   Processing continues
997 --
998 -- Post Failure
999 --   Error handled by procedure
1000 --
1001 -- Access Status
1002 --   Internal and External use.
1003 --
1004    PROCEDURE chk_available_for_promotion (
1005       p_succession_plan_id        IN   NUMBER,
1006       p_available_for_promotion   IN   VARCHAR2,
1007       p_object_version_number     IN   NUMBER,
1008       p_effective_date            IN   DATE
1009    )
1010    IS
1011       --
1012       l_proc           VARCHAR2 (72) := g_package || 'chk_available_for_promotion';
1013       l_api_updating   BOOLEAN;
1014    --
1015    BEGIN
1016       --
1017       hr_utility.set_location ('Entering:' || l_proc, 5);
1018       --
1019       l_api_updating             :=
1020          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
1021                                    p_object_version_number      => p_object_version_number
1022                                   );
1023 
1024       --
1025       IF (       l_api_updating
1026              AND NVL (p_available_for_promotion, hr_api.g_varchar2) <>
1027                                                        per_suc_shd.g_old_rec.available_for_promotion
1028           OR NOT l_api_updating
1029          )
1030       THEN
1031          --
1032          -- check if value of available for promotion scale lookup falls within
1033          -- lookup.
1034          --
1035          IF p_available_for_promotion IS NOT NULL
1036          THEN
1037             --
1038             IF hr_api.not_exists_in_hr_lookups (p_lookup_type         => 'YES_NO',
1039                                                 p_lookup_code         => p_available_for_promotion,
1040                                                 p_effective_date      => p_effective_date
1041                                                )
1042             THEN
1043                --
1044                -- raise error as does not exist as lookup
1045                --
1046                per_suc_shd.constraint_error ('PER_SUC_AVAIL_FOR_PROMOTION');
1047             --
1048             END IF;
1049          --
1050          END IF;
1051       --
1052       END IF;
1053 
1054       --
1055       hr_utility.set_location ('Leaving:' || l_proc, 10);
1056    --
1057    END chk_available_for_promotion;
1058 
1059 -- ----------------------------------------------------------------------------
1060 -- |----------------------< chk_plan_status >---------------------|
1061 -- ----------------------------------------------------------------------------
1062 --
1063 -- Description
1064 --   This procedure is used to check that the plan_status field
1065 --   falls within the 'SUCCESSION_PLAN_STATUS' lookup.
1066 --
1067 -- Pre Conditions
1068 --   None.
1069 --
1070 -- In Parameters
1071 --   succession_plan_id                 PK of record being inserted or updated.
1072 --   plan_status                        plan_status lookup.
1073 --   object_version_number              Object version number of record being
1074 --                                      inserted or updated.
1075 --   effective_date                     effective date
1076 --
1077 -- Post Success
1078 --   Processing continues
1079 --
1080 -- Post Failure
1081 --   Error handled by procedure
1082 --
1083 -- Access Status
1084 --   Internal and External use.
1085 --
1086    PROCEDURE chk_plan_status (
1087       p_succession_plan_id      IN   NUMBER,
1088       p_plan_status             IN   VARCHAR2,
1089       p_object_version_number   IN   NUMBER,
1090       p_effective_date          IN   DATE
1091    )
1092    IS
1093       --
1094       l_proc           VARCHAR2 (72) := g_package || 'chk_plan_status';
1095       l_api_updating   BOOLEAN;
1096    --
1097    BEGIN
1098       --
1099       hr_utility.set_location ('Entering:' || l_proc, 5);
1100       --
1101       l_api_updating             :=
1102          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
1103                                    p_object_version_number      => p_object_version_number
1104                                   );
1105 
1106       --
1107       IF (       l_api_updating
1108              AND NVL (p_plan_status, hr_api.g_varchar2) <> per_suc_shd.g_old_rec.plan_status
1109           OR NOT l_api_updating
1110          )
1111       THEN
1112          --
1113          -- check if value of plan status lookup falls within
1114          -- lookup.
1115          --
1116          IF p_plan_status IS NOT NULL
1117          THEN
1118             --
1119             IF hr_api.not_exists_in_hr_lookups (p_lookup_type         => 'SUCCESSION_PLAN_STATUS',
1120                                                 p_lookup_code         => p_plan_status,
1121                                                 p_effective_date      => p_effective_date
1122                                                )
1123             THEN
1124                --
1125                -- raise error as does not exist as lookup
1126                --
1130             END IF;
1127             hr_utility.set_message (800, 'HR_51934_SUC_CHK_STATUS');
1128             hr_utility.raise_error;
1129             --
1131          --
1132          END IF;
1133       --
1134       END IF;
1135 
1136       --
1137       hr_utility.set_location ('Leaving:' || l_proc, 10);
1138    --
1139    END chk_plan_status;
1140 
1141 --
1142 -- ----------------------------------------------------------------------------
1143 -- |----------------------------< chk_readiness_percentage >---------------------------|
1144 -- ----------------------------------------------------------------------------
1145 --
1146 -- Description
1147 --   This procedure is used to check that the readiness_percentage is a number between
1148 --   0 and 100.
1149 --
1150 -- Pre Conditions
1151 --   None.
1152 --
1153 -- In Parameters
1154 --   succession_plan_id                 PK of record being inserted or updated.
1155 --   readiness_percentage               readiness_percentage being inserted.
1156 --   object_version_number              Object version number of record being
1157 --                                      inserted or updated.
1158 -- Post Success
1159 --   Processing continues
1160 --
1161 -- Post Failure
1162 --   Errors handled by the procedure
1163 --
1164 -- Access Status
1165 --   Internal and External use.
1166    PROCEDURE chk_readiness_percentage (
1167       p_succession_plan_id      IN   NUMBER,
1168       p_readiness_percentage    IN   NUMBER,
1169       p_object_version_number   IN   NUMBER
1170    )
1171    IS
1172       --
1173       l_proc           VARCHAR2 (72) := g_package || 'chk_readiness_percentage';
1174       l_api_updating   BOOLEAN;
1175    --
1176    BEGIN
1177       --
1178       hr_utility.set_location ('Entering:' || l_proc, 5);
1179       --
1180       l_api_updating             :=
1181          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
1182                                    p_object_version_number      => p_object_version_number
1183                                   );
1184 
1185       --
1186       IF (       l_api_updating
1187              AND NVL (p_readiness_percentage, hr_api.g_number) <>
1188                                    NVL (per_suc_shd.g_old_rec.readiness_percentage, hr_api.g_number)
1189           OR NOT l_api_updating
1190          )
1191       THEN
1192          --
1193          -- check if the readiness_percentage is a number between 0 and 100.
1194          --
1195          IF (p_readiness_percentage > 100 OR p_readiness_percentage < 0)
1196          THEN
1197             --
1198             -- raise error as position does not exist as of effective date.
1199             --
1200             hr_utility.set_message (800, 'HR_51935_SUC_CHK_PERCENT');
1201             hr_utility.raise_error;
1202          END IF;
1203       --
1204       END IF;
1205 
1206       --
1207       hr_utility.set_location (' Leaving:' || l_proc, 10);
1208    --
1209    END chk_readiness_percentage;
1210 
1211 -- ----------------------------------------------------------------------------
1212 -- |--------------------------< chk_person_start_date >------------------------|
1213 -- ----------------------------------------------------------------------------
1214 --
1215 --- Bug#3207986 start
1216 -- Description
1217 --   This procedure is used to check that the earliest date entered is later
1218 --   than the start date of the employee for the current position
1219 --
1220 --
1221 -- Pre Conditions
1222 --   None.
1223 --
1224 -- In Parameters
1225 --   p_person_id                        person_id of the person on which
1226 --                                      the transaction is being done.
1227 --   p_start_date                       the effective date entered
1228 --
1229 -- Post Success
1230 --   Processing continues
1231 --
1232 -- Post Failure
1233 --   Error handled by procedure
1234 --
1235 -- Access Status
1236 --   Internal and External use.
1237 --
1238 ------------------------------------------------------------------------
1239    PROCEDURE chk_person_start_date (
1240       p_person_id    per_people_f.person_id%TYPE,
1241       p_start_date   per_assignments_f.effective_start_date%TYPE
1242    )
1243    IS
1244       l_curr_position_id   hr_positions.position_id%TYPE;
1245 
1246       CURSOR person_start_details (
1247          p_person_id    per_people_f.person_id%TYPE,
1248          p_start_date   per_assignments_f.effective_start_date%TYPE
1249       )
1250       IS
1251          SELECT paf.position_id
1252            FROM per_assignments_f paf
1253           WHERE paf.person_id = p_person_id
1254             AND (SYSDATE BETWEEN paf.effective_start_date AND NVL (paf.effective_end_date, SYSDATE)
1255                 )
1256             AND paf.effective_start_date <= p_start_date;
1257    BEGIN
1258       OPEN person_start_details (p_person_id => p_person_id, p_start_date => p_start_date);
1259 
1260       FETCH person_start_details
1261        INTO l_curr_position_id;
1262 
1263       IF (person_start_details%NOTFOUND)
1264       THEN
1265          CLOSE person_start_details;
1266 
1267          hr_utility.set_message (801, 'HR_52005_SUC_CHK_DATE');
1268          hr_utility.raise_error;
1269       ELSE
1270          CLOSE person_start_details;
1271       END IF;
1272    END;
1273 
1274 --- Bug#3207986 end
1275 ------------------------------------------------------------------------------
1276 
1277    -- ----------------------------------------------------------------------------
1278 -- |----------------------------< chk_date >----------------------------------|
1279 -- ----------------------------------------------------------------------------
1280 --
1281 -- Description
1282 --   This procedure is used to check that the record being inserted or
1283 --   updated is unique.
1284 --
1285 -- Pre Conditions
1286 --   None.
1287 --
1288 -- In Parameters
1289 --   succession_plan_id                 PK of record being inserted or updated.
1290 --   person_id                          id of person being inserted.
1291 --   position_id                        id of position being inserted.
1292 --   start_date                         start date of succession plan record
1293 --   end_date                           end date of succession plan record
1294 --   object_version_number              Object version number of record being
1295 --                                      inserted or updated.
1296 -- Post Success
1297 --   Processing continues
1298 --
1299 -- Post Failure
1300 --   Errors handled by the procedure
1301 --
1302 -- Access Status
1303 --   Internal and External use.
1304    PROCEDURE chk_date (
1305       p_succession_plan_id      IN   NUMBER,
1306       p_position_id             IN   NUMBER,
1307       p_person_id               IN   NUMBER,
1308       p_start_date              IN   DATE,
1309       p_end_date                IN   DATE,
1310       p_object_version_number   IN   NUMBER,
1311       p_job_id                  IN   NUMBER,
1312       p_successee_person_id     IN   NUMBER
1313    )
1314    IS
1315       --
1316       l_proc           VARCHAR2 (72) := g_package || 'chk_date';
1317       l_api_updating   BOOLEAN;
1318       l_dummy          VARCHAR2 (1);
1319 
1320       --
1321       CURSOR c1
1322       IS
1323          SELECT NULL
1324            FROM per_succession_planning per
1325           WHERE per.person_id = p_person_id
1326             AND per.succession_plan_id <> NVL (p_succession_plan_id, -1)
1327             AND (   (p_position_id IS NOT NULL AND per.position_id = p_position_id)
1328                  OR (p_job_id IS NOT NULL AND per.job_id = p_job_id)
1329                  OR (    p_successee_person_id IS NOT NULL
1330                      AND per.successee_person_id = p_successee_person_id
1331                     )
1332                 )
1333             AND (   per.start_date BETWEEN p_start_date AND NVL (p_end_date, hr_api.g_eot)
1334                  OR NVL (per.end_date, hr_api.g_eot) BETWEEN p_start_date
1335                                                          AND NVL (p_end_date, hr_api.g_eot)
1336                 );
1337    --
1338    BEGIN
1339       --
1340       hr_utility.set_location ('Entering:' || l_proc, 5);
1341       --
1342       l_api_updating             :=
1343          per_suc_shd.api_updating (p_succession_plan_id         => p_succession_plan_id,
1344                                    p_object_version_number      => p_object_version_number
1345                                   );
1346 
1347       --
1348       IF (       l_api_updating
1349              AND (   NVL (p_start_date, hr_api.g_date) <>
1350                                                NVL (per_suc_shd.g_old_rec.start_date, hr_api.g_date)
1351                   OR NVL (p_end_date, hr_api.g_date) <>
1352                                                  NVL (per_suc_shd.g_old_rec.end_date, hr_api.g_date)
1353                  )
1354           OR NOT l_api_updating
1355          )
1356       THEN
1357          --
1358          -- check if succession plans overlap
1359          --
1360          OPEN c1;
1361 
1362          --
1363          FETCH c1
1364           INTO l_dummy;
1365 
1366          --
1367          IF c1%FOUND
1368          THEN
1369             --
1370             CLOSE c1;
1371 
1372             --
1373             -- raise error as succession plan records overlap.
1374             --
1375             per_suc_shd.constraint_error ('PER_SUCCESSION_PLANNING_UK');
1376          --
1377          END IF;
1378 
1379          --
1380          CLOSE c1;
1381       --
1382       END IF;
1383 
1384       --
1385       hr_utility.set_location (' Leaving:' || l_proc, 10);
1386    --
1387    END chk_date;
1388 
1389 --
1390 -- -----------------------------------------------------------------------
1391 -- |------------------------------< chk_df >-----------------------------|
1392 -- -----------------------------------------------------------------------
1393 --
1394 -- Description:
1395 --   Validates the all Descriptive Flexfield values.
1396 --
1397 -- Pre-conditions:
1398 --   All other columns have been validated. Must be called as the
1399 --   last step from insert_validate and update_validate.
1400 --
1401 -- In Arguments:
1402 --   p_rec
1403 --
1404 -- Post Success:
1405 --   If the Descriptive Flexfield structure column and data values are
1406 --   all valid this procedure will end normally and processing will
1407 --   continue.
1408 --
1409 -- Post Failure:
1410 --   If the Descriptive Flexfield structure column value or any of
1411 --   the data values are invalid then an application error is raised as
1412 --   a PL/SQL exception.
1413 --
1414 -- Access Status:
1415 --   Internal Row Handler Use Only.
1416 --
1417 -- {End Of Comments}
1418 -- ----------------------------------------------------------------------------
1419 --
1420    PROCEDURE chk_df (p_rec IN per_suc_shd.g_rec_type)
1421    IS
1422 --
1423       l_proc   VARCHAR2 (72) := g_package || 'chk_df';
1424 --
1425    BEGIN
1426       hr_utility.set_location ('Entering:' || l_proc, 10);
1427 
1428       --
1429       IF    (    (p_rec.succession_plan_id IS NOT NULL)
1430              AND (   NVL (per_suc_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
1431                                                    NVL (p_rec.attribute_category, hr_api.g_varchar2)
1432                   OR NVL (per_suc_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
1433                                                            NVL (p_rec.attribute1, hr_api.g_varchar2)
1434                   OR NVL (per_suc_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
1435                                                            NVL (p_rec.attribute2, hr_api.g_varchar2)
1436                   OR NVL (per_suc_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
1437                                                            NVL (p_rec.attribute3, hr_api.g_varchar2)
1438                   OR NVL (per_suc_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
1439                                                            NVL (p_rec.attribute4, hr_api.g_varchar2)
1440                   OR NVL (per_suc_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
1441                                                            NVL (p_rec.attribute5, hr_api.g_varchar2)
1442                   OR NVL (per_suc_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
1443                                                            NVL (p_rec.attribute6, hr_api.g_varchar2)
1444                   OR NVL (per_suc_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
1445                                                            NVL (p_rec.attribute7, hr_api.g_varchar2)
1446                   OR NVL (per_suc_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
1447                                                            NVL (p_rec.attribute8, hr_api.g_varchar2)
1448                   OR NVL (per_suc_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
1449                                                            NVL (p_rec.attribute9, hr_api.g_varchar2)
1450                   OR NVL (per_suc_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
1451                                                           NVL (p_rec.attribute10, hr_api.g_varchar2)
1452                   OR NVL (per_suc_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
1453                                                           NVL (p_rec.attribute11, hr_api.g_varchar2)
1454                   OR NVL (per_suc_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
1455                                                           NVL (p_rec.attribute12, hr_api.g_varchar2)
1456                   OR NVL (per_suc_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
1457                                                           NVL (p_rec.attribute13, hr_api.g_varchar2)
1458                   OR NVL (per_suc_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
1459                                                           NVL (p_rec.attribute14, hr_api.g_varchar2)
1460                   OR NVL (per_suc_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
1461                                                           NVL (p_rec.attribute15, hr_api.g_varchar2)
1462                   OR NVL (per_suc_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
1463                                                           NVL (p_rec.attribute16, hr_api.g_varchar2)
1464                   OR NVL (per_suc_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
1465                                                           NVL (p_rec.attribute17, hr_api.g_varchar2)
1466                   OR NVL (per_suc_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
1467                                                           NVL (p_rec.attribute18, hr_api.g_varchar2)
1468                   OR NVL (per_suc_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
1469                                                           NVL (p_rec.attribute19, hr_api.g_varchar2)
1470                   OR NVL (per_suc_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
1471                                                           NVL (p_rec.attribute20, hr_api.g_varchar2)
1472                  )
1473             )
1474          OR (p_rec.succession_plan_id IS NULL)
1475       THEN
1476          --
1477          -- Only execute the validation if absolutely necessary:
1478          -- a) During update, the structure column value or any
1479          --    of the attribute values have actually changed.
1480          -- b) During insert.
1481          --
1482          hr_dflex_utility.ins_or_upd_descflex_attribs
1483                                                  (p_appl_short_name         => 'PER',
1484                                                   p_descflex_name           => 'PER_SUCCESSION_PLANNING',
1485                                                   p_attribute_category      => p_rec.attribute_category,
1486                                                   p_attribute1_name         => 'ATTRIBUTE1',
1487                                                   p_attribute1_value        => p_rec.attribute1,
1488                                                   p_attribute2_name         => 'ATTRIBUTE2',
1489                                                   p_attribute2_value        => p_rec.attribute2,
1490                                                   p_attribute3_name         => 'ATTRIBUTE3',
1491                                                   p_attribute3_value        => p_rec.attribute3,
1492                                                   p_attribute4_name         => 'ATTRIBUTE4',
1493                                                   p_attribute4_value        => p_rec.attribute4,
1494                                                   p_attribute5_name         => 'ATTRIBUTE5',
1495                                                   p_attribute5_value        => p_rec.attribute5,
1496                                                   p_attribute6_name         => 'ATTRIBUTE6',
1497                                                   p_attribute6_value        => p_rec.attribute6,
1498                                                   p_attribute7_name         => 'ATTRIBUTE7',
1499                                                   p_attribute7_value        => p_rec.attribute7,
1500                                                   p_attribute8_name         => 'ATTRIBUTE8',
1501                                                   p_attribute8_value        => p_rec.attribute8,
1502                                                   p_attribute9_name         => 'ATTRIBUTE9',
1503                                                   p_attribute9_value        => p_rec.attribute9,
1504                                                   p_attribute10_name        => 'ATTRIBUTE10',
1505                                                   p_attribute10_value       => p_rec.attribute10,
1506                                                   p_attribute11_name        => 'ATTRIBUTE11',
1507                                                   p_attribute11_value       => p_rec.attribute11,
1508                                                   p_attribute12_name        => 'ATTRIBUTE12',
1509                                                   p_attribute12_value       => p_rec.attribute12,
1510                                                   p_attribute13_name        => 'ATTRIBUTE13',
1511                                                   p_attribute13_value       => p_rec.attribute13,
1512                                                   p_attribute14_name        => 'ATTRIBUTE14',
1513                                                   p_attribute14_value       => p_rec.attribute14,
1514                                                   p_attribute15_name        => 'ATTRIBUTE15',
1515                                                   p_attribute15_value       => p_rec.attribute15,
1516                                                   p_attribute16_name        => 'ATTRIBUTE16',
1517                                                   p_attribute16_value       => p_rec.attribute16,
1518                                                   p_attribute17_name        => 'ATTRIBUTE17',
1519                                                   p_attribute17_value       => p_rec.attribute17,
1520                                                   p_attribute18_name        => 'ATTRIBUTE18',
1521                                                   p_attribute18_value       => p_rec.attribute18,
1522                                                   p_attribute19_name        => 'ATTRIBUTE19',
1523                                                   p_attribute19_value       => p_rec.attribute19,
1524                                                   p_attribute20_name        => 'ATTRIBUTE20',
1525                                                   p_attribute20_value       => p_rec.attribute20
1526                                                  );
1527       END IF;
1528 
1529       --
1530       hr_utility.set_location (' Leaving:' || l_proc, 20);
1531    END chk_df;
1532 
1533 --
1534 -- ----------------------------------------------------------------------------
1535 -- |---------------------------< insert_validate >----------------------------|
1536 -- ----------------------------------------------------------------------------
1537    PROCEDURE insert_validate (p_rec IN per_suc_shd.g_rec_type, p_effective_date IN DATE)
1538    IS
1539 --
1540       l_proc   VARCHAR2 (72) := g_package || 'insert_validate';
1541 --
1542    BEGIN
1543       hr_utility.set_location ('Entering:' || l_proc, 5);
1544       --
1545       hr_api.validate_bus_grp_id (p_rec.business_group_id);                     -- Validate Bus Grp
1546 --
1547 -- Call all supporting business operations
1548 --
1549 -- Business Rule Mapping
1550 -- =====================
1551 -- CHK_SUCCESSION_PLANN_ID
1552 --
1553       chk_succession_plan_id (p_rec.succession_plan_id, p_rec.object_version_number);
1554 --
1555 -- Business Rule Mapping
1556 -- =====================
1557 -- CHK_PERSON_ID
1558 --
1559       chk_successor (p_effective_date,
1560                      p_rec.succession_plan_id,
1561                      p_rec.person_id,
1562                      p_rec.job_id,
1563                      p_rec.position_id,
1564                      p_rec.person_rank,
1565                      p_rec.successee_person_id,
1566                      p_rec.object_version_number,
1567                      p_rec.start_date
1568                     );
1569 --
1570 -- Business Rule Mapping
1571 -- =====================
1572 -- CHK_SUCCESSEE
1573 --
1574       chk_successee (p_effective_date,
1575                      p_rec.succession_plan_id,
1576                      p_rec.job_id,
1577                      p_rec.position_id,
1578                      p_rec.successee_person_id,
1579                      p_rec.object_version_number
1580                     );
1581 --
1582 -- Business Rule Mapping
1583 -- =====================
1584 -- CHK_TIME_SCALE
1585 --
1586       chk_time_scale (p_rec.succession_plan_id,
1587                       p_rec.time_scale,
1588                       p_rec.object_version_number,
1589                       p_effective_date
1590                      );
1591 --
1592 -- Business Rule Mapping
1593 -- =====================
1594 -- CHK_START_DATE
1595 --
1596       chk_start_date (p_rec.succession_plan_id, p_rec.start_date, p_rec.object_version_number);
1597 --
1598 -- Business Rule Mapping
1599 -- =====================
1600 -- CHK_END_DATE
1601 --
1602       chk_end_date (p_rec.succession_plan_id,
1603                     p_rec.start_date,
1604                     p_rec.end_date,
1605                     p_rec.object_version_number
1606                    );
1607 --
1608 -- Business Rule Mapping
1609 -- =====================
1610 -- CHK_AVAILABLE_FOR_PROMOTION
1611 --
1612       chk_available_for_promotion (p_rec.succession_plan_id,
1613                                    p_rec.available_for_promotion,
1614                                    p_rec.object_version_number,
1615                                    p_effective_date
1616                                   );
1617 --
1618 -- Business Rule Mapping
1619 -- =====================
1620 -- CHK_PLAN_STATUS
1621 --
1622       chk_plan_status (p_rec.succession_plan_id,
1623                        p_rec.plan_status,
1624                        p_rec.object_version_number,
1625                        p_effective_date
1626                       );
1627 --
1628 -- Business Rule Mapping
1629 -- =====================
1630 -- CHK_READINESS_PERCENTAGE
1631 --
1632       chk_readiness_percentage(p_rec.succession_plan_id,
1633                                p_rec.readiness_percentage,
1634                                p_rec.object_version_number
1635                               );
1636 --
1637 -- Business Rule Mapping
1638 -- =====================
1639 -- CHK_PERSON_START_DATE
1640 --
1641 -- Bug#3207986
1642       chk_person_start_date (p_rec.person_id, p_rec.start_date);
1643 --
1644 -- Business Rule Mapping
1645 -- =====================
1646 -- CHK_DATE
1647 --
1648       chk_date (p_rec.succession_plan_id,
1649                 p_rec.position_id,
1650                 p_rec.person_id,
1651                 p_rec.start_date,
1652                 p_rec.end_date,
1653                 p_rec.object_version_number,
1654                 p_rec.job_id,
1655                 p_rec.successee_person_id
1656                );
1657   --
1658   -- Descriptive flex check
1659   -- ======================
1660   --
1661 /*
1662   IF hr_general.get_calling_context <>'FORMS' THEN
1663     per_suc_flex.df(p_rec => p_rec);
1664   END IF;
1665 */
1666   --
1667   -- call descriptive flexfield validation routines
1668   --
1669       per_suc_bus.chk_df (p_rec => p_rec);
1670       --
1671       hr_utility.set_location (' Leaving:' || l_proc, 10);
1672    END insert_validate;
1673 
1674 --
1675 -- ----------------------------------------------------------------------------
1676 -- |---------------------------< update_validate >----------------------------|
1677 -- ----------------------------------------------------------------------------
1678    PROCEDURE update_validate (p_rec IN per_suc_shd.g_rec_type, p_effective_date IN DATE)
1679    IS
1680 --
1681       l_proc   VARCHAR2 (72) := g_package || 'update_validate';
1682 --
1683    BEGIN
1684       hr_utility.set_location ('Entering:' || l_proc, 5);
1685       --
1686       hr_api.validate_bus_grp_id (p_rec.business_group_id);                     -- Validate Bus Grp
1687 --
1688 -- Call all supporting business operations
1689 --
1690 -- Business Rule Mapping
1691 -- =====================
1692 -- CHK_SUCCESSION_PLANN_ID
1693 --
1694       chk_succession_plan_id (p_rec.succession_plan_id, p_rec.object_version_number);
1695 --
1696 -- Business Rule Mapping
1697 -- =====================
1698 -- CHK_PERSON_ID
1699 --
1700       chk_successor (p_effective_date,
1701                      p_rec.succession_plan_id,
1702                      p_rec.person_id,
1703                      p_rec.job_id,
1704                      p_rec.position_id,
1705                      p_rec.person_rank,
1706                      p_rec.successee_person_id,
1707                      p_rec.object_version_number,
1708                      p_rec.start_date
1709                     );
1710 --
1711 -- Business Rule Mapping
1712 -- =====================
1713 -- CHK_SUCCESSEE
1714 --
1715       chk_successee (p_effective_date,
1716                      p_rec.succession_plan_id,
1717                      p_rec.job_id,
1718                      p_rec.position_id,
1719                      p_rec.successee_person_id,
1720                      p_rec.object_version_number
1721                     );
1722 --
1723 --
1724 --
1725 -- Business Rule Mapping
1726 -- =====================
1727 -- CHK_TIME_SCALE
1728 --
1729       chk_time_scale (p_rec.succession_plan_id,
1730                       p_rec.time_scale,
1731                       p_rec.object_version_number,
1732                       p_effective_date
1733                      );
1734 --
1735 -- Business Rule Mapping
1736 -- =====================
1737 -- CHK_START_DATE
1738 --
1739       chk_start_date (p_rec.succession_plan_id, p_rec.start_date, p_rec.object_version_number);
1740 --
1741 -- Business Rule Mapping
1742 -- =====================
1743 -- CHK_END_DATE
1744 --
1745       chk_end_date (p_rec.succession_plan_id,
1746                     p_rec.start_date,
1747                     p_rec.end_date,
1748                     p_rec.object_version_number
1749                    );
1750 --
1751 -- Business Rule Mapping
1752 -- =====================
1753 -- CHK_AVAILABLE_FOR_PROMOTION
1754 --
1755       chk_available_for_promotion (p_rec.succession_plan_id,
1756                                    p_rec.available_for_promotion,
1757                                    p_rec.object_version_number,
1758                                    p_effective_date
1759                                   );
1760 --
1761 -- Business Rule Mapping
1762 -- =====================
1763 -- CHK_PLAN_STATUS
1764 --
1765       chk_plan_status (p_rec.succession_plan_id,
1766                        p_rec.plan_status,
1767                        p_rec.object_version_number,
1768                        p_effective_date
1769                       );
1770 --
1771 -- Business Rule Mapping
1772 -- =====================
1773 -- CHK_READINESS_PERCENTAGE
1774 --
1775       chk_readiness_percentage(p_rec.succession_plan_id,
1776                                p_rec.readiness_percentage,
1777                                p_rec.object_version_number
1778                               );
1779 --
1780 -- Business Rule Mapping
1781 -- =====================
1782 -- CHK_PERSON_START_DATE
1783 --
1784 -- Bug#3207986
1785       chk_person_start_date (p_rec.person_id, p_rec.start_date);
1786 --
1787 -- Business Rule Mapping
1788 -- =====================
1789 -- CHK_DATE
1790 --
1791       chk_date (p_rec.succession_plan_id,
1792                 p_rec.position_id,
1793                 p_rec.person_id,
1794                 p_rec.start_date,
1795                 p_rec.end_date,
1796                 p_rec.object_version_number,
1797                 p_rec.job_id,
1798                 p_rec.successee_person_id
1799                );
1800   --
1801   -- Descriptive flex check
1802   -- ======================
1803   --
1804 /*
1805   IF hr_general.get_calling_context <>'FORMS' THEN
1806     per_suc_flex.df(p_rec => p_rec);
1807   END IF;
1808 */
1809   --
1810   -- call descriptive flexfield validation routines
1811   --
1812       per_suc_bus.chk_df (p_rec => p_rec);
1813       --
1814       hr_utility.set_location (' Leaving:' || l_proc, 10);
1815    END update_validate;
1816 
1817 --
1818 -- ----------------------------------------------------------------------------
1819 -- |---------------------------< delete_validate >----------------------------|
1820 -- ----------------------------------------------------------------------------
1821    PROCEDURE delete_validate (p_rec IN per_suc_shd.g_rec_type)
1822    IS
1823 --
1824       l_proc   VARCHAR2 (72) := g_package || 'delete_validate';
1825 --
1826    BEGIN
1827       hr_utility.set_location ('Entering:' || l_proc, 5);
1828       --
1829       -- Call all supporting business operations
1830       --
1831       hr_utility.set_location (' Leaving:' || l_proc, 10);
1832    END delete_validate;
1833 --
1834 END per_suc_bus;