DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PDT_BUS

Source


1 Package Body hr_pdt_bus as
2 /* $Header: hrpdtrhi.pkb 120.4.12010000.2 2008/08/06 08:46:56 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_pdt_bus.';  -- Global package name
9 g_debug    boolean      := hr_utility.debug_enabled;
10 --
11 -- The following two global variables are only to be
12 -- used by the return_legislation_code function.
13 --
14 g_legislation_code            varchar2(150)  default null;
15 g_person_deployment_id        number         default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------< set_security_group_id >--------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21 Procedure set_security_group_id
22   (p_person_deployment_id                 in number
23   ) is
24   --
25   -- Declare cursor
26   --
27   cursor csr_sec_grp is
28     select pbg.security_group_id,
29            pbg.legislation_code
30       from per_business_groups_perf pbg
31          , hr_person_deployments pdt
32      where pdt.person_deployment_id = p_person_deployment_id
33          and pbg.business_group_id = pdt.to_business_group_id;
34   --
35   -- Declare local variables
36   --
37   l_security_group_id number;
38   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
39   l_legislation_code  varchar2(150);
40   --
41 begin
42   --
43   hr_utility.set_location('Entering:'|| l_proc, 10);
44   --
45   -- Ensure that all the mandatory parameter are not null
46   --
47   hr_api.mandatory_arg_error
48     (p_api_name           => l_proc
49     ,p_argument           => 'person_deployment_id'
50     ,p_argument_value     => p_person_deployment_id
51     );
52   --
53   open csr_sec_grp;
54   fetch csr_sec_grp into l_security_group_id
55                        , l_legislation_code;
56   --
57   if csr_sec_grp%notfound then
58      --
59      close csr_sec_grp;
60      --
61      -- The primary key is invalid therefore we must error
62      --
63      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
64      fnd_message.raise_error;
65      --
66   else
67     close csr_sec_grp;
68     --
69     -- Set the security_group_id in CLIENT_INFO
70     --
71     hr_api.set_security_group_id
72       (p_security_group_id => l_security_group_id
73       );
74     --
75     -- Set the sessions legislation context in HR_SESSION_DATA
76     --
77     hr_api.set_legislation_context(l_legislation_code);
78   end if;
79   --
80   hr_utility.set_location(' Leaving:'|| l_proc, 20);
81   --
82 end set_security_group_id;
83 --
84 --  ---------------------------------------------------------------------------
85 --  |---------------------< return_legislation_code >-------------------------|
86 --  ---------------------------------------------------------------------------
87 --
88 Function return_legislation_code
89   (p_person_deployment_id                 in     number
90   )
91   Return Varchar2 Is
92   --
93   -- Declare cursor
94   --
95   cursor csr_leg_code is
96     select pbg.legislation_code
97       from per_business_groups_perf     pbg
98          , hr_person_deployments pdt
99      where pdt.person_deployment_id = p_person_deployment_id
100          and pbg.business_group_id = pdt.to_business_group_id;
101   --
102   -- Declare local variables
103   --
104   l_legislation_code  varchar2(150);
105   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
106   --
107 Begin
108   --
109   hr_utility.set_location('Entering:'|| l_proc, 10);
110   --
111   -- Ensure that all the mandatory parameter are not null
112   --
113   hr_api.mandatory_arg_error
114     (p_api_name           => l_proc
115     ,p_argument           => 'person_deployment_id'
116     ,p_argument_value     => p_person_deployment_id
117     );
118   --
119   if ( nvl(hr_pdt_bus.g_person_deployment_id, hr_api.g_number)
120        = p_person_deployment_id) then
121     --
122     -- The legislation code has already been found with a previous
123     -- call to this function. Just return the value in the global
124     -- variable.
125     --
126     l_legislation_code := hr_pdt_bus.g_legislation_code;
127     hr_utility.set_location(l_proc, 20);
128   else
129     --
130     -- The ID is different to the last call to this function
131     -- or this is the first call to this function.
132     --
133     open csr_leg_code;
134     fetch csr_leg_code into l_legislation_code;
135     --
136     if csr_leg_code%notfound then
137       --
138       -- The primary key is invalid therefore we must error
139       --
140       close csr_leg_code;
141       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
142       fnd_message.raise_error;
143     end if;
144     hr_utility.set_location(l_proc,30);
145     --
146     -- Set the global variables so the values are
147     -- available for the next call to this function.
148     --
149     close csr_leg_code;
150     hr_pdt_bus.g_person_deployment_id        := p_person_deployment_id;
151     hr_pdt_bus.g_legislation_code  := l_legislation_code;
152   end if;
153   hr_utility.set_location(' Leaving:'|| l_proc, 40);
154   return l_legislation_code;
155 end return_legislation_code;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< chk_ddf >----------------------------------|
159 -- ----------------------------------------------------------------------------
160 --
161 -- Description:
162 --   Validates all the Developer Descriptive Flexfield values.
163 --
164 -- Prerequisites:
165 --   All other columns have been validated.  Must be called as the
166 --   last step from insert_validate and update_validate.
167 --
168 -- In Arguments:
169 --   p_rec
170 --
171 -- Post Success:
172 --   If the Developer Descriptive Flexfield structure column and data values
173 --   are all valid this procedure will end normally and processing will
174 --   continue.
175 --
176 -- Post Failure:
177 --   If the Developer Descriptive Flexfield structure column value or any of
178 --   the data values are invalid then an application error is raised as
179 --   a PL/SQL exception.
180 --
181 -- Access Status:
182 --   Internal Row Handler Use Only.
183 --
184 -- ----------------------------------------------------------------------------
185 procedure chk_ddf
186   (p_rec in hr_pdt_shd.g_rec_type
187   ) is
188 --
189   l_proc   varchar2(72) := g_package || 'chk_ddf';
190 --
191 begin
192   hr_utility.set_location('Entering:'||l_proc,10);
193   --
194   if ((p_rec.person_deployment_id is not null)  and (
195     nvl(hr_pdt_shd.g_old_rec.per_information_category, hr_api.g_varchar2) <>
196     nvl(p_rec.per_information_category, hr_api.g_varchar2)  or
197     nvl(hr_pdt_shd.g_old_rec.per_information1, hr_api.g_varchar2) <>
198     nvl(p_rec.per_information1, hr_api.g_varchar2)  or
199     nvl(hr_pdt_shd.g_old_rec.per_information2, hr_api.g_varchar2) <>
200     nvl(p_rec.per_information2, hr_api.g_varchar2)  or
201     nvl(hr_pdt_shd.g_old_rec.per_information3, hr_api.g_varchar2) <>
202     nvl(p_rec.per_information3, hr_api.g_varchar2)  or
203     nvl(hr_pdt_shd.g_old_rec.per_information4, hr_api.g_varchar2) <>
204     nvl(p_rec.per_information4, hr_api.g_varchar2)  or
205     nvl(hr_pdt_shd.g_old_rec.per_information5, hr_api.g_varchar2) <>
206     nvl(p_rec.per_information5, hr_api.g_varchar2)  or
207     nvl(hr_pdt_shd.g_old_rec.per_information6, hr_api.g_varchar2) <>
208     nvl(p_rec.per_information6, hr_api.g_varchar2)  or
209     nvl(hr_pdt_shd.g_old_rec.per_information7, hr_api.g_varchar2) <>
210     nvl(p_rec.per_information7, hr_api.g_varchar2)  or
211     nvl(hr_pdt_shd.g_old_rec.per_information8, hr_api.g_varchar2) <>
212     nvl(p_rec.per_information8, hr_api.g_varchar2)  or
213     nvl(hr_pdt_shd.g_old_rec.per_information9, hr_api.g_varchar2) <>
214     nvl(p_rec.per_information9, hr_api.g_varchar2)  or
215     nvl(hr_pdt_shd.g_old_rec.per_information10, hr_api.g_varchar2) <>
216     nvl(p_rec.per_information10, hr_api.g_varchar2)  or
217     nvl(hr_pdt_shd.g_old_rec.per_information11, hr_api.g_varchar2) <>
218     nvl(p_rec.per_information11, hr_api.g_varchar2)  or
219     nvl(hr_pdt_shd.g_old_rec.per_information12, hr_api.g_varchar2) <>
220     nvl(p_rec.per_information12, hr_api.g_varchar2)  or
221     nvl(hr_pdt_shd.g_old_rec.per_information13, hr_api.g_varchar2) <>
222     nvl(p_rec.per_information13, hr_api.g_varchar2)  or
223     nvl(hr_pdt_shd.g_old_rec.per_information14, hr_api.g_varchar2) <>
224     nvl(p_rec.per_information14, hr_api.g_varchar2)  or
225     nvl(hr_pdt_shd.g_old_rec.per_information15, hr_api.g_varchar2) <>
226     nvl(p_rec.per_information15, hr_api.g_varchar2)  or
227     nvl(hr_pdt_shd.g_old_rec.per_information16, hr_api.g_varchar2) <>
228     nvl(p_rec.per_information16, hr_api.g_varchar2)  or
229     nvl(hr_pdt_shd.g_old_rec.per_information17, hr_api.g_varchar2) <>
230     nvl(p_rec.per_information17, hr_api.g_varchar2)  or
231     nvl(hr_pdt_shd.g_old_rec.per_information18, hr_api.g_varchar2) <>
232     nvl(p_rec.per_information18, hr_api.g_varchar2)  or
233     nvl(hr_pdt_shd.g_old_rec.per_information19, hr_api.g_varchar2) <>
234     nvl(p_rec.per_information19, hr_api.g_varchar2)  or
235     nvl(hr_pdt_shd.g_old_rec.per_information20, hr_api.g_varchar2) <>
236     nvl(p_rec.per_information20, hr_api.g_varchar2)  or
237     nvl(hr_pdt_shd.g_old_rec.per_information21, hr_api.g_varchar2) <>
238     nvl(p_rec.per_information21, hr_api.g_varchar2)  or
239     nvl(hr_pdt_shd.g_old_rec.per_information22, hr_api.g_varchar2) <>
240     nvl(p_rec.per_information22, hr_api.g_varchar2)  or
241     nvl(hr_pdt_shd.g_old_rec.per_information23, hr_api.g_varchar2) <>
242     nvl(p_rec.per_information23, hr_api.g_varchar2)  or
243     nvl(hr_pdt_shd.g_old_rec.per_information24, hr_api.g_varchar2) <>
244     nvl(p_rec.per_information24, hr_api.g_varchar2)  or
245     nvl(hr_pdt_shd.g_old_rec.per_information25, hr_api.g_varchar2) <>
246     nvl(p_rec.per_information25, hr_api.g_varchar2)  or
247     nvl(hr_pdt_shd.g_old_rec.per_information26, hr_api.g_varchar2) <>
248     nvl(p_rec.per_information26, hr_api.g_varchar2)  or
249     nvl(hr_pdt_shd.g_old_rec.per_information27, hr_api.g_varchar2) <>
250     nvl(p_rec.per_information27, hr_api.g_varchar2)  or
251     nvl(hr_pdt_shd.g_old_rec.per_information28, hr_api.g_varchar2) <>
252     nvl(p_rec.per_information28, hr_api.g_varchar2)  or
253     nvl(hr_pdt_shd.g_old_rec.per_information29, hr_api.g_varchar2) <>
254     nvl(p_rec.per_information29, hr_api.g_varchar2)  or
255     nvl(hr_pdt_shd.g_old_rec.per_information30, hr_api.g_varchar2) <>
256     nvl(p_rec.per_information30, hr_api.g_varchar2) ))
257     or (p_rec.person_deployment_id is null)  then
258     --
259     -- Only execute the validation if absolutely necessary:
260     -- a) During update, the structure column value or any
261     --    of the attribute values have actually changed.
262     -- b) During insert.
263     --
264     hr_dflex_utility.ins_or_upd_descflex_attribs
265       (p_appl_short_name                 => 'PER'
266       ,p_descflex_name                   => 'Person Developer DF'
267       ,p_attribute_category              => p_rec.per_information_category
268       ,p_attribute1_name                 => 'PER_INFORMATION1'
269       ,p_attribute1_value                => p_rec.per_information1
270       ,p_attribute2_name                 => 'PER_INFORMATION2'
271       ,p_attribute2_value                => p_rec.per_information2
272       ,p_attribute3_name                 => 'PER_INFORMATION3'
273       ,p_attribute3_value                => p_rec.per_information3
274       ,p_attribute4_name                 => 'PER_INFORMATION4'
275       ,p_attribute4_value                => p_rec.per_information4
276       ,p_attribute5_name                 => 'PER_INFORMATION5'
277       ,p_attribute5_value                => p_rec.per_information5
278       ,p_attribute6_name                 => 'PER_INFORMATION6'
279       ,p_attribute6_value                => p_rec.per_information6
280       ,p_attribute7_name                 => 'PER_INFORMATION7'
281       ,p_attribute7_value                => p_rec.per_information7
282       ,p_attribute8_name                 => 'PER_INFORMATION8'
283       ,p_attribute8_value                => p_rec.per_information8
284       ,p_attribute9_name                 => 'PER_INFORMATION9'
285       ,p_attribute9_value                => p_rec.per_information9
286       ,p_attribute10_name                => 'PER_INFORMATION10'
287       ,p_attribute10_value               => p_rec.per_information10
288       ,p_attribute11_name                => 'PER_INFORMATION11'
289       ,p_attribute11_value               => p_rec.per_information11
290       ,p_attribute12_name                => 'PER_INFORMATION12'
291       ,p_attribute12_value               => p_rec.per_information12
292       ,p_attribute13_name                => 'PER_INFORMATION13'
293       ,p_attribute13_value               => p_rec.per_information13
294       ,p_attribute14_name                => 'PER_INFORMATION14'
295       ,p_attribute14_value               => p_rec.per_information14
296       ,p_attribute15_name                => 'PER_INFORMATION15'
297       ,p_attribute15_value               => p_rec.per_information15
298       ,p_attribute16_name                => 'PER_INFORMATION16'
299       ,p_attribute16_value               => p_rec.per_information16
300       ,p_attribute17_name                => 'PER_INFORMATION17'
301       ,p_attribute17_value               => p_rec.per_information17
302       ,p_attribute18_name                => 'PER_INFORMATION18'
303       ,p_attribute18_value               => p_rec.per_information18
304       ,p_attribute19_name                => 'PER_INFORMATION19'
305       ,p_attribute19_value               => p_rec.per_information19
306       ,p_attribute20_name                => 'PER_INFORMATION20'
307       ,p_attribute20_value               => p_rec.per_information20
308       ,p_attribute21_name                => 'PER_INFORMATION21'
309       ,p_attribute21_value               => p_rec.per_information21
310       ,p_attribute22_name                => 'PER_INFORMATION22'
311       ,p_attribute22_value               => p_rec.per_information22
312       ,p_attribute23_name                => 'PER_INFORMATION23'
313       ,p_attribute23_value               => p_rec.per_information23
314       ,p_attribute24_name                => 'PER_INFORMATION24'
315       ,p_attribute24_value               => p_rec.per_information24
316       ,p_attribute25_name                => 'PER_INFORMATION25'
317       ,p_attribute25_value               => p_rec.per_information25
318       ,p_attribute26_name                => 'PER_INFORMATION26'
319       ,p_attribute26_value               => p_rec.per_information26
320       ,p_attribute27_name                => 'PER_INFORMATION27'
321       ,p_attribute27_value               => p_rec.per_information27
322       ,p_attribute28_name                => 'PER_INFORMATION28'
323       ,p_attribute28_value               => p_rec.per_information28
324       ,p_attribute29_name                => 'PER_INFORMATION29'
325       ,p_attribute29_value               => p_rec.per_information29
326       ,p_attribute30_name                => 'PER_INFORMATION30'
327       ,p_attribute30_value               => p_rec.per_information30
328       );
329   end if;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc,20);
332 end chk_ddf;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |-----------------------< chk_non_updateable_args >------------------------|
336 -- ----------------------------------------------------------------------------
337 -- {Start Of Comments}
338 --
339 -- Description:
340 --   This procedure is used to ensure that non updateable attributes have
341 --   not been updated. If an attribute has been updated an error is generated.
342 --
343 -- Pre Conditions:
344 --   g_old_rec has been populated with details of the values currently in
345 --   the database.
346 --
347 -- In Arguments:
348 --   p_rec has been populated with the updated values the user would like the
349 --   record set to.
350 --
351 -- Post Success:
352 --   Processing continues if all the non updateable attributes have not
353 --   changed.
354 --
355 -- Post Failure:
356 --   An application error is raised if any of the non updatable attributes
357 --   have been altered.
358 --
359 -- {End Of Comments}
360 -- ----------------------------------------------------------------------------
361 Procedure chk_non_updateable_args
362   (p_rec in hr_pdt_shd.g_rec_type
363   ) IS
364 --
365   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
366   l_error       exception;
367   l_argument    varchar2(30);
368 --
369 Begin
370   --
371   hr_utility.set_location('Entering:'|| l_proc,10);
372   --
373   -- Only proceed with the validation if a row exists for the current
374   -- record in the HR Schema.
375   --
376   IF NOT hr_pdt_shd.api_updating
377       (p_person_deployment_id              => p_rec.person_deployment_id
378       ,p_object_version_number             => p_rec.object_version_number
379       ) THEN
380      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
381      fnd_message.set_token('PROCEDURE ', l_proc);
382      fnd_message.set_token('STEP ', '5');
383      fnd_message.raise_error;
384   END IF;
385   --
386   if nvl(p_rec.from_business_group_id,hr_api.g_number)
387         <> nvl(hr_pdt_shd.g_old_rec.from_business_group_id,hr_api.g_number) then
388      l_argument := 'from_business_group';
389      raise l_error;
390   end if;
391   --
392   if nvl(p_rec.to_business_group_id,hr_api.g_number)
393         <> nvl(hr_pdt_shd.g_old_rec.to_business_group_id,hr_api.g_number) then
394      l_argument := 'to_business_group';
395      raise l_error;
396   end if;
397   --
398   if nvl(p_rec.from_person_id,hr_api.g_number)
399         <> nvl(hr_pdt_shd.g_old_rec.from_person_id,hr_api.g_number) then
400      l_argument := 'from_person_id';
401      raise l_error;
402   end if;
403   --
404   if nvl(p_rec.permanent,hr_api.g_number)
405         <> nvl(hr_pdt_shd.g_old_rec.permanent,hr_api.g_number) then
406      l_argument := 'permanent';
407      raise l_error;
408   end if;
409   --
410   --
411   hr_utility.set_location(' Leaving : '|| l_proc, 30);
412   --
413   exception
414     when l_error then
415        hr_api.argument_changed_error
416          (p_api_name => l_proc
417          ,p_argument => l_argument);
418     when others then
419        raise;
420 End chk_non_updateable_args;
421 --
422 --  ---------------------------------------------------------------------------
423 --  |------------------------< chk_business_groups >--------------------------|
424 --  ---------------------------------------------------------------------------
425 --
426 --  Desciption:
427 --    This procedures validates that both from and to business group ids exist
428 --    in per_business_groups
429 --
430 --  Pre-conditions :
431 --    None
432 --
433 --  In Parameters :
434 --    p_from_business_group_id
435 --    p_to_business_group_id
436 --
437 --  Post Success :
438 --    Processing continues if the  is valid
439 --
440 --  Post Failure :
441 --    An application error will be raised and processing is terminated if the
442 --     is invalid
443 --
444 --  Access Status :
445 --    Internal Row Handler Use only.
446 --
447 -- {End of Comments}
448 --
449 -- ---------------------------------------------------------------------------
450 Procedure chk_business_groups
451   (p_from_business_group_id in hr_person_deployments.from_business_group_id%type
452   ,p_to_business_group_id in hr_person_deployments.to_business_group_id%type
453   ) is
454   --
455   l_proc        varchar2(72) := g_package||'chk_business_groups';
456   l_dummy       number;
457   --
458   cursor csr_bg_exists(p_bg_id in number) is
459   select 1
460   from   per_business_groups_perf
461   where  business_group_id = p_bg_id;
462 begin
463   hr_utility.set_location('Entering:'||l_proc, 10);
464   --
465   hr_api.mandatory_arg_error
466     (p_api_name       => l_proc
467     ,p_argument       => 'from_business_group_id'
468     ,p_argument_value => p_from_business_group_id
469     );
470   --
471   hr_api.mandatory_arg_error
472     (p_api_name       => l_proc
473     ,p_argument       => 'to_business_group_id'
474     ,p_argument_value => p_to_business_group_id
475     );
476   --
477   open csr_bg_exists(p_from_business_group_id);
478   fetch csr_bg_exists into l_dummy;
479   if csr_bg_exists%notfound then
480      close csr_bg_exists;
481      fnd_message.set_name('PER','HR_449627_PDT_FROM_BG_NOTEXIST');
482      hr_multi_message.add
483       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.FROM_BUSINESS_GROUP_ID');
484   else
485      close csr_bg_exists;
486   end if;
487   --
488   open csr_bg_exists(p_to_business_group_id);
489   fetch csr_bg_exists into l_dummy;
490   if csr_bg_exists%notfound then
491      close csr_bg_exists;
492      fnd_message.set_name('PER','HR_449628_PDT_TO_BG_NOTEXIST');
493      hr_multi_message.add
494       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID');
495   else
496      close csr_bg_exists;
497   end if;
498   --
499   hr_utility.set_location('Leaving:'||l_proc, 20);
500   --
501 end chk_business_groups;
502 --
503 --  ---------------------------------------------------------------------------
504 --  |------------------------< chk_from_person_id >---------------------------|
505 --  ---------------------------------------------------------------------------
506 --
507 --  Desciption:
508 --    This procedures validates that the from person id exists on the start date in
509 --    the from business group in per_all_people_f
510 --
511 --  Pre-conditions :
512 --    None
513 --
514 --  In Parameters :
515 --    p_from_person_id
516 --    p_from_business_group_id
517 --    p_start_date
518 --
519 --  Post Success :
520 --    Processing continues if the  is valid
521 --
522 --  Post Failure :
523 --    An application error will be raised and processing is terminated if the
524 --     is invalid
525 --
526 --  Access Status :
527 --    Internal Row Handler Use only.
528 --
529 -- {End of Comments}
530 --
531 -- ---------------------------------------------------------------------------
532 Procedure chk_from_person_id
533   (p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
534   ,p_object_version_number  in hr_person_deployments.object_version_number%type
535   ,p_from_person_id         in hr_person_deployments.from_person_id%type
536   ,p_from_business_group_id in hr_person_deployments.from_business_group_id%type
537   ,p_start_date             in date
538   ) is
539   --
540   l_proc        varchar2(72) := g_package||'chk_from_person_id';
541   l_dummy       number;
542   l_api_updating     boolean;
543   --
544   cursor csr_check_person(p_person_id number, p_effective_date in date) is
545   select 1
546   from   per_all_people_f per,
547          per_periods_of_service pds
548   where  per.person_id = p_person_id
549   and    p_effective_date between
550          per.effective_start_date and per.effective_end_date
551   and    per.business_group_id = p_from_business_group_id
552   and    pds.person_id = per.person_id
553   and    p_start_date between
554          pds.date_start and nvl(pds.actual_termination_date,hr_api.g_eot);
555   --
556 begin
557   hr_utility.set_location('Entering:'||l_proc, 10);
558   --
559   -- Check mandatory parameters have been set
560   --
561   hr_api.mandatory_arg_error
562     (p_api_name       => l_proc
563     ,p_argument       => 'from_business_group_id'
564     ,p_argument_value => p_from_business_group_id
565     );
566   --
567   hr_api.mandatory_arg_error
568     (p_api_name       => l_proc
569     ,p_argument       => 'from_person_id'
570     ,p_argument_value => p_from_person_id
571     );
572   --
573   hr_api.mandatory_arg_error
574     (p_api_name       => l_proc
575     ,p_argument       => 'start_date'
576     ,p_argument_value => p_start_date
577     );
578   --
579   if hr_multi_message.no_exclusive_error
580      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.FROM_BUSINESS_GROUP_ID'
581      ) then
582     --
583     l_api_updating := hr_pdt_shd.api_updating
584            (p_person_deployment_id   => p_person_deployment_id
585            ,p_object_version_number  => p_object_version_number);
586     --
587     --
588     --  Only proceed with validation if:
589     --  a) rec is being inserted or
590     --  b) rec is updating and the g_old_rec is not current value
591     --
592     if ( (l_api_updating and (hr_pdt_shd.g_old_rec.start_date <> p_start_date))
593         or not l_api_updating)
594     then
595       open csr_check_person(p_from_person_id, p_start_date);
596       fetch csr_check_person into l_dummy;
597       if csr_check_person%notfound then
598          close csr_check_person;
599          --
600          fnd_message.set_name('PER','HR_449629_PDT_FR_PER_NOTEXIST');
601          fnd_message.raise_error;
602       else
603          close csr_check_person;
604       end if;
605       --
606     end if;
607   end if;
608   --
609   hr_utility.set_location('Leaving:'||l_proc, 20);
610   --
611   exception
612     when app_exception.application_exception then
613       if hr_multi_message.exception_add
614       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.FROM_PERSON_ID'
615       ) then
616         hr_utility.set_location(' Leaving:'||l_proc, 50);
617         raise;
618       end if;
619    hr_utility.set_location(' Leaving:'||l_proc,60);
620 end chk_from_person_id;
621 --
622 --  ---------------------------------------------------------------------------
623 --  |------------------------< chk_to_person_id >-----------------------------|
624 --  ---------------------------------------------------------------------------
625 --
626 --  Desciption:
627 --    This procedures validates that if specified, the to person id exists on the
628 --   start date in to business group in per_all_people_f, and the to_person_id is
629 --   not of type EMP,CWK, or APL on the start_date or in the future
630 --
631 --  Pre-conditions :
632 --    None
633 --
634 --  In Parameters :
635 --    p_to_person_id
636 --    p_to_business_group_id
637 --    p_start_date
638 --    p_status
639 --
640 --  Post Success :
641 --    Processing continues if the to_person_id is valid
642 --
643 --  Post Failure :
644 --    An application error will be raised and processing is terminated if the
645 --    to_person_id is invalid
646 --
647 --  Access Status :
648 --    Internal Row Handler Use only.
649 --
650 -- {End of Comments}
651 --
652 -- ---------------------------------------------------------------------------
653 Procedure chk_to_person_id
654   (p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
655   ,p_object_version_number  in hr_person_deployments.object_version_number%type
656   ,p_to_person_id           in hr_person_deployments.to_person_id%type
657   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
658   ,p_start_date             in date
659   ,p_status                 in hr_person_deployments.status%type
660   ) is
661   --
662   l_proc        varchar2(72) := g_package||'chk_to_person_id';
663   l_dummy       number;
664   l_api_updating     boolean;
665   --
666   cursor csr_check_person(p_person_id number) is
667   select per.person_id
668   from   per_all_people_f per
669   where  per.person_id = p_person_id
670   and    p_start_date between
671          per.effective_start_date and per.effective_end_date
672   and    per.business_group_id = p_to_business_group_id;
673   --
674   cursor csr_check_per_type(p_person_id number) is
675   select ptu.person_type_id
676   from   per_person_type_usages_f ptu,
677          per_person_types ppt
678   where  ptu.person_id = p_person_id
679   and    ptu.person_type_id = ppt.person_type_id
680   and    ppt.system_person_type in ('EMP','CWK','APL')
681   and    ptu.effective_end_date >= p_start_date;
682   --
683   cursor csr_check_per_type2(p_person_id number) is
684   select ptu.person_type_id
685   from   per_person_type_usages_f ptu,
686          per_person_types ppt
687   where  ptu.person_id = p_person_id
688   and    ptu.person_type_id = ppt.person_type_id
689   and    ppt.system_person_type in ('EMP','CWK','APL')
690   and    ptu.effective_start_date > p_start_date
691   and not exists (select 1
692                   from   per_person_type_usages_f ptu1,
693                          per_person_types ppt1
694                   where  ptu.person_type_usage_id = ptu1.person_type_usage_id
695                   and    ptu1.person_type_id = ppt1.person_type_id
696                   and    ppt1.system_person_type in ('EMP','CWK','APL')
697                   and    ptu1.effective_start_date = p_start_date);
698   --
699 begin
700   hr_utility.set_location('Entering:'||l_proc, 10);
701   --
702   -- Check mandatory parameters have been set
703   --
704   hr_api.mandatory_arg_error
705     (p_api_name       => l_proc
706     ,p_argument       => 'to_business_group_id'
707     ,p_argument_value => p_to_business_group_id
708     );
709   --
710   hr_api.mandatory_arg_error
711     (p_api_name       => l_proc
712     ,p_argument       => 'start_date'
713     ,p_argument_value => p_start_date
714     );
715   --
716   hr_api.mandatory_arg_error
717     (p_api_name       => l_proc
718     ,p_argument       => 'status'
719     ,p_argument_value => p_status
720     );
721   --
722   if hr_multi_message.no_exclusive_error
723      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.FROM_BUSINESS_GROUP_ID'
724      ) then
725     --
726     l_api_updating := hr_pdt_shd.api_updating
727            (p_person_deployment_id   => p_person_deployment_id
728            ,p_object_version_number  => p_object_version_number);
729     --
730     --
731     --  Only proceed with validation if:
732     --  a) rec is being inserted or
733     --  b) rec is updating and the g_old_rec is not current value
734     --
735     if ( (l_api_updating and
736          (       hr_pdt_shd.g_old_rec.start_date <> p_start_date
737           or nvl(hr_pdt_shd.g_old_rec.to_person_id,hr_api.g_number)
738                  <> nvl(p_to_person_id,hr_api.g_number)))
739         or not l_api_updating)
740     then
741       if p_to_person_id is not null then
742 
743 	open csr_check_person(p_to_person_id);
744 	fetch csr_check_person into l_dummy;
745 	if csr_check_person%notfound then
746 	   close csr_check_person;
747 	   --
748 	   fnd_message.set_name('PER','HR_449630_PDT_TO_PER_NOTEXIST');
749 	   fnd_message.raise_error;
750 	else
751 	   close csr_check_person;
752 	   --
753            -- only check person type in host if we are in DRAFT status or
754            -- upon initiation when DRAFT becomes ACTIVE
755            --
756            if  p_status='DRAFT' then
757              --
758 	     open csr_check_per_type(p_to_person_id);
759 	     fetch csr_check_per_type into l_dummy;
760 	     if csr_check_per_type%found then
761 	       close csr_check_per_type;
762 	       fnd_message.set_name('PER','HR_449631_PDT_TO_PER_FUT_PER');
763 	       fnd_message.raise_error;
764 	     else
765 	       close csr_check_per_type;
766 	     end if;  --check future person types
767              --
768            elsif p_status='ACTIVE' and hr_pdt_shd.g_old_rec.status='DRAFT' then
769              --
770 	     open csr_check_per_type2(p_to_person_id);
771 	     fetch csr_check_per_type2 into l_dummy;
772 	     if csr_check_per_type2%found then
773 	       close csr_check_per_type2;
774 	       fnd_message.set_name('PER','HR_449631_PDT_TO_PER_FUT_PER');
775 	       fnd_message.raise_error;
776 	     else
777 	       close csr_check_per_type2;
778 	     end if;  --check future person types
779              --
780           end if;  --status checks
781 	end if;  --check person
782 	--
783       end if; --to_person_id not null
784       --
785       if p_to_person_id is null and (p_status='ACTIVE' or p_status='COMPLETE') then
786         fnd_message.set_name('PER','HR_449632_PDT_TO_PER_NULL');
787         fnd_message.raise_error;
788       end if; --status check
789       --
790     end if;  --api updating
791   end if;  --multi message
792   --
793   hr_utility.set_location('Leaving:'||l_proc, 20);
794   --
795   exception
796     when app_exception.application_exception then
797       if hr_multi_message.exception_add
798       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.TO_PERSON_ID'
799       ) then
800         hr_utility.set_location(' Leaving:'||l_proc, 50);
801         raise;
802       end if;
803    hr_utility.set_location(' Leaving:'||l_proc,60);
804 end chk_to_person_id;
805 --
806 --  ---------------------------------------------------------------------------
807 --  |------------------------< chk_person_type_id >----------------------------|
808 --  ---------------------------------------------------------------------------
809 --
810 --  Desciption:
811 --    This procedures validates that person type is valid in the to business group
812 --    and is of type EMP, and is active
813 --
814 --  Pre-conditions :
815 --    None
816 --
817 --  In Parameters :
818 --  p_person_type_id
819 --  p_to_business_group_id
820 --
821 --  Post Success :
822 --    Processing continues if the person type id  is valid
823 --
824 --  Post Failure :
825 --    An application error will be raised and processing is terminated if the
826 --    person type id is invalid
827 --
828 --  Access Status :
829 --    Internal Row Handler Use only.
830 --
831 -- {End of Comments}
832 --
833 -- ---------------------------------------------------------------------------
834 Procedure chk_person_type_id
835   (p_person_type_id         in hr_person_deployments.person_type_id%type
836   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
837   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
838   ,p_object_version_number  in hr_person_deployments.object_version_number%type
839   ) is
840   --
841   l_proc             varchar2(72) := g_package||'chk_';
842   l_api_updating     boolean;
843   l_sys_type         per_person_types.system_person_type%type;
844   l_bg_id            per_person_types.business_group_id%type;
845   l_active_flag      per_person_types.active_flag%type;
846   --
847   cursor csr_check_per_type is
848   select system_person_type,business_group_id,active_flag
849   from   per_person_types
850   where  person_type_id = p_person_type_id;
851   --
852 begin
853   hr_utility.set_location('Entering:'||l_proc, 10);
854   --
855   hr_api.mandatory_arg_error
856     (p_api_name       => l_proc
857     ,p_argument       => 'to_business_group_id'
858     ,p_argument_value => p_to_business_group_id
859     );
860   --
861   if hr_multi_message.no_all_inclusive_error
862      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
863      ) then
864     --
865     l_api_updating := hr_pdt_shd.api_updating
866            (p_person_deployment_id   => p_person_deployment_id
867            ,p_object_version_number  => p_object_version_number);
868     --
869     if (( (l_api_updating and
870          (nvl(hr_pdt_shd.g_old_rec.person_type_id,hr_api.g_number)
871                           <> nvl(p_person_type_id,hr_api.g_number)))
872         or not l_api_updating)
873         and p_person_type_id is not null) then
874           --
875 	  open csr_check_per_type;
876 	  fetch csr_check_per_type into l_sys_type,l_bg_id,l_active_flag;
877 	  if csr_check_per_type%notfound then
878 	     close csr_check_per_type;
879 	     fnd_message.set_name('PER','HR_7513_PER_TYPE_INVALID');
880 	     fnd_message.raise_error;
881           else
882 	    close csr_check_per_type;
883 	    --
884 	    if l_sys_type <> 'EMP' then
885 	      fnd_message.set_name('PER','HR_7513_PER_TYPE_INVALID');
886 	      fnd_message.raise_error;
887 	    end if;
888 	    if l_bg_id <> p_to_business_group_id then
889 	      fnd_message.set_name('PER','HR_7974_PER_TYPE_INV_BUS_GROUP');
890 	      fnd_message.raise_error;
891 	    end if;
892 	    if l_active_flag <> 'Y' then
893 	      fnd_message.set_name('PER','HR_7973_PER_TYPE_NOT_ACTIVE');
894 	      fnd_message.raise_error;
895 	    end if;
896           end if;  --csr notfound
897 
898     end if; --api updating
899   end if;  --multi message
900   --
901   hr_utility.set_location('Leaving:'||l_proc, 20);
902   --
903   exception
904     when app_exception.application_exception then
905       if hr_multi_message.exception_add
906       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.PERSON_TYPE_ID'
907       ) then
908         hr_utility.set_location(' Leaving:'||l_proc, 50);
909         raise;
910       end if;
911    hr_utility.set_location(' Leaving:'||l_proc,60);
912 end chk_person_type_id;
913 --
914 --  ---------------------------------------------------------------------------
915 --  |------------------------< chk_start_end_date >---------------------------|
916 --  ---------------------------------------------------------------------------
917 --
918 --  Desciption:
919 --    This procedures validates that the start date is not greater than the end date
920 --
921 --  Pre-conditions :
922 --    None
923 --
924 --  In Parameters :
925 --    p_start_date
926 --    p_end_date
927 --
928 --  Post Success :
929 --    Processing continues if the dates are valid
930 --
931 --  Post Failure :
932 --    An application error will be raised and processing is terminated if the
933 --    dates are invalid
934 --
935 --  Access Status :
936 --    Internal Row Handler Use only.
937 --
938 -- {End of Comments}
939 --
940 -- ---------------------------------------------------------------------------
941 Procedure chk_start_end_date
942   (p_start_date             in hr_person_deployments.start_date%type
943   ,p_end_date               in hr_person_deployments.end_date%type
944   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
945   ,p_object_version_number  in hr_person_deployments.object_version_number%type
946   ,p_status                 in hr_person_deployments.status%type
947   ) is
948   --
949   l_proc        varchar2(72) := g_package||'chk_start_end_date';
950   l_api_updating     boolean;
951   --
952 begin
953   hr_utility.set_location('Entering:'||l_proc, 10);
954   --
955   hr_api.mandatory_arg_error
956     (p_api_name       => l_proc
957     ,p_argument       => 'start_date'
958     ,p_argument_value => p_start_date
959     );
960   --
961   if hr_multi_message.no_all_inclusive_error
962      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
963      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.END_DATE'
964      ) then
965     --
966     l_api_updating := hr_pdt_shd.api_updating
967            (p_person_deployment_id   => p_person_deployment_id
968            ,p_object_version_number  => p_object_version_number);
969     --
970     if ( (l_api_updating and
971          (   hr_pdt_shd.g_old_rec.start_date <> p_start_date
972           or nvl(hr_pdt_shd.g_old_rec.end_date,hr_api.g_date)
973                  <> nvl(p_end_date,hr_api.g_date)))
974         or not l_api_updating) then
975       --
976       -- bug fix 5665505
977       -- commented the following code
978       /*
979       -- Added check for COMPLETED deployments: Bug 5494622
980       if (p_status = 'COMPLETE' and p_start_date > nvl(p_end_date,hr_api.g_eot))
981        then
982         fnd_message.set_name('PER','HR_449621_PDT_CHG_DATES');
983         fnd_message.raise_error;
984       end if;
985 
986       if (p_status <> 'COMPLETE' and p_start_date >= nvl(p_end_date,hr_api.g_eot))
987        then
988         fnd_message.set_name('PER','HR_449621_PDT_CHG_DATES');
989         fnd_message.raise_error;
990       end if;
991       --
992       */
993      -- added the following piece of code
994      -- bug fix 5665505
995      --
996      if p_start_date > nvl(p_end_date,hr_api.g_eot)
997 	 then
998 	  fnd_message.set_name('PER','HR_449621_PDT_CHG_DATES');
999 	  fnd_message.raise_error;
1000 	end if;
1001 	--
1002       -- End of Additions
1003     end if;
1004   end if;
1005   --
1006   hr_utility.set_location('Leaving:'||l_proc, 20);
1007   --
1008   exception
1009     when app_exception.application_exception then
1010       if hr_multi_message.exception_add
1011       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
1012       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.END_DATE'
1013       ) then
1014         hr_utility.set_location(' Leaving:'||l_proc, 50);
1015         raise;
1016       end if;
1017    hr_utility.set_location(' Leaving:'||l_proc,60);
1018 end chk_start_end_date;
1019 --
1020 --
1021 --  ---------------------------------------------------------------------------
1022 --  |------------------------< chk_start_date >---------------------------|
1023 --  ---------------------------------------------------------------------------
1024 --
1025 --  Desciption:
1026 --    This function validates that the deployment start date is not greater
1027 --    than the employee start date.
1028 --
1029 --  Pre-conditions :
1030 --    None
1031 --
1032 --  In Parameters :
1033 --    p_start_date
1034 --    p_person_id
1035 --
1036 --  Post Success :
1037 --    Processing continues if the dates are valid
1038 --
1039 --  Post Failure :
1040 --    An application error will be raised and processing is terminated if the
1041 --    dates are invalid
1042 --
1043 --  Access Status :
1044 --    Internal Row Handler Use only.
1045 --
1046 -- {End of Comments}
1047 --
1048 -- ---------------------------------------------------------------------------
1049 FUNCTION chk_start_date
1050   (p_person_id in HR_PERSON_DEPLOYMENTS.FROM_PERSON_ID%type
1051   ,p_start_date in HR_PERSON_DEPLOYMENTS.START_DATE%type
1052   ) RETURN VARCHAR2
1053    is
1054 
1055  -- Declare Cursor
1056 
1057  cursor csr_get_min_st_date is
1058  select min(effective_start_date) from per_all_people_f
1059  where person_id = p_person_id;
1060 
1061  -- Declare Local Variables
1062 
1063  l_emp_date_start date;
1064  l_dep_start_date date;
1065 
1066 
1067 
1068  begin
1069 
1070  l_dep_start_date := trunc(p_start_date);
1071 
1072  open csr_get_min_st_date;
1073  fetch csr_get_min_st_date into l_emp_date_start;
1074 
1075  if csr_get_min_st_date%notfound then
1076  fnd_message.set_name('PER','HR_449629_PDT_FR_PER_NOTEXIST');
1077  fnd_message.raise_error;
1078  end if;
1079 
1080  if(l_dep_start_date < l_emp_date_start) then
1081  return 'Y';
1082  else return 'N';
1083  end if;
1084 
1085  end chk_start_date;
1086 
1087 --  ---------------------------------------------------------------------------
1088 --  |------------------------< chk_permanent >--------------------------------|
1089 --  ---------------------------------------------------------------------------
1090 --
1091 --  Desciption:
1092 --    This procedures validates that permanent is a valid value of 'Y','N' or null
1093 --    If PERMANENT='Y', then end date must be null
1094 --    If PERMANENT='Y', the from_person_id cannot have a future person record change
1095 --
1096 --  Pre-conditions :
1097 --    None
1098 --
1099 --  In Parameters :
1100 --    p_permanent
1101 --    p_from_person_id
1102 --    p_end_date
1103 --
1104 --  Post Success :
1105 --    Processing continues if the  is valid
1106 --
1107 --  Post Failure :
1108 --    An application error will be raised and processing is terminated if the
1109 --     is invalid
1110 --
1111 --  Access Status :
1112 --    Internal Row Handler Use only.
1113 --
1114 -- {End of Comments}
1115 --
1116 -- ---------------------------------------------------------------------------
1117 Procedure chk_permanent
1118   (p_permanent              in hr_person_deployments.permanent%type
1119   ,p_from_person_id         in hr_person_deployments.from_person_id%type
1120   ,p_end_date               in hr_person_deployments.end_date%type
1121   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1122   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1123   ) is
1124   --
1125   l_proc        varchar2(72) := g_package||'chk_permanent';
1126   l_api_updating     boolean;
1127   l_dummy            number;
1128   --
1129   cursor csr_check_fut_home_per is
1130   select 1
1131   from   per_all_people_f
1132   where  person_id = p_from_person_id
1133   and    effective_start_date > nvl(p_end_date,hr_api.g_eot);
1134   --
1135 begin
1136   hr_utility.set_location('Entering:'||l_proc, 10);
1137   --
1138   hr_api.mandatory_arg_error
1139     (p_api_name       => l_proc
1140     ,p_argument       => 'from_person_id'
1141     ,p_argument_value => p_from_person_id
1142     );
1143   --
1144   if hr_multi_message.no_exclusive_error
1145      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.END_DATE'
1146      ) then
1147     --
1148     l_api_updating := hr_pdt_shd.api_updating
1149            (p_person_deployment_id   => p_person_deployment_id
1150            ,p_object_version_number  => p_object_version_number);
1151     --
1152     if ( (l_api_updating and
1153           nvl(hr_pdt_shd.g_old_rec.end_date,hr_api.g_date)
1154               <> nvl(p_end_date,hr_api.g_date))
1155         or not l_api_updating) then
1156       --
1157       if (p_permanent <> 'Y' and p_permanent <> 'N' and p_permanent is not null) then
1158         fnd_message.set_name('PER','HR_449633_PDT_PERM_INVALID');
1159         fnd_message.raise_error;
1160       end if;
1161       --
1162       if (p_permanent is not null and p_permanent = 'Y') then
1163         if nvl(p_end_date,hr_api.g_date) <> hr_api.g_date then
1164           fnd_message.set_name('PER','HR_449634_PDT_PERM_NO_END');
1165           fnd_message.raise_error;
1166         end if;
1167         --
1168         open csr_check_fut_home_per;
1169         fetch csr_check_fut_home_per into l_dummy;
1170         if csr_check_fut_home_per%found then
1171           fnd_message.set_name('PER','HR_449635_PDT_HOME_FUTPER');
1172           fnd_message.raise_error;
1173         end if;
1174         --
1175       end if;
1176       --
1177     end if;  --api updating
1178   end if;  --multi mesage
1179   --
1180   hr_utility.set_location('Leaving:'||l_proc, 20);
1181   --
1182   exception
1183     when app_exception.application_exception then
1184       if hr_multi_message.exception_add
1185       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.PERMANENT'
1186       ) then
1187         hr_utility.set_location(' Leaving:'||l_proc, 50);
1188         raise;
1189       end if;
1190    hr_utility.set_location(' Leaving:'||l_proc,60);
1191 end chk_permanent;
1192 --
1193 --  ---------------------------------------------------------------------------
1194 --  |------------------------< chk_deployment_reason >------------------------|
1195 --  ---------------------------------------------------------------------------
1196 --
1197 --  Desciption:
1198 --    This procedures validates that deployment reason exists as a lookup code on
1199 --    HR_LEG_LOOKUPS for the lookup type 'HR_DEPLOYMENT_REASONS' with an enabled flag
1200 --    set to 'Y' and start_date of the deployment between start_date_active and
1201 --     end_date_active on HR_LEG_LOOKUPS
1202 --
1203 --  Pre-conditions :
1204 --    None
1205 --
1206 --  In Parameters :
1207 --    p_deployment_reason
1208 --    p_start_date
1209 --
1210 --  Post Success :
1211 --    Processing continues if the deployment reason is valid
1212 --
1213 --  Post Failure :
1214 --    An application error will be raised and processing is terminated if the
1215 --    deployment reason is invalid
1216 --
1217 --  Access Status :
1218 --    Internal Row Handler Use only.
1219 --
1220 -- {End of Comments}
1221 --
1222 -- ---------------------------------------------------------------------------
1223 Procedure chk_deployment_reason
1224   (p_deployment_reason      in hr_person_deployments.deployment_reason%type
1225   ,p_start_date             in hr_person_deployments.start_date%type
1226   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1227   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1228   ) is
1229   --
1230   l_proc        varchar2(72) := g_package||'chk_deployment_reason';
1231   l_api_updating     boolean;
1232   --
1233 begin
1234   hr_utility.set_location('Entering:'||l_proc, 10);
1235   --
1236   hr_api.mandatory_arg_error
1237     (p_api_name       => l_proc
1238     ,p_argument       => 'start_date'
1239     ,p_argument_value => p_start_date
1240     );
1241   --
1242   if hr_multi_message.no_exclusive_error
1243      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
1244      ) then
1245     --
1246     l_api_updating := hr_pdt_shd.api_updating
1247            (p_person_deployment_id   => p_person_deployment_id
1248            ,p_object_version_number  => p_object_version_number);
1249     --
1250     if ( (l_api_updating and
1251            (   hr_pdt_shd.g_old_rec.start_date <> p_start_date
1252             or nvl(hr_pdt_shd.g_old_rec.deployment_reason,hr_api.g_varchar2)
1253                 <> nvl(p_deployment_reason,hr_api.g_varchar2)))
1254         or not l_api_updating) then
1255       --
1256       if  p_deployment_reason is not null
1257       and hr_api.not_exists_in_leg_lookups
1258             (p_effective_date        => p_start_date
1259             ,p_lookup_type           => 'HR_DEPLOYMENT_REASONS'
1260             ,p_lookup_code           => p_deployment_reason
1261              )
1262       then
1263         fnd_message.set_name('PER','HR_449636_PDT_REAS_NOTEXIST');
1264         fnd_message.raise_error;
1265       end if;
1266      end if;  --api updating
1267   end if;  --multi message
1268   --
1269   hr_utility.set_location('Leaving:'||l_proc, 20);
1270   --
1271   exception
1272     when app_exception.application_exception then
1273       if hr_multi_message.exception_add
1274       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.DEPLOYMENT_REASON'
1275       ) then
1276         hr_utility.set_location(' Leaving:'||l_proc, 50);
1277         raise;
1278       end if;
1279    hr_utility.set_location(' Leaving:'||l_proc,60);
1280 end chk_deployment_reason;
1281 --
1282 --  ---------------------------------------------------------------------------
1283 --  |------------------------< chk_employee_number >--------------------------|
1284 --  ---------------------------------------------------------------------------
1285 --
1286 --  Desciption:
1287 --    This procedures validates that employee number is not set unless to
1288 --    to business group has manual numbering or automatic global numbering.
1289 --    If to_person_id is specified, the employee number if specified must be the same
1290 --    number as the to_person_id
1291 --    The number specified must be unique.
1292 --
1293 --  Pre-conditions :
1294 --    None
1295 --
1296 --  In Parameters :
1297 --    p_employee_number
1298 --    p_to_business_group_id
1299 --    p_to_person_id
1300 --
1301 --  Post Success :
1302 --    Processing continues if the employee number is valid
1303 --
1304 --  Post Failure :
1305 --    An application error will be raised and processing is terminated if the
1306 --    employee number is invalid
1307 --
1308 --  Access Status :
1309 --    Internal Row Handler Use only.
1310 --
1311 -- {End of Comments}
1312 --
1313 -- ---------------------------------------------------------------------------
1314 Procedure chk_employee_number
1315   (p_employee_number in hr_person_deployments.employee_number%type
1316   ,p_to_business_group_id in hr_person_deployments.to_business_group_id%type
1317   ,p_to_person_id in hr_person_deployments.to_person_id%type
1318   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1319   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1320   ) is
1321   --
1322   l_proc             varchar2(72) := g_package||'chk_employee_number';
1323   l_api_updating     boolean;
1324   l_dummy            number;
1325   l_numgen_method    per_all_people_f.employee_number%type;
1326   l_host_empnum      per_all_people_f.employee_number%type;
1327   l_global_num_set   fnd_profile_option_values.profile_option_value%type;
1328   --
1329   cursor csr_numgen_method is
1330   select pbg.method_of_generation_emp_num
1331   from   per_business_groups pbg
1332   where  pbg.business_group_id=p_to_business_group_id;
1333   --
1334   cursor csr_check_host_number is
1335   select employee_number
1336   from   per_all_people_f
1337   where  person_id = p_to_person_id
1338   and    effective_end_date = hr_api.g_eot;
1339   --
1340   cursor csr_check_num_unique is
1341   select 1
1342   from   per_all_people_f
1343   where  effective_end_date = hr_api.g_eot
1344   and    employee_number=p_employee_number
1345   and    business_group_id = p_to_business_group_id;
1346   --
1347 begin
1348   hr_utility.set_location('Entering:'||l_proc, 10);
1349   --
1350   hr_api.mandatory_arg_error
1351     (p_api_name       => l_proc
1352     ,p_argument       => 'to_business_group_id'
1353     ,p_argument_value => p_to_business_group_id
1354     );
1355   --
1356   if hr_multi_message.no_all_inclusive_error
1357      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
1358      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_PERSON_ID'
1359      ) then
1360     --
1361     l_api_updating := hr_pdt_shd.api_updating
1362            (p_person_deployment_id   => p_person_deployment_id
1363            ,p_object_version_number  => p_object_version_number);
1364     --
1365     if ( (l_api_updating and
1366            (nvl(hr_pdt_shd.g_old_rec.employee_number,hr_api.g_varchar2)
1367                 <> nvl(p_employee_number,hr_api.g_varchar2)))
1368         or not l_api_updating) then
1369       --
1370       if p_employee_number is not null then
1371         --get num gen method
1372         open csr_numgen_method;
1373         fetch csr_numgen_method into l_numgen_method;
1374         close csr_numgen_method;
1375         --
1376         l_global_num_set := fnd_profile.value('PER_GLOBAL_EMP_NUM');
1377         --
1378         if l_numgen_method='N'
1379            or (l_numgen_method='A' and l_global_num_set <> 'Y') then
1380            fnd_message.set_name('PER','HR_449637_PDT_NUMGENMETH');
1381            fnd_message.raise_error;
1382         end if;
1383         --
1384         if p_to_person_id is not null then
1385           open csr_check_host_number;
1386           fetch csr_check_host_number into l_host_empnum;
1387           close csr_check_host_number;
1388           --
1389           if l_host_empnum <> p_employee_number then
1390             fnd_message.set_name('PER','HR_449638_PDT_NUM_HOST');
1391             fnd_message.raise_error;
1392           end if;
1393         elsif p_to_person_id is null
1394           and not(l_numgen_method = 'A' and l_global_num_set = 'Y') then
1395 	  --
1396 	  --check that number is not used already in ToBG
1397 	  --
1398 	  open csr_check_num_unique;
1399 	  fetch csr_check_num_unique into l_dummy;
1400           if csr_check_num_unique%found then
1401             close csr_check_num_unique;
1402             fnd_message.set_name('PER','HR_449639_PDT_NUM_USED');
1403             fnd_message.raise_error;
1404           else
1405             close csr_check_num_unique;
1406           end if;
1407         end if;  --p_to_person_id not null
1408       end if;  --p_employee_number not null
1409     end if; --api updating
1410   end if; --multi message
1411   --
1412   hr_utility.set_location('Leaving:'||l_proc, 20);
1413   --
1414   exception
1415     when app_exception.application_exception then
1416       if hr_multi_message.exception_add
1417       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.EMPLOYEE_NUMBER'
1418       ) then
1419         hr_utility.set_location(' Leaving:'||l_proc, 50);
1420         raise;
1421       end if;
1422    hr_utility.set_location(' Leaving:'||l_proc,60);
1423 end chk_employee_number;
1424 --
1425 --  ---------------------------------------------------------------------------
1426 --  |------------------------< chk_leaving_reason >---------------------------|
1427 --  ---------------------------------------------------------------------------
1428 --
1429 --  Desciption:
1430 --    This procedures validates that leaving reason exists as a lookup code on
1431 --    HR_LEG_LOOKUPS for the lookup type 'LEAV_REAS' with an enabled flag
1432 --    set to 'Y' and start_date of the deployment between start_date_active and
1433 --     end_date_active on HR_LEG_LOOKUPS
1434 --    A value cannot be entered if PERMANENT='Y'
1435 --
1436 --  Pre-conditions :
1437 --    None
1438 --
1439 --  In Parameters :
1440 --    p_leaving_reason
1441 --    p_to_business_group_id
1442 --    p_permanent
1443 --
1444 --  Post Success :
1445 --    Processing continues if the leaving_reason is valid
1446 --
1447 --  Post Failure :
1448 --    An application error will be raised and processing is terminated if the
1449 --    leaving_reason is invalid
1450 --
1451 --  Access Status :
1452 --    Internal Row Handler Use only.
1453 --
1454 -- {End of Comments}
1455 --
1456 -- ---------------------------------------------------------------------------
1457 Procedure chk_leaving_reason
1458   (p_leaving_reason         in hr_person_deployments.leaving_reason%type
1459   ,p_start_date             in hr_person_deployments.start_date%type
1460   ,p_permanent              in hr_person_deployments.permanent%type
1461   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1462   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1463   ) is
1464   --
1465   l_proc        varchar2(72) := g_package||'chk_leaving_reason';
1466   l_api_updating     boolean;
1467   --
1468 begin
1469   hr_utility.set_location('Entering:'||l_proc, 10);
1470   --
1471   hr_api.mandatory_arg_error
1472     (p_api_name       => l_proc
1473     ,p_argument       => 'start_date'
1474     ,p_argument_value => p_start_date
1475     );
1476   --
1477   if hr_multi_message.no_exclusive_error
1478      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
1479      ) then
1480     --
1481     l_api_updating := hr_pdt_shd.api_updating
1482            (p_person_deployment_id   => p_person_deployment_id
1483            ,p_object_version_number  => p_object_version_number);
1484     --
1485     if ( (l_api_updating and
1486            (nvl(hr_pdt_shd.g_old_rec.leaving_reason,hr_api.g_varchar2)
1487                 <> nvl(p_leaving_reason,hr_api.g_varchar2)))
1488         or not l_api_updating) then
1489       --
1490       if p_leaving_reason is not null then
1491         if nvl(p_permanent,'N') = 'Y' then
1492           fnd_message.set_name('PER','HR_449640_PDT_PERM_LEAV_REAS');
1493           fnd_message.raise_error;
1494         end if;
1495         --
1496         if hr_api.not_exists_in_leg_lookups
1497              (p_effective_date        => p_start_date
1498              ,p_lookup_type           => 'LEAV_REAS'
1499              ,p_lookup_code           => p_leaving_reason
1500               ) then
1501            fnd_message.set_name('PER','HR_7485_PDS_INV_LR');
1502            fnd_message.raise_error;
1503         end if;  -- lookup validation
1504       end if;  --leaving reason not null
1505     end if; --api updating
1506   end if; --multi message
1507   --
1508   hr_utility.set_location('Leaving:'||l_proc, 20);
1509   --
1510   exception
1511     when app_exception.application_exception then
1512       if hr_multi_message.exception_add
1513       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.LEAVING_REASON'
1514       ) then
1515         hr_utility.set_location(' Leaving:'||l_proc, 50);
1516         raise;
1517       end if;
1518    hr_utility.set_location(' Leaving:'||l_proc,60);
1519 end chk_leaving_reason;
1520 --
1521 --  ---------------------------------------------------------------------------
1522 --  |------------------------< chk_leaving_person_type_id >-------------------|
1523 --  ---------------------------------------------------------------------------
1524 --
1525 --  Desciption:
1526 --    This procedures validates that leaving person type exists in the
1527 --    to business group and is active and of type EX_EMP.
1528 --    A value cannot be specified if PERMANENT='Y'
1529 --
1530 --  Pre-conditions :
1531 --    None
1532 --
1533 --  In Parameters :
1534 --  p_leaving_person_type_id
1535 --  p_to_business_group_id
1536 --  p_permanent
1537 --
1538 --  Post Success :
1539 --    Processing continues if the leaving person type id  is valid
1540 --
1541 --  Post Failure :
1542 --    An application error will be raised and processing is terminated if the
1543 --    leaving person type id is invalid
1544 --
1545 --  Access Status :
1546 --    Internal Row Handler Use only.
1547 --
1548 -- {End of Comments}
1549 --
1550 -- ---------------------------------------------------------------------------
1551 Procedure chk_leaving_person_type_id
1552   (p_leaving_person_type_id in hr_person_deployments.leaving_person_type_id%type
1553   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
1554   ,p_permanent              in hr_person_deployments.permanent%type
1555   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1556   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1557   ) is
1558   --
1559   l_proc             varchar2(72) := g_package||'chk_';
1560   l_api_updating     boolean;
1561   l_sys_type         per_person_types.system_person_type%type;
1562   l_bg_id            per_person_types.business_group_id%type;
1563   l_active_flag      per_person_types.active_flag%type;
1564   --
1565   cursor csr_check_per_type is
1566   select system_person_type,business_group_id,active_flag
1567   from   per_person_types
1568   where  person_type_id = p_leaving_person_type_id;
1569   --
1570 begin
1571   hr_utility.set_location('Entering:'||l_proc, 10);
1572   --
1573   hr_api.mandatory_arg_error
1574     (p_api_name       => l_proc
1575     ,p_argument       => 'to_business_group_id'
1576     ,p_argument_value => p_to_business_group_id
1577     );
1578   --
1579   if hr_multi_message.no_all_inclusive_error
1580      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
1581      ) then
1582     --
1583     l_api_updating := hr_pdt_shd.api_updating
1584            (p_person_deployment_id   => p_person_deployment_id
1585            ,p_object_version_number  => p_object_version_number);
1586     --
1587     if (( (l_api_updating and
1588          (nvl(hr_pdt_shd.g_old_rec.leaving_person_type_id,hr_api.g_number)
1589                           <> nvl(p_leaving_person_type_id,hr_api.g_number)))
1590         or not l_api_updating)
1591         and p_leaving_person_type_id is not null) then
1592           --
1593 	  if nvl(p_permanent,'N') = 'Y' then
1594 	    fnd_message.set_name('PER','HR_449641_PDT_PERM_LEAV_TYPE');
1595 	    fnd_message.raise_error;
1596 	  end if;
1597           --
1598 	  open csr_check_per_type;
1599 	  fetch csr_check_per_type into l_sys_type,l_bg_id,l_active_flag;
1600 	  if csr_check_per_type%notfound then
1601 	     close csr_check_per_type;
1602 	     fnd_message.set_name('PER','HR_7513_PER_TYPE_INVALID');
1603 	     fnd_message.raise_error;
1604           else
1605 	    close csr_check_per_type;
1606 	    --
1607 	    if l_sys_type <> 'EX_EMP' then
1608 	      fnd_message.set_name('PER','HR_7513_PER_TYPE_INVALID');
1609 	      fnd_message.raise_error;
1610 	    end if;
1611 	    if l_bg_id <> p_to_business_group_id then
1612 	      fnd_message.set_name('PER','HR_7974_PER_TYPE_INV_BUS_GROUP');
1613 	      fnd_message.raise_error;
1614 	    end if;
1615 	    if l_active_flag <> 'Y' then
1616 	      fnd_message.set_name('PER','HR_7973_PER_TYPE_NOT_ACTIVE');
1617 	      fnd_message.raise_error;
1618 	    end if;
1619           end if;  --csr notfound
1620 
1621     end if; --api updating
1622   end if;  --multi message
1623   --
1624   hr_utility.set_location('Leaving:'||l_proc, 20);
1625   --
1626   exception
1627     when app_exception.application_exception then
1628       if hr_multi_message.exception_add
1629       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.LEAVING_PERSON_TYPE_ID'
1630       ) then
1631         hr_utility.set_location(' Leaving:'||l_proc, 50);
1632         raise;
1633       end if;
1634    hr_utility.set_location(' Leaving:'||l_proc,60);
1635 end chk_leaving_person_type_id;
1636 --
1637 --  ---------------------------------------------------------------------------
1638 --  |------------------------< chk_status >-----------------------------------|
1639 --  ---------------------------------------------------------------------------
1640 --
1641 --  Desciption:
1642 --    This procedures validates that status exists as a lookup code on
1643 --    HR_LEG_LOOKUPS for the lookup type 'HR_DEPLOYMENT_STATUSES' with an enabled flag
1644 --    set to 'Y' and start_date of the deployment between start_date_active and
1645 --     end_date_active on HR_LEG_LOOKUPS
1646 --
1647 --  Pre-conditions :
1648 --    None
1649 --
1650 --  In Parameters :
1651 --    p_status
1652 --    p_start_date
1653 --
1654 --  Post Success :
1655 --    Processing continues if the status is valid
1656 --
1657 --  Post Failure :
1658 --    An application error will be raised and processing is terminated if the
1659 --    status is invalid
1660 --
1661 --  Access Status :
1662 --    Internal Row Handler Use only.
1663 --
1664 -- {End of Comments}
1665 --
1666 -- ---------------------------------------------------------------------------
1667 Procedure chk_status
1668   (p_status in hr_person_deployments.status%type
1669   ,p_start_date             in hr_person_deployments.start_date%type
1670   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1671   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1672   ) is
1673   --
1674   l_proc        varchar2(72) := g_package||'chk_status';
1675   l_api_updating     boolean;
1676   --
1677 begin
1678   hr_utility.set_location('Entering:'||l_proc, 10);
1679   --
1680   hr_api.mandatory_arg_error
1681     (p_api_name       => l_proc
1682     ,p_argument       => 'status'
1683     ,p_argument_value => p_status
1684     );
1685   --
1686   hr_api.mandatory_arg_error
1687     (p_api_name       => l_proc
1688     ,p_argument       => 'start_date'
1689     ,p_argument_value => p_start_date
1690     );
1691   --
1692   if hr_multi_message.no_all_inclusive_error
1693      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.STATUS'
1694      ) then
1695     --
1696     l_api_updating := hr_pdt_shd.api_updating
1697            (p_person_deployment_id   => p_person_deployment_id
1698            ,p_object_version_number  => p_object_version_number);
1699     --
1700     if ( (l_api_updating and
1701          (hr_pdt_shd.g_old_rec.status <> p_status))
1702         or not l_api_updating) then
1703        --
1704        if hr_api.not_exists_in_leg_lookups
1705             (p_effective_date        => p_start_date
1706             ,p_lookup_type           => 'HR_DEPLOYMENT_STATUSES'
1707             ,p_lookup_code           => p_status
1708              ) then
1709            fnd_message.set_name('PER','HR_7485_PDS_INV_LR');
1710            fnd_message.raise_error;
1711        end if;
1712        --
1713        if not l_api_updating and (p_status='ACTIVE' or p_status='COMPLETE') then
1714            fnd_message.set_name('PER','HR_449642_PDT_INS_STATUS');
1715            fnd_message.raise_error;
1716        end if;
1717 
1718     end if;  --api updating
1719   end if; --multi message
1720   --
1721   hr_utility.set_location('Leaving:'||l_proc, 20);
1722   --
1723   exception
1724     when app_exception.application_exception then
1725       if hr_multi_message.exception_add
1726       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.STATUS'
1727       ) then
1728         hr_utility.set_location(' Leaving:'||l_proc, 50);
1729         raise;
1730       end if;
1731    hr_utility.set_location(' Leaving:'||l_proc,60);
1732 end chk_status;
1733 --
1734 --  ---------------------------------------------------------------------------
1735 --  |------------------------< chk_deplymt_policy_id >------------------------|
1736 --  ---------------------------------------------------------------------------
1737 --
1738 --  Desciption:
1739 --    This procedures validates that deplymt policy id is null.
1740 --    The parameter is not supported for initial release of global transfer functionality
1741 --
1742 --  Pre-conditions :
1743 --    None
1744 --
1745 --  In Parameters :
1746 --    p_deplymt_policy_id
1747 --
1748 --  Post Success :
1749 --    Processing continues if the deplymt policy id is valid
1750 --
1751 --  Post Failure :
1752 --    An application error will be raised and processing is terminated if the
1753 --    deplymt policy id is invalid
1754 --
1755 --  Access Status :
1756 --    Internal Row Handler Use only.
1757 --
1758 -- {End of Comments}
1759 --
1760 -- ---------------------------------------------------------------------------
1761 Procedure chk_deplymt_policy_id
1762   (p_deplymt_policy_id in hr_person_deployments.deplymt_policy_id%type
1763   ) is
1764   --
1765   l_proc        varchar2(72) := g_package||'chk_deplymt_policy_id';
1766   l_api_updating     boolean;
1767   --
1768 begin
1769   hr_utility.set_location('Entering:'||l_proc, 10);
1770   --
1771   if p_deplymt_policy_id is not null then
1772      fnd_message.set_name('PER','HR_449643_PDT_INV_POLICY');
1773      fnd_message.raise_error;
1774   end if;
1775   --
1776   hr_utility.set_location('Leaving:'||l_proc, 20);
1777   --
1778   exception
1779     when app_exception.application_exception then
1780       if hr_multi_message.exception_add
1781       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.DEPLYMT_POLICY_ID'
1782       ) then
1783         hr_utility.set_location(' Leaving:'||l_proc, 50);
1784         raise;
1785       end if;
1786    hr_utility.set_location(' Leaving:'||l_proc,60);
1787 end chk_deplymt_policy_id;
1788 --
1789 --  ---------------------------------------------------------------------------
1790 --  |------------------------< chk_retain_direct_reports >--------------------|
1791 --  ---------------------------------------------------------------------------
1792 --
1793 --  Desciption:
1794 --    This procedures validates that retain_direct_reports is a valid value
1795 --    of 'Y','N' or null
1796 --    It must be null if the employee has no direct reports
1797 --
1798 --  Pre-conditions :
1799 --    None
1800 --
1801 --  In Parameters :
1802 --    p_retain_direct_reports
1803 --    p_from_person_id
1804 --    p_to_business_group_id
1805 --    p_from_business_group_id
1806 --
1807 --  Post Success :
1808 --    Processing continues if the  is valid
1809 --
1810 --  Post Failure :
1811 --    An application error will be raised and processing is terminated if the
1812 --     is invalid
1813 --
1814 --  Access Status :
1815 --    Internal Row Handler Use only.
1816 --
1817 -- {End of Comments}
1818 --
1819 -- ---------------------------------------------------------------------------
1820 Procedure chk_retain_direct_reports
1821   (p_retain_direct_reports              in hr_person_deployments.retain_direct_reports%type
1822   ,p_from_person_id         in hr_person_deployments.from_person_id%type
1823   ,p_start_date             in hr_person_deployments.start_date%type
1824   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
1825   ,p_from_business_group_id in hr_person_deployments.to_business_group_id%type
1826   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1827   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1828   ) is
1829   --
1830   l_proc        varchar2(72) := g_package||'chk_retain_direct_reports';
1831   l_api_updating     boolean;
1832   l_dummy            number;
1833   --
1834   cursor csr_check_directs(p_person_id number) is
1835   select 1
1836   from   per_all_assignments_f
1837   where  supervisor_id = p_person_id
1838   and    p_start_date between effective_start_date and effective_end_date;
1839   --
1840 begin
1841   hr_utility.set_location('Entering:'||l_proc, 10);
1842   --
1843   hr_api.mandatory_arg_error
1844     (p_api_name       => l_proc
1845     ,p_argument       => 'from_person_id'
1846     ,p_argument_value => p_from_person_id
1847     );
1848   --
1849   hr_api.mandatory_arg_error
1850     (p_api_name       => l_proc
1851     ,p_argument       => 'start_date'
1852     ,p_argument_value => p_start_date
1853     );
1854   --
1855   if hr_multi_message.no_exclusive_error
1856      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.FROM_PERSON_ID'
1857      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
1858      ) then
1859     --
1860     l_api_updating := hr_pdt_shd.api_updating
1861            (p_person_deployment_id   => p_person_deployment_id
1862            ,p_object_version_number  => p_object_version_number);
1863     --
1864     if nvl(fnd_profile.value('HR_CROSS_BUSINESS_GROUP'),'N') = 'N'
1865     and p_from_business_group_id <> p_to_business_group_id then
1866         fnd_message.set_name('PER','HR_449644_PDT_RETAIN_REPS');
1867         fnd_message.raise_error;
1868     end if;
1869     --
1870     if ( (l_api_updating and
1871           nvl(hr_pdt_shd.g_old_rec.retain_direct_reports,hr_api.g_varchar2)
1872               <> nvl(p_retain_direct_reports,hr_api.g_varchar2))
1873         or not l_api_updating) then
1874       --
1875       if (p_retain_direct_reports <> 'Y'
1876           and p_retain_direct_reports <> 'N'
1877           and p_retain_direct_reports is not null) then
1878             fnd_message.set_name('PER','HR_449645_PDT_RET_REPS_INV');
1879             fnd_message.raise_error;
1880       end if;
1881       --
1882     end if;  --api updating
1883   end if;  --multi mesage
1884   --
1885   hr_utility.set_location('Leaving:'||l_proc, 20);
1886   --
1887   exception
1888     when app_exception.application_exception then
1889       if hr_multi_message.exception_add
1890       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.RETAIN_DIRECT_REPORTS'
1891       ) then
1892         hr_utility.set_location(' Leaving:'||l_proc, 50);
1893         raise;
1894       end if;
1895    hr_utility.set_location(' Leaving:'||l_proc,60);
1896 end chk_retain_direct_reports;
1897 --
1898 --  ---------------------------------------------------------------------------
1899 --  |------------------------< chk_organization_id >--------------------------|
1900 --  ---------------------------------------------------------------------------
1901 --
1902 --  Desciption:
1903 --    This procedures validates that the org is a valid internal HR organization
1904 --
1905 --  Pre-conditions :
1906 --    None
1907 --
1908 --  In Parameters :
1909 --    p_organization_id
1910 --    p_to_business_group_id
1911 --
1912 --  Post Success :
1913 --    Processing continues if the organization is valid
1914 --
1915 --  Post Failure :
1916 --    An application error will be raised and processing is terminated if the
1917 --    organization is invalid
1918 --
1919 --  Access Status :
1920 --    Internal Row Handler Use only.
1921 --
1922 -- {End of Comments}
1923 --
1924 -- ---------------------------------------------------------------------------
1925 Procedure chk_organization_id
1926   (p_organization_id        in hr_person_deployments.organization_id%type
1927   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
1928   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
1929   ,p_object_version_number  in hr_person_deployments.object_version_number%type
1930   ) is
1931   --
1932   l_proc        varchar2(72) := g_package||'chk_organization_id';
1933   l_api_updating     boolean;
1934   l_dummy            number;
1935   --
1936   cursor csr_check_int_org is
1937   select   1
1938   from     hr_all_organization_units
1939   where    organization_id     = p_organization_id
1940   and      internal_external_flag = 'INT';
1941   --
1942   -- following detects match on Host BG as well
1943   -- Since a proposal creates a primary asg, this is OK for asgrhi validation
1944   --
1945   cursor csr_check_hr_org is
1946   select   1
1947   from     per_organization_units
1948   where    organization_id = p_organization_id
1949       UNION
1950   select   1
1951   from     per_business_groups_perf
1952   where    business_group_id = p_to_business_group_id;
1953   --
1954 begin
1955   hr_utility.set_location('Entering:'||l_proc, 10);
1956   --
1957   hr_api.mandatory_arg_error
1958     (p_api_name       => l_proc
1959     ,p_argument       => 'organization_id'
1960     ,p_argument_value => p_organization_id
1961     );
1962   --
1963   hr_api.mandatory_arg_error
1964     (p_api_name       => l_proc
1965     ,p_argument       => 'to_business_group_id'
1966     ,p_argument_value => p_to_business_group_id
1967     );
1968   --
1969     l_api_updating := hr_pdt_shd.api_updating
1970            (p_person_deployment_id   => p_person_deployment_id
1971            ,p_object_version_number  => p_object_version_number);
1972     --
1973     if ( (l_api_updating and
1974           hr_pdt_shd.g_old_rec.organization_id <> p_organization_id)
1975         or not l_api_updating) then
1976       --
1977       open csr_check_int_org;
1978       fetch csr_check_int_org into l_dummy;
1979       if csr_check_int_org%notfound then
1980          close csr_check_int_org;
1981          fnd_message.set_name('PER','HR_34983_ASG_INVALID_ORG');
1982          fnd_message.raise_error;
1983       else
1984          close csr_check_int_org;
1985       end if;
1986       --
1987      open csr_check_hr_org;
1988      fetch csr_check_hr_org into l_dummy;
1989      if csr_check_hr_org%notfound then
1990         close csr_check_hr_org;
1991         fnd_message.set_name('PER','HR_51277_ASG_INV_HR_ORG');
1992         fnd_message.raise_error;
1993      else
1994         close csr_check_hr_org;
1995      end if;
1996     end if; --api updating
1997   --
1998   hr_utility.set_location('Leaving:'||l_proc, 20);
1999   --
2000   exception
2001     when app_exception.application_exception then
2002       if hr_multi_message.exception_add
2003       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.ORGANIZATION_ID'
2004       ) then
2005         hr_utility.set_location(' Leaving:'||l_proc, 50);
2006         raise;
2007       end if;
2008    hr_utility.set_location(' Leaving:'||l_proc,60);
2009 end chk_organization_id;
2010 --
2011 --  ---------------------------------------------------------------------------
2012 --  |------------------------< chk_location_id >------------------------------|
2013 --  ---------------------------------------------------------------------------
2014 --
2015 --  Desciption:
2016 --    This procedures validates that location is valid and active on the start date
2017 --
2018 --  Pre-conditions :
2019 --    None
2020 --
2021 --  In Parameters :
2022 --    p_location_id
2023 --    p_start_date
2024 --    p_to_business_group_id
2025 --
2026 --  Post Success :
2027 --    Processing continues if the location is valid
2028 --
2029 --  Post Failure :
2030 --    An application error will be raised and processing is terminated if the
2031 --    location is invalid
2032 --
2033 --  Access Status :
2034 --    Internal Row Handler Use only.
2035 --
2036 -- {End of Comments}
2037 --
2038 -- ---------------------------------------------------------------------------
2039 Procedure chk_location_id
2040   (p_location_id            in hr_person_deployments.location_id%type
2041   ,p_start_date             in hr_person_deployments.start_date%type
2042   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
2043   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2044   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2045    ) is
2046   --
2047   l_proc        varchar2(72) := g_package||'chk_location_id';
2048   l_api_updating     boolean;
2049   l_inactive_date    date;
2050   --
2051   cursor csr_check_loc is
2052   select inactive_date
2053   from   hr_locations_all
2054   where  location_id = p_location_id
2055   and    nvl(business_group_id,p_to_business_group_id)=p_to_business_group_id;
2056   --
2057 begin
2058   hr_utility.set_location('Entering:'||l_proc, 10);
2059   --
2060   hr_api.mandatory_arg_error
2061     (p_api_name       => l_proc
2062     ,p_argument       => 'start_date'
2063     ,p_argument_value => p_start_date
2064     );
2065   --
2066   hr_api.mandatory_arg_error
2067     (p_api_name       => l_proc
2068     ,p_argument       => 'to_business_group_id'
2069     ,p_argument_value => p_to_business_group_id
2070     );
2071   --
2072   if hr_multi_message.no_all_inclusive_error
2073      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
2074      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
2075      ) then
2076     --
2077     l_api_updating := hr_pdt_shd.api_updating
2078            (p_person_deployment_id   => p_person_deployment_id
2079            ,p_object_version_number  => p_object_version_number);
2080     --
2081     if ( (l_api_updating and
2082           (nvl(hr_pdt_shd.g_old_rec.location_id,hr_api.g_number)
2083               <> nvl(p_location_id,hr_api.g_number)
2084            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2085         or not l_api_updating) then
2086       --
2087       if p_location_id is not null then
2088 	open csr_check_loc;
2089 	fetch csr_check_loc into l_inactive_date;
2090 	if csr_check_loc%notfound then
2091 	   close csr_check_loc;
2092 	   fnd_message.set_name('PER','HR_7382_ASG_NON_EXIST_LOCATION');
2093 	   fnd_message.raise_error;
2094 	else
2095 	   close csr_check_loc;
2096 	   if p_start_date < l_inactive_date then
2097 	      fnd_message.set_name('PER','HR_51215_ASG_INACT_LOCATION');
2098 	      fnd_message.raise_error;
2099 	   end if;
2100 	end if;  -- csr_check_loc notfound
2101 	--
2102       end if;  --location not null
2103     end if;  --api updating
2104   end if;  --multi message
2105   --
2106   hr_utility.set_location('Leaving:'||l_proc, 20);
2107   --
2108   exception
2109     when app_exception.application_exception then
2110       if hr_multi_message.exception_add
2111       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.LOCATION_ID'
2112       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
2113       ) then
2114         hr_utility.set_location(' Leaving:'||l_proc, 50);
2115         raise;
2116       end if;
2117    hr_utility.set_location(' Leaving:'||l_proc,60);
2118 end chk_location_id;
2119 --
2120 --  ---------------------------------------------------------------------------
2121 --  |------------------------< chk_job_id >-----------------------------------|
2122 --  ---------------------------------------------------------------------------
2123 --
2124 --  Desciption:
2125 --    This procedures validates that job exists in the host BG as of the
2126 --   start date of deployment
2127 --
2128 --  Pre-conditions :
2129 --    None
2130 --
2131 --  In Parameters :
2132 --    p_job_id
2133 --    p_to_business_group_id
2134 --    p_start_date
2135 --
2136 --  Post Success :
2137 --    Processing continues if the job is valid
2138 --
2139 --  Post Failure :
2140 --    An application error will be raised and processing is terminated if the
2141 --    job is invalid
2142 --
2143 --  Access Status :
2144 --    Internal Row Handler Use only.
2145 --
2146 -- {End of Comments}
2147 --
2148 -- ---------------------------------------------------------------------------
2149 Procedure chk_job_id
2150   (p_job_id                 in hr_person_deployments.job_id%type
2151   ,p_start_date             in hr_person_deployments.start_date%type
2152   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
2153   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2154   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2155   ) is
2156   --
2157   l_proc        varchar2(72) := g_package||'chk_job_id';
2158   l_api_updating     boolean;
2159   l_dummy            number;
2160   --
2161   cursor csr_check_job is
2162   select 1
2163   from   per_jobs job,
2164          per_job_groups jgr
2165   where  job.job_id = p_job_id
2166   and    p_start_date between job.date_from and nvl(job.date_to,hr_api.g_eot)
2167   and    job.job_group_id  = jgr.job_group_id
2168   and    jgr.internal_name = 'HR_'||jgr.business_group_id
2169   and    (jgr.business_group_id = job.business_group_id
2170       or jgr.business_group_id is null)
2171   and    job.business_group_id = p_to_business_group_id;
2172   --
2173 begin
2174   hr_utility.set_location('Entering:'||l_proc, 10);
2175   --
2176   hr_api.mandatory_arg_error
2177     (p_api_name       => l_proc
2178     ,p_argument       => 'start_date'
2179     ,p_argument_value => p_start_date
2180     );
2181   --
2182   hr_api.mandatory_arg_error
2183     (p_api_name       => l_proc
2184     ,p_argument       => 'to_business_group_id'
2185     ,p_argument_value => p_to_business_group_id
2186     );
2187   --
2188   if hr_multi_message.no_all_inclusive_error
2189      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
2190      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
2191      ) then
2192     --
2193     l_api_updating := hr_pdt_shd.api_updating
2194            (p_person_deployment_id   => p_person_deployment_id
2195            ,p_object_version_number  => p_object_version_number);
2196     --
2197     if ( (l_api_updating and
2198           (nvl(hr_pdt_shd.g_old_rec.job_id,hr_api.g_number)
2199               <> nvl(p_job_id,hr_api.g_number)
2200            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2201         or not l_api_updating) then
2202       --
2203       if p_job_id is not null then
2204         open csr_check_job;
2205         fetch csr_check_job into l_dummy;
2206         if csr_check_job%notfound then
2207            close csr_check_job;
2208 	   fnd_message.set_name('PER','HR_51172_ASG_INV_DT_JOB');
2209 	   fnd_message.raise_error;
2210         else
2211            close csr_check_job;
2212         end if;
2213       end if;  --job not null
2214     end if;  --api updating
2215   end if;  --multi message
2216   --
2217   hr_utility.set_location('Leaving:'||l_proc, 20);
2218   --
2219   exception
2220     when app_exception.application_exception then
2221       if hr_multi_message.exception_add
2222       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.JOB_ID'
2223       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
2224       ) then
2225         hr_utility.set_location(' Leaving:'||l_proc, 50);
2226         raise;
2227       end if;
2228    hr_utility.set_location(' Leaving:'||l_proc,60);
2229 end chk_job_id;
2230 --
2231 --  ---------------------------------------------------------------------------
2232 --  |------------------------< chk_position_id >------------------------------|
2233 --  ---------------------------------------------------------------------------
2234 --
2235 --  Desciption:
2236 --    This procedures validates that position exists in the host BG as of the
2237 --   start date of deployment
2238 --
2239 --  Pre-conditions :
2240 --    None
2241 --
2242 --  In Parameters :
2243 --    p_position_id
2244 --    p_to_business_group_id
2245 --    p_start_date
2246 --
2247 --  Post Success :
2248 --    Processing continues if the position is valid
2249 --
2250 --  Post Failure :
2251 --    An application error will be raised and processing is terminated if the
2252 --    position is invalid
2253 --
2254 --  Access Status :
2255 --    Internal Row Handler Use only.
2256 --
2257 -- {End of Comments}
2258 --
2259 -- ---------------------------------------------------------------------------
2260 Procedure chk_position_id
2261   (p_position_id            in hr_person_deployments.position_id%type
2262   ,p_start_date             in hr_person_deployments.start_date%type
2263   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
2264   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2265   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2266   ) is
2267   --
2268   l_proc        varchar2(72) := g_package||'chk_position_id';
2269   l_api_updating     boolean;
2270   l_dummy            number;
2271   --
2272   cursor csr_check_position is
2273   select 1
2274   from   hr_positions_f hp,
2275          per_shared_types ps
2276   where  hp.position_id = p_position_id
2277   and    hp.business_group_id = p_to_business_group_id
2278   and    p_start_date between
2279          hp.effective_start_date and hp.effective_end_date
2280   and    p_start_date between
2281          hp.date_effective and nvl(hp.date_end,hr_api.g_eot)
2282   and    ps.shared_type_id = hp.availability_status_id
2283   and    ps.system_type_cd = 'ACTIVE';
2284   --
2285 begin
2286   hr_utility.set_location('Entering:'||l_proc, 10);
2287   --
2288   hr_api.mandatory_arg_error
2289     (p_api_name       => l_proc
2290     ,p_argument       => 'start_date'
2291     ,p_argument_value => p_start_date
2292     );
2293   --
2294   hr_api.mandatory_arg_error
2295     (p_api_name       => l_proc
2296     ,p_argument       => 'to_business_group_id'
2297     ,p_argument_value => p_to_business_group_id
2298     );
2299   --
2300   if hr_multi_message.no_all_inclusive_error
2301      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
2302      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
2303      ) then
2304     --
2305     l_api_updating := hr_pdt_shd.api_updating
2306            (p_person_deployment_id   => p_person_deployment_id
2307            ,p_object_version_number  => p_object_version_number);
2308     --
2309     if ( (l_api_updating and
2310           (nvl(hr_pdt_shd.g_old_rec.position_id,hr_api.g_number)
2311               <> nvl(p_position_id,hr_api.g_number)
2312            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2313         or not l_api_updating) then
2314       --
2315       if p_position_id is not null then
2316         open csr_check_position;
2317         fetch csr_check_position into l_dummy;
2318         if csr_check_position%notfound then
2319            close csr_check_position;
2320 	   fnd_message.set_name('PER','HR_51000_ASG_INVALID_POS');
2321 	   fnd_message.raise_error;
2322         else
2323            close csr_check_position;
2324         end if;
2325       end if;  --position not null
2326     end if;  --api updating
2327   end if;  --multi message
2328   --
2329   hr_utility.set_location('Leaving:'||l_proc, 20);
2330   --
2331   exception
2332     when app_exception.application_exception then
2333       if hr_multi_message.exception_add
2334       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2335       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
2336       ) then
2337         hr_utility.set_location(' Leaving:'||l_proc, 50);
2338         raise;
2339       end if;
2340    hr_utility.set_location(' Leaving:'||l_proc,60);
2341 end chk_position_id;
2342 --
2343 --  ---------------------------------------------------------------------------
2344 --  |------------------------< chk_grade_id >---------------------------------|
2345 --  ---------------------------------------------------------------------------
2346 --
2347 --  Desciption:
2348 --    This procedures validates that grade exists in the host BG as of the
2349 --   start date of deployment
2350 --
2351 --  Pre-conditions :
2352 --    None
2353 --
2354 --  In Parameters :
2355 --    p_grade_id
2356 --    p_to_business_group_id
2357 --    p_start_date
2358 --
2359 --  Post Success :
2360 --    Processing continues if the grade is valid
2361 --
2362 --  Post Failure :
2363 --    An application error will be raised and processing is terminated if the
2364 --    grade is invalid
2365 --
2366 --  Access Status :
2367 --    Internal Row Handler Use only.
2368 --
2369 -- {End of Comments}
2370 --
2371 -- ---------------------------------------------------------------------------
2372 Procedure chk_grade_id
2373   (p_grade_id               in hr_person_deployments.grade_id%type
2374   ,p_start_date             in hr_person_deployments.start_date%type
2375   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
2376   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2377   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2378   ) is
2379   --
2380   l_proc        varchar2(72) := g_package||'chk_grade_id';
2381   l_api_updating     boolean;
2382   l_dummy            number;
2383   --
2384   cursor csr_check_grade is
2385   select 1
2386   from   per_grades grade
2387   where  grade.grade_id = p_grade_id
2388   and    grade.business_group_id = p_to_business_group_id
2389   and    p_start_date between
2390          grade.date_from and nvl(grade.date_to,hr_api.g_eot);
2391   --
2392 begin
2393   hr_utility.set_location('Entering:'||l_proc, 10);
2394   --
2395   hr_api.mandatory_arg_error
2396     (p_api_name       => l_proc
2397     ,p_argument       => 'start_date'
2398     ,p_argument_value => p_start_date
2399     );
2400   --
2401   hr_api.mandatory_arg_error
2402     (p_api_name       => l_proc
2403     ,p_argument       => 'to_business_group_id'
2404     ,p_argument_value => p_to_business_group_id
2405     );
2406   --
2407   if hr_multi_message.no_all_inclusive_error
2408      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
2409      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
2410      ) then
2411     --
2412     l_api_updating := hr_pdt_shd.api_updating
2413            (p_person_deployment_id   => p_person_deployment_id
2414            ,p_object_version_number  => p_object_version_number);
2415     --
2416     if ( (l_api_updating and
2417           (nvl(hr_pdt_shd.g_old_rec.grade_id,hr_api.g_number)
2418               <> nvl(p_grade_id,hr_api.g_number)
2419            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2420         or not l_api_updating) then
2421       --
2422       if p_grade_id is not null then
2423         open csr_check_grade;
2424         fetch csr_check_grade into l_dummy;
2425         if csr_check_grade%notfound then
2426            close csr_check_grade;
2427 	   fnd_message.set_name('PER','HR_7393_ASG_INVALID_GRADE');
2428 	   fnd_message.raise_error;
2429         else
2430            close csr_check_grade;
2431         end if;
2432       end if;  --grade not null
2433     end if;  --api updating
2434   end if;  --multi message
2435   --
2436   hr_utility.set_location('Leaving:'||l_proc, 20);
2437   --
2438   exception
2439     when app_exception.application_exception then
2440       if hr_multi_message.exception_add
2441       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.GRADE_ID'
2442       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
2443       ) then
2444         hr_utility.set_location(' Leaving:'||l_proc, 50);
2445         raise;
2446       end if;
2447    hr_utility.set_location(' Leaving:'||l_proc,60);
2448 end chk_grade_id;
2449 --
2450 --  ---------------------------------------------------------------------------
2451 --  |------------------------< chk_position_id_job_id >------------------------|
2452 --  ---------------------------------------------------------------------------
2453 --
2454 --  Desciption:
2455 --    This procedures validates that the position and job combination is valid
2456 --
2457 --  Pre-conditions :
2458 --    None
2459 --
2460 --  In Parameters :
2461 --    p_position_id
2462 --    p_job_id
2463 --    p_start_date
2464 --
2465 --  Post Success :
2466 --    Processing continues if the position and job combo is valid
2467 --
2468 --  Post Failure :
2469 --    An application error will be raised and processing is terminated if the
2470 --    position and job combo is invalid
2471 --
2472 --  Access Status :
2473 --    Internal Row Handler Use only.
2474 --
2475 -- {End of Comments}
2476 --
2477 -- ---------------------------------------------------------------------------
2478 Procedure chk_position_id_job_id
2479   (p_position_id            in hr_person_deployments.position_id%type
2480   ,p_job_id                 in hr_person_deployments.job_id%type
2481   ,p_start_date             in hr_person_deployments.start_date%type
2482   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2483   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2484   ) is
2485   --
2486   l_proc        varchar2(72) := g_package||'chk_position_id_job_id';
2487   l_api_updating     boolean;
2488   l_dummy            number;
2489   --
2490   cursor csr_check_pos_job is
2491   select null
2492   from   hr_positions_f hp,
2493          per_shared_types ps
2494   where  hp.position_id = p_position_id
2495   and    p_start_date between
2496          hp.effective_start_date and hp.effective_end_date
2497   and    hp.job_id = p_job_id
2498   and    p_start_date between
2499          hp.date_effective and nvl(hp.date_end,hr_api.g_eot)
2500   and    ps.shared_type_id = hp.availability_status_id
2501   and    ps.system_type_cd = 'ACTIVE' ;
2502   --
2503 begin
2504   hr_utility.set_location('Entering:'||l_proc, 10);
2505   --
2506   hr_api.mandatory_arg_error
2507     (p_api_name       => l_proc
2508     ,p_argument       => 'start_date'
2509     ,p_argument_value => p_start_date
2510     );
2511   --
2512   if hr_multi_message.no_exclusive_error
2513      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.JOB_ID'
2514      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2515      ) then
2516     --
2517     l_api_updating := hr_pdt_shd.api_updating
2518            (p_person_deployment_id   => p_person_deployment_id
2519            ,p_object_version_number  => p_object_version_number);
2520     --
2521     if ( (l_api_updating and
2522           (   nvl(hr_pdt_shd.g_old_rec.position_id,hr_api.g_number)
2523                  <> nvl(p_position_id,hr_api.g_number)
2524            or nvl(hr_pdt_shd.g_old_rec.job_id,hr_api.g_number)
2525                  <> nvl(p_job_id,hr_api.g_number)
2526            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2527         or not l_api_updating) then
2528       --
2529       if p_position_id is not null and p_job_id is not null then
2530 	open csr_check_pos_job;
2531 	fetch csr_check_pos_job into l_dummy;
2532 	if csr_check_pos_job%notfound then
2533 	   close csr_check_pos_job;
2534 	   fnd_message.set_name('PER','HR_51056_ASG_INV_POS_JOB_COMB');
2535 	   fnd_message.raise_error;
2536 	else
2537 	   close csr_check_pos_job;
2538 	end if;
2539       end if;  --pos and job not null
2540     end if;  --api updating
2541   end if;  --multi message
2542   --
2543   hr_utility.set_location('Leaving:'||l_proc, 20);
2544   --
2545   exception
2546     when app_exception.application_exception then
2547       if hr_multi_message.exception_add
2548       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2549       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.JOB_ID'
2550       ) then
2551         hr_utility.set_location(' Leaving:'||l_proc, 50);
2552         raise;
2553       end if;
2554    hr_utility.set_location(' Leaving:'||l_proc,60);
2555 end chk_position_id_job_id;
2556 --
2557 --  ---------------------------------------------------------------------------
2558 --  |------------------------< chk_position_id_grade_id >---------------------|
2559 --  ---------------------------------------------------------------------------
2560 --
2561 --  Desciption:
2562 --    This procedures validates that position and grade combination is valid
2563 --
2564 --  Pre-conditions :
2565 --    None
2566 --
2567 --  In Parameters :
2568 --
2569 --
2570 --  Post Success :
2571 --    Processing continues if the position and grade combo is valid
2572 --
2573 --  Post Failure :
2574 --    An application error will be raised and processing is terminated if the
2575 --    position and grade combo is invalid
2576 --
2577 --  Access Status :
2578 --    Internal Row Handler Use only.
2579 --
2580 -- {End of Comments}
2581 --
2582 -- ---------------------------------------------------------------------------
2583 Procedure chk_position_id_grade_id
2584   (p_position_id            in hr_person_deployments.position_id%type
2585   ,p_grade_id               in hr_person_deployments.grade_id%type
2586   ,p_start_date             in hr_person_deployments.start_date%type
2587   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2588   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2589   ,p_inv_pos_grade_warning  out nocopy boolean
2590   ) is
2591   --
2592   l_proc        varchar2(72) := g_package||'chk_position_id_grade_id';
2593   l_api_updating             boolean;
2594   l_dummy                    number;
2595   l_inv_pos_grade_warning    boolean := false;
2596   --
2597   cursor csr_any_valid_grades is
2598   select 1
2599   from   per_valid_grades
2600   where  position_id = p_position_id
2601   and    p_start_date between
2602          date_from and nvl(date_to,hr_api.g_eot);
2603   --
2604   cursor csr_valid_grade is
2605   select 1
2606   from   per_valid_grades
2607   where  position_id = p_position_id
2608   and    grade_id = p_grade_id
2609   and    p_start_date between
2610          date_from and nvl(date_to,hr_api.g_eot);
2611   --
2612 begin
2613   hr_utility.set_location('Entering:'||l_proc, 10);
2614   --
2615   hr_api.mandatory_arg_error
2616     (p_api_name       => l_proc
2617     ,p_argument       => 'start_date'
2618     ,p_argument_value => p_start_date
2619     );
2620   --
2621   if hr_multi_message.no_exclusive_error
2622      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.GRADE_ID'
2623      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2624      ) then
2625     --
2626     l_api_updating := hr_pdt_shd.api_updating
2627            (p_person_deployment_id   => p_person_deployment_id
2628            ,p_object_version_number  => p_object_version_number);
2629     --
2630     if ( (l_api_updating and
2631           (   nvl(hr_pdt_shd.g_old_rec.position_id,hr_api.g_number)
2632                  <> nvl(p_position_id,hr_api.g_number)
2633            or nvl(hr_pdt_shd.g_old_rec.grade_id,hr_api.g_number)
2634                  <> nvl(p_grade_id,hr_api.g_number)
2635            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2636         or not l_api_updating) then
2637       --
2638       if p_position_id is not null and p_grade_id is not null then
2639         open csr_any_valid_grades;
2640         fetch csr_any_valid_grades into l_dummy;
2641         if csr_any_valid_grades%found then
2642            close csr_any_valid_grades;
2643            --
2644            open csr_valid_grade;
2645            fetch csr_valid_grade into l_dummy;
2646            if csr_valid_grade%notfound then
2647               close csr_valid_grade;
2648               p_inv_pos_grade_warning := l_inv_pos_grade_warning;
2649            else
2650               close csr_valid_grade;
2651            end if;
2652         else
2653            close csr_any_valid_grades;
2654         end if;  --csr_any_valid_grades
2655       end if;  --pos and grade not null
2656     end if;  --api updating
2657   end if;  --multi message
2658   --
2659   hr_utility.set_location('Leaving:'||l_proc, 20);
2660   --
2661   exception
2662     when app_exception.application_exception then
2663       if hr_multi_message.exception_add
2664       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2665       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.GRADE_ID'
2666       ) then
2667         hr_utility.set_location(' Leaving:'||l_proc, 50);
2668         raise;
2669       end if;
2670    hr_utility.set_location(' Leaving:'||l_proc,60);
2671 end chk_position_id_grade_id;
2672 --
2673 --  ---------------------------------------------------------------------------
2674 --  |------------------------< chk_job_id_grade_id >--------------------------|
2675 --  ---------------------------------------------------------------------------
2676 --
2677 --  Desciption:
2678 --    This procedures validates that job and grade combination is valid
2679 --
2680 --  Pre-conditions :
2681 --    None
2682 --
2683 --  In Parameters :
2684 --
2685 --
2686 --  Post Success :
2687 --    Processing continues if the job and grade combo is valid
2688 --
2689 --  Post Failure :
2690 --    An application error will be raised and processing is terminated if the
2691 --    job and grade combo is invalid
2692 --
2693 --  Access Status :
2694 --    Internal Row Handler Use only.
2695 --
2696 -- {End of Comments}
2697 --
2698 -- ---------------------------------------------------------------------------
2699 Procedure chk_job_id_grade_id
2700   (p_job_id                 in hr_person_deployments.job_id%type
2701   ,p_grade_id               in hr_person_deployments.grade_id%type
2702   ,p_start_date             in hr_person_deployments.start_date%type
2703   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2704   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2705   ,p_inv_job_grade_warning  out nocopy boolean
2706   ) is
2707   --
2708   l_proc        varchar2(72) := g_package||'chk_job_id_grade_id';
2709   l_api_updating             boolean;
2710   l_dummy                    number;
2711   l_inv_job_grade_warning    boolean := false;
2712   --
2713   cursor csr_any_valid_grades is
2714   select 1
2715   from   per_valid_grades
2716   where  job_id = p_job_id
2717   and    p_start_date between
2718          date_from and nvl(date_to,hr_api.g_eot);
2719   --
2720   cursor csr_valid_grade is
2721   select 1
2722   from   per_valid_grades
2723   where  job_id = p_job_id
2724   and    grade_id = p_grade_id
2725   and    p_start_date between
2726          date_from and nvl(date_to,hr_api.g_eot);
2727   --
2728 begin
2729   hr_utility.set_location('Entering:'||l_proc, 10);
2730   --
2731   hr_api.mandatory_arg_error
2732     (p_api_name       => l_proc
2733     ,p_argument       => 'start_date'
2734     ,p_argument_value => p_start_date
2735     );
2736   --
2737   if hr_multi_message.no_exclusive_error
2738      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.GRADE_ID'
2739      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.JOB_ID'
2740      ) then
2741     --
2742     l_api_updating := hr_pdt_shd.api_updating
2743            (p_person_deployment_id   => p_person_deployment_id
2744            ,p_object_version_number  => p_object_version_number);
2745     --
2746     if ( (l_api_updating and
2747           (   nvl(hr_pdt_shd.g_old_rec.job_id,hr_api.g_number)
2748                  <> nvl(p_job_id,hr_api.g_number)
2749            or nvl(hr_pdt_shd.g_old_rec.grade_id,hr_api.g_number)
2750                  <> nvl(p_grade_id,hr_api.g_number)
2751            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2752         or not l_api_updating) then
2753       --
2754       if p_job_id is not null and p_grade_id is not null then
2755         open csr_any_valid_grades;
2756         fetch csr_any_valid_grades into l_dummy;
2757         if csr_any_valid_grades%found then
2758            close csr_any_valid_grades;
2759            --
2760            open csr_valid_grade;
2761            fetch csr_valid_grade into l_dummy;
2762            if csr_valid_grade%notfound then
2763               close csr_valid_grade;
2764               p_inv_job_grade_warning := l_inv_job_grade_warning;
2765            else
2766               close csr_valid_grade;
2767            end if;
2768         else
2769            close csr_any_valid_grades;
2770         end if;  --csr_any_valid_grades
2771       end if;  --job and grade not null
2772     end if;  --api updating
2773   end if;  --multi message
2774   --
2775   hr_utility.set_location('Leaving:'||l_proc, 20);
2776   --
2777   exception
2778     when app_exception.application_exception then
2779       if hr_multi_message.exception_add
2780       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.JOB_ID'
2781       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.GRADE_ID'
2782       ) then
2783         hr_utility.set_location(' Leaving:'||l_proc, 50);
2784         raise;
2785       end if;
2786    hr_utility.set_location(' Leaving:'||l_proc,60);
2787 end chk_job_id_grade_id;
2788 --
2789 --  ---------------------------------------------------------------------------
2790 --  |------------------------< chk_position_id_org_id >------------------------|
2791 --  ---------------------------------------------------------------------------
2792 --
2793 --  Desciption:
2794 --    This procedures validates that the position and org combination is valid
2795 --
2796 --  Pre-conditions :
2797 --    None
2798 --
2799 --  In Parameters :
2800 --    p_position_id
2801 --    p_organization_id
2802 --    p_start_date
2803 --
2804 --  Post Success :
2805 --    Processing continues if the position and org combo is valid
2806 --
2807 --  Post Failure :
2808 --    An application error will be raised and processing is terminated if the
2809 --    position and org combo is invalid
2810 --
2811 --  Access Status :
2812 --    Internal Row Handler Use only.
2813 --
2814 -- {End of Comments}
2815 --
2816 -- ---------------------------------------------------------------------------
2817 Procedure chk_position_id_org_id
2818   (p_position_id            in hr_person_deployments.position_id%type
2819   ,p_organization_id        in hr_person_deployments.organization_id%type
2820   ,p_start_date             in hr_person_deployments.start_date%type
2821   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2822   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2823   ) is
2824   --
2825   l_proc        varchar2(72) := g_package||'chk_position_id_org_id';
2826   l_api_updating     boolean;
2827   l_dummy            number;
2828   --
2829   cursor csr_check_pos_org is
2830   select null
2831   from   hr_positions_f hp,
2832          per_shared_types ps
2833   where  hp.position_id = p_position_id
2834   and    p_start_date between
2835          hp.effective_start_date and hp.effective_end_date
2836   and    hp.organization_id = p_organization_id
2837   and    p_start_date between
2838          hp.date_effective and nvl(hp.date_end,hr_api.g_eot)
2839   and    ps.shared_type_id = hp.availability_status_id
2840   and    ps.system_type_cd = 'ACTIVE' ;
2841   --
2842 begin
2843   hr_utility.set_location('Entering:'||l_proc, 10);
2844   --
2845   hr_api.mandatory_arg_error
2846     (p_api_name       => l_proc
2847     ,p_argument       => 'start_date'
2848     ,p_argument_value => p_start_date
2849     );
2850   --
2851   if hr_multi_message.no_exclusive_error
2852      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.ORGANIZATION_ID'
2853      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2854      ) then
2855     --
2856     l_api_updating := hr_pdt_shd.api_updating
2857            (p_person_deployment_id   => p_person_deployment_id
2858            ,p_object_version_number  => p_object_version_number);
2859     --
2860     if ( (l_api_updating and
2861           (   nvl(hr_pdt_shd.g_old_rec.position_id,hr_api.g_number)
2862                  <> nvl(p_position_id,hr_api.g_number)
2863            or hr_pdt_shd.g_old_rec.organization_id <> p_organization_id
2864            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2865         or not l_api_updating) then
2866       --
2867       if p_position_id is not null and p_organization_id is not null then
2868 	open csr_check_pos_org;
2869 	fetch csr_check_pos_org into l_dummy;
2870 	if csr_check_pos_org%notfound then
2871 	   close csr_check_pos_org;
2872 	   fnd_message.set_name('PER','HR_51056_ASG_INV_POS_ORG_COMB');
2873 	   fnd_message.raise_error;
2874 	else
2875 	   close csr_check_pos_org;
2876 	end if;
2877       end if;  --pos and org not null
2878     end if;  --api updating
2879   end if;  --multi message
2880   --
2881   hr_utility.set_location('Leaving:'||l_proc, 20);
2882   --
2883   exception
2884     when app_exception.application_exception then
2885       if hr_multi_message.exception_add
2886       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.POSITION_ID'
2887       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.ORGANIZATION_ID'
2888       ) then
2889         hr_utility.set_location(' Leaving:'||l_proc, 50);
2890         raise;
2891       end if;
2892    hr_utility.set_location(' Leaving:'||l_proc,60);
2893 end chk_position_id_org_id;
2894 --
2895 --  ---------------------------------------------------------------------------
2896 --  |------------------------< chk_payroll_id >-------------------------------|
2897 --  ---------------------------------------------------------------------------
2898 --
2899 --  Desciption:
2900 --    This procedures validates that payroll is valid for the host BG.
2901 --    If the legislation is US or CA, then it must be null since there can bo no address
2902 --    entered against a deployment proposal.
2903 --
2904 --
2905 --  Pre-conditions :
2906 --    None
2907 --
2908 --  In Parameters :
2909 --    p_payroll_id
2910 --    p_start_date
2911 --    p_to_business_group_id
2912 --
2913 --  Post Success :
2914 --    Processing continues if the payroll is valid
2915 --
2916 --  Post Failure :
2917 --    An application error will be raised and processing is terminated if the
2918 --    payroll is invalid
2919 --
2920 --  Access Status :
2921 --    Internal Row Handler Use only.
2922 --
2923 -- {End of Comments}
2924 --
2925 -- ---------------------------------------------------------------------------
2926 Procedure chk_payroll_id
2927   (p_payroll_id             in hr_person_deployments.payroll_id%type
2928   ,p_start_date             in hr_person_deployments.start_date%type
2929   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
2930   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
2931   ,p_object_version_number  in hr_person_deployments.object_version_number%type
2932   ) is
2933   --
2934   l_proc        varchar2(72) := g_package||'chk_payroll_id';
2935   l_api_updating     boolean;
2936   l_dummy            number;
2937   l_legislation_code per_business_groups.legislation_code%type;
2938   --
2939   cursor csr_get_leg_code is
2940   select legislation_code
2941   from per_business_groups_perf
2942   where business_group_id = p_to_business_group_id;
2943   --
2944   cursor csr_check_payroll is
2945   select 1
2946   from   pay_all_payrolls_f
2947   where  p_start_date between
2948          effective_start_date and effective_end_date
2949   and    payroll_id = p_payroll_id
2950   and    business_group_id = p_to_business_group_id;
2951   --
2952 begin
2953   hr_utility.set_location('Entering:'||l_proc, 10);
2954   --
2955   hr_api.mandatory_arg_error
2956     (p_api_name       => l_proc
2957     ,p_argument       => 'start_date'
2958     ,p_argument_value => p_start_date
2959     );
2960   --
2961   hr_api.mandatory_arg_error
2962     (p_api_name       => l_proc
2963     ,p_argument       => 'to_business_group_id'
2964     ,p_argument_value => p_to_business_group_id
2965     );
2966   --
2967   if hr_multi_message.no_all_inclusive_error
2968      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
2969      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
2970      ) then
2971     --
2972     l_api_updating := hr_pdt_shd.api_updating
2973            (p_person_deployment_id   => p_person_deployment_id
2974            ,p_object_version_number  => p_object_version_number);
2975     --
2976     if ( (l_api_updating and
2977           (nvl(hr_pdt_shd.g_old_rec.payroll_id,hr_api.g_number)
2978               <> nvl(p_payroll_id,hr_api.g_number)
2979            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
2980         or not l_api_updating) then
2981       --
2982       if p_payroll_id is not null then
2983         open csr_check_payroll;
2984         fetch csr_check_payroll into l_dummy;
2985         if csr_check_payroll%notfound then
2986            close csr_check_payroll;
2987 	   fnd_message.set_name('PER','HR_7370_ASG_INVALID_PAYROLL');
2988 	   fnd_message.raise_error;
2989         else
2990            close csr_check_payroll;
2991         end if;
2992         --
2993 	open csr_get_leg_code;
2994 	fetch csr_get_leg_code into l_legislation_code;
2995 	close csr_get_leg_code;
2996         --
2997 	if hr_general.chk_geocodes_installed = 'Y'
2998 	and ( ( l_legislation_code = 'CA'
2999 		and hr_utility.chk_product_install(p_product => 'Oracle Payroll',
3000 						   p_legislation => 'CA'))
3001 	      OR ( l_legislation_code = 'US'
3002 		and hr_utility.chk_product_install(p_product => 'Oracle Payroll',
3003 						   p_legislation => 'US')))
3004 	then
3005            fnd_message.set_name('PER','HR_449646_PDT_NO_PAYROLL');
3006 	   fnd_message.raise_error;
3007         end if;  -- leg code check
3008       end if; --payroll not null
3009     end if;  --api updating
3010   end if;  --multi message
3011   --
3012   hr_utility.set_location('Leaving:'||l_proc, 20);
3013   --
3014   exception
3015     when app_exception.application_exception then
3016       if hr_multi_message.exception_add
3017       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.PAYROLL_ID'
3018       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
3019       ) then
3020         hr_utility.set_location(' Leaving:'||l_proc, 50);
3021         raise;
3022       end if;
3023    hr_utility.set_location(' Leaving:'||l_proc,60);
3024 end chk_payroll_id;
3025 --
3026 --  ---------------------------------------------------------------------------
3027 --  |------------------------< chk_assignment_status_type_id >----------------|
3028 --  ---------------------------------------------------------------------------
3029 --
3030 --  Desciption:--    This procedures validates that assignment_status_type_id exists in the Host BG
3031 --    and is of ACTIVE_ASG
3032 --
3033 --  Pre-conditions :
3034 --    None
3035 --
3036 --  In Parameters :
3037 --    p_assignment_status_type_id
3038 --    p_to_business_group_id
3039 --
3040 --  Post Success :
3041 --    Processing continues if the assignment_status_type_id is valid
3042 --
3043 --  Post Failure :
3044 --    An application error will be raised and processing is terminated if the
3045 --    assignment_status_type_id is invalid
3046 --
3047 --  Access Status :
3048 --    Internal Row Handler Use only.
3049 --
3050 -- {End of Comments}
3051 --
3052 -- ---------------------------------------------------------------------------
3053 Procedure chk_assignment_status_type_id
3054   (p_assignment_status_type_id in hr_person_deployments.assignment_status_type_id%type
3055   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
3056   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3057   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3058   ) is
3059   --
3060   l_proc        varchar2(72) := g_package||'chk_assignment_status_type_id';
3061   l_api_updating     boolean;
3062   l_active_flag        per_assignment_status_types.active_flag%type;
3063   l_per_system_status  per_assignment_status_types.per_system_status%type;
3064   l_legislation_code per_business_groups.legislation_code%type;
3065   --
3066   cursor csr_get_leg_code is
3067   select legislation_code
3068   from per_business_groups_perf
3069   where business_group_id = p_to_business_group_id;
3070   --
3071   cursor csr_check_asg_status_amend is
3072   select active_flag, per_system_status
3073   from   per_ass_status_type_amends
3074   where  assignment_status_type_id = p_assignment_status_type_id
3075   and    business_group_id = p_to_business_group_id;
3076   --
3077   cursor csr_check_asg_status(p_legislation_code per_business_groups.legislation_code%TYPE) is
3078   select active_flag, per_system_status
3079   from   per_assignment_status_types
3080   where  assignment_status_type_id = p_assignment_status_type_id
3081   and    nvl(business_group_id,p_to_business_group_id) = p_to_business_group_id
3082   and    nvl(legislation_code,p_legislation_code) = p_legislation_code;
3083 /*
3084   and    (business_group_id is not null
3085           and business_group_id = p_to_business_group_id)
3086   or     (business_group_id is null
3087           and (legislation_code is not null
3088                and legislation_code= p_legislation_code));
3089 */
3090   --
3091 begin
3092   hr_utility.set_location('Entering:'||l_proc, 10);
3093   --
3094   hr_api.mandatory_arg_error
3095     (p_api_name       => l_proc
3096     ,p_argument       => 'to_business_group_id'
3097     ,p_argument_value => p_to_business_group_id
3098     );
3099   --
3100   if hr_multi_message.no_all_inclusive_error
3101      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
3102      ) then
3103     --
3104     l_api_updating := hr_pdt_shd.api_updating
3105            (p_person_deployment_id   => p_person_deployment_id
3106            ,p_object_version_number  => p_object_version_number);
3107     --
3108     if ( (l_api_updating and
3109           (nvl(hr_pdt_shd.g_old_rec.assignment_status_type_id,hr_api.g_number)
3110               <> nvl(p_assignment_status_type_id,hr_api.g_number)))
3111         or not l_api_updating) then
3112       --
3113       if p_assignment_status_type_id is not null then
3114          open csr_check_asg_status_amend;
3115          fetch csr_check_asg_status_amend into l_active_flag,l_per_system_status;
3116          if csr_check_asg_status_amend%notfound then
3117             close csr_check_asg_status_amend;
3118             --
3119 	    open csr_get_leg_code;
3120 	    fetch csr_get_leg_code into l_legislation_code;
3121 	    close csr_get_leg_code;
3122 	    --
3123             open csr_check_asg_status(l_legislation_code);
3124             fetch csr_check_asg_status into l_active_flag,l_per_system_status;
3125             if csr_check_asg_status%notfound then
3126                close csr_check_asg_status;
3127                fnd_message.set_name('PER','HR_7940_ASG_INV_ASG_STAT_TYPE');
3128                fnd_message.raise_error;
3129             else
3130                close csr_check_asg_status;
3131                if l_active_flag <> 'Y' then
3132                  fnd_message.set_name('PER','HR_51206_ASG_INV_AST_ACT_FLG');
3133                  fnd_message.raise_error;
3134                end if;
3135                --
3136                if l_per_system_status <> 'ACTIVE_ASSIGN' then
3137                  fnd_message.set_name('PER','HR_7941_ASG_INV_STAT_NOT_ACT');
3138                  fnd_message.raise_error;
3139                end if;
3140             end if;
3141          else
3142             close csr_check_asg_status_amend;
3143          end if;
3144       end if;
3145     end if;  --api updating
3146   end if;  --multi message
3147   --
3148   hr_utility.set_location('Leaving:'||l_proc, 20);
3149   --
3150   exception
3151     when app_exception.application_exception then
3152       if hr_multi_message.exception_add
3153       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.ASSIGNMENT_STATUS_TYPE_ID'
3154       ) then
3155         hr_utility.set_location(' Leaving:'||l_proc, 50);
3156         raise;
3157       end if;
3158    hr_utility.set_location(' Leaving:'||l_proc,60);
3159 end chk_assignment_status_type_id;
3160 --
3161 --  ---------------------------------------------------------------------------
3162 --  |------------------------< chk_supervisor_id >----------------------------|
3163 --  ---------------------------------------------------------------------------
3164 --
3165 --  Desciption:
3166 --    This procedures validates that supervisor_id is valid for range of assignment
3167 --
3168 --  Pre-conditions :
3169 --    None
3170 --
3171 --  In Parameters :
3172 --    p_supervisor_id
3173 --    p_start_date
3174 --    p_from_person_id
3175 --    p_to_person_id
3176 --    p_to_business_group_id
3177 --
3178 --  Post Success :
3179 --    Processing continues if the  is valid
3180 --
3181 --  Post Failure :
3182 --    An application error will be raised and processing is terminated if the
3183 --     is invalid
3184 --
3185 --  Access Status :
3186 --    Internal Row Handler Use only.
3187 --
3188 -- {End of Comments}
3189 --
3190 -- ---------------------------------------------------------------------------
3191 Procedure chk_supervisor_id
3192   (p_supervisor_id in hr_person_deployments.supervisor_id%type
3193   ,p_start_date             in hr_person_deployments.start_date%type
3194   ,p_from_person_id         in hr_person_deployments.from_person_id%type
3195   ,p_to_person_id           in hr_person_deployments.to_person_id%type
3196   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
3197   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3198   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3199   ) is
3200   --
3201   l_proc        varchar2(72) := g_package||'chk_supervisor_id';
3202   l_api_updating     boolean;
3203   l_per_party_id number;
3204   l_sup_party_id number;
3205   l_sup_bg_id    number;
3206   --
3207   cursor csr_party_id(p_per_id number)  IS
3208   select party_id
3209   from   per_all_people_f
3210   where  person_id = p_per_id
3211   and    p_start_date
3212      between  effective_start_date
3213        and    effective_end_date;
3214   --
3215   cursor csr_check_sup is
3216   select 1
3217   from   per_all_people_f
3218   where  person_id = p_supervisor_id
3219   and    p_start_date between
3220          effective_start_date and effective_end_date
3221   and    nvl(current_employee_flag,'N') = 'Y';
3222   --
3223 begin
3224   hr_utility.set_location('Entering:'||l_proc, 10);
3225   --
3226   hr_api.mandatory_arg_error
3227     (p_api_name       => l_proc
3228     ,p_argument       => 'start_date'
3229     ,p_argument_value => p_start_date
3230     );
3231   --
3232   if hr_multi_message.no_all_inclusive_error
3233      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
3234      ) then
3235     --
3236     l_api_updating := hr_pdt_shd.api_updating
3237            (p_person_deployment_id   => p_person_deployment_id
3238            ,p_object_version_number  => p_object_version_number);
3239     --
3240     if ( (l_api_updating and
3241           ((nvl(hr_pdt_shd.g_old_rec.supervisor_id,hr_api.g_number)
3242               <> nvl(p_supervisor_id,hr_api.g_number))
3243           or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
3244         or not l_api_updating) then
3245       --
3246       if p_supervisor_id is not null then
3247          --
3248          if p_supervisor_id = nvl(p_to_person_id,-1)
3249          or p_supervisor_id = p_from_person_id then
3250             fnd_message.set_name('PER','HR_51143_ASG_EMP_EQUAL_SUP');
3251             fnd_message.raise_error;
3252          end if;
3253          --
3254 	 open csr_party_id(p_from_person_id);
3255 	 fetch csr_party_id into l_per_party_id;
3256 	 close csr_party_id;
3257 	 --
3258 	 open csr_party_id(p_supervisor_id);
3259 	 fetch csr_party_id into l_sup_party_id;
3260 	 close csr_party_id;
3261          --
3262          if l_per_party_id = l_sup_party_id then
3263             fnd_message.set_name('PER','HR_449603_ASG_SUP_DUP_PER');
3264             fnd_message.raise_error;
3265          end if;
3266          --
3267          open csr_check_sup;
3268          fetch csr_check_sup into l_sup_bg_id;
3269          if csr_check_sup%notfound then
3270             close csr_check_sup;
3271             fnd_message.set_name('PER','PAY_7599_SYS_SUP_DT_OUTDATE');
3272             fnd_message.raise_error;
3273          else
3274             close csr_check_sup;
3275             if (p_to_business_group_id <> l_sup_bg_id  AND
3276                nvl(fnd_profile.value('HR_CROSS_BUSINESS_GROUP'),'N')='N') then
3277               fnd_message.set_name('PER','HR_51145_ASG_SUP_BG_NE_EMP_BG');
3278               fnd_message.raise_error;
3279             end if;
3280          end if;
3281       end if;  --supervisor id not null
3282     end if;  --api updating
3283   end if; -- muti message
3284   --
3285   hr_utility.set_location('Leaving:'||l_proc, 20);
3286   --
3287   exception
3288     when app_exception.application_exception then
3289       if hr_multi_message.exception_add
3290       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.SUPERVISOR_ID'
3291       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
3292       ) then
3293         hr_utility.set_location(' Leaving:'||l_proc, 50);
3294         raise;
3295       end if;
3296    hr_utility.set_location(' Leaving:'||l_proc,60);
3297 end chk_supervisor_id;
3298 --
3299 --  ---------------------------------------------------------------------------
3300 --  |------------------------< chk_supervisor_assignment_id >-----------------|
3301 --  ---------------------------------------------------------------------------
3302 --
3303 --  Desciption:
3304 --    This procedures validates that supervisor_assignment_id is an existing employee
3305 --    assignment of the given supervisor.
3306 --
3307 --  Pre-conditions :
3308 --    None
3309 --
3310 --  In Parameters :
3311 --    p_supervisor_id
3312 --    p_supervisor_assignment_id
3313 --    p_start_date
3314 --
3315 --  Post Success :
3316 --    Processing continues if the supervisor_assignment_id is valid
3317 --
3318 --  Post Failure :
3319 --    An application error will be raised and processing is terminated if the
3320 --    supervisor_assignment_id is invalid
3321 --
3322 --  Access Status :
3323 --    Internal Row Handler Use only.
3324 --
3325 -- {End of Comments}
3326 --
3327 -- ---------------------------------------------------------------------------
3328 Procedure chk_supervisor_assignment_id
3329   (p_supervisor_assignment_id in out nocopy hr_person_deployments.supervisor_assignment_id%type
3330   ,p_supervisor_id          in hr_person_deployments.supervisor_id%type
3331   ,p_start_date             in hr_person_deployments.start_date%type
3332   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3333   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3334   ) is
3335   --
3336   l_proc        varchar2(72) := g_package||'chk_supervisor_assignment_id';
3337   l_api_updating     boolean;
3338   l_sup_asg_type     per_all_assignments_f.assignment_type%type;
3339   --
3340   cursor csr_check_sup_asg is
3341   select assignment_type
3342   from   per_all_assignments_f
3343   where  person_id = p_supervisor_id
3344   and    p_start_date between
3345          effective_start_date and effective_end_date;
3346   --
3347 begin
3348   hr_utility.set_location('Entering:'||l_proc, 10);
3349   --
3350   hr_api.mandatory_arg_error
3351     (p_api_name       => l_proc
3352     ,p_argument       => 'start_date'
3353     ,p_argument_value => p_start_date
3354     );
3355   --
3356   if hr_multi_message.no_all_inclusive_error
3357      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
3358      ) then
3359     --
3360     l_api_updating := hr_pdt_shd.api_updating
3361            (p_person_deployment_id   => p_person_deployment_id
3362            ,p_object_version_number  => p_object_version_number);
3363     --
3364     if ((l_api_updating and
3365          (   (nvl(hr_pdt_shd.g_old_rec.supervisor_id,hr_api.g_number)
3366                 <> nvl(p_supervisor_id,hr_api.g_number))
3367            or (nvl(hr_pdt_shd.g_old_rec.supervisor_assignment_id,hr_api.g_number)
3368                 <> nvl(p_supervisor_assignment_id,hr_api.g_number))
3369            or (hr_pdt_shd.g_old_rec.start_date <> p_start_date)
3370           )
3371          )
3372         or not l_api_updating
3373         ) then
3374       --
3375       if p_supervisor_id is null and p_supervisor_assignment_id is not null then
3376          p_supervisor_assignment_id := null;
3377       elsif p_supervisor_assignment_id is not null then
3378          open csr_check_sup_asg;
3379          fetch csr_check_sup_asg into l_sup_asg_type;
3380          if csr_check_sup_asg%notfound then
3381             close csr_check_sup_asg;
3382             fnd_message.set_name('PER','HR_50146_SUP_ASG_INVALID');
3383             fnd_message.raise_error;
3384          else
3385             close csr_check_sup_asg;
3386             if (l_sup_asg_type = 'E'
3387             or   (l_sup_asg_type = 'C' and
3388                   nvl(fnd_profile.value('HR_TREAT_CWK_AS_EMP'), 'N') = 'Y')) then
3389               null;
3390             else
3391               fnd_message.set_name('PER','HR_50147_SUP_ASG_WRONG_TYPE');
3392               fnd_message.raise_error;
3393             end if;
3394          end if;
3395 
3396       end if;
3397     end if;  --api updating
3398   end if;  --multi message
3399   --
3400   hr_utility.set_location('Leaving:'||l_proc, 20);
3401   --
3402   exception
3403     when app_exception.application_exception then
3404       if hr_multi_message.exception_add
3405       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.SUPERVISOR_ASSIGNMENT_ID'
3406       ) then
3407         hr_utility.set_location(' Leaving:'||l_proc, 50);
3408         raise;
3409       end if;
3410    hr_utility.set_location(' Leaving:'||l_proc,60);
3411 end chk_supervisor_assignment_id;
3412 --
3413 --  ---------------------------------------------------------------------------
3414 --  |------------------------< chk_pay_basis_id >-----------------------------|
3415 --  ---------------------------------------------------------------------------
3416 --
3417 --  Desciption:
3418 --    This procedures validates that pay_basis_id exists in host BG
3419 --
3420 --  Pre-conditions :
3421 --    None
3422 --
3423 --  In Parameters :
3424 --    p_pay_basis_id
3425 --    p_to_business_group_id
3426 --
3427 --  Post Success :
3428 --    Processing continues if thepay_basis_id  is valid
3429 --
3430 --  Post Failure :
3431 --    An application error will be raised and processing is terminated if the
3432 --    pay_basis_id is invalid
3433 --
3434 --  Access Status :
3435 --    Internal Row Handler Use only.
3436 --
3437 -- {End of Comments}
3438 --
3439 -- ---------------------------------------------------------------------------
3440 Procedure chk_pay_basis_id
3441   (p_pay_basis_id in hr_person_deployments.pay_basis_id%type
3442   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
3443   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3444   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3445   ) is
3446   --
3447   l_proc               varchar2(72) := g_package||'chk_pay_basis_id';
3448   l_api_updating       boolean;
3449   l_business_group_id  per_business_groups.business_group_id%TYPE;
3450   --
3451   cursor csr_check_pay_basis is
3452   select business_group_id
3453   from   per_pay_bases
3454   where  pay_basis_id = p_pay_basis_id;
3455   --
3456 begin
3457   hr_utility.set_location('Entering:'||l_proc, 10);
3458   --
3459   l_api_updating := hr_pdt_shd.api_updating
3460          (p_person_deployment_id   => p_person_deployment_id
3461          ,p_object_version_number  => p_object_version_number);
3462   --
3463   if ( (l_api_updating and
3464         (nvl(hr_pdt_shd.g_old_rec.pay_basis_id,hr_api.g_number)
3465             <> nvl(p_pay_basis_id,hr_api.g_number)))
3466       or not l_api_updating) then
3467       --
3468       if p_pay_basis_id is not null then
3469 	open csr_check_pay_basis;
3470 	fetch csr_check_pay_basis into l_business_group_id;
3471 	if csr_check_pay_basis%notfound then
3472 	   close csr_check_pay_basis;
3473 	   fnd_message.set_name('PER','HR_51168_ASG_INV_PAY_BASIS_ID');
3474 	   fnd_message.raise_error;
3475 	else
3476 	   close csr_check_pay_basis;
3477 	   if p_to_business_group_id <> l_business_group_id then
3478 	     fnd_message.set_name('PER','HR_51169_ASG_INV_PAY_BAS_BG');
3479 	     fnd_message.raise_error;
3480            end if;
3481 	end if;
3482     end if;  -- pay basis not null
3483   end if;  --api updating
3484   --
3485   hr_utility.set_location('Leaving:'||l_proc, 20);
3486   --
3487   exception
3488     when app_exception.application_exception then
3489       if hr_multi_message.exception_add
3490       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.PAY_BASIS_ID'
3491       ) then
3492         hr_utility.set_location(' Leaving:'||l_proc, 50);
3493         raise;
3494       end if;
3495    hr_utility.set_location(' Leaving:'||l_proc,60);
3496 end chk_pay_basis_id;
3497 --
3498 --  ---------------------------------------------------------------------------
3499 --  |------------------------< chk_people_group_id >--------------------------|
3500 --  ---------------------------------------------------------------------------
3501 --
3502 --  Desciption:
3503 --    This procedures validates that people group id exists on pay_people_groups
3504 --    and that the structure of the provided combination is valid for the Host BG
3505 --
3506 --  Pre-conditions :
3507 --    None
3508 --
3509 --  In Parameters :
3510 --    p_people_group_id
3511 --    p_start_date
3512 --    p_to_business_group_id
3513 --
3514 --  Post Success :
3515 --    Processing continues if the people_group_id is valid
3516 --
3517 --  Post Failure :
3518 --    An application error will be raised and processing is terminated if the
3519 --    people_group_id is invalid
3520 --
3521 --  Access Status :
3522 --    Internal Row Handler Use only.
3523 --
3524 -- {End of Comments}
3525 --
3526 -- ---------------------------------------------------------------------------
3527 Procedure chk_people_group_id
3528   (p_people_group_id        in hr_person_deployments.people_group_id%type
3529   ,p_start_date             in hr_person_deployments.start_date%type
3530   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
3531   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3532   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3533   ) is
3534   --
3535   l_proc                 varchar2(72) := g_package||'chk_people_group_id';
3536   l_api_updating         boolean;
3537   l_id_flex_num          pay_people_groups.id_flex_num%type;
3538   l_enabled_flag         pay_people_groups.enabled_flag%TYPE;
3539   l_bg_id_flex_num       per_business_groups_perf.people_group_structure%type;
3540   --
3541   cursor csr_check_grp is
3542   select enabled_flag,id_flex_num
3543   from   pay_people_groups
3544   where  people_group_id = p_people_group_id
3545   and    p_start_date between
3546          nvl(start_date_active,hr_api.g_sot) and nvl(end_date_active,hr_api.g_eot);
3547   --
3548   cursor csr_get_bg_flex is
3549   select people_group_structure
3550   from   per_business_groups_perf
3551   where  business_group_id = p_to_business_group_id;
3552   --
3553 begin
3554   hr_utility.set_location('Entering:'||l_proc, 10);
3555   --
3556   hr_api.mandatory_arg_error
3557     (p_api_name       => l_proc
3558     ,p_argument       => 'start_date'
3559     ,p_argument_value => p_start_date
3560     );
3561   --
3562   hr_api.mandatory_arg_error
3563     (p_api_name       => l_proc
3564     ,p_argument       => 'to_business_group_id'
3565     ,p_argument_value => p_to_business_group_id
3566     );
3567   --
3568   if hr_multi_message.no_all_inclusive_error
3569      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
3570      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
3571      ) then
3572     --
3573     l_api_updating := hr_pdt_shd.api_updating
3574 	   (p_person_deployment_id   => p_person_deployment_id
3575 	   ,p_object_version_number  => p_object_version_number);
3576     --
3577     if ( (l_api_updating and
3578 	  (nvl(hr_pdt_shd.g_old_rec.people_group_id,hr_api.g_number)
3579 	      <> nvl(p_people_group_id,hr_api.g_number)
3580 	   or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
3581 	or not l_api_updating) then
3582 	--
3583         if p_people_group_id is not null then
3584            open csr_check_grp;
3585            fetch csr_check_grp into l_enabled_flag,l_id_flex_num;
3586            if csr_check_grp%notfound then
3587               close csr_check_grp;
3588 	      fnd_message.set_name('PER','HR_7385_ASG_INV_PEOPLE_GROUP');
3589 	      fnd_message.raise_error;
3590            else
3591               close csr_check_grp;
3592               if l_enabled_flag <> 'Y' then
3593 	        fnd_message.set_name('PER','HR_51252_ASG_INV_PGP_ENBD_FLAG');
3594 	        fnd_message.raise_error;
3595               end if;
3596               --
3597               open csr_get_bg_flex;
3598               fetch csr_get_bg_flex into l_bg_id_flex_num;
3599               close csr_get_bg_flex;
3600               --
3601               if to_number(l_bg_id_flex_num) <> l_id_flex_num then
3602 	        fnd_message.set_name('PER','HR_7386_ASG_INV_PEOP_GRP_LINK');
3603 	        fnd_message.raise_error;
3604               end if;
3605               --
3606            end if;  --csr_check_grp not found
3607         end if;  --people group not null
3608     end if; --api updating
3609   end if;  --multi message
3610   --
3611   hr_utility.set_location('Leaving:'||l_proc, 20);
3612   --
3613   exception
3614     when app_exception.application_exception then
3615       if hr_multi_message.exception_add
3616       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.PEOPLE_GROUP_ID'
3617       ) then
3618         hr_utility.set_location(' Leaving:'||l_proc, 50);
3619         raise;
3620       end if;
3621    hr_utility.set_location(' Leaving:'||l_proc,60);
3622 end chk_people_group_id;
3623 --
3624 --  ---------------------------------------------------------------------------
3625 --  |------------------------< chk_soft_coding_keyflex_id >-------------------|
3626 --  ---------------------------------------------------------------------------
3627 --
3628 --  Desciption:
3629 --    This procedures validates that people group id exists on
3630 --    and that the structure of the provided combination is valid for the Host BG
3631 --
3632 --  Pre-conditions :
3633 --    None
3634 --
3635 --  In Parameters :
3636 --    p_soft_coding_keyflex_id
3637 --    p_start_date
3638 --    p_to_business_group_id
3639 --
3640 --  Post Success :
3641 --    Processing continues if the soft_coding_keyflex_id is valid
3642 --
3643 --  Post Failure :
3644 --    An application error will be raised and processing is terminated if the
3645 --    soft_coding_keyflex_id is invalid
3646 --
3647 --  Access Status :
3648 --    Internal Row Handler Use only.
3649 --
3650 -- {End of Comments}
3651 --
3652 -- ---------------------------------------------------------------------------
3653 Procedure chk_soft_coding_keyflex_id
3654   (p_soft_coding_keyflex_id in hr_person_deployments.soft_coding_keyflex_id%type
3655   ,p_start_date             in hr_person_deployments.start_date%type
3656   ,p_to_business_group_id   in hr_person_deployments.to_business_group_id%type
3657   ,p_payroll_id             in hr_person_deployments.payroll_id%type
3658   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3659   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3660   ) is
3661   --
3662   l_proc                 varchar2(72) := g_package||'chk_soft_coding_keyflex_id';
3663   l_api_updating         boolean;
3664   l_dummy                number;
3665   l_legislation_code     per_business_groups_perf.legislation_code%type;
3666   --
3667   cursor csr_check_scl is
3668   select 1
3669   from   hr_soft_coding_keyflex
3670   where  soft_coding_keyflex_id = p_soft_coding_keyflex_id
3671   and    enabled_flag = 'Y'
3672   and    p_start_date between
3673          nvl(start_date_active,hr_api.g_sot) and nvl(end_date_active,hr_api.g_eot);
3674   --
3675   cursor csr_bg_leg is
3676   select legislation_code
3677   from   per_business_groups_perf
3678   where  business_group_id = p_to_business_group_id;
3679   --
3680   cursor csr_pay_legislation_rules(p_legislation_code per_business_groups_perf.legislation_code%type) is
3681   select 1
3682   from   pay_legislation_rules
3683   where  legislation_code = p_legislation_code
3684   and    rule_type = 'TAX_UNIT'
3685   and    rule_mode = 'Y';
3686   --
3687   cursor csr_tax_unit_message(p_message_name varchar2) is
3688   select 1
3689   from   fnd_new_messages
3690   where  message_name = p_message_name
3691   and    application_id = 801;
3692 --
3693 begin
3694   hr_utility.set_location('Entering:'||l_proc, 10);
3695   --
3696   hr_api.mandatory_arg_error
3697     (p_api_name       => l_proc
3698     ,p_argument       => 'start_date'
3699     ,p_argument_value => p_start_date
3700     );
3701   --
3702   hr_api.mandatory_arg_error
3703     (p_api_name       => l_proc
3704     ,p_argument       => 'to_business_group_id'
3705     ,p_argument_value => p_to_business_group_id
3706     );
3707   --
3708   if hr_multi_message.no_all_inclusive_error
3709      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
3710      ,p_check_column2      =>  'HR_PERSON_DEPLOYMENTS.TO_BUSINESS_GROUP_ID'
3711      ) then
3712     --
3713     l_api_updating := hr_pdt_shd.api_updating
3714 	   (p_person_deployment_id   => p_person_deployment_id
3715 	   ,p_object_version_number  => p_object_version_number);
3716     --
3717     if ( (l_api_updating and
3718 	  (nvl(hr_pdt_shd.g_old_rec.soft_coding_keyflex_id,hr_api.g_number)
3719 	      <> nvl(p_soft_coding_keyflex_id,hr_api.g_number)
3720 	   or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
3721         or (l_api_updating and
3722             p_soft_coding_keyflex_id is null and p_payroll_id is not null)
3723 	or not l_api_updating) then
3724 	--
3725         if p_soft_coding_keyflex_id is not null then
3726            open csr_check_scl;
3727            fetch csr_check_scl into l_dummy;
3728            if csr_check_scl%notfound then
3729               close csr_check_scl;
3730 	      fnd_message.set_name('PER','HR_7383_ASG_INV_KEYFLEX');
3731               hr_multi_message.add
3732                   (p_associated_column1 => 'HR_PERSON_DEPLOYMENTS.SOFT_CODING_KEYFLEX_ID'                  ,p_associated_column2 => 'HR_PERSON_DEPLOYMENTS.START_DATE');
3733            else
3734               close csr_check_scl;
3735               --
3736 	      end if;
3737 	 else  -- bug fix 6956927
3738 	 -- Check that for relevant legislations SCL is mandatory,
3739       --  when payroll_id is populated
3740               if p_payroll_id is not null then
3741 		open csr_bg_leg;
3742 		fetch csr_bg_leg into l_legislation_code;
3743 		close csr_bg_leg;
3744 		--
3745                 open csr_pay_legislation_rules(l_legislation_code);
3746                 fetch csr_pay_legislation_rules into l_dummy;
3747                 if csr_pay_legislation_rules%found then
3748                    close csr_pay_legislation_rules;
3749                    if l_legislation_code = 'US' then
3750 	              fnd_message.set_name('PER','HR_50001_EMP_ASS_NO_GRE');
3751                       hr_multi_message.add
3752                        (p_associated_column1 => 'HR_PERSON_DEPLOYMENTS.PAYROLL_ID');
3753                    else
3754                       open csr_tax_unit_message('HR_INV_LEG_ENT_'||l_legislation_code);
3755                       fetch csr_tax_unit_message into l_dummy;
3756                       if csr_tax_unit_message%found then
3757                          close csr_tax_unit_message;
3758                          fnd_message.set_name('PER','HR_INV_LEG_ENT_'||l_legislation_code);
3759                       else
3760                          close csr_tax_unit_message;
3761                          fnd_message.set_name('PER','HR_34024_IP_INV_LEG_ENT');
3762                       end if;
3763                       hr_multi_message.add
3764                        (p_associated_column1 => 'HR_PERSON_DEPLOYMENTS.PAYROLL_ID');
3765                    end if;  --legislation code
3766                 end if;  --csr_pay_legislation_rules found
3767               end if; --payroll_id not null
3768           -- end if;  --csr_check_scl not found
3769         end if;  --soft coding keyflex not null
3770     end if; --api updating
3771   end if;  --multi message
3772   --
3773   hr_utility.set_location('Leaving:'||l_proc, 20);
3774   --
3775   exception
3776     when app_exception.application_exception then
3777       if hr_multi_message.exception_add
3778       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.SOFT_CODING_KEYFLEX_ID'
3779       ) then
3780         hr_utility.set_location(' Leaving:'||l_proc, 50);
3781         raise;
3782       end if;
3783    hr_utility.set_location(' Leaving:'||l_proc,60);
3784 end chk_soft_coding_keyflex_id;
3785 --
3786 --  ---------------------------------------------------------------------------
3787 --  |------------------------< chk_assignment_category >----------------------|
3788 --  ---------------------------------------------------------------------------
3789 --
3790 --  Desciption:
3791 --    This procedures validates that assignment category is valid from lookup EMP_CAT
3792 --
3793 --  Pre-conditions :
3794 --    None
3795 --
3796 --  In Parameters :
3797 --    p_assignment_category
3798 --    p_start_date
3799 --
3800 --  Post Success :
3801 --    Processing continues if the  is valid
3802 --
3803 --  Post Failure :
3804 --    An application error will be raised and processing is terminated if the
3805 --     is invalid
3806 --
3807 --  Access Status :
3808 --    Internal Row Handler Use only.
3809 --
3810 -- {End of Comments}
3811 --
3812 -- ---------------------------------------------------------------------------
3813 Procedure chk_assignment_category
3814   (p_assignment_category in hr_person_deployments.assignment_category%type
3815   ,p_start_date             in hr_person_deployments.start_date%type
3816   ,p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3817   ,p_object_version_number  in hr_person_deployments.object_version_number%type
3818   ) is
3819   --
3820   l_proc        varchar2(72) := g_package||'chk_assignment_category';
3821   l_api_updating     boolean;
3822   --
3823 begin
3824   hr_utility.set_location('Entering:'||l_proc, 10);
3825   --
3826   hr_api.mandatory_arg_error
3827     (p_api_name       => l_proc
3828     ,p_argument       => 'start_date'
3829     ,p_argument_value => p_start_date
3830     );
3831   --
3832   if hr_multi_message.no_all_inclusive_error
3833      (p_check_column1      =>  'HR_PERSON_DEPLOYMENTS.START_DATE'
3834      ) then
3835     --
3836     l_api_updating := hr_pdt_shd.api_updating
3837 	   (p_person_deployment_id   => p_person_deployment_id
3838 	   ,p_object_version_number  => p_object_version_number);
3839     --
3840     if ( (l_api_updating and
3841           (nvl(hr_pdt_shd.g_old_rec.assignment_category,hr_api.g_varchar2)
3842               <> nvl(p_assignment_category,hr_api.g_varchar2)
3843            or hr_pdt_shd.g_old_rec.start_date <> p_start_date))
3844         or not l_api_updating) then
3845       --
3846       if p_assignment_category is not null
3847       and hr_api.not_exists_in_leg_lookups
3848           (p_effective_date        => p_start_date
3849           ,p_lookup_type           => 'EMP_CAT'
3850           ,p_lookup_code           => p_assignment_category
3851           ) then
3852           fnd_message.set_name('PER','HR_51028_ASG_INV_EMP_CATEGORY');
3853           fnd_message.raise_error;
3854       end if;  --assignment category not null
3855     end if;  --api updating
3856   end if;  --multi message
3857   --
3858   hr_utility.set_location('Leaving:'||l_proc, 20);
3859   --
3860   exception
3861     when app_exception.application_exception then
3862       if hr_multi_message.exception_add
3863       (p_associated_column1      => 'HR_PERSON_DEPLOYMENTS.ASSIGNMENT_CATEGORY'
3864       ,p_associated_column2      => 'HR_PERSON_DEPLOYMENTS.START_DATE'
3865       ) then
3866         hr_utility.set_location(' Leaving:'||l_proc, 50);
3867         raise;
3868       end if;
3869    hr_utility.set_location(' Leaving:'||l_proc,60);
3870 end chk_assignment_category;
3871 --
3872 --  ---------------------------------------------------------------------------
3873 --  |------------------------< chk_delete >-----------------------------------|
3874 --  ---------------------------------------------------------------------------
3875 --
3876 --  Desciption:
3877 --    This procedures validates that
3878 --
3879 --  Pre-conditions :
3880 --    None
3881 --
3882 --  In Parameters :
3883 --
3884 --
3885 --  Post Success :
3886 --    Processing continues if the  is valid
3887 --
3888 --  Post Failure :
3889 --    An application error will be raised and processing is terminated if the
3890 --     is invalid
3891 --
3892 --  Access Status :
3893 --    Internal Row Handler Use only.
3894 --
3895 -- {End of Comments}
3896 --
3897 -- ---------------------------------------------------------------------------
3898 Procedure chk_delete
3899   (p_person_deployment_id   in hr_person_deployments.person_deployment_id%type
3900   ) is
3901   --
3902   l_proc        varchar2(72) := g_package||'chk_delete';
3903   l_api_updating     boolean;
3904   l_start_date       date;
3905   l_status           hr_person_deployments.status%type;
3906   --
3907   cursor csr_deployment is
3908   select start_date,status
3909   from   hr_person_deployments
3910   where  person_deployment_id = p_person_deployment_id;
3911   --
3912 begin
3913   hr_utility.set_location('Entering:'||l_proc, 10);
3914   --
3915   open csr_deployment;
3916   fetch csr_deployment into l_start_date,l_status;
3917   if csr_deployment%notfound then
3918      close csr_deployment;
3919      fnd_message.set_name('PER','HR_449647_PDT_DPL_DEL_PK');
3920      fnd_message.raise_error;
3921   else
3922      close csr_deployment;
3923      if l_status = 'ACTIVE' then
3924         fnd_message.set_name('PER','HR_449648_PDT_DPL_DEL_STATUS');
3925         fnd_message.raise_error;
3926      end if;
3927   end if;
3928   --
3929   hr_utility.set_location('Leaving:'||l_proc, 20);
3930   --
3931 end chk_delete;
3932 --
3933 -- ----------------------------------------------------------------------------
3934 -- |---------------------------< insert_validate >----------------------------|
3935 -- ----------------------------------------------------------------------------
3936 Procedure insert_validate
3937   (p_rec                          in out nocopy hr_pdt_shd.g_rec_type
3938   ) is
3939 --
3940   l_proc  varchar2(72) := g_package||'insert_validate';
3941   l_inv_pos_grade_warning  boolean;
3942   l_inv_job_grade_warning  boolean;
3943 --
3944 Begin
3945   hr_utility.set_location('Entering:'||l_proc, 5);
3946   --
3947   -- Call all supporting business operations
3948   --
3949   --
3950   -- Set security Group context based on the TO_BUSINESS_GROUP_ID since the data
3951   -- in this table is being held specifically to be copied to an assignment there
3952   --
3953   hr_oru_bus.set_security_group_id(p_rec.to_business_group_id);
3954   --
3955   -- Validate Dependent Attributes
3956   --
3957   if g_debug then
3958      hr_utility.set_location(l_proc, 10);
3959   end if;
3960   --
3961   hr_pdt_bus.chk_business_groups
3962     (p_from_business_group_id => p_rec.from_business_group_id
3963     ,p_to_business_group_id   => p_rec.to_business_group_id
3964     );
3965   --
3966   if g_debug then
3967      hr_utility.set_location(l_proc, 15);
3968   end if;
3969   --
3970   hr_pdt_bus.chk_from_person_id
3971     (p_person_deployment_id   => p_rec.person_deployment_id
3972     ,p_object_version_number  => p_rec.object_version_number
3973     ,p_from_person_id         => p_rec.from_person_id
3974     ,p_from_business_group_id => p_rec.from_business_group_id
3975     ,p_start_date             => p_rec.start_date
3976     );
3977   --
3978   if g_debug then
3979      hr_utility.set_location(l_proc, 20);
3980   end if;
3981   --
3982   hr_pdt_bus.chk_to_person_id
3983     (p_person_deployment_id   => p_rec.person_deployment_id
3984     ,p_object_version_number  => p_rec.object_version_number
3985     ,p_to_person_id           => p_rec.to_person_id
3986     ,p_to_business_group_id   => p_rec.to_business_group_id
3987     ,p_start_date             => p_rec.start_date
3988     ,p_status                 => p_rec.status
3989     );
3990   --
3991   if g_debug then
3992      hr_utility.set_location(l_proc, 25);
3993   end if;
3994   --
3995   hr_pdt_bus.chk_person_type_id
3996     (p_person_type_id         => p_rec.person_type_id
3997     ,p_to_business_group_id   => p_rec.to_business_group_id
3998     ,p_person_deployment_id   => p_rec.person_deployment_id
3999     ,p_object_version_number  => p_rec.object_version_number
4000     );
4001   --
4002   if g_debug then
4003      hr_utility.set_location(l_proc,30 );
4004   end if;
4005   --
4006   hr_pdt_bus.chk_start_end_date
4007     (p_start_date             => p_rec.start_date
4008     ,p_end_date               => p_rec.end_date
4009     ,p_person_deployment_id   => p_rec.person_deployment_id
4010     ,p_object_version_number  => p_rec.object_version_number
4011     ,p_status                 => p_rec.status
4012     );
4013   --
4014   if g_debug then
4015      hr_utility.set_location(l_proc, 35);
4016   end if;
4017   --
4018   hr_pdt_bus.chk_permanent
4019     (p_permanent              => p_rec.permanent
4020     ,p_from_person_id         => p_rec.from_person_id
4021     ,p_end_date               => p_rec.end_date
4022     ,p_person_deployment_id   => p_rec.person_deployment_id
4023     ,p_object_version_number  => p_rec.object_version_number
4024     );
4025   --
4026   if g_debug then
4027      hr_utility.set_location(l_proc, 40);
4028   end if;
4029   --
4030   hr_pdt_bus.chk_deployment_reason
4031     (p_deployment_reason      => p_rec.deployment_reason
4032     ,p_start_date             => p_rec.start_date
4033     ,p_person_deployment_id   => p_rec.person_deployment_id
4034     ,p_object_version_number  => p_rec.object_version_number
4035     );
4036   --
4037   if g_debug then
4038      hr_utility.set_location(l_proc, 45);
4039   end if;
4040   --
4041   hr_pdt_bus.chk_employee_number
4042     (p_employee_number        => p_rec.employee_number
4043     ,p_to_business_group_id   => p_rec.to_business_group_id
4044     ,p_to_person_id           => p_rec.to_person_id
4045     ,p_person_deployment_id   => p_rec.person_deployment_id
4046     ,p_object_version_number  => p_rec.object_version_number
4047     );
4048   --
4049   if g_debug then
4050      hr_utility.set_location(l_proc,50 );
4051   end if;
4052   --
4053   hr_pdt_bus.chk_leaving_reason
4054     (p_leaving_reason         => p_rec.leaving_reason
4055     ,p_start_date             => p_rec.start_date
4056     ,p_permanent              => p_rec.permanent
4057     ,p_person_deployment_id   => p_rec.person_deployment_id
4058     ,p_object_version_number  => p_rec.object_version_number
4059     );
4060   --
4061   if g_debug then
4062      hr_utility.set_location(l_proc, 55);
4063   end if;
4064   --
4065   hr_pdt_bus.chk_leaving_person_type_id
4066     (p_leaving_person_type_id => p_rec.leaving_person_type_id
4067     ,p_to_business_group_id   => p_rec.to_business_group_id
4068     ,p_permanent              => p_rec.permanent
4069     ,p_person_deployment_id   => p_rec.person_deployment_id
4070     ,p_object_version_number  => p_rec.object_version_number
4071     );
4072   --
4073   if g_debug then
4074      hr_utility.set_location(l_proc, 60);
4075   end if;
4076   --
4077   hr_pdt_bus.chk_status
4078     (p_status                 => p_rec.status
4079     ,p_start_date             => p_rec.start_date
4080     ,p_person_deployment_id   => p_rec.person_deployment_id
4081     ,p_object_version_number  => p_rec.object_version_number
4082     );
4083   --
4084   if g_debug then
4085      hr_utility.set_location(l_proc,65 );
4086   end if;
4087   --
4088   hr_pdt_bus.chk_deplymt_policy_id
4089     (p_deplymt_policy_id      => p_rec.deplymt_policy_id
4090     );
4091   --
4092   if g_debug then
4093      hr_utility.set_location(l_proc, 70);
4094   end if;
4095   --
4096   hr_pdt_bus.chk_retain_direct_reports
4097     (p_retain_direct_reports  => p_rec.retain_direct_reports
4098     ,p_from_person_id         => p_rec.from_person_id
4099     ,p_start_date             => p_rec.start_date
4100     ,p_to_business_group_id   => p_rec.to_business_group_id
4101     ,p_from_business_group_id => p_rec.from_business_group_id
4102     ,p_person_deployment_id   => p_rec.person_deployment_id
4103     ,p_object_version_number  => p_rec.object_version_number
4104     );
4105   --
4106   if g_debug then
4107      hr_utility.set_location(l_proc, 75);
4108   end if;
4109   --
4110   hr_pdt_bus.chk_organization_id
4111     (p_organization_id        => p_rec.organization_id
4112     ,p_to_business_group_id   => p_rec.to_business_group_id
4113     ,p_person_deployment_id   => p_rec.person_deployment_id
4114     ,p_object_version_number  => p_rec.object_version_number
4115     );
4116   --
4117   if g_debug then
4118      hr_utility.set_location(l_proc, 80);
4119   end if;
4120   --
4121   hr_pdt_bus.chk_location_id
4122     (p_location_id            => p_rec.location_id
4123     ,p_start_date             => p_rec.start_date
4124     ,p_to_business_group_id   => p_rec.to_business_group_id
4125     ,p_person_deployment_id   => p_rec.person_deployment_id
4126     ,p_object_version_number  => p_rec.object_version_number
4127      );
4128   --
4129   if g_debug then
4130      hr_utility.set_location(l_proc, 85);
4131   end if;
4132   --
4133   hr_pdt_bus.chk_job_id
4134     (p_job_id                 => p_rec.job_id
4135     ,p_start_date             => p_rec.start_date
4136     ,p_to_business_group_id   => p_rec.to_business_group_id
4137     ,p_person_deployment_id   => p_rec.person_deployment_id
4138     ,p_object_version_number  => p_rec.object_version_number
4139     );
4140   --
4141   if g_debug then
4142      hr_utility.set_location(l_proc,90 );
4143   end if;
4144   --
4145   hr_pdt_bus.chk_position_id
4146     (p_position_id            => p_rec.position_id
4147     ,p_start_date             => p_rec.start_date
4148     ,p_to_business_group_id   => p_rec.to_business_group_id
4149     ,p_person_deployment_id   => p_rec.person_deployment_id
4150     ,p_object_version_number  => p_rec.object_version_number
4151     );
4152   --
4153   if g_debug then
4154      hr_utility.set_location(l_proc, 95);
4155   end if;
4156   --
4157   hr_pdt_bus.chk_grade_id
4158     (p_grade_id               => p_rec.grade_id
4159     ,p_start_date             => p_rec.start_date
4160     ,p_to_business_group_id   => p_rec.to_business_group_id
4161     ,p_person_deployment_id   => p_rec.person_deployment_id
4162     ,p_object_version_number  => p_rec.object_version_number
4163     );
4164   --
4165   if g_debug then
4166      hr_utility.set_location(l_proc, 100);
4167   end if;
4168   --
4169   hr_pdt_bus.chk_position_id_job_id
4170     (p_position_id            => p_rec.position_id
4171     ,p_job_id                 => p_rec.job_id
4172     ,p_start_date             => p_rec.start_date
4173     ,p_person_deployment_id   => p_rec.person_deployment_id
4174     ,p_object_version_number  => p_rec.object_version_number
4175     );
4176   --
4177   if g_debug then
4178      hr_utility.set_location(l_proc, 105);
4179   end if;
4180   --
4181   hr_pdt_bus.chk_position_id_grade_id
4182     (p_position_id            => p_rec.position_id
4183     ,p_grade_id               => p_rec.grade_id
4184     ,p_start_date             => p_rec.start_date
4185     ,p_person_deployment_id   => p_rec.person_deployment_id
4186     ,p_object_version_number  => p_rec.object_version_number
4187     ,p_inv_pos_grade_warning  => l_inv_pos_grade_warning
4188     );
4189   --
4190   if g_debug then
4191      hr_utility.set_location(l_proc, 110);
4192   end if;
4193   --
4194   hr_pdt_bus.chk_job_id_grade_id
4195     (p_job_id                 => p_rec.job_id
4196     ,p_grade_id               => p_rec.grade_id
4197     ,p_start_date             => p_rec.start_date
4198     ,p_person_deployment_id   => p_rec.person_deployment_id
4199     ,p_object_version_number  => p_rec.object_version_number
4200     ,p_inv_job_grade_warning  => l_inv_job_grade_warning
4201     );
4202   --
4203   if g_debug then
4204      hr_utility.set_location(l_proc, 115);
4205   end if;
4206   --
4207   hr_pdt_bus.chk_position_id_org_id
4208     (p_position_id            => p_rec.position_id
4209     ,p_organization_id        => p_rec.organization_id
4210     ,p_start_date             => p_rec.start_date
4211     ,p_person_deployment_id   => p_rec.person_deployment_id
4212     ,p_object_version_number  => p_rec.object_version_number
4213     );
4214   --
4215   if g_debug then
4216      hr_utility.set_location(l_proc, 120);
4217   end if;
4218   --
4219   hr_pdt_bus.chk_payroll_id
4220     (p_payroll_id             => p_rec.payroll_id
4221     ,p_start_date             => p_rec.start_date
4222     ,p_to_business_group_id   => p_rec.to_business_group_id
4223     ,p_person_deployment_id   => p_rec.person_deployment_id
4224     ,p_object_version_number  => p_rec.object_version_number
4225     );
4226   --
4227   if g_debug then
4228      hr_utility.set_location(l_proc, 125);
4229   end if;
4230   --
4231   hr_pdt_bus.chk_assignment_status_type_id
4232     (p_assignment_status_type_id => p_rec.assignment_status_type_id
4233     ,p_to_business_group_id   => p_rec.to_business_group_id
4234     ,p_person_deployment_id   => p_rec.person_deployment_id
4235     ,p_object_version_number  => p_rec.object_version_number
4236     );
4237   --
4238   if g_debug then
4239      hr_utility.set_location(l_proc, 130);
4240   end if;
4241   --
4242   hr_pdt_bus.chk_supervisor_id
4243     (p_supervisor_id          => p_rec.supervisor_id
4244     ,p_start_date             => p_rec.start_date
4245     ,p_from_person_id         => p_rec.from_person_id
4246     ,p_to_person_id           => p_rec.to_person_id
4247     ,p_to_business_group_id   => p_rec.to_business_group_id
4248     ,p_person_deployment_id   => p_rec.person_deployment_id
4249     ,p_object_version_number  => p_rec.object_version_number
4250     );
4251   --
4252   if g_debug then
4253      hr_utility.set_location(l_proc, 140);
4254   end if;
4255   --
4256   hr_pdt_bus.chk_supervisor_assignment_id
4257     (p_supervisor_assignment_id => p_rec.supervisor_assignment_id
4258     ,p_supervisor_id          => p_rec.supervisor_id
4259     ,p_start_date             => p_rec.start_date
4260     ,p_person_deployment_id   => p_rec.person_deployment_id
4261     ,p_object_version_number  => p_rec.object_version_number
4262     );
4263   --
4264   if g_debug then
4265      hr_utility.set_location(l_proc, 145);
4266   end if;
4267   --
4268   hr_pdt_bus.chk_pay_basis_id
4269     (p_pay_basis_id           => p_rec.pay_basis_id
4270     ,p_to_business_group_id   => p_rec.to_business_group_id
4271     ,p_person_deployment_id   => p_rec.person_deployment_id
4272     ,p_object_version_number  => p_rec.object_version_number
4273     );
4274   --
4275   if g_debug then
4276      hr_utility.set_location(l_proc, 150);
4277   end if;
4278   --
4279   hr_pdt_bus.chk_people_group_id
4280     (p_people_group_id        => p_rec.people_group_id
4281     ,p_start_date             => p_rec.start_date
4282     ,p_to_business_group_id   => p_rec.to_business_group_id
4283     ,p_person_deployment_id   => p_rec.person_deployment_id
4284     ,p_object_version_number  => p_rec.object_version_number
4285     );
4286   --
4287   if g_debug then
4288      hr_utility.set_location(l_proc, 155);
4289   end if;
4290   --
4291   hr_pdt_bus.chk_soft_coding_keyflex_id
4292     (p_soft_coding_keyflex_id => p_rec.soft_coding_keyflex_id
4293     ,p_start_date             => p_rec.start_date
4294     ,p_to_business_group_id   => p_rec.to_business_group_id
4295     ,p_payroll_id             => p_rec.payroll_id
4296     ,p_person_deployment_id   => p_rec.person_deployment_id
4297     ,p_object_version_number  => p_rec.object_version_number
4298     );
4299   --
4300   if g_debug then
4301      hr_utility.set_location(l_proc, 160);
4302   end if;
4303   --
4304   hr_pdt_bus.chk_assignment_category
4305     (p_assignment_category    => p_rec.assignment_category
4306     ,p_start_date             => p_rec.start_date
4307     ,p_person_deployment_id   => p_rec.person_deployment_id
4308     ,p_object_version_number  => p_rec.object_version_number
4309     );
4310   --
4311   hr_pdt_bus.chk_ddf(p_rec);
4312   --
4313   hr_utility.set_location(' Leaving:'||l_proc, 10);
4314 End insert_validate;
4315 --
4316 -- ----------------------------------------------------------------------------
4317 -- |---------------------------< update_validate >----------------------------|
4318 -- ----------------------------------------------------------------------------
4319 Procedure update_validate
4320   (p_rec                          in out nocopy hr_pdt_shd.g_rec_type
4321   ) is
4322 --
4323   l_proc  varchar2(72) := g_package||'update_validate';
4324   l_inv_pos_grade_warning  boolean;
4325   l_inv_job_grade_warning  boolean;
4326 --
4327 Begin
4328   hr_utility.set_location('Entering:'||l_proc, 5);
4329   --
4330   -- Call all supporting business operations
4331   --
4332   --
4333   -- Set security Group context based on the TO_BUSINESS_GROUP_ID since the data
4334   -- in this table is being held specifically to be copied to an assignment there
4335   --
4336   hr_oru_bus.set_security_group_id(p_rec.to_business_group_id);
4337   --
4338   -- Validate Dependent Attributes
4339   --
4340   chk_non_updateable_args
4341     (p_rec              => p_rec
4342     );
4343   --
4344   if g_debug then
4345      hr_utility.set_location(l_proc, 20);
4346   end if;
4347   --
4348   hr_pdt_bus.chk_to_person_id
4349     (p_person_deployment_id   => p_rec.person_deployment_id
4350     ,p_object_version_number  => p_rec.object_version_number
4351     ,p_to_person_id           => p_rec.to_person_id
4352     ,p_to_business_group_id   => p_rec.to_business_group_id
4353     ,p_start_date             => p_rec.start_date
4354     ,p_status                 => p_rec.status
4355     );
4356   --
4357   if g_debug then
4358      hr_utility.set_location(l_proc, 25);
4359   end if;
4360   --
4361   hr_pdt_bus.chk_person_type_id
4362     (p_person_type_id         => p_rec.person_type_id
4363     ,p_to_business_group_id   => p_rec.to_business_group_id
4364     ,p_person_deployment_id   => p_rec.person_deployment_id
4365     ,p_object_version_number  => p_rec.object_version_number
4366     );
4367   --
4368   if g_debug then
4369      hr_utility.set_location(l_proc,30 );
4370   end if;
4371   --
4372   hr_pdt_bus.chk_start_end_date
4373     (p_start_date             => p_rec.start_date
4374     ,p_end_date               => p_rec.end_date
4375     ,p_person_deployment_id   => p_rec.person_deployment_id
4376     ,p_object_version_number  => p_rec.object_version_number
4377     ,p_status                 => p_rec.status
4378     );
4379   --
4380   if g_debug then
4381      hr_utility.set_location(l_proc, 35);
4382   end if;
4383   --
4384   hr_pdt_bus.chk_deployment_reason
4385     (p_deployment_reason      => p_rec.deployment_reason
4386     ,p_start_date             => p_rec.start_date
4387     ,p_person_deployment_id   => p_rec.person_deployment_id
4388     ,p_object_version_number  => p_rec.object_version_number
4389     );
4390   --
4391   if g_debug then
4392      hr_utility.set_location(l_proc, 45);
4393   end if;
4394   --
4395   hr_pdt_bus.chk_employee_number
4396     (p_employee_number        => p_rec.employee_number
4397     ,p_to_business_group_id   => p_rec.to_business_group_id
4398     ,p_to_person_id           => p_rec.to_person_id
4399     ,p_person_deployment_id   => p_rec.person_deployment_id
4400     ,p_object_version_number  => p_rec.object_version_number
4401     );
4402   --
4403   if g_debug then
4404      hr_utility.set_location(l_proc,50 );
4405   end if;
4406   --
4407   hr_pdt_bus.chk_leaving_reason
4408     (p_leaving_reason         => p_rec.leaving_reason
4409     ,p_start_date             => p_rec.start_date
4410     ,p_permanent              => p_rec.permanent
4411     ,p_person_deployment_id   => p_rec.person_deployment_id
4412     ,p_object_version_number  => p_rec.object_version_number
4413     );
4414   --
4415   if g_debug then
4416      hr_utility.set_location(l_proc, 55);
4417   end if;
4418   --
4419   hr_pdt_bus.chk_leaving_person_type_id
4420     (p_leaving_person_type_id => p_rec.leaving_person_type_id
4421     ,p_to_business_group_id   => p_rec.to_business_group_id
4422     ,p_permanent              => p_rec.permanent
4423     ,p_person_deployment_id   => p_rec.person_deployment_id
4424     ,p_object_version_number  => p_rec.object_version_number
4425     );
4426   --
4427   if g_debug then
4428      hr_utility.set_location(l_proc, 60);
4429   end if;
4430   --
4431   hr_pdt_bus.chk_status
4432     (p_status                 => p_rec.status
4433     ,p_start_date             => p_rec.start_date
4434     ,p_person_deployment_id   => p_rec.person_deployment_id
4435     ,p_object_version_number  => p_rec.object_version_number
4436     );
4437   --
4438   if g_debug then
4439      hr_utility.set_location(l_proc,65 );
4440   end if;
4441   --
4442   hr_pdt_bus.chk_deplymt_policy_id
4443     (p_deplymt_policy_id      => p_rec.deplymt_policy_id
4444     );
4445   --
4446   if g_debug then
4447      hr_utility.set_location(l_proc, 70);
4448   end if;
4449   --
4450   hr_pdt_bus.chk_retain_direct_reports
4451     (p_retain_direct_reports  => p_rec.retain_direct_reports
4452     ,p_from_person_id         => p_rec.from_person_id
4453     ,p_start_date             => p_rec.start_date
4454     ,p_to_business_group_id   => p_rec.to_business_group_id
4455     ,p_from_business_group_id => p_rec.from_business_group_id
4456     ,p_person_deployment_id   => p_rec.person_deployment_id
4457     ,p_object_version_number  => p_rec.object_version_number
4458     );
4459   --
4460   if g_debug then
4461      hr_utility.set_location(l_proc, 75);
4462   end if;
4463   --
4464   hr_pdt_bus.chk_organization_id
4465     (p_organization_id        => p_rec.organization_id
4466     ,p_to_business_group_id   => p_rec.to_business_group_id
4467     ,p_person_deployment_id   => p_rec.person_deployment_id
4468     ,p_object_version_number  => p_rec.object_version_number
4469     );
4470   --
4471   if g_debug then
4472      hr_utility.set_location(l_proc, 80);
4473   end if;
4474   --
4475   hr_pdt_bus.chk_location_id
4476     (p_location_id            => p_rec.location_id
4477     ,p_start_date             => p_rec.start_date
4478     ,p_to_business_group_id   => p_rec.to_business_group_id
4479     ,p_person_deployment_id   => p_rec.person_deployment_id
4480     ,p_object_version_number  => p_rec.object_version_number
4481      );
4482   --
4483   if g_debug then
4484      hr_utility.set_location(l_proc, 85);
4485   end if;
4486   --
4487   hr_pdt_bus.chk_job_id
4488     (p_job_id                 => p_rec.job_id
4489     ,p_start_date             => p_rec.start_date
4490     ,p_to_business_group_id   => p_rec.to_business_group_id
4491     ,p_person_deployment_id   => p_rec.person_deployment_id
4492     ,p_object_version_number  => p_rec.object_version_number
4493     );
4494   --
4495   if g_debug then
4496      hr_utility.set_location(l_proc,90 );
4497   end if;
4498   --
4499   hr_pdt_bus.chk_position_id
4500     (p_position_id            => p_rec.position_id
4501     ,p_start_date             => p_rec.start_date
4502     ,p_to_business_group_id   => p_rec.to_business_group_id
4503     ,p_person_deployment_id   => p_rec.person_deployment_id
4504     ,p_object_version_number  => p_rec.object_version_number
4505     );
4506   --
4507   if g_debug then
4508      hr_utility.set_location(l_proc, 95);
4509   end if;
4510   --
4511   hr_pdt_bus.chk_grade_id
4512     (p_grade_id               => p_rec.grade_id
4513     ,p_start_date             => p_rec.start_date
4514     ,p_to_business_group_id   => p_rec.to_business_group_id
4515     ,p_person_deployment_id   => p_rec.person_deployment_id
4516     ,p_object_version_number  => p_rec.object_version_number
4517     );
4518   --
4519   if g_debug then
4520      hr_utility.set_location(l_proc, 100);
4521   end if;
4522   --
4523   hr_pdt_bus.chk_position_id_job_id
4524     (p_position_id            => p_rec.position_id
4525     ,p_job_id                 => p_rec.job_id
4526     ,p_start_date             => p_rec.start_date
4527     ,p_person_deployment_id   => p_rec.person_deployment_id
4528     ,p_object_version_number  => p_rec.object_version_number
4529     );
4530   --
4531   if g_debug then
4532      hr_utility.set_location(l_proc, 105);
4533   end if;
4534   --
4535   hr_pdt_bus.chk_position_id_grade_id
4536     (p_position_id            => p_rec.position_id
4537     ,p_grade_id               => p_rec.grade_id
4538     ,p_start_date             => p_rec.start_date
4539     ,p_person_deployment_id   => p_rec.person_deployment_id
4540     ,p_object_version_number  => p_rec.object_version_number
4541     ,p_inv_pos_grade_warning  => l_inv_pos_grade_warning
4542     );
4543   --
4544   if g_debug then
4545      hr_utility.set_location(l_proc, 110);
4546   end if;
4547   --
4548   hr_pdt_bus.chk_job_id_grade_id
4549     (p_job_id                 => p_rec.job_id
4550     ,p_grade_id               => p_rec.grade_id
4551     ,p_start_date             => p_rec.start_date
4552     ,p_person_deployment_id   => p_rec.person_deployment_id
4553     ,p_object_version_number  => p_rec.object_version_number
4554     ,p_inv_job_grade_warning  => l_inv_job_grade_warning
4555     );
4556   --
4557   if g_debug then
4558      hr_utility.set_location(l_proc, 115);
4559   end if;
4560   --
4561   hr_pdt_bus.chk_position_id_org_id
4562     (p_position_id            => p_rec.position_id
4563     ,p_organization_id        => p_rec.organization_id
4564     ,p_start_date             => p_rec.start_date
4565     ,p_person_deployment_id   => p_rec.person_deployment_id
4566     ,p_object_version_number  => p_rec.object_version_number
4567     );
4568   --
4569   if g_debug then
4570      hr_utility.set_location(l_proc, 120);
4571   end if;
4572   --
4573   hr_pdt_bus.chk_payroll_id
4574     (p_payroll_id             => p_rec.payroll_id
4575     ,p_start_date             => p_rec.start_date
4576     ,p_to_business_group_id   => p_rec.to_business_group_id
4577     ,p_person_deployment_id   => p_rec.person_deployment_id
4578     ,p_object_version_number  => p_rec.object_version_number
4579     );
4580   --
4581   if g_debug then
4582      hr_utility.set_location(l_proc, 125);
4583   end if;
4584   --
4585   hr_pdt_bus.chk_assignment_status_type_id
4586     (p_assignment_status_type_id => p_rec.assignment_status_type_id
4587     ,p_to_business_group_id   => p_rec.to_business_group_id
4588     ,p_person_deployment_id   => p_rec.person_deployment_id
4589     ,p_object_version_number  => p_rec.object_version_number
4590     );
4591   --
4592   if g_debug then
4593      hr_utility.set_location(l_proc, 130);
4594   end if;
4595   --
4596   hr_pdt_bus.chk_supervisor_id
4597     (p_supervisor_id          => p_rec.supervisor_id
4598     ,p_start_date             => p_rec.start_date
4599     ,p_from_person_id         => p_rec.from_person_id
4600     ,p_to_person_id           => p_rec.to_person_id
4601     ,p_to_business_group_id   => p_rec.to_business_group_id
4602     ,p_person_deployment_id   => p_rec.person_deployment_id
4603     ,p_object_version_number  => p_rec.object_version_number
4604     );
4605   --
4606   if g_debug then
4607      hr_utility.set_location(l_proc, 140);
4608   end if;
4609   --
4610   hr_pdt_bus.chk_supervisor_assignment_id
4611     (p_supervisor_assignment_id => p_rec.supervisor_assignment_id
4612     ,p_supervisor_id          => p_rec.supervisor_id
4613     ,p_start_date             => p_rec.start_date
4614     ,p_person_deployment_id   => p_rec.person_deployment_id
4615     ,p_object_version_number  => p_rec.object_version_number
4616     );
4617   --
4618   if g_debug then
4619      hr_utility.set_location(l_proc, 145);
4620   end if;
4621   --
4622   hr_pdt_bus.chk_pay_basis_id
4623     (p_pay_basis_id           => p_rec.pay_basis_id
4624     ,p_to_business_group_id   => p_rec.to_business_group_id
4625     ,p_person_deployment_id   => p_rec.person_deployment_id
4626     ,p_object_version_number  => p_rec.object_version_number
4627     );
4628   --
4629   if g_debug then
4630      hr_utility.set_location(l_proc, 150);
4631   end if;
4632   --
4633   hr_pdt_bus.chk_people_group_id
4634     (p_people_group_id        => p_rec.people_group_id
4635     ,p_start_date             => p_rec.start_date
4636     ,p_to_business_group_id   => p_rec.to_business_group_id
4637     ,p_person_deployment_id   => p_rec.person_deployment_id
4638     ,p_object_version_number  => p_rec.object_version_number
4639     );
4640   --
4641   if g_debug then
4642      hr_utility.set_location(l_proc, 155);
4643   end if;
4644   --
4645   hr_pdt_bus.chk_soft_coding_keyflex_id
4646     (p_soft_coding_keyflex_id => p_rec.soft_coding_keyflex_id
4647     ,p_start_date             => p_rec.start_date
4648     ,p_to_business_group_id   => p_rec.to_business_group_id
4649     ,p_payroll_id             => p_rec.payroll_id
4650     ,p_person_deployment_id   => p_rec.person_deployment_id
4651     ,p_object_version_number  => p_rec.object_version_number
4652     );
4653   --
4654   if g_debug then
4655      hr_utility.set_location(l_proc, 160);
4656   end if;
4657   --
4658   hr_pdt_bus.chk_assignment_category
4659     (p_assignment_category    => p_rec.assignment_category
4660     ,p_start_date             => p_rec.start_date
4661     ,p_person_deployment_id   => p_rec.person_deployment_id
4662     ,p_object_version_number  => p_rec.object_version_number
4663     );
4664   --
4665   hr_pdt_bus.chk_ddf(p_rec);
4666   --
4667   hr_utility.set_location(' Leaving:'||l_proc, 10);
4668 End update_validate;
4669 --
4670 -- ----------------------------------------------------------------------------
4671 -- |---------------------------< delete_validate >----------------------------|
4672 -- ----------------------------------------------------------------------------
4673 Procedure delete_validate
4674   (p_rec                          in hr_pdt_shd.g_rec_type
4675   ) is
4676 --
4677   l_proc  varchar2(72) := g_package||'delete_validate';
4678 --
4679 Begin
4680   hr_utility.set_location('Entering:'||l_proc, 5);
4681   --
4682   -- Call all supporting business operations
4683   --
4684   hr_utility.set_location(' Leaving:'||l_proc, 10);
4685 End delete_validate;
4686 --
4687 end hr_pdt_bus;