DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PSF_BUS

Source


1 PACKAGE BODY HR_PSF_BUS as
2 /* $Header: hrpsfrhi.pkb 120.5.12000000.2 2007/02/06 06:59:04 ande ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_psf_bus.';  -- Global package name
9 --
10 --
11 --
12 --  ---------------------------------------------------------------------------
13 --  |----------------------<  set_security_group_id  >------------------------|
14 --  ---------------------------------------------------------------------------
15 --
16 --
17   procedure set_security_group_id
18    (
19     p_position_id                in hr_positions.position_id%TYPE
20    ) is
21   --
22   -- Declare cursor
23   --
24      cursor csr_sec_grp is
25        select inf.org_information14
26       from hr_organization_information inf
27          , hr_all_positions_f  pos
28      where pos.position_id = p_position_id
29        and inf.organization_id = pos.business_group_id
30        and inf.org_information_context || '' = 'Business Group Information';
31   --
32   -- Local variables
33   --
34   l_security_group_id number;
35   l_proc              varchar2(72) ;
36   --
37   begin
38 g_debug := hr_utility.debug_enabled;
39 if g_debug then
40     l_proc        := g_package||'set_security_group_id';
41     hr_utility.set_location('Entering:'|| l_proc, 10);
42 end if;
43   --
44   -- Ensure that all the mandatory parameter are not null
45   --
46   hr_api.mandatory_arg_error(p_api_name       => l_proc,
47                              p_argument       => 'position_id',
48                              p_argument_value => p_position_id);
49   --
50   open csr_sec_grp;
51   fetch csr_sec_grp into l_security_group_id;
52   if csr_sec_grp%notfound then
53     close csr_sec_grp;
54     --
55     -- The primary key is invalid therefore we must error
56     --
57     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
58     hr_utility.raise_error;
59   end if;
60   close csr_sec_grp;
61   --
62   -- Set the security_group_id in CLIENT_INFO
63   --
64   hr_api.set_security_group_id
65     (p_security_group_id => l_security_group_id
66     );
67   --
68 if g_debug then
69   hr_utility.set_location(' Leaving:'|| l_proc, 20);
70 end if;
71   --
72 end set_security_group_id;
73 --
74 --
75 --  ----------------------------------------------------------------------------
76 --  |--------------------------<  get_validation_date  >--------------------|
77 --  ----------------------------------------------------------------------------
78 --
79 --  Desciption :
80 --
81 --  Validates that the position NAME is unique within position's BUSINESS GROUP
82 --
83 --  Pre-conditions :
84 --
85 --  In Arguments :
86 --    p_date_effective
87 --    p_validation_Start_Date
88 --    p_validation_date
89 --
90 --  Post Success :
91 --
92 --  Post Failure :
93 --
94 --  Access Status :
95 --    Internal Table Handler Use only.
96 --
97 -- {End of Comments}
98 --
99 -- ---------------------------------------------------------------------------
100 --
101 Procedure get_validation_date(
102       p_date_effective        in  date
103      ,p_validation_start_date in  date
104      ,p_validation_date       out nocopy date
105 ) is
106 l_proc varchar2(30);
107 
108 Begin
109 if g_debug then
110 l_proc :='get_validation_date';
111   hr_utility.set_location('Entering:'||l_proc, 1);
112 end if;
113   --
114   --   Check mandatory parameters have been set
115   --
116   hr_api.mandatory_arg_error
117     (p_api_name                 => l_proc
118     ,p_argument                 => 'date_effective'
119     ,p_argument_value           => p_date_effective
120     );
121   --
122 if g_debug then
123   hr_utility.set_location(l_proc, 10);
124 end if;
125   --
126   hr_api.mandatory_arg_error
127     (p_api_name                 => l_proc
128     ,p_argument                 => 'validation_start_date'
129     ,p_argument_value           => p_validation_start_date
130     );
131   --
132 if g_debug then
133   hr_utility.set_location(l_proc, 20);
134 end if;
135   --
136   -- If this is the first row then date_effective must be used for validation
137   -- as this is the date a position becomes effective
138   -- for changes in any other row, use validation_start_Date.
139   --
140   if p_date_effective < p_validation_start_date then
141 if g_debug then
142     hr_utility.set_location(l_proc, 30);
143 end if;
144     p_validation_Date := p_validation_start_Date;
145   else
146 if g_debug then
147     hr_utility.set_location(l_proc, 40);
148 end if;
149     p_validation_date := p_date_effective;
150   end if;
151   --
152 if g_debug then
153   hr_utility.set_location(l_proc, 100);
154 end if;
155 --
156 End get_validation_date;
157 --
158 --  ---------------------------------------------------------------------------
159 --  |-----------------------<  chk_end dates >--------------------|
160 --  ---------------------------------------------------------------------------
161 --
162 --  Desciption :
163 --
164 --    Validates that the various end dates compared to the effective date
165 --
166 --  Pre-conditions :
167 --
168 --  In Arguments :
169 --
170 --  Post Success :
171 --
172 --  Post Failure :
173 --
174 --  Access Status :
175 --    Internal Table Handler Use only.
176 --
177 -- {End of Comments}
178 --
179 -- ---------------------------------------------------------------------------
180 --
181 procedure chk_end_dates
182 (
183 position_id                     in number
184 ,availability_status_id         in number
185 ,p_effective_date               in date
186 ,current_org_prop_end_date      in date
187 ,current_job_prop_end_date      in date
188 ,avail_status_prop_end_date     in date
189 ,earliest_hire_date             in date
190 ,fill_by_date                   in date
191 ,proposed_date_for_layoff       in date
192 ,date_effective                 in date)
193 is
194    l_avail_status_start_date  date;
195 begin
196    if current_org_prop_end_date < date_effective then
197       hr_utility.set_message(800,'PER_INVALID_ORG_PROP_END_DATE');
198       hr_utility.raise_error;
199    end if;
200    if current_job_prop_end_date < date_effective then
201       hr_utility.set_message(800,'PER_INVALID_JOB_PROP_END_DATE');
202       hr_utility.raise_error;
203    end if;
204 
205    l_avail_status_start_date := hr_general.DECODE_AVAIL_STATUS_START_DATE (
206                                             position_id
207                                             ,availability_status_id
208                                             ,p_effective_date ) ;
209    if avail_status_prop_end_date < nvl(l_avail_status_start_date,date_effective) then
210       hr_utility.set_message(800,'PER_INVALID_STATUS_PROP_END_DT');
211       hr_utility.raise_error;
212    end if;
213 
214    if earliest_hire_date < date_effective then
215       hr_utility.set_message(800,'PER_INVALID_EARLIEST_HIRE_DATE');
216       hr_utility.raise_error;
217    end if;
218    if fill_by_date < nvl(earliest_hire_date, date_effective) then
219       hr_utility.set_message(800,'PER_INVALID_FILL_BY_DATE');
220       hr_utility.set_message_token('VALID_DATE',nvl(earliest_hire_date, date_effective));
221       hr_utility.raise_error;
222    end if;
223    if proposed_date_for_layoff < date_effective then
224       hr_utility.set_message(800,'PER_INVALID_PROP_DT_FOR_LAYOFF');
225       hr_utility.raise_error;
226    end if;
227 end chk_end_dates;
228 --  ---------------------------------------------------------------------------
229 --  |--------------------------<  chg_date_effective >--------------------|
230 --  ---------------------------------------------------------------------------
231 --
232 --  Desciption :
233 --
234 --  Validates that the date effective is to be changed or not
235 --
236 --  Pre-conditions :
237 --
238 --  In Arguments :
239 --
240 --  Post Success :
241 --
242 --  Post Failure :
243 --
244 --  Access Status :
245 --    Internal Table Handler Use and independent procedure of the package
246 --
247 -- {End of Comments}
248 --
249 -- -------------------------------------------------------------------------
250 --
251 procedure chg_date_effective
252      (p_position_id             in number
253      ,p_effective_start_date    in date
254      ,p_effective_end_date      in date
255      ,p_date_effective          in date
256      ,p_new_date_effective      out nocopy date
257      ,p_chg_date_effective      out nocopy boolean
258      ,p_business_group_id       in number
259      ,p_old_avail_status_id     in number
260      ,p_availability_status_id  in number
261      ,p_datetrack_mode          in varchar2
262       )
263 is
264 -- cursor to check active rows for the position prior to the effective_start_date of their row
265     cursor pos_active_rows(p_position_id number,p_effective_start_date date) is
266        select count(*)
267        from hr_all_positions_f pos, per_shared_types sht
268        where pos.position_id = p_position_id
269        and pos.effective_start_date < p_effective_start_date
270        and hr_psf_shd.get_availability_status(pos.availability_status_id,p_business_group_id) ='ACTIVE';
271 -- cursor to find out the next active row's effective start date
272     cursor next_active_row(p_position_id number,p_effective_start_date date) is
273        select effective_start_date
274        from hr_all_positions_f pos, per_shared_types sht
275        where pos.position_id = p_position_id
276        and pos.effective_start_date > p_effective_start_date
277        and hr_psf_shd.get_availability_status(pos.availability_status_id,p_business_group_id) ='ACTIVE';
278 -- cursor to find the first active row
279     cursor valid_first_active_row(p_position_id number,p_effective_end_date date) is
280        select min(effective_start_date)
281        from hr_all_positions_f pos
282        where effective_start_date > p_effective_end_date + 1
283        and hr_psf_shd.get_availability_status(pos.availability_status_id,p_business_group_id) ='ACTIVE';
284     l_active_rows      number;
285     l_current_row_stat varchar2(30);
286     l_next_active_date date;
287     l_proc             varchar2(72) ;
288     l_effective_date   date;
289     l_date_effective   date;
290 begin
291 
292 g_debug := hr_utility.debug_enabled;
293 if g_debug then
294     l_proc              := g_package||'Chg_date_effective' ;
295    hr_utility.set_location('Entering'||l_proc, 10);
296 end if;
297    p_chg_date_effective := FALSE ;
298 -- call to chk_availability_status_id is made to check wether the status transition is a valid transition or not.
299 -- if it is a valid transition only then control will be coming to the change in date_effective code
300 -- otherwise invalid status change will be displayed
301    chk_availability_status_id(p_position_id            => p_position_id
302                              ,p_business_group_id      => p_business_group_id
303                              ,p_datetrack_mode         => p_datetrack_mode
304                              ,p_validation_start_date  => p_effective_start_date
305                              ,p_availability_status_id => p_availability_status_id
306                              ,p_effective_date         => l_effective_date
307                              ,p_date_effective         => l_date_effective
308                              ,p_old_avail_status_id    => p_old_avail_status_id
309                             );
310    if g_debug then
311    hr_utility.set_location('after chk_avail_stat '||l_proc, 20);
312    end if;
313 -- depending upon the datetrack mode action has to be taken to find out
314 -- the change in date effective
315     if p_datetrack_mode = 'INSERT'
316        or p_datetrack_mode = 'CORRECTION'
317        or p_datetrack_mode = 'UPDATE'
318        or p_datetrack_mode = 'UPDATE_OVERRIDE'
319        or p_datetrack_mode = 'UPDATE_CHANGE_INSERT'
320        then
321 --
322 -- if current row's status is active and there are no active rows
323 -- prior to this row then date effective is to
324 -- be changed to the effective start date of this row.
325 -- no. of active rows in the database for this position prior to
326 -- the effective start date is computed
327 --
328 if g_debug then
329        hr_utility.set_location('inside for action '||p_datetrack_mode||l_proc, 30);
330 end if;
331        open pos_active_rows(p_position_id,p_effective_start_date);
332        fetch pos_active_rows into l_active_rows ;
333        close pos_active_rows ;
334        if l_active_rows = 0 then
335           -- status of the current row is found
336           l_current_row_stat := hr_psf_shd.get_availability_status(p_availability_status_id,p_business_group_id);
337           if l_current_row_stat ='ACTIVE' then
338              -- current row is going to be first active row date effective is to be changed
339              -- to the effective start date of the first active row
340              p_new_date_effective := p_effective_start_date ;
341              p_chg_date_effective := (p_new_date_effective <> p_date_effective);
342           else
343              -- check to find out the effective start date of the first row after current row
344              -- next active row's effective start date is fetched
345              if g_debug then
346              hr_utility.set_location('next row is to be found'||l_proc, 40);
347              end if;
348              open next_active_row(p_position_id,p_effective_start_date);
349              fetch next_active_row into l_next_active_date;
350              if next_active_row%found then
351                 -- there is a active row for this position after the current position
352                 p_new_date_effective := l_next_active_date ;
353                 p_chg_date_effective := (p_new_date_effective <> p_date_effective);
354              end if;
355              close next_active_row;
356           end if;
357        else
358           -- there exists a active row prior to the current row
359           -- date effective is not going to be changed
360           p_chg_date_effective := FALSE ;
361        end if;
362     elsif p_datetrack_mode = 'DELETE_NEXT_CHANGE'  then
363     if g_debug then
364        hr_utility.set_location('inside for action '||p_datetrack_mode||l_proc, 50);
365     end if;
366           if p_date_effective < p_effective_start_date then
367              -- nothing should be done as first active row is not going to be deleted
368              null;
369           else
370              -- status of the current row is found
371              l_current_row_stat := hr_psf_shd.get_availability_status(p_availability_status_id,p_business_group_id);
372              if l_current_row_stat ='ACTIVE' then
373                 -- current row is active row itself, so nothing is to be changed
374                 p_chg_date_effective := FALSE;
375              else
376              if g_debug then
377                 hr_utility.set_location('valid active row searching'||l_proc, 60);
378              end if;
379                 open valid_first_active_row(p_position_id,p_effective_end_date);
380                 fetch valid_first_active_row into l_next_active_date ;
381                 if valid_first_active_row%found then
382                    -- next active row effective start date has been found after deletion of the next row
383                    p_new_date_effective := l_next_active_date ;
384                    p_chg_date_effective := (p_new_date_effective <> p_date_effective);
385                 end if;
386                 close valid_first_active_row ;
387              end if;
388           end if;
389     elsif p_datetrack_mode = 'FUTURE_CHANGE'
390        or p_datetrack_mode = 'ZAP' then  -- 'Purge' as seen on GUI
391           -- nothing is to be done in this case
392           p_chg_date_effective := FALSE ;
393          if g_debug then
394               hr_utility.set_location('inside for action '||p_datetrack_mode||l_proc, 70);
395          end if;
396     end if;
397    hr_utility.set_location('Leaving'||l_proc, 1000);
398 end chg_date_effective ;
399 
400 --  ---------------------------------------------------------------------------
401 --  |-----------------------<  chk_availability_status_id >--------------------|
402 --  ---------------------------------------------------------------------------
403 --
404 --  Desciption :
405 --
406 --    Validates that the availability_status_id exists in PER_SHARED_TYPES
407 --
408 --  Pre-conditions :
409 --
410 --  In Arguments :
411 --
412 --  Post Success :
413 --
414 --  Post Failure :
415 --
416 --  Access Status :
417 --    Internal Table Handler Use only.
418 --
419 -- {End of Comments}
420 --
421 -- ---------------------------------------------------------------------------
422 --
423 procedure chk_availability_status_id
424    (p_position_id            in number
425    ,p_validation_start_date  in date
426    ,p_availability_status_id in number
427    ,p_old_avail_status_id    in number
428    ,p_business_group_id      in number
429    ,p_date_effective         in date default null
430    ,p_effective_date         in date default null
431    ,p_object_version_number  in number default 1
432    ,p_datetrack_mode         in varchar2)
433 is
434    type stat_matrix is record
435         (previous_stat varchar2(30)
436         ,present_stat  varchar2(30)
437         ,future_stat   varchar2(30)) ;
438    TYPE tran_stat IS table of stat_matrix
439              index by binary_integer ;
440    chk_stat  tran_stat;
441    cursor csr_stat(p_position_id number,p_effective_start_date date,p_business_group_id number) is
442       select hr_psf_shd.get_availability_status(pos.availability_status_id,p_business_group_id)
443       from hr_all_positions_f pos
444       where pos.position_id = p_position_id
445       and pos.effective_start_date = p_effective_start_date;
446    cursor csr_prev(p_position_id number, p_effective_start_date date) is
447        select max(effective_start_date)
448        from hr_all_positions_f
449        where position_id = p_position_id
450        and effective_start_date < p_effective_start_date ;
451    cursor csr_future(p_position_id number, p_effective_start_date date) is
452        select min(effective_start_date)
453        from hr_all_positions_f
454        where position_id = p_position_id
455        and effective_start_date > p_effective_start_date ;
456    cursor csr_present(p_position_id number, p_object_version_number number) is
457        select effective_start_date
458        from hr_all_positions_f
459        where position_id = p_position_id
460        and object_version_number = p_object_version_number ;
461    l_present_stat varchar2(30) ;
462    l_prev_stat    varchar2(30);
463    l_future_stat  varchar2(30);
464    l_prev_esd     date ;
465    l_future_esd   date ;
466    l_current_esd  date ;
467    l_proc         varchar2(72) ;
468    l_return       boolean := false ;
469    i              number ;
470    l_count        number ;
471    l_validation_reqd boolean := TRUE ;
472    --
473    procedure set_stat (p_chk_stat     in out nocopy tran_stat
474                     , p_subscript     in     number
475                     , p_prev_stat     in     varchar2
476                     , p_present_stat  in     varchar2
477                     , p_future_stat   in     varchar2) is
478    --
479    begin
480      --
481      p_chk_stat(p_subscript).previous_stat := p_prev_stat ;
482      p_chk_stat(p_subscript).present_stat  := p_present_stat;
483      p_chk_stat(p_subscript).future_stat   := p_future_stat;
484      --
485    end;
486    --
487 begin
488   --
489   g_debug := hr_utility.debug_enabled;
490   --
491   if g_debug then
492     l_proc := g_package||'chk_avail_stat';
493   --
494   end if;
495   --
496   l_present_stat := hr_psf_shd.get_availability_status(p_availability_status_id
497                                                       ,p_business_group_id);
498   --
499   -- populating the status transition matrix
500   --
501       set_stat(chk_stat, 1, NULL, 'PROPOSED', NULL);
502       set_stat(chk_stat, 2, NULL, 'PROPOSED', 'PROPOSED');
503       set_stat(chk_stat, 3, 'PROPOSED', 'PROPOSED', NULL);
504       set_stat(chk_stat, 4, 'PROPOSED', 'PROPOSED', 'PROPOSED');
505       set_stat(chk_stat, 5, 'PROPOSED', 'PROPOSED', 'ACTIVE');
506       set_stat(chk_stat, 6, 'PROPOSED', 'PROPOSED', 'DELETED');
507       set_stat(chk_stat, 7, 'PROPOSED', 'DELETED', 'DELETED');
508       set_stat(chk_stat, 8, 'PROPOSED', 'DELETED', NULL);
509       set_stat(chk_stat, 9, 'PROPOSED', 'ACTIVE', NULL);
510       set_stat(chk_stat, 10, 'DELETED',  'DELETED', 'DELETED');
511       set_stat(chk_stat, 11, 'DELETED',  'DELETED', NULL);
512       set_stat(chk_stat, 12, 'PROPOSED', 'ACTIVE', 'ACTIVE');
513       set_stat(chk_stat, 13, 'ACTIVE', 'ACTIVE', 'ACTIVE');
514       set_stat(chk_stat, 14, 'ACTIVE', 'ACTIVE', NULL);
515       set_stat(chk_stat, 15, NULL, 'ACTIVE', 'ACTIVE');
516       set_stat(chk_stat, 16, NULL, 'ACTIVE', NULL);
517       set_stat(chk_stat, 17, 'ACTIVE', 'ACTIVE', 'FROZEN');
518       set_stat(chk_stat, 18, 'ACTIVE', 'FROZEN', 'FROZEN');
519       set_stat(chk_stat, 19, 'ACTIVE', 'FROZEN', 'ACTIVE');
520       set_stat(chk_stat, 20, 'FROZEN', 'FROZEN', 'FROZEN');
521       set_stat(chk_stat, 21, 'FROZEN', 'FROZEN', 'ACTIVE');
522       set_stat(chk_stat, 22, 'FROZEN', 'ACTIVE', 'ACTIVE');
523       set_stat(chk_stat, 23, 'FROZEN', 'ACTIVE', 'FROZEN');
524       set_stat(chk_stat, 24, 'ACTIVE', 'ACTIVE', 'FROZEN');
525       set_stat(chk_stat, 25, 'ACTIVE', 'FROZEN', 'FROZEN');
526       set_stat(chk_stat, 26, 'ACTIVE', 'ELIMINATED', 'ELIMINATED');
527       set_stat(chk_stat, 27, 'ACTIVE', 'ACTIVE', 'ELIMINATED');
528       set_stat(chk_stat, 28, 'ELIMINATED', 'ELIMINATED', 'ELIMINATED');
529       set_stat(chk_stat, 29, 'FROZEN', 'ELIMINATED', 'ELIMINATED');
530       set_stat(chk_stat, 30, 'FROZEN', 'FROZEN', 'ELIMINATED');
531       set_stat(chk_stat, 31, 'ACTIVE', 'FROZEN', 'ELIMINATED');
532       set_stat(chk_stat, 32, 'FROZEN', 'ACTIVE', 'ELIMINATED');
533       set_stat(chk_stat, 33, 'PROPOSED', 'ACTIVE', 'ELIMINATED');
534       set_stat(chk_stat, 34, 'PROPOSED', 'ACTIVE', 'FROZEN');
535       set_stat(chk_stat, 35, NULL, 'ACTIVE', 'ELIMINATED');
536       set_stat(chk_stat, 36, NULL, 'ACTIVE', 'FROZEN');
537       set_stat(chk_stat, 37, 'ACTIVE', 'FROZEN', NULL);
538       set_stat(chk_stat, 38, 'FROZEN', 'FROZEN', NULL);
539       set_stat(chk_stat, 39, 'ELIMINATED', 'ELIMINATED', NULL);
540       set_stat(chk_stat, 40, 'ACTIVE', 'ELIMINATED', NULL);
541       set_stat(chk_stat, 41, 'FROZEN', 'ELIMINATED', NULL);
542       set_stat(chk_stat, 42, 'FROZEN', 'ACTIVE', NULL);
543       set_stat(chk_stat, 43, NULL, 'PROPOSED', 'ACTIVE');
544       --
545       --set_stat(chk_stat, 44, 'ACTIVE', 'DELETED', NULL); -- Added for bug 2130540
546 
547 --
548 -- status transition matrix is populated depending upon the datetrack mode
549 -- previous and future status will be defined and compared with the matrix
550 -- values.
551     if p_datetrack_mode = 'INSERT' then
552        l_prev_stat := NULL;
553        l_future_stat := NULL ;
554     elsif p_datetrack_mode = 'CORRECTION' then
555        -- old rec value does not matter to us and previous and future
556        -- values are to be fetched from the database
557        open csr_prev(p_position_id,p_validation_start_date) ;
558        fetch csr_prev into l_prev_esd ;
559        close csr_prev ;
560        open csr_future(p_position_id,p_validation_start_date) ;
561        fetch csr_future into l_future_esd ;
562        close csr_future ;
563        -- corresponding to the previous and future records status is fetched
564        -- from the database
565        open csr_stat(p_position_id,l_prev_esd,p_business_group_id) ;
566        fetch csr_stat into l_prev_stat ;
567        close csr_stat ;
568        open csr_stat(p_position_id,l_future_esd,p_business_group_id) ;
569        fetch csr_stat into l_future_stat ;
570        close csr_stat ;
571     elsif p_datetrack_mode = 'UPDATE' or
572           p_datetrack_mode = 'UPDATE_OVERRIDE' then
573        -- old rec values are used for previous status and future stat is
574        -- fetched from the database
575        l_prev_stat := hr_psf_shd.get_availability_status( p_old_avail_status_id,
576                                                           p_business_group_id) ;
577        l_future_stat := NULL ;
578     elsif p_datetrack_mode = 'UPDATE_CHANGE_INSERT' then -- 'INSERT after UPDATE' as seen on GUI
579        -- old rec values are used for previous status and future stat is
580        -- fetched from the database
581        l_prev_stat := hr_psf_shd.get_availability_status( p_old_avail_status_id,
582                                                           p_business_group_id) ;
583 
584        open csr_future(p_position_id,p_validation_start_date) ;
585        fetch csr_future into l_future_esd ;
586        close csr_future ;
587        -- corresponding to the previous and future records status is fetched
588        -- from the database
589        open csr_stat(p_position_id,l_future_esd,p_business_group_id) ;
590        fetch csr_stat into l_future_stat ;
591        close csr_stat ;
592     elsif p_datetrack_mode = 'FUTURE_CHANGE' then -- 'All' as seen on GUI
593        l_validation_reqd := false ;
594     elsif p_datetrack_mode = 'DELETE_NEXT_CHANGE' then  -- 'Next' as seen on GUI
595        -- current row effective start date is used to fetch next rows  as
596        -- validation start date does not have value in this case
597        open csr_present(p_position_id,p_object_version_number) ;
598        fetch csr_present into l_current_esd ;
599        close csr_present ;
600 if g_debug then
601        hr_utility.set_location('current row esd is'||l_current_esd||l_proc,111);
602        hr_utility.set_location('curr, ovn is'||p_object_version_number||l_proc,111);
603 end if;
604 
605        -- old rec value does not matter to us and previous and future
606        -- values are to be fetched from the database
607        open csr_prev(p_position_id,l_current_esd) ;
608        fetch csr_prev into l_prev_esd ;
609        close csr_prev ;
610 
611        -- as next row is getting deleted we have to find out the status of the
612        -- next to next row. That's why there are two calls.
613        open csr_future(p_position_id,l_current_esd) ;
614        fetch csr_future into l_future_esd ;
615        close csr_future ;
616 if g_debug then
617        hr_utility.set_location('deleted row esd is'||l_future_esd||l_proc,111);
618 end if;
619        open csr_future(p_position_id,l_future_esd) ;
620        fetch csr_future into l_future_esd ;
621        close csr_future ;
622 if g_debug then
623        hr_utility.set_location('next row esd is'||l_future_esd||l_proc,111);
624 end if;
625 
626        -- corresponding to the previous and future records status is fetched
627        -- from the database
628        open csr_stat(p_position_id,l_prev_esd,p_business_group_id) ;
629        fetch csr_stat into l_prev_stat ;
630        close csr_stat ;
631        open csr_stat(p_position_id,l_future_esd,p_business_group_id) ;
632        fetch csr_stat into l_future_stat ;
633        close csr_stat ;
634 if g_debug then
635        hr_utility.set_location('next row stat is'||l_future_stat||l_proc,111);
636 end if;
637     elsif p_datetrack_mode = 'ZAP' then  -- 'Purge' as seen on GUI
638        l_validation_reqd := false ;
639     end if;
640 if g_debug then
641     hr_utility.set_location(nvl(l_prev_stat,'NULL')||nvl(l_present_stat,'NULL')||nvl(l_future_stat,'NULL'),100);
642     hr_utility.set_location(p_datetrack_mode||l_proc ,100);
643 end if;
644     if l_validation_reqd = true then
645        l_count := chk_stat.count ;
646        i := 1 ;
647        loop
648          if nvl(chk_stat(i).previous_stat,'ZZZZ') = nvl(l_prev_stat,'ZZZZ')
649            and nvl(chk_stat(i).present_stat,'ZZZZ') = nvl(l_present_stat,'ZZZZ')
650            and nvl(chk_stat(i).future_stat,'ZZZZ') = nvl(l_future_stat,'ZZZZ')
651          then
652            l_return := true ;
653            exit ;
654          else
655            i := i + 1;
656          end if;
657          if i > l_count then
658             exit ;
659          end if;
660        end loop;
661        if l_return <> true then
662           hr_utility.set_message(800,'HR_NOT_VALID_STATUS_CHANGE');
663           hr_utility.raise_error;
664        end if;
665    end if;
666 /*
667 -- code to stop change in availability status to active (Row is going to first active row )
668 -- when date_effective is not equal to effective date
669    if l_present_stat = 'ACTIVE' then
670       if l_prev_stat in ('NULL','PROPOSED') then
671          if p_effective_date <> p_date_effective then
672             -- raise the error
673             hr_utility.set_message(800,'PER_STAT_ACTIVE_DE_ED_ONLY');
674             hr_utility.raise_error;
675          end if;
676       end if;
677    end if;
678 */
679 end chk_availability_status_id;
680 --
681 
682 --  ---------------------------------------------------------------------------
683 --  |-------------------< chk_entry_step_id >-----------------------|
684 --  ---------------------------------------------------------------------------
685 --
686 procedure chk_entry_step_id
687   (p_position_id              in hr_all_positions_f.position_id%TYPE
688   ,p_entry_step_id            in hr_all_positions_f.entry_step_id%TYPE
689   ,p_entry_grade_id           in hr_all_positions_f.entry_grade_id%TYPE
690   ,p_business_group_id        in hr_all_positions_f.business_group_id%TYPE
691   ,p_validation_start_date    in hr_all_positions_f.effective_start_date%TYPE
692   ,p_validation_end_date      in hr_all_positions_f.effective_end_date%TYPE
693   ,p_effective_date           in date
694   ,p_object_version_number    in hr_all_positions_f.object_version_number%TYPE
695   )
696   is
697 --
698    l_sequence           per_spinal_point_steps_f.sequence%TYPE;
699    l_exists            varchar2(1);
700    l_api_updating      boolean;
701    l_business_group_id number(15);
702    l_proc              varchar2(72) ;
703 --
704    cursor csr_valid_step is
705    select  business_group_id
706      from  per_spinal_point_steps_f psps
707      where psps.step_id               = p_entry_step_id
708        and p_validation_start_date between psps.effective_start_date and psps.effective_end_date;
709 --
710    cursor csr_valid_step_grade is
711      select   psps.sequence
712      from     per_grade_spines_f pgs,
713               per_spinal_point_steps_f psps
714      where    psps.step_id       = p_entry_step_id
715        and    pgs.grade_id       = p_entry_grade_id
716        and    pgs.grade_spine_id = psps.grade_spine_id
717        and    p_effective_date between pgs.effective_start_date
718                                    and pgs.effective_end_date
719        and    p_effective_date between psps.effective_start_date
720                                    and psps.effective_end_date;
721 --
722 begin
723 if g_debug then
724   l_proc  := g_package||'chk_entry_step_id';
725   hr_utility.set_location('Entering:'|| l_proc, 10);
726 end if;
727   --
728   -- Check mandatory parameters have been set
729   --
730   hr_api.mandatory_arg_error
731     (p_api_name       => l_proc
732     ,p_argument       => 'validation_start_date'
733     ,p_argument_value => p_validation_start_date
734     );
735   --
736   hr_api.mandatory_arg_error
737     (p_api_name       => l_proc
738     ,p_argument       => 'validation_end_date'
739     ,p_argument_value => p_validation_end_date
740     );
741   --
742   hr_api.mandatory_arg_error
743     (p_api_name       => l_proc
744     ,p_argument       => 'effective_date'
745     ,p_argument_value => p_effective_date
746     );
747   --
748   hr_api.mandatory_arg_error
749     (p_api_name       => l_proc
750     ,p_argument       => 'business_group_id'
751     ,p_argument_value => p_business_group_id
752     );
753   if g_debug then
754             hr_utility.set_location(l_proc, 20);
755   end if;
756   --
757   -- Only proceed with validation if :
758   -- a) The current g_old_rec is current and
759   -- b) The value for special ceiling step has changed
760   --
761   l_api_updating := hr_psf_shd.api_updating
762         (p_position_id          => p_position_id
763         ,p_effective_date         => p_effective_date
764         ,p_object_version_number  => p_object_version_number
765         );
766 if g_debug then
767   hr_utility.set_location(l_proc, 30);
768 end if;
769   --
770   if ((l_api_updating and
771        nvl(hr_psf_shd.g_old_rec.entry_step_id, hr_api.g_number) <>
772        nvl(p_entry_step_id, hr_api.g_number)) or
773       (NOT l_api_updating)) then
774 if g_debug then
775     hr_utility.set_location(l_proc, 40);
776 end if;
777     --
778     if p_entry_step_id is not null then
779     if g_debug then
780       hr_utility.set_location(l_proc, 50);
781     end if;
782       --
783       -- Check that entry_step_id exists and is date effective
784       -- per_grade_spines_f
785       --
786       open csr_valid_step;
787       fetch csr_valid_step into l_business_group_id;
788       if csr_valid_step%notfound then
789         close csr_valid_step;
790         hr_utility.set_message(800, 'HR_ENTRY_STEP_ID_NF');
791         hr_utility.raise_error;
792         --
793       end if;
794       close csr_valid_step;
795       if g_debug then
796         hr_utility.set_location(l_proc, 60);
797       end if;
798       --
799       -- Check that the business group of the entry_step_id on
800       -- per_grade_spines is the same as that of the position.
801       --
802       if l_business_group_id <> p_business_group_id then
803        hr_utility.set_message(800, 'HR_PSF_INV_BG_FOR_ENTRY_STEP');
804         hr_utility.raise_error;
805       end if;
806       if g_debug then
807                 hr_utility.set_location(l_proc, 70);
808       end if;
809       --
810       -- Check that the entry_step_id is valid for the grade
811       -- if p_grade is not null.
812       --
813       if p_entry_grade_id is not null then
814         open csr_valid_step_grade;
815         fetch csr_valid_step_grade into l_sequence;
816         if csr_valid_step_grade%notfound then
817           close csr_valid_step_grade;
818           hr_utility.set_message(800, 'HR_PSF_STEP_INV_FOR_GRADE');
819           hr_utility.raise_error;
820         end if;
821         close csr_valid_step_grade;
822         if g_debug then
823           hr_utility.set_location(l_proc, 80);
824         end if;
825       else
826         --
827         -- If the value for step is not null
828         -- then grade id must also be not null
829         --
830         hr_utility.set_message(800, 'HR_PSF_GRADE_REQUIRED');
831         hr_utility.raise_error;
832       end if;
833       if g_debug then
834       hr_utility.set_location(l_proc, 90);
835       end if;
836       --
837     end if;
838     if g_debug then
839     hr_utility.set_location(l_proc, 130);
840     end if;
841     --
842   end if;
843   --
844   hr_utility.set_location(' Leaving:'|| l_proc, 140);
845 end chk_entry_step_id;
846 --
847 --
848 --
849 --  ---------------------------------------------------------------------------
850 --  |---------------------------< chk_entry_grade_id >------------------------------|
851 --  ---------------------------------------------------------------------------
852 --
853 procedure chk_entry_grade_id
854   (p_position_id              in     hr_all_positions_f.position_id%TYPE
855   ,p_business_group_id        in     hr_all_positions_f.business_group_id%TYPE
856   ,p_entry_grade_id           in     hr_all_positions_f.entry_grade_id%TYPE
857   ,p_effective_date           in     date
858   ,p_validation_start_date    in     hr_all_positions_f.effective_start_date%TYPE
859   ,p_validation_end_date      in     hr_all_positions_f.effective_end_date%TYPE
860   ,p_object_version_number    in     hr_all_positions_f.object_version_number%TYPE
861   )
862   is
863 --
864   l_exists             varchar2(1);
865   l_api_updating       boolean;
866   l_business_group_id  number(15);
867   l_proc               varchar2(72);
868   l_vac_grade_id       hr_all_positions_f.entry_grade_id%TYPE;
869   --
870   cursor csr_valid_grade is
871     select   business_group_id
872     from     per_grades
873     where    grade_id = p_entry_grade_id
874     and      p_validation_start_date
875       between date_from and nvl(date_to, hr_api.g_eot);
876   --
877 begin
878 if g_debug then
879  l_proc  :=    g_package||'chk_entry_grade_id';
880   hr_utility.set_location('Entering:'|| l_proc, 10);
881 end if;
882 
883   --
884   -- Check mandatory parameters have been set
885   --
886   hr_api.mandatory_arg_error
887     (p_api_name       => l_proc
888     ,p_argument       => 'effective_date'
889     ,p_argument_value => p_effective_date
890     );
891   --
892   hr_api.mandatory_arg_error
893     (p_api_name       => l_proc
894     ,p_argument       => 'validation_start_date'
895     ,p_argument_value => p_validation_start_date
896     );
897   --
898   hr_api.mandatory_arg_error
899     (p_api_name       => l_proc
900     ,p_argument       => 'validation_end_date'
901     ,p_argument_value => p_validation_end_date
902     );
903   --
904   hr_api.mandatory_arg_error
905     (p_api_name       => l_proc
906     ,p_argument       => 'business_group_id'
907     ,p_argument_value => p_business_group_id
908     );
909   if g_debug then
910   hr_utility.set_location(l_proc, 20);
911  end if;
912   --
913   -- Only proceed with validation if :
914   -- a) The current  g_old_rec is current and
915   -- b) The value for grade has changed
916   --
917   l_api_updating := hr_psf_shd.api_updating
918         (p_position_id            => p_position_id
919         ,p_effective_date         => p_effective_date
920         ,p_object_version_number  => p_object_version_number
921         );
922   if g_debug then
923   hr_utility.set_location(l_proc, 30);
924   end if;
925   --
926   if ((l_api_updating and
927        nvl(hr_psf_shd.g_old_rec.entry_grade_id, hr_api.g_number) <>
928        nvl(p_entry_grade_id, hr_api.g_number)) or
929       (NOT l_api_updating)) then
930    if g_debug then
931    hr_utility.set_location(l_proc, 40);
932    end if;
933    --
934    -- Check if the grade is set.
935    --
936    if p_entry_grade_id is not null then
937      --
938      -- Check that the grade exists between date from and date to in
939      -- PER_GRADES.
940      --
941      open csr_valid_grade;
942      fetch csr_valid_grade into l_business_group_id;
943      if csr_valid_grade%notfound then
944        close csr_valid_grade;
945        hr_utility.set_message(800, 'HR_PSF_INVALID_GRADE');
946        hr_utility.raise_error;
947        --
948      end if;
949      close csr_valid_grade;
950    if g_debug then
951      hr_utility.set_location(l_proc, 50);
952    end if;
953      --
954      -- Check that the business group for the grade is the same
955      -- as that of the position
956      --
957      if l_business_group_id <> p_business_group_id then
958        --
959        hr_utility.set_message(800, 'HR_PSF_INVALID_BG_GRADE');
960        hr_utility.raise_error;
961        --
962      end if;
963      if g_debug then
964      hr_utility.set_location(l_proc, 60);
965      end if;
966      --
967    end if;
968    if g_debug then
969    hr_utility.set_location(l_proc, 80);
970    end if;
971    --
972   end if;
973   if g_debug then
974   hr_utility.set_location(' Leaving:'|| l_proc, 110);
975   end if;
976   --
977 end chk_entry_grade_id;
978 --
979 --  ---------------------------------------------------------------------------
980 --  |---------------------------< chk_entry_grade_rule_id >------------------------------|
981 --  ---------------------------------------------------------------------------
982 --
983 procedure chk_entry_grade_rule_id
984   (p_position_id              in     hr_all_positions_f.position_id%TYPE
985   ,p_business_group_id        in     hr_all_positions_f.business_group_id%TYPE
986   ,p_entry_grade_rule_id           in     hr_all_positions_f.entry_grade_rule_id%TYPE
987   ,p_effective_date           in     date
988   ,p_validation_start_date    in     hr_all_positions_f.effective_start_date%TYPE
989   ,p_validation_end_date      in     hr_all_positions_f.effective_end_date%TYPE
990   ,p_object_version_number    in     hr_all_positions_f.object_version_number%TYPE
991   )
992   is
993 --
994   l_exists             varchar2(1);
995   l_api_updating       boolean;
996   l_business_group_id  number(15);
997   l_proc               varchar2(72) ;
998   l_entry_grade_rule_id       hr_all_positions_f.entry_grade_rule_id%TYPE;
999   --
1000   cursor csr_valid_grade_rule is
1001     select   business_group_id
1002     from     pay_grade_rules_f
1003     where    grade_rule_id = p_entry_grade_rule_id
1004     and      p_validation_start_date
1005       between effective_start_date and effective_end_date;
1006   --
1007 begin
1008 if g_debug then
1009  l_proc  :=  g_package||'chk_entry_grade_rule_id';
1010   hr_utility.set_location('Entering:'|| l_proc, 10);
1011 end if;
1012 
1013   --
1014   -- Check mandatory parameters have been set
1015   --
1016   hr_api.mandatory_arg_error
1017     (p_api_name       => l_proc
1018     ,p_argument       => 'effective_date'
1019     ,p_argument_value => p_effective_date
1020     );
1021   --
1022   hr_api.mandatory_arg_error
1023     (p_api_name       => l_proc
1024     ,p_argument       => 'validation_start_date'
1025     ,p_argument_value => p_validation_start_date
1026     );
1027   --
1028   hr_api.mandatory_arg_error
1029     (p_api_name       => l_proc
1030     ,p_argument       => 'validation_end_date'
1031     ,p_argument_value => p_validation_end_date
1032     );
1033   --
1034   hr_api.mandatory_arg_error
1035     (p_api_name       => l_proc
1036     ,p_argument       => 'business_group_id'
1037     ,p_argument_value => p_business_group_id
1038     );
1039     if g_debug then
1040   hr_utility.set_location(l_proc, 20);
1041   end if;
1042   --
1043   -- Only proceed with validation if :
1044   -- a) The current  g_old_rec is current and
1045   -- b) The value for grade has changed
1046   --
1047   l_api_updating := hr_psf_shd.api_updating
1048         (p_position_id            => p_position_id
1049         ,p_effective_date         => p_effective_date
1050         ,p_object_version_number  => p_object_version_number
1051         );
1052   if g_debug then
1053   hr_utility.set_location(l_proc, 30);
1054   end if;
1055   --
1056   if ((l_api_updating and
1057        nvl(hr_psf_shd.g_old_rec.entry_grade_rule_id, hr_api.g_number) <>
1058        nvl(p_entry_grade_rule_id, hr_api.g_number)) or
1059       (NOT l_api_updating)) then
1060    if g_debug then
1061    hr_utility.set_location(l_proc, 40);
1062    end if;
1063    --
1064    -- Check if the grade is set.
1065    --
1066    if p_entry_grade_rule_id is not null then
1067      --
1068      -- Check that the grade exists between date from and date to in
1069      -- PER_GRADES.
1070      --
1071      open csr_valid_grade_rule;
1072      fetch csr_valid_grade_rule into l_business_group_id;
1073      if csr_valid_grade_rule%notfound then
1074        close csr_valid_grade_rule;
1075        hr_utility.set_message(800, 'HR_PSF_INVALID_GRADE_RULE');
1076        hr_utility.raise_error;
1077        --
1078      end if;
1079      close csr_valid_grade_rule;
1080      if g_debug then
1081      hr_utility.set_location(l_proc, 50);
1082      end if;
1083      --
1084      -- Check that the business group for the grade rule is the same
1085      -- as that of the position
1086      --
1087      if l_business_group_id <> p_business_group_id then
1088        --
1089        hr_utility.set_message(800, 'HR_PSF_INVALID_BG_GRADE_RULE');
1090        hr_utility.raise_error;
1091        --
1092      end if;
1093      hr_utility.set_location(l_proc, 60);
1094      --
1095    end if;
1096    hr_utility.set_location(l_proc, 80);
1097    --
1098   end if;
1099   if g_debug then
1100   hr_utility.set_location(' Leaving:'|| l_proc, 110);
1101   end if;
1102   --
1103 end chk_entry_grade_rule_id;
1104 --
1105 --
1106 --
1107 --  ---------------------------------------------------------------------------
1108 --  |------------------------< chk_pay_freq_payroll_id >-------------------------------|
1109 --  ---------------------------------------------------------------------------
1110 --
1111 procedure chk_pay_freq_payroll_id
1112   (p_position_id           in hr_all_positions_f.position_id%TYPE
1113   ,p_business_group_id     in hr_all_positions_f.business_group_id%TYPE
1114   ,p_pay_freq_payroll_id   in hr_all_positions_f.pay_freq_payroll_id%TYPE
1115   ,p_validation_start_date in hr_all_positions_f.effective_start_date%TYPE
1116   ,p_validation_end_date   in hr_all_positions_f.effective_end_date%TYPE
1117   ,p_effective_date        in date
1118   ,p_datetrack_mode        in varchar2
1119   ,p_object_version_number in hr_all_positions_f.object_version_number%TYPE
1120   )
1121   is
1122   --
1123   l_api_updating                 boolean;
1124   l_cur_opu_effective_start_date date;
1125   l_cur_opu_effective_end_date   date;
1126   l_business_group_id            number(15);
1127   l_exists                       varchar2(1);
1128   l_future_change                boolean;
1129   l_invalid_ppm                  boolean;
1130   l_min_opu_effective_start_date date;
1131   l_min_ppm_effective_start_date date;
1132   l_max_opu_effective_end_date   date;
1133   l_max_ppm_effective_end_date   date;
1134   l_org_payment_method_id
1135                       pay_personal_payment_methods_f.org_payment_method_id%TYPE;
1136   l_org_pay_method_usage_id
1137                        pay_org_pay_method_usages_f.org_pay_method_usage_id%TYPE;
1138   l_personal_payment_method_id
1139                  pay_personal_payment_methods_f.personal_payment_method_id%TYPE;
1140   l_proc                         varchar2(72);
1141   l_working_start_date           date;
1142   l_working_end_date             date;
1143   --
1144   cursor csr_payroll_exists is
1145     select business_group_id
1146     from pay_payrolls_f pp
1147     where pp.payroll_id = p_pay_freq_payroll_id and
1148           p_validation_start_date between pp.effective_start_date and pp.effective_end_date ;
1149 --
1150 begin
1151 if g_debug then
1152 l_proc  :=  g_package||'chk_pay_freq_payroll_id';
1153   hr_utility.set_location('Entering:'|| l_proc, 10);
1154 end if;
1155   --
1156   -- Check mandatory parameters have been set
1157   --
1158   hr_api.mandatory_arg_error
1159     (p_api_name       => l_proc
1160     ,p_argument       => 'business_group_id'
1161     ,p_argument_value => p_business_group_id
1162     );
1163   --
1164   hr_api.mandatory_arg_error
1165     (p_api_name       => l_proc
1166     ,p_argument       => 'validation_start_date'
1167     ,p_argument_value => p_validation_start_date
1168     );
1169   --
1170   hr_api.mandatory_arg_error
1171     (p_api_name       => l_proc
1172     ,p_argument       => 'effective_date'
1173     ,p_argument_value => p_effective_date
1174     );
1175   --
1176   hr_api.mandatory_arg_error
1177     (p_api_name       => l_proc
1178     ,p_argument       => 'validation_end_date'
1179     ,p_argument_value => p_validation_end_date
1180     );
1181 if g_debug then
1182   hr_utility.set_location(l_proc, 20);
1183 end if;
1184   --
1185   l_api_updating := hr_psf_shd.api_updating
1186          (p_position_id          => p_position_id
1187          ,p_effective_date         => p_effective_date
1188          ,p_object_version_number  => p_object_version_number
1189          );
1190 if g_debug then
1191   hr_utility.set_location(l_proc, 30);
1192 end if;
1193   --
1194   if (l_api_updating and
1195        (nvl(hr_psf_shd.g_old_rec.pay_freq_payroll_id, hr_api.g_number)
1196          <> nvl(p_pay_freq_payroll_id, hr_api.g_number))
1197      )
1198     or  NOT l_api_updating
1199   then
1200 if g_debug then
1201     hr_utility.set_location(l_proc, 40);
1202 end if;
1203     --
1204     if p_pay_freq_payroll_id is not null then
1205       --
1206       -- Check that payroll exists and the effective start date of the
1207       -- position is the same as or after the effective start date
1208       -- of the payroll. Also the effective end date of the assignment
1209       -- is the same as or before the effective end date of the payroll.
1210       --
1211       open csr_payroll_exists;
1212       fetch csr_payroll_exists into l_business_group_id;
1213       if csr_payroll_exists%notfound then
1214         close csr_payroll_exists;
1215         hr_utility.set_message(800, 'HR_PSF_PAYROLL_NF');
1216         hr_utility.raise_error;
1217       end if;
1218       close csr_payroll_exists;
1219 if g_debug then
1220       hr_utility.set_location(l_proc, 60);
1221 end if;
1222       --
1223       -- Check that business group of payroll is the
1224       -- same as that of the position
1225       --
1226       if l_business_group_id <> p_business_group_id then
1227         hr_utility.set_message(800, 'HR_PSF_INVALID_BG_PAYROLL');
1228         hr_utility.raise_error;
1229       end if;
1230 if g_debug then
1231       hr_utility.set_location(l_proc, 70);
1232 end if;
1233     end if;
1234   end if;
1235   --
1236 if g_debug then
1237   hr_utility.set_location(' Leaving:'|| l_proc, 300);
1238 end if;
1239 end chk_pay_freq_payroll_id;
1240 --
1241 --  ----------------------------------------------------------------------------
1242 --  |--------------------------<  chk_ccid_unique_for_BG  >--------------------|
1243 --  ----------------------------------------------------------------------------
1244 --
1245 --  PMFLETCH - New uniqueness validation routine
1246 --
1247 --  Desciption :
1248 --
1249 --    Validates that the POSITION_DEFINITION_ID is unique within a
1250 --    position's BUSINESS GROUP
1251 --
1252 --  Pre-conditions :
1253 --
1254 --  In Arguments :
1255 --    p_business_group_id
1256 --    p_position_id
1257 --    p_position_definition_id
1258 --    p_validation_start_date
1259 --    p_validation_end_date
1260 --    p_effective_date
1261 --    p_object_version_number
1262 --
1263 --  Post Success :
1264 --    If the POSITION_DEFINITION_ID in HR_ALL_POSITIONS_F table does not exist
1265 --    for given BUSINESS_GROUP_ID then processing continues
1266 --
1267 --  Post Failure :
1268 --    If the POSITION_DEFINITION_ID does exist in HR_ALL_POSITIONS_F table for given
1269 --    BUSINESS_GROUP_ID, then an application error will be raised and processing
1270 --    terminated
1271 --
1272 --  Access Status :
1273 --    Internal Table Handler Use only.
1274 --
1275 -- {End of Comments}
1276 --
1277 -- ---------------------------------------------------------------------------
1278 --
1279 procedure chk_ccid_unique_for_BG
1280   (p_business_group_id             in      number
1281   ,p_position_id                   in      number
1282   ,p_position_definition_id        in      number
1283   ,p_validation_start_date         in      date
1284   ,p_validation_end_date           in      date
1285   ,p_effective_date                in      date
1286   ,p_object_version_number         in      number
1287   )  is
1288 --
1289    l_api_updating                  boolean;
1290    l_exists                        varchar2(1);
1291    l_proc                          varchar2(72) ;
1292 --
1293   -- Check there are no records in this business group that have the same
1294   -- position definition id within the validation date range - except for
1295   -- the current position
1296    cursor csr_ccid_unique is
1297      select 'x'
1298        from hr_all_positions_f psf
1299       where psf.position_id <> nvl(p_position_id, -1)
1300         and psf.business_group_id = p_business_group_id
1301         and psf.position_definition_id = p_position_definition_id
1302         and psf.effective_start_date <= p_validation_end_date
1303         and psf.effective_end_date   >= p_validation_start_date;
1304 --
1305 begin
1306   if g_debug then
1307      l_proc :=      g_package||'chk_ccid_unique_for_BG';
1308     hr_utility.set_location('Entering:'||l_proc, 10);
1309     hr_utility.set_location('p_business_group_id:'||p_business_group_id, 10);
1310     hr_utility.set_location('p_position_id:'||p_position_id, 10);
1311     hr_utility.set_location('p_position_definition_id:'||p_position_definition_id, 10);
1312     hr_utility.set_location('p_validation_start_date:'||p_validation_start_date, 10);
1313     hr_utility.set_location('p_validation_end_date:'||p_validation_end_date, 10);
1314     hr_utility.set_location('p_effective_date:'||p_effective_date, 10);
1315     hr_utility.set_location('p_object_version_number:'||p_object_version_number, 10);
1316   end if;
1317   --
1318   --   Check mandatory parameters have been set
1319   --
1320   hr_api.mandatory_arg_error
1321     (p_api_name                 => l_proc
1322     ,p_argument                 => 'business_group_id'
1323     ,p_argument_value           => p_business_group_id
1324     );
1325   if g_debug then
1326     hr_utility.set_location(l_proc, 20);
1327   end if;
1328   --
1329   hr_api.mandatory_arg_error
1330     (p_api_name                 => l_proc
1331     ,p_argument                 => 'position_definition_id'
1332     ,p_argument_value           => p_position_definition_id
1333     );
1334   if g_debug then
1335     hr_utility.set_location(l_proc, 30);
1336   end if;
1337   --
1338   hr_api.mandatory_arg_error
1339     (p_api_name                 => l_proc
1340     ,p_argument                 => 'validation_start_date'
1341     ,p_argument_value           => p_validation_start_date
1342     );
1343   if g_debug then
1344     hr_utility.set_location(l_proc, 40);
1345   end if;
1346   --
1347   hr_api.mandatory_arg_error
1348     (p_api_name                 => l_proc
1349     ,p_argument                 => 'validation_end_date'
1350     ,p_argument_value           => p_validation_end_date
1351     );
1352   if g_debug then
1353     hr_utility.set_location(l_proc, 50);
1354   end if;
1355   --
1356   hr_api.mandatory_arg_error
1357     (p_api_name                 => l_proc
1358     ,p_argument                 => 'effective_date'
1359     ,p_argument_value           => p_effective_date
1360     );
1361   if g_debug then
1362     hr_utility.set_location(l_proc, 60);
1363   end if;
1364   --
1365   l_api_updating := hr_psf_shd.api_updating
1366          (p_position_id          => p_position_id
1367          ,p_effective_date         => p_effective_date
1368          ,p_object_version_number  => p_object_version_number
1369          );
1370   if g_debug then
1371     hr_utility.set_location(l_proc, 70);
1372   end if;
1373   --
1374   if (l_api_updating and
1375        (nvl(hr_psf_shd.g_old_rec.position_definition_id, hr_api.g_number)
1376          <> nvl(p_position_definition_id, hr_api.g_number))
1377      )
1378     or  NOT l_api_updating
1379   then
1380     if g_debug then
1381       hr_utility.set_location(l_proc, 80);
1382     end if;
1383     --
1384     --    Check for unique ccid
1385     --
1386     open csr_ccid_unique;
1387     fetch csr_ccid_unique into l_exists;
1388     if csr_ccid_unique%found then
1389       close csr_ccid_unique;
1390       hr_utility.set_message(800,'PAY_7688_USER_POS_TAB_UNIQUE');
1391       hr_utility.raise_error;
1392     else
1393       close csr_ccid_unique;
1394       if g_debug then
1395         hr_utility.set_location(l_proc, 90);
1396       end if;
1397     end if;
1398   --
1399   end if;
1400   --
1401   if g_debug then
1402     hr_utility.set_location(' Leaving:'||l_proc, 100);
1403   end if;
1404 --
1405 end chk_ccid_unique_for_BG;
1406 --
1407 --
1408 --  ----------------------------------------------------------------------------
1409 --  |--------------------------<  chk_name_unique_for_BG  >--------------------|
1410 --  ----------------------------------------------------------------------------
1411 --
1412 --  Desciption :
1413 --
1414 --    Validates that the position NAME is unique within position's BUSINESS GROUP
1415 --
1416 --  Pre-conditions :
1417 --
1418 --  In Arguments :
1419 --    p_business_group_id
1420 --    p_position_id
1421 --    p_name
1422 --    p_effective_date
1423 --
1424 --  Post Success :
1425 --    If the NAME in HR_ALL_POSITIONS table does not exist for given BUSINESS_GROUP_ID
1426 --    then processing continues
1427 --
1428 --  Post Failure :
1429 --    If the NAME does exist in PER_POSITIONS table for given BUSINESS_GROUP_ID,
1430 --    then an application error will be raised and processing terminated
1431 --
1432 --  Access Status :
1433 --    Internal Table Handler Use only.
1434 --
1435 -- {End of Comments}
1436 --
1437 -- ---------------------------------------------------------------------------
1438 --
1439 procedure chk_name_unique_for_BG
1440   (p_business_group_id  in      number
1441   ,p_position_id        in      number
1442   ,p_effective_date     in      date
1443   ,p_name               in      varchar2
1444   ,p_object_version_number in number
1445   )  is
1446 --
1447    l_api_updating                 boolean;
1448    l_exists             varchar2(1);
1449    l_proc               varchar2(72) ;
1450 --
1451    cursor csr_name_unique is
1452       select  'x'
1453         from  hr_all_positions_f psf
1454        where  psf.name = p_name
1455          and  (p_position_id is null or psf.position_id <> p_position_id)
1456          and  psf.business_group_id = p_business_group_id;
1457 --
1458 --
1459 Begin
1460 if g_debug then
1461    l_proc :=      g_package||'chk_name_unique_for_BG';
1462   hr_utility.set_location('Entering:'||l_proc, 1);
1463 end if;
1464   --
1465   --   Check mandatory parameters have been set
1466   --
1467   hr_api.mandatory_arg_error
1468     (p_api_name                 => l_proc
1469     ,p_argument                 => 'business_group_id'
1470     ,p_argument_value           => p_business_group_id
1471     );
1472 if g_debug then
1473   hr_utility.set_location(l_proc, 2);
1474 end if;
1475   --
1476   hr_api.mandatory_arg_error
1477     (p_api_name                 => l_proc
1478     ,p_argument                 => 'name'
1479     ,p_argument_value           => p_name
1480     );
1481 if g_debug then
1482   hr_utility.set_location(l_proc, 3);
1483 end if;
1484   --
1485   hr_api.mandatory_arg_error
1486     (p_api_name                 => l_proc
1487     ,p_argument                 => 'effective_date'
1488     ,p_argument_value           => p_effective_date
1489     );
1490 if g_debug then
1491   hr_utility.set_location(l_proc, 20);
1492 end if;
1493   --
1494   l_api_updating := hr_psf_shd.api_updating
1495          (p_position_id          => p_position_id
1496          ,p_effective_date         => p_effective_date
1497          ,p_object_version_number  => p_object_version_number
1498          );
1499 if g_debug then
1500   hr_utility.set_location(l_proc, 30);
1501 end if;
1502   --
1503   if (l_api_updating and
1504        (nvl(hr_psf_shd.g_old_rec.name, hr_api.g_varchar2)
1505          <> nvl(p_name, hr_api.g_varchar2))
1506      )
1507     or  NOT l_api_updating
1508   then
1509 if g_debug then
1510     hr_utility.set_location(l_proc, 40);
1511 end if;
1512     --
1513     --    Check for unique name
1514     --
1515     open csr_name_unique;
1516     fetch csr_name_unique into l_exists;
1517     if csr_name_unique%found then
1518       close csr_name_unique;
1519       hr_utility.set_message(800,'PAY_7688_USER_POS_TAB_UNIQUE');
1520       hr_utility.raise_error;
1521     else
1522       close csr_name_unique;
1523     end if;
1524   --
1525   end if;
1526   --
1527 if g_debug then
1528   hr_utility.set_location(' Leaving:'||l_proc, 100);
1529 end if;
1530 end chk_name_unique_for_BG;
1531 --
1532 --
1533 -- End insert/update/delete_validate
1534 --
1535 --
1536 --  ---------------------------------------------------------------------------
1537 --  |-------------------------<  chk_hrs_frequency  >-------------------------|
1538 --  ---------------------------------------------------------------------------
1539 --
1540 --  Desciption :
1541 --
1542 --    Validate that if the values for WORKING_HOURS and FREQUENCY are null that
1543 --    the values are defaulted from HR_ORGANIZATION_UNITS for the position's
1544 --    ORGANIZATION_ID. When organization defaults are not maintained, the
1545 --    default values from the business group are used.
1546 --
1547 --    Validate that if FREQUENCY is null and WORKING_HOURS is not null
1548 --    or if WORKING_HOURS is null and FREQUENCY is not null an error
1549 --    is raised
1550 --
1551 --    Validate the FREQUENCY value against the table
1552 --    FND_COMMON_LOOKUPS where the LOOKUP_TYPE is 'FREQUENCY'. (I,U)
1553 --
1554 --    Validate that if the value for WORKING_HOURS is NOT NULL,
1555 --    that the FREQUENCY value is valid for the WORKING_HOURS value.
1556 --
1557 --
1558 --  Pre-conditions:
1559 --    None
1560 --
1561 --  In Arguments :
1562 --    p_business_group_id
1563 --    p_organization_id
1564 --    p_position_id
1565 --    p_working_hours
1566 --    p_frequency
1567 --    p_effective_date
1568 --    p_object_version_number
1569 --
1570 --  Post Success :
1571 --    If the above business rules are satisfied, processing continues
1572 --
1573 --  Post Failure :
1574 --    If the above business rules are violated, an application error
1575 --    is raised and processing terminates
1576 --
1577 --  Access Status :
1578 --    Internal Table Handler Use only.
1579 --
1580 -- {End of Comments}
1581 --
1582 -- ---------------------------------------------------------------------------
1583 procedure chk_hrs_frequency
1584   (p_position_id        in number default null
1585   ,p_working_hours         in number
1586   ,p_effective_date        in date
1587   ,p_frequency             in varchar2
1588   ,p_object_version_number in number default null)    is
1589 --
1590    l_proc   varchar2(72);
1591    l_exists          varchar2(1);
1592    l_working_hours    number;
1593    l_frequency        varchar2(30);
1594    l_api_updating     boolean;
1595 --
1596    cursor csr_valid_freq is
1597      select 'x'
1598      from fnd_common_lookups
1599      where lookup_type = 'FREQUENCY'
1600      and lookup_code = p_frequency
1601      and enabled_flag = 'Y'
1602      and p_effective_date between nvl(start_date_active,p_effective_date)
1603        and nvl(end_date_active,p_effective_date);
1604 --
1605 begin
1606 if g_debug then
1607    l_proc   := g_package||'chk_hrs_frequency';
1608   hr_utility.set_location('Entering:'||l_proc, 1);
1609 end if;
1610   --
1611   -- Only proceed with validation if :
1612   -- a) The current g_old_rec is current and
1613   -- b) The working hours value has changed or
1614   -- c) The frequency value has changed
1615   --
1616 --
1617   l_api_updating := hr_psf_shd.api_updating
1618     (p_position_id        => p_position_id
1619     ,p_effective_date        => p_effective_date
1620     ,p_object_version_number => p_object_version_number);
1621   --
1622   if ((l_api_updating and
1623       (nvl(hr_psf_shd.g_old_rec.working_hours,hr_api.g_number) <>
1624       nvl(p_working_hours,hr_api.g_number) or
1625       (nvl(hr_psf_shd.g_old_rec.frequency,hr_api.g_varchar2) <>
1626       nvl(p_frequency,hr_api.g_varchar2)))) or
1627       (NOT l_api_updating)) then
1628       --
1629       --    Check for values consistency
1630       --
1631 if g_debug then
1632       hr_utility.set_location(l_proc, 5);
1633 end if;
1634       --
1635     if ((p_working_hours is null and p_frequency is not null) or
1636       (p_working_hours is not null and p_frequency is null)) then
1637        hr_utility.set_message(800,'PER_52981_POS_WORK_FREQ_NULL');
1638        hr_utility.raise_error;
1639     end if;
1640       --
1641       --    Check for valid frequency against fnd_common_lookups
1642       --
1643 if g_debug then
1644     hr_utility.set_location(l_proc, 6);
1645 end if;
1646       --
1647 if p_frequency is not null then
1648 
1649     open csr_valid_freq;
1650     fetch csr_valid_freq into l_exists;
1651     if csr_valid_freq%notfound then
1652       hr_utility.set_message(800,'HR_51363_POS_INVAL_FREQUENCY');
1653       hr_utility.raise_error;
1654     end if;
1655       --
1656       --    Validate combinations of working_hours and frequency
1657       --
1658 if g_debug then
1659     hr_utility.set_location(l_proc, 7);
1660 end if;
1661       --
1662     if ((p_working_hours > 24 AND p_frequency = 'D') or
1663        ((p_working_hours > 168)
1664         and (p_frequency = 'W')) or
1665        ((p_working_hours > 744)
1666         and (p_frequency = 'M')) or
1667        ((p_working_hours > 8784)
1668         and (p_frequency = 'Y'))) then
1669        hr_utility.set_message(800,'HR_POS_2_MANY_HOURS');
1670        hr_utility.raise_error;
1671     end if;
1672     --
1673   end if;
1674 --
1675 end if;
1676 if g_debug then
1677 hr_utility.set_location(' Leaving:'||l_proc, 8);
1678 end if;
1679 end chk_hrs_frequency;
1680 --
1681 --
1682 --  ---------------------------------------------------------------------------
1683 --  |------------------------< chk_pay_basis_id >-------------------------------|
1684 --  ---------------------------------------------------------------------------
1685 --
1686 procedure chk_pay_basis_id
1687   (p_position_id           in hr_all_positions_f.position_id%TYPE
1688   ,p_business_group_id     in hr_all_positions_f.business_group_id%TYPE
1689   ,p_pay_basis_id          in hr_all_positions_f.pay_basis_id%TYPE
1690   ,p_validation_start_date in hr_all_positions_f.effective_start_date%TYPE
1691   ,p_validation_end_date   in hr_all_positions_f.effective_end_date%TYPE
1692   ,p_effective_date        in date
1693   ,p_datetrack_mode        in varchar2
1694   ,p_object_version_number in hr_all_positions_f.object_version_number%TYPE
1695   )
1696   is
1697   --
1698   cursor c1 is
1699   select 'x'
1700   from per_pay_bases
1701   where pay_basis_id = p_pay_basis_id and
1702         business_group_id = p_business_group_id;
1703   --
1704   -- Declare local variables
1705   --
1706   l_proc              varchar2(72);
1707   l_exists            varchar2(1);
1708 begin
1709 if g_debug then
1710   l_proc              :=  g_package||'chk_pay_basis_id';
1711   hr_utility.set_location('Entering:'|| l_proc, 10);
1712 end if;
1713   --
1714   -- Ensure that all the mandatory parameter are not null
1715   --
1716   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1717                              p_argument       => 'position_id',
1718                              p_argument_value => p_position_id);
1719   --
1720 if g_debug then
1721   hr_utility.set_location('Entering : ' || l_proc, 10);
1722 end if;
1723   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1724                              p_argument       => 'position_id',
1725                              p_argument_value => p_position_id);
1726   --
1727   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1728                              p_argument       => 'business_group_id',
1729                              p_argument_value => p_business_group_id);
1730   --
1731   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1732                              p_argument       => 'validation_start_date',
1733                              p_argument_value => p_validation_start_date);
1734   --
1735   open c1;
1736   fetch c1 into l_exists;
1737   if c1%notfound then
1738     --
1739       close c1;
1740       hr_utility.set_message(800,'HR_PSF_INVALID_PAY_BASIS');
1741       hr_utility.raise_error;
1742   else
1743       close c1;
1744   end if;
1745   --
1746 if g_debug then
1747   hr_utility.set_location(' Leaving : ' || l_proc, 100);
1748 end if;
1749 end;
1750 --
1751 --
1752 --  ---------------------------------------------------------------------------
1753 --  |---------------------< return_legislation_code >-------------------------|
1754 --  ---------------------------------------------------------------------------
1755 --
1756 function return_legislation_code
1757   (p_position_id              in number
1758   ) return varchar2 is
1759   --
1760   -- Declare cursor
1761   --
1762   cursor csr_leg_code is
1763     select pbg.legislation_code
1764       from per_business_groups  pbg
1765          , hr_positions_f         pos
1766      where pos.position_id       = p_position_id
1767        and pbg.business_group_id = pos.business_group_id
1768      order by pos.effective_start_date;
1769   --
1770   -- Declare local variables
1771   --
1772   l_legislation_code  varchar2(150);
1773   l_proc              varchar2(72)  ;
1774 begin
1775 if g_debug then
1776   l_proc              :=  g_package||'return_legislation_code';
1777   hr_utility.set_location('Entering:'|| l_proc, 10);
1778 end if;
1779   --
1780   -- Ensure that all the mandatory parameter are not null
1781   --
1782   hr_api.mandatory_arg_error(p_api_name       => l_proc,
1783                              p_argument       => 'position_id',
1784                              p_argument_value => p_position_id);
1785   --
1786   open csr_leg_code;
1787   fetch csr_leg_code into l_legislation_code;
1788   if csr_leg_code%notfound then
1789     close csr_leg_code;
1790     --
1791     -- The primary key is invalid therefore we must error
1792     --
1793     hr_utility.set_message(800, 'HR_7220_INVALID_PRIMARY_KEY');
1794     hr_utility.raise_error;
1795   end if;
1796   --
1797   close csr_leg_code;
1798 if g_debug then
1799   hr_utility.set_location(' Leaving:'|| l_proc, 20);
1800 end if;
1801   --
1802   return l_legislation_code;
1803 end return_legislation_code;
1804 --
1805 --  ---------------------------------------------------------------------------
1806 --  |---------------------------<  chk_dates >--------------------------------|
1807 --  ---------------------------------------------------------------------------
1808 --
1809 --  Desciption :
1810 --
1811 --    Validates DATE_EFFECTIVE is not null
1812 --
1813 --    Validates that DATE_EFFECTIVE is less than or equal to the value for
1814 --    DATE_END on the same POSITION record
1815 --
1816 --  Pre-conditions:
1817 --    Format of p_date_effective must be correct
1818 --
1819 --  In Arguments :
1820 --    p_position_id
1821 --    p_date_effective
1822 --    p_date_end
1823 --    p_effective_date
1824 --    p_validation_start_Date
1825 --    p_validation_end_date
1826 --    p_object_version_number
1827 --
1828 --  Post Success :
1829 --    If the above business rules are satisfied, processing continues
1830 --
1831 --  Post Failure :
1832 --    If the above business rules are violated, an application error
1833 --    is raised and processing terminates
1834 --
1835 --  Access Status :
1836 --    Internal Table Handler Use only.
1837 --
1838 -- {End of Comments}
1839 --
1840 -- ---------------------------------------------------------------------------
1841 procedure chk_dates
1842   (p_position_id           in number default null
1843   ,p_date_effective        in date
1844   ,p_date_end              in date
1845   ,p_validation_start_date in date
1846   ,p_validation_end_date   in date
1847   ,p_effective_date        in date
1848   ,p_object_version_number in number default null) is
1849 --
1850    cursor c_get_eff_start_date (p_position_id number) is
1851    select min(effective_start_date)
1852    from hr_all_positions_f
1853    where position_id = p_position_id;
1854 --
1855    l_proc               varchar2(72)   ;
1856    l_api_updating          boolean;
1857    l_effective_start_date  date;
1858 
1859    l_return    boolean;
1860    l_industry  varchar2(10);
1861    l_status    varchar2(10);
1862    l_full_hr   boolean;
1863    l_ll        date;
1864    l_ul        date;
1865    l_updateable Boolean;
1866 
1867 --
1868 begin
1869 if g_debug then
1870    l_proc   := g_package||'chk_dates';
1871   hr_utility.set_location('Entering:'||l_proc, 1);
1872 end if;
1873   --
1874   --  Check mandatory parameters have been set
1875   --
1876   hr_api.mandatory_arg_error
1877     (p_api_name      => l_proc
1878     ,p_argument      => 'date_effective'
1879     ,p_argument_value   => p_date_effective
1880     );
1881 
1882   hr_api.mandatory_arg_error
1883     (p_api_name      => l_proc
1884     ,p_argument      => 'validation_start_date'
1885     ,p_argument_value   => p_validation_start_date
1886     );
1887 
1888   hr_api.mandatory_arg_error
1889     (p_api_name      => l_proc
1890     ,p_argument      => 'validation_end_date'
1891     ,p_argument_value   => p_validation_end_date
1892     );
1893 
1894 if g_debug then
1895   hr_utility.set_location(l_proc, 2);
1896 end if;
1897   --
1898   -- Only proceed with validation if :
1899   -- a) The current g_old_rec is current and
1900   -- b) The date_end value has changed
1901   --
1902   l_api_updating := hr_psf_shd.api_updating
1903     (p_position_id        => p_position_id
1904     ,p_effective_date        => p_effective_date
1905     ,p_object_version_number => p_object_version_number);
1906   --
1907   --
1908 if g_debug then
1909   hr_utility.set_location('HR Installation check ' || l_proc, 40);
1910 end if;
1911   --
1912   -- Find if full hr installation or shared hr installation
1913   --
1914   l_return := fnd_installation.get(appl_id     => 800,
1915                                    dep_appl_id => 800,
1916                                    status      => l_status,
1917                                    industry    => l_industry);
1918   --
1919 if g_debug then
1920   hr_utility.set_location('HR Installation check done ' || l_proc, 45);
1921 end if;
1922   if l_status = 'I' then
1923      l_full_hr := true;
1924   elsif l_status = 'S' then
1925      l_full_hr := false;
1926   else
1927      hr_utility.set_message(801,'HR_NULL_INSTALLATION_STATUS');
1928      hr_utility.raise_error;
1929   end if;
1930 
1931   --
1932   -- if full hr is installed the date_end must be null
1933   --
1934   if l_full_hr  and p_date_end is not null then
1935       hr_utility.set_message(800,'HR_DATE_END_MUST_BE_NULL');
1936       hr_utility.raise_error;
1937   end if;
1938   --
1939   if (((l_api_updating and
1940        (hr_psf_shd.g_old_rec.date_end <> p_date_end) or
1941        (hr_psf_shd.g_old_rec.date_effective <> p_date_effective)) or
1942        (NOT l_api_updating))) then
1943     --
1944     --   Check that date_effective <= date_end
1945     --
1946 if g_debug then
1947     hr_utility.set_location(l_proc, 3);
1948 end if;
1949     --
1950     if p_date_effective > nvl(p_date_end,hr_api.g_eot) then
1951       hr_utility.set_message(800,'HR_51362_POS_INVAL_EFF_DATE');
1952       hr_utility.raise_error;
1953     end if;
1954     --
1955 /*
1956     --
1957     -- Date_effective must be on or after effective_start_Date
1958     --
1959     if ( l_api_updating) then
1960       --
1961       open c_get_eff_start_date(p_position_id);
1962       fetch c_get_eff_start_date into l_effective_start_Date;
1963       close c_get_eff_start_date;
1964       if l_effective_start_date is null then
1965 I       hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1966         hr_utility.set_message_token('PROCEDURE', l_proc);
1967         hr_utility.set_message_token('STEP','5');
1968         hr_utility.raise_error;
1969       end if;
1970     else
1971       l_effective_start_date := p_validation_start_date;
1972     end if;
1973     --
1974     if ( p_date_effective < l_effective_start_date ) then
1975       hr_utility.set_message(800,'HR_PSF_DE_MUST_LATER_OR_EQ_ESD');
1976       hr_utility.raise_error;
1977     end if;
1978 --
1979     if (nvl(p_date_effective, hr_api.g_date) <>
1980         nvl(hr_psf_shd.g_old_rec.effective_start_date, hr_api.g_date)) then
1981       -- find if date_Effective can be modified
1982       --
1983       DE_Update_properties(
1984           p_position_id           => p_position_id,
1985           p_effective_Start_Date  => hr_psf_shd.g_old_rec.effective_start_date,
1986           p_updateable            => l_updateable,
1987           p_lower_limit           => l_ll,
1988           p_upper_limit           => l_ul);
1989       --
1990       if not l_updateable then
1991         --
1992         hr_utility.set_message(800,'HR_PSF_DE_NOT_UPDT_THIS_ROW');
1993         hr_utility.raise_error;
1994       end if;
1995       --
1996       if p_date_effective not between l_ll and l_ul then
1997          hr_utility.set_message(801,'HR_PSF_DE_OUT_OF_RANGE');
1998          hr_utility.raise_error;
1999       end if;
2000       -- if it is first row with ACTIVE status then
2001     --
2002     end if;
2003   --
2004 */
2005   end if;
2006   --
2007 if g_debug then
2008   hr_utility.set_location(' Leaving:'||l_proc, 4);
2009 end if;
2010 end chk_dates;
2011 --
2012 --
2013 --  ---------------------------------------------------------------------------
2014 --  |-----------------------------< chk_job_id >------------------------------|
2015 --  ---------------------------------------------------------------------------
2016 --
2017 procedure chk_job_id
2018   (p_position_id             in     hr_positions_f.position_id%TYPE           default null
2019   ,p_business_group_id       in     hr_positions_f.business_group_id%TYPE
2020   ,p_job_id                  in     hr_positions_f.job_id%TYPE
2021   ,p_effective_date          in     date
2022   ,p_validation_start_date   in     hr_positions_f.effective_start_date%TYPE
2023   ,p_validation_end_date     in     hr_positions_f.effective_end_date%TYPE
2024   ,p_object_version_number   in     hr_positions_f.object_version_number%TYPE default null
2025   )
2026   is
2027   --
2028   l_proc              varchar2(72) ;
2029   l_exists            varchar2(1);
2030   l_api_updating      boolean;
2031   l_business_group_id hr_positions_f.business_group_id%TYPE;
2032   l_vac_job_id        hr_positions_f.job_id%TYPE;
2033   --
2034   cursor csr_valid_job_id is
2035      select 'x'
2036      from per_jobs_v job
2037      where job.job_id = p_job_id
2038      and job.business_group_id + 0 = p_business_group_id;
2039   --
2040   cursor csr_valid_job_dates(p_validation_date date)  is
2041      select 'x'
2042      from per_jobs_v job
2043      where job.job_id = p_job_id
2044        and p_validation_date between job.date_from
2045        and nvl(job.date_to,hr_api.g_eot);
2046   --
2047 
2048 begin
2049 if g_debug then
2050   l_proc :=  g_package||'chk_job_id';
2051   hr_utility.set_location('Entering:'|| l_proc, 10);
2052 end if;
2053   --
2054   -- Check mandatory arguments
2055   --
2056   hr_api.mandatory_arg_error
2057     (p_api_name      => l_proc
2058     ,p_argument      => 'job_id'
2059     ,p_argument_value   => p_job_id
2060     );
2061   --
2062   hr_api.mandatory_arg_error
2063     (p_api_name       => l_proc
2064     ,p_argument       => 'effective_date'
2065     ,p_argument_value => p_effective_date
2066     );
2067   --
2068   hr_api.mandatory_arg_error
2069     (p_api_name       =>  l_proc
2070     ,p_argument       =>  'validation_start_date'
2071     ,p_argument_value =>  p_validation_start_date
2072     );
2073   --
2074   hr_api.mandatory_arg_error
2075     (p_api_name        =>  l_proc
2076     ,p_argument       =>  'validation_end_date'
2077     ,p_argument_value =>  p_validation_end_date
2078     );
2079 if g_debug then
2080   hr_utility.set_location(l_proc, 20);
2081 end if;
2082   --
2083   --  Check if the position is being updated.
2084   --
2085   l_api_updating := hr_psf_shd.api_updating
2086         (p_position_id            => p_position_id
2087         ,p_effective_date         => p_effective_date
2088         ,p_object_version_number  => p_object_version_number
2089         );
2090 if g_debug then
2091   hr_utility.set_location(l_proc, 30);
2092 end if;
2093   --
2094   -- Only proceed with validation if :
2095   -- a) The current g_old_rec is current and
2096   -- b) The value for job has changed
2097   --
2098   if ((l_api_updating and
2099        nvl(hr_psf_shd.g_old_rec.job_id,
2100        hr_api.g_number) <> nvl(p_job_id, hr_api.g_number))
2101     or
2102       NOT l_api_updating) then
2103 if g_debug then
2104     hr_utility.set_location(l_proc, 40);
2105 end if;
2106     --
2107     --    Check for valid job id
2108     --
2109     open csr_valid_job_id;
2110     fetch csr_valid_job_id into l_exists;
2111     if csr_valid_job_id%notfound then
2112       close csr_valid_job_id;
2113       hr_utility.set_message(800,'HR_51090_JOB_NOT_EXIST');
2114       hr_utility.raise_error;
2115     else
2116 if g_debug then
2117       hr_utility.set_location(l_proc, 3);
2118 end if;
2119       --
2120       close csr_valid_job_id;
2121       --
2122       --    Check validation_date between job date_from and date_to
2123       --
2124       open csr_valid_job_dates(p_validation_start_date);
2125       fetch csr_valid_job_dates into l_exists;
2126       if csr_valid_job_dates%notfound then
2127         close csr_valid_job_dates;
2128         hr_utility.set_message(800,'HR_51358_POS_JOB_INVALID_DATE');
2129         hr_utility.raise_error;
2130       end if;
2131       close csr_valid_job_dates;
2132     end if;
2133     --
2134   end if;
2135 if g_debug then
2136   hr_utility.set_location(' Leaving:'|| l_proc, 100);
2137 end if;
2138   --
2139 end chk_job_id;
2140 --
2141 --
2142 --  ---------------------------------------------------------------------------
2143 --  |-----------------------< chk_organization_id >---------------------------|
2144 --  ---------------------------------------------------------------------------
2145 --
2146 procedure chk_organization_id
2147   (p_position_id             in  hr_positions_f.position_id%TYPE            default null
2148   ,p_organization_id         in  hr_positions_f.organization_id%TYPE
2149   ,p_business_group_id       in  hr_positions_f.business_group_id%TYPE
2150   ,p_validation_start_date   in  hr_positions_f.effective_start_date%TYPE
2151   ,p_validation_end_date     in  hr_positions_f.effective_end_date%TYPE
2152   ,p_effective_date          in  date
2153   ,p_object_version_number   in  hr_positions_f.object_version_number%TYPE  default null
2154   )
2155 is
2156   --
2157   l_exists               varchar2(1);
2158   l_api_updating         boolean;
2159   l_proc                 varchar2(72);
2160   l_business_group_id    hr_positions_f.business_group_id%TYPE;
2161   --
2162   cursor csr_valid_organization_id is
2163      select 'x'
2164      from per_organization_units oru
2165      where oru.organization_id = p_organization_id
2166      and oru.business_group_id = p_business_group_id
2167      and oru.internal_external_flag = 'INT';
2168   --
2169   cursor csr_valid_organization_dates( p_validation_date date) is
2170      select 'x'
2171      from hr_organization_units oru
2172      where oru.organization_id = p_organization_id
2173        and p_validation_date between oru.date_from
2174        and nvl(oru.date_to,hr_api.g_eot);
2175   --
2176 
2177 begin
2178 if g_debug then
2179   l_proc :=  g_package||'chk_organization_id';
2180   hr_utility.set_location('Entering:'|| l_proc, 10);
2181 end if;
2182   --
2183   -- Check mandatory parameters have been set
2184   --
2185   hr_api.mandatory_arg_error
2186     (p_api_name       => l_proc
2187     ,p_argument       => 'effective_date'
2188     ,p_argument_value => p_effective_date
2189     );
2190   --
2191   hr_api.mandatory_arg_error
2192     (p_api_name       => l_proc
2193     ,p_argument       => 'organization_id'
2194     ,p_argument_value => p_organization_id
2195     );
2196   --
2197   hr_api.mandatory_arg_error
2198     (p_api_name       => l_proc
2199     ,p_argument       => 'business_group_id'
2200     ,p_argument_value => p_business_group_id
2201     );
2202   --
2203   hr_api.mandatory_arg_error
2204     (p_api_name       => l_proc
2205     ,p_argument       => 'validation_start_date'
2206     ,p_argument_value => p_validation_start_date
2207     );
2208   --
2209   hr_api.mandatory_arg_error
2210     (p_api_name       => l_proc
2211     ,p_argument       => 'validation_end_date'
2212     ,p_argument_value => p_validation_end_date
2213     );
2214 if g_debug then
2215   hr_utility.set_location(l_proc, 20);
2216 end if;
2217   --
2218   -- Only proceed with validation if :
2219   -- a) The current  g_old_rec is current and
2220   -- b) The value for organization_id has changed
2221   --
2222   l_api_updating := hr_psf_shd.api_updating
2223          (p_position_id            => p_position_id
2224          ,p_effective_date         => p_effective_date
2225          ,p_object_version_number  => p_object_version_number
2226          );
2227 if g_debug then
2228   hr_utility.set_location(l_proc, 30);
2229 end if;
2230   --
2231   if (l_api_updating and
2232      hr_psf_shd.g_old_rec.organization_id <> p_organization_id)
2233     or
2234       NOT l_api_updating
2235   then
2236 if g_debug then
2237     hr_utility.set_location(l_proc, 40);
2238 end if;
2239     --
2240     --    Check for valid organization id
2241     --
2242     open csr_valid_organization_id;
2243     fetch csr_valid_organization_id into l_exists;
2244     if csr_valid_organization_id%notfound then
2245       close csr_valid_organization_id;
2246       hr_utility.set_message(800,'HR_51371_POS_ORG_NOT_EXIST');
2247       hr_utility.raise_error;
2248     else
2249 if g_debug then
2250       hr_utility.set_location(l_proc, 3);
2251 end if;
2252       close csr_valid_organization_id;
2253       --
2254       --    Check validation_date between org date_from and date_to
2255       --
2256       open csr_valid_organization_dates(p_validation_start_date);
2257       fetch csr_valid_organization_dates into l_exists;
2258       if csr_valid_organization_dates%notfound then
2259         close csr_valid_organization_dates;
2260         hr_utility.set_message(800,'HR_51359_POS_ORG_INVAL_W_DATE');
2261         hr_utility.raise_error;
2262       end if;
2263       close csr_valid_organization_dates;
2264     end if;
2265   end if;
2266   --
2267   --
2268 if g_debug then
2269   hr_utility.set_location(' Leaving:'|| l_proc, 140);
2270 end if;
2271 end chk_organization_id;
2272 --
2273 --
2274 --  ---------------------------------------------------------------------------
2275 --  |--------------------<  chk_successor_position_id  >----------------------|
2276 --  ---------------------------------------------------------------------------
2277 --
2278 --  Desciption:
2279 --
2280 --    Validates that if SUCCESSOR_POSITION_ID exists, it must be a valid
2281 --    position for the business group and the successor DATE_END is on or after
2282 --    the DATE_EFFECTIVE of the position.
2283 --
2284 --  Pre-conditions:
2285 --
2286 --  In Arguments :
2287 --    p_position_id
2288 --    p_business_group_id
2289 --    p_successor_position_id
2290 --    p_effective_date
2291 --    p_validation_start_Date
2292 --    p_validation_end_Date
2293 --    p_object_version_number
2294 --
2295 --  Post Success :
2296 --    If the above business rules are satisfied, processing continues
2297 --
2298 --  Post Failure :
2299 --    If the above business rules are violated, an application error
2300 --    is raised and processing terminates
2301 --
2302 --  Access Status :
2303 --    Internal Table Handler Use only.
2304 --
2305 -- {End of Comments}
2306 --
2307 -- ----------------------------------------------------------------------------
2308 procedure chk_successor_position_id
2309   (p_business_group_id      in number
2310   ,p_position_id            in number default null
2311   ,p_successor_position_id  in number
2312   ,p_validation_start_date  in date
2313   ,p_validation_end_date    in date
2314   ,p_effective_date      in date
2315   ,p_object_version_number  in number default null
2316   )   is
2317 --
2318    l_exists           varchar2(1);
2319    l_proc   varchar2(72) ;
2320    l_api_updating     boolean;
2321 --
2322 cursor csr_valid_successor_position (p_validation_start_date date) is
2323 select 'x'
2324 from hr_all_positions_f psf, per_shared_types sht
2325 where psf.position_id = p_successor_position_id
2326 and psf.availability_status_id = sht.shared_type_id
2327 and (sht.business_group_id = p_business_group_id
2328      or sht.business_group_id is null)
2329 and sht.system_type_cd in ('ACTIVE','FROZEN')
2330 and psf.business_group_id = p_business_group_id
2331 and p_validation_start_date between psf.effective_start_date
2332                             and psf.effective_end_date ;
2333 
2334 begin
2335 if g_debug then
2336   l_proc     :=   g_package||'chk_successor_position_id';
2337   hr_utility.set_location('Entering:'||l_proc, 1);
2338 end if;
2339   --
2340   -- Only proceed with validation if :
2341   -- a) The current g_old_rec is current and
2342   -- b) The successor_position_id value has changed
2343   --
2344   if p_successor_position_id is not null then
2345   --
2346   hr_api.mandatory_arg_error
2347     (p_api_name       => l_proc
2348     ,p_argument       => 'effective date'
2349     ,p_argument_value => p_effective_date);
2350   --
2351   hr_api.mandatory_arg_error
2352     (p_api_name       => l_proc
2353     ,p_argument       => 'validation start date'
2354     ,p_argument_value => p_validation_start_date);
2355   --
2356   hr_api.mandatory_arg_error
2357     (p_api_name       => l_proc
2358     ,p_argument       => 'validation end date'
2359     ,p_argument_value => p_validation_end_date);
2360   --
2361   l_api_updating := hr_psf_shd.api_updating
2362     (p_position_id            => p_position_id
2363     ,p_effective_date            => p_effective_date
2364     ,p_object_version_number     => p_object_version_number);
2365   --
2366   --
2367   --    Check for valid successor position id
2368   --
2369   if ((l_api_updating and
2370        hr_psf_shd.g_old_rec.successor_position_id <>
2371        p_successor_position_id) or
2372        (NOT l_api_updating)) then
2373     --
2374 if g_debug then
2375       hr_utility.set_location(l_proc, 2);
2376 end if;
2377       open csr_valid_successor_position(p_validation_start_date);
2378       fetch csr_valid_successor_position into l_exists;
2379       if csr_valid_successor_position%notfound then
2380         close csr_valid_successor_position;
2381         hr_utility.set_message(800,'PER_52979_POS_SUCC_NOT_EXIST');
2382         hr_utility.raise_error;
2383      else
2384       close csr_valid_successor_position;
2385       if(l_api_updating and p_position_id = p_successor_position_id) then
2386         hr_utility.set_message(800,'HR_51360_POS_SUCCESSOR_EQ_POS');
2387         hr_utility.raise_error;
2388      end if;
2389     end if;
2390    end if;
2391   end if;
2392   --
2393 if g_debug then
2394   hr_utility.set_location(' Leaving:'||l_proc, 3);
2395 end if;
2396 end chk_successor_position_id;
2397 --
2398 --
2399 --  ---------------------------------------------------------------------------
2400 --  |--------------------<  chk_relief_position_id  >----------------------|
2401 --  ---------------------------------------------------------------------------
2402 --
2403 --  Desciption:
2404 --
2405 --    Validates that if relief_position_id exists, it must be a valid
2406 
2407 --    position for the business group and the successor DATE_END is on or after
2408 --    the DATE_EFFECTIVE of the position.
2409 --
2410 --  Pre-conditions:
2411 --
2412 --  In Arguments :
2413 --    p_position_id
2414 --    p_business_group_id
2415 --    p_relief_position_id
2416 --    p_effective_date
2417 --    p_validation_start_Date
2418 --    p_validation_end_Date
2419 --    p_object_version_number
2420 --
2421 --  Post Success :
2422 --    If the above business rules are satisfied, processing continues
2423 --
2424 --  Post Failure :
2425 --    If the above business rules are violated, an application error
2426 --    is raised and processing terminates
2427 --
2428 --  Access Status :
2429 --    Internal Table Handler Use only.
2430 --
2431 -- {End of Comments}
2432 --
2433 -- ----------------------------------------------------------------------------
2434 procedure chk_relief_position_id
2435   (p_business_group_id      in number
2436   ,p_position_id            in number default null
2437   ,p_relief_position_id     in number
2438   ,p_validation_start_date  in date
2439   ,p_validation_end_date    in date
2440   ,p_effective_date      in date
2441   ,p_object_version_number  in number default null
2442   )   is
2443 --
2444    l_exists           varchar2(1);
2445    l_proc   varchar2(72) ;
2446    l_api_updating     boolean;
2447 --
2448 cursor csr_valid_relief_position (p_validation_start_date date) is
2449 select 'x'
2450 from hr_all_positions_f psf, per_shared_types sht
2451 where psf.position_id = p_relief_position_id
2452 and psf.availability_status_id = sht.shared_type_id
2453 and (sht.business_group_id = p_business_group_id
2454      or sht.business_group_id is null)
2455 and sht.system_type_cd in ('ACTIVE','FROZEN')
2456 and psf.business_group_id = p_business_group_id
2457 and p_validation_start_date between psf.effective_start_date
2458                             and psf.effective_end_date ;
2459 --
2460 begin
2461 if g_debug then
2462    l_proc :=   g_package||'chk_relief_position_id';
2463   hr_utility.set_location('Entering:'||l_proc, 1);
2464 end if;
2465   --
2466   -- Only proceed with validation if :
2467   -- a) The current g_old_rec is current and
2468   -- b) The relief_position_id value has changed
2469   --
2470   if p_relief_position_id is not null then
2471   --
2472   hr_api.mandatory_arg_error
2473     (p_api_name       => l_proc
2474     ,p_argument       => 'effective date'
2475     ,p_argument_value => p_effective_date);
2476   --
2477   l_api_updating := hr_psf_shd.api_updating
2478     (p_position_id            => p_position_id
2479     ,p_effective_date            => p_effective_date
2480     ,p_object_version_number     => p_object_version_number);
2481   --
2482   hr_api.mandatory_arg_error
2483     (p_api_name       => l_proc
2484     ,p_argument       => 'validation start date'
2485     ,p_argument_value => p_validation_start_date);
2486   --
2487   --
2488   hr_api.mandatory_arg_error
2489     (p_api_name       => l_proc
2490     ,p_argument       => 'validation end date'
2491     ,p_argument_value => p_validation_end_date);
2492   --
2493   --    Check for valid successor position id
2494   --
2495   if ((l_api_updating and
2496        hr_psf_shd.g_old_rec.relief_position_id <>
2497        p_relief_position_id) or
2498        (NOT l_api_updating)) then
2499     --
2500 if g_debug then
2501     hr_utility.set_location(l_proc, 2);
2502 end if;
2503     --
2504       open csr_valid_relief_position(p_validation_start_date);
2505       fetch csr_valid_relief_position into l_exists;
2506       if csr_valid_relief_position%notfound then
2507         close csr_valid_relief_position;
2508         hr_utility.set_message(800,'PER_52980_POS_RELF_NOT_EXIST');
2509         hr_utility.raise_error;
2510      else
2511       close csr_valid_relief_position;
2512       if(l_api_updating and p_position_id = p_relief_position_id) then
2513         hr_utility.set_message(800,'HR_51361_POS_RELIEF_EQ_POS');
2514         hr_utility.raise_error;
2515      end if;
2516     end if;
2517    end if;
2518   end if;
2519   --
2520 if g_debug then
2521   hr_utility.set_location(' Leaving:'||l_proc, 3);
2522 end if;
2523 end chk_relief_position_id;
2524 --
2525 --
2526 --  ---------------------------------------------------------------------------
2527 --  |--------------------------< chk_location_id >----------------------------|
2528 --  ---------------------------------------------------------------------------
2529 --
2530 procedure chk_location_id
2531   (p_position_id           in hr_positions.position_id%TYPE           default null
2532   ,p_location_id           in hr_positions.location_id%TYPE
2533   ,p_effective_date        in date
2534   ,p_validation_start_date in hr_positions.effective_start_date%TYPE
2535   ,p_validation_end_date   in hr_positions.effective_end_date%TYPE
2536   ,p_object_version_number in hr_positions.object_version_number%TYPE default null
2537   )
2538   is
2539   --
2540   l_exists          varchar2(1);
2541   l_api_updating    boolean;
2542   l_proc            varchar2(72);
2543   l_inactive_date   date;
2544   --
2545   cursor csr_valid_location is
2546      select 'x'
2547      from   hr_locations loc
2548      where  loc.location_id = p_location_id
2549       and p_effective_date < nvl(loc.inactive_date,
2550          hr_api.g_eot);
2551 
2552   --
2553 begin
2554 
2555 if g_debug then
2556   l_proc  :=  g_package||'chk_location_id';
2557   hr_utility.set_location('Entering:'|| l_proc, 10);
2558 end if;
2559   --
2560   -- Check mandatory parameters have been set
2561   --
2562   hr_api.mandatory_arg_error
2563     (p_api_name       => l_proc
2564     ,p_argument       => 'effective_date'
2565     ,p_argument_value => p_effective_date
2566     );
2567   --
2568   hr_api.mandatory_arg_error
2569     (p_api_name       => l_proc
2570     ,p_argument       => 'validation_start_date'
2571     ,p_argument_value => p_validation_start_date
2572     );
2573   --
2574   hr_api.mandatory_arg_error
2575     (p_api_name       => l_proc
2576     ,p_argument       => 'validation_end_date'
2577     ,p_argument_value => p_validation_end_date
2578     );
2579 if g_debug then
2580   hr_utility.set_location('Entering:'|| l_proc, 20);
2581 end if;
2582   --
2583   -- Only proceed with validation if :
2584   -- a) The current g_old_rec is current and
2585   -- b) The value for location_id has changed
2586   --
2587   l_api_updating := hr_psf_shd.api_updating
2588          (p_position_id          => p_position_id
2589          ,p_effective_date         => p_effective_date
2590          ,p_object_version_number  => p_object_version_number
2591          );
2592 if g_debug then
2593   hr_utility.set_location('Entering:'|| l_proc, 30);
2594 end if;
2595   --
2596   if ((l_api_updating and
2597        nvl(hr_psf_shd.g_old_rec.location_id, hr_api.g_number) <>
2598        nvl(p_location_id, hr_api.g_number)) or
2599       (NOT l_api_updating))
2600   then
2601     --
2602 if g_debug then
2603     hr_utility.set_location('Entering:'|| l_proc, 40);
2604 end if;
2605     --
2606     if p_location_id is not null then
2607       --
2608       -- Check that the location exists in HR_LOCATIONS
2609       --
2610       open csr_valid_location;
2611       fetch csr_valid_location into l_exists;
2612       if csr_valid_location%notfound then
2613         close csr_valid_location;
2614         hr_utility.set_message(800, 'HR_51357_POS_LOC_NOT_EXIST');
2615         hr_utility.raise_error;
2616         --
2617       end if;
2618       close csr_valid_location;
2619       --
2620     end if;
2621     --
2622   end if;
2623   --
2624 if g_debug then
2625   hr_utility.set_location('Entering:'|| l_proc, 90);
2626 end if;
2627 end chk_location_id;
2628 --
2629 --
2630 --  ---------------------------------------------------------------------------
2631 --  |--------------------<  chk_position_definition_id  >---------------------|
2632 --  ---------------------------------------------------------------------------
2633 --
2634 --  Desciption :
2635 --
2636 --    Validates that POSITION_DEFINITION_ID is not null
2637 --
2638 --
2639 --  Pre-conditions:
2640 --
2641 --  In Arguments :
2642 --    p_position_definition_id
2643 --
2644 --  Post Success :
2645 --
2646 --  Post Failure :
2647 --
2648 --  Access Status :
2649 --    Internal Table Handler Use only.
2650 --
2651 -- {End of Comments}
2652 --
2653 -- -----------------------------------------------------------------------
2654 procedure chk_position_definition_id
2655   (p_position_definition_id   in number
2656   ,p_effective_date           in    date
2657   ,p_position_id              in    number default null
2658   ,p_object_version_number    in    number default null
2659   )   is
2660 --
2661    l_proc   varchar2(72)   ;
2662    l_exists    varchar2(1);
2663    l_api_updating  boolean;
2664 --
2665 cursor csr_pos_def is
2666   select 'x'
2667   from per_position_definitions
2668   where position_definition_id = p_position_definition_id;
2669 --
2670 begin
2671 if g_debug then
2672    l_proc   := g_package||'chk_position_definition_id';
2673   hr_utility.set_location('Entering:'||l_proc, 1);
2674 end if;
2675   --
2676   --  Check mandatory parameters have been set
2677   --
2678   hr_api.mandatory_arg_error
2679     (p_api_name      => l_proc
2680     ,p_argument      => 'position_definition_id'
2681     ,p_argument_value   => p_position_definition_id
2682     );
2683   --
2684   hr_api.mandatory_arg_error
2685     (p_api_name      => l_proc
2686     ,p_argument      => 'effective_date'
2687     ,p_argument_value   => p_effective_date
2688     );
2689   --
2690 if g_debug then
2691   hr_utility.set_location(l_proc, 2);
2692 end if;
2693   --
2694   l_api_updating := hr_psf_shd.api_updating
2695     (p_position_id        => p_position_id
2696     ,p_effective_date        => p_effective_date
2697     ,p_object_version_number => p_object_version_number);
2698   --
2699 if g_debug then
2700   hr_utility.set_location(l_proc, 3);
2701 end if;
2702   --
2703   if ((l_api_updating and
2704        (hr_psf_shd.g_old_rec.position_definition_id <>
2705           p_position_definition_id)) or
2706        (NOT l_api_updating)) then
2707 --
2708 if g_debug then
2709   hr_utility.set_location(l_proc, 4);
2710 end if;
2711   --
2712   open csr_pos_def;
2713   fetch csr_pos_def into l_exists;
2714   if csr_pos_def%notfound then
2715     hr_utility.set_message(800,'HR_51369_POS_DEF_NOT_EXIST');
2716     hr_utility.raise_error;
2717   end if;
2718   close csr_pos_def;
2719 --
2720 end if;
2721 if g_debug then
2722   hr_utility.set_location('Leaving '||l_proc, 5);
2723 end if;
2724   --
2725 end chk_position_definition_id;
2726 --
2727 --  ---------------------------------------------------------------------------
2728 --  |---------------------<  chk_probation_info >---------------------------|
2729 --  ---------------------------------------------------------------------------
2730 --
2731 --  Desciption :
2732 --
2733 --    Validate that if the PROBATION_PERIOD is null and PROBATION_PERIOD_UNITS
2734 --    is not null or if PROBATION_PERIOD is not null and PROBATION_PERIOS_UNITS
2735 --    is null then an error is raised
2736 --
2737 --    Validate the value for PROBATION_PERIOD_UNITS against the table
2738 --    FND_COMMON_LOOKUPS where the LOOKUP_TYPE is 'QUALIFYING_UNITS'.
2739 --
2740 --  Pre-conditions:
2741 --    None
2742 --
2743 --  In Arguments :
2744 --    p_position_id
2745 --    p_probation_period
2746 --    p_probation_period_units
2747 --    p_effective_date
2748 --    p_object_version_number
2749 --
2750 --  Post Success :
2751 --    If the above business rules are satisfied, processing continues
2752 --
2753 --  Post Failure :
2754 --    If the above business rules are violated, an application error
2755 --    is raised and processing terminates
2756 --
2757 --  Access Status :
2758 --    Internal Table Handler Use only.
2759 --
2760 -- {End of Comments}
2761 --
2762 -- ---------------------------------------------------------------------------
2763 procedure chk_probation_info
2764   (p_position_id              in number default null
2765   ,p_Effective_date           in date
2766   ,p_probation_period      in number
2767   ,p_probation_period_unit_cd in varchar2
2768   ,p_object_version_number    in number default null) is
2769 --
2770    l_proc   varchar2(72);
2771    l_api_updating     boolean;
2772    l_exists    varchar2(1);
2773 --
2774    cursor csr_valid_unit is
2775      select 'x'
2776      from fnd_common_lookups
2777      where lookup_type = 'QUALIFYING_UNITS'
2778        and lookup_code = p_probation_period_unit_cd;
2779 --
2780 begin
2781 if g_debug then
2782    l_proc      := g_package||'chk_probation_info';
2783   hr_utility.set_location('Entering:'||l_proc, 1);
2784 end if;
2785   --
2786   -- Only proceed with validation if :
2787   -- a) The current g_old_rec is current and
2788   -- b) The probation_period value has changed
2789   -- c) The probation_period_unit_cd value has changed
2790   --
2791   l_api_updating := hr_psf_shd.api_updating
2792     (p_position_id        => p_position_id
2793     ,p_effective_date        => p_effective_date
2794     ,p_object_version_number => p_object_version_number);
2795   --
2796   if ((l_api_updating and
2797     (nvl(hr_psf_shd.g_old_rec.probation_period,hr_api.g_number) <>
2798     nvl(p_probation_period,hr_api.g_number)) or
2799     (nvl(hr_psf_shd.g_old_rec.probation_period_unit_cd,hr_api.g_varchar2) <>
2800     nvl(p_probation_period_unit_cd,hr_api.g_varchar2))) or
2801     (NOT l_api_updating)) then
2802     --
2803     --    Check for values consistency
2804     --
2805 if g_debug then
2806     hr_utility.set_location(l_proc, 2);
2807 end if;
2808     --
2809     if (p_probation_period is null and
2810         p_probation_period_unit_cd is not null) or
2811        (p_probation_period is not null and
2812        p_probation_period_unit_cd is null) then
2813        hr_utility.set_message(800,'HR_51365_POS_PROB_UNITS_REQ');
2814        hr_utility.raise_error;
2815     else
2816       --
2817       --    Validate probation_period_unit_cd against fnd_common_lookups
2818       --
2819 if g_debug then
2820       hr_utility.set_location(l_proc, 3);
2821 end if;
2822       --
2823       if p_probation_period is not null
2824            and p_probation_period_unit_cd is not null then
2825         open csr_valid_unit;
2826         fetch csr_valid_unit into l_exists;
2827         if csr_valid_unit%notfound then
2828           hr_utility.set_message(800,'HR_51366_POS_PROB_UNITS_INV');
2829           hr_utility.raise_error;
2830         end if;
2831      end if;
2832   end if;
2833 end if;
2834     --
2835 if g_debug then
2836   hr_utility.set_location(' Leaving:'||l_proc, 4);
2837 end if;
2838 end chk_probation_info;
2839 --
2840 --
2841 --  ---------------------------------------------------------------------------
2842 --  |------------------<  chk_time_start_finish  >---------------------------|
2843 --  ---------------------------------------------------------------------------
2844 --
2845 --  Desciption :
2846 --
2847 --    Validate that TIME_NORMAL_FINISH is not before TIME_NORMAL_START.
2848 --
2849 --    Selects TIME_NORMAL_START and TIME_NORMAL_FINISH from the corresponding
2850 --    values on HR_ORGANIZATION_UNITS for the position's ORGANIZATION_ID when
2851 --    the values are null. When organization defaults are not maintained, the
2852 --    default values from the business group are used.
2853 --
2854 --  Pre-conditions:
2855 --    None
2856 --
2857 --  In Arguments :
2858 --    p_business_group_id
2859 --    p_organization_id
2860 --    p_position_id
2861 --    p_time_normal_start
2862 --    p_time_normal_finish
2863 --    p_effective_date
2864 --    p_object_version_number
2865 --
2866 --  Post Success :
2867 --    If the above business rules are satisfied, processing continues
2868 --
2869 --  Post Failure :
2870 --    If the above business rules are violated, an application error
2871 --    is raised and processing terminates
2872 --
2873 --  Access Status :
2874 --    Internal Table Handler Use only.
2875 --
2876 -- {End of Comments}
2877 --
2878 -- ---------------------------------------------------------------------------
2879 procedure chk_time_start_finish
2880   (p_position_id         in number default null
2881   ,p_effective_Date         in date
2882   ,p_time_normal_start      in varchar2
2883   ,p_time_normal_finish     in varchar2
2884   ,p_object_version_number  in number default null)   is
2885 --
2886    l_exists            varchar2(1);
2887    l_proc              varchar2(72);
2888    l_time_normal_start    varchar2(5);
2889    l_time_normal_finish   varchar2(5);
2890    l_api_updating         boolean;
2891 --
2892 begin
2893 if g_debug then
2894    l_proc   := g_package||'chk_time_start_finish';
2895   hr_utility.set_location('Entering:'||l_proc, 1);
2896 end if;
2897   --
2898   -- Only proceed with validation if :
2899   -- a) The current g_old_rec is current and
2900   -- b) The time_normal_start value has changed
2901   -- c) The time_normal_finish value has changed
2902   --
2903   l_api_updating := hr_psf_shd.api_updating
2904     (p_position_id        => p_position_id
2905     ,p_effective_Date        => p_effective_date
2906     ,p_object_version_number => p_object_version_number);
2907   --
2908   if ((l_api_updating and
2909      (nvl(hr_psf_shd.g_old_rec.time_normal_start,hr_api.g_varchar2) <>
2910      nvl(p_time_normal_start,hr_api.g_varchar2) or
2911      (nvl(hr_psf_shd.g_old_rec.time_normal_finish,hr_api.g_varchar2) <>
2912      nvl(p_time_normal_finish,hr_api.g_varchar2)))) or
2913      (NOT l_api_updating)) then
2914   --
2915     --    Check for values consistency
2916     --
2917 if g_debug then
2918     hr_utility.set_location(l_proc, 4);
2919 end if;
2920     --
2921     if (p_time_normal_start is not null and p_time_normal_finish is null) or
2922       (p_time_normal_start is null and p_time_normal_finish is not null) then
2923         hr_utility.set_message(800,'HR_51367_POS_TIMES_REQ');
2924         hr_utility.raise_error;
2925 --
2926   elsif not (substr(p_time_normal_start,1,2) between '00' and '24'
2927         and substr(p_time_normal_start,4,2) between '00' and '59'
2928         and substr(p_time_normal_start,3,1) = ':') then
2929         hr_utility.set_message(800,'HR_51154_INVAL_TIME_FORMAT');
2930         hr_utility.raise_error;
2931 --
2932    elsif not (substr(p_time_normal_finish,1,2) between '00' and '24'
2933         and substr(p_time_normal_finish,4,2) between '00' and '59'
2934         and substr(p_time_normal_finish,3,1) = ':') then
2935         hr_utility.set_message(800,'HR_51154_INVAL_TIME_FORMAT');
2936         hr_utility.raise_error;
2937 end if;
2938 /*
2939 -- remove this check
2940     --
2941     --   Check that time_normal_start <= time_normal_finish
2942     --
2943 if g_debug then
2944     hr_utility.set_location(l_proc, 5);
2945 end if;
2946     --
2947     if p_time_normal_finish <= p_time_normal_start then
2948       hr_utility.set_message(801,'HR_51368_POS_FIN_GT_START');
2949       hr_utility.raise_error;
2950     end if;
2951 */
2952     --
2953   end if;
2954   --
2955 if g_debug then
2956   hr_utility.set_location(' Leaving:'||l_proc, 6);
2957 end if;
2958 end chk_time_start_finish;
2959 /*
2960 --
2961 --  ---------------------------------------------------------------------------
2962 --  |-------------------< chk_position_transaction_id >-----------------------|
2963 --  ---------------------------------------------------------------------------
2964 --
2965 procedure chk_position_transaction_id
2966   (p_position_id              in hr_all_positions_f.position_id%TYPE
2967   ,p_position_transaction_id  in hr_all_positions_f.position_transaction_id%TYPE
2968   ,p_validation_start_date    in hr_all_positions_f.effective_start_date%TYPE
2969   ,p_validation_end_date      in hr_all_positions_f.effective_end_date%TYPE
2970   ,p_effective_date           in date
2971   ,p_object_version_number    in hr_all_positions_f.object_version_number%TYPE
2972   )
2973   is
2974 --
2975    l_exists            varchar2(1);
2976    l_api_updating      boolean;
2977    l_business_group_id number(15);
2978    l_proc              varchar2(72) ;
2979 --
2980    cursor csr_valid_tran is
2981    select  null
2982      from  pqh_position_transactions ptx
2983      where ptx.position_transaction_id = p_position_transaction_id;
2984 --
2985 begin
2986 if g_debug then
2987    l_proc  := g_package||'chk_position_transaction_id';
2988   hr_utility.set_location('Entering:'|| l_proc, 10);
2989 end if;
2990   --
2991   -- Check mandatory parameters have been set
2992   --
2993   hr_api.mandatory_arg_error
2994     (p_api_name       => l_proc
2995     ,p_argument       => 'validation_start_date'
2996     ,p_argument_value => p_validation_start_date
2997     );
2998   --
2999   hr_api.mandatory_arg_error
3000     (p_api_name       => l_proc
3001     ,p_argument       => 'validation_end_date'
3002     ,p_argument_value => p_validation_end_date
3003     );
3004   --
3005   hr_api.mandatory_arg_error
3006     (p_api_name       => l_proc
3007     ,p_argument       => 'effective_date'
3008     ,p_argument_value => p_effective_date
3009     );
3010   --
3011 if g_debug then
3012   hr_utility.set_location(l_proc, 20);
3013 end if;
3014   --
3015   -- Only proceed with validation if :
3016   -- a) The current g_old_rec is current and
3017   -- b) The value for position_transaction_id has changed
3018   --
3019   l_api_updating := hr_psf_shd.api_updating
3020         (p_position_id            => p_position_id
3021         ,p_effective_date         => p_effective_date
3022         ,p_object_version_number  => p_object_version_number
3023         );
3024 if g_debug then
3025   hr_utility.set_location(l_proc, 30);
3026 end if;
3027   --
3028   if ((l_api_updating and
3029        nvl(hr_psf_shd.g_old_rec.position_transaction_id, hr_api.g_number) <>
3030        nvl(p_position_transaction_id, hr_api.g_number)) or
3031       (NOT l_api_updating)) then
3032 if g_debug then
3033     hr_utility.set_location(l_proc, 40);
3034 end if;
3035     --
3036     if p_position_transaction_id is not null then
3037 if g_debug then
3038       hr_utility.set_location(l_proc, 50);
3039 end if;
3040       --
3041       -- Check that position_transaction_id exists in
3042       -- pqh_position_transactions
3043       --
3044       open csr_valid_tran;
3045       fetch csr_valid_tran into l_exists;
3046       if csr_valid_tran%notfound then
3047         close csr_valid_tran;
3048         hr_utility.set_message(800, 'HR_INV_POSN_TRAN');
3049         hr_utility.raise_error;
3050         --
3051       end if;
3052       close csr_valid_tran;
3053 if g_debug then
3054       hr_utility.set_location(l_proc, 60);
3055     hr_utility.set_location(l_proc, 130);
3056   hr_utility.set_location(' Leaving:'|| l_proc, 140);
3057 end if;
3058 end chk_position_transaction_id;
3059 */
3060 --
3061 --
3062 --  ---------------------------------------------------------------------------
3063 --  |--------------------<  chk_supervisor_position_id  >----------------------|
3064 --  ---------------------------------------------------------------------------
3065 --
3066 --  Desciption:
3067 --
3068 --    Validates that if supervisor_position_id exists, it must be a valid
3069 --    position for the business group and the successor DATE_END is on or after
3070 --    the DATE_EFFECTIVE of the position.
3071 --
3072 --  Pre-conditions:
3073 --
3074 --  In Arguments :
3075 --    p_position_id
3076 --    p_business_group_id
3077 --    p_supervisor_position_id
3078 --    p_effective_date
3079 --    p_validation_start_Date
3080 --    p_validation_end_Date
3081 --    p_object_version_number
3082 --
3083 --  Post Success :
3084 --    If the above business rules are satisfied, processing continues
3085 --
3086 --  Post Failure :
3087 --    If the above business rules are violated, an application error
3088 --    is raised and processing terminates
3089 --
3090 --  Access Status :
3091 --    Internal Table Handler Use only.
3092 --
3093 -- {End of Comments}
3094 --
3095 -- ----------------------------------------------------------------------------
3096 procedure chk_supervisor_position_id
3097   (p_business_group_id      in number
3098   ,p_position_id            in number default null
3099   ,p_supervisor_position_id  in number
3100   ,p_validation_start_date  in date
3101   ,p_validation_end_date    in date
3102   ,p_effective_date      in date
3103   ,p_object_version_number  in number default null
3104   )   is
3105 --
3106    l_exists           varchar2(1);
3107    l_proc   varchar2(72) ;
3108    l_api_updating     boolean;
3109 --
3110 cursor csr_valid_supervisor_position (p_validation_start_date date) is
3111 select 'x'
3112 from hr_all_positions_f psf, per_shared_types sht
3113 where psf.position_id = p_supervisor_position_id
3114 and psf.availability_status_id = sht.shared_type_id
3115 and (sht.business_group_id = p_business_group_id
3116      or sht.business_group_id is null)
3117 and sht.system_type_cd in ('ACTIVE','FROZEN')
3118 and psf.business_group_id = p_business_group_id
3119 and p_validation_start_date between psf.effective_start_date
3120                             and psf.effective_end_date ;
3121 --
3122 begin
3123 if g_debug then
3124    l_proc    :=   g_package||'chk_supervisor_position_id';
3125   hr_utility.set_location('Entering:'||l_proc, 1);
3126 end if;
3127   --
3128   -- Only proceed with validation if :
3129   -- a) The current g_old_rec is current and
3130   -- b) The supervisor_position_id value has changed
3131   --
3132   if p_supervisor_position_id is not null then
3133     --
3134     hr_api.mandatory_arg_error
3135       (p_api_name       => l_proc
3136       ,p_argument       => 'effective date'
3137       ,p_argument_value => p_effective_date);
3138     --
3139     hr_api.mandatory_arg_error
3140       (p_api_name       => l_proc
3141       ,p_argument       => 'validation start date'
3142       ,p_argument_value => p_validation_start_date);
3143     --
3144     hr_api.mandatory_arg_error
3145       (p_api_name       => l_proc
3146       ,p_argument       => 'validation end date'
3147       ,p_argument_value => p_validation_end_date);
3148     --
3149     l_api_updating := hr_psf_shd.api_updating
3150       (p_position_id          => p_position_id
3151       ,p_effective_date            => p_effective_date
3152       ,p_object_version_number     => p_object_version_number);
3153     --
3154     --
3155     --    Check for valid successor position id
3156     --
3157     if ((l_api_updating and
3158          hr_psf_shd.g_old_rec.supervisor_position_id <>
3159          p_supervisor_position_id) or
3160          (NOT l_api_updating)) then
3161       --
3162 if g_debug then
3163       hr_utility.set_location(l_proc, 2);
3164 end if;
3165       open csr_valid_supervisor_position(p_validation_start_date);
3166       fetch csr_valid_supervisor_position into l_exists;
3167       if csr_valid_supervisor_position%notfound then
3168         close csr_valid_supervisor_position;
3169         hr_utility.set_message(800,'HR_PSF_SUPER_NOT_EXIST');
3170         hr_utility.raise_error;
3171       else
3172         close csr_valid_supervisor_position;
3173         if(l_api_updating and p_position_id = p_supervisor_position_id) then
3174             hr_utility.set_message(800,'HR_PSF_SUPERVISOR_EQ_POS');
3175             hr_utility.raise_error;
3176         end if;
3177       end if;
3178     end if;
3179   end if;
3180   --
3181 if g_debug then
3182   hr_utility.set_location(' Leaving:'||l_proc, 3);
3183 end if;
3184 end chk_supervisor_position_id;
3185 --
3186 --
3187 --
3188 --  ---------------------------------------------------------------------------
3189 --  |--------------------<  chk_prior_position_id  >----------------------|
3190 --  ---------------------------------------------------------------------------
3191 --
3192 --  Desciption:
3193 --
3194 --    Validates that if prior_position_id exists, it must be a valid
3195 --    position for the business group and the successor DATE_END is on or after
3196 --    the DATE_EFFECTIVE of the position.
3197 --
3198 --  Pre-conditions:
3199 --
3200 --  In Arguments :
3201 --    p_position_id
3202 --    p_business_group_id
3203 --    p_prior_position_id
3204 --    p_effective_date
3205 --    p_validation_start_Date
3206 --    p_validation_end_Date
3207 --    p_object_version_number
3208 --
3209 --  Post Success :
3210 --    If the above business rules are satisfied, processing continues
3211 --
3212 --  Post Failure :
3213 --    If the above business rules are violated, an application error
3214 --    is raised and processing terminates
3215 --
3216 --  Access Status :
3217 --    Internal Table Handler Use only.
3218 --
3219 -- {End of Comments}
3220 --
3221 -- ----------------------------------------------------------------------------
3222 procedure chk_prior_position_id
3223   (p_business_group_id      in number
3224   ,p_position_id            in number default null
3225   ,p_prior_position_id  in number
3226   ,p_validation_start_date  in date
3227   ,p_validation_end_date    in date
3228   ,p_effective_date      in date
3229   ,p_object_version_number  in number default null
3230   )   is
3231 --
3232    l_exists           varchar2(1);
3233    l_proc   varchar2(72) ;
3234    l_api_updating     boolean;
3235 --
3236 cursor csr_valid_prior_position (p_validation_start_date date) is
3237 select 'x'
3238 from hr_all_positions_f psf, per_shared_types sht
3239 where psf.position_id = p_prior_position_id
3240 and psf.availability_status_id = sht.shared_type_id
3241 and (sht.business_group_id = p_business_group_id
3242      or sht.business_group_id is null)
3243 and sht.system_type_cd in ('ACTIVE','FROZEN')
3244 and psf.business_group_id = p_business_group_id
3245 and p_validation_start_date between psf.effective_start_date
3246                             and psf.effective_end_date ;
3247 --
3248 begin
3249 if g_debug then
3250    l_proc    :=   g_package||'chk_prior_position_id';
3251   hr_utility.set_location('Entering:'||l_proc, 1);
3252 end if;
3253   --
3254   -- Only proceed with validation if :
3255   -- a) The current g_old_rec is current and
3256   -- b) The prior_position_id value has changed
3257   --
3258   if p_prior_position_id is not null then
3259     --
3260     hr_api.mandatory_arg_error
3261       (p_api_name       => l_proc
3262       ,p_argument       => 'effective date'
3263       ,p_argument_value => p_effective_date);
3264     --
3265     hr_api.mandatory_arg_error
3266       (p_api_name       => l_proc
3267       ,p_argument       => 'validation start date'
3268       ,p_argument_value => p_validation_start_date);
3269     --
3270     hr_api.mandatory_arg_error
3271       (p_api_name       => l_proc
3272       ,p_argument       => 'validation end date'
3273       ,p_argument_value => p_validation_end_date);
3274     --
3275     l_api_updating := hr_psf_shd.api_updating
3276       (p_position_id          => p_position_id
3277       ,p_effective_date            => p_effective_date
3278       ,p_object_version_number     => p_object_version_number);
3279     --
3280     --
3281     --    Check for valid successor position id
3282     --
3283     if ((l_api_updating and
3284          hr_psf_shd.g_old_rec.prior_position_id <>
3285          p_prior_position_id) or
3286          (NOT l_api_updating)) then
3287       --
3288 if g_debug then
3289       hr_utility.set_location(l_proc, 2);
3290 end if;
3291       open csr_valid_prior_position(p_validation_start_date);
3292       fetch csr_valid_prior_position into l_exists;
3293       if csr_valid_prior_position%notfound then
3294         close csr_valid_prior_position;
3295         hr_utility.set_message(800,'HR_PSF_PRIOR_NOT_EXIST');
3296         hr_utility.raise_error;
3297       else
3298         close csr_valid_prior_position;
3299       end if;
3300     end if;
3301   end if;
3302   --
3303 if g_debug then
3304   hr_utility.set_location(' Leaving:'||l_proc, 3);
3305 end if;
3306 end chk_prior_position_id;
3307 --
3308 -- ----------------------------------------------------------------------------
3309 -- |------< chk_work_term_end_month_cd >------|
3310 -- ----------------------------------------------------------------------------
3311 --
3312 -- Description
3313 --   This procedure is used to check that the lookup value is valid.
3314 --
3315 -- Pre Conditions
3316 --   None.
3317 --
3318 -- In Parameters
3319 --   position_id PK of record being inserted or updated.
3320 --   work_term_end_month_cd   Value of lookup code.
3321 --   effective_date           effective date
3322 --   validation_start_date
3323 --   validation_end_Date
3324 --   date_effective
3325 --   object_version_number    Object version number of record being
3326 --                         inserted or updated.
3327 --
3328 -- Post Success
3329 --   Processing continues
3330 --
3331 -- Post Failure
3332 --   Error handled by procedure
3333 --
3334 -- Access Status
3335 --   Internal table handler use only.
3336 --
3337 Procedure chk_work_term_end_month_cd
3338   (p_position_id             in number
3339   ,p_work_term_end_month_cd  in varchar2
3340   ,p_effective_date          in date
3341   ,p_validation_start_date   in date
3342   ,p_validation_end_date     in date
3343   ,p_object_version_number   in number) is
3344   --
3345   l_proc         varchar2(72) ;
3346   l_api_updating boolean;
3347   --
3348 Begin
3349   --
3350 if g_debug then
3351  l_proc       := g_package||'chk_work_term_end_month_cd';
3352   hr_utility.set_location('Entering:'||l_proc, 5);
3353 end if;
3354   --
3355   l_api_updating := hr_psf_shd.api_updating
3356     (p_position_id            => p_position_id
3357     ,p_effective_date         => p_effective_date
3358     ,p_object_version_number  => p_object_version_number);
3359   --
3360   if (l_api_updating
3361       and p_work_term_end_month_cd
3362       <> nvl(hr_psf_shd.g_old_rec.work_term_end_month_cd,hr_api.g_varchar2)
3363       or not l_api_updating)
3364       and p_work_term_end_month_cd is not null then
3365     --
3366     -- check if value of lookup falls within lookup type.
3367     --
3368     if hr_api.not_exists_in_dt_hr_lookups
3369           (p_lookup_type           => 'MONTH_CODE'
3370           ,p_lookup_code           => p_work_term_end_month_cd
3371           ,p_validation_start_date => p_validation_start_date
3372           ,p_validation_end_date   => p_validation_end_date
3373           ,p_effective_date        => p_effective_date) then
3374       --
3375       -- raise error as does not exist as lookup
3376       --
3377       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3378       hr_utility.raise_error;
3379       --
3380     end if;
3381     --
3382   end if;
3383   --
3384 if g_debug then
3385   hr_utility.set_location('Leaving:'||l_proc,10);
3386 end if;
3387   --
3388 end chk_work_term_end_month_cd;
3389 --
3390 --
3391 -- ----------------------------------------------------------------------------
3392 -- |------< chk_work_term_end_day_cd >------|
3393 -- ----------------------------------------------------------------------------
3394 --
3395 -- Description
3396 --   This procedure is used to check that the lookup value is valid.
3397 --
3398 -- Pre Conditions
3399 --   None.
3400 --
3401 -- In Parameters
3402 --   position_id                   PK of record being inserted or updated.
3403 --   work_term_end_day_cd          Value of lookup code.
3404 --   validation_start_date
3405 --   validation_end_Date
3406 --   date_effective
3407 --   effective_date                effective date
3408 --   object_version_number         Object version number of record being
3409 --                         inserted or updated.
3410 --
3411 -- Post Success
3412 --   Processing continues
3413 --
3414 -- Post Failure
3415 --   Error handled by procedure
3416 --
3417 -- Access Status
3418 --   Internal table handler use only.
3419 --
3420 Procedure chk_work_term_end_day_cd
3421   (p_position_id             in number
3422   ,p_work_term_end_day_cd    in varchar2
3423   ,p_effective_date          in date
3424   ,p_validation_start_date   in date
3425   ,p_validation_end_date     in date
3426   ,p_object_version_number   in number) is
3427   --
3428   l_proc         varchar2(72) ;
3429   l_api_updating boolean;
3430   --
3431 Begin
3432   --
3433 if g_debug then
3434   l_proc          := g_package||'chk_work_term_end_day_cd';
3435   hr_utility.set_location('Entering:'||l_proc, 5);
3436 end if;
3437   --
3438   l_api_updating := hr_psf_shd.api_updating
3439     (p_position_id            => p_position_id
3440     ,p_effective_date         => p_effective_date
3441     ,p_object_version_number  => p_object_version_number);
3442   --
3443   if (l_api_updating
3444       and p_work_term_end_day_cd
3445       <> nvl(hr_psf_shd.g_old_rec.work_term_end_day_cd,hr_api.g_varchar2)
3446       or not l_api_updating)
3447       and p_work_term_end_day_cd is not null then
3448     --
3449     -- check if value of lookup falls within lookup type.
3450     --
3451     if hr_api.not_exists_in_dt_hr_lookups
3452           (p_lookup_type           => 'DAY_CODE'
3453           ,p_lookup_code           => p_work_term_end_day_cd
3454           ,p_validation_start_date => p_validation_start_date
3455           ,p_validation_end_date   => p_validation_end_date
3456           ,p_effective_date        => p_effective_date) then
3457       --
3458       -- raise error as does not exist as lookup
3459       --
3460       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3461       hr_utility.raise_error;
3462       --
3463     end if;
3464     --
3465   end if;
3466   --
3467 if g_debug then
3468   hr_utility.set_location('Leaving:'||l_proc,10);
3469 end if;
3470   --
3471 end chk_work_term_end_day_cd;
3472 --
3473 -- ----------------------< chk_position_type > ------------------------
3474 --
3475 Procedure chk_position_type
3476   (p_position_id             in number
3477   ,p_position_type           in varchar2
3478   ,p_effective_date          in date
3479   ,p_validation_start_date   in date
3480   ,p_validation_end_date     in date
3481   ,p_object_version_number   in number) is
3482   --
3483   l_proc         varchar2(72);
3484   l_api_updating boolean;
3485   --
3486 Begin
3487   --
3488 if g_debug then
3489 l_proc        := g_package||'chk_position_type';
3490   hr_utility.set_location('Entering:'||l_proc, 5);
3491 end if;
3492   --
3493   hr_api.mandatory_arg_error
3494       (p_api_name       => l_proc
3495       ,p_argument       => 'position type'
3496       ,p_argument_value => p_position_type);
3497     --
3498   --
3499   hr_api.mandatory_arg_error
3500       (p_api_name       => l_proc
3501       ,p_argument       => 'validation start date'
3502       ,p_argument_value => p_validation_start_date);
3503     --
3504   --
3505   hr_api.mandatory_arg_error
3506       (p_api_name       => l_proc
3507       ,p_argument       => 'effective date'
3508       ,p_argument_value => p_effective_date);
3509     --
3510   l_api_updating := hr_psf_shd.api_updating
3511     (p_position_id            => p_position_id
3512     ,p_effective_date         => p_effective_date
3513     ,p_object_version_number  => p_object_version_number);
3514   --
3515   if (l_api_updating
3516       and p_position_type
3517       <> nvl(hr_psf_shd.g_old_rec.position_type,hr_api.g_varchar2)
3518       or not l_api_updating)
3519       and p_position_type is not null then
3520     --
3521     -- check if value of lookup falls within lookup type.
3522     --
3523     if hr_api.not_exists_in_dt_hr_lookups
3524           (p_lookup_type           => 'POSITION_TYPE'
3525           ,p_lookup_code           => p_position_type
3526           ,p_validation_start_date => p_validation_start_date
3527           ,p_validation_end_date   => p_validation_end_date
3528           ,p_effective_date        => p_effective_date) then
3529       --
3530       -- raise error as does not exist as lookup
3531       --
3532       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3533       hr_utility.raise_error;
3534       --
3535     end if;
3536     --
3537   end if;
3538   --
3539 if g_debug then
3540   hr_utility.set_location('Leaving:'||l_proc,10);
3541 end if;
3542   --
3543 end chk_position_type;
3544 --
3545 -- ----------------------------------------------------------------------------
3546 -- |------< chk_work_period_type_cd >------|
3547 -- ----------------------------------------------------------------------------
3548 --
3549 -- Description
3550 --   This procedure is used to check that the lookup value is valid.
3551 --
3552 -- Pre Conditions
3553 --   None.
3554 --
3555 -- In Parameters
3556 --   position_id                   PK of record being inserted or updated.
3557 --   work_period_type_cd          Value of lookup code.
3558 --   validation_start_date
3559 --   validation_end_Date
3560 --   date_effective
3561 --   effective_date                effective date
3562 --   object_version_number         Object version number of record being
3563 --                         inserted or updated.
3564 --
3565 -- Post Success
3566 --   Processing continues
3567 --
3568 -- Post Failure
3569 --   Error handled by procedure
3570 --
3571 -- Access Status
3572 --   Internal table handler use only.
3573 --
3574 Procedure chk_work_period_type_cd
3575   (p_position_id             in number
3576   ,p_work_period_type_cd    in varchar2
3577   ,p_effective_date          in date
3578   ,p_validation_start_date   in date
3579   ,p_validation_end_date     in date
3580   ,p_object_version_number   in number) is
3581   --
3582   l_proc         varchar2(72) ;
3583   l_api_updating boolean;
3584   --
3585 Begin
3586   --
3587 if g_debug then
3588   l_proc          := g_package||'chk_work_period_type_cd';
3589   hr_utility.set_location('Entering:'||l_proc, 5);
3590 end if;
3591   --
3592   l_api_updating := hr_psf_shd.api_updating
3593     (p_position_id            => p_position_id
3594     ,p_effective_date         => p_effective_date
3595     ,p_object_version_number  => p_object_version_number);
3596   --
3597   if (l_api_updating
3598       and p_work_period_type_cd
3599       <> nvl(hr_psf_shd.g_old_rec.work_period_type_cd,hr_api.g_varchar2)
3600       or not l_api_updating)
3601       and p_work_period_type_cd is not null then
3602     --
3603     -- check if value of lookup falls within lookup type.
3604     --
3605     if hr_api.not_exists_in_dt_hr_lookups
3606           (p_lookup_type           => 'YES_NO'
3607           ,p_lookup_code           => p_work_period_type_cd
3608           ,p_validation_start_date => p_validation_start_date
3609           ,p_validation_end_date   => p_validation_end_date
3610           ,p_effective_date        => p_effective_date) then
3611       --
3612       -- raise error as does not exist as lookup
3613       --
3614       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3615       hr_utility.raise_error;
3616       --
3617     end if;
3618     --
3619   end if;
3620   --
3621 if g_debug then
3622   hr_utility.set_location('Leaving:'||l_proc,10);
3623 end if;
3624   --
3625 end chk_work_period_type_cd;
3626 --
3627 -- ----------------------------------------------------------------------------
3628 -- |------< chk_works_council_approval_flg >------|
3629 -- ----------------------------------------------------------------------------
3630 --
3631 -- Description
3632 --   This procedure is used to check that the lookup value is valid.
3633 --
3634 -- Pre Conditions
3635 --   None.
3636 --
3637 -- In Parameters
3638 --   position_id                   PK of record being inserted or updated.
3639 --   works_council_approval_flag   Value of lookup code.
3640 --   validation_start_date
3641 --   validation_end_Date
3642 --   date_effective
3643 --   effective_date                effective date
3644 --   object_version_number         Object version number of record being
3645 --                         inserted or updated.
3646 --
3647 -- Post Success
3648 --   Processing continues
3649 --
3650 -- Post Failure
3651 --   Error handled by procedure
3652 --
3653 -- Access Status
3654 --   Internal table handler use only.
3655 --
3656 Procedure chk_works_council_approval_flg
3657   (p_position_id             in number
3658   ,p_works_council_approval_flag    in varchar2
3659   ,p_effective_date          in date
3660   ,p_validation_start_date   in date
3661   ,p_validation_end_date     in date
3662   ,p_object_version_number   in number) is
3663   --
3664   l_proc         varchar2(72) ;
3665   l_api_updating boolean;
3666   --
3667 Begin
3668   --
3669 if g_debug then
3670   l_proc     := g_package||'chk_works_council_approval_flg';
3671   hr_utility.set_location('Entering:'||l_proc, 5);
3672 end if;
3673   --
3674   l_api_updating := hr_psf_shd.api_updating
3675     (p_position_id            => p_position_id
3676     ,p_effective_date         => p_effective_date
3677     ,p_object_version_number  => p_object_version_number);
3678   --
3679   if (l_api_updating
3680       and p_works_council_approval_flag
3681       <> nvl(hr_psf_shd.g_old_rec.works_council_approval_flag,hr_api.g_varchar2)
3682       or not l_api_updating)
3683       and p_works_council_approval_flag is not null then
3684     --
3685     -- check if value of lookup falls within lookup type.
3686     --
3687     if hr_api.not_exists_in_dt_hr_lookups
3688           (p_lookup_type           => 'YES_NO'
3689           ,p_lookup_code           => p_works_council_approval_flag
3690           ,p_validation_start_date => p_validation_start_date
3691           ,p_validation_end_date   => p_validation_end_date
3692           ,p_effective_date        => p_effective_date) then
3693       --
3694       -- raise error as does not exist as lookup
3695       --
3696       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3697       hr_utility.raise_error;
3698       --
3699     end if;
3700     --
3701   end if;
3702   --
3703 if g_debug then
3704   hr_utility.set_location('Leaving:'||l_proc,10);
3705 end if;
3706   --
3707 end chk_works_council_approval_flg;
3708 --
3709 --
3710 -- ----------------------------------------------------------------------------
3711 -- |------< chk_term_start_month_cd >------|
3712 -- ----------------------------------------------------------------------------
3713 --
3714 -- Description
3715 --   This procedure is used to check that the lookup value is valid.
3716 --
3717 -- Pre Conditions
3718 --   None.
3719 --
3720 -- In Parameters
3721 --   position_id                   PK of record being inserted or updated.
3722 --   p_term_start_month_cd   Value of lookup code.
3723 --   validation_start_date
3724 --   validation_end_Date
3725 --   date_effective
3726 --   effective_date                effective date
3727 --   object_version_number         Object version number of record being
3728 --                         inserted or updated.
3729 --
3730 -- Post Success
3731 --   Processing continues
3732 --
3733 -- Post Failure
3734 --   Error handled by procedure
3735 --
3736 -- Access Status
3737 --   Internal table handler use only.
3738 --
3739 Procedure chk_term_start_month_cd
3740   (p_position_id             in number
3741   ,p_term_start_month_cd    in varchar2
3742   ,p_effective_date          in date
3743   ,p_validation_start_date   in date
3744   ,p_validation_end_date     in date
3745   ,p_object_version_number   in number) is
3746   --
3747   l_proc         varchar2(72);
3748   l_api_updating boolean;
3749   --
3750 Begin
3751   --
3752 if g_debug then
3753  l_proc          := g_package||'chk_term_start_month_cd';
3754   hr_utility.set_location('Entering:'||l_proc, 5);
3755 end if;
3756   --
3757   l_api_updating := hr_psf_shd.api_updating
3758     (p_position_id            => p_position_id
3759     ,p_effective_date         => p_effective_date
3760     ,p_object_version_number  => p_object_version_number);
3761   --
3762   if (l_api_updating
3763       and p_term_start_month_cd
3764       <> nvl(hr_psf_shd.g_old_rec.term_start_month_cd,hr_api.g_varchar2)
3765       or not l_api_updating)
3766       and p_term_start_month_cd is not null then
3767     --
3768     -- check if value of lookup falls within lookup type.
3769     --
3770     if hr_api.not_exists_in_dt_hr_lookups
3771           (p_lookup_type           => 'MONTH_CODE'
3772           ,p_lookup_code           => p_term_start_month_cd
3773           ,p_validation_start_date => p_validation_start_date
3774           ,p_validation_end_date   => p_validation_end_date
3775           ,p_effective_date        => p_effective_date) then
3776       --
3777       -- raise error as does not exist as lookup
3778       --
3779       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3780       hr_utility.raise_error;
3781       --
3782     end if;
3783     --
3784   end if;
3785   --
3786 if g_debug then
3787   hr_utility.set_location('Leaving:'||l_proc,10);
3788 end if;
3789   --
3790 end chk_term_start_month_cd;
3791 --
3792 --
3793 -- ----------------------------------------------------------------------------
3794 -- |------< chk_term_start_day_cd >------|
3795 -- ----------------------------------------------------------------------------
3796 --
3797 -- Description
3798 --   This procedure is used to check that the lookup value is valid.
3799 --
3800 -- Pre Conditions
3801 --   None.
3802 --
3803 -- In Parameters
3804 --   position_id                   PK of record being inserted or updated.
3805 --   p_term_start_day_cd   Value of lookup code.
3806 --   validation_start_date
3807 --   validation_end_Date
3808 --   date_effective
3809 --   effective_date                effective date
3810 --   object_version_number         Object version number of record being
3811 --                         inserted or updated.
3812 --
3813 -- Post Success
3814 --   Processing continues
3815 --
3816 -- Post Failure
3817 --   Error handled by procedure
3818 --
3819 -- Access Status
3820 --   Internal table handler use only.
3821 --
3822 Procedure chk_term_start_day_cd
3823   (p_position_id             in number
3824   ,p_term_start_day_cd    in varchar2
3825   ,p_effective_date          in date
3826   ,p_validation_start_date   in date
3827   ,p_validation_end_date     in date
3828   ,p_object_version_number   in number) is
3829   --
3830   l_proc         varchar2(72) ;
3831   l_api_updating boolean;
3832   --
3833 Begin
3834   --
3835 if g_debug then
3836   l_proc      := g_package||'chk_term_start_day_cd';
3837   hr_utility.set_location('Entering:'||l_proc, 5);
3838 end if;
3839   --
3840   l_api_updating := hr_psf_shd.api_updating
3841     (p_position_id            => p_position_id
3842     ,p_effective_date         => p_effective_date
3843     ,p_object_version_number  => p_object_version_number);
3844   --
3845   if (l_api_updating
3846       and p_term_start_day_cd
3847       <> nvl(hr_psf_shd.g_old_rec.term_start_day_cd,hr_api.g_varchar2)
3848       or not l_api_updating)
3849       and p_term_start_day_cd is not null then
3850     --
3851     -- check if value of lookup falls within lookup type.
3852     --
3853     if hr_api.not_exists_in_dt_hr_lookups
3854           (p_lookup_type           => 'DAY_CODE'
3855           ,p_lookup_code           => p_term_start_day_cd
3856           ,p_validation_start_date => p_validation_start_date
3857           ,p_validation_end_date   => p_validation_end_date
3858           ,p_effective_date        => p_effective_date) then
3859       --
3860       -- raise error as does not exist as lookup
3861       --
3862       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3863       hr_utility.raise_error;
3864       --
3865     end if;
3866     --
3867   end if;
3868   --
3869 if g_debug then
3870   hr_utility.set_location('Leaving:'||l_proc,10);
3871 end if;
3872   --
3873 end chk_term_start_day_cd;
3874 --
3875 --
3876 -- ----------------------------------------------------------------------------
3877 -- |------< chk_seasonal_flag >------|
3878 -- ----------------------------------------------------------------------------
3879 --
3880 -- Description
3881 --   This procedure is used to check that the lookup value is valid.
3882 --
3883 -- Pre Conditions
3884 --   None.
3885 --
3886 -- In Parameters
3887 --   position_id                   PK of record being inserted or updated.
3888 --   p_seasonal_flag               Value of lookup code.
3889 --   validation_start_date
3890 --   validation_end_Date
3891 --   date_effective
3892 --   effective_date                effective date
3893 --   object_version_number         Object version number of record being
3894 --                         inserted or updated.
3895 --
3896 -- Post Success
3897 --   Processing continues
3898 --
3899 -- Post Failure
3900 --   Error handled by procedure
3901 --
3902 -- Access Status
3903 --   Internal table handler use only.
3904 --
3905 Procedure chk_seasonal_flag
3906   (p_position_id             in number
3907   ,p_seasonal_flag    in varchar2
3908   ,p_effective_date          in date
3909   ,p_validation_start_date   in date
3910   ,p_validation_end_date     in date
3911   ,p_object_version_number   in number) is
3912   --
3913   l_proc         varchar2(72) ;
3914   l_api_updating boolean;
3915   --
3916 Begin
3917   --
3918 if g_debug then
3919   l_proc          := g_package||'chk_seasonal_flag';
3920   hr_utility.set_location('Entering:'||l_proc, 5);
3921 end if;
3922   --
3923   l_api_updating := hr_psf_shd.api_updating
3924     (p_position_id            => p_position_id
3925     ,p_effective_date         => p_effective_date
3926     ,p_object_version_number  => p_object_version_number);
3927   --
3928   if (l_api_updating
3929       and p_seasonal_flag
3930       <> nvl(hr_psf_shd.g_old_rec.seasonal_flag,hr_api.g_varchar2)
3931       or not l_api_updating)
3932       and p_seasonal_flag is not null then
3933     --
3934     -- check if value of lookup falls within lookup type.
3935     --
3936     if hr_api.not_exists_in_dt_hr_lookups
3937           (p_lookup_type           => 'YES_NO'
3938           ,p_lookup_code           => p_seasonal_flag
3939           ,p_validation_start_date => p_validation_start_date
3940           ,p_validation_end_date   => p_validation_end_date
3941           ,p_effective_date        => p_effective_date) then
3942       --
3943       -- raise error as does not exist as lookup
3944       --
3945       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
3946       hr_utility.raise_error;
3947       --
3948     end if;
3949     --
3950   end if;
3951   --
3952 if g_debug then
3953   hr_utility.set_location('Leaving:'||l_proc,10);
3954 end if;
3955   --
3956 end chk_seasonal_flag;
3957 --
3958 --
3959 -- ----------------------------------------------------------------------------
3960 -- |------< chk_review_flag >------|
3961 -- ----------------------------------------------------------------------------
3962 --
3963 -- Description
3964 --   This procedure is used to check that the lookup value is valid.
3965 --
3966 -- Pre Conditions
3967 --   None.
3968 --
3969 -- In Parameters
3970 --   position_id                   PK of record being inserted or updated.
3971 --   p_review_flag                 Value of lookup code.
3972 --   validation_start_date
3973 --   validation_end_Date
3974 --   date_effective
3975 --   effective_date                effective date
3976 --   object_version_number         Object version number of record being
3977 --
3978 -- Post Success
3979 --   Processing continues
3980 --
3981 -- Post Failure
3982 --   Error handled by procedure
3983 --
3984 -- Access Status
3985 --   Internal table handler use only.
3986 --
3987 Procedure chk_review_flag
3988   (p_position_id             in number
3989   ,p_review_flag    in varchar2
3990   ,p_effective_date          in date
3991   ,p_validation_start_date   in date
3992   ,p_validation_end_date     in date
3993   ,p_object_version_number   in number) is
3994   --
3995   l_proc         varchar2(72) ;
3996   l_api_updating boolean;
3997   --
3998 Begin
3999   --
4000 if g_debug then
4001   l_proc         := g_package||'chk_review_flag';
4002   hr_utility.set_location('Entering:'||l_proc, 5);
4003 end if;
4004   --
4005   l_api_updating := hr_psf_shd.api_updating
4006     (p_position_id            => p_position_id
4007     ,p_effective_date         => p_effective_date
4008     ,p_object_version_number  => p_object_version_number);
4009   --
4010   if (l_api_updating
4011       and p_review_flag
4012       <> nvl(hr_psf_shd.g_old_rec.review_flag,hr_api.g_varchar2)
4013       or not l_api_updating)
4014       and p_review_flag is not null then
4015     --
4016     -- check if value of lookup falls within lookup type.
4017     --
4018     if hr_api.not_exists_in_dt_hr_lookups
4019           (p_lookup_type           => 'YES_NO'
4020           ,p_lookup_code           => p_review_flag
4021           ,p_validation_start_date => p_validation_start_date
4022           ,p_validation_end_date   => p_validation_end_date
4023           ,p_effective_date        => p_effective_date) then
4024       --
4025       -- raise error as does not exist as lookup
4026       --
4027       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4028       hr_utility.raise_error;
4029       --
4030     end if;
4031     --
4032   end if;
4033   --
4034 if g_debug then
4035   hr_utility.set_location('Leaving:'||l_proc,10);
4036 end if;
4037   --
4038 end chk_review_flag;
4039 --
4040 --
4041 -- ----------------------------------------------------------------------------
4042 -- |------< chk_replacement_required_flag >------|
4043 -- ----------------------------------------------------------------------------
4044 --
4045 -- Description
4046 --   This procedure is used to check that the lookup value is valid.
4047 --
4048 -- Pre Conditions
4049 --   None.
4050 --
4051 -- In Parameters
4052 --   position_id                   PK of record being inserted or updated.
4053 --   p_replacement_required_flag                 Value of lookup code.
4054 --   validation_start_date
4055 --   validation_end_Date
4056 --   date_effective
4057 --   effective_date                effective date
4058 --   object_version_number         Object version number of record being
4059 --
4060 -- Post Success
4061 --   Processing continues
4062 --
4063 -- Post Failure
4064 --   Error handled by procedure
4065 --
4066 -- Access Status
4067 --   Internal table handler use only.
4068 --
4069 Procedure chk_replacement_required_flag
4070   (p_position_id               in number
4071   ,p_replacement_required_flag in varchar2
4072   ,p_effective_date            in date
4073   ,p_validation_start_date     in date
4074   ,p_validation_end_date       in date
4075   ,p_object_version_number     in number) is
4076   --
4077   l_proc         varchar2(72) ;
4078   l_api_updating boolean;
4079   --
4080 Begin
4081   --
4082 if g_debug then
4083 l_proc       := g_package||'chk_replacement_required_flag';
4084   hr_utility.set_location('Entering:'||l_proc, 5);
4085 end if;
4086   --
4087   l_api_updating := hr_psf_shd.api_updating
4088     (p_position_id            => p_position_id
4089     ,p_effective_date         => p_effective_date
4090     ,p_object_version_number  => p_object_version_number);
4091   --
4092   if (l_api_updating
4093       and p_replacement_required_flag
4094       <> nvl(hr_psf_shd.g_old_rec.replacement_required_flag,hr_api.g_varchar2)
4095       or not l_api_updating)
4096       and p_replacement_required_flag is not null then
4097     --
4098     -- check if value of lookup falls within lookup type.
4099     --
4100     if hr_api.not_exists_in_dt_hr_lookups
4101           (p_lookup_type           => 'YES_NO'
4102           ,p_lookup_code           => p_replacement_required_flag
4103           ,p_validation_start_date => p_validation_start_date
4104           ,p_validation_end_date   => p_validation_end_date
4105           ,p_effective_date        => p_effective_date) then
4106       --
4107       -- raise error as does not exist as lookup
4108       --
4109       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4110       hr_utility.raise_error;
4111       --
4112     end if;
4113     --
4114   end if;
4115   --
4116 if g_debug then
4117   hr_utility.set_location('Leaving:'||l_proc,10);
4118 end if;
4119   --
4120 end chk_replacement_required_flag;
4121 --
4122 --
4123 -- ----------------------------------------------------------------------------
4124 -- |------< chk_probation_period_unit_cd >------|
4125 -- ----------------------------------------------------------------------------
4126 --
4127 -- Description
4128 --   This procedure is used to check that the lookup value is valid.
4129 --
4130 -- Pre Conditions
4131 --   None.
4132 --
4133 -- In Parameters
4134 --   position_id                   PK of record being inserted or updated.
4135 --   p_probation_period_unit_cd                 Value of lookup code.
4136 --   validation_start_date
4137 --   validation_end_Date
4138 --   date_effective
4139 --   effective_date                effective date
4140 --   object_version_number         Object version number of record being
4141 --
4142 -- Post Success
4143 --   Processing continues
4144 --
4145 -- Post Failure
4146 --   Error handled by procedure
4147 --
4148 -- Access Status
4149 --   Internal table handler use only.
4150 --
4151 Procedure chk_probation_period_unit_cd
4152   (p_position_id               in number
4153   ,p_probation_period_unit_cd in varchar2
4154   ,p_effective_date            in date
4155   ,p_validation_start_date     in date
4156   ,p_validation_end_date       in date
4157   ,p_object_version_number     in number) is
4158   --
4159   l_proc         varchar2(72);
4160   l_api_updating boolean;
4161   --
4162 Begin
4163   --
4164 if g_debug then
4165   l_proc   := g_package||'chk_probation_period_unit_cd';
4166   hr_utility.set_location('Entering:'||l_proc, 5);
4167 end if;
4168   --
4169   l_api_updating := hr_psf_shd.api_updating
4170     (p_position_id            => p_position_id
4171     ,p_effective_date         => p_effective_date
4172     ,p_object_version_number  => p_object_version_number);
4173   --
4174   if (l_api_updating
4175       and p_probation_period_unit_cd
4176       <> nvl(hr_psf_shd.g_old_rec.probation_period_unit_cd,hr_api.g_varchar2)
4177       or not l_api_updating)
4178       and p_probation_period_unit_cd is not null then
4179     --
4180     -- check if value of lookup falls within lookup type.
4181     --
4182     if hr_api.not_exists_in_dt_hr_lookups
4183           (p_lookup_type           => 'FREQUENCY'
4184           ,p_lookup_code           => p_probation_period_unit_cd
4185           ,p_validation_start_date => p_validation_start_date
4186           ,p_validation_end_date   => p_validation_end_date
4187           ,p_effective_date        => p_effective_date) then
4188       --
4189       -- raise error as does not exist as lookup
4190       --
4191       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4192       hr_utility.raise_error;
4193       --
4194     end if;
4195     --
4196   end if;
4197   --
4198 if g_debug then
4199   hr_utility.set_location('Leaving:'||l_proc,10);
4200 end if;
4201   --
4202 end chk_probation_period_unit_cd;
4203 --
4204 --
4205 -- ----------------------------------------------------------------------------
4206 -- |------< chk_permit_recruitment_flag >------|
4207 -- ----------------------------------------------------------------------------
4208 --
4209 -- Description
4210 --   This procedure is used to check that the lookup value is valid.
4211 --
4212 -- Pre Conditions
4213 --   None.
4214 --
4215 -- In Parameters
4216 --   position_id                   PK of record being inserted or updated.
4217 --   p_permit_recruitment_flag                 Value of lookup code.
4218 --   validation_start_date
4219 --   validation_end_Date
4220 --   date_effective
4221 --   effective_date                effective date
4222 --   object_version_number         Object version number of record being
4223 --
4224 -- Post Success
4225 --   Processing continues
4226 --
4227 -- Post Failure
4228 --   Error handled by procedure
4229 --
4230 -- Access Status
4231 --   Internal table handler use only.
4232 --
4233 Procedure chk_permit_recruitment_flag
4234   (p_position_id               in number
4235   ,p_permit_recruitment_flag   in varchar2
4236   ,p_effective_date            in date
4237   ,p_validation_start_date     in date
4238   ,p_validation_end_date       in date
4239   ,p_object_version_number     in number) is
4240   --
4241   l_proc         varchar2(72) ;
4242   l_api_updating boolean;
4243   --
4244 Begin
4245   --
4246 if g_debug then
4247   l_proc         := g_package||'chk_permit_recruitment_flag';
4248   hr_utility.set_location('Entering:'||l_proc, 5);
4249 end if;
4250   --
4251   l_api_updating := hr_psf_shd.api_updating
4252     (p_position_id            => p_position_id
4253     ,p_effective_date         => p_effective_date
4254     ,p_object_version_number  => p_object_version_number);
4255   --
4256   if (l_api_updating
4257       and p_permit_recruitment_flag
4258       <> nvl(hr_psf_shd.g_old_rec.permit_recruitment_flag,hr_api.g_varchar2)
4259       or not l_api_updating)
4260       and p_permit_recruitment_flag is not null then
4261     --
4262     -- check if value of lookup falls within lookup type.
4263     --
4264     if hr_api.not_exists_in_dt_hr_lookups
4265           (p_lookup_type           => 'YES_NO'
4266           ,p_lookup_code           => p_permit_recruitment_flag
4267           ,p_validation_start_date => p_validation_start_date
4268           ,p_validation_end_date   => p_validation_end_date
4269           ,p_effective_date        => p_effective_date) then
4270       --
4271       -- raise error as does not exist as lookup
4272       --
4273       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4274       hr_utility.raise_error;
4275       --
4276     end if;
4277     --
4278   end if;
4279   --
4280 if g_debug then
4281   hr_utility.set_location('Leaving:'||l_proc,10);
4282 end if;
4283   --
4284 end chk_permit_recruitment_flag;
4285 --
4286 --
4287 -- ----------------------------------------------------------------------------
4288 -- |------< chk_permanent_temporary_flag >------|
4289 -- ----------------------------------------------------------------------------
4290 --
4291 -- Description
4292 --   This procedure is used to check that the lookup value is valid.
4293 --
4294 -- Pre Conditions
4295 --   None.
4296 --
4297 -- In Parameters
4298 --   position_id                   PK of record being inserted or updated.
4299 --   permanent_temporary_flag                 Value of lookup code.
4300 --   validation_start_date
4301 --   validation_end_Date
4302 --   date_effective
4303 --   effective_date                effective date
4304 --   object_version_number         Object version number of record being
4305 --
4306 -- Post Success
4307 --   Processing continues
4308 --
4309 -- Post Failure
4310 --   Error handled by procedure
4311 --
4312 -- Access Status
4313 --   Internal table handler use only.
4314 --
4315 Procedure chk_permanent_temporary_flag
4316   (p_position_id               in number
4317   ,p_permanent_temporary_flag   in varchar2
4318   ,p_effective_date            in date
4319   ,p_validation_start_date     in date
4320   ,p_validation_end_date       in date
4321   ,p_object_version_number     in number) is
4322   --
4323   l_proc         varchar2(72) ;
4324   l_api_updating boolean;
4325   --
4326 Begin
4327   --
4328 if g_debug then
4329   l_proc          := g_package||'chk_permanent_temporary_flag';
4330   hr_utility.set_location('Entering:'||l_proc, 5);
4331 end if;
4332   --
4333   l_api_updating := hr_psf_shd.api_updating
4334     (p_position_id            => p_position_id
4335     ,p_effective_date         => p_effective_date
4336     ,p_object_version_number  => p_object_version_number);
4337   --
4338   if (l_api_updating
4339       and p_permanent_temporary_flag
4340       <> nvl(hr_psf_shd.g_old_rec.permanent_temporary_flag,hr_api.g_varchar2)
4341       or not l_api_updating)
4342       and p_permanent_temporary_flag is not null then
4343     --
4344     -- check if value of lookup falls within lookup type.
4345     --
4346     if hr_api.not_exists_in_dt_hr_lookups
4347           (p_lookup_type           => 'YES_NO'
4348           ,p_lookup_code           => p_permanent_temporary_flag
4349           ,p_validation_start_date => p_validation_start_date
4350           ,p_validation_end_date   => p_validation_end_date
4351           ,p_effective_date        => p_effective_date) then
4352       --
4353       -- raise error as does not exist as lookup
4354       --
4355       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4356       hr_utility.raise_error;
4357       --
4358     end if;
4359     --
4360   end if;
4361   --
4362 if g_debug then
4363   hr_utility.set_location('Leaving:'||l_proc,10);
4364 end if;
4365   --
4366 end chk_permanent_temporary_flag;
4367 --
4368 --
4369 -- ----------------------------------------------------------------------------
4370 -- |------< chk_pay_term_end_month_cd >------|
4371 -- ----------------------------------------------------------------------------
4372 --
4373 -- Description
4374 --   This procedure is used to check that the lookup value is valid.
4375 --
4376 -- Pre Conditions
4377 --   None.
4378 --
4379 -- In Parameters
4380 --   position_id                   PK of record being inserted or updated.
4381 --   pay_term_end_month_cd                 Value of lookup code.
4382 --   validation_start_date
4383 --   validation_end_Date
4384 --   date_effective
4385 --   effective_date                effective date
4386 --   object_version_number         Object version number of record being
4387 --
4388 -- Post Success
4389 --   Processing continues
4390 --
4391 -- Post Failure
4392 --   Error handled by procedure
4393 --
4394 -- Access Status
4395 --   Internal table handler use only.
4396 --
4397 Procedure chk_pay_term_end_month_cd
4398   (p_position_id               in number
4399   ,p_pay_term_end_month_cd   in varchar2
4400   ,p_effective_date            in date
4401   ,p_validation_start_date     in date
4402   ,p_validation_end_date       in date
4403   ,p_object_version_number     in number) is
4404   --
4405   l_proc         varchar2(72);
4406   l_api_updating boolean;
4407   --
4408 Begin
4409   --
4410 if g_debug then
4411   l_proc          := g_package||'chk_pay_term_end_month_cd';
4412   hr_utility.set_location('Entering:'||l_proc, 5);
4413 end if;
4414   --
4415   l_api_updating := hr_psf_shd.api_updating
4416     (p_position_id            => p_position_id
4417     ,p_effective_date         => p_effective_date
4418     ,p_object_version_number  => p_object_version_number);
4419   --
4420   if (l_api_updating
4421       and p_pay_term_end_month_cd
4422       <> nvl(hr_psf_shd.g_old_rec.pay_term_end_month_cd,hr_api.g_varchar2)
4423       or not l_api_updating)
4424       and p_pay_term_end_month_cd is not null then
4425     --
4426     -- check if value of lookup falls within lookup type.
4427     --
4428     if hr_api.not_exists_in_dt_hr_lookups
4429           (p_lookup_type           => 'MONTH_CODE'
4430           ,p_lookup_code           => p_pay_term_end_month_cd
4431           ,p_validation_start_date => p_validation_start_date
4432           ,p_validation_end_date   => p_validation_end_date
4433           ,p_effective_date        => p_effective_date) then
4434       --
4435       -- raise error as does not exist as lookup
4436       --
4437       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4438       hr_utility.raise_error;
4439       --
4440     end if;
4441     --
4442   end if;
4443   --
4444 if g_debug then
4445   hr_utility.set_location('Leaving:'||l_proc,10);
4446 end if;
4447   --
4448 end chk_pay_term_end_month_cd;
4449 --
4450 --
4451 -- ----------------------------------------------------------------------------
4452 -- |------< chk_pay_term_end_day_cd >------|
4453 -- ----------------------------------------------------------------------------
4454 --
4455 -- Description
4456 --   This procedure is used to check that the lookup value is valid.
4457 --
4458 -- Pre Conditions
4459 --   None.
4460 --
4461 -- In Parameters
4462 --   position_id                   PK of record being inserted or updated.
4463 --   pay_term_end_day_cd                 Value of lookup code.
4464 --   validation_start_date
4465 --   validation_end_Date
4466 --   date_effective
4467 --   effective_date                effective date
4468 --   object_version_number         Object version number of record being
4469 --
4470 -- Post Success
4471 --   Processing continues
4472 --
4473 -- Post Failure
4474 --   Error handled by procedure
4475 --
4476 -- Access Status
4477 --   Internal table handler use only.
4478 --
4479 Procedure chk_pay_term_end_day_cd
4480   (p_position_id               in number
4481   ,p_pay_term_end_day_cd   in varchar2
4482   ,p_effective_date            in date
4483   ,p_validation_start_date     in date
4484   ,p_validation_end_date       in date
4485   ,p_object_version_number     in number) is
4486   --
4487   l_proc         varchar2(72) ;
4488   l_api_updating boolean;
4489   --
4490 Begin
4491   --
4492 if g_debug then
4493   l_proc          := g_package||'chk_pay_term_end_day_cd';
4494   hr_utility.set_location('Entering:'||l_proc, 5);
4495 end if;
4496   --
4497   l_api_updating := hr_psf_shd.api_updating
4498     (p_position_id            => p_position_id
4499     ,p_effective_date         => p_effective_date
4500     ,p_object_version_number  => p_object_version_number);
4501   --
4502   if (l_api_updating
4503       and p_pay_term_end_day_cd
4504       <> nvl(hr_psf_shd.g_old_rec.pay_term_end_day_cd,hr_api.g_varchar2)
4505       or not l_api_updating)
4506       and p_pay_term_end_day_cd is not null then
4507     --
4508     -- check if value of lookup falls within lookup type.
4509     --
4510     if hr_api.not_exists_in_dt_hr_lookups
4511           (p_lookup_type           => 'DAY_CODE'
4512           ,p_lookup_code           => p_pay_term_end_day_cd
4513           ,p_validation_start_date => p_validation_start_date
4514           ,p_validation_end_date   => p_validation_end_date
4515           ,p_effective_date        => p_effective_date) then
4516       --
4517       -- raise error as does not exist as lookup
4518       --
4519       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4520       hr_utility.raise_error;
4521       --
4522     end if;
4523     --
4524   end if;
4525   --
4526 if g_debug then
4527   hr_utility.set_location('Leaving:'||l_proc,10);
4528 end if;
4529   --
4530 end chk_pay_term_end_day_cd;
4531 --
4532 --
4533 -- ----------------------------------------------------------------------------
4534 -- |------< chk_overlap_unit_cd >------|
4535 -- ----------------------------------------------------------------------------
4536 --
4537 -- Description
4538 --   This procedure is used to check that the lookup value is valid.
4539 --
4540 -- Pre Conditions
4541 --   None.
4542 --
4543 -- In Parameters
4544 --   position_id                   PK of record being inserted or updated.
4545 --   overlap_unit_cd                 Value of lookup code.
4546 --   validation_start_date
4547 --   validation_end_Date
4548 --   date_effective
4549 --   effective_date                effective date
4550 --   object_version_number         Object version number of record being
4551 --
4552 -- Post Success
4553 --   Processing continues
4554 --
4555 -- Post Failure
4556 --   Error handled by procedure
4557 --
4558 -- Access Status
4559 --   Internal table handler use only.
4560 --
4561 Procedure chk_overlap_unit_cd
4562   (p_position_id               in number
4563   ,p_overlap_unit_cd   in varchar2
4564   ,p_effective_date            in date
4565   ,p_validation_start_date     in date
4566   ,p_validation_end_date       in date
4567   ,p_object_version_number     in number) is
4568   --
4569   l_proc         varchar2(72);
4570   l_api_updating boolean;
4571   --
4572 Begin
4573   --
4574 if g_debug then
4575   l_proc          := g_package||'chk_overlap_unit_cd';
4576   hr_utility.set_location('Entering:'||l_proc, 5);
4577 end if;
4578   --
4579   l_api_updating := hr_psf_shd.api_updating
4580     (p_position_id            => p_position_id
4581     ,p_effective_date         => p_effective_date
4582     ,p_object_version_number  => p_object_version_number);
4583   --
4584   if (l_api_updating
4585       and p_overlap_unit_cd
4586       <> nvl(hr_psf_shd.g_old_rec.overlap_unit_cd,hr_api.g_varchar2)
4587       or not l_api_updating)
4588       and p_overlap_unit_cd is not null then
4589     --
4590     -- check if value of lookup falls within lookup type.
4591     --
4592     if hr_api.not_exists_in_dt_hr_lookups
4593           (p_lookup_type           => 'FREQUENCY'
4594           ,p_lookup_code           => p_overlap_unit_cd
4595           ,p_validation_start_date => p_validation_start_date
4596           ,p_validation_end_date   => p_validation_end_date
4597           ,p_effective_date        => p_effective_date) then
4598       --
4599       -- raise error as does not exist as lookup
4600       --
4601       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4602       hr_utility.raise_error;
4603       --
4604     end if;
4605     --
4606   end if;
4607   --
4608 if g_debug then
4609   hr_utility.set_location('Leaving:'||l_proc,10);
4610 end if;
4611   --
4612 end chk_overlap_unit_cd;
4613 --
4614 --
4615 -- ----------------------------------------------------------------------------
4616 -- |------< chk_bargaining_unit_cd >------|
4617 -- ----------------------------------------------------------------------------
4618 --
4619 -- Description
4620 --   This procedure is used to check that the lookup value is valid.
4621 --
4622 -- Pre Conditions
4623 --   None.
4624 --
4625 -- In Parameters
4626 --   position_id                   PK of record being inserted or updated.
4627 --   bargaining_unit_cd                 Value of lookup code.
4628 --   validation_start_date
4629 --   validation_end_Date
4630 --   date_effective
4631 --   effective_date                effective date
4632 --   object_version_number         Object version number of record being
4633 --
4634 -- Post Success
4635 --   Processing continues
4636 --
4637 -- Post Failure
4638 --   Error handled by procedure
4639 --
4640 -- Access Status
4641 --   Internal table handler use only.
4642 --
4643 Procedure chk_bargaining_unit_cd
4644   (p_position_id               in number
4645   ,p_bargaining_unit_cd   in varchar2
4646   ,p_effective_date            in date
4647   ,p_validation_start_date     in date
4648   ,p_validation_end_date       in date
4649   ,p_object_version_number     in number) is
4650   --
4651   l_proc         varchar2(72);
4652   l_api_updating boolean;
4653   --
4654 Begin
4655   --
4656 if g_debug then
4657   l_proc          := g_package||'chk_bargaining_unit_cd';
4658   hr_utility.set_location('Entering:'||l_proc, 5);
4659 end if;
4660   --
4661   l_api_updating := hr_psf_shd.api_updating
4662     (p_position_id            => p_position_id
4663     ,p_effective_date         => p_effective_date
4664     ,p_object_version_number  => p_object_version_number);
4665   --
4666   if (l_api_updating
4667       and p_bargaining_unit_cd
4668       <> nvl(hr_psf_shd.g_old_rec.bargaining_unit_cd,hr_api.g_varchar2)
4669       or not l_api_updating)
4670       and p_bargaining_unit_cd is not null then
4671     --
4672     -- check if value of lookup falls within lookup type.
4673     --
4674     if hr_api.not_exists_in_dt_hr_lookups
4675           (p_lookup_type           => 'BARGAINING_UNIT_CODE'
4676           ,p_lookup_code           => p_bargaining_unit_cd
4677           ,p_validation_start_date => p_validation_start_date
4678           ,p_validation_end_date   => p_validation_end_date
4679           ,p_effective_date        => p_effective_date) then
4680       --
4681       -- raise error as does not exist as lookup
4682       --
4683       hr_utility.set_message(800,'HR_LOOKUP_DOES_NOT_EXIST');
4684       hr_utility.raise_error;
4685       --
4686     end if;
4687     --
4688   end if;
4689   --
4690 if g_debug then
4691   hr_utility.set_location('Leaving:'||l_proc,10);
4692 end if;
4693   --
4694 end chk_bargaining_unit_cd;
4695 --
4696 -- ------------------ <chk_fte> ---------------------
4697 --
4698 Procedure chk_fte
4699   (p_position_id               in number
4700   ,p_fte                       in number
4701   ,p_position_type             in varchar2
4702   ,p_effective_date            in date
4703   ,p_validation_start_date     in date
4704   ,p_validation_end_date       in date
4705   ,p_object_version_number     in number) is
4706   --
4707   l_proc         varchar2(72) ;
4708   l_api_updating boolean;
4709   --
4710 Begin
4711   --
4712 if g_debug then
4713  l_proc          := g_package||'chk_fte';
4714   hr_utility.set_location('Entering:'||l_proc, 5);
4715 end if;
4716   --
4717   hr_api.mandatory_arg_error
4718       (p_api_name       => l_proc
4719       ,p_argument       => 'position type'
4720       ,p_argument_value => p_position_type);
4721     --
4722   --
4723   hr_api.mandatory_arg_error
4724       (p_api_name       => l_proc
4725       ,p_argument       => 'validation start date'
4726       ,p_argument_value => p_validation_start_date);
4727     --
4728   --
4729   hr_api.mandatory_arg_error
4730       (p_api_name       => l_proc
4731       ,p_argument       => 'effective date'
4732       ,p_argument_value => p_effective_date);
4733     --
4734   l_api_updating := hr_psf_shd.api_updating
4735     (p_position_id            => p_position_id
4736     ,p_effective_date         => p_effective_date
4737     ,p_object_version_number  => p_object_version_number);
4738   --
4739   if ((l_api_updating
4740       and ((p_fte <> nvl(hr_psf_shd.g_old_rec.fte,hr_api.g_number))
4741          or (p_position_type <> nvl(hr_psf_shd.g_old_rec.position_type,
4742                      hr_api.g_varchar2))))
4743       or not l_api_updating) then
4744       --
4745       if p_position_type <> 'NONE' then
4746         if ( p_fte is null and p_position_type <> 'POOLED') then
4747           hr_utility.set_message(800,'HR_FTE_NULL_INV_FOR_POS_TYPE');
4748           hr_utility.raise_error;
4749         elsif p_position_type = 'SINGLE' then
4750           if not (p_fte <= 1) then
4751             hr_utility.set_message(800,'HR_FTE_MUST_BE_LESS_OR_EQ_ONE');
4752             hr_utility.raise_error;
4753           end if;
4754         end if;
4755       end if;
4756       --
4757   end if;
4758   --
4759 end chk_fte;
4760 --
4761 -- ------------------ <chk_max_persons> ---------------------
4762 --
4763 Procedure chk_max_persons
4764   (p_position_id               in number
4765   ,p_max_persons               in number
4766   ,p_position_type             in varchar2
4767   ,p_effective_date            in date
4768   ,p_object_version_number     in number) is
4769   --
4770   l_proc         varchar2(72) ;
4771   l_api_updating boolean;
4772   --
4773 Begin
4774   --
4775 if g_debug then
4776  l_proc          := g_package||'p_max_persons';
4777   hr_utility.set_location('Entering:'||l_proc, 5);
4778   hr_utility.set_location('Entering:'||p_max_persons, 2);
4779 
4780 hr_utility.set_location('Entering:'||
4781      nvl(hr_psf_shd.g_old_rec.max_persons,hr_api.g_number),3);
4782 end if;
4783   --
4784   hr_api.mandatory_arg_error
4785       (p_api_name       => l_proc
4786       ,p_argument       => 'position type'
4787       ,p_argument_value => p_position_type);
4788   --
4789   hr_api.mandatory_arg_error
4790       (p_api_name       => l_proc
4791       ,p_argument       => 'effective date'
4792       ,p_argument_value => p_effective_date);
4793   --
4794   l_api_updating := hr_psf_shd.api_updating
4795     (p_position_id            => p_position_id
4796     ,p_effective_date         => p_effective_date
4797     ,p_object_version_number  => p_object_version_number);
4798   --
4799   if ((l_api_updating
4800     and ((nvl(p_max_persons,hr_api.g_number) <>
4801        nvl(hr_psf_shd.g_old_rec.max_persons,hr_api.g_number))
4802          or (p_position_type <> nvl(hr_psf_shd.g_old_rec.position_type,
4803                      hr_api.g_varchar2))))
4804       or not l_api_updating) then
4805       --
4806       if (p_position_type = 'SINGLE')
4807         and ((p_max_persons is NULL) or (p_max_persons <> 1 )) then
4808           hr_utility.set_message(800,'HR_POS_MAX_PERSONS_NE_ONE');
4809           hr_utility.raise_error;
4810       elsif (p_position_type = 'SHARED') and (p_max_persons IS NULL )
4811        then
4812           hr_utility.set_message(800,'HR_MAX_PERS_NULL_INV_POS_TYPE');
4813           hr_utility.raise_error;
4814       elsif (p_position_type = 'SHARED') and (p_max_persons < 1 )
4815        then
4816           hr_utility.set_message(800,'PER_INVALID_SHARED_MAX_PERSON');
4817           hr_utility.raise_error;
4818       end if;
4819       --
4820   end if;
4821   --
4822 end chk_max_persons;
4823 --
4824 -- ---------------------------------------------------------------------------
4825 -- --------------------------< chk_resesrved_fte >----------------------------
4826 -- ---------------------------------------------------------------------------
4827 
4828 Procedure chk_reserved_fte
4829   (p_position_id               in number
4830   ,p_fte                       in number
4831   ,p_position_type             in varchar2
4832   ,p_effective_date            in date
4833   ,p_validation_start_date     in date
4834   ,p_validation_end_date       in date
4835   ,p_object_version_number     in number) is
4836 
4837   l_proc         varchar2(72) ;
4838   l_api_updating boolean;
4839   l_rsv_fte   number;
4840 
4841 cursor csr_valid_fte(p_position_id number, p_effective_date date) is
4842 select sum(poei_information6) fte
4843 from per_position_extra_info
4844 where position_id = p_position_id
4845 and information_type= 'PER_RESERVED'
4846 and p_effective_date
4847   between fnd_date.canonical_to_date(poei_information3)
4848   and nvl(fnd_date.canonical_to_date(poei_information4),hr_general.end_of_time);
4849   --
4850 cursor csr_valid_eff_date(p_position_id number,
4851                           p_validation_start_date date,
4852                           p_validation_end_date date) is
4853 select p_validation_start_date start_date
4854 from dual
4855 union
4856 select effective_start_date start_date
4857 from hr_all_positions_f
4858 where effective_start_date between p_validation_start_date
4859 and p_validation_end_date
4860 and position_id = p_position_id
4861 union
4862 select start_date
4863 from (select fnd_date.canonical_to_date(poei_information3) start_date
4864       from per_position_extra_info
4865       where position_id = p_position_id
4866       and information_type = 'PER_RESERVED') a
4867 where a.start_date between p_validation_start_date and p_validation_end_date;
4868 Begin
4869   --
4870 if g_debug then
4871   l_proc       := 'chk_reserved_fte';
4872   hr_utility.set_location('Entering:'||l_proc, 5);
4873 end if;
4874   --
4875   hr_api.mandatory_arg_error
4876       (p_api_name       => l_proc
4877       ,p_argument       => 'position type'
4878       ,p_argument_value => p_position_type);
4879     --
4880   --
4881   hr_api.mandatory_arg_error
4882       (p_api_name       => l_proc
4883       ,p_argument       => 'validation start date'      ,p_argument_value => p_validation_start_date);
4884     --
4885   --
4886   hr_api.mandatory_arg_error
4887       (p_api_name       => l_proc
4888       ,p_argument       => 'effective date'
4889       ,p_argument_value => p_effective_date);
4890     --
4891   l_api_updating := hr_psf_shd.api_updating
4892     (p_position_id            => p_position_id
4893     ,p_effective_date         => p_effective_date
4894     ,p_object_version_number  => p_object_version_number);
4895   --
4896 
4897   if (l_api_updating
4898       and p_fte
4899       <> nvl(hr_psf_shd.g_old_rec.fte,hr_api.g_number)
4900       ) then
4901       --
4902     for r2 in csr_valid_eff_date(p_position_id, p_validation_start_date, p_validation_end_date) loop
4903     if p_position_type ='SHARED' or p_position_type ='SINGLE' then
4904         open csr_valid_fte(p_position_id, r2.start_date);
4905          fetch csr_valid_fte into l_rsv_fte;
4906          if (p_fte < l_rsv_fte) then
4907             hr_utility.set_message(800,'PER_FTE_LT_RSVD_FTE');
4908             hr_utility.set_message_token('POSITION_FTE',p_fte);
4909             hr_utility.set_message_token('RESERVED_FTE',l_rsv_fte);
4910             hr_utility.set_message_token('EFFECTIVE_DATE',r2.start_date);
4911             hr_utility.raise_error;
4912          else
4913 if g_debug then
4914             hr_utility.set_location(l_proc, 3);
4915 end if;
4916          end if;
4917       --
4918        close csr_valid_fte;
4919     end if;
4920     end loop;
4921   end if;
4922   --
4923 end chk_reserved_fte;
4924 
4925 -- ---------------------------------------------------------------------------
4926 -- --------------------------< chk_proposed_fte_for_layoff >------------------
4927 -- ---------------------------------------------------------------------------
4928 Procedure chk_proposed_fte_for_layoff
4929 ( p_fte                      in number
4930  ,p_proposed_fte_for_layoff  in number
4931  ,p_proposed_date_for_layoff in date) is
4932 
4933  --
4934  l_proc    varchar2(30);
4935 Begin
4936   --
4937 if g_debug then
4938  l_proc    :='chk_proposed_fte_for_layoff';
4939   hr_utility.set_location('Entering:'||l_proc, 5);
4940 end if;
4941   --
4942   if p_proposed_fte_for_layoff is not null then
4943     if nvl(p_fte, 0) < p_proposed_fte_for_layoff then
4944       --
4945        hr_utility.set_message(800,'HR_FTE_TARGT_LT_LAYOFF_FTE');
4946        hr_utility.raise_error;
4947     end if;
4948     if p_proposed_date_for_layoff is null then
4949       --
4950        hr_utility.set_message(800,'HR_PROP_DT_LAYOFF_CANNOT_NULL');
4951        hr_utility.raise_error;
4952     end if;
4953   else
4954     if p_proposed_date_for_layoff is not null then
4955       --
4956        hr_utility.set_message(800,'HR_PROP_DT_LAYOFF_MUSTBE_NULL');
4957        hr_utility.raise_error;
4958     end if;
4959   end if;
4960 end chk_proposed_fte_for_layoff;
4961 --
4962 -- ----------------------------------------------------------------------------
4963 -- |--------------------------< chk_extended_pay >--------------------------|
4964 -- ----------------------------------------------------------------------------
4965 Procedure chk_extended_pay
4966   (p_position_id               in number
4967   ,p_work_period_type_cd       in varchar2
4968   ,p_term_start_day_cd         in varchar2
4969   ,p_term_start_month_cd       in varchar2
4970   ,p_pay_term_end_day_cd       in varchar2
4971   ,p_pay_term_end_month_cd     in varchar2
4972   ,p_work_term_end_day_cd      in varchar2
4973   ,p_work_term_end_month_cd    in varchar2 ) is
4974   --
4975   l_proc varchar2(30);
4976 Begin
4977   --
4978 if g_debug then
4979 l_proc :='chk_extended_flag';
4980   hr_utility.set_location('Entering:'||l_proc, 5);
4981 end if;
4982   --
4983   if p_work_period_type_cd = 'Y' then
4984 /*
4985     if p_pay_term_end_day_cd is null    or
4986        p_pay_term_end_month_cd is null  or
4987        p_work_term_end_day_cd is null   or
4988        p_work_term_end_month_cd is null     then
4989       --
4990        hr_utility.set_message(800,'HR_PAY_WORK_TERM_MUST_BE_ENTR');
4991        hr_utility.raise_error;
4992 */
4993     if (( (p_pay_term_end_day_cd is null and
4994           p_pay_term_end_month_cd is not null)  or
4995          (p_pay_term_end_day_cd is not null and
4996           p_pay_term_end_month_cd is null)) or
4997        ( (p_term_start_day_cd is null and
4998           p_term_start_month_cd is not null)  or
4999          (p_term_start_day_cd is not null and
5000           p_term_start_month_cd is null))) then
5001       --
5002        hr_utility.set_message(800,'HR_INVALID_PAY_TERM');
5003        hr_utility.raise_error;
5004     end if;
5005     if ( (p_work_term_end_day_cd is null and
5006           p_work_term_end_month_cd is not null)  or
5007          (p_work_term_end_day_cd is not null and
5008           p_work_term_end_month_cd is null)) then
5009       --
5010        hr_utility.set_message(800,'HR_INVALID_WORK_TERM');
5011        hr_utility.raise_error;
5012     end if;
5013   else
5014     if p_pay_term_end_day_cd is not null    or
5015        p_pay_term_end_month_cd is not null  or
5016        p_term_start_day_cd is not null    or
5017        p_term_start_month_cd is not null  or
5018        p_work_term_end_day_cd is not null   or
5019        p_work_term_end_month_cd is not null     then
5020       --
5021        hr_utility.set_message(800,'HR_PAY_WORK_TERM_MUST_BE_NULL');
5022        hr_utility.raise_error;
5023     end if;
5024   end if;
5025   --
5026 end chk_extended_pay;
5027 -- ----------------------------------------------------------------------------
5028 -- |--------------------------<  chk_seasonal_poi  >--------------------------|
5029 -- ----------------------------------------------------------------------------
5030 procedure chk_seasonal_poi
5031 (p_position_id              in number
5032   ,p_seasonal_flag          in varchar2
5033   ,p_effective_date            in date
5034   ,p_validation_start_date     in date
5035   ,p_validation_end_date       in date
5036   ,p_object_version_number     in number) is
5037 l_dummy             varchar2(1);
5038 l_api_updating     boolean;
5039 
5040 cursor c_seasonal is
5041 select 'X'
5042 from per_position_extra_info
5043 where position_id = p_position_id
5044 and information_type = 'PER_SEASONAL';
5045 begin
5046   l_api_updating := hr_psf_shd.api_updating
5047     (p_position_id            => p_position_id
5048     ,p_effective_date         => p_effective_date
5049     ,p_object_version_number  => p_object_version_number);
5050 
5051   if (l_api_updating
5052       and p_seasonal_flag
5053       <> nvl(hr_psf_shd.g_old_rec.seasonal_flag,hr_api.g_varchar2)
5054       and (p_seasonal_flag='N' or p_seasonal_flag is null)) then
5055     open c_seasonal;
5056     fetch c_seasonal into l_dummy;
5057     if c_seasonal%found then
5058           close c_seasonal;
5059           hr_utility.set_message(800,'HR_INV_SEASONAL_FLAG');
5060           hr_utility.raise_error;
5061     end if;
5062     close c_seasonal;
5063   end if;
5064 end;
5065 -- ----------------------------------------------------------------------------
5066 -- |--------------------------<   chk_overlap_poi  >--------------------------|
5067 -- ----------------------------------------------------------------------------
5068 procedure chk_overlap_poi
5069 (p_position_id              in number
5070   ,p_overlap_period         in number
5071   ,p_effective_date            in date
5072   ,p_validation_start_date     in date
5073   ,p_validation_end_date       in date
5074   ,p_object_version_number     in number) is
5075 l_proc varchar2(100) ;
5076 l_dummy             varchar2(1);
5077 l_api_updating     boolean;
5078 --
5079 cursor c_overlap is
5080 select 'X'
5081 from per_position_extra_info
5082 where position_id = p_position_id
5083 and information_type = 'PER_OVERLAP';
5084 begin
5085 if g_debug then
5086 l_proc  :='chk_overlap_poi';
5087   hr_utility.set_location('Entering:'||l_proc,10);
5088 end if;
5089   l_api_updating := hr_psf_shd.api_updating
5090     (p_position_id            => p_position_id
5091     ,p_effective_date         => p_effective_date
5092     ,p_object_version_number  => p_object_version_number);
5093 
5094   if (l_api_updating
5095       and nvl(p_overlap_period,-1)
5096       <> nvl(hr_psf_shd.g_old_rec.overlap_period,hr_api.g_number)
5097       and p_overlap_period is null) then
5098 if g_debug then
5099     hr_utility.set_location('Checking for Overlap Dates in Position Extra Info:'||l_proc,20);
5100 end if;
5101     open c_overlap;
5102     fetch c_overlap into l_dummy;
5103 if g_debug then
5104     hr_utility.set_location('Checked for Overlap Dates in Position Extra Info:'||l_proc,30);
5105 end if;
5106     if c_overlap%found then
5107 if g_debug then
5108     hr_utility.set_location('Overlap Dates Found in Position Extra Info:'||l_proc,40);
5109 end if;
5110           close c_overlap;
5111           hr_utility.set_message(800,'HR_INV_OVERLAP_PERIOD');
5112           hr_utility.raise_error;
5113     end if;
5114 if g_debug then
5115     hr_utility.set_location('Overlap Dates not Found in Position Extra Info:'||l_proc,40);
5116 end if;
5117     close c_overlap;
5118   end if;
5119 if g_debug then
5120   hr_utility.set_location('Leaving:'||l_proc,20);
5121 end if;
5122 end;
5123 -- ----------------------------------------------------------------------------
5124 -- |--------------------------< permit_extended_pay >-------------------------|
5125 -- ----------------------------------------------------------------------------
5126 function permit_extended_pay(p_position_id varchar2) return boolean is
5127 l_proc varchar2(100) ;
5128 l_position_family   varchar2(100);
5129 l_chk               boolean := false;
5130 cursor c1 is
5131 select poei_information3
5132 from per_position_extra_info
5133 where position_id = p_position_id
5134 and information_type = 'PER_FAMILY'
5135 and poei_information3 in ('ACADEMIC','FACULTY');
5136 begin
5137 if g_debug then
5138 l_proc  :='PERMIT_EXTENDED_PAY';
5139   hr_utility.set_location('Entering:'||l_proc,10);
5140 end if;
5141   if p_position_id is not null then
5142     open c1;
5143     fetch c1 into l_position_family;
5144     if c1%found then
5145 if g_debug then
5146       hr_utility.set_location('Academic/Faculty Position Extra info Found:'||l_proc,10);
5147 end if;
5148       close c1;
5149       return true;
5150     else
5151       close c1;
5152 if g_debug then
5153       hr_utility.set_location('Academic/Faculty Position Extra info not Found:'||l_proc,10);
5154 end if;
5155       return false;
5156     end if;
5157   else
5158     return(false);
5159   end if;
5160 if g_debug then
5161     hr_utility.set_location('Leaving:'||l_proc,20);
5162 end if;
5163 end;
5164 -- ----------------------------------------------------------------------------
5165 -- |--------------------------< chk_extended_pay_permit >--------------------------|
5166 -- ----------------------------------------------------------------------------
5167 procedure chk_extended_pay_permit
5168 (p_position_id           in number
5169   ,p_work_period_type_cd       in varchar2
5170   ,p_effective_date            in date
5171   ,p_validation_start_date     in date
5172   ,p_validation_end_date       in date
5173   ,p_object_version_number     in number
5174 ) is
5175 l_proc         varchar2(100);
5176 l_api_updating    boolean;
5177 l_permit_extended_pay   boolean;
5178 begin
5179 if g_debug then
5180 l_proc   :='chk_extended_pay_permit';
5181     hr_utility.set_location('Entering:'||l_proc,10);
5182 end if;
5183   l_api_updating := hr_psf_shd.api_updating
5184     (p_position_id            => p_position_id
5185     ,p_effective_date         => p_effective_date
5186     ,p_object_version_number  => p_object_version_number);
5187 
5188   if (((l_api_updating and p_work_period_type_cd
5189       <> nvl(hr_psf_shd.g_old_rec.work_period_type_cd,hr_api.g_varchar2)) or not l_api_updating)
5190       and nvl(p_WORK_PERIOD_TYPE_CD,'N') = 'Y') then
5191 if g_debug then
5192     hr_utility.set_location('Check permit_extended_pay:'||l_proc,10);
5193 end if;
5194     l_permit_extended_pay := permit_extended_pay(p_position_id => p_position_id);
5195 if g_debug then
5196         hr_utility.set_location('Checking permit_extended_pay complete:'||l_proc,10);
5197 end if;
5198     if (l_permit_extended_pay = false)  then
5199       --Position family is neither Academic nor Faculty, so Extended pay cannot be permitted.
5200       hr_utility.set_message(800,'HR_INV_EXTD_PAY_PERMIT');
5201       hr_utility.raise_error;
5202     end if;
5203   end if;
5204 if g_debug then
5205     hr_utility.set_location('Leaving:'||l_proc,20);
5206 end if;
5207 end;
5208 --
5209 --
5210 -- ----------------------------------------------------------------------------
5211 -- |-------------------< chk_position_type_single >---------------------------|
5212 -- ----------------------------------------------------------------------------
5213 --
5214 -- Description
5215 --   This procedure is used to check for invalid uptation os position type
5216 --    to Single.
5217 --
5218 -- Pre Conditions
5219 --   None.
5220 --
5221 -- In Parameters
5222 --   position_id                   PK of record being inserted or updated.
5223 --   p_position_type
5224 --   validation_start_date
5225 --   validation_end_Date
5226 --   date_effective
5227 --   effective_date                effective date
5228 --   object_version_number         Object version number of record being
5229 --
5230 -- Post Success
5231 --   Processing continues
5232 --
5233 -- Post Failure
5234 --   Error handled by procedure
5235 --
5236 -- Access Status
5237 --   Internal table handler use only.
5238 --
5239 Procedure chk_position_type_single
5240   (p_position_id               in number
5241   ,p_position_type             in varchar2
5242   ,p_effective_date            in date
5243   ,p_object_version_number     in number) is
5244   --
5245   l_proc         varchar2(72) ;
5246   l_api_updating boolean;
5247   l_no_assignments  number;
5248   --
5249   cursor c_no_assignments(p_position_id number, p_effective_date date) is
5250   select count(1)
5251   from per_all_assignments_f asg, per_assignment_status_types ast
5252   where asg.position_id = p_position_id
5253   and p_effective_date between asg.effective_start_date and asg.effective_end_date
5254   and asg.assignment_type in ('E', 'C')
5255   and asg.assignment_status_type_id = ast.assignment_status_type_id
5256   and ast.per_system_status <> 'TERM_ASSIGN';
5257   --
5258 Begin
5259   --
5260 if g_debug then
5261   l_proc         := g_package||'chk_position_type_single';
5262   hr_utility.set_location('Entering:'||l_proc, 5);
5263 end if;
5264   --
5265   l_api_updating := hr_psf_shd.api_updating
5266     (p_position_id            => p_position_id
5267     ,p_effective_date         => p_effective_date
5268     ,p_object_version_number  => p_object_version_number);
5269   --
5270   if (l_api_updating
5271       and p_position_type
5272       <> nvl(hr_psf_shd.g_old_rec.position_type,hr_api.g_varchar2))
5273   then
5274     --
5275     -- check if value of lookup falls within lookup type.
5276     --
5277     if ((p_position_type = 'SINGLE')
5278         and (nvl(hr_psf_shd.g_old_rec.position_type,hr_api.g_varchar2)
5279         <> 'SINGLE' )) then
5280       open c_no_assignments(p_position_id, p_effective_date);
5281       fetch c_no_assignments into l_no_assignments;
5282       close c_no_assignments;
5283       if l_no_assignments > 1 then
5284         --
5285         -- raise error as does not exist as lookup
5286         --
5287         hr_utility.set_message(800,'PER_CANNOT_CHG_POS_SINGLE');
5288         hr_utility.raise_error;
5289         --
5290       end if;
5291       --
5292     end if;
5293     --
5294   end if;
5295   --
5296 if g_debug then
5297   hr_utility.set_location('Leaving:'||l_proc,10);
5298 end if;
5299   --
5300 end chk_position_type_single;
5301 --
5302 -- ----------------------------------------------------------------------------
5303 -- |--------------------------< dt_update_validate >--------------------------|
5304 -- ----------------------------------------------------------------------------
5305 -- {Start Of Comments}
5306 --
5307 -- Description:
5308 --   This procedure is used for referential integrity of datetracked
5309 --   parent entities when a datetrack update operation is taking place
5310 --   and where there is no cascading of update defined for this entity.
5311 --
5312 -- Prerequisites:
5313 --   This procedure is called from the update_validate.
5314 --
5315 -- In Parameters:
5316 --
5317 -- Post Success:
5318 --   Processing continues.
5319 --
5320 -- Post Failure:
5321 --
5322 -- Developer Implementation Notes:
5323 --   This procedure should not need maintenance unless the HR Schema model
5324 --   changes.
5325 --
5326 -- Access Status:
5327 --   Internal Row Handler Use Only.
5328 --
5329 -- {End Of Comments}
5330 -- ----------------------------------------------------------------------------
5331 Procedure dt_update_validate
5332             (p_relief_position_id            in number default hr_api.g_number,
5333              p_successor_position_id         in number default hr_api.g_number,
5334              p_supervisor_position_id        in number default hr_api.g_number,
5335              p_pay_freq_payroll_id           in number default hr_api.g_number,
5336              p_entry_grade_rule_id           in number default hr_api.g_number,
5337              p_entry_step_id                 in number default hr_api.g_number,
5338              p_datetrack_mode                in varchar2,
5339              p_validation_start_date         in date,
5340              p_validation_end_date           in date) Is
5341 --
5342   l_proc     varchar2(72) ;
5343   l_integrity_error Exception;
5344   l_table_name     all_tables.table_name%TYPE;
5345 --
5346 Begin
5347 if g_debug then
5348   l_proc   := g_package||'dt_update_validate';
5349   hr_utility.set_location('Entering:'||l_proc, 5);
5350 end if;
5351   --
5352   -- Ensure that the p_datetrack_mode argument is not null
5353   --
5354   hr_api.mandatory_arg_error
5355     (p_api_name       => l_proc,
5356      p_argument       => 'datetrack_mode',
5357      p_argument_value => p_datetrack_mode);
5358   --
5359   -- Only perform the validation if the datetrack update mode is valid
5360   --
5361   If (dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode)) then
5362     --
5363     --
5364     -- Ensure the arguments are not null
5365     --
5366     hr_api.mandatory_arg_error
5367       (p_api_name       => l_proc,
5368        p_argument       => 'validation_start_date',
5369        p_argument_value => p_validation_start_date);
5370     --
5371     hr_api.mandatory_arg_error
5372       (p_api_name       => l_proc,
5373        p_argument       => 'validation_end_date',
5374        p_argument_value => p_validation_end_date);
5375     --
5376 -- ##
5377 if g_debug then
5378     hr_utility.set_location(l_proc,20 );
5379 end if;
5380     If ((nvl(p_relief_position_id, hr_api.g_number) <> hr_api.g_number) and
5381       NOT (dt_api.check_min_max_dates
5382             (p_base_table_name => 'hr_all_positions_f',
5383              p_base_key_column => 'position_id',
5384              p_base_key_value  => p_relief_position_id,
5385              p_from_date       => p_validation_start_date,
5386              p_to_date         => p_validation_end_date)))  Then
5387       l_table_name := 'all positions';
5388       Raise l_integrity_error;
5389     End If;
5390 if g_debug then
5391     hr_utility.set_location(l_proc,30 );
5392 end if;
5393     If ((nvl(p_successor_position_id, hr_api.g_number) <> hr_api.g_number) and
5394       NOT (dt_api.check_min_max_dates
5395             (p_base_table_name => 'hr_all_positions_f',
5396              p_base_key_column => 'position_id',
5397              p_base_key_value  => p_successor_position_id,
5398              p_from_date       => p_validation_start_date,
5399              p_to_date         => p_validation_end_date)))  Then
5400       l_table_name := 'all positions';
5401       Raise l_integrity_error;
5402     End If;
5403 if g_debug then
5404     hr_utility.set_location(l_proc,40 );
5405 end if;
5406     If ((nvl(p_supervisor_position_id, hr_api.g_number) <> hr_api.g_number) and
5407       NOT (dt_api.check_min_max_dates
5408             (p_base_table_name => 'hr_all_positions_f',
5409              p_base_key_column => 'position_id',
5410              p_base_key_value  => p_supervisor_position_id,
5411              p_from_date       => p_validation_start_date,
5412              p_to_date         => p_validation_end_date)))  Then
5413       l_table_name := 'all positions';
5414       Raise l_integrity_error;
5415     End If;
5416 if g_debug then
5417     hr_utility.set_location(l_proc,50 );
5418 end if;
5419     If ((nvl(p_pay_freq_payroll_id, hr_api.g_number) <> hr_api.g_number) and
5420       NOT (dt_api.check_min_max_dates
5421             (p_base_table_name => 'pay_all_payrolls_f',
5422              p_base_key_column => 'payroll_id',
5423              p_base_key_value  => p_pay_freq_payroll_id,
5424              p_from_date       => p_validation_start_date,
5425              p_to_date         => p_validation_end_date)))  Then
5426       l_table_name := 'all payrolls';
5427       Raise l_integrity_error;
5428     End If;
5429 if g_debug then
5430     hr_utility.set_location(l_proc,60 );
5431 end if;
5432     If ((nvl(p_entry_step_id, hr_api.g_number) <> hr_api.g_number) and
5433       NOT (dt_api.check_min_max_dates
5434             (p_base_table_name => 'per_spinal_point_steps_f',
5435              p_base_key_column => 'step_id',
5436              p_base_key_value  => p_entry_step_id,
5437              p_from_date       => p_validation_start_date,
5438              p_to_date         => p_validation_end_date)))  Then
5439       l_table_name := 'spinal point steps';
5440       Raise l_integrity_error;
5441     End If;
5442 if g_debug then
5443     hr_utility.set_location(l_proc,70 );
5444 end if;
5445     If ((nvl(p_entry_grade_rule_id, hr_api.g_number) <> hr_api.g_number) and
5446       NOT (dt_api.check_min_max_dates
5447             (p_base_table_name => 'pay_grade_rules_f',
5448              p_base_key_column => 'grade_rule_id',
5449              p_base_key_value  => p_entry_grade_rule_id,
5450              p_from_date       => p_validation_start_date,
5451              p_to_date         => p_validation_end_date)))  Then
5452       l_table_name := 'grade rules';
5453       Raise l_integrity_error;
5454     End If;
5455 -- ##
5456     --
5457   End If;
5458   --
5459 if g_debug then
5460   hr_utility.set_location(' Leaving:'||l_proc, 10);
5461 end if;
5462 Exception
5463   When l_integrity_error Then
5464     --
5465     -- A referential integrity check was violated therefore
5466     -- we must error
5467     --
5468     hr_utility.set_message(800, 'HR_7216_DT_UPD_INTEGRITY_ERR');
5469     hr_utility.set_message_token('TABLE_NAME', l_table_name);
5470     hr_utility.raise_error;
5471   When Others Then
5472     --
5473     -- An unhandled or unexpected error has occurred which
5474     -- we must report
5475     --
5476     hr_utility.set_message(800, 'HR_6153_ALL_PROCEDURE_FAIL');
5477     hr_utility.set_message_token('PROCEDURE', l_proc);
5478     hr_utility.set_message_token('STEP','15');
5479     hr_utility.raise_error;
5480 End dt_update_validate;
5481 --
5482 -- ----------------------------------------------------------------------------
5483 -- |--------------------------< dt_delete_validate >--------------------------|
5484 -- ----------------------------------------------------------------------------
5485 -- {Start Of Comments}
5486 --
5487 -- Description:
5488 --   This procedure is used for referential integrity of datetracked
5489 --   child entities when either a datetrack DELETE or ZAP is in operation
5490 --   and where there is no cascading of delete defined for this entity.
5491 --   For the datetrack mode of DELETE or ZAP we must ensure that no
5492 --   datetracked child rows exist between the validation start and end
5493 --   dates.
5494 --
5495 -- Prerequisites:
5496 --   This procedure is called from the delete_validate.
5497 --
5498 -- In Parameters:
5499 --
5500 -- Post Success:
5501 --   Processing continues.
5502 --
5503 -- Post Failure:
5504 --   If a row exists by determining the returning Boolean value from the
5505 --   generic dt_api.rows_exist function then we must supply an error via
5506 --   the use of the local exception handler l_rows_exist.
5507 --
5508 -- Developer Implementation Notes:
5509 --   This procedure should not need maintenance unless the HR Schema model
5510 --   changes.
5511 --
5512 -- Access Status:
5513 --   Internal Row Handler Use Only.
5514 --
5515 -- {End Of Comments}
5516 -- ----------------------------------------------------------------------------
5517 Procedure dt_delete_validate
5518             (p_position_id     in number,
5519              p_datetrack_mode     in varchar2,
5520              p_validation_start_date in date,
5521              p_validation_end_date   in date) Is
5522 --
5523   l_proc varchar2(72) ;
5524   l_rows_exist Exception;
5525   l_table_name all_tables.table_name%TYPE;
5526 --
5527 Begin
5528 if g_debug then
5529  l_proc     := g_package||'dt_delete_validate';
5530   hr_utility.set_location('Entering:'||l_proc, 5);
5531 end if;
5532   --
5533   -- Ensure that the p_datetrack_mode argument is not null
5534   --
5535   hr_api.mandatory_arg_error
5536     (p_api_name       => l_proc,
5537      p_argument       => 'datetrack_mode',
5538      p_argument_value => p_datetrack_mode);
5539   --
5540   -- Only perform the validation if the datetrack mode is either
5541   -- DELETE or ZAP
5542   --
5543   If (p_datetrack_mode = 'DELETE' or
5544       p_datetrack_mode = 'ZAP') then
5545     --
5546     --
5547     -- Ensure the arguments are not null
5548     --
5549     hr_api.mandatory_arg_error
5550       (p_api_name       => l_proc,
5551        p_argument       => 'validation_start_date',
5552        p_argument_value => p_validation_start_date);
5553     --
5554     hr_api.mandatory_arg_error
5555       (p_api_name       => l_proc,
5556        p_argument       => 'validation_end_date',
5557        p_argument_value => p_validation_end_date);
5558     --
5559     hr_api.mandatory_arg_error
5560       (p_api_name       => l_proc,
5561        p_argument       => 'position_id',
5562        p_argument_value => p_position_id);
5563     --
5564     If (dt_api.rows_exist
5565           (p_base_table_name => 'hr_all_positions_f',
5566            p_base_key_column => 'relief_position_id',
5567            p_base_key_value  => p_position_id,
5568            p_from_date       => p_validation_start_date,
5569            p_to_date         => p_validation_end_date)) Then
5570       l_table_name := 'all positions';
5571       Raise l_rows_exist;
5572     End If;
5573 
5574     If (dt_api.rows_exist
5575           (p_base_table_name => 'hr_all_positions_f',
5576            p_base_key_column => 'supervisor_position_id',
5577            p_base_key_value  => p_position_id,
5578            p_from_date       => p_validation_start_date,
5579            p_to_date         => p_validation_end_date)) Then
5580       l_table_name := 'all positions';
5581       Raise l_rows_exist;
5582     End If;
5583     If (dt_api.rows_exist
5584           (p_base_table_name => 'hr_all_positions_f',
5585            p_base_key_column => 'successor_position_id',
5586            p_base_key_value  => p_position_id,
5587            p_from_date       => p_validation_start_date,
5588            p_to_date         => p_validation_end_date)) Then
5589       l_table_name := 'all positions';
5590       Raise l_rows_exist;
5591     End If;
5592 /*
5593     If (dt_api.rows_exist
5594           (p_base_table_name => 'hr_all_positions_f',
5595            p_base_key_column => 'prior_position_id',
5596            p_base_key_value  => p_position_id,
5597            p_from_date       => p_validation_start_date,
5598            p_to_date         => p_validation_end_date)) Then
5599       l_table_name := 'all positions';
5600       Raise l_rows_exist;
5601     End If;
5602 */
5603     --
5604     -- Bug 3199913
5605     -- Removed refernce to 'per_all_assignments_f' since assignment and position
5606     -- do not have parent-child relationship.
5607     -- Removed refernce to 'pay_element_links_f' since assignment and position
5608     -- do not have parent-child relationship.
5609     --
5610   End If;
5611   --
5612 if g_debug then
5613   hr_utility.set_location(' Leaving:'||l_proc, 10);
5614 end if;
5615 Exception
5616   When l_rows_exist Then
5617     --
5618     -- A referential integrity check was violated therefore
5619     -- we must error
5620     --
5621     hr_utility.set_message(800, 'HR_7215_DT_CHILD_EXISTS');
5622     hr_utility.set_message_token('TABLE_NAME', l_table_name);
5623     hr_utility.raise_error;
5624   When Others Then
5625     --
5626     -- An unhandled or unexpected error has occurred which
5627     -- we must report
5628     --
5629     hr_utility.set_message(800, 'HR_6153_ALL_PROCEDURE_FAIL');
5630     hr_utility.set_message_token('PROCEDURE', l_proc);
5631     hr_utility.set_message_token('STEP','15');
5632     hr_utility.raise_error;
5633 End dt_delete_validate;
5634 --
5635 Procedure chk_proposed_status
5636   (p_position_id               in number
5637   ,p_availability_status_id    in varchar2
5638   ,p_business_group_id         in varchar2
5639   ,p_effective_date             in date
5640   ,p_validate_start_date       in date
5641   ,p_validate_end_date         in date
5642   ,p_object_version_number     in number
5643   ,p_datetrack_mode              in varchar2) is
5644   --
5645   l_proc         varchar2(72) ;
5646   l_api_updating boolean;
5647   l_count       number;
5648   --
5649   cursor c1 is
5650   select count(*)
5651   from per_all_assignments_f
5652   where position_id = p_position_id
5653   and effective_start_date between p_validate_start_date and p_validate_end_date;
5654   --
5655   --
5656 Begin
5657   --
5658 if g_debug then
5659   l_proc         := g_package||'chk_proposed_status';
5660   hr_utility.set_location('Entering:'||l_proc, 5);
5661 end if;
5662   --
5663   l_api_updating := hr_psf_shd.api_updating
5664     (p_position_id            => p_position_id
5665     ,p_effective_date         => p_effective_date
5666     ,p_object_version_number  => p_object_version_number);
5667   --
5668 if g_debug then
5669     hr_utility.set_location('datetrack mode:'||p_datetrack_mode, 5);
5670 end if;
5671  if p_datetrack_mode = 'CORRECTION' then
5672   if (l_api_updating
5673       and p_availability_status_id
5674       <> nvl(hr_psf_shd.g_old_rec.availability_status_id,hr_api.g_number))
5675   then
5676 if g_debug then
5677     hr_utility.set_location('Availability_status id:'||p_availability_status_id, 5);
5678     hr_utility.set_location('position id:'||p_position_id, 5);
5679   hr_utility.set_location('get avail '||hr_psf_shd.get_availability_status(p_availability_status_id,p_business_group_id),6);
5680 end if;
5681     if hr_psf_shd.get_availability_status(p_availability_status_id,p_business_group_id) = 'PROPOSED' then
5682 if g_debug then
5683   hr_utility.set_location('Entering:'||l_proc, 5);
5684 end if;
5685       open c1;
5686       fetch c1 into l_count;
5687       close c1;
5688       if l_count >0 then
5689         hr_utility.set_message(800, 'HR_ASG_EXISTS_CANT_CHG_PROP');
5690         hr_utility.raise_error;
5691       end if;
5692     end if;
5693    end if;
5694   end if;
5695   --
5696 if g_debug then
5697   hr_utility.set_location('Leaving:'||l_proc,10);
5698 end if;
5699   --
5700 end chk_proposed_status;
5701 --
5702 --
5703 -- ----------------------------------------------------------------------------
5704 -- |---------------------------< insert_validate >----------------------------|
5705 -- ----------------------------------------------------------------------------
5706 Procedure insert_validate
5707    (p_rec          in hr_psf_shd.g_rec_type,
5708     p_effective_date        in date,
5709     p_datetrack_mode        in varchar2,
5710     p_validation_start_date in date,
5711     p_validation_end_date   in date) is
5712 --
5713   l_proc varchar2(72) ;
5714 --
5715 Begin
5716 g_debug := hr_utility.debug_enabled;
5717 if g_debug then
5718   l_proc := g_package||'insert_validate';
5719   hr_utility.set_location('Entering:'||l_proc, 5);
5720 end if;
5721   --
5722   -- Call all supporting business operations
5723   --
5724   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
5725 --
5726 if g_debug then
5727 hr_utility.set_location(l_proc, 6);
5728 end if;
5729 --
5730 -- Validate date effective and date_end
5731 --
5732 chk_dates
5733   (p_date_effective        => p_rec.date_effective
5734   ,p_date_end              => p_rec.date_end
5735   ,p_validation_start_date => p_validation_start_date
5736   ,p_validation_end_date   => p_validation_end_date
5737   ,p_effective_Date        => p_effective_date
5738   ,p_object_version_number => p_rec.object_version_number
5739 );
5740 --
5741 if g_debug then
5742 hr_utility.set_location(l_proc, 50);
5743 end if;
5744 --
5745 -- validate end dates
5746 chk_end_dates
5747 (position_id                => p_rec.position_id
5748 ,availability_status_id     => p_rec.availability_status_id
5749 ,p_effective_date           => p_effective_date
5750 ,current_org_prop_end_date  => p_rec.current_org_prop_end_date
5751 ,current_job_prop_end_date  => p_rec.current_job_prop_end_date
5752 ,avail_status_prop_end_date => p_rec.avail_status_prop_end_date
5753 ,earliest_hire_date         => p_rec.earliest_hire_date
5754 ,fill_by_date               => p_rec.fill_by_date
5755 ,proposed_date_for_layoff   => p_rec.proposed_date_for_layoff
5756 ,date_effective             => p_rec.date_effective );
5757 --
5758 -- Validate job id
5759 --
5760 if g_debug then
5761 hr_utility.set_location(l_proc, 100);
5762 end if;
5763 chk_job_id
5764     (p_job_id          => p_rec.job_id
5765     ,p_business_group_id     => p_rec.business_group_id
5766     ,p_validation_start_date => p_validation_start_date
5767     ,p_validation_end_date   => p_validation_end_date
5768     ,p_effective_Date        => p_effective_date
5769     ,p_object_version_number => p_rec.object_version_number
5770 );
5771 --
5772 if g_debug then
5773 hr_utility.set_location(l_proc, 110);
5774 end if;
5775 --
5776 -- Validate organization id
5777 --
5778 chk_organization_id
5779   ( p_organization_id       =>  p_rec.organization_id
5780    ,p_business_group_id     =>  p_rec.business_group_id
5781    ,p_validation_start_date =>  p_validation_start_date
5782    ,p_validation_end_date   =>  p_validation_end_date
5783    ,p_effective_Date        =>  p_effective_date
5784    ,p_object_version_number =>  p_rec.object_version_number
5785 );
5786 --
5787 if g_debug then
5788 hr_utility.set_location(l_proc, 120);
5789 end if;
5790 --
5791 -- Validate successor position id
5792 --
5793 chk_successor_position_id
5794   (p_business_group_id     =>  p_rec.business_group_id
5795   ,p_position_id           =>  null
5796   ,p_successor_position_id =>  p_rec.successor_position_id
5797   ,p_validation_start_date =>  p_validation_start_date
5798   ,p_validation_end_date   =>  p_validation_end_date
5799   ,p_effective_date        =>  p_effective_date
5800   ,p_object_version_number =>  p_rec.object_version_number
5801 );
5802 if g_debug then
5803 hr_utility.set_location(l_proc, 130);
5804 end if;
5805 --
5806 -- Validate relief position id
5807 --
5808 chk_relief_position_id
5809   (p_business_group_id     =>  p_rec.business_group_id
5810   ,p_relief_position_id    =>  p_rec.relief_position_id
5811   ,p_validation_start_date =>  p_validation_start_date
5812   ,p_validation_end_date   =>  p_validation_end_date
5813   ,p_effective_date     =>  p_effective_Date
5814 );
5815 --
5816 if g_debug then
5817 hr_utility.set_location(l_proc, 140);
5818 end if;
5819 --
5820 -- Validate location_id
5821 --
5822 chk_location_id
5823   (p_location_id        => p_rec.location_id
5824   ,p_effective_Date        => p_effective_date
5825   ,p_validation_start_date => p_validation_start_Date
5826   ,p_validation_end_date   => p_validation_end_Date
5827 
5828 );
5829 --
5830 if g_debug then
5831 hr_utility.set_location(l_proc, 150);
5832 end if;
5833 --
5834 -- Validate position definition id
5835 --
5836 chk_position_definition_id
5837   (p_position_definition_id   => p_rec.position_definition_id
5838   ,p_effective_Date           => p_effective_date
5839 );
5840 --
5841 if g_debug then
5842 hr_utility.set_location(l_proc, 160);
5843 end if;
5844 --
5845 -- Validate working_hours and frequency
5846 --
5847 chk_hrs_frequency
5848   (p_working_hours     => p_rec.working_hours
5849   ,p_frequency      => p_rec.frequency
5850   ,p_effective_date       => p_effective_date
5851 );
5852 --
5853 if g_debug then
5854 hr_utility.set_location(l_proc, 170);
5855 end if;
5856 --
5857 -- Validate probation period and probation_period_unit_cd
5858 --
5859 chk_probation_info
5860   (p_probation_period         => p_rec.probation_period
5861   ,p_probation_period_unit_cd => p_rec.probation_period_unit_cd
5862   ,p_effective_Date           => p_effective_date
5863 );
5864 --
5865 if g_debug then
5866 hr_utility.set_location('Entering:'||l_proc, 180);
5867 end if;
5868 --
5869 -- Validate time normal start and time_normal_finish
5870 --
5871 chk_time_start_finish
5872   (p_time_normal_start    => p_rec.time_normal_start
5873   ,p_time_normal_finish   => p_rec.time_normal_finish
5874   ,p_effective_date       => p_effective_date
5875 );
5876 --
5877 if g_debug then
5878 hr_utility.set_location(l_proc, 200);
5879 end if;
5880 --
5881 chk_entry_step_id
5882   (p_position_id              => p_rec.position_id
5883   ,p_entry_step_id            => p_rec.entry_step_id
5884   ,p_entry_grade_id           => p_rec.entry_grade_id
5885   ,p_business_group_id        => p_rec.business_group_id
5886   ,p_validation_start_date    => p_validation_start_date
5887   ,p_validation_end_date      => p_validation_end_date
5888   ,p_effective_date           => p_effective_date
5889   ,p_object_version_number    => p_rec.object_version_number
5890   );
5891   --
5892 if g_debug then
5893   hr_utility.set_location(l_proc, 210);
5894 end if;
5895   --
5896   chk_entry_grade_id
5897   (p_position_id              => p_rec.position_id
5898   ,p_business_group_id        => p_rec.business_group_id
5899   ,p_entry_grade_id           => p_rec.entry_grade_id
5900   ,p_effective_date           => p_effective_date
5901   ,p_validation_start_date    => p_validation_start_date
5902   ,p_validation_end_date      => p_validation_end_date
5903   ,p_object_version_number    => p_rec.object_version_number
5904   );
5905   --
5906 if g_debug then
5907   hr_utility.set_location(l_proc, 215);
5908 end if;
5909   --
5910   chk_entry_grade_rule_id
5911   (p_position_id              => p_rec.position_id
5912   ,p_business_group_id        => p_rec.business_group_id
5913   ,p_entry_grade_rule_id      => p_rec.entry_grade_rule_id
5914   ,p_effective_date           => p_effective_date
5915   ,p_validation_start_date    => p_validation_start_date
5916   ,p_validation_end_date      => p_validation_end_date
5917   ,p_object_version_number    => p_rec.object_version_number
5918   );
5919   --
5920 if g_debug then
5921   hr_utility.set_location(l_proc, 220);
5922 end if;
5923   --
5924   chk_work_term_end_month_cd
5925   (p_position_id              => p_rec.position_id
5926   ,p_work_term_end_month_cd   => p_rec.work_term_end_month_cd
5927   ,p_effective_date           => p_effective_date
5928   ,p_validation_start_date    => p_validation_start_date
5929   ,p_validation_end_date      => p_validation_end_date
5930   ,p_object_version_number => p_rec.object_version_number);
5931   --
5932 if g_debug then
5933   hr_utility.set_location(l_proc, 230);
5934 end if;
5935   --
5936   chk_work_term_end_day_cd
5937   (p_position_id           => p_rec.position_id
5938   ,p_work_term_end_day_cd  => p_rec.work_term_end_day_cd
5939   ,p_effective_date        => p_effective_date
5940   ,p_validation_start_date => p_validation_start_date
5941   ,p_validation_end_date   => p_validation_end_date
5942   ,p_object_version_number => p_rec.object_version_number);
5943   --
5944 if g_debug then
5945   hr_utility.set_location(l_proc, 240);
5946 end if;
5947   --
5948   chk_work_period_type_cd
5949   (p_position_id           => p_rec.position_id
5950   ,p_work_period_type_cd   => p_rec.work_period_type_cd
5951   ,p_effective_date        => p_effective_date
5952   ,p_validation_start_date => p_validation_start_date
5953   ,p_validation_end_date   => p_validation_end_date
5954   ,p_object_version_number => p_rec.object_version_number);
5955   --
5956 if g_debug then
5957   hr_utility.set_location(l_proc, 250);
5958 end if;
5959   --
5960   chk_works_council_approval_flg
5961   (p_position_id                 => p_rec.position_id
5962   ,p_works_council_approval_flag => p_rec.works_council_approval_flag
5963   ,p_effective_date              => p_effective_date
5964   ,p_validation_start_date       => p_validation_start_date
5965   ,p_validation_end_date         => p_validation_end_date
5966   ,p_object_version_number       => p_rec.object_version_number);
5967   --
5968 if g_debug then
5969   hr_utility.set_location(l_proc, 260);
5970 end if;
5971   --
5972   chk_term_start_month_cd
5973   (p_position_id           => p_rec.position_id
5974   ,p_term_start_month_cd   => p_rec.term_start_month_cd
5975   ,p_effective_date        => p_effective_date
5976   ,p_validation_start_date => p_validation_start_date
5977   ,p_validation_end_date   => p_validation_end_date
5978   ,p_object_version_number => p_rec.object_version_number);
5979   --
5980 if g_debug then
5981   hr_utility.set_location(l_proc, 270);
5982 end if;
5983   --
5984   chk_term_start_day_cd
5985   (p_position_id           => p_rec.position_id
5986   ,p_term_start_day_cd     => p_rec.term_start_day_cd
5987   ,p_effective_date        => p_effective_date
5988   ,p_validation_start_date => p_validation_start_date
5989   ,p_validation_end_date   => p_validation_end_date
5990   ,p_object_version_number => p_rec.object_version_number);
5991   --
5992 if g_debug then
5993   hr_utility.set_location(l_proc, 280);
5994 end if;
5995   --
5996   chk_seasonal_flag
5997   (p_position_id           => p_rec.position_id
5998   ,p_seasonal_flag         => p_rec.seasonal_flag
5999   ,p_effective_date        => p_effective_date
6000   ,p_validation_start_date => p_validation_start_date
6001   ,p_validation_end_date   => p_validation_end_date
6002   ,p_object_version_number => p_rec.object_version_number);
6003   --
6004 if g_debug then
6005   hr_utility.set_location(l_proc, 290);
6006 end if;
6007   --
6008   chk_review_flag
6009   (p_position_id           => p_rec.position_id
6010   ,p_review_flag           => p_rec.review_flag
6011   ,p_effective_date        => p_effective_date
6012   ,p_validation_start_date => p_validation_start_date
6013   ,p_validation_end_date   => p_validation_end_date
6014   ,p_object_version_number => p_rec.object_version_number);
6015   --
6016 if g_debug then
6017   hr_utility.set_location(l_proc, 300);
6018 end if;
6019   --
6020   chk_replacement_required_flag
6021   (p_position_id               => p_rec.position_id
6022   ,p_replacement_required_flag => p_rec.replacement_required_flag
6023   ,p_effective_date            => p_effective_date
6024   ,p_validation_start_date     => p_validation_start_date
6025   ,p_validation_end_date       => p_validation_end_date
6026   ,p_object_version_number     => p_rec.object_version_number);
6027   --
6028 if g_debug then
6029   hr_utility.set_location(l_proc, 310);
6030 end if;
6031   --
6032   chk_probation_period_unit_cd
6033   (p_position_id              => p_rec.position_id
6034   ,p_probation_period_unit_cd => p_rec.probation_period_unit_cd
6035   ,p_effective_date           => p_effective_date
6036   ,p_validation_start_date    => p_validation_start_date
6037   ,p_validation_end_date      => p_validation_end_date
6038   ,p_object_version_number    => p_rec.object_version_number);
6039   --
6040 if g_debug then
6041   hr_utility.set_location(l_proc, 320);
6042 end if;
6043   --
6044   chk_permit_recruitment_flag
6045   (p_position_id             => p_rec.position_id
6046   ,p_permit_recruitment_flag => p_rec.permit_recruitment_flag
6047   ,p_effective_date          => p_effective_date
6048   ,p_validation_start_date   => p_validation_start_date
6049   ,p_validation_end_date     => p_validation_end_date
6050   ,p_object_version_number   => p_rec.object_version_number);
6051   --
6052 if g_debug then
6053   hr_utility.set_location(l_proc, 330);
6054 end if;
6055   --
6056   chk_permanent_temporary_flag
6057   (p_position_id              => p_rec.position_id
6058   ,p_permanent_temporary_flag => p_rec.permanent_temporary_flag
6059   ,p_effective_date           => p_effective_date
6060   ,p_validation_start_date    => p_validation_start_date
6061   ,p_validation_end_date      => p_validation_end_date
6062   ,p_object_version_number    => p_rec.object_version_number);
6063   --
6064 if g_debug then
6065    hr_utility.set_location(l_proc, 335);
6066  end if;
6067    --
6068  chk_permanent_seasonal_flag
6069    (p_position_id               => p_rec.position_id
6070    ,p_permanent_temporary_flag  => p_rec.permanent_temporary_flag
6071    ,p_seasonal_flag             => p_rec.seasonal_flag
6072    ,p_effective_date            => p_effective_date
6073    ,p_object_version_number     => p_rec.object_version_number);
6074    --
6075 
6076 if g_debug then
6077   hr_utility.set_location(l_proc, 340);
6078 end if;
6079   --
6080   chk_pay_term_end_month_cd
6081   (p_position_id           => p_rec.position_id
6082   ,p_pay_term_end_month_cd => p_rec.pay_term_end_month_cd
6083   ,p_effective_date        => p_effective_date
6084   ,p_validation_start_date => p_validation_start_date
6085   ,p_validation_end_date   => p_validation_end_date
6086   ,p_object_version_number => p_rec.object_version_number);
6087   --
6088 if g_debug then
6089   hr_utility.set_location(l_proc, 350);
6090 end if;
6091   --
6092   chk_pay_term_end_day_cd
6093   (p_position_id           => p_rec.position_id
6094   ,p_pay_term_end_day_cd   => p_rec.pay_term_end_day_cd
6095   ,p_effective_date        => p_effective_date
6096   ,p_validation_start_date => p_validation_start_date
6097   ,p_validation_end_date   => p_validation_end_date
6098   ,p_object_version_number => p_rec.object_version_number);
6099   --
6100 if g_debug then
6101   hr_utility.set_location(l_proc, 360);
6102 end if;
6103   --
6104   chk_overlap_unit_cd
6105   (p_position_id           => p_rec.position_id
6106   ,p_overlap_unit_cd       => p_rec.overlap_unit_cd
6107   ,p_effective_date        => p_effective_date
6108   ,p_validation_start_date => p_validation_start_date
6109   ,p_validation_end_date   => p_validation_end_date
6110   ,p_object_version_number => p_rec.object_version_number);
6111   --
6112 if g_debug then
6113   hr_utility.set_location(l_proc, 370);
6114 end if;
6115   --
6116   chk_bargaining_unit_cd
6117   (p_position_id           => p_rec.position_id
6118   ,p_bargaining_unit_cd    => p_rec.bargaining_unit_cd
6119   ,p_effective_date        => p_effective_date
6120   ,p_validation_start_date => p_validation_start_date
6121   ,p_validation_end_date   => p_validation_end_date
6122   ,p_object_version_number => p_rec.object_version_number);
6123   --
6124 if g_debug then
6125   hr_utility.set_location(l_proc, 380);
6126 end if;
6127   --
6128   chk_pay_freq_payroll_id
6129   (p_position_id           => p_rec.position_id
6130   ,p_business_group_id     => p_rec.business_group_id
6131   ,p_pay_freq_payroll_id   => p_rec.pay_freq_payroll_id
6132   ,p_validation_start_date => p_validation_start_date
6133   ,p_validation_end_date   => p_validation_end_date
6134   ,p_effective_date        => p_effective_Date
6135   ,p_datetrack_mode        => p_datetrack_mode
6136   ,p_object_version_number => p_rec.object_version_number
6137   );
6138   --
6139 if g_debug then
6140   hr_utility.set_location(l_proc, 390);
6141 end if;
6142   --
6143 /*
6144   chk_position_transaction_id
6145   (p_position_id              => p_rec.position_id
6146   ,p_position_transaction_id  => p_rec.position_transaction_id
6147   ,p_validation_start_date    => p_validation_start_date
6148   ,p_validation_end_date      => p_validation_end_date
6149   ,p_effective_date           => p_effective_date
6150   ,p_object_version_number    => p_rec.object_version_number
6151   );
6152   --
6153 */
6154  --
6155 if g_debug then
6156   hr_utility.set_location(l_proc, 400);
6157 end if;
6158   --
6159   chk_supervisor_position_id
6160   (p_business_group_id      => p_rec.business_group_id
6161   ,p_position_id            => p_rec.position_id
6162   ,p_supervisor_position_id => p_rec.supervisor_position_id
6163   ,p_validation_start_date  => p_validation_start_date
6164   ,p_validation_end_date    => p_validation_end_date
6165   ,p_effective_date      => p_effective_date
6166   ,p_object_version_number  => p_rec.object_version_number
6167   );
6168   --
6169 if g_debug then
6170   hr_utility.set_location(l_proc, 410);
6171 end if;
6172   --
6173   chk_prior_position_id
6174   (p_business_group_id      => p_rec.business_group_id
6175   ,p_position_id            => p_rec.position_id
6176   ,p_prior_position_id      => p_rec.prior_position_id
6177   ,p_validation_start_date  => p_validation_start_date
6178   ,p_validation_end_date    => p_validation_end_date
6179   ,p_effective_date      => p_effective_date
6180   ,p_object_version_number  => p_rec.object_version_number
6181   );
6182   --
6183 if g_debug then
6184   hr_utility.set_location(l_proc, 420);
6185 end if;
6186   --
6187   chk_availability_status_id
6188    (p_position_id            => p_rec.position_id
6189    ,p_validation_start_date  => p_validation_start_date
6190    ,p_availability_status_id => p_rec.availability_status_id
6191    ,p_old_avail_status_id    => hr_psf_shd.g_old_rec.availability_status_id
6192    ,p_effective_date         => p_effective_date
6193    ,p_date_effective         => p_rec.date_effective
6194    ,p_business_group_id      => p_rec.business_group_id
6195    ,p_object_version_number  => p_rec.object_version_number
6196    ,p_datetrack_mode         => p_datetrack_mode );
6197   --
6198 if g_debug then
6199   hr_utility.set_location(l_proc, 430);
6200 end if;
6201   --
6202   chk_position_type
6203   (p_position_id             => p_rec.position_id
6204   ,p_position_type           => p_rec.position_type
6205   ,p_effective_date          => p_effective_date
6206   ,p_validation_start_date   => p_validation_start_Date
6207   ,p_validation_end_date     => p_validation_end_date
6208   ,p_object_version_number   => p_rec.object_version_number
6209   );
6210   --
6211 if g_debug then
6212   hr_utility.set_location(l_proc, 440);
6213 end if;
6214   --
6215   chk_fte
6216   (p_position_id               => p_rec.position_id
6217   ,p_fte                       => p_rec.fte
6218   ,p_position_type             => p_rec.position_type
6219   ,p_effective_date            => p_effective_date
6220   ,p_validation_start_date     => p_validation_start_date
6221   ,p_validation_end_date       => p_validation_end_Date
6222   ,p_object_version_number     => p_rec.object_version_number);
6223   --
6224 if g_debug then
6225   hr_utility.set_location(l_proc, 445);
6226 end if;
6227   --
6228   chk_max_persons
6229   (p_position_id               => p_rec.position_id
6230   ,p_max_persons               => p_rec.max_persons
6231   ,p_position_type             => p_rec.position_type
6232   ,p_effective_date            => p_effective_date
6233   ,p_object_version_number     => p_rec.object_version_number);
6234   --
6235 if g_debug then
6236   hr_utility.set_location(l_proc, 450);
6237 end if;
6238   --
6239   chk_extended_pay
6240   (p_position_id               => p_rec.position_id
6241   ,p_work_period_type_cd       => p_rec.work_period_type_cd
6242   ,p_term_start_day_cd         => p_rec.term_start_day_cd
6243   ,p_term_start_month_cd       => p_rec.term_start_month_cd
6244   ,p_pay_term_end_day_cd       => p_rec.pay_term_end_day_cd
6245   ,p_pay_term_end_month_cd     => p_rec.pay_term_end_month_cd
6246   ,p_work_term_end_day_cd      => p_rec.work_term_end_day_cd
6247   ,p_work_term_end_month_cd    => p_rec.work_term_end_month_cd
6248   );
6249   --
6250 if g_debug then
6251   hr_utility.set_location(l_proc, 460);
6252 end if;
6253   --
6254   chk_proposed_fte_for_layoff
6255   (p_fte                      => p_rec.fte
6256   ,p_proposed_fte_for_layoff  => p_rec.proposed_fte_for_layoff
6257   ,p_proposed_date_for_layoff => p_rec.proposed_Date_for_layoff
6258   );
6259   --
6260 if g_debug then
6261   hr_utility.set_location(l_proc, 470);
6262 end if;
6263   --
6264 /*
6265 chk_extended_pay_permit
6266 (p_position_id            => p_rec.position_id
6267   ,p_work_period_type_cd        => p_rec.work_period_type_cd
6268   ,p_effective_date             => p_effective_date
6269   ,p_validation_start_date      => p_validation_start_Date
6270   ,p_validation_end_date        => p_validation_end_date
6271   ,p_object_version_number      => p_rec.object_version_number
6272 );
6273 if g_debug then
6274 hr_utility.set_location(l_proc, 2000);
6275 end if;
6276 --
6277 -- Validate status
6278 --
6279 chk_status
6280   (p_position_id            => p_rec.position_id
6281   ,p_effective_Date        =>  p_effective_date
6282   ,p_status                 => p_rec.status
6283   ,p_object_version_number  => p_rec.object_version_number
6284 );
6285 --
6286 */
6287 if g_debug then
6288   hr_utility.set_location('Entering:'||l_proc, 210);
6289 end if;
6290   --
6291   --
6292   -- Call developer descriptive flexfield validation routines
6293   --
6294   --hr_psf_bus.chk_ddf(p_rec => p_rec);
6295   --
6296   --
6297   --
6298   -- Call descriptive flexfield validation routines
6299   --
6300   hr_psf_bus.chk_df(p_rec => p_rec);
6301   --
6302 if g_debug then
6303   hr_utility.set_location('Entering:'||l_proc, 220);
6304 end if;
6305   --
6306   -- PMFLETCH ** Not using this uniqueness chech anymore **
6307   -- Check position_name is unique for Business_group
6308   --
6309   --chk_name_unique_for_BG
6310   -- (p_business_group_id    => p_rec.business_group_id
6311   -- ,p_position_id          => p_rec.position_id
6312   -- ,p_effective_date       => p_effective_date
6313   -- ,p_name                 => p_rec.name
6314   -- ,p_object_version_number  => p_rec.object_version_number
6315   -- );
6316   --
6317   -- PMFLETCH Check position_definition_id is unique for business group
6318   --
6319   chk_ccid_unique_for_BG
6320     (p_business_group_id             => p_rec.business_group_id
6321     ,p_position_id                   => p_rec.position_id
6322     ,p_position_definition_id        => p_rec.position_definition_id
6323     ,p_validation_start_date         => p_validation_start_date
6324     ,p_validation_end_date           => p_validation_end_date
6325     ,p_effective_date                => p_effective_date
6326     ,p_object_version_number         => p_rec.object_version_number
6327     );
6328   --
6329   --
6330   -- Call to validate Position Control Business Rules
6331   --
6332   if (per_pqh_shr.position_control_enabled
6333       ( p_organization_id => p_rec.organization_id
6334       , p_effective_date  => p_effective_date
6335       ) = 'Y') then
6336     --
6337     if p_rec.position_transaction_id is null then
6338       hr_utility.set_message(800, 'PER_CANT_CRE_PC_POS_NO_TXN');
6339       hr_utility.raise_error;
6340     end if;
6341     --
6342   end if;
6343   --
6344   per_pqh_shr.hr_psf_bus('INSERT_VALIDATE',p_rec
6345         ,p_effective_date
6346         ,p_validation_start_date
6347         ,p_validation_end_date
6348         ,p_datetrack_mode);
6349   --
6350   --End of Position Control Business Rules call
6351   --
6352   --
6353 if g_debug then
6354   hr_utility.set_location(' Leaving:'||l_proc, 230);
6355 end if;
6356   --
6357 End insert_validate;
6358 --
6359 -- ----------------------------------------------------------------------------
6360 -- |---------------------------< update_validate >----------------------------|
6361 -- ----------------------------------------------------------------------------
6362 Procedure update_validate
6363    (p_rec          in hr_psf_shd.g_rec_type,
6364     p_effective_date  in date,
6365     p_datetrack_mode  in varchar2,
6366     p_validation_start_date in date,
6367     p_validation_end_date   in date) is
6368 --
6369   l_proc varchar2(72) ;
6370 --
6371 Begin
6372 g_debug := hr_utility.debug_enabled;
6373 if g_debug then
6374 l_proc    := g_package||'update_validate';
6375   hr_utility.set_location('Entering:'||l_proc, 5);
6376 end if;
6377   --
6378   -- Call all supporting business operations
6379   --
6380   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
6381   --
6382 if g_debug then
6383   hr_utility.set_location('Entering:'||l_proc, 100);
6384 end if;
6385   -- Validate successor position id
6386   --
6387   chk_successor_position_id
6388     (p_business_group_id     => p_rec.business_group_id
6389     ,p_position_id           => p_rec.position_id
6390     ,p_successor_position_id => p_rec.successor_position_id
6391     ,p_validation_start_date =>  p_validation_start_date
6392     ,p_validation_end_date   =>  p_validation_end_date
6393     ,p_effective_date        =>  p_effective_date
6394     ,p_object_version_number => p_rec.object_version_number
6395   );
6396   --
6397 if g_debug then
6398   hr_utility.set_location('Entering:'||l_proc, 110);
6399 end if;
6400   --
6401   -- Validate relief position id
6402   --
6403   chk_relief_position_id
6404     (p_business_group_id     => p_rec.business_group_id
6405     ,p_position_id           => p_rec.position_id
6406     ,p_relief_position_id    => p_rec.relief_position_id
6407     ,p_validation_start_date =>  p_validation_start_date
6408     ,p_validation_end_date   =>  p_validation_end_date
6409     ,p_effective_date        =>  p_effective_Date
6410     ,p_object_version_number => p_rec.object_version_number
6411   );
6412   --
6413 if g_debug then
6414   hr_utility.set_location('Entering:'||l_proc, 120);
6415 end if;
6416   --
6417   -- Validate location_id
6418   --
6419   chk_location_id
6420     (p_position_id           => p_rec.position_id
6421     ,p_location_id        =>  p_rec.location_id
6422     ,p_effective_Date        => p_effective_date
6423     ,p_validation_start_date => p_validation_start_Date
6424     ,p_validation_end_date   => p_validation_end_Date
6425     ,p_object_version_number => p_rec.object_version_number
6426   );
6427   --
6428 if g_debug then
6429   hr_utility.set_location('Entering:'||l_proc, 130);
6430 end if;
6431   --
6432   -- Validate working_hours and frequency
6433   --
6434   chk_hrs_frequency
6435     (p_position_id        => p_rec.position_id
6436     ,p_working_hours      => p_rec.working_hours
6437     ,p_frequency       => p_rec.frequency
6438     ,p_effective_date        => p_effective_date
6439     ,p_object_version_number => p_rec.object_version_number
6440   );
6441   --
6442 if g_debug then
6443   hr_utility.set_location('Entering:'||l_proc, 140);
6444 end if;
6445   --
6446   -- Validate probation period and probation_period_unit_cd
6447   --
6448   chk_probation_info
6449     (p_position_id              => p_rec.position_id
6450     ,p_probation_period         => p_rec.probation_period
6451     ,p_probation_period_unit_cd => p_rec.probation_period_unit_cd
6452     ,p_effective_Date           => p_effective_date
6453     ,p_object_version_number    => p_rec.object_version_number
6454   );
6455   --
6456 if g_debug then
6457   hr_utility.set_location('Entering:'||l_proc, 150);
6458 end if;
6459   --
6460   -- Validate time normal start and time_normal_finish
6461   --
6462   chk_time_start_finish
6463     (p_position_id           => p_rec.position_id
6464     ,p_time_normal_start     => p_rec.time_normal_start
6465     ,p_time_normal_finish    => p_rec.time_normal_finish
6466     ,p_effective_date        => p_effective_date
6467     ,p_object_version_number => p_rec.object_version_number
6468   );
6469   --
6470 if g_debug then
6471   hr_utility.set_location('Entering:'||l_proc, 160);
6472 end if;
6473   --
6474   -- Validate position definition id
6475   --
6476   chk_position_definition_id
6477     (p_position_definition_id => p_rec.position_definition_id
6478     ,p_position_id              => p_rec.position_id
6479     ,p_effective_Date           => p_effective_date
6480     ,p_object_version_number    => p_rec.object_version_number
6481   );
6482   --
6483 if g_debug then
6484   hr_utility.set_location(l_proc, 165);
6485 end if;
6486   --
6487   -- Validate working_hours and frequency
6488   --
6489   chk_hrs_frequency
6490   (p_position_id          => p_rec.position_id
6491   ,p_working_hours     => p_rec.working_hours
6492   ,p_frequency      => p_rec.frequency
6493   ,p_effective_date       => p_effective_date
6494   );
6495   --
6496 if g_debug then
6497   hr_utility.set_location(l_proc, 170);
6498 end if;
6499   --
6500   -- Validate probation period and probation_period_unit_cd
6501   --
6502   chk_probation_info
6503   (p_position_id              => p_rec.position_id
6504   ,p_probation_period         => p_rec.probation_period
6505   ,p_probation_period_unit_cd => p_rec.probation_period_unit_cd
6506   ,p_effective_Date           => p_effective_date
6507   );
6508   --
6509 if g_debug then
6510   hr_utility.set_location('Entering:'||l_proc, 180);
6511 end if;
6512   --
6513   -- Validate time normal start and time_normal_finish
6514   --
6515   chk_time_start_finish
6516   (p_position_id          => p_rec.position_id
6517   ,p_time_normal_start    => p_rec.time_normal_start
6518   ,p_time_normal_finish   => p_rec.time_normal_finish
6519   ,p_effective_date       => p_effective_date
6520   );
6521   --
6522 if g_debug then
6523   hr_utility.set_location(l_proc, 200);
6524 end if;
6525   --
6526   chk_entry_step_id
6527   (p_position_id              => p_rec.position_id
6528   ,p_entry_step_id            => p_rec.entry_step_id
6529   ,p_entry_grade_id           => p_rec.entry_grade_id
6530   ,p_business_group_id        => p_rec.business_group_id
6531   ,p_validation_start_date    => p_validation_start_date
6532   ,p_validation_end_date      => p_validation_end_date
6533   ,p_effective_date           => p_effective_date
6534   ,p_object_version_number    => p_rec.object_version_number
6535   );
6536 if g_debug then
6537 hr_utility.set_location(l_proc, 210);
6538 end if;
6539 chk_entry_grade_id
6540   (p_position_id              => p_rec.position_id
6541   ,p_business_group_id        => p_rec.business_group_id
6542   ,p_entry_grade_id           => p_rec.entry_grade_id
6543   ,p_effective_date           => p_effective_date
6544   ,p_validation_start_date    => p_validation_start_date
6545   ,p_validation_end_date      => p_validation_end_date
6546   ,p_object_version_number    => p_rec.object_version_number
6547   );
6548   --
6549 if g_debug then
6550   hr_utility.set_location(l_proc, 215);
6551 end if;
6552   --
6553   chk_entry_grade_rule_id
6554   (p_position_id              => p_rec.position_id
6555   ,p_business_group_id        => p_rec.business_group_id
6556   ,p_entry_grade_rule_id      => p_rec.entry_grade_rule_id
6557   ,p_effective_date           => p_effective_date
6558   ,p_validation_start_date    => p_validation_start_date
6559   ,p_validation_end_date      => p_validation_end_date
6560   ,p_object_version_number    => p_rec.object_version_number
6561   );
6562   --
6563 if g_debug then
6564   hr_utility.set_location(l_proc, 220);
6565 end if;
6566   --
6567   chk_work_term_end_month_cd
6568   (p_position_id            => p_rec.position_id
6569   ,p_work_term_end_month_cd => p_rec.work_term_end_month_cd
6570   ,p_effective_date         => p_effective_date
6571   ,p_validation_start_date  => p_validation_start_date
6572   ,p_validation_end_date    => p_validation_end_date
6573   ,p_object_version_number  => p_rec.object_version_number);
6574   --
6575 if g_debug then
6576   hr_utility.set_location(l_proc, 230);
6577 end if;
6578   --
6579   chk_work_term_end_day_cd
6580   (p_position_id           => p_rec.position_id
6581   ,p_work_term_end_day_cd  => p_rec.work_term_end_day_cd
6582   ,p_effective_date        => p_effective_date
6583   ,p_validation_start_date => p_validation_start_date
6584   ,p_validation_end_date   => p_validation_end_date
6585   ,p_object_version_number => p_rec.object_version_number);
6586   --
6587 if g_debug then
6588   hr_utility.set_location(l_proc, 240);
6589 end if;
6590   --
6591   chk_work_period_type_cd
6592   (p_position_id           => p_rec.position_id
6593   ,p_work_period_type_cd   => p_rec.work_period_type_cd
6594   ,p_effective_date        => p_effective_date
6595   ,p_validation_start_date => p_validation_start_date
6596   ,p_validation_end_date   => p_validation_end_date
6597   ,p_object_version_number => p_rec.object_version_number);
6598   --
6599 if g_debug then
6600   hr_utility.set_location(l_proc, 250);
6601 end if;
6602   --
6603   chk_works_council_approval_flg
6604   (p_position_id                 => p_rec.position_id
6605   ,p_works_council_approval_flag => p_rec.works_council_approval_flag
6606   ,p_effective_date              => p_effective_date
6607   ,p_validation_start_date       => p_validation_start_date
6608   ,p_validation_end_date         => p_validation_end_date
6609   ,p_object_version_number       => p_rec.object_version_number);
6610   --
6611 if g_debug then
6612   hr_utility.set_location(l_proc, 260);
6613 end if;
6614   --
6615   chk_term_start_month_cd
6616   (p_position_id           => p_rec.position_id
6617   ,p_term_start_month_cd   => p_rec.term_start_month_cd
6618   ,p_effective_date        => p_effective_date
6619   ,p_validation_start_date => p_validation_start_date
6620   ,p_validation_end_date   => p_validation_end_date
6621   ,p_object_version_number => p_rec.object_version_number);
6622   --
6623 if g_debug then
6624   hr_utility.set_location(l_proc, 270);
6625 end if;
6626   --
6627   chk_term_start_day_cd
6628   (p_position_id           => p_rec.position_id
6629   ,p_term_start_day_cd     => p_rec.term_start_day_cd
6630   ,p_effective_date        => p_effective_date
6631   ,p_validation_start_date => p_validation_start_date
6632   ,p_validation_end_date   => p_validation_end_date
6633   ,p_object_version_number => p_rec.object_version_number);
6634   --
6635 if g_debug then
6636   hr_utility.set_location(l_proc, 280);
6637 end if;
6638   --
6639   chk_seasonal_flag
6640   (p_position_id           => p_rec.position_id
6641   ,p_seasonal_flag         => p_rec.seasonal_flag
6642   ,p_effective_date        => p_effective_date
6643   ,p_validation_start_date => p_validation_start_date
6644   ,p_validation_end_date   => p_validation_end_date
6645   ,p_object_version_number => p_rec.object_version_number);
6646   --
6647 if g_debug then
6648   hr_utility.set_location(l_proc, 290);
6649 end if;
6650   --
6651   chk_review_flag
6652   (p_position_id           => p_rec.position_id
6653   ,p_review_flag           => p_rec.review_flag
6654   ,p_effective_date        => p_effective_date
6655   ,p_validation_start_date => p_validation_start_date
6656   ,p_validation_end_date   => p_validation_end_date
6657   ,p_object_version_number => p_rec.object_version_number);
6658   --
6659 if g_debug then
6660   hr_utility.set_location(l_proc, 300);
6661 end if;
6662   --
6663   chk_replacement_required_flag
6664   (p_position_id               => p_rec.position_id
6665   ,p_replacement_required_flag => p_rec.replacement_required_flag
6666   ,p_effective_date            => p_effective_date
6667   ,p_validation_start_date     => p_validation_start_date
6668   ,p_validation_end_date       => p_validation_end_date
6669   ,p_object_version_number     => p_rec.object_version_number);
6670   --
6671 if g_debug then
6672   hr_utility.set_location(l_proc, 310);
6673 end if;
6674   --
6675   chk_probation_period_unit_cd
6676   (p_position_id              => p_rec.position_id
6677   ,p_probation_period_unit_cd => p_rec.probation_period_unit_cd
6678   ,p_effective_date           => p_effective_date
6679   ,p_validation_start_date    => p_validation_start_date
6680   ,p_validation_end_date      => p_validation_end_date
6681   ,p_object_version_number    => p_rec.object_version_number);
6682   --
6683 if g_debug then
6684   hr_utility.set_location(l_proc, 320);
6685 end if;
6686   --
6687   chk_permit_recruitment_flag
6688   (p_position_id             => p_rec.position_id
6689   ,p_permit_recruitment_flag => p_rec.permit_recruitment_flag
6690   ,p_effective_date          => p_effective_date
6691   ,p_validation_start_date   => p_validation_start_date
6692   ,p_validation_end_date     => p_validation_end_date
6693   ,p_object_version_number   => p_rec.object_version_number);
6694   --
6695 if g_debug then
6696   hr_utility.set_location(l_proc, 330);
6697 end if;
6698   --
6699   chk_permanent_temporary_flag
6700   (p_position_id              => p_rec.position_id
6701   ,p_permanent_temporary_flag => p_rec.permanent_temporary_flag
6702   ,p_effective_date           => p_effective_date
6703   ,p_validation_start_date    => p_validation_start_date
6704   ,p_validation_end_date      => p_validation_end_date
6705   ,p_object_version_number    => p_rec.object_version_number);
6706   --
6707 if g_debug then
6708   hr_utility.set_location(l_proc, 335);
6709 end if;
6710 --
6711 -- for bug fix 5250975
6712 chk_permanent_seasonal_flag
6713   (p_position_id               => p_rec.position_id
6714   ,p_permanent_temporary_flag  => p_rec.permanent_temporary_flag
6715   ,p_seasonal_flag             => p_rec.seasonal_flag
6716   ,p_effective_date            => p_effective_date
6717   ,p_object_version_number     => p_rec.object_version_number);
6718 --
6719 
6720 if g_debug then
6721   hr_utility.set_location(l_proc, 340);
6722 end if;
6723   --
6724   chk_pay_term_end_month_cd
6725   (p_position_id           => p_rec.position_id
6726   ,p_pay_term_end_month_cd => p_rec.pay_term_end_month_cd
6727   ,p_effective_date        => p_effective_date
6728   ,p_validation_start_date => p_validation_start_date
6729   ,p_validation_end_date   => p_validation_end_date
6730   ,p_object_version_number => p_rec.object_version_number);
6731   --
6732 if g_debug then
6733   hr_utility.set_location(l_proc, 350);
6734 end if;
6735   --
6736   chk_pay_term_end_day_cd
6737   (p_position_id           => p_rec.position_id
6738   ,p_pay_term_end_day_cd   => p_rec.pay_term_end_day_cd
6739   ,p_effective_date        => p_effective_date
6740   ,p_validation_start_date => p_validation_start_date
6741   ,p_validation_end_date   => p_validation_end_date
6742   ,p_object_version_number => p_rec.object_version_number);
6743   --
6744 if g_debug then
6745   hr_utility.set_location(l_proc, 360);
6746 end if;
6747   --
6748   chk_overlap_unit_cd
6749   (p_position_id           => p_rec.position_id
6750   ,p_overlap_unit_cd       => p_rec.overlap_unit_cd
6751   ,p_effective_date        => p_effective_date
6752   ,p_validation_start_date => p_validation_start_date
6753   ,p_validation_end_date   => p_validation_end_date
6754   ,p_object_version_number => p_rec.object_version_number);
6755   --
6756 if g_debug then
6757   hr_utility.set_location(l_proc, 370);
6758 end if;
6759   --
6760   chk_bargaining_unit_cd
6761   (p_position_id           => p_rec.position_id
6762   ,p_bargaining_unit_cd    => p_rec.bargaining_unit_cd
6763   ,p_effective_date        => p_effective_date
6764   ,p_validation_start_date => p_validation_start_date
6765   ,p_validation_end_date   => p_validation_end_date
6766   ,p_object_version_number => p_rec.object_version_number);
6767   --
6768 if g_debug then
6769   hr_utility.set_location(l_proc, 380);
6770 end if;
6771   --
6772   chk_pay_freq_payroll_id
6773   (p_position_id           => p_rec.position_id
6774   ,p_business_group_id     => p_rec.business_group_id
6775   ,p_pay_freq_payroll_id   => p_rec.pay_freq_payroll_id
6776   ,p_validation_start_date => p_validation_start_date
6777   ,p_validation_end_date   => p_validation_end_date
6778   ,p_effective_date        => p_effective_Date
6779   ,p_datetrack_mode        => p_datetrack_mode
6780   ,p_object_version_number => p_rec.object_version_number
6781   );
6782   --
6783 if g_debug then
6784   hr_utility.set_location(l_proc, 390);
6785 end if;
6786   --
6787 /*
6788   chk_position_transaction_id
6789   (p_position_id              => p_rec.position_id
6790   ,p_position_transaction_id  => p_rec.position_transaction_id
6791   ,p_validation_start_date    => p_validation_start_date
6792   ,p_validation_end_date      => p_validation_end_date
6793   ,p_effective_date           => p_effective_date
6794   ,p_object_version_number    => p_rec.object_version_number
6795   );
6796 */
6797   --
6798 if g_debug then
6799   hr_utility.set_location(l_proc, 400);
6800 end if;
6801   --
6802   chk_supervisor_position_id
6803   (p_business_group_id      => p_rec.business_group_id
6804   ,p_position_id            => p_rec.position_id
6805   ,p_supervisor_position_id => p_rec.supervisor_position_id
6806   ,p_validation_start_date  => p_validation_start_date
6807   ,p_validation_end_date    => p_validation_end_date
6808   ,p_effective_date      => p_effective_date
6809   ,p_object_version_number  => p_rec.object_version_number
6810   );
6811   --
6812 if g_debug then
6813   hr_utility.set_location(l_proc, 410);
6814 end if;
6815   --
6816   chk_prior_position_id
6817   (p_business_group_id      => p_rec.business_group_id
6818   ,p_position_id            => p_rec.position_id
6819   ,p_prior_position_id      => p_rec.prior_position_id
6820   ,p_validation_start_date  => p_validation_start_date
6821   ,p_validation_end_date    => p_validation_end_date
6822   ,p_effective_date      => p_effective_date
6823   ,p_object_version_number  => p_rec.object_version_number
6824   );
6825   --
6826 if g_debug then
6827   hr_utility.set_location(l_proc, 420);
6828 end if;
6829   --
6830   chk_availability_status_id
6831    (p_position_id            => p_rec.position_id
6832    ,p_validation_start_date  => p_validation_start_date
6833    ,p_availability_status_id => p_rec.availability_status_id
6834    ,p_old_avail_status_id    => hr_psf_shd.g_old_rec.availability_status_id
6835    ,p_effective_date         => p_effective_date
6836    ,p_date_effective         => p_rec.date_effective
6837    ,p_business_group_id      => p_rec.business_group_id
6838    ,p_object_version_number  => p_rec.object_version_number
6839    ,p_datetrack_mode         => p_datetrack_mode );
6840   --
6841 if g_debug then
6842   hr_utility.set_location(l_proc, 430);
6843 end if;
6844   --
6845   chk_position_type
6846   (p_position_id             => p_rec.position_id
6847   ,p_position_type           => p_rec.position_type
6848   ,p_effective_date          => p_effective_date
6849   ,p_validation_start_date   => p_validation_start_Date
6850   ,p_validation_end_date     => p_validation_end_date
6851   ,p_object_version_number   => p_rec.object_version_number
6852   );
6853   --
6854 if g_debug then
6855   hr_utility.set_location(l_proc, 440);
6856 end if;
6857   --
6858   chk_fte
6859   (p_position_id               => p_rec.position_id
6860   ,p_fte                       => p_rec.fte
6861   ,p_position_type             => p_rec.position_type
6862   ,p_effective_date            => p_effective_date
6863   ,p_validation_start_date     => p_validation_start_date
6864   ,p_validation_end_date       => p_validation_end_Date
6865   ,p_object_version_number     => p_rec.object_version_number);
6866   --
6867 if g_debug then
6868   hr_utility.set_location(l_proc, 445);
6869 end if;
6870   --
6871   chk_max_persons
6872   (p_position_id               => p_rec.position_id
6873   ,p_max_persons               => p_rec.max_persons
6874   ,p_position_type             => p_rec.position_type
6875   ,p_effective_date            => p_effective_date
6876   ,p_object_version_number     => p_rec.object_version_number);
6877   --
6878 if g_debug then
6879   hr_utility.set_location(l_proc, 450);
6880 end if;
6881   --
6882   if (p_rec.position_transaction_id is null)  then
6883   chk_reserved_fte
6884   (p_position_id               => p_rec.position_id
6885   ,p_fte                       => p_rec.fte
6886   ,p_position_type             => p_rec.position_type
6887   ,p_effective_date            => p_effective_date
6888   ,p_validation_start_date     => p_validation_start_date
6889   ,p_validation_end_date       => p_validation_end_Date
6890   ,p_object_version_number     => p_rec.object_version_number);
6891   end if;
6892   --
6893 if g_debug then
6894   hr_utility.set_location(l_proc, 455);
6895 end if;
6896   --
6897   chk_extended_pay
6898   (p_position_id               => p_rec.position_id
6899   ,p_work_period_type_cd       => p_rec.work_period_type_cd
6900   ,p_term_start_day_cd         => p_rec.term_start_day_cd
6901   ,p_term_start_month_cd       => p_rec.term_start_month_cd
6902   ,p_pay_term_end_day_cd       => p_rec.pay_term_end_day_cd
6903   ,p_pay_term_end_month_cd     => p_rec.pay_term_end_month_cd
6904   ,p_work_term_end_day_cd      => p_rec.work_term_end_day_cd
6905   ,p_work_term_end_month_cd    => p_rec.work_term_end_month_cd
6906   );
6907   --
6908 if g_debug then
6909   hr_utility.set_location(l_proc, 460);
6910 end if;
6911   --
6912   chk_proposed_fte_for_layoff
6913   (p_fte                      => p_rec.fte
6914   ,p_proposed_fte_for_layoff  => p_rec.proposed_fte_for_layoff
6915   ,p_proposed_date_for_layoff => p_rec.proposed_Date_for_layoff
6916   );
6917   --
6918 if g_debug then
6919   hr_utility.set_location(l_proc, 470);
6920 end if;
6921   --
6922   --
6923   -- Call the datetrack update integrity operation
6924   --
6925   dt_update_validate
6926     (p_supervisor_position_id        => p_rec.supervisor_position_id,
6927      p_successor_position_id         => p_rec.successor_position_id,
6928      p_relief_position_id            => p_rec.relief_position_id,
6929      p_pay_freq_payroll_id           => p_rec.pay_freq_payroll_id,
6930      p_entry_grade_rule_id           => p_rec.entry_grade_rule_id,
6931      p_entry_step_id                 => p_rec.entry_step_id,
6932      p_datetrack_mode                => p_datetrack_mode,
6933      p_validation_start_date       => p_validation_start_date,
6934      p_validation_end_date      => p_validation_end_date);
6935   --
6936   --
6937 if g_debug then
6938   hr_utility.set_location(l_proc, 480);
6939 end if;
6940   --
6941   --
6942   chk_proposed_status
6943   (p_position_id               =>p_rec.position_id
6944   ,p_availability_status_id    =>p_rec.availability_status_id
6945   ,p_business_group_id         =>p_rec.business_group_id
6946   ,p_effective_date            =>p_effective_date
6947   ,p_validate_start_date       =>p_validation_start_date
6948   ,p_validate_end_date         =>p_validation_end_date
6949   ,p_object_version_number     =>p_rec.object_version_number
6950   ,p_datetrack_mode            =>p_datetrack_mode);
6951   --
6952   -- Call all supporting business operations
6953   --
6954   --
6955 if g_debug then
6956   hr_utility.set_location(l_proc, 490);
6957 end if;
6958   --
6959   -- validate end dates
6960   chk_end_dates
6961   (position_id                => p_rec.position_id
6962   ,availability_status_id     => p_rec.availability_status_id
6963   ,p_effective_date           => p_effective_date
6964   ,current_org_prop_end_date  => p_rec.current_org_prop_end_date
6965   ,current_job_prop_end_date  => p_rec.current_job_prop_end_date
6966   ,avail_status_prop_end_date => p_rec.avail_status_prop_end_date
6967   ,earliest_hire_date         => p_rec.earliest_hire_date
6968   ,fill_by_date               => p_rec.fill_by_date
6969   ,proposed_date_for_layoff   => p_rec.proposed_date_for_layoff
6970   ,date_effective             => p_rec.date_effective );
6971   --
6972 if g_debug then
6973   hr_utility.set_location(l_proc, 500);
6974 end if;
6975   --
6976   -- Validate date effective
6977   --
6978   chk_dates
6979     (p_position_id            => p_rec.position_id
6980     ,p_date_effective      => p_rec.date_effective
6981     ,p_date_end            => p_rec.date_end
6982     ,p_validation_start_date => p_validation_start_date
6983     ,p_validation_end_date   => p_validation_end_date
6984     ,p_effective_Date        => p_effective_date
6985     ,p_object_version_number => p_rec.object_version_number
6986   );
6987   --
6988   --
6989   --
6990 if g_debug then
6991   hr_utility.set_location(l_proc, 510);
6992 end if;
6993   --
6994   chk_seasonal_poi
6995   (p_position_id     => p_rec.position_id
6996   ,p_seasonal_flag      => p_rec.seasonal_flag
6997   ,p_effective_date             => p_effective_date
6998   ,p_validation_start_date      => p_validation_start_Date
6999   ,p_validation_end_date        => p_validation_end_date
7000   ,p_object_version_number      => p_rec.object_version_number);
7001   --
7002 if g_debug then
7003   hr_utility.set_location(l_proc, 520);
7004 end if;
7005   --
7006   chk_overlap_poi
7007   (p_position_id     => p_rec.position_id
7008   ,p_overlap_period     => p_rec.overlap_period
7009   ,p_effective_date             => p_effective_date
7010   ,p_validation_start_date      => p_validation_start_Date
7011   ,p_validation_end_date        => p_validation_end_date
7012   ,p_object_version_number      => p_rec.object_version_number);
7013   --
7014 if g_debug then
7015   hr_utility.set_location(l_proc, 530);
7016 end if;
7017   --
7018 /*
7019 chk_extended_pay_permit
7020 (p_position_id            => p_rec.position_id
7021   ,p_work_period_type_cd        => p_rec.work_period_type_cd
7022   ,p_effective_date             => p_effective_date
7023   ,p_validation_start_date      => p_validation_start_Date
7024   ,p_validation_end_date        => p_validation_end_date
7025   ,p_object_version_number      => p_rec.object_version_number
7026 );
7027   --
7028 if g_debug then
7029   hr_utility.set_location('Entering:'||l_proc, 450);
7030 end if;
7031   --
7032   -- Validate status
7033   --
7034   chk_status
7035     (p_position_id            => p_rec.position_id
7036     ,p_status                 => p_rec.status
7037     ,p_object_version_number  => p_rec.object_version_number
7038   );
7039 */
7040   --
7041 if g_debug then
7042   hr_utility.set_location('Entering:'||l_proc, 600);
7043 end if;
7044   --
7045   -- PMFLETCH ** Not using this uniqueness chech anymore **
7046   -- Check position_name is unique for Business_group
7047   --
7048   --chk_name_unique_for_BG
7049   -- (p_business_group_id    => p_rec.business_group_id
7050   -- ,p_position_id          => p_rec.position_id
7051   -- ,p_effective_date       => p_effective_date
7052   -- ,p_name                 => p_rec.name
7053   -- ,p_object_version_number  => p_rec.object_version_number
7054   -- );
7055   --
7056   -- PMFLETCH Check position_definition_id is unique for business group
7057   --
7058   chk_ccid_unique_for_BG
7059     (p_business_group_id             => p_rec.business_group_id
7060     ,p_position_id                   => p_rec.position_id
7061     ,p_position_definition_id        => p_rec.position_definition_id
7062     ,p_validation_start_date         => p_validation_start_date
7063     ,p_validation_end_date           => p_validation_end_date
7064     ,p_effective_date                => p_effective_date
7065     ,p_object_version_number         => p_rec.object_version_number
7066     );
7067   --
7068   --
7069 if g_debug then
7070   hr_utility.set_location(l_proc, 610);
7071 end if;
7072   --
7073   -- Check validation for position_type change to Single
7074   --
7075   chk_position_type_single
7076   (  p_position_id              => p_rec.position_id
7077     ,p_position_type            => p_rec.position_type
7078     ,p_effective_date           => p_effective_date
7079     ,p_object_version_number    => p_rec.object_version_number);
7080   --
7081 if g_debug then
7082   hr_utility.set_location(l_proc, 620);
7083 end if;
7084   --
7085   --
7086   --
7087   -- Call developer descriptive flexfield validation routines
7088   --
7089   -- hr_psf_bus.chk_ddf(p_rec => p_rec);
7090   --
7091   --
7092 if g_debug then
7093   hr_utility.set_location(l_proc, 630);
7094 end if;
7095   --
7096   -- Call descriptive flexfield validation routines
7097   --
7098   hr_psf_bus.chk_df(p_rec => p_rec);
7099   --
7100   --
7101   -- Call to validate Position Control Business Rules
7102   --
7103   if (per_pqh_shr.position_control_enabled
7104                 ( p_organization_id => p_rec.organization_id
7105                 , p_effective_date  => p_effective_date
7106                 ) = 'Y') then
7107     --
7108     if p_rec.position_transaction_id is null then
7109       hr_utility.set_message(800, 'PER_CANT_CRE_PC_POS_NO_TXN');
7110       hr_utility.raise_error;
7111     end if;
7112     --
7113   end if;
7114   --
7115   per_pqh_shr.hr_psf_bus('UPDATE_VALIDATE',p_rec
7116     ,p_effective_date
7117     ,p_validation_start_date
7118     ,p_validation_end_date
7119     ,p_datetrack_mode);
7120   --
7121   --
7122   --End of Position Control Business Rules call
7123   --
7124   --
7125 if g_debug then
7126   hr_utility.set_location(' Leaving:'||l_proc, 700);
7127 end if;
7128   --
7129 End update_validate;
7130 --
7131 procedure delete_date_effective(p_position_id           in number
7132                                ,p_object_version_number in number
7133                                ,p_business_group_id     in number
7134                                ,p_datetrack_mode        in varchar2 ) is
7135  l_proc varchar2(72) ;
7136  l_next_stat varchar2(30);
7137  l_next_esd date;
7138  l_next_eed date;
7139  l_esd date;
7140  l_eed date;
7141  l_eot date := to_date('31/12/4712','dd/mm/yyyy');
7142 -- fetches the next row info. given effective start date
7143  cursor next_row(p_effective_start_date date) is
7144     select effective_start_date,effective_end_date
7145            ,hr_psf_shd.get_availability_status(availability_status_id,p_business_group_id)
7146     from hr_all_positions_f
7147     where position_id = p_position_id
7148     and effective_start_date > p_effective_start_date
7149     order by effective_start_date ;
7150   cursor current_row is
7151     select effective_start_date,effective_end_date
7152     from hr_all_positions_f
7153     where position_id = p_position_id
7154     and object_version_number = p_object_version_number ;
7155   cursor pos_all is
7156     select date_effective
7157     from hr_all_positions_f
7158     where position_id = p_position_id
7159     for update of date_effective;
7160 begin
7161 if g_debug then
7162  l_proc  := g_package||'delete_date_effective ';
7163   hr_utility.set_location('entering '||l_proc,5);
7164 end if;
7165   if p_datetrack_mode ='DELETE_NEXT_CHANGE' then
7166      open current_row ;
7167      fetch current_row into l_esd,l_eed ;
7168      close current_row ;
7169      -- effective start date of current row is fetched from the database
7170      -- that will be used to fetch the next row and its status
7171      if l_eed < l_eot then
7172 if g_debug then
7173         hr_utility.set_location('first row fetched and next row there '||l_proc,15);
7174 end if;
7175         open next_row(l_esd);
7176         fetch next_row into l_next_esd,l_next_eed,l_next_stat;
7177         if next_row%found then
7178       if l_next_eed <l_eot and l_next_stat = 'ACTIVE' then
7179 if g_debug then
7180               hr_utility.set_location('next row active and next row there '||l_proc,25);
7181 end if;
7182          fetch next_row into l_next_esd,l_next_eed,l_next_stat ;
7183          if l_next_stat = 'ACTIVE' then
7184        -- next to next row is active effective start date of that row will be
7185        -- made date effective for all the rows.
7186 if g_debug then
7187                  hr_utility.set_location('next row active changing date effective '||l_proc,35);
7188 end if;
7189        for i in pos_all loop
7190            update hr_all_positions_f
7191            set date_effective = l_next_esd
7192            where current of pos_all ;
7193        end loop;
7194          end if;
7195       end if;
7196         end if;
7197    close next_row;
7198      end if;
7199   end if;
7200 if g_debug then
7201   hr_utility.set_location('Leaving '||l_proc,100);
7202 end if;
7203 end;
7204 -- ----------------------------------------------------------------------------
7205 -- |-------------------------< pre_delete_checks >-----------------------------|
7206 -- ----------------------------------------------------------------------------
7207 --
7208 PROCEDURE pre_delete_checks(p_position_id        in  number
7209                            ,p_business_group_id  in  number
7210                            ,p_datetrack_mode  in  varchar2
7211                            ) is
7212  --
7213   l_exists                   varchar2(1);
7214   l_pos_structure_element_id number;
7215   l_sql_text                 VARCHAR2(2000);
7216   l_oci_out                  VARCHAR2(1);
7217   l_sql_cursor               NUMBER;
7218   l_rows_fetched             NUMBER;
7219   l_proc                  varchar2(72) ;
7220 
7221 begin
7222 if g_debug then
7223   l_proc                   := g_package||'pre_delete_checks';
7224  hr_utility.set_location('Entering : ' || l_proc, 10);
7225 end if;
7226  if p_datetrack_mode = 'ZAP' then
7227 if g_debug then
7228      hr_utility.set_location(l_proc, 20);
7229 end if;
7230      l_exists := NULL;
7231 --     if p_hr_ins = 'Y' then
7232          l_exists := NULL;
7233          begin
7234          select '1'
7235          into l_exists
7236          from sys.dual
7237          where exists(SELECT  NULL
7238                       from    PER_BUDGET_ELEMENTS BE
7239                       where   BE.POSITION_ID = p_position_id);
7240          exception when no_data_found then
7241                        null;
7242          end;
7243          if l_exists = '1' then
7244            hr_utility.set_message(801,'PER_7417_POS_ASSIGNMENT');
7245            hr_utility.raise_error;
7246          end if;
7247          l_exists := NULL;
7248 if g_debug then
7249          hr_utility.set_location(l_proc, 30);
7250 end if;
7251          begin
7252          select '1'
7253          into l_exists
7254          from sys.dual
7255          where exists(SELECT  NULL
7256                       from    PER_ALL_VACANCIES VAC
7257                       where   VAC.POSITION_ID = p_position_id);
7258          exception when no_data_found then
7259                        null;
7260          end;
7261          if l_exists = '1' then
7262            hr_utility.set_message(801,'PER_7861_DEL_POS_REC_ACT');
7263            hr_utility.raise_error;
7264          end if;
7265 if g_debug then
7266          hr_utility.set_location(l_proc, 40);
7267 end if;
7268          begin
7269          select  e.pos_structure_element_id
7270          into    l_pos_structure_element_id
7271          from    per_pos_structure_elements e
7272          where   e.parent_position_id = p_position_id
7273          and     not exists (
7274                              select  null
7275          from    per_pos_structure_elements e2
7276          where   e2.subordinate_position_id = p_position_id)
7277          and     1 = (
7278                       select  count(e3.pos_structure_element_id)
7279                       from    per_pos_structure_elements e3
7280                       where   e3.parent_position_id = p_position_id);
7281          exception when no_data_found then
7282                         null;
7283          end;
7284 if g_debug then
7285          hr_utility.set_location(l_proc, 50);
7286 end if;
7287          l_exists := NULL;
7288          if l_pos_structure_element_id is null then
7289             begin
7290             select '1'
7291             into l_exists
7292             from sys.dual
7293             where exists(SELECT  NULL
7294                       FROM   PER_POS_STRUCTURE_ELEMENTS PSE
7295                       WHERE  PSE.PARENT_POSITION_ID      = p_position_id
7296                       OR     PSE.SUBORDINATE_POSITION_ID = p_position_id) ;
7297             exception when no_data_found then
7298                         null;
7299             end;
7300 if g_debug then
7301             hr_utility.set_location(l_proc, 70);
7302 end if;
7303             if l_exists = '1' then
7304                hr_utility.set_message(801,'PER_7416_POS_IN_POS_HIER');
7305                hr_utility.raise_error;
7306             end if;
7307          end if;
7308          l_exists := NULL;
7309 if g_debug then
7310          hr_utility.set_location(l_proc, 80);
7311 end if;
7312          begin
7313          select '1'
7314          into l_exists
7315          from sys.dual
7316          where exists(SELECT  NULL
7317                       FROM PER_VALID_GRADES VG1
7318                       WHERE business_group_id + 0 = p_business_group_id
7319                       AND VG1.POSITION_ID = p_position_id);
7320          exception when no_data_found then
7321                         null;
7322          end;
7323 if g_debug then
7324          hr_utility.set_location(l_proc, 90);
7325 end if;
7326          if l_exists = '1' then
7327                hr_utility.set_message(801,'PER_7865_DEF_POS_DEL_GRADE');
7328                hr_utility.raise_error;
7329          end if;
7330          l_exists := NULL;
7331 if g_debug then
7332          hr_utility.set_location(l_proc, 100);
7333 end if;
7334          begin
7335          select '1'
7336          into l_exists
7337          from sys.dual
7338          where exists(select  null
7339                       from per_job_requirements jre1
7340                       where jre1.position_id = p_position_id);
7341          exception when no_data_found then
7342                         null;
7343          end;
7344          if l_exists = '1' then
7345              hr_utility.set_message(801,'PER_7866_DEF_POS_DEL_REQ');
7346              hr_utility.raise_error;
7347          end if;
7348          l_exists := NULL;
7349 if g_debug then
7350          hr_utility.set_location(l_proc, 110);
7351 end if;
7352          begin
7353          select '1'
7354          into l_exists
7355          from sys.dual
7356          where exists(select  null
7357                       from per_job_evaluations jev1
7358                       where jev1.position_id = p_position_id);
7359          exception when no_data_found then
7360                         null;
7361          end;
7362          if l_exists = '1' then
7363              hr_utility.set_message(801,'PER_7867_DEF_POS_DEL_EVAL');
7364              hr_utility.raise_error;
7365          end if;
7366 
7367          l_exists := NULL;
7368 if g_debug then
7369          hr_utility.set_location(l_proc, 120);
7370 end if;
7371          begin
7372          select '1'
7373          into l_exists
7374          from sys.dual
7375          where exists(select  null
7376                       from hr_all_positions_f
7377                       where successor_position_id = p_position_id);
7378          exception when no_data_found then
7379                         null;
7380 
7381          end;
7382 
7383          if l_exists = '1' then
7384              hr_utility.set_message(801,'PER_7996_POS_SUCCESSOR_REF');
7385              hr_utility.raise_error;
7386          end if;
7387 
7388          l_exists := NULL;
7389 if g_debug then
7390          hr_utility.set_location(l_proc, 120);
7391 end if;
7392          begin
7393          select '1'
7394          into l_exists
7395          from sys.dual
7396          where exists(select  null
7397                       from hr_all_positions_f
7398                       where supervisor_position_id = p_position_id);
7399          exception when no_data_found then
7400                         null;
7401 
7402          end;
7403 
7404          if l_exists = '1' then
7405              hr_utility.set_message(800,'HR_PSF_SUPERVISOR_REF');
7406              hr_utility.raise_error;
7407          end if;
7408 
7409          l_exists := NULL;
7410 if g_debug then
7411          hr_utility.set_location(l_proc, 130);
7412 end if;
7413 /*
7414          begin
7415          select '1'
7416          into l_exists
7417          from sys.dual
7418          where exists(select  null
7419                       from per_position_extra_info
7420                       where position_id = p_position_id);
7421          exception when no_data_found then
7422                         null;
7423          end;
7424          if l_exists = '1' then
7425              hr_utility.set_message(800,'HR_DEL_POS_EXTRA_INFO');
7426              hr_utility.raise_error;
7427          end if;
7428 */
7429          l_exists := NULL;
7430 if g_debug then
7431          hr_utility.set_location(l_proc, 140);
7432 end if;
7433 
7434          begin
7435          select '1'
7436          into l_exists
7437          from sys.dual
7438          where exists(select  null
7439                       from per_mm_positions
7440                       where new_position_id = p_position_id);
7441          exception when no_data_found then
7442                         null;
7443          end;
7444 
7445          if l_exists = '1' then
7446              hr_utility.set_message(800,'HR_52776_NOT_DEL_MM_POSITIONS');
7447              hr_utility.raise_error;
7448          end if;
7449          --
7450          l_exists := NULL;
7451 if g_debug then
7452          hr_utility.set_location(l_proc, 150);
7453 end if;
7454 /* new logic
7455          --
7456          begin
7457          select '1'
7458          into l_exists
7459          from sys.dual
7460          where exists(select  null
7461                       from pqh_position_transactions
7462                       where position_id = p_position_id);
7463          exception when no_data_found then
7464                         null;
7465          end;
7466          --
7467          if l_exists = '1' then
7468              hr_utility.set_message(800,'HR_NOT_DEL_PTX');
7469              hr_utility.raise_error;
7470          end if;
7471          --
7472          l_exists := NULL;
7473 if g_debug then
7474          hr_utility.set_location(l_proc, 150);
7475 end if;
7476          --
7477          begin
7478          select '1'
7479          into l_exists
7480          from sys.dual
7481          where exists(select  null
7482                       from pqh_attribute_ranges
7483                       where position_id = p_position_id);
7484          exception when no_data_found then
7485                         null;
7486          end;
7487          --
7488          if l_exists = '1' then
7489              hr_utility.set_message(800,'HR_NOT_DEL_ATT_RANGES');
7490              hr_utility.raise_error;
7491          end if;
7492          --
7493          l_exists := NULL;
7494 if g_debug then
7495          hr_utility.set_location(l_proc, 150);
7496 end if;
7497          --
7498          begin
7499          select '1'
7500          into l_exists
7501          from sys.dual
7502          where exists(select  null
7503                       from pqh_budgets
7504                       where position_id = p_position_id);
7505          exception when no_data_found then
7506                         null;
7507          end;
7508          --
7509          if l_exists = '1' then
7510              hr_utility.set_message(800,'HR_NOT_DEL_BGT');
7511              hr_utility.raise_error;
7512          end if;
7513          --
7514          l_exists := NULL;
7515 if g_debug then
7516          hr_utility.set_location(l_proc, 150);
7517 end if;
7518          --
7519          begin
7520          select '1'
7521          into l_exists
7522          from sys.dual
7523          where exists(select  null
7524                       from pqh_worksheet_details
7525                       where position_id = p_position_id);
7526          exception when no_data_found then
7527                         null;
7528          end;
7529          --
7530          if l_exists = '1' then
7531              hr_utility.set_message(800,'HR_NOT_WKS_DETAIL');
7532              hr_utility.raise_error;
7533          end if;
7534 --     end if;
7535 */
7536     --
7537     -- is po installed?
7538     --
7539 --    if p_po_ins = 'Y' then
7540       begin
7541         l_sql_text := 'select null '
7542            ||' from sys.dual '
7543            ||' where exists( select null '
7544            ||'    from   po_system_parameters '
7545            ||'    where  security_position_structure_id = '
7546            ||to_char(p_position_id)
7547            ||' ) '
7548            ||' or exists( select null '
7549            ||'    from   po_employee_hierarchies '
7550            ||'    where  employee_position_id = '
7551            ||to_char(p_position_id)
7552            ||' or    superior_position_id = '
7553            ||to_char(p_position_id)
7554            ||' ) ';
7555       --
7556       -- Open Cursor for Processing Sql statment.
7557       --
7558 if g_debug then
7559       hr_utility.set_location(l_proc, 150);
7560 end if;
7561       l_sql_cursor := dbms_sql.open_cursor;
7562       --
7563       -- Parse SQL statement.
7564       --
7565       dbms_sql.parse(l_sql_cursor, l_sql_text, dbms_sql.v7);
7566       --
7567       -- Map the local variables to each returned Column
7568       --
7569 if g_debug then
7570       hr_utility.set_location(l_proc, 160);
7571 end if;
7572       dbms_sql.define_column(l_sql_cursor, 1,l_oci_out,1);
7573       --
7574       -- Execute the SQL statement.
7575       --
7576 if g_debug then
7577       hr_utility.set_location(l_proc, 170);
7578 end if;
7579       l_rows_fetched := dbms_sql.execute(l_sql_cursor);
7580       --
7581       if (dbms_sql.fetch_rows(l_sql_cursor) > 0)
7582       then
7583          hr_utility.set_message(800,'HR_6048_PO_POS_DEL_POS_CONT');
7584          hr_utility.raise_error;
7585       end if;
7586       --
7587       -- Close cursor used for processing SQL statement.
7588       --
7589       dbms_sql.close_cursor(l_sql_cursor);
7590 if g_debug then
7591       hr_utility.set_location(l_proc, 180);
7592 end if;
7593       end;
7594 --    end if;
7595     --
7596     --  Ref Int check for OTA.
7597     --
7598     per_ota_predel_validation.ota_predel_pos_validation(p_position_id);
7599 if g_debug then
7600     hr_utility.set_location('Leaving : ' || l_proc, 300);
7601 end if;
7602     --
7603   end if;
7604 end pre_delete_checks;
7605 --
7606 -- ----------------------------------------------------------------------------
7607 -- |---------------------------< delete_validate >----------------------------|
7608 -- ----------------------------------------------------------------------------
7609 Procedure delete_validate
7610    (p_rec          in hr_psf_shd.g_rec_type,
7611     p_effective_date  in date,
7612     p_datetrack_mode  in varchar2,
7613     p_validation_start_date in date,
7614     p_validation_end_date   in date) is
7615 --
7616   l_proc varchar2(72) ;
7617 --
7618 Begin
7619 g_debug := hr_utility.debug_enabled;
7620 if g_debug then
7621  l_proc   := g_package||'delete_validate';
7622   hr_utility.set_location('Entering:'||l_proc, 5);
7623 end if;
7624   --
7625   -- Delete Validations
7626   pre_delete_checks(p_position_id        => p_rec.position_id
7627                    ,p_business_group_id  => p_rec.business_group_id
7628                    ,p_datetrack_mode     => p_datetrack_mode);
7629   --
7630   -- Call all supporting business operations
7631   --
7632   dt_delete_validate
7633     (p_datetrack_mode      => p_datetrack_mode,
7634      p_validation_start_date  => p_validation_start_date,
7635      p_validation_end_date => p_validation_end_date,
7636      p_position_id      => p_rec.position_id);
7637   --
7638   chk_availability_status_id
7639    (p_position_id            => p_rec.position_id
7640    ,p_validation_start_date  => p_validation_start_date
7641    ,p_availability_status_id => p_rec.availability_status_id
7642    ,p_old_avail_status_id    => hr_psf_shd.g_old_rec.availability_status_id
7643    ,p_effective_date         => p_effective_date
7644    ,p_date_effective         => p_rec.date_effective
7645    ,p_business_group_id      => p_rec.business_group_id
7646    ,p_object_version_number  => p_rec.object_version_number
7647    ,p_datetrack_mode         => p_datetrack_mode );
7648    --
7649    -- Bug 3199913 Start
7650    -- check added
7651    --
7652    chk_ref_int_del
7653     (p_position_id            => p_rec.position_id
7654     ,p_validation_start_date  => p_validation_start_date
7655     ,p_validation_end_date    => p_validation_end_date
7656     ,p_datetrack_mode         => p_datetrack_mode );
7657    -- Bug 3199913 End
7658 
7659 -- changes the date effective if only first active row is getting deleted and there is an
7660 -- active row after that in the position.
7661    delete_date_effective(p_position_id           => p_rec.position_id
7662                         ,p_object_version_number => p_rec.object_version_number
7663                         ,p_business_group_id     => p_rec.business_group_id
7664                         ,p_datetrack_mode        => p_datetrack_mode );
7665 
7666 if g_debug then
7667   hr_utility.set_location(' Leaving:'||l_proc, 10);
7668 end if;
7669 End delete_validate;
7670 --
7671 -- -----------------------------------------------------------------------------
7672 -- |-------------------------------< chk_ddf >---------------------------------|
7673 -- -----------------------------------------------------------------------------
7674 --
7675 procedure chk_ddf
7676   (p_rec   in hr_psf_shd.g_rec_type) is
7677 --
7678   l_proc       varchar2(72) ;
7679   l_error      exception;
7680 --
7681 Begin
7682 g_debug := hr_utility.debug_enabled;
7683 if g_debug then
7684  l_proc        := g_package||'chk_ddf';
7685   hr_utility.set_location('Entering:'||l_proc, 5);
7686 end if;
7687   --
7688   -- Check if the row is being inserted or updated and a
7689   -- value has changed
7690   --
7691   if (p_rec.position_id is null)
7692     or ((p_rec.position_id is not null)
7693     and
7694     nvl(hr_psf_shd.g_old_rec.information_category, hr_api.g_varchar2) <>
7695     nvl(p_rec.information_category, hr_api.g_varchar2) or
7696     nvl(hr_psf_shd.g_old_rec.information1, hr_api.g_varchar2) <>
7697     nvl(p_rec.information1, hr_api.g_varchar2) or
7698     nvl(hr_psf_shd.g_old_rec.information2, hr_api.g_varchar2) <>
7699     nvl(p_rec.information2, hr_api.g_varchar2) or
7700     nvl(hr_psf_shd.g_old_rec.information3, hr_api.g_varchar2) <>
7701     nvl(p_rec.information3, hr_api.g_varchar2) or
7702     nvl(hr_psf_shd.g_old_rec.information4, hr_api.g_varchar2) <>
7703     nvl(p_rec.information4, hr_api.g_varchar2) or
7704     nvl(hr_psf_shd.g_old_rec.information5, hr_api.g_varchar2) <>
7705     nvl(p_rec.information5, hr_api.g_varchar2) or
7706     nvl(hr_psf_shd.g_old_rec.information6, hr_api.g_varchar2) <>
7707     nvl(p_rec.information6, hr_api.g_varchar2) or
7708     nvl(hr_psf_shd.g_old_rec.information7, hr_api.g_varchar2) <>
7709     nvl(p_rec.information7, hr_api.g_varchar2) or
7710     nvl(hr_psf_shd.g_old_rec.information8, hr_api.g_varchar2) <>
7711     nvl(p_rec.information8, hr_api.g_varchar2) or
7712     nvl(hr_psf_shd.g_old_rec.information9, hr_api.g_varchar2) <>
7713     nvl(p_rec.information9, hr_api.g_varchar2) or
7714     nvl(hr_psf_shd.g_old_rec.information10, hr_api.g_varchar2) <>
7715     nvl(p_rec.information10, hr_api.g_varchar2) or
7716     nvl(hr_psf_shd.g_old_rec.information11, hr_api.g_varchar2) <>
7717     nvl(p_rec.information11, hr_api.g_varchar2) or
7718     nvl(hr_psf_shd.g_old_rec.information12, hr_api.g_varchar2) <>
7719     nvl(p_rec.information12, hr_api.g_varchar2) or
7720     nvl(hr_psf_shd.g_old_rec.information13, hr_api.g_varchar2) <>
7721     nvl(p_rec.information13, hr_api.g_varchar2) or
7722     nvl(hr_psf_shd.g_old_rec.information14, hr_api.g_varchar2) <>
7723     nvl(p_rec.information14, hr_api.g_varchar2) or
7724     nvl(hr_psf_shd.g_old_rec.information15, hr_api.g_varchar2) <>
7725     nvl(p_rec.information15, hr_api.g_varchar2) or
7726     nvl(hr_psf_shd.g_old_rec.information16, hr_api.g_varchar2) <>
7727     nvl(p_rec.information16, hr_api.g_varchar2) or
7728     nvl(hr_psf_shd.g_old_rec.information17, hr_api.g_varchar2) <>
7729     nvl(p_rec.information17, hr_api.g_varchar2) or
7730     nvl(hr_psf_shd.g_old_rec.information18, hr_api.g_varchar2) <>
7731     nvl(p_rec.information18, hr_api.g_varchar2) or
7732     nvl(hr_psf_shd.g_old_rec.information19, hr_api.g_varchar2) <>
7733     nvl(p_rec.information19, hr_api.g_varchar2) or
7734     nvl(hr_psf_shd.g_old_rec.information20, hr_api.g_varchar2) <>
7735     nvl(p_rec.information20, hr_api.g_varchar2) or
7736     nvl(hr_psf_shd.g_old_rec.information21, hr_api.g_varchar2) <>
7737     nvl(p_rec.information21, hr_api.g_varchar2) or
7738     nvl(hr_psf_shd.g_old_rec.information22, hr_api.g_varchar2) <>
7739     nvl(p_rec.information22, hr_api.g_varchar2) or
7740     nvl(hr_psf_shd.g_old_rec.information23, hr_api.g_varchar2) <>
7741     nvl(p_rec.information23, hr_api.g_varchar2) or
7742     nvl(hr_psf_shd.g_old_rec.information24, hr_api.g_varchar2) <>
7743     nvl(p_rec.information24, hr_api.g_varchar2) or
7744     nvl(hr_psf_shd.g_old_rec.information25, hr_api.g_varchar2) <>
7745     nvl(p_rec.information25, hr_api.g_varchar2) or
7746     nvl(hr_psf_shd.g_old_rec.information26, hr_api.g_varchar2) <>
7747     nvl(p_rec.information26, hr_api.g_varchar2) or
7748     nvl(hr_psf_shd.g_old_rec.information27, hr_api.g_varchar2) <>
7749     nvl(p_rec.information27, hr_api.g_varchar2) or
7750     nvl(hr_psf_shd.g_old_rec.information28, hr_api.g_varchar2) <>
7751     nvl(p_rec.information28, hr_api.g_varchar2) or
7752     nvl(hr_psf_shd.g_old_rec.information29, hr_api.g_varchar2) <>
7753     nvl(p_rec.information29, hr_api.g_varchar2) or
7754     nvl(hr_psf_shd.g_old_rec.information30, hr_api.g_varchar2) <>
7755     nvl(p_rec.information30, hr_api.g_varchar2))
7756   then
7757     --
7758     hr_dflex_utility.ins_or_upd_descflex_attribs
7759       (p_appl_short_name    => 'PER'
7760       ,p_descflex_name      => 'DDF HR_ALL_POSITIONS_F'
7761       ,p_attribute_category => p_rec.information_category
7762       ,p_attribute1_name    => 'information1'
7763       ,p_attribute1_value   => p_rec.information1
7764       ,p_attribute2_name    => 'information2'
7765       ,p_attribute2_value   => p_rec.information2
7766       ,p_attribute3_name    => 'information3'
7767       ,p_attribute3_value   => p_rec.information3
7768       ,p_attribute4_name    => 'information4'
7769       ,p_attribute4_value   => p_rec.information4
7770       ,p_attribute5_name    => 'information5'
7771       ,p_attribute5_value   => p_rec.information5
7772       ,p_attribute6_name    => 'information6'
7773       ,p_attribute6_value   => p_rec.information6
7774       ,p_attribute7_name    => 'information7'
7775       ,p_attribute7_value   => p_rec.information7
7776       ,p_attribute8_name    => 'information8'
7777       ,p_attribute8_value   => p_rec.information8
7778       ,p_attribute9_name    => 'information9'
7779       ,p_attribute9_value   => p_rec.information9
7780       ,p_attribute10_name   => 'information10'
7781       ,p_attribute10_value  => p_rec.information10
7782       ,p_attribute11_name   => 'information11'
7783       ,p_attribute11_value  => p_rec.information11
7784       ,p_attribute12_name   => 'information12'
7785       ,p_attribute12_value  => p_rec.information12
7786       ,p_attribute13_name   => 'information13'
7787       ,p_attribute13_value  => p_rec.information13
7788       ,p_attribute14_name   => 'information14'
7789       ,p_attribute14_value  => p_rec.information14
7790       ,p_attribute15_name   => 'information15'
7791       ,p_attribute15_value  => p_rec.information15
7792       ,p_attribute16_name   => 'information16'
7793       ,p_attribute16_value  => p_rec.information16
7794       ,p_attribute17_name   => 'information17'
7795       ,p_attribute17_value  => p_rec.information17
7796       ,p_attribute18_name   => 'information18'
7797       ,p_attribute18_value  => p_rec.information18
7798       ,p_attribute19_name   => 'information19'
7799       ,p_attribute19_value  => p_rec.information19
7800       ,p_attribute20_name   => 'information20'
7801       ,p_attribute20_value  => p_rec.information20
7802       ,p_attribute21_name   => 'information21'
7803       ,p_attribute21_value  => p_rec.information21
7804       ,p_attribute22_name   => 'information22'
7805       ,p_attribute22_value  => p_rec.information22
7806       ,p_attribute23_name   => 'information23'
7807       ,p_attribute23_value  => p_rec.information23
7808       ,p_attribute24_name   => 'information24'
7809       ,p_attribute24_value  => p_rec.information24
7810       ,p_attribute25_name   => 'information25'
7811       ,p_attribute25_value  => p_rec.information25
7812       ,p_attribute26_name   => 'information26'
7813       ,p_attribute26_value  => p_rec.information26
7814       ,p_attribute27_name   => 'information27'
7815       ,p_attribute27_value  => p_rec.information27
7816       ,p_attribute28_name   => 'information28'
7817       ,p_attribute28_value  => p_rec.information28
7818       ,p_attribute29_name   => 'information29'
7819       ,p_attribute29_value  => p_rec.information29
7820       ,p_attribute30_name   => 'information30'
7821       ,p_attribute30_value  => p_rec.information30
7822       );
7823     --
7824   end if;
7825   --
7826 if g_debug then
7827   hr_utility.set_location(' Leaving:'||l_proc, 10);
7828 end if;
7829 end chk_ddf;
7830 --
7831 -- Location  :    hr_psf_bus package
7832 -- Called in :    insert_validate
7833 --       update_validate. [Must be the last validation. Can be a part of another
7834 --       procedure called from insert/update_validate]
7835 --
7836 
7837 --
7838 -- -----------------------------------------------------------------------
7839 -- |------------------------------< chk_df >-----------------------------|
7840 -- -----------------------------------------------------------------------
7841 --
7842 -- Description:
7843 --   Validates the all Descriptive Flexfield values.
7844 --
7845 -- Pre-conditions:
7846 --   All other columns have been validated. Must be called as the
7847 --   last step from insert_validate and update_validate.
7848 --
7849 -- In Arguments:
7850 --   p_rec
7851 --
7852 -- Post Success:
7853 --   If the Descriptive Flexfield structure column and data values are
7854 --   all valid this procedure will end normally and processing will
7855 --   continue.
7856 --
7857 -- Post Failure:
7858 --   If the Descriptive Flexfield structure column value or any of
7859 --   the data values are invalid then an application error is raised as
7860 --   a PL/SQL exception.
7861 --
7862 -- Access Status:
7863 --   Internal Row Handler Use Only.
7864 --
7865 procedure chk_df
7866   (p_rec in hr_psf_shd.g_rec_type) is
7867 --
7868   l_proc     varchar2(72);
7869 --
7870 begin
7871 g_debug := hr_utility.debug_enabled;
7872 if g_debug then
7873 l_proc      := g_package||'chk_df';
7874   hr_utility.set_location('Entering:'||l_proc, 10);
7875 end if;
7876   --
7877   if ((p_rec.position_id is not null) and (
7878     nvl(hr_psf_shd.g_old_rec.attribute_category, hr_api.g_varchar2) <>
7879     nvl(p_rec.attribute_category, hr_api.g_varchar2) or
7880     nvl(hr_psf_shd.g_old_rec.attribute1, hr_api.g_varchar2) <>
7881     nvl(p_rec.attribute1, hr_api.g_varchar2) or
7882     nvl(hr_psf_shd.g_old_rec.attribute2, hr_api.g_varchar2) <>
7883     nvl(p_rec.attribute2, hr_api.g_varchar2) or
7884     nvl(hr_psf_shd.g_old_rec.attribute3, hr_api.g_varchar2) <>
7885     nvl(p_rec.attribute3, hr_api.g_varchar2) or
7886     nvl(hr_psf_shd.g_old_rec.attribute4, hr_api.g_varchar2) <>
7887     nvl(p_rec.attribute4, hr_api.g_varchar2) or
7888     nvl(hr_psf_shd.g_old_rec.attribute5, hr_api.g_varchar2) <>
7889     nvl(p_rec.attribute5, hr_api.g_varchar2) or
7890     nvl(hr_psf_shd.g_old_rec.attribute6, hr_api.g_varchar2) <>
7891     nvl(p_rec.attribute6, hr_api.g_varchar2) or
7892     nvl(hr_psf_shd.g_old_rec.attribute7, hr_api.g_varchar2) <>
7893     nvl(p_rec.attribute7, hr_api.g_varchar2) or
7894     nvl(hr_psf_shd.g_old_rec.attribute8, hr_api.g_varchar2) <>
7895     nvl(p_rec.attribute8, hr_api.g_varchar2) or
7896     nvl(hr_psf_shd.g_old_rec.attribute9, hr_api.g_varchar2) <>
7897     nvl(p_rec.attribute9, hr_api.g_varchar2) or
7898     nvl(hr_psf_shd.g_old_rec.attribute10, hr_api.g_varchar2) <>
7899     nvl(p_rec.attribute10, hr_api.g_varchar2) or
7900     nvl(hr_psf_shd.g_old_rec.attribute11, hr_api.g_varchar2) <>
7901     nvl(p_rec.attribute11, hr_api.g_varchar2) or
7902     nvl(hr_psf_shd.g_old_rec.attribute12, hr_api.g_varchar2) <>
7903     nvl(p_rec.attribute12, hr_api.g_varchar2) or
7904     nvl(hr_psf_shd.g_old_rec.attribute13, hr_api.g_varchar2) <>
7905     nvl(p_rec.attribute13, hr_api.g_varchar2) or
7906     nvl(hr_psf_shd.g_old_rec.attribute14, hr_api.g_varchar2) <>
7907     nvl(p_rec.attribute14, hr_api.g_varchar2) or
7908     nvl(hr_psf_shd.g_old_rec.attribute15, hr_api.g_varchar2) <>
7909     nvl(p_rec.attribute15, hr_api.g_varchar2) or
7910     nvl(hr_psf_shd.g_old_rec.attribute16, hr_api.g_varchar2) <>
7911     nvl(p_rec.attribute16, hr_api.g_varchar2) or
7912     nvl(hr_psf_shd.g_old_rec.attribute17, hr_api.g_varchar2) <>
7913     nvl(p_rec.attribute17, hr_api.g_varchar2) or
7914     nvl(hr_psf_shd.g_old_rec.attribute18, hr_api.g_varchar2) <>
7915     nvl(p_rec.attribute18, hr_api.g_varchar2) or
7916     nvl(hr_psf_shd.g_old_rec.attribute19, hr_api.g_varchar2) <>
7917     nvl(p_rec.attribute19, hr_api.g_varchar2) or
7918     nvl(hr_psf_shd.g_old_rec.attribute20, hr_api.g_varchar2) <>
7919     nvl(p_rec.attribute20, hr_api.g_varchar2) or
7920     nvl(hr_psf_shd.g_old_rec.attribute21, hr_api.g_varchar2) <>
7921     nvl(p_rec.attribute21, hr_api.g_varchar2) or
7922     nvl(hr_psf_shd.g_old_rec.attribute22, hr_api.g_varchar2) <>
7923     nvl(p_rec.attribute22, hr_api.g_varchar2) or
7924     nvl(hr_psf_shd.g_old_rec.attribute23, hr_api.g_varchar2) <>
7925     nvl(p_rec.attribute23, hr_api.g_varchar2) or
7926     nvl(hr_psf_shd.g_old_rec.attribute24, hr_api.g_varchar2) <>
7927     nvl(p_rec.attribute24, hr_api.g_varchar2) or
7928     nvl(hr_psf_shd.g_old_rec.attribute25, hr_api.g_varchar2) <>
7929     nvl(p_rec.attribute25, hr_api.g_varchar2) or
7930     nvl(hr_psf_shd.g_old_rec.attribute26, hr_api.g_varchar2) <>
7931     nvl(p_rec.attribute26, hr_api.g_varchar2) or
7932     nvl(hr_psf_shd.g_old_rec.attribute27, hr_api.g_varchar2) <>
7933     nvl(p_rec.attribute27, hr_api.g_varchar2) or
7934     nvl(hr_psf_shd.g_old_rec.attribute28, hr_api.g_varchar2) <>
7935     nvl(p_rec.attribute28, hr_api.g_varchar2) or
7936     nvl(hr_psf_shd.g_old_rec.attribute29, hr_api.g_varchar2) <>
7937     nvl(p_rec.attribute29, hr_api.g_varchar2) or
7938     nvl(hr_psf_shd.g_old_rec.attribute30, hr_api.g_varchar2) <>
7939     nvl(p_rec.attribute30, hr_api.g_varchar2)))
7940     or (p_rec.position_id is null) then
7941    --
7942    -- Only execute the validation if absolutely necessary:
7943    -- a) During update, the structure column value or any
7944    --    of the attribute values have actually changed.
7945    -- b) During insert.
7946    --
7947    if nvl(fnd_profile.value('FLEXFIELDS:VALIDATE_ON_SERVER'),'N') = 'Y'
7948        then
7949    hr_dflex_utility.ins_or_upd_descflex_attribs
7950      (p_appl_short_name     => 'PER'
7951       ,p_descflex_name      => 'PER_POSITIONS'
7952       ,p_attribute_category => p_rec.attribute_category
7953       ,p_attribute1_name    => 'ATTRIBUTE1'
7954       ,p_attribute1_value   => p_rec.attribute1
7955       ,p_attribute2_name    => 'ATTRIBUTE2'
7956       ,p_attribute2_value   => p_rec.attribute2
7957       ,p_attribute3_name    => 'ATTRIBUTE3'
7958       ,p_attribute3_value   => p_rec.attribute3
7959       ,p_attribute4_name    => 'ATTRIBUTE4'
7960       ,p_attribute4_value   => p_rec.attribute4
7961       ,p_attribute5_name    => 'ATTRIBUTE5'
7962       ,p_attribute5_value   => p_rec.attribute5
7963       ,p_attribute6_name    => 'ATTRIBUTE6'
7964       ,p_attribute6_value   => p_rec.attribute6
7965       ,p_attribute7_name    => 'ATTRIBUTE7'
7966       ,p_attribute7_value   => p_rec.attribute7
7967       ,p_attribute8_name    => 'ATTRIBUTE8'
7968       ,p_attribute8_value   => p_rec.attribute8
7969       ,p_attribute9_name    => 'ATTRIBUTE9'
7970       ,p_attribute9_value   => p_rec.attribute9
7971       ,p_attribute10_name   => 'ATTRIBUTE10'
7972       ,p_attribute10_value  => p_rec.attribute10
7973       ,p_attribute11_name   => 'ATTRIBUTE11'
7974       ,p_attribute11_value  => p_rec.attribute11
7975       ,p_attribute12_name   => 'ATTRIBUTE12'
7976       ,p_attribute12_value  => p_rec.attribute12
7977       ,p_attribute13_name   => 'ATTRIBUTE13'
7978       ,p_attribute13_value  => p_rec.attribute13
7979       ,p_attribute14_name   => 'ATTRIBUTE14'
7980       ,p_attribute14_value  => p_rec.attribute14
7981       ,p_attribute15_name   => 'ATTRIBUTE15'
7982       ,p_attribute15_value  => p_rec.attribute15
7983       ,p_attribute16_name   => 'ATTRIBUTE16'
7984       ,p_attribute16_value  => p_rec.attribute16
7985       ,p_attribute17_name   => 'ATTRIBUTE17'
7986       ,p_attribute17_value  => p_rec.attribute17
7987       ,p_attribute18_name   => 'ATTRIBUTE18'
7988       ,p_attribute18_value  => p_rec.attribute18
7989       ,p_attribute19_name   => 'ATTRIBUTE19'
7990       ,p_attribute19_value  => p_rec.attribute19
7991       ,p_attribute20_name   => 'ATTRIBUTE20'
7992       ,p_attribute20_value  => p_rec.attribute20
7993       ,p_attribute21_name   => 'ATTRIBUTE21'
7994       ,p_attribute21_value  => p_rec.attribute21
7995       ,p_attribute22_name   => 'ATTRIBUTE22'
7996       ,p_attribute22_value  => p_rec.attribute22
7997       ,p_attribute23_name   => 'ATTRIBUTE23'
7998       ,p_attribute23_value  => p_rec.attribute23
7999       ,p_attribute24_name   => 'ATTRIBUTE24'
8000       ,p_attribute24_value  => p_rec.attribute24
8001       ,p_attribute25_name   => 'ATTRIBUTE25'
8002       ,p_attribute25_value  => p_rec.attribute25
8003       ,p_attribute26_name   => 'ATTRIBUTE26'
8004       ,p_attribute26_value  => p_rec.attribute26
8005       ,p_attribute27_name   => 'ATTRIBUTE27'
8006       ,p_attribute27_value  => p_rec.attribute27
8007       ,p_attribute28_name   => 'ATTRIBUTE28'
8008       ,p_attribute28_value  => p_rec.attribute28
8009       ,p_attribute29_name   => 'ATTRIBUTE29'
8010       ,p_attribute29_value  => p_rec.attribute29
8011       ,p_attribute30_name   => 'ATTRIBUTE30'
8012       ,p_attribute30_value  => p_rec.attribute30
8013       );
8014    end if;
8015   end if;
8016   --
8017 if g_debug then
8018   hr_utility.set_location(' Leaving:'||l_proc, 20);
8019 end if;
8020 
8021 end chk_df;
8022 --
8023 --
8024 --  ---------------------------------------------------------------------------
8025 --  |-------------------------< chk_ref_int_del >-----------------------------|
8026 --  ---------------------------------------------------------------------------
8027 --
8028 --  Description:
8029 --    Validates that a position cannot be purged if foreign key
8030 --    references exist to any of the following tables :
8031 --               - PER_ALL_ASSIGNMENTS_F
8032 --               - PAY_ELEMENT_LINKS_F
8033 --  Pre-conditions:
8034 --    None
8035 --
8036 --  In Arguments:
8037 --    p_position_id
8038 --    p_validation_start_date
8039 --    p_validation_end_date
8040 --    p_datetrack_mode
8041 --
8042 --  Post Success:
8043 --    If no rows exist in the tables listed above then processing continues.
8044 --
8045 --  Post Failure:
8046 --    If rows exist in any of the tables listed above, an application
8047 --    error is raised and processing is terminated.
8048 --
8049 --  Procedure added for bug 3199913
8050 procedure chk_ref_int_del
8051   (p_position_id           in varchar2
8052   ,p_validation_start_date in date
8053   ,p_validation_end_date   in date
8054   ,p_datetrack_mode        in varchar2
8055   )
8056   is
8057 --
8058    l_exists         varchar2(1);
8059    l_proc           varchar2(72)  :=  g_package||'chk_ref_int_del';
8060 --
8061    cursor csr_assgt is
8062      select   null
8063      from     sys.dual
8064      where exists(select   null
8065                   from     per_all_assignments_f
8066                   where    position_id = p_position_id
8067                   and      (p_datetrack_mode = 'ZAP'
8068                   or       (p_datetrack_mode = 'DELETE'
8069                   and       effective_start_date >= p_validation_start_date)));
8070 
8071    cursor csr_element_links is
8072      select null
8073      from sys.dual
8074      where exists(select   null
8075                   from     pay_element_links_f
8076                   where    position_id = p_position_id
8077                   and      (p_datetrack_mode = 'ZAP'
8078                   or       (p_datetrack_mode = 'DELETE'
8079                   and       effective_start_date >= p_validation_start_date)));
8080 
8081    cursor csr_budget_details is
8082      select   null
8083      from     sys.dual
8084      where exists(select   null
8085                   from     pqh_budget_details
8086                   where    position_id = p_position_id
8087                   and      p_datetrack_mode = 'ZAP');
8088 
8089 --
8090 begin
8091   hr_utility.set_location('Entering:'|| l_proc, 1);
8092   --
8093   -- Check that the position is not attached to any assignment
8094   --
8095   open csr_assgt;
8096   fetch csr_assgt into l_exists;
8097   if csr_assgt%found then
8098     close csr_assgt;
8099     hr_utility.set_message(801,'PER_7417_POS_ASSIGNMENT');
8100     hr_utility.raise_error;
8101   end if;
8102   close csr_assgt;
8103   --
8104   hr_utility.set_location(l_proc, 2);
8105   --
8106   -- Check that the position is not attached to any element link
8107   --
8108   open csr_element_links;
8109   fetch csr_element_links into l_exists;
8110   if csr_element_links%found then
8111     close csr_element_links;
8112     hr_utility.set_message(801,'PER_7863_DEL_POS_LINK');
8113     hr_utility.raise_error;
8114   end if;
8115   close csr_element_links;
8116   --
8117   hr_utility.set_location(l_proc, 3);
8118   --
8119   -- Check that the position is not attached to any Budget
8120   --
8121   open csr_budget_details;
8122   fetch csr_budget_details into l_exists;
8123   if csr_budget_details%found then
8124     close csr_budget_details;
8125     hr_utility.set_message(800,'PER_DEL_POSITION_BUDGET');
8126     hr_utility.raise_error;
8127   end if;
8128   close csr_budget_details;
8129   --
8130   --
8131   hr_utility.set_location(' Leaving:'|| l_proc, 11);
8132   --
8133 end chk_ref_int_del;
8134 
8135 --
8136 Function First_active_position_row(
8137   p_position_id          in  number,
8138   p_effective_start_date in  date) return boolean is
8139     --
8140     cursor c1 is
8141       select min(psf.effective_start_date)
8142       from
8143          hr_all_positions_f psf
8144       where psf.position_id = p_position_id
8145         and hr_psf_shd.get_availability_status(psf.availability_status_id
8146                                                ,psf.business_group_id) =  'ACTIVE';
8147 
8148     --
8149     l_minesd        date;
8150     l_proc          varchar2(30);
8151     --
8152 Begin
8153   --
8154 g_debug := hr_utility.debug_enabled;
8155 if g_debug then
8156    l_proc           :='First_active_position_row';
8157   hr_utility.set_location( 'Entering : ' || l_proc, 10);
8158 end if;
8159   open c1;
8160   fetch c1 into l_minesd;
8161   close c1;
8162   --
8163 if g_debug then
8164   hr_utility.set_location( l_proc, 20);
8165 end if;
8166   --
8167   if l_minesd is null or l_minesd = p_effective_start_date then
8168     --
8169 if g_debug then
8170     hr_utility.set_location( l_proc, 30);
8171 end if;
8172     --
8173     return (true);
8174     --
8175   else
8176     --
8177 if g_debug then
8178     hr_utility.set_location( l_proc, 40);
8179 end if;
8180     --
8181     return (false);
8182     --
8183   end if;
8184 if g_debug then
8185   hr_utility.set_location('Leaving : ' || l_proc, 100);
8186 end if;
8187   --
8188 End First_active_position_row;
8189 --
8190 Function First_proposed_only_position(
8191    p_position_id           number,
8192    p_effective_start_date  date) return boolean is
8193 
8194   --
8195   l_rows_not_proposed  number(15);
8196   l_esd              date;
8197   l_proc             varchar2(30)  ;
8198   --
8199   cursor c1 is
8200     select count(*)
8201     from
8202        hr_all_positions_f psf
8203     where psf.position_id = p_position_id
8204         and hr_psf_shd.get_availability_status(psf.availability_status_id
8205                                                ,psf.business_group_id) <>  'PROPOSED';
8206   --
8207   cursor c2 is
8208    select min(psf.effective_Start_Date)
8209    from
8210      hr_all_positions_f psf
8211    where psf.position_id = p_position_id;
8212   --
8213 Begin
8214   --
8215 if g_debug then
8216   l_proc              :='First_proposed_only_position';
8217   hr_utility.set_location('Entering : ' || l_proc, 10);
8218 end if;
8219   open c1;
8220   fetch c1 into l_rows_not_proposed;
8221   if l_rows_not_proposed = 0 then
8222     --
8223 if g_debug then
8224     hr_utility.set_location(l_proc, 20);
8225 end if;
8226     open c2;
8227     fetch c2 into l_esd;
8228     close c2;
8229     if l_esd is null or l_esd = p_effective_Start_date then
8230 if g_debug then
8231       hr_utility.set_location(l_proc, 30);
8232 end if;
8233       return(true);
8234     end if;
8235     --
8236 if g_debug then
8237     hr_utility.set_location(l_proc, 40);
8238 end if;
8239     --
8240   end if;
8241   --
8242 if g_debug then
8243   hr_utility.set_location( 'Leaving : ' || l_proc, 100);
8244 end if;
8245   return(false);
8246   --
8247 End First_proposed_only_position;
8248 --
8249 
8250 Function all_proposed_only_position(
8251    p_position_id           number )
8252  return boolean is
8253 
8254   --
8255   l_rows_not_proposed  number(15);
8256   l_esd              date;
8257   l_proc             varchar2(30)  ;
8258   --
8259   cursor c1 is
8260     select count(*)
8261     from
8262        hr_all_positions_f psf
8263     where psf.position_id = p_position_id
8264         and hr_psf_shd.get_availability_status(psf.availability_status_id
8265                                                ,psf.business_group_id) <>  'PROPOSED';
8266   --
8267 Begin
8268   --
8269 g_debug := hr_utility.debug_enabled;
8270 if g_debug then
8271   l_proc              :='all_proposed_only_position';
8272   hr_utility.set_location('Entering : ' || l_proc, 10);
8273 end if;
8274   open c1;
8275   fetch c1 into l_rows_not_proposed;
8276   if l_rows_not_proposed = 0 then
8277       return(true);
8278   end if;
8279   --
8280 if g_debug then
8281   hr_utility.set_location( 'Leaving : ' || l_proc, 100);
8282 end if;
8283   return(false);
8284   --
8285 End all_proposed_only_position;
8286 --
8287 Function Lower_limit(
8288    p_position_id           in number,
8289    p_effective_start_date  in date) return date is
8290   --
8291   l_esd      date;
8292   l_proc     varchar2(30)  ;
8293   --
8294   cursor c1 is
8295   select
8296      min(psf.effective_start_date)
8297   from
8298      hr_all_positions_f psf
8299   where psf.position_id = p_position_id;
8300   --
8301   cursor c2 is
8302   select max(effective_start_date)
8303   from hr_all_positions_f psf
8304   where psf.position_id = p_position_id
8305     and psf.effective_start_date < p_effective_start_date;
8306   --
8307   l_proposed_only boolean ;
8308   l_sot date ;
8309 Begin
8310   --
8311 if g_debug then
8312   l_proc      :='Lower_limit';
8313   hr_utility.set_location( 'Entering : ' || l_proc, 10);
8314 end if;
8315   l_sot := to_date('01/01/0001','mm/dd/yyyy');
8316   l_proposed_only := hr_psf_bus.all_proposed_only_position(p_position_id);
8317   if l_proposed_only = true then
8318      return(l_sot);
8319   end if;
8320   open c1;
8321   fetch c1 into l_esd;
8322   close c1;
8323   --
8324 if g_debug then
8325   hr_utility.set_location(l_proc, 20);
8326 end if;
8327   --
8328   if l_esd is null or l_esd = p_effective_start_date then
8329 if g_debug then
8330       hr_utility.set_location( 'Leaving : ' || l_proc, 30);
8331 end if;
8332      return(l_sot);
8333   else
8334     --
8335 if g_debug then
8336     hr_utility.set_location(l_proc, 40);
8337 end if;
8338     --
8339     open c2;
8340     fetch c2 into l_esd;
8341     close c2;
8342     --
8343 if g_debug then
8344     hr_utility.set_location( 'Leaving : ' || l_proc, 50);
8345 end if;
8346     --
8347     return(l_esd + 1);
8348     --
8349   end if;
8350   --
8351 End Lower_limit;
8352 --
8353 Function Upper_limit(
8354    p_position_id          in number,
8355    p_effective_Start_date in date) return date is
8356   --
8357   l_esd          date;
8358   l_tmp_esd      date;
8359   l_ret_date     date;
8360   l_eot          date;
8361   l_proc         varchar2(30)  ;
8362   --
8363   cursor c1 is
8364   select max(psf.effective_start_date)
8365     from hr_all_positions_f psf
8366     where psf.position_id = p_position_id;
8367   --
8368   cursor c2 is
8369   select min(effective_start_date)
8370     from per_all_assignments_f paf
8371     where paf.position_id = p_position_id;
8372   --
8373   cursor c3 is
8374   select min(effective_start_date)
8375     from hr_all_positions_f psf
8376     where psf.position_id = p_position_id
8377       and psf.effective_start_date > p_effective_start_date;
8378   --
8379   l_proposed_only boolean;
8380 Begin
8381   --
8382 if g_debug then
8383  l_proc          :='Upper_Limit';
8384   hr_utility.set_location( 'Entering : ' || l_proc, 10);
8385 end if;
8386   l_eot  := to_date('12/31/4712', 'mm/dd/yyyy');
8387   --
8388 if g_debug then
8389   hr_utility.set_location(l_proc, 20);
8390 end if;
8391   l_proposed_only := hr_psf_bus.all_proposed_only_position(p_position_id);
8392   if l_proposed_only = true then
8393      return(l_eot);
8394   else
8395      --
8396      open c1;
8397      fetch c1 into l_esd;
8398      close c1;
8399      --
8400 if g_debug then
8401      hr_utility.set_location(l_proc, 30);
8402 end if;
8403      --
8404      if l_esd is null or l_esd = p_effective_start_date then
8405 if g_debug then
8406         hr_utility.set_location(l_proc, 40);
8407 end if;
8408         --
8409         l_ret_date := l_eot;
8410      elsE
8411         --
8412         l_ret_date := l_esd -1;
8413      end if;
8414      --
8415 if g_debug then
8416      hr_utility.set_location(l_proc, 50);
8417 end if;
8418      --
8419      open c2;
8420      fetch c2 into l_tmp_esd;
8421      close c2;
8422      --
8423 if g_debug then
8424      hr_utility.set_location(l_proc, 60);
8425 end if;
8426      --
8427      if nvl(l_tmp_esd, l_eot) < nvl(l_ret_date, l_eot) then
8428 if g_debug then
8429         hr_utility.set_location(l_proc, 70);
8430 end if;
8431         --
8432         l_ret_date := l_tmp_esd;
8433      end if;
8434      --
8435 if g_debug then
8436      hr_utility.set_location(l_proc, 80);
8437 end if;
8438      --
8439      open c3;
8440      fetch c3 into l_tmp_esd;
8441      close c3;
8442      --
8443 if g_debug then
8444      hr_utility.set_location(l_proc, 90);
8445 end if;
8446      --
8447      if nvl(l_tmp_esd, l_eot) < nvl(l_esd, l_eot) then
8448 if g_debug then
8449        hr_utility.set_location(l_proc, 100);
8450 end if;
8451        --
8452        l_ret_date := l_tmp_esd - 1;
8453      end if;
8454      --
8455 if g_debug then
8456      hr_utility.set_location( 'Leaving : ' || l_proc, 200);
8457 end if;
8458      return(nvl(l_ret_date, l_eot));
8459      --
8460   end if;
8461 END Upper_limit;
8462 --
8463 --
8464 -- Procedure : DE_Update_properties
8465 -- Description : Determines in Date_Effective is updateable and
8466 --               the valid range
8467 --
8468 Procedure DE_Update_properties(
8469   p_position_id           in number,
8470   p_effective_Start_Date  in date,
8471   p_updateable           out nocopy boolean,
8472   p_lower_limit          out nocopy date,
8473   p_upper_limit          out nocopy date) is
8474 
8475   --
8476   l_updateable     Boolean:=false;
8477   --
8478 Begin
8479   --
8480   l_updateable :=  first_active_position_row (p_position_id, p_effective_start_date);
8481   if not l_updateable then
8482     l_updateable :=  hr_psf_bus.all_proposed_only_position(p_position_id);
8483   end if;
8484   --
8485   p_updateable := l_updateable;
8486   --
8487   if l_updateable then
8488      p_lower_limit := lower_limit(p_position_id, p_effective_start_Date);
8489      p_upper_limit := upper_limit(p_position_id, p_effective_start_Date);
8490   end if;
8491 end DE_update_properties;
8492 --
8493 --
8494 -- ----------------------------------------------------------------------------
8495 -- |------< chk_permanent_seasonal_flag >------|
8496 -- ----------------------------------------------------------------------------
8497 --
8498 -- Description
8499 --   This procedure is used to check whether both permanent and seasonal flags
8500 --   are enabled.
8501 --
8502 Procedure chk_permanent_seasonal_flag
8503   (p_position_id               in number
8504   ,p_permanent_temporary_flag   in varchar2
8505   ,p_seasonal_flag             in varchar2
8506   ,p_effective_date            in date
8507   ,p_object_version_number     in number) is
8508   --
8509   l_proc         varchar2(72) ;
8510   l_api_updating boolean;
8511   --
8512 Begin
8513   --
8514 if g_debug then
8515   l_proc          := g_package||'chk_permanent_seasonal_flag';
8516   hr_utility.set_location('Entering:'||l_proc, 5);
8517 end if;
8518   --
8519   l_api_updating := hr_psf_shd.api_updating
8520     (p_position_id            => p_position_id
8521     ,p_effective_date         => p_effective_date
8522     ,p_object_version_number  => p_object_version_number);
8523   --
8524   if ((l_api_updating and
8525       (p_permanent_temporary_flag <> nvl(hr_psf_shd.g_old_rec.permanent_temporary_flag,hr_api.g_varchar2)
8526       or p_seasonal_flag <> nvl(hr_psf_shd.g_old_rec.seasonal_flag,hr_api.g_varchar2)))
8527       or not l_api_updating) then
8528       if (p_permanent_temporary_flag is not null and p_seasonal_flag is not null) then
8529       	if(p_seasonal_flag = 'Y' and p_permanent_temporary_flag = 'Y') then
8530   	  -- raise error as both flags are set to Y.
8531 	  --
8532           hr_utility.set_message(8302,'PQH_INV_PRMNT_SEASONAL_FLAG');
8533           hr_utility.raise_error;
8534         end if;
8535       end if;
8536   end if;
8537   --
8538 if g_debug then
8539   hr_utility.set_location('Leaving:'||l_proc,10);
8540 end if;
8541   --
8542 end chk_permanent_seasonal_flag;
8543 --
8544 
8545 end hr_psf_bus;