DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ASG_BUS1

Source


1 Package Body per_asg_bus1 as
2 /* $Header: peasgrhi.pkb 120.19.12010000.3 2008/11/12 06:37:24 skura ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)    := '  per_asg_bus1.';  -- 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_assignment_id            number        default null;
16 --
17 --  ---------------------------------------------------------------------------
18 --  |----------------------<  set_security_group_id  >------------------------|
19 --  ---------------------------------------------------------------------------
20 --
21   procedure set_security_group_id
22    (
23     p_assignment_id               in per_all_assignments_f.assignment_id%TYPE
24    ,p_associated_column1                   in varchar2 default null
25    ) is
26   --
27   -- Declare cursor
28   --
29    cursor csr_sec_grp is
30     select pbg.security_group_id, pbg.legislation_code
31      from per_business_groups_perf  pbg
32       where  pbg.business_group_id =  (select distinct asg.business_group_id  from
33                                      per_all_assignments_f    asg
34                                     where asg.assignment_id  = p_assignment_id);
35 
36   --
37   -- Local variables
38   --
39   l_security_group_id number;
40   l_legislation_code  varchar2(150);
41   l_proc              varchar2(72) := g_package||'set_security_group_id';
42   --
43   begin
44  if g_debug then
45     hr_utility.set_location('Entering:'|| l_proc, 10);
46  end if;
47   --
48   -- Ensure that all the mandatory parameter are not null
49   --
50   hr_api.mandatory_arg_error(p_api_name       => l_proc,
51                              p_argument       => 'assignment_id',
52                              p_argument_value => p_assignment_id);
53   --
54   open csr_sec_grp;
55   fetch csr_sec_grp into l_security_group_id, l_legislation_code;
56   if csr_sec_grp%notfound then
57     close csr_sec_grp;
58     --
59     -- The primary key is invalid therefore we must error
60     --
61     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
62     hr_utility.raise_error;
63     /*hr_multi_message.add
64        (p_associated_column1
65         => nvl(p_associated_column1,'ASSIGNMENT_ID')
66        ); */
67   else
68     close csr_sec_grp;
69     --
70     -- Set the security_group_id in CLIENT_INFO
71     --
72     hr_api.set_security_group_id
73       (p_security_group_id => l_security_group_id
74       );
75   end if;
76   --
77   -- Set the sessions legislation context in HR_SESSION_DATA
78   --
79   hr_api.set_legislation_context(l_legislation_code);
80   --
81   --
82  if g_debug then
83   hr_utility.set_location(' Leaving:'|| l_proc, 20);
84  end if;
85   --
86 end set_security_group_id;
87 --
88 -- ----------------------------------------------------------------------------
89 -- |----------------------< check_non_updateable_args >-----------------------|
90 -- ----------------------------------------------------------------------------
91 -- {Start Of Comments}
92 --
93 -- Description:
94 --   This procedure is used to ensure that non updatetable attributes have
95 --   not been updated. If an attribute has been updated an error is generated.
96 --
97 -- Pre Conditions:
98 --   g_old_rec has been populated with details of the values currently in
99 --   the database.
100 --
101 -- In Arguments:
102 --   p_rec has been populated with the updated values the user would like the
103 --
104 -- Post Success:
105 --   Processing continues if all the non updateable attributes have not
106 --   changed.
107 --
108 -- Post Failure:
109 --   An application error is raised if any of the non updatable attributes
110 --   (business_group_id, person_id, assignment_sequence, assignment_type,
111 --   period_of_service_id, primary_flag, or assignment_id) have been altered.
112 --
113 -- Access Status:
114 --   Internal Table Handler Use Only.
115 --
116 Procedure check_non_updateable_args(p_rec in per_asg_shd.g_rec_type
117                                    ,p_effective_date in date) is
118 --
119   l_proc     varchar2(72) := g_package||'check_non_updateable_args';
120 --
121 Begin
122  if g_debug then
123   hr_utility.set_location('Entering:'||l_proc, 5);
124  end if;
125   --
126   -- Only proceed with validation if a row exists for
127   -- the current record in the HR Schema
128   --
129   if not per_asg_shd.api_updating
130                 (p_assignment_id          => p_rec.assignment_id
131                 ,p_object_version_number  => p_rec.object_version_number
132                 ,p_effective_date         => p_effective_date
133                 ) then
134     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
135     hr_utility.set_message_token('PROCEDURE', l_proc);
136     hr_utility.set_message_token('STEP', '5');
137   end if;
138   --
139  if g_debug then
140   hr_utility.set_location(l_proc, 6);
141  end if;
142   --
143   if nvl(p_rec.business_group_id, hr_api.g_number) <>
144      nvl(per_asg_shd.g_old_rec.business_group_id, hr_api.g_number) then
145      hr_api.argument_changed_error
146        (p_api_name => l_proc
147        ,p_argument => 'BUSINESS_GROUP_ID'
148        ,p_base_table => per_asg_shd.g_tab_nam
149      );
150   end if;
151  if g_debug then
152   hr_utility.set_location(l_proc, 7);
153  end if;
154   --
155   if p_rec.assignment_id <> per_asg_shd.g_old_rec.assignment_id then
156      hr_api.argument_changed_error
157        (p_api_name => l_proc
158        ,p_argument => 'ASSIGNMENT_ID'
159        ,p_base_table => per_asg_shd.g_tab_nam
160      );
161   end if;
162  if g_debug then
163   hr_utility.set_location(l_proc, 8);
164  end if;
165   --
166   if p_rec.person_id <> per_asg_shd.g_old_rec.person_id then
167      hr_api.argument_changed_error
168        (p_api_name => l_proc
169        ,p_argument => 'PERSON_ID'
170        ,p_base_table => per_asg_shd.g_tab_nam
171      );
172   end if;
173  if g_debug then
174   hr_utility.set_location(l_proc, 9);
175  end if;
176   --
177   if p_rec.assignment_sequence <> per_asg_shd.g_old_rec.assignment_sequence then
178      hr_api.argument_changed_error
179        (p_api_name => l_proc
180        ,p_argument => 'ASSIGNMENT_SEQUENCE'
181        ,p_base_table => per_asg_shd.g_tab_nam
182      );
183   end if;
184   --
185  if g_debug then
186   hr_utility.set_location(l_proc, 10);
187  end if;
188   --
189   -- Bug fix 3101091 starts. Commenting out the check that makes vendor_id
190   -- non updatable
191   /* if p_rec.vendor_id <> per_asg_shd.g_old_rec.vendor_id then
192     --
193     hr_api.argument_changed_error
194       (p_api_name => l_proc
195       ,p_argument => 'VENDOR_ID'
196       ,p_base_table => per_asg_shd.g_tab_nam);
197     --
198   end if;  */
199   -- End fix 3101091.
200   --
201  if g_debug then
202   hr_utility.set_location(' Leaving:'||l_proc, 999);
203  end if;
204   --
205 end check_non_updateable_args;
206 --
207 -- ----------------------------------------------------------------------------
208 -- |---------------------------< delete_validate >----------------------------|
209 -- ----------------------------------------------------------------------------
210 Procedure delete_validate
211     (p_rec                         in per_asg_shd.g_rec_type,
212      p_effective_date              in date,
213      p_datetrack_mode              in varchar2,
214      p_validation_start_date       in date,
215      p_validation_end_date         in date,
216      p_org_now_no_manager_warning  out nocopy boolean,
217      p_loc_change_tax_issues       OUT nocopy boolean,
218      p_delete_asg_budgets          OUT nocopy boolean,
219      p_element_salary_warning      OUT nocopy boolean,
220      p_element_entries_warning     OUT nocopy boolean,
221      p_spp_warning                 OUT nocopy boolean,
222      p_cost_warning                OUT nocopy boolean,
223      p_life_events_exists   	   OUT nocopy boolean,
224      p_cobra_coverage_elements     OUT nocopy boolean,
225      p_assgt_term_elements         OUT nocopy boolean,
226      ---
227      p_new_prim_ass_id             OUT nocopy number,
228      p_prim_change_flag            OUT nocopy varchar2,
229      p_new_end_date                OUT nocopy date,
230      p_new_primary_flag            OUT nocopy varchar2,
231      p_s_pay_id                    OUT nocopy number,
232      p_cancel_atd                  OUT nocopy date,
233      p_cancel_lspd                 OUT nocopy date,
234      p_reterm_atd                  OUT nocopy date,
235      p_reterm_lspd                 OUT nocopy date,
236      ---
237      p_appl_asg_new_end_date       OUT nocopy date  ) is
238   --
239   l_proc                   varchar2(72);
240   --
241   l_temp_flag                  boolean;
242   l_org_now_no_manager_warning boolean;
243   l_loc_change_tax_issues      boolean; --4888485 , all new declarations below
244   l_delete_asg_budgets         boolean;
245   l_element_salary_warning     boolean;
246   l_element_entries_warning    boolean;
247   l_spp_warning                boolean;
248   l_cost_warning               boolean;
249   l_life_events_exists         boolean;
250   l_cobra_coverage_elements    boolean;
251   l_assgt_term_elements        boolean;
252   --
253 Begin
254  if g_debug then
255   l_proc:= g_package||'delete_validate';
256   hr_utility.set_location('Entering:'||l_proc, 5);
257  end if;
258  --
259  -- 4888485 starts here
260  --
261  -- Bug 5012157 : Commented out BEN type assgt checks and moved the logic to API.
262 /* if per_asg_shd.g_old_rec.assignment_type = 'B' then
263     if g_debug then
264        hr_utility.set_location('Selected assignment is of type Benifits', 10);
265     end if;
266     --
267     fnd_message.set_name('PER', 'HR_449746_DEL_BEN_ASG');
268     fnd_message.raise_error;
269  end if;
270  -- */
271  if g_debug then
272     hr_utility.set_location('Before calling pre_delete checks ', 20);
273  end if;
274  --
275  -- Added IF Condition for 5012244.
276  if (p_datetrack_mode <> 'DELETE') THEN
277  hr_assignment_internal.pre_delete
278     (p_rec                        => p_rec,
279      p_effective_date             => p_effective_date,
280      p_datetrack_mode             => p_datetrack_mode,
281      p_validation_start_date      => p_validation_start_date,
282      p_validation_end_date        => p_validation_end_date,
283      p_org_now_no_manager_warning => p_org_now_no_manager_warning,
284      p_loc_change_tax_issues      => l_loc_change_tax_issues,
285      p_delete_asg_budgets         => l_delete_asg_budgets,
286      p_element_salary_warning     => l_element_salary_warning,
287      p_element_entries_warning    => l_element_entries_warning,
288      p_spp_warning                => l_spp_warning,
289      P_cost_warning               => l_cost_warning,
290      p_life_events_exists   	  => l_life_events_exists,
291      p_cobra_coverage_elements    => l_cobra_coverage_elements,
292      p_assgt_term_elements        => l_assgt_term_elements,
293      ---
294      p_new_prim_ass_id            => p_new_prim_ass_id,
295      p_prim_change_flag           => p_prim_change_flag,
296      p_new_end_date               => p_new_end_date,
297      p_new_primary_flag           => p_new_primary_flag,
298      p_s_pay_id                   => p_s_pay_id,
299      p_cancel_atd                 => p_cancel_atd,
300      p_cancel_lspd                => p_cancel_lspd,
301      p_reterm_atd                 => p_reterm_atd,
302      p_reterm_lspd                => p_reterm_lspd,
303      ---
304      p_appl_asg_new_end_date      => p_appl_asg_new_end_date );
305 
306      end if;
307 --
308 -- 4888485 Ends here
309 --
310   per_asg_bus2.chk_system_pers_type
311     (p_person_id              =>  per_asg_shd.g_old_rec.person_id
312     ,p_validation_start_date  =>  p_validation_start_date
313     ,p_validation_end_date    =>  p_validation_end_date
314     ,p_datetrack_mode         =>  p_datetrack_mode
315     ,p_effective_date         =>  p_effective_date
316     );
317   --
318  if g_debug then
319   hr_utility.set_location(l_proc, 6);
320  end if;
321   --
322   per_asg_bus2.chk_ref_int_del
323     (p_assignment_id          =>  p_rec.assignment_id
324     ,p_validation_start_date  =>  p_validation_start_date
325     ,p_validation_end_date    =>  p_validation_end_date
326     ,p_datetrack_mode         =>  p_datetrack_mode
327     );
328   --
329  if g_debug then
330   hr_utility.set_location(l_proc, 7);
331  end if;
332   --
333  if g_debug then
334   hr_utility.set_location(l_proc, 8);
335  end if;
336   --
337   per_asg_bus1.chk_future_primary
338     (p_assignment_id  =>  p_rec.assignment_id
339     ,p_primary_flag   =>  per_asg_shd.g_old_rec.primary_flag
340     ,p_datetrack_mode =>  p_datetrack_mode
341     ,p_effective_date =>  p_effective_date
342 
343     );
344   --
345  if g_debug then
346   hr_utility.set_location(l_proc, 9);
347  end if;
348   --
349   per_asg_bus2.chk_term_status
350     (p_assignment_id          =>  p_rec.assignment_id
351     ,p_datetrack_mode         =>  p_datetrack_mode
352     ,p_validation_start_date  =>  p_validation_start_date
353     );
354   --
355  if g_debug then
356   hr_utility.set_location(l_proc, 10);
357  end if;
358   --
359   per_asg_bus1.dt_delete_validate
360 
361     (p_assignment_id        => p_rec.assignment_id
362     ,p_datetrack_mode        => p_datetrack_mode
363     ,p_validation_start_date    => p_validation_start_date
364     ,p_validation_end_date    => p_validation_end_date
365     );
366  if g_debug then
367   hr_utility.set_location(l_proc, 20);
368  end if;
369   --
370   per_asg_bus2.chk_payroll_id
371     (p_assignment_id          =>  p_rec.assignment_id
372     ,p_business_group_id      =>  per_asg_shd.g_old_rec.business_group_id
373     ,p_person_id              =>  per_asg_shd.g_old_rec.person_id
374     ,p_payroll_id             =>  per_asg_shd.g_old_rec.payroll_id
375     ,p_assignment_type        =>  per_asg_shd.g_old_rec.assignment_type
376     ,p_validation_start_date  =>  p_validation_start_date
377     ,p_validation_end_date    =>  p_validation_end_date
378     ,p_effective_date         =>  p_effective_date
379     ,p_datetrack_mode         =>  p_datetrack_mode
380     ,p_payroll_id_updated     =>  l_temp_flag
381     ,p_object_version_number  =>  p_rec.object_version_number
382     );
383  if g_debug then
384   hr_utility.set_location(l_proc, 30);
385  end if;
386   --
387   per_asg_bus1.chk_del_organization_id
388     (p_assignment_id              => p_rec.assignment_id
389     ,p_effective_date             => p_effective_date
390     ,p_manager_flag               => p_rec.manager_flag
391 
392     ,p_organization_id            => p_rec.organization_id
393     ,p_org_now_no_manager_warning => l_org_now_no_manager_warning
394     );
395   --
396  if g_debug then
397   hr_utility.set_location(l_proc, 40);
398  end if;
399   --
400   per_pqh_shr.per_asg_bus('DELETE_VALIDATE',
401                 p_rec,
402                             p_effective_date,
403                             p_validation_start_date,
404                             p_validation_end_date,
405                             p_datetrack_mode);
406    p_org_now_no_manager_warning := l_org_now_no_manager_warning;
407  if g_debug then
408   hr_utility.set_location(' Leaving:'||l_proc, 11);
409  end if;
410 End delete_validate;
411 --
412 -- ----------------------------------------------------------------------------
413 -- |--------------------------< dt_delete_validate >--------------------------|
414 -- ----------------------------------------------------------------------------
415 -- {Start Of Comments}
416 --
417 -- Description:
418 --   This procedure is used for referential integrity of datetracked
419 --   child entities when either a datetrack DELETE or ZAP is in operation
420 --   and where there is no cascading of delete defined for this entity.
421 --   For the datetrack mode of DELETE or ZAP we must ensure that no
422 --   datetracked child rows exist between the validation start and end
423 --   dates.
424 --
425 -- Pre Conditions:
426 --   This procedure is called from the delete_validate.
427 --
428 -- In Arguments:
429 --
430 -- Post Success:
431 --   Processing continues.
432 --
433 -- Post Failure:
434 --   If a row exists by determining the returning Boolean value from the
435 --   generic dt_api.rows_exist function then we must supply an error via
436 --   the use of the local exception handler l_rows_exist.
437 --
438 -- Developer Implementation Notes:
439 --   This procedure should not need maintenance unless the HR Schema model
440 --   changes.
441 --
442 -- Access Status:
443 --   Internal Table Handler Use Only.
444 --
445 -- {End Of Comments}
446 -- ----------------------------------------------------------------------------
447 Procedure dt_delete_validate
448             (p_assignment_id        in number,
449              p_datetrack_mode        in varchar2,
450          p_validation_start_date    in date,
451          p_validation_end_date    in date) Is
452 --
453   l_proc    varchar2(72)     := g_package||'dt_delete_validate';
454   l_rows_exist    Exception;
455   l_table_name    all_tables.table_name%TYPE;
456 --
457 Begin
458  if g_debug then
459   hr_utility.set_location('Entering:'||l_proc, 5);
460  end if;
461   --
462   -- Ensure that the p_datetrack_mode argument is not null
463   --
464   hr_api.mandatory_arg_error
465     (p_api_name       => l_proc,
466      p_argument       => 'datetrack_mode',
467      p_argument_value => p_datetrack_mode);
468   --
469   -- Only perform the validation if the datetrack mode is either
470   -- DELETE or ZAP
471   --
472   If (p_datetrack_mode = 'DELETE' or
473       p_datetrack_mode = 'ZAP') then
474     --
475     --
476     -- Ensure the arguments are not null
477     --
478     hr_api.mandatory_arg_error
479       (p_api_name       => l_proc,
480        p_argument       => 'validation_start_date',
481        p_argument_value => p_validation_start_date);
482     --
483     hr_api.mandatory_arg_error
484       (p_api_name       => l_proc,
485        p_argument       => 'validation_end_date',
486        p_argument_value => p_validation_end_date);
487     --
488     hr_api.mandatory_arg_error
489       (p_api_name       => l_proc,
490        p_argument       => 'assignment_id',
491        p_argument_value => p_assignment_id);
492     --
493     If (dt_api.rows_exist
494           (p_base_table_name => 'pay_cost_allocations_f',
495            p_base_key_column => 'assignment_id',
496            p_base_key_value  => p_assignment_id,
497            p_from_date       => p_validation_start_date,
498            p_to_date         => p_validation_end_date)) Then
499       l_table_name := 'cost allocations';
500       Raise l_rows_exist;
501     End If;
502     If (dt_api.rows_exist
503           (p_base_table_name => 'pay_assignment_link_usages_f',
504            p_base_key_column => 'assignment_id',
505            p_base_key_value  => p_assignment_id,
506            p_from_date       => p_validation_start_date,
507            p_to_date         => p_validation_end_date)) Then
508       l_table_name := 'assignment link usages';
509       Raise l_rows_exist;
510     End If;
511     --
512     If (dt_api.rows_exist
513           (p_base_table_name => 'pay_personal_payment_methods_f',
514            p_base_key_column => 'assignment_id',
515            p_base_key_value  => p_assignment_id,
516            p_from_date       => p_validation_start_date,
517            p_to_date         => p_validation_end_date)) Then
518       l_table_name := 'personal payment methods';
519       Raise l_rows_exist;
520     End If;
521     --
522     If (dt_api.rows_exist
523           (p_base_table_name => 'per_spinal_point_placements_f',
524            p_base_key_column => 'assignment_id',
525            p_base_key_value  => p_assignment_id,
526            p_from_date       => p_validation_start_date,
527            p_to_date         => p_validation_end_date)) Then
528       l_table_name := 'spinal point placements';
529       Raise l_rows_exist;
530     End If;
531     --
532     If (dt_api.rows_exist
533           (p_base_table_name => 'pay_element_entries_f',
534            p_base_key_column => 'assignment_id',
535            p_base_key_value  => p_assignment_id,
536            p_from_date       => p_validation_start_date,
537            p_to_date         => p_validation_end_date)) Then
538       l_table_name := 'element entries';
539       Raise l_rows_exist;
540     End If;
541     --
542     If (dt_api.rows_exist
543           (p_base_table_name => 'pay_us_emp_fed_tax_rules_f',
544            p_base_key_column => 'assignment_id',
545            p_base_key_value  => p_assignment_id,
546            p_from_date       => p_validation_start_date,
547            p_to_date         => p_validation_end_date)) Then
548       l_table_name := 'us emp fed tax rules';
549       Raise l_rows_exist;
550     End If;
551     --
552     If (dt_api.rows_exist
553           (p_base_table_name => 'pay_us_emp_county_tax_rules_f',
554            p_base_key_column => 'assignment_id',
555            p_base_key_value  => p_assignment_id,
556            p_from_date       => p_validation_start_date,
557            p_to_date         => p_validation_end_date)) Then
558       l_table_name := 'us emp county tax rules';
559       Raise l_rows_exist;
560     End If;
561     --
562     If (dt_api.rows_exist
563           (p_base_table_name => 'pay_us_emp_state_tax_rules_f',
564            p_base_key_column => 'assignment_id',
565            p_base_key_value  => p_assignment_id,
566            p_from_date       => p_validation_start_date,
567            p_to_date         => p_validation_end_date)) Then
568       l_table_name := 'us emp state tax rules';
569       Raise l_rows_exist;
570     End If;
571     --
572     If (dt_api.rows_exist
573           (p_base_table_name => 'pay_us_emp_city_tax_rules_f',
574            p_base_key_column => 'assignment_id',
575            p_base_key_value  => p_assignment_id,
576            p_from_date       => p_validation_start_date,
577            p_to_date         => p_validation_end_date)) Then
578       l_table_name := 'us emp city tax rules';
579       Raise l_rows_exist;
580     End If;
581     --
582   End If;
583   --
584  if g_debug then
585   hr_utility.set_location(' Leaving:'||l_proc, 10);
586  end if;
587 Exception
588   When Others Then
589     --
590     -- An unhandled or unexpected error has occurred which
591     -- we must report
592     --
593     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
594     hr_utility.set_message_token('PROCEDURE', l_proc);
595     hr_utility.set_message_token('STEP','15');
596     hr_utility.raise_error;
597 End dt_delete_validate;
598 --
599 -- ----------------------------------------------------------------------------
600 -- |--------------------------< dt_update_validate >--------------------------|
601 -- ----------------------------------------------------------------------------
602 -- {Start Of Comments}
603 --
604 -- Description:
605 --   This procedure is used for referential integrity of datetracked
606 --   parent entities when a datetrack update operation is taking place
607 --   and where there is no cascading of update defined for this entity.
608 --
609 -- Pre Conditions:
610 --   This procedure is called from the update_validate.
611 --
612 -- In Arguments:
613 --
614 -- Post Success:
615 --   Processing continues.
616 --
617 -- Post Failure:
618 --
619 -- Developer Implementation Notes:
620 --   This procedure should not need maintenance unless the HR Schema model
621 --   changes.
622 --
623 -- Access Status:
624 --   Internal Table Handler Use Only.
625 --
626 -- {End Of Comments}
627 -- ----------------------------------------------------------------------------
628 Procedure dt_update_validate
629             (p_payroll_id                    in number default hr_api.g_number,
630              p_person_id                     in number default hr_api.g_number,
631          p_datetrack_mode             in varchar2,
632              p_validation_start_date         in date,
633          p_validation_end_date         in date) Is
634 --
635   l_proc        varchar2(72) := g_package||'dt_update_validate';
636   l_integrity_error Exception;
637   l_table_name        all_tables.table_name%TYPE;
638 --
639 Begin
640  if g_debug then
641   hr_utility.set_location('Entering:'||l_proc, 5);
642  end if;
643   --
644   -- Ensure that the p_datetrack_mode argument is not null
645   --
646   hr_api.mandatory_arg_error
647     (p_api_name       => l_proc,
648      p_argument       => 'datetrack_mode',
649      p_argument_value => p_datetrack_mode);
650   --
651   -- Mode will be valid, as this is checked at the start of the upd.
652   --
653   --
654   --
655   -- Ensure the arguments are not null
656   --
657   hr_api.mandatory_arg_error
658     (p_api_name       => l_proc,
659      p_argument       => 'validation_start_date',
660      p_argument_value => p_validation_start_date);
661   --
662   hr_api.mandatory_arg_error
663     (p_api_name       => l_proc,
664      p_argument       => 'validation_end_date',
665      p_argument_value => p_validation_end_date);
666   --
667   -- Start of fix 2535030
668   /*
669   If ((nvl(p_payroll_id, hr_api.g_number) <> hr_api.g_number) and
670     NOT (dt_api.check_min_max_dates
671           (p_base_table_name => 'pay_all_payrolls_f',   -- bug fix 2679167
672            p_base_key_column => 'payroll_id',
673            p_base_key_value  => p_payroll_id,
674            p_from_date       => p_validation_start_date,
675            p_to_date         => p_validation_end_date)))  Then
676     l_table_name := 'payrolls';
677     Raise l_integrity_error;
678   End If;
679   */
680   -- End of fix 2535030
681 
682   If ((nvl(p_person_id, hr_api.g_number) <> hr_api.g_number) and
683     NOT (dt_api.check_min_max_dates
684           (p_base_table_name => 'per_all_people_f',
685            p_base_key_column => 'person_id',
686            p_base_key_value  => p_person_id,
687            p_from_date       => p_validation_start_date,
688            p_to_date         => p_validation_end_date)))  Then
689     l_table_name := 'people';
690     Raise l_integrity_error;
691   End If;
692   --
693  if g_debug then
694 hr_utility.set_location(' Leaving:'||l_proc, 10);
695  end if;
696 Exception
697   When Others Then
698     --
699     -- An unhandled or unexpected error has occurred which
700     -- we must report
701     --
702     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
703     hr_utility.set_message_token('PROCEDURE', l_proc);
704     hr_utility.set_message_token('STEP','15');
705     hr_utility.raise_error;
706 End dt_update_validate;
707 -- -----------------------------------------------------------------------
708 -- |------------------------------< chk_df >-----------------------------|
709 -- -----------------------------------------------------------------------
710 --
711 -- Description:
712 --   Validates the all Descriptive Flexfield values.
713 --
714 -- Pre-conditions:
715 --   All other columns have been validated. Must be called as the
716 --   last step from insert_validate and update_validate.
717 --
718 -- In Arguments:
719 --   p_rec
720 --
721 -- Post Success:
722 --   If the Descriptive Flexfield structure column and data values are
723 --   all valid this procedure will end normally and processing will
724 --   continue.
725 --
726 -- Post Failure:
727 --   If the Descriptive Flexfield structure column value or any of
728 --   the data values are invalid then an application error is raised as
729 --   a PL/SQL exception.
730 --
731 -- Access Status:
732 --   Internal Row Handler Use Only.
733 --
734 -- ---------------------------------------------------------------------------
735 procedure chk_df
736   (p_rec              in per_asg_shd.g_rec_type
737   ,p_validate_df_flex in boolean default true) is
738 --
739   l_proc     varchar2(72);
740 --
741 begin
742   --
743  if g_debug then
744   l_proc := g_package||'chk_df';
745     hr_utility.set_location('Entering:'||l_proc, 10);
746  end if;
747     --
748     -- if inserting and not required to validate flex data
749     -- then ensure all flex data passed is null
750     --
751       If ((p_rec.assignment_id is null) and
752           (not p_validate_df_flex)) then
753            --
754            --
755              If (not ( (p_rec.ass_attribute_category is null) and
756                        (p_rec.ass_attribute1         is null) and
757                        (p_rec.ass_attribute2         is null) and
758                        (p_rec.ass_attribute3         is null) and
759                        (p_rec.ass_attribute4         is null) and
760                        (p_rec.ass_attribute5         is null) and
761                        (p_rec.ass_attribute6         is null) and
762                        (p_rec.ass_attribute7         is null) and
763                        (p_rec.ass_attribute8         is null) and
764                        (p_rec.ass_attribute9         is null) and
765                        (p_rec.ass_attribute10        is null) and
766                        (p_rec.ass_attribute11        is null) and
767                        (p_rec.ass_attribute12        is null) and
768                        (p_rec.ass_attribute13        is null) and
769                        (p_rec.ass_attribute14        is null) and
770                        (p_rec.ass_attribute15        is null) and
771                        (p_rec.ass_attribute16        is null) and
772                        (p_rec.ass_attribute17        is null) and
773                        (p_rec.ass_attribute18        is null) and
774                        (p_rec.ass_attribute19        is null) and
775                        (p_rec.ass_attribute20        is null) and
776                        (p_rec.ass_attribute21        is null) and
777                        (p_rec.ass_attribute22        is null) and
778                        (p_rec.ass_attribute23        is null) and
779                        (p_rec.ass_attribute24        is null) and
780                        (p_rec.ass_attribute25        is null) and
781                        (p_rec.ass_attribute26        is null) and
782                        (p_rec.ass_attribute27        is null) and
783                        (p_rec.ass_attribute28        is null) and
784                        (p_rec.ass_attribute29        is null) and
785                        (p_rec.ass_attribute30        is null) ) )
786                  then
787                    hr_utility.set_message(800,'HR_6153_ALL_PROCEDURE_FAIL');
788                    hr_utility.set_message_token('PROCEDURE','chk_df');
789                    hr_utility.set_message_token('STEP',1);
790                    hr_utility.raise_error;
791              End if;
792       End if;
793       --
794       --
795       -- if   (    updating and flex data has changed
796       --        OR updating and all flex segments are NULL)
797       --   OR ( inserting and required to validate flexdata)
798       -- then validate flex data.
799       --
800       --
801       If (  (p_rec.assignment_id is not null)
802              and
803          (  (nvl(per_asg_shd.g_old_rec.ass_attribute_category, hr_api.g_varchar2) <>
804              nvl(p_rec.ass_attribute_category, hr_api.g_varchar2) or
805              nvl(per_asg_shd.g_old_rec.ass_attribute1, hr_api.g_varchar2)  <>
806              nvl(p_rec.ass_attribute1, hr_api.g_varchar2) or
807              nvl(per_asg_shd.g_old_rec.ass_attribute2, hr_api.g_varchar2)  <>
808              nvl(p_rec.ass_attribute2, hr_api.g_varchar2) or
809              nvl(per_asg_shd.g_old_rec.ass_attribute3, hr_api.g_varchar2)  <>
810              nvl(p_rec.ass_attribute3, hr_api.g_varchar2) or
811              nvl(per_asg_shd.g_old_rec.ass_attribute4, hr_api.g_varchar2)  <>
812              nvl(p_rec.ass_attribute4, hr_api.g_varchar2) or
813              nvl(per_asg_shd.g_old_rec.ass_attribute5, hr_api.g_varchar2)  <>
814              nvl(p_rec.ass_attribute5, hr_api.g_varchar2) or
815              nvl(per_asg_shd.g_old_rec.ass_attribute6, hr_api.g_varchar2)  <>
816              nvl(p_rec.ass_attribute6, hr_api.g_varchar2) or
817              nvl(per_asg_shd.g_old_rec.ass_attribute7, hr_api.g_varchar2)  <>
818              nvl(p_rec.ass_attribute7, hr_api.g_varchar2) or
819              nvl(per_asg_shd.g_old_rec.ass_attribute8, hr_api.g_varchar2)  <>
820              nvl(p_rec.ass_attribute8, hr_api.g_varchar2) or
821              nvl(per_asg_shd.g_old_rec.ass_attribute9, hr_api.g_varchar2)  <>
822              nvl(p_rec.ass_attribute9, hr_api.g_varchar2) or
823              nvl(per_asg_shd.g_old_rec.ass_attribute10, hr_api.g_varchar2) <>
824              nvl(p_rec.ass_attribute10, hr_api.g_varchar2) or
825              nvl(per_asg_shd.g_old_rec.ass_attribute11, hr_api.g_varchar2) <>
826              nvl(p_rec.ass_attribute11, hr_api.g_varchar2) or
827              nvl(per_asg_shd.g_old_rec.ass_attribute12, hr_api.g_varchar2) <>
828              nvl(p_rec.ass_attribute12, hr_api.g_varchar2) or
829              nvl(per_asg_shd.g_old_rec.ass_attribute13, hr_api.g_varchar2) <>
830              nvl(p_rec.ass_attribute13, hr_api.g_varchar2) or
831              nvl(per_asg_shd.g_old_rec.ass_attribute14, hr_api.g_varchar2) <>
832              nvl(p_rec.ass_attribute14, hr_api.g_varchar2) or
833              nvl(per_asg_shd.g_old_rec.ass_attribute15, hr_api.g_varchar2) <>
834              nvl(p_rec.ass_attribute15, hr_api.g_varchar2) or
835              nvl(per_asg_shd.g_old_rec.ass_attribute16, hr_api.g_varchar2) <>
836              nvl(p_rec.ass_attribute16, hr_api.g_varchar2) or
837              nvl(per_asg_shd.g_old_rec.ass_attribute17, hr_api.g_varchar2) <>
838              nvl(p_rec.ass_attribute17, hr_api.g_varchar2) or
839              nvl(per_asg_shd.g_old_rec.ass_attribute18, hr_api.g_varchar2) <>
840              nvl(p_rec.ass_attribute18, hr_api.g_varchar2) or
841              nvl(per_asg_shd.g_old_rec.ass_attribute19, hr_api.g_varchar2) <>
842              nvl(p_rec.ass_attribute19, hr_api.g_varchar2) or
843              nvl(per_asg_shd.g_old_rec.ass_attribute20, hr_api.g_varchar2) <>
844              nvl(p_rec.ass_attribute20, hr_api.g_varchar2) or
845              nvl(per_asg_shd.g_old_rec.ass_attribute21, hr_api.g_varchar2) <>
846              nvl(p_rec.ass_attribute21, hr_api.g_varchar2) or
847              nvl(per_asg_shd.g_old_rec.ass_attribute22, hr_api.g_varchar2) <>
848              nvl(p_rec.ass_attribute22, hr_api.g_varchar2) or
849              nvl(per_asg_shd.g_old_rec.ass_attribute23, hr_api.g_varchar2) <>
850              nvl(p_rec.ass_attribute23, hr_api.g_varchar2) or
851              nvl(per_asg_shd.g_old_rec.ass_attribute24, hr_api.g_varchar2) <>
852              nvl(p_rec.ass_attribute24, hr_api.g_varchar2) or
853              nvl(per_asg_shd.g_old_rec.ass_attribute25, hr_api.g_varchar2) <>
854              nvl(p_rec.ass_attribute25, hr_api.g_varchar2) or
855              nvl(per_asg_shd.g_old_rec.ass_attribute26, hr_api.g_varchar2) <>
856              nvl(p_rec.ass_attribute26, hr_api.g_varchar2) or
857              nvl(per_asg_shd.g_old_rec.ass_attribute27, hr_api.g_varchar2) <>
858              nvl(p_rec.ass_attribute27, hr_api.g_varchar2) or
859              nvl(per_asg_shd.g_old_rec.ass_attribute28, hr_api.g_varchar2) <>
860              nvl(p_rec.ass_attribute28, hr_api.g_varchar2) or
861              nvl(per_asg_shd.g_old_rec.ass_attribute29, hr_api.g_varchar2) <>
862              nvl(p_rec.ass_attribute29, hr_api.g_varchar2) or
863              nvl(per_asg_shd.g_old_rec.ass_attribute30, hr_api.g_varchar2) <>
864              nvl(p_rec.ass_attribute30, hr_api.g_varchar2)
865             )
866           or
867             (
868               (p_rec.ass_attribute_category is null) and
869               (p_rec.ass_attribute1         is null) and
870               (p_rec.ass_attribute2         is null) and
871               (p_rec.ass_attribute3         is null) and
872               (p_rec.ass_attribute4         is null) and
873               (p_rec.ass_attribute5         is null) and
874               (p_rec.ass_attribute6         is null) and
875               (p_rec.ass_attribute7         is null) and
876               (p_rec.ass_attribute8         is null) and
877               (p_rec.ass_attribute9         is null) and
878               (p_rec.ass_attribute10        is null) and
879               (p_rec.ass_attribute11        is null) and
880               (p_rec.ass_attribute12        is null) and
881               (p_rec.ass_attribute13        is null) and
882               (p_rec.ass_attribute14        is null) and
883               (p_rec.ass_attribute15        is null) and
884               (p_rec.ass_attribute16        is null) and
885               (p_rec.ass_attribute17        is null) and
886               (p_rec.ass_attribute18        is null) and
887               (p_rec.ass_attribute19        is null) and
888               (p_rec.ass_attribute20        is null) and
889               (p_rec.ass_attribute21        is null) and
890               (p_rec.ass_attribute22        is null) and
891               (p_rec.ass_attribute23        is null) and
892               (p_rec.ass_attribute24        is null) and
893               (p_rec.ass_attribute25        is null) and
894               (p_rec.ass_attribute26        is null) and
895               (p_rec.ass_attribute27        is null) and
896               (p_rec.ass_attribute28        is null) and
897               (p_rec.ass_attribute29        is null) and
898               (p_rec.ass_attribute30        is null)
899             )
900           ))
901         --  or inserting and required to validate flex
902         or
903           ((p_rec.assignment_id is null) and
904            (p_validate_df_flex))
905            then
906 --
907 --           validate flex segment values
908 --
909     hr_dflex_utility.ins_or_upd_descflex_attribs(
910          p_appl_short_name      => 'PER'
911         ,p_descflex_name        => 'PER_ASSIGNMENTS'
912         ,p_attribute_category   => p_rec.ass_attribute_category
913         ,p_attribute1_name      => 'ASS_ATTRIBUTE1'
914         ,p_attribute1_value     => p_rec.ass_attribute1
915         ,p_attribute2_name      => 'ASS_ATTRIBUTE2'
916         ,p_attribute2_value     => p_rec.ass_attribute2
917         ,p_attribute3_name      => 'ASS_ATTRIBUTE3'
918         ,p_attribute3_value     => p_rec.ass_attribute3
919         ,p_attribute4_name      => 'ASS_ATTRIBUTE4'
920         ,p_attribute4_value     => p_rec.ass_attribute4
921         ,p_attribute5_name      => 'ASS_ATTRIBUTE5'
922         ,p_attribute5_value     => p_rec.ass_attribute5
923         ,p_attribute6_name      => 'ASS_ATTRIBUTE6'
924         ,p_attribute6_value     => p_rec.ass_attribute6
925         ,p_attribute7_name      => 'ASS_ATTRIBUTE7'
926         ,p_attribute7_value     => p_rec.ass_attribute7
927         ,p_attribute8_name      => 'ASS_ATTRIBUTE8'
928         ,p_attribute8_value     => p_rec.ass_attribute8
929         ,p_attribute9_name      => 'ASS_ATTRIBUTE9'
930         ,p_attribute9_value     => p_rec.ass_attribute9
931         ,p_attribute10_name     => 'ASS_ATTRIBUTE10'
932         ,p_attribute10_value    => p_rec.ass_attribute10
933         ,p_attribute11_name     => 'ASS_ATTRIBUTE11'
934         ,p_attribute11_value    => p_rec.ass_attribute11
935         ,p_attribute12_name     => 'ASS_ATTRIBUTE12'
936         ,p_attribute12_value    => p_rec.ass_attribute12
937         ,p_attribute13_name     => 'ASS_ATTRIBUTE13'
938         ,p_attribute13_value    => p_rec.ass_attribute13
939         ,p_attribute14_name     => 'ASS_ATTRIBUTE14'
940         ,p_attribute14_value    => p_rec.ass_attribute14
941         ,p_attribute15_name     => 'ASS_ATTRIBUTE15'
942         ,p_attribute15_value    => p_rec.ass_attribute15
943         ,p_attribute16_name     => 'ASS_ATTRIBUTE16'
944         ,p_attribute16_value    => p_rec.ass_attribute16
945         ,p_attribute17_name     => 'ASS_ATTRIBUTE17'
946         ,p_attribute17_value    => p_rec.ass_attribute17
947         ,p_attribute18_name     => 'ASS_ATTRIBUTE18'
948         ,p_attribute18_value    => p_rec.ass_attribute18
949         ,p_attribute19_name     => 'ASS_ATTRIBUTE19'
950         ,p_attribute19_value    => p_rec.ass_attribute19
951         ,p_attribute20_name     => 'ASS_ATTRIBUTE20'
952         ,p_attribute20_value    => p_rec.ass_attribute20
953         ,p_attribute21_name     => 'ASS_ATTRIBUTE21'
954         ,p_attribute21_value    => p_rec.ass_attribute21
955         ,p_attribute22_name     => 'ASS_ATTRIBUTE22'
956         ,p_attribute22_value    => p_rec.ass_attribute22
957         ,p_attribute23_name     => 'ASS_ATTRIBUTE23'
958         ,p_attribute23_value    => p_rec.ass_attribute23
959         ,p_attribute24_name     => 'ASS_ATTRIBUTE24'
960         ,p_attribute24_value    => p_rec.ass_attribute24
961         ,p_attribute25_name     => 'ASS_ATTRIBUTE25'
962         ,p_attribute25_value    => p_rec.ass_attribute25
963         ,p_attribute26_name     => 'ASS_ATTRIBUTE26'
964         ,p_attribute26_value    => p_rec.ass_attribute26
965         ,p_attribute27_name     => 'ASS_ATTRIBUTE27'
966         ,p_attribute27_value    => p_rec.ass_attribute27
967         ,p_attribute28_name     => 'ASS_ATTRIBUTE28'
968         ,p_attribute28_value    => p_rec.ass_attribute28
969         ,p_attribute29_name     => 'ASS_ATTRIBUTE29'
970         ,p_attribute29_value    => p_rec.ass_attribute29
971         ,p_attribute30_name     => 'ASS_ATTRIBUTE30'
972         ,p_attribute30_value    => p_rec.ass_attribute30
973         );
974   End if;
975   --
976  if g_debug then
977   hr_utility.set_location('  Leaving:'||l_proc, 20);
978  end if;
979 --
980 end chk_df;
981 --
982 -- ----------------------------------------------------------------------------
983 -- |---------------------------< insert_validate >----------------------------|
984 -- ----------------------------------------------------------------------------
985 Procedure insert_validate
986     (p_rec                in out nocopy  per_asg_shd.g_rec_type,
987      p_effective_date           in  date,
988      p_datetrack_mode           in  varchar2,
989      p_validation_start_date       in  date,
990      p_validation_end_date           in  date,
991          p_validate_df_flex            in  boolean,
992          p_other_manager_warning       out nocopy boolean,
993          p_hourly_salaried_warning     out nocopy boolean,
994          p_inv_pos_grade_warning       out nocopy boolean
995         ) is
996   l_proc                    varchar2(72);
997   l_temp_flag                   boolean;
998   l_other_manager_warning       boolean;
999   l_hourly_salaried_warning     boolean;
1000   L_inv_pos_grade_warning       boolean := false;
1001   L_inv_job_grade_warning       boolean := false;
1002   l_source_type per_all_assignments_f.source_type%TYPE default NULL;  --- Fix For Bug #7481310
1003 --
1004 Begin
1005  if g_debug then
1006   l_proc := g_package||'insert_validate';
1007   hr_utility.set_location('Entering: '||l_proc, 10);
1008  end if;
1009   --
1010   -- Validate Important Attributes
1011   --
1012   --
1013   -- Call all supporting business operations. Mapping to the
1014   -- appropriate Business Rules in perasg.bru is provided (where
1015   -- relevant)
1016   --
1017   l_other_manager_warning := FALSE;
1018   l_hourly_salaried_warning := FALSE;
1019   --
1020   hr_api.validate_bus_grp_id
1021     (p_business_group_id => p_rec.business_group_id
1022     ,p_associated_column1 => per_asg_shd.g_tab_nam ||
1023                              '.BUSINESS_GROUP_ID'
1024     );
1025   --
1026   hr_multi_message.end_validation_set;
1027   --
1028  if g_debug then
1029   hr_utility.set_location(l_proc, 15);
1030  end if;
1031   --
1032   --  per_asg_bus2.chk_title (p_title  =>  p_rec.title);
1033   --
1034   per_asg_bus2.chk_dup_apl_vacancy
1035    (p_person_id              => p_rec.person_id
1036    ,p_business_group_id      => p_rec.business_group_id
1037    ,p_vacancy_id             => p_rec.vacancy_id
1038    ,p_effective_date         => p_effective_date
1039    ,p_assignment_type        => p_rec.assignment_type
1040    );
1041  if g_debug then
1042   hr_utility.set_location(l_proc, 22);
1043  end if;
1044   --
1045   per_asg_bus2.chk_time_finish_formatted --#2734822
1046     (p_time_normal_finish => p_rec.time_normal_finish
1047     );
1048  if g_debug then
1049   hr_utility.set_location(l_proc, 25);
1050  end if;
1051   --
1052   per_asg_bus2.chk_time_start_formatted --#2734822
1053     (p_time_normal_start => p_rec.time_normal_start
1054     );
1055  if g_debug then
1056   hr_utility.set_location(l_proc, 27);
1057  end if;
1058   --
1059   per_asg_bus1.chk_assignment_type
1060     (p_assignment_id         =>  p_rec.assignment_id
1061     ,p_assignment_type       =>  p_rec.assignment_type
1062     ,p_person_id             =>  p_rec.person_id
1063     ,p_effective_date        =>  p_effective_date
1064     ,p_object_version_number =>  p_rec.object_version_number
1065     ,p_validation_start_date   =>  p_validation_start_date
1066     );
1067  if g_debug then
1068   hr_utility.set_location(l_proc, 30);
1069  end if;
1070   --
1071   hr_multi_message.end_validation_set;
1072   --
1073   per_asg_bus2.chk_probation_unit
1074     (p_assignment_id         =>  p_rec.assignment_id
1075     ,p_probation_unit        =>  p_rec.probation_unit
1076     ,p_effective_date        =>  p_effective_date
1077     ,p_validation_start_date =>  p_validation_start_date
1078     ,p_validation_end_date   =>  p_validation_end_date
1079     ,p_object_version_number =>  p_rec.object_version_number
1080     );
1081  if g_debug then
1082   hr_utility.set_location(l_proc, 40);
1083  end if;
1084   --
1085   per_asg_bus2.chk_probation_period
1086     (p_assignment_id         =>  p_rec.assignment_id
1087     ,p_probation_period      =>  p_rec.probation_period
1088     ,p_effective_date        =>  p_effective_date
1089     ,p_object_version_number =>  p_rec.object_version_number
1090     );
1091  if g_debug then
1092   hr_utility.set_location(l_proc, 50);
1093  end if;
1094   --
1095   per_asg_bus2.chk_prob_unit_prob_period
1096     (p_assignment_id                 =>  p_rec.assignment_id
1097     ,p_probation_unit                =>  p_rec.probation_unit
1098     ,p_probation_period              =>  p_rec.probation_period
1099     ,p_effective_date                =>  p_effective_date
1100     ,p_object_version_number         =>  p_rec.object_version_number
1101     );
1102  if g_debug then
1103   hr_utility.set_location(l_proc, 60);
1104  end if;
1105  --- Fix For Bug # 7481310 Starts ---
1106 if p_rec.assignment_type = 'O' then
1107  hr_utility.set_location(l_proc || 'This is an Offer Assignment', 60);
1108 
1109 select source_type into l_source_type from per_all_assignments_f
1110 where person_id = p_rec.person_id and BUSINESS_GROUP_ID = p_rec.business_group_id
1111 and ASSIGNMENT_TYPE = 'A' and VACANCY_ID = p_rec.vacancy_id and
1112 p_effective_date between EFFECTIVE_START_DATE and EFFECTIVE_END_DATE;
1113 
1114 end if;
1115 --- Fix For Bug # 7481310 Ends ---
1116 
1117 --- Fix For Bug # 7481310 Starts ---
1118 if NOT (NVL(l_source_type,'IREC') = NVL(p_rec.source_type,'IREC') AND p_rec.assignment_type = 'O') then
1119   --
1120   per_asg_bus2.chk_source_type
1121     (p_assignment_id           =>  p_rec.assignment_id
1122     ,p_source_type             =>  p_rec.source_type
1123     ,p_recruitment_activity_id =>  p_rec.recruitment_activity_id
1124     ,p_effective_date          =>  p_effective_date
1125     ,p_validation_start_date   =>  p_validation_start_date
1126     ,p_validation_end_date     =>  p_validation_end_date
1127     ,p_object_version_number   =>  p_rec.object_version_number
1128     );
1129 end if;
1130 --- Fix For Bug # 7481310 Ends ---
1131  if g_debug then
1132   hr_utility.set_location(l_proc, 70);
1133  end if;
1134   --
1135   per_asg_bus1.chk_date_probation_end
1136     (p_assignment_id          =>  p_rec.assignment_id
1137     ,p_date_probation_end     =>  p_rec.date_probation_end
1138     ,p_assignment_type        =>  p_rec.assignment_type
1139     ,p_probation_period       =>  p_rec.probation_period
1140     ,p_probation_unit         =>  p_rec.probation_unit
1141     ,p_validation_start_date  =>  p_validation_start_date
1142     ,p_effective_date         =>  p_effective_date
1143     ,p_object_version_number  =>  p_rec.object_version_number
1144     );
1145  if g_debug then
1146   hr_utility.set_location(l_proc, 80);
1147  end if;
1148   --
1149   per_asg_bus2.chk_internal_address_line
1150     (p_assignment_id          =>  p_rec.assignment_id
1151     ,p_assignment_type        =>  p_rec.assignment_type
1152     ,p_internal_address_line  =>  p_rec.internal_address_line
1153     ,p_effective_date         =>  p_effective_date
1154     ,p_object_version_number  =>  p_rec.object_version_number
1155     );
1156  if g_debug then
1157   hr_utility.set_location(l_proc, 90);
1158  end if;
1159   --
1160   per_asg_bus1.chk_change_reason
1161     (p_assignment_id          =>  p_rec.assignment_id
1162     ,p_assignment_type        =>  p_rec.assignment_type
1163     ,p_change_reason          =>  p_rec.change_reason
1164     ,p_effective_date         =>  p_effective_date
1165     ,p_validation_start_date  =>  p_validation_start_date
1166     ,p_validation_end_date    =>  p_validation_end_date
1167     ,p_object_version_number  =>  p_rec.object_version_number
1168     );
1169  if g_debug then
1170   hr_utility.set_location(l_proc, 100);
1171  end if;
1172   --
1173   per_asg_bus1.chk_default_code_comb_id
1174     (p_assignment_id          =>  p_rec.assignment_id
1175     ,p_default_code_comb_id   =>  p_rec.default_code_comb_id
1176     ,p_assignment_type        =>  p_rec.assignment_type
1177     ,p_effective_date         =>  p_effective_date
1178     ,p_validation_start_date =>  p_validation_start_date
1179     ,p_object_version_number  =>  p_rec.object_version_number
1180     );
1181  if g_debug then
1182   hr_utility.set_location(l_proc, 110);
1183  end if;
1184   --
1185   per_asg_bus1.chk_employment_category
1186     (p_assignment_id         =>  p_rec.assignment_id
1187     ,p_assignment_type       =>  p_rec.assignment_type
1188     ,p_employment_category   =>  p_rec.employment_category
1189     ,p_effective_date        =>  p_effective_date
1190     ,p_validation_start_date =>  p_validation_start_date
1191     ,p_validation_end_date   =>  p_validation_end_date
1192     ,p_object_version_number =>  p_rec.object_version_number
1193     );
1194  if g_debug then
1195   hr_utility.set_location(l_proc, 120);
1196  end if;
1197   --
1198   per_asg_bus2.chk_sal_review_period
1199     (p_assignment_id                 =>  p_rec.assignment_id
1200     ,p_sal_review_period             =>  p_rec.sal_review_period
1201     ,p_assignment_type               =>  p_rec.assignment_type
1202     ,p_effective_date                =>  p_effective_date
1203     ,p_object_version_number         =>  p_rec.object_version_number
1204     );
1205  if g_debug then
1206   hr_utility.set_location(l_proc, 130);
1207  end if;
1208   --
1209   per_asg_bus2.chk_sal_review_period_freq
1210     (p_assignment_id                =>  p_rec.assignment_id
1211     ,p_sal_review_period_frequency  =>  p_rec.sal_review_period_frequency
1212     ,p_assignment_type              =>  p_rec.assignment_type
1213     ,p_effective_date               =>  p_effective_date
1214     ,p_validation_start_date        =>  p_validation_start_date
1215     ,p_validation_end_date          =>  p_validation_end_date
1216     ,p_object_version_number        =>  p_rec.object_version_number
1217     );
1218  if g_debug then
1219   hr_utility.set_location(l_proc, 140);
1220  end if;
1221   --
1222   per_asg_bus2.chk_sal_rp_freq_sal_rp
1223     (p_assignment_id                 =>  p_rec.assignment_id
1224     ,p_sal_review_period_frequency   =>  p_rec.sal_review_period_frequency
1225     ,p_sal_review_period             =>  p_rec.sal_review_period
1226     ,p_effective_date                =>  p_effective_date
1227     ,p_object_version_number         =>  p_rec.object_version_number
1228     );
1229  if g_debug then
1230   hr_utility.set_location(l_proc, 150);
1231  end if;
1232   --
1233   per_asg_bus2.chk_perf_review_period
1234     (p_assignment_id                 =>  p_rec.assignment_id
1235     ,p_perf_review_period            =>  p_rec.perf_review_period
1236     ,p_assignment_type               =>  p_rec.assignment_type
1237     ,p_effective_date                =>  p_effective_date
1238     ,p_object_version_number         =>  p_rec.object_version_number
1239     );
1240  if g_debug then
1241   hr_utility.set_location(l_proc, 160);
1242  end if;
1243   --
1244   per_asg_bus2.chk_perf_review_period_freq
1245     (p_assignment_id                 =>  p_rec.assignment_id
1246     ,p_perf_review_period_frequency  =>  p_rec.perf_review_period_frequency
1247     ,p_assignment_type               =>  p_rec.assignment_type
1248     ,p_effective_date                =>  p_effective_date
1249     ,p_validation_start_date         =>  p_validation_start_date
1250     ,p_validation_end_date           =>  p_validation_end_date
1251     ,p_object_version_number         =>  p_rec.object_version_number
1252     );
1253  if g_debug then
1254   hr_utility.set_location(l_proc, 170);
1255  end if;
1256   --
1257   per_asg_bus2.chk_perf_rp_freq_perf_rp
1258     (p_assignment_id                 =>  p_rec.assignment_id
1259     ,p_perf_review_period_frequency  =>  p_rec.perf_review_period_frequency
1260     ,p_perf_review_period            =>  p_rec.perf_review_period
1261     ,p_effective_date                =>  p_effective_date
1262     ,p_object_version_number         =>  p_rec.object_version_number
1263     );
1264  if g_debug then
1265   hr_utility.set_location(l_proc, 180);
1266  end if;
1267   --
1268   per_asg_bus1.chk_frequency
1269     (p_assignment_id           =>  p_rec.assignment_id
1270     ,p_frequency               =>  p_rec.frequency
1271     ,p_effective_date          =>  p_effective_date
1272     ,p_validation_start_date   =>  p_validation_start_date
1273     ,p_validation_end_date     =>  p_validation_end_date
1274     ,p_object_version_number   =>  p_rec.object_version_number
1275     );
1276  if g_debug then
1277   hr_utility.set_location(l_proc, 190);
1278  end if;
1279   --
1280   per_asg_bus1.chk_frequency_normal_hours
1281     (p_assignment_id           =>  p_rec.assignment_id
1282     ,p_frequency               =>  p_rec.frequency
1283     ,p_normal_hours            =>  p_rec.normal_hours
1284     ,p_effective_date          =>  p_effective_date
1285     ,p_object_version_number   =>  p_rec.object_version_number
1286     );
1287  if g_debug then
1288   hr_utility.set_location(l_proc, 200);
1289  end if;
1290   --
1291   per_asg_bus2.chk_set_of_books_id
1292     (p_assignment_id          =>  p_rec.assignment_id
1293     ,p_assignment_type        =>  p_rec.assignment_type
1294     ,p_business_group_id      =>  p_rec.business_group_id
1295     ,p_set_of_books_id        =>  p_rec.set_of_books_id
1296     ,p_effective_date         =>  p_effective_date
1297     ,p_object_version_number  =>  p_rec.object_version_number
1298     );
1299  if g_debug then
1300   hr_utility.set_location(l_proc, 210);
1301  end if;
1302   --
1303   per_asg_bus2.chk_source_organization_id
1304     (p_assignment_id          =>  p_rec.assignment_id
1305     ,p_assignment_type        =>  p_rec.assignment_type
1306     ,p_business_group_id      =>  p_rec.business_group_id
1307     ,p_source_organization_id =>  p_rec.source_organization_id
1308     ,p_effective_date         =>  p_effective_date
1309     ,p_object_version_number  =>  p_rec.object_version_number
1310     ,p_validation_start_date  =>  p_validation_start_date
1311     ,p_validation_end_date    =>  p_validation_end_date
1312     );
1313  if g_debug then
1314   hr_utility.set_location(l_proc, 230);
1315  end if;
1316   --
1317   per_asg_bus2.chk_soft_coding_keyflex_id
1318     (p_assignment_id          =>  p_rec.assignment_id
1319     ,p_assignment_type        =>  p_rec.assignment_type
1320     ,p_soft_coding_keyflex_id =>  p_rec.soft_coding_keyflex_id
1321     ,p_effective_date         =>  p_effective_date
1322     ,p_validation_start_date  =>  p_validation_start_date
1323     ,p_object_version_number  =>  p_rec.object_version_number
1324     ,p_payroll_id             =>  p_rec.payroll_id
1325     ,p_business_group_id      =>  p_rec.business_group_id
1326     );
1327  if g_debug then
1328   hr_utility.set_location(l_proc, 240);
1329  end if;
1330   --
1331   per_asg_bus2.chk_pay_basis_id
1332     (p_assignment_id         =>  p_rec.assignment_id
1333     ,p_pay_basis_id          =>  p_rec.pay_basis_id
1334     ,p_assignment_type       =>  p_rec.assignment_type
1335     ,p_business_group_id     =>  p_rec.business_group_id
1336     ,p_effective_date        =>  p_effective_date
1337     ,p_validation_start_date =>  p_validation_start_date
1338     ,p_object_version_number =>  p_rec.object_version_number
1339     );
1340  if g_debug then
1341   hr_utility.set_location(l_proc, 250);
1342  end if;
1343   --
1344   per_asg_bus2.chk_recruitment_activity_id
1345     (p_assignment_id           =>  p_rec.assignment_id
1346     ,p_assignment_type         =>  p_rec.assignment_type
1347     ,p_business_group_id       =>  p_rec.business_group_id
1348     ,p_recruitment_activity_id =>  p_rec.recruitment_activity_id
1349     ,p_effective_date          =>  p_effective_date
1350     ,p_object_version_number   =>  p_rec.object_version_number
1351     ,p_validation_start_date   =>  p_validation_start_date
1352     ,p_validation_end_date     =>  p_validation_end_date
1353     );
1354  if g_debug then
1355   hr_utility.set_location(l_proc, 260);
1356  end if;
1357   --
1358   per_asg_bus2.chk_vacancy_id
1359     (p_assignment_id         =>  p_rec.assignment_id
1360     ,p_assignment_type       =>  p_rec.assignment_type
1361     ,p_business_group_id     =>  p_rec.business_group_id
1362     ,p_vacancy_id            =>  p_rec.vacancy_id
1363     ,p_effective_date        =>  p_effective_date
1364     ,p_object_version_number =>  p_rec.object_version_number
1365     ,p_validation_start_date =>  p_validation_start_date
1366     ,p_validation_end_date   =>  p_validation_end_date
1367     );
1368  if g_debug then
1369   hr_utility.set_location(l_proc, 270);
1370  end if;
1371   --
1372   per_asg_bus1.chk_location_id
1373     (p_assignment_id         =>  p_rec.assignment_id
1374     ,p_location_id           =>  p_rec.location_id
1375     ,p_assignment_type       =>  p_rec.assignment_type
1376     ,p_vacancy_id            =>  p_rec.vacancy_id
1377     ,p_validation_start_date =>  p_validation_start_date
1378     ,p_validation_end_date   =>  p_validation_end_date
1379     ,p_effective_date        =>  p_effective_date
1380     ,p_object_version_number =>  p_rec.object_version_number
1381     );
1382  if g_debug then
1383   hr_utility.set_location(l_proc, 280);
1384  end if;
1385   --
1386   per_asg_bus2.chk_people_group_id
1387     (p_assignment_id          =>  p_rec.assignment_id
1388     ,p_business_group_id      =>  p_rec.business_group_id
1389     ,p_assignment_type        =>  p_rec.assignment_type
1390     ,p_people_group_id        =>  p_rec.people_group_id
1391     ,p_vacancy_id             =>  p_rec.vacancy_id
1392     ,p_validation_start_date  =>  p_validation_start_date
1393     ,p_validation_end_date    =>  p_validation_end_date
1394     ,p_effective_date         =>  p_effective_date
1395     ,p_object_version_number  =>  p_rec.object_version_number
1396     );
1397  if g_debug then
1398   hr_utility.set_location(l_proc, 290);
1399  end if;
1400   --
1401  if g_debug then
1402   hr_utility.set_location(p_validation_start_date, 290);
1403  end if;
1404  if g_debug then
1405   hr_utility.set_location(p_validation_end_date, 290);
1406  end if;
1407   per_asg_bus2.chk_position_id
1408     (p_assignment_id         =>  p_rec.assignment_id
1409     ,p_position_id           =>  p_rec.position_id
1410     ,p_business_group_id     =>  p_rec.business_group_id
1411     ,p_assignment_type       =>  p_rec.assignment_type
1412     ,p_vacancy_id            =>  p_rec.vacancy_id
1413     ,p_validation_start_date =>  p_validation_start_date
1414     ,p_validation_end_date   =>  p_validation_end_date
1415     ,p_effective_date        =>  p_effective_date
1416     ,p_object_version_number =>  p_rec.object_version_number
1417     );
1418  if g_debug then
1419   hr_utility.set_location(l_proc, 300);
1420  end if;
1421   -- fix for 6331872 starts here
1422   per_asg_bus1.chk_frozen_single_pos
1423     (p_assignment_id         =>  p_rec.assignment_id
1424     ,p_position_id           =>  p_rec.position_id
1425     ,p_effective_date        =>  p_effective_date
1426     );
1427 
1428  if g_debug then
1429   hr_utility.set_location(p_validation_end_date, 305);
1430  end if;
1431  -- fix for 6331872 ends here
1432   per_asg_bus1.chk_job_id
1433     (p_assignment_id         =>  p_rec.assignment_id
1434     ,p_business_group_id     =>  p_rec.business_group_id
1435     ,p_assignment_type       =>  p_rec.assignment_type
1436     ,p_job_id                =>  p_rec.job_id
1437     ,p_vacancy_id            =>  p_rec.vacancy_id
1438     ,p_effective_date        =>  p_effective_date
1439     ,p_validation_start_date =>  p_validation_start_date
1440     ,p_validation_end_date   =>  p_validation_end_date
1441     ,p_object_version_number =>  p_rec.object_version_number
1442     );
1443  if g_debug then
1444   hr_utility.set_location(l_proc, 310);
1445  end if;
1446   --
1447   per_asg_bus2.chk_position_id_job_id
1448     (p_assignment_id         =>  p_rec.assignment_id
1449     ,p_position_id           =>  p_rec.position_id
1450     ,p_job_id                =>  p_rec.job_id
1451     ,p_validation_start_date =>  p_validation_start_date
1452     ,p_validation_end_date   =>  p_validation_end_date
1453     ,p_effective_date        =>  p_effective_date
1454     ,p_object_version_number =>  p_rec.object_version_number
1455     );
1456  if g_debug then
1457   hr_utility.set_location(l_proc, 320);
1458  end if;
1459   --
1460   per_asg_bus1.chk_grade_id
1461     (p_assignment_id            =>  p_rec.assignment_id
1462     ,p_business_group_id        =>  p_rec.business_group_id
1463     ,p_assignment_type          =>  p_rec.assignment_type
1464     ,p_grade_id                 =>  p_rec.grade_id
1465     ,p_vacancy_id               =>  p_rec.vacancy_id
1466     ,p_special_ceiling_step_id  =>  p_rec.special_ceiling_step_id
1467     ,p_effective_date           =>  p_effective_date
1468     ,p_validation_start_date    =>  p_validation_start_date
1469     ,p_validation_end_date      =>  p_validation_end_date
1470     ,p_object_version_number    =>  p_rec.object_version_number
1471     );
1472  if g_debug then
1473   hr_utility.set_location(l_proc, 330);
1474  end if;
1475   --
1476   per_asg_bus2.chk_special_ceiling_step_id
1477     (p_assignment_id            =>  p_rec.assignment_id
1478     ,p_assignment_type          =>  p_rec.assignment_type
1479     ,p_special_ceiling_step_id  =>  p_rec.special_ceiling_step_id
1480     ,p_grade_id                 =>  p_rec.grade_id
1481     ,p_business_group_id        =>  p_rec.business_group_id
1482     ,p_validation_start_date    =>  p_validation_start_date
1483     ,p_validation_end_date      =>  p_validation_end_date
1484     ,p_effective_date           =>  p_effective_date
1485     ,p_object_version_number    =>  p_rec.object_version_number
1486     );
1487  if g_debug then
1488   hr_utility.set_location(l_proc, 340);
1489  end if;
1490   --
1491   per_asg_bus2.chk_position_id_grade_id
1492     (p_assignment_id         =>  p_rec.assignment_id
1493     ,p_position_id           =>  p_rec.position_id
1494     ,p_grade_id              =>  p_rec.grade_id
1495     ,p_validation_start_date =>  p_validation_start_date
1496     ,p_validation_end_date   =>  p_validation_end_date
1497     ,p_effective_date        =>  p_effective_date
1498     ,p_object_version_number =>  p_rec.object_version_number
1499     ,p_inv_pos_grade_warning =>  l_inv_pos_grade_warning
1500     );
1501  if g_debug then
1502   hr_utility.set_location(l_proc, 350);
1503  end if;
1504   --
1505   per_asg_bus1.chk_job_id_grade_id
1506     (p_assignment_id          =>  p_rec.assignment_id
1507     ,p_job_id                 =>  p_rec.job_id
1508     ,p_grade_id               =>  p_rec.grade_id
1509     ,p_validation_start_date  =>  p_validation_start_date
1510     ,p_validation_end_date    =>  p_validation_end_date
1511     ,p_effective_date         =>  p_effective_date
1512     ,p_object_version_number  =>  p_rec.object_version_number
1513     ,p_inv_job_grade_warning  =>  l_inv_job_grade_warning
1514     );
1515  if g_debug then
1516   hr_utility.set_location(l_proc, 360);
1517  end if;
1518   --
1519   per_asg_bus2.chk_person_id
1520     (p_person_id              =>  p_rec.person_id
1521     ,p_business_group_id      =>  p_rec.business_group_id
1522     ,p_effective_date         =>  p_effective_date
1523     );
1524  if g_debug then
1525   hr_utility.set_location(l_proc, 370);
1526  end if;
1527   --
1528   per_asg_bus2.chk_supervisor_id
1529     (p_assignment_id          =>  p_rec.assignment_id
1530     ,p_supervisor_id          =>  p_rec.supervisor_id
1531     ,p_person_id              =>  p_rec.person_id
1532     ,p_business_group_id      =>  p_rec.business_group_id
1533     ,p_validation_start_date  =>  p_validation_start_date
1534     ,p_effective_date         =>  p_effective_date
1535     ,p_object_version_number  =>  p_rec.object_version_number
1536     );
1537  if g_debug then
1538   hr_utility.set_location(l_proc, 375);
1539  end if;
1540   --
1541   per_asg_bus2.chk_supervisor_assignment_id
1542     (p_assignment_id            =>  p_rec.assignment_id
1543     ,p_supervisor_id            =>  p_rec.supervisor_id
1544     ,p_supervisor_assignment_id =>  p_rec.supervisor_assignment_id
1545     ,p_validation_start_date    =>  p_validation_start_date
1546     ,p_effective_date           =>  p_effective_date
1547     ,p_object_version_number    =>  p_rec.object_version_number
1548     );
1549  if g_debug then
1550   hr_utility.set_location(l_proc, 380);
1551  end if;
1552   --
1553   per_asg_bus2.chk_person_referred_by_id
1554     (p_assignment_id           =>  p_rec.assignment_id
1555     ,p_assignment_type         =>  p_rec.assignment_type
1556     ,p_person_id               =>  p_rec.person_id
1557     ,p_person_referred_by_id   =>  p_rec.person_referred_by_id
1558     ,p_business_group_id       =>  p_rec.business_group_id
1559     ,p_effective_date          =>  p_effective_date
1560     ,p_object_version_number   =>  p_rec.object_version_number
1561     ,p_validation_start_date   =>  p_validation_start_date
1562     ,p_validation_end_date     =>  p_validation_end_date
1563     );
1564  if g_debug then
1565   hr_utility.set_location(l_proc, 390);
1566  end if;
1567   --
1568   per_asg_bus2.chk_recruiter_id
1569     (p_assignment_id          =>  p_rec.assignment_id
1570     ,p_person_id              =>  p_rec.person_id
1571     ,p_assignment_type        =>  p_rec.assignment_type
1572     ,p_business_group_id      =>  p_rec.business_group_id
1573     ,p_recruiter_id           =>  p_rec.recruiter_id
1574     ,p_vacancy_id             =>  p_rec.vacancy_id
1575     ,p_effective_date         =>  p_effective_date
1576     ,p_object_version_number  =>  p_rec.object_version_number
1577     ,p_validation_start_date  =>  p_validation_start_date
1578     ,p_validation_end_date    =>  p_validation_end_date
1579     );
1580  if g_debug then
1581   hr_utility.set_location(l_proc, 400);
1582  end if;
1583   --
1584   per_asg_bus2.chk_period_of_service_id
1585     (p_assignment_id          =>  p_rec.assignment_id
1586     ,p_business_group_id      =>  p_rec.business_group_id
1587     ,p_person_id              =>  p_rec.person_id
1588     ,p_assignment_type        =>  p_rec.assignment_type
1589     ,p_period_of_service_id   =>  p_rec.period_of_service_id
1590     ,p_validation_start_date  =>  p_validation_start_date
1591     ,p_validation_end_date    =>  p_validation_end_date
1592     ,p_effective_date         =>  p_effective_date
1593     ,p_object_version_number  =>  p_rec.object_version_number
1594     );
1595  if g_debug then
1596   hr_utility.set_location(l_proc, 405);
1597  end if;
1598   --
1599   per_asg_bus2.gen_assignment_sequence
1600     (p_assignment_type      =>  p_rec.assignment_type
1601     ,p_person_id            =>  p_rec.person_id
1602     ,p_assignment_sequence  =>  p_rec.assignment_sequence
1603     );
1604  if g_debug then
1605   hr_utility.set_location(l_proc, 410);
1606  end if;
1607   --
1608   per_asg_bus1.gen_chk_assignment_number
1609     (p_assignment_id          =>  p_rec.assignment_id
1610     ,p_business_group_id      =>  p_rec.business_group_id
1611     ,p_assignment_type        =>  p_rec.assignment_type
1612     ,p_assignment_sequence    =>  p_rec.assignment_sequence
1613     ,p_assignment_number      =>  p_rec.assignment_number
1614     ,p_person_id              =>  p_rec.person_id
1615     ,p_effective_date         =>  p_effective_date
1616     ,p_object_version_number  =>  p_rec.object_version_number
1617     );
1618  if g_debug then
1619   hr_utility.set_location(l_proc, 420);
1620  end if;
1621   --
1622   per_asg_bus2.chk_primary_flag
1623     (p_assignment_id         =>  p_rec.assignment_id
1624     ,p_primary_flag          =>  p_rec.primary_flag
1625     ,p_assignment_type       =>  p_rec.assignment_type
1626     ,p_person_id             =>  p_rec.person_id
1627     ,p_period_of_service_id  =>  p_rec.period_of_service_id
1628    ,p_pop_date_start        =>  p_rec.period_of_placement_date_start
1629     ,p_effective_date        =>  p_effective_date
1630     ,p_object_version_number =>  p_rec.object_version_number
1631     ,p_validation_start_date =>  p_validation_start_date
1632     ,p_validation_end_date   =>  p_validation_end_date
1633     );
1634  if g_debug then
1635   hr_utility.set_location(l_proc, 430);
1636  end if;
1637   --
1638 per_asg_bus2.chk_applicant_rank
1639         (p_applicant_rank        =>  p_rec.applicant_rank
1640         ,p_assignment_type       =>  p_rec.assignment_type
1641         ,p_assignment_id         =>  p_rec.assignment_id
1642         ,p_object_version_number =>  p_rec.object_version_number
1643         ,p_effective_date        =>  p_effective_date);
1644 
1645 per_asg_bus2.chk_posting_content_id
1646         (p_posting_content_id  =>  p_rec.posting_content_id
1647         ,p_assignment_type     =>  p_rec.assignment_type
1648         ,p_assignment_id       =>  p_rec.assignment_id
1649         ,p_object_version_number =>  p_rec.object_version_number
1650         ,p_effective_date      =>  p_effective_date);
1651 
1652   per_asg_bus1.chk_manager_flag
1653     (p_assignment_id         =>  p_rec.assignment_id
1654     ,p_assignment_type       =>  p_rec.assignment_type
1655     ,p_organization_id       =>  p_rec.organization_id
1656     ,p_manager_flag          =>  p_rec.manager_flag
1657     ,p_effective_date        =>  p_effective_date
1658     ,p_object_version_number =>  p_rec.object_version_number
1659     ,p_other_manager_warning =>  l_other_manager_warning
1660     ,p_no_managers_warning   =>  l_temp_flag
1661     );
1662  if g_debug then
1663   hr_utility.set_location(l_proc, 440);
1664  end if;
1665   --
1666   per_asg_bus1.chk_organization_id
1667     (p_assignment_id               =>  p_rec.assignment_id
1668     ,p_primary_flag                =>  p_rec.primary_flag
1669     ,p_organization_id             =>  p_rec.organization_id
1670     ,p_business_group_id           =>  p_rec.business_group_id
1671     ,p_assignment_type             =>  p_rec.assignment_type
1672     ,p_vacancy_id                  =>  p_rec.vacancy_id
1673     ,p_validation_start_date       =>  p_validation_start_date
1674     ,p_validation_end_date         =>  p_validation_end_date
1675     ,p_effective_date              =>  p_effective_date
1676     ,p_object_version_number       =>  p_rec.object_version_number
1677     ,p_manager_flag                =>  p_rec.manager_flag
1678     ,p_org_now_no_manager_warning  =>  l_temp_flag
1679     ,p_other_manager_warning       =>  l_other_manager_warning
1680     );
1681  if g_debug then
1682   hr_utility.set_location(l_proc, 450);
1683  end if;
1684   --
1685   per_asg_bus2.chk_position_id_org_id
1686     (p_assignment_id         =>  p_rec.assignment_id
1687     ,p_position_id           =>  p_rec.position_id
1688     ,p_organization_id       =>  p_rec.organization_id
1689     ,p_validation_start_date =>  p_validation_start_date
1690     ,p_validation_end_date   =>  p_validation_end_date
1691     ,p_effective_date        =>  p_effective_date
1692     ,p_object_version_number =>  p_rec.object_version_number
1693     );
1694  if g_debug then
1695   hr_utility.set_location(l_proc, 460);
1696  end if;
1697   --
1698   per_asg_bus1.chk_application_id
1699     (p_assignment_id          =>  p_rec.assignment_id
1700     ,p_assignment_type        =>  p_rec.assignment_type
1701     ,p_business_group_id      =>  p_rec.business_group_id
1702     ,p_assignment_sequence    =>  p_rec.assignment_sequence
1703     ,p_application_id         =>  p_rec.application_id
1704     ,p_effective_date         =>  p_effective_date
1705     ,p_object_version_number  =>  p_rec.object_version_number
1706     ,p_validation_start_date  =>  p_validation_start_date
1707     );
1708  if g_debug then
1709   hr_utility.set_location(l_proc, 470);
1710  end if;
1711   --
1712   per_asg_bus2.chk_payroll_id
1713     (p_assignment_id          =>  p_rec.assignment_id
1714     ,p_business_group_id      =>  p_rec.business_group_id
1715     ,p_person_id              =>  p_rec.person_id
1716     ,p_payroll_id             =>  p_rec.payroll_id
1717     ,p_assignment_type        =>  p_rec.assignment_type
1718     ,p_validation_start_date  =>  p_validation_start_date
1719     ,p_validation_end_date    =>  p_validation_end_date
1720     ,p_effective_date         =>  p_effective_date
1721     ,p_datetrack_mode         =>  p_datetrack_mode
1722     ,p_payroll_id_updated     =>  l_temp_flag
1723     ,p_object_version_number  =>  p_rec.object_version_number
1724     );
1725  if g_debug then
1726   hr_utility.set_location(l_proc, 490);
1727  end if;
1728   --
1729   per_asg_bus1.chk_assignment_status_type_id
1730     (p_rec                       => p_rec
1731     ,p_effective_date            => p_effective_date
1732     ,p_validation_start_date     => p_validation_start_date
1733     );
1734  if g_debug then
1735   hr_utility.set_location(l_proc, 500);
1736  end if;
1737 --
1738  per_asg_bus1.chk_bargaining_unit_code
1739     (p_assignment_id         =>  p_rec.assignment_id
1740     ,p_bargaining_unit_code  =>  p_rec.bargaining_unit_code
1741     ,p_effective_date        =>  p_effective_date
1742     ,p_object_version_number =>  p_rec.object_version_number
1743     ,p_validation_start_date =>  p_validation_start_date
1744     ,p_validation_end_date   =>  p_validation_end_date
1745     );
1746  if g_debug then
1747   hr_utility.set_location(l_proc, 511);
1748  end if;
1749 --
1750  per_asg_bus1.chk_hourly_salaried_code
1751     (p_assignment_id           =>  p_rec.assignment_id
1752     ,p_hourly_salaried_code    =>  p_rec.hourly_salaried_code
1753     ,p_effective_date          =>  p_effective_date
1754     ,p_object_version_number   =>  p_rec.object_version_number
1755     ,p_validation_start_date   =>  p_validation_start_date
1756     ,p_validation_end_date     =>  p_validation_end_date
1757     ,p_pay_basis_id            =>  p_rec.pay_basis_id
1758     ,p_hourly_salaried_warning => l_hourly_salaried_warning
1759    ,p_assignment_type         => p_rec.assignment_type);
1760   --
1761   per_asg_bus1.chk_single_position
1762     (p_assignment_id         =>  p_rec.assignment_id
1763     ,p_position_id        =>  p_rec.position_id
1764     ,p_effective_date        =>  p_effective_date
1765     ,p_object_version_number => p_rec.object_version_number
1766     ,p_assignment_type       => p_rec.assignment_type
1767     );
1768   --
1769  if g_debug then
1770   hr_utility.set_location(l_proc, 513);
1771  end if;
1772   per_asg_bus3.chk_contract_id
1773   (p_assignment_id           => p_rec.assignment_id
1774   ,p_effective_date          => p_effective_date
1775   ,p_object_version_number   => p_rec.object_version_number
1776   ,p_contract_id             => p_rec.contract_id
1777   ,p_person_id               => p_rec.person_id
1778   ,p_validation_start_date   => p_validation_start_date
1779   ,p_business_group_id       => p_rec.business_group_id
1780   ) ;
1781  if g_debug then
1782   hr_utility.set_location(l_proc, 515);
1783  end if;
1784   --
1785   per_asg_bus3.chk_establishment_id
1786   (p_assignment_id           => p_rec.assignment_id
1787   ,p_effective_date          => p_effective_date
1788   ,p_object_version_number   => p_rec.object_version_number
1789   ,p_establishment_id        => p_rec.establishment_id
1790   ,p_assignment_type         => p_rec.assignment_type
1791   ,p_business_group_id       => p_rec.business_group_id
1792    );
1793  if g_debug then
1794   hr_utility.set_location(l_proc, 520);
1795  end if;
1796   --
1797   per_asg_bus3.chk_collective_agreement_id
1798   (p_assignment_id           => p_rec.assignment_id
1799   ,p_effective_date          => p_effective_date
1800   ,p_object_version_number   => p_rec.object_version_number
1801   ,p_collective_agreement_id => p_rec.collective_agreement_id
1802   ,p_business_group_id       => p_rec.business_group_id
1803   ,p_establishment_id        => p_rec.establishment_id
1804   );
1805  if g_debug then
1806   hr_utility.set_location(l_proc, 530);
1807  end if;
1808   --
1809   per_asg_bus3.chk_cagr_id_flex_num
1810   (p_assignment_id           => p_rec.assignment_id
1811   ,p_effective_date          => p_effective_date
1812   ,p_object_version_number   => p_rec.object_version_number
1813   ,p_cagr_id_flex_num        => p_rec.cagr_id_flex_num
1814   ,p_collective_agreement_id => p_rec.collective_agreement_id
1815   ) ;
1816  if g_debug then
1817   hr_utility.set_location(l_proc, 535);
1818  end if;
1819   --
1820   per_asg_bus3.chk_cagr_grade_def_id
1821   (p_assignment_id           => p_rec.assignment_id
1822   ,p_effective_date          => p_effective_date
1823   ,p_object_version_number   => p_rec.object_version_number
1824   ,p_cagr_grade_def_id       => p_rec.cagr_grade_def_id
1825   ,p_collective_agreement_id => p_rec.collective_agreement_id
1826   ,p_cagr_id_flex_num        => p_rec.cagr_id_flex_num
1827   );
1828 
1829   per_asg_bus3.chk_notice_period
1830   (p_assignment_id           => p_rec.assignment_id
1831   ,p_notice_period           => p_rec.notice_period
1832   );
1833 
1834   per_asg_bus3.chk_notice_period_uom
1835   (p_assignment_id           => p_rec.assignment_id
1836   ,p_notice_period_uom       => p_rec.notice_period_uom
1837   ,p_notice_period           => p_rec.notice_period
1838   ,p_effective_date          => p_effective_date
1839   ,p_validation_start_date  =>  p_validation_start_date
1840   ,p_validation_end_date    =>  p_validation_end_date
1841   );
1842 
1843   per_asg_bus3.chk_work_at_home
1844   (p_assignment_id           => p_rec.assignment_id
1845   ,p_effective_date          => p_effective_date
1846   ,p_work_at_home      => p_rec.work_at_home
1847   ,p_validation_start_date  =>  p_validation_start_date
1848   ,p_validation_end_date    =>  p_validation_end_date
1849   );
1850 
1851   per_asg_bus3.chk_employee_category
1852   (p_assignment_id           => p_rec.assignment_id
1853   ,p_effective_date          => p_effective_date
1854   ,p_employee_category       => p_rec.employee_category
1855   ,p_validation_start_date  =>  p_validation_start_date
1856   ,p_validation_end_date    =>  p_validation_end_date
1857   );
1858   --
1859  if g_debug then
1860   hr_utility.set_location(l_proc, 600);
1861  end if;
1862   --
1863   per_asg_bus1.chk_assignment_category
1864     (p_assignment_id           => p_rec.assignment_id
1865     ,p_assignment_type         => p_rec.assignment_type
1866     ,p_effective_date          => p_effective_date
1867     ,p_assignment_category     => p_rec.assignment_category
1868     ,p_object_version_number   => p_rec.object_version_number
1869     ,p_validation_start_date   => p_validation_start_date
1870     ,p_validation_end_date     => p_validation_end_date);
1871   --
1872  if g_debug then
1873   hr_utility.set_location(l_proc, 610);
1874  end if;
1875   --
1876   per_asg_bus3.chk_vendor_id
1877     (p_assignment_id          => p_rec.assignment_id
1878     ,p_assignment_type        => p_rec.assignment_type
1879     ,p_vendor_id              => p_rec.vendor_id
1880     ,p_business_group_id      => p_rec.business_group_id
1881     ,p_object_version_number  => p_rec.object_version_number
1882     ,p_effective_date         => p_effective_date);
1883   --
1884  if g_debug then
1885   hr_utility.set_location(l_proc, 620);
1886  end if;
1887   --
1888   per_asg_bus3.chk_vendor_site_id
1889     (p_assignment_id          => p_rec.assignment_id
1890     ,p_assignment_type        => p_rec.assignment_type
1891     ,p_vendor_site_id         => p_rec.vendor_site_id
1892     ,p_object_version_number  => p_rec.object_version_number
1893     ,p_effective_date         => p_effective_date);
1894   --
1895  if g_debug then
1896   hr_utility.set_location(l_proc, 630);
1897  end if;
1898   --
1899   per_asg_bus3.chk_po_header_id
1900     (p_assignment_id          => p_rec.assignment_id
1901     ,p_assignment_type        => p_rec.assignment_type
1902     ,p_po_header_id           => p_rec.po_header_id
1903     ,p_business_group_id      => p_rec.business_group_id
1904     ,p_object_version_number  => p_rec.object_version_number
1905     ,p_effective_date         => p_effective_date);
1906   --
1907  if g_debug then
1908   hr_utility.set_location(l_proc, 640);
1909  end if;
1910   --
1911   per_asg_bus3.chk_po_line_id
1912     (p_assignment_id          => p_rec.assignment_id
1913     ,p_assignment_type        => p_rec.assignment_type
1914     ,p_po_line_id             => p_rec.po_line_id
1915     ,p_object_version_number  => p_rec.object_version_number
1916     ,p_effective_date         => p_effective_date);
1917   --
1918  if g_debug then
1919   hr_utility.set_location(l_proc, 650);
1920  end if;
1921   --
1922   per_asg_bus3.chk_projected_assignment_end
1923     (p_assignment_id            => p_rec.assignment_id
1924     ,p_assignment_type          => p_rec.assignment_type
1925     ,p_effective_start_date     => p_rec.effective_start_date
1926     ,p_projected_assignment_end => p_rec.projected_assignment_end
1927     ,p_object_version_number    => p_rec.object_version_number
1928     ,p_effective_date           => p_effective_date);
1929   --
1930  if g_debug then
1931   hr_utility.set_location(l_proc, 660);
1932  end if;
1933   --
1934   per_asg_bus3.chk_vendor_id_site_id
1935     (p_assignment_id          => p_rec.assignment_id
1936     ,p_vendor_id              => p_rec.vendor_id
1937     ,p_vendor_site_id         => p_rec.vendor_site_id
1938     ,p_object_version_number  => p_rec.object_version_number
1939     ,p_effective_date         => p_effective_date);
1940   --
1941  if g_debug then
1942   hr_utility.set_location(l_proc, 670);
1943  end if;
1944   --
1945   per_asg_bus3.chk_po_header_id_line_id
1946     (p_assignment_id          => p_rec.assignment_id
1947     ,p_po_header_id           => p_rec.po_header_id
1948     ,p_po_line_id             => p_rec.po_line_id
1949     ,p_object_version_number  => p_rec.object_version_number
1950     ,p_effective_date         => p_effective_date);
1951   --
1952  if g_debug then
1953   hr_utility.set_location(l_proc, 680);
1954  end if;
1955   --
1956   per_asg_bus3.chk_vendor_po_match
1957     (p_assignment_id          => p_rec.assignment_id
1958     ,p_vendor_id              => p_rec.vendor_id
1959     ,p_vendor_site_id         => p_rec.vendor_site_id
1960     ,p_po_header_id           => p_rec.po_header_id
1961     ,p_object_version_number  => p_rec.object_version_number
1962     ,p_effective_date         => p_effective_date);
1963   --
1964  if g_debug then
1965   hr_utility.set_location(l_proc, 690);
1966  end if;
1967   --
1968   per_asg_bus3.chk_po_job_match
1969     (p_assignment_id          => p_rec.assignment_id
1970     ,p_job_id                 => p_rec.job_id
1971     ,p_po_line_id             => p_rec.po_line_id
1972     ,p_object_version_number  => p_rec.object_version_number
1973     ,p_effective_date         => p_effective_date);
1974   --
1975  if g_debug then
1976   hr_utility.set_location(l_proc, 700);
1977  end if;
1978   --
1979   per_asg_bus3.chk_vendor_assignment_number
1980     (p_assignment_id            => p_rec.assignment_id
1981     ,p_assignment_type          => p_rec.assignment_type
1982     ,p_vendor_assignment_number => p_rec.vendor_assignment_number
1983     ,p_business_group_id        => p_rec.business_group_id
1984     ,p_object_version_number    => p_rec.object_version_number
1985     ,p_effective_date           => p_effective_date);
1986   --
1987  if g_debug then
1988   hr_utility.set_location(l_proc, 710);
1989  end if;
1990   --
1991   per_asg_bus3.chk_vendor_employee_number
1992     (p_assignment_id            => p_rec.assignment_id
1993     ,p_assignment_type          => p_rec.assignment_type
1994     ,p_vendor_employee_number   => p_rec.vendor_employee_number
1995     ,p_business_group_id        => p_rec.business_group_id
1996     ,p_object_version_number    => p_rec.object_version_number
1997     ,p_effective_date           => p_effective_date);
1998   --
1999  if g_debug then
2000   hr_utility.set_location(l_proc, 720);
2001  end if;
2002   --
2003   per_asg_bus3.chk_pop_date_start
2004     (p_assignment_id            => p_rec.assignment_id
2005     ,p_business_group_id        => p_rec.business_group_id
2006     ,p_person_id                => p_rec.person_id
2007     ,p_assignment_type          => p_rec.assignment_type
2008     ,p_pop_date_start           => p_rec.period_of_placement_date_start
2009     ,p_validation_start_date    => p_validation_start_date
2010     ,p_validation_end_date      => p_validation_end_date
2011     ,p_effective_date           => p_effective_date
2012     ,p_object_version_number    => p_rec.object_version_number);
2013  --
2014  if g_debug then
2015   hr_utility.set_location(l_proc, 730);
2016  end if;
2017   --
2018   per_asg_bus3.chk_grade_ladder_pgm_id
2019     (p_grade_id               => p_rec.grade_id
2020     ,p_grade_ladder_pgm_id    => p_rec.grade_ladder_pgm_id
2021     ,p_business_group_id        => p_rec.business_group_id
2022     ,p_effective_date           => p_effective_date);
2023   --
2024   --
2025   -- Call descriptive flexfield validation routines
2026   --
2027   per_asg_bus1.chk_df(p_rec               => p_rec
2028                      ,p_validate_df_flex  => p_validate_df_flex);
2029   --
2030   p_other_manager_warning := l_other_manager_warning;
2031   p_hourly_salaried_warning := l_hourly_salaried_warning;
2032   p_inv_pos_grade_warning := l_inv_pos_grade_warning;
2033   --
2034   --
2035   -- Call to validate Position Control Business Rules
2036   --
2037     per_pqh_shr.per_asg_bus('INSERT_VALIDATE',
2038                 p_rec,
2039                             p_effective_date,
2040                             p_validation_start_date,
2041                             p_validation_end_date,
2042                             p_datetrack_mode);
2043   --
2044   -- End of call to Position Control Business Rules
2045   --
2046 /*
2047   --
2048   -- Call to validate Position Control Business Rules
2049   --
2050   if (pqh_psf_bus.position_control_enabled
2051       ( p_organization_id => p_rec.organization_id
2052       , p_effective_date  => p_effective_date
2053       ) = 'Y') then
2054     pqh_psf_bus.per_asg_bus_insert_validate
2055          (p_position_id    => p_rec.position_id
2056          ,p_assignment_date   => p_effective_date
2057          ,p_assignment_grade_id  => p_rec.grade_id
2058          ,p_assignment_emp_cat   => p_rec.employment_category
2059          );
2060   end if;
2061   --
2062   -- End of call to Position Control Business Rules
2063   --
2064 */
2065   --
2066  if g_debug then
2067   hr_utility.set_location(' Leaving:'||l_proc, 740);
2068  end if;
2069 End insert_validate;
2070 --
2071 -- ----------------------------------------------------------------------------
2072 -- |---------------------------< update_validate >----------------------------|
2073 -- ----------------------------------------------------------------------------
2074 Procedure update_validate
2075     (p_rec                in out nocopy  per_asg_shd.g_rec_type,
2076 
2077      p_effective_date           in  date,
2078      p_datetrack_mode           in  varchar2,
2079      p_validation_start_date       in  date,
2080      p_validation_end_date           in   date,
2081          p_payroll_id_updated          out nocopy  boolean,
2082          p_other_manager_warning       out nocopy  boolean,
2083          p_hourly_salaried_warning     out nocopy  boolean,
2084          p_no_managers_warning         out nocopy  boolean,
2085          p_org_now_no_manager_warning  out nocopy  boolean,
2086          p_inv_pos_grade_warning       out nocopy  boolean
2087          ) is
2088 --
2089   l_proc                   varchar2(72);
2090   l_temp_flag                  boolean;
2091 
2092   l_other_manager_warning      boolean;
2093   l_hourly_salaried_warning    boolean;
2094   l_no_managers_warning        boolean;
2095   l_org_now_no_manager_warning boolean;
2096   L_inv_pos_grade_warning      boolean := false;
2097   l_payroll_id_updated         boolean;
2098 --
2099 -- bug 4681211
2100 l_api_updating boolean;
2101 l_assignment_sequence number;
2102 -- bug 4681211
2103 --
2104 Begin
2105  if g_debug then
2106   l_proc := g_package||'update_validate';
2107   hr_utility.set_location('Entering:'||l_proc, 10);
2108  end if;
2109   --
2110   -- Call all supporting business operations. Mapping to the
2111   -- appropriate Business Rules in perasg.bru is provided (where relevant).
2112   --
2113   l_other_manager_warning      := FALSE;
2114   l_hourly_salaried_warning    := FALSE;
2115   l_no_managers_warning        := FALSE;
2116 
2117   l_org_now_no_manager_warning := FALSE;
2118   --
2119   hr_api.validate_bus_grp_id
2120     (p_business_group_id => p_rec.business_group_id
2121     ,p_associated_column1 => per_asg_shd.g_tab_nam ||
2122                              '.BUSINESS_GROUP_ID'
2123     ); -- chk business group id
2124   --
2125   hr_multi_message.end_validation_set;
2126   --
2127   -- Check that the columns which cannot be updated
2128   -- have not changed
2129   --
2130   -- Business Rule Mapping
2131   -- =====================
2132   -- CHK_BUSINESS_GROUP_ID / c
2133   -- CHK_PERSON_ID / c
2134   -- GEN_ASSIGNMENT_SEQUENCE / c
2135   -- CHK_ASSIGNMENT_ID / e
2136   --
2137   per_asg_bus1.check_non_updateable_args
2138     (p_rec            => p_rec
2139     ,p_effective_date => p_effective_date
2140     );
2141  if g_debug then
2142   hr_utility.set_location(l_proc, 20);
2143  end if;
2144   --
2145   per_asg_bus2.chk_system_pers_type
2146     (p_person_id             =>  p_rec.person_id
2147     ,p_validation_start_date =>  p_validation_start_date
2148     ,p_validation_end_date   =>  p_validation_end_date
2149     ,p_datetrack_mode        =>  p_datetrack_mode
2150     ,p_effective_date        =>  p_effective_date
2151 
2152     );
2153  if g_debug then
2154   hr_utility.set_location(l_proc, 21);
2155  end if;
2156   --
2157   per_asg_bus2.chk_term_status
2158     (p_assignment_id         =>  p_rec.assignment_id
2159     ,p_datetrack_mode        =>  p_datetrack_mode
2160     ,p_validation_start_date =>  p_validation_start_date
2161     );
2162  if g_debug then
2163   hr_utility.set_location(l_proc, 22);
2164  end if;
2165   --
2166   -- per_asg_bus2.chk_title(p_title  =>  p_rec.title);
2167   --
2168   per_asg_bus2.chk_time_finish_formatted --#2734822
2169     (p_time_normal_finish => p_rec.time_normal_finish
2170     );
2171  if g_debug then
2172   hr_utility.set_location(l_proc, 25);
2173  end if;
2174   --
2175   per_asg_bus2.chk_time_start_formatted --#2734822
2176     (p_time_normal_start => p_rec.time_normal_start
2177     );
2178  if g_debug then
2179   hr_utility.set_location(l_proc, 30);
2180  end if;
2181   --
2182   per_asg_bus1.chk_assignment_type
2183     (p_assignment_id         =>  p_rec.assignment_id
2184     ,p_assignment_type       =>  p_rec.assignment_type
2185     ,p_person_id             =>  p_rec.person_id
2186     ,p_effective_date        =>  p_effective_date
2187     ,p_object_version_number =>  p_rec.object_version_number
2188     ,p_validation_start_date   =>  p_validation_start_date
2189     );
2190  if g_debug then
2191   hr_utility.set_location(l_proc, 30);
2192  end if;
2193   --
2194   per_asg_bus2.chk_probation_unit
2195     (p_assignment_id         =>  p_rec.assignment_id
2196     ,p_probation_unit        =>  p_rec.probation_unit
2197     ,p_effective_date        =>  p_effective_date
2198     ,p_validation_start_date =>  p_validation_start_date
2199 
2200     ,p_validation_end_date   =>  p_validation_end_date
2201     ,p_object_version_number =>  p_rec.object_version_number
2202     );
2203  if g_debug then
2204   hr_utility.set_location(l_proc, 40);
2205  end if;
2206   --
2207   per_asg_bus2.chk_probation_period
2208     (p_assignment_id          =>  p_rec.assignment_id
2209      ,p_probation_period      =>  p_rec.probation_period
2210      ,p_effective_date        =>  p_effective_date
2211      ,p_object_version_number =>  p_rec.object_version_number
2212     );
2213  if g_debug then
2214   hr_utility.set_location(l_proc, 50);
2215  end if;
2216   --
2217 
2218   per_asg_bus2.chk_prob_unit_prob_period
2219     (p_assignment_id                 =>  p_rec.assignment_id
2220     ,p_probation_unit                =>  p_rec.probation_unit
2221     ,p_probation_period              =>  p_rec.probation_period
2222     ,p_effective_date                =>  p_effective_date
2223     ,p_object_version_number         =>  p_rec.object_version_number
2224     );
2225  if g_debug then
2226   hr_utility.set_location(l_proc, 60);
2227  end if;
2228   --
2229   per_asg_bus2.chk_source_type
2230     (p_assignment_id           =>  p_rec.assignment_id
2231     ,p_source_type             =>  p_rec.source_type
2232     ,p_recruitment_activity_id =>  p_rec.recruitment_activity_id
2233 
2234     ,p_effective_date          =>  p_effective_date
2235     ,p_validation_start_date   =>  p_validation_start_date
2236     ,p_validation_end_date     =>  p_validation_end_date
2237     ,p_object_version_number   =>  p_rec.object_version_number
2238     );
2239  if g_debug then
2240   hr_utility.set_location(l_proc, 70);
2241  end if;
2242   --
2243   per_asg_bus1.chk_date_probation_end
2244     (p_assignment_id          =>  p_rec.assignment_id
2245     ,p_date_probation_end     =>  p_rec.date_probation_end
2246     ,p_assignment_type        =>  p_rec.assignment_type
2247     ,p_probation_period       =>  p_rec.probation_period
2248     ,p_probation_unit         =>  p_rec.probation_unit
2249 
2250     ,p_validation_start_date  =>  p_validation_start_date
2251     ,p_effective_date         =>  p_effective_date
2252     ,p_object_version_number  =>  p_rec.object_version_number
2253     );
2254  if g_debug then
2255   hr_utility.set_location(l_proc, 80);
2256  end if;
2257   --
2258   per_asg_bus2.chk_internal_address_line
2259     (p_assignment_id          =>  p_rec.assignment_id
2260     ,p_assignment_type        =>  p_rec.assignment_type
2261     ,p_internal_address_line  =>  p_rec.internal_address_line
2262     ,p_effective_date         =>  p_effective_date
2263     ,p_object_version_number  =>  p_rec.object_version_number
2264     );
2265 
2266  if g_debug then
2267   hr_utility.set_location(l_proc, 90);
2268  end if;
2269   --
2270   per_asg_bus1.chk_change_reason
2271     (p_assignment_id          =>  p_rec.assignment_id
2272     ,p_assignment_type        =>  p_rec.assignment_type
2273     ,p_change_reason          =>  p_rec.change_reason
2274     ,p_effective_date         =>  p_effective_date
2275     ,p_validation_start_date  =>  p_validation_start_date
2276     ,p_validation_end_date    =>  p_validation_end_date
2277     ,p_object_version_number  =>  p_rec.object_version_number
2278     );
2279  if g_debug then
2280   hr_utility.set_location(l_proc, 100);
2281  end if;
2282   --
2283 
2284   per_asg_bus1.chk_default_code_comb_id
2285     (p_assignment_id          =>  p_rec.assignment_id
2286     ,p_default_code_comb_id   =>  p_rec.default_code_comb_id
2287     ,p_assignment_type        =>  p_rec.assignment_type
2288     ,p_effective_date         =>  p_effective_date
2289     ,p_validation_start_date =>  p_validation_start_date
2290     ,p_object_version_number  =>  p_rec.object_version_number
2291     );
2292  if g_debug then
2293   hr_utility.set_location(l_proc, 110);
2294  end if;
2295   --
2296   per_asg_bus1.chk_employment_category
2297     (p_assignment_id         =>  p_rec.assignment_id
2298     ,p_assignment_type       =>  p_rec.assignment_type
2299 
2300     ,p_employment_category   =>  p_rec.employment_category
2301     ,p_effective_date        =>  p_effective_date
2302     ,p_validation_start_date =>  p_validation_start_date
2303     ,p_validation_end_date   =>  p_validation_end_date
2304     ,p_object_version_number =>  p_rec.object_version_number
2305     );
2306  if g_debug then
2307   hr_utility.set_location(l_proc, 120);
2308  end if;
2309   --
2310   per_asg_bus2.chk_sal_review_period
2311     (p_assignment_id         =>  p_rec.assignment_id
2312     ,p_sal_review_period     =>  p_rec.sal_review_period
2313     ,p_assignment_type       =>  p_rec.assignment_type
2314     ,p_effective_date        =>  p_effective_date
2315 
2316     ,p_object_version_number =>  p_rec.object_version_number
2317     );
2318  if g_debug then
2319   hr_utility.set_location(l_proc, 130);
2320  end if;
2321   --
2322   per_asg_bus2.chk_sal_review_period_freq
2323     (p_assignment_id                =>  p_rec.assignment_id
2324     ,p_sal_review_period_frequency  =>  p_rec.sal_review_period_frequency
2325     ,p_assignment_type              =>  p_rec.assignment_type
2326     ,p_effective_date               =>  p_effective_date
2327     ,p_validation_start_date        =>  p_validation_start_date
2328     ,p_validation_end_date          =>  p_validation_end_date
2329     ,p_object_version_number        =>  p_rec.object_version_number
2330     );
2331 
2332  if g_debug then
2333   hr_utility.set_location(l_proc, 140);
2334  end if;
2335   --
2336   per_asg_bus2.chk_sal_rp_freq_sal_rp
2337     (p_assignment_id               =>  p_rec.assignment_id
2338     ,p_sal_review_period_frequency =>  p_rec.sal_review_period_frequency
2339     ,p_sal_review_period           =>  p_rec.sal_review_period
2340     ,p_effective_date              =>  p_effective_date
2341     ,p_object_version_number       =>  p_rec.object_version_number
2342     );
2343  if g_debug then
2344   hr_utility.set_location(l_proc, 150);
2345  end if;
2346   --
2347   per_asg_bus2.chk_perf_review_period
2348     (p_assignment_id                 =>  p_rec.assignment_id
2349 
2350     ,p_perf_review_period            =>  p_rec.perf_review_period
2351     ,p_assignment_type               =>  p_rec.assignment_type
2352     ,p_effective_date                =>  p_effective_date
2353     ,p_object_version_number         =>  p_rec.object_version_number
2354     );
2355  if g_debug then
2356   hr_utility.set_location(l_proc, 160);
2357  end if;
2358   --
2359   per_asg_bus2.chk_perf_review_period_freq
2360     (p_assignment_id                 =>  p_rec.assignment_id
2361     ,p_perf_review_period_frequency  =>  p_rec.perf_review_period_frequency
2362     ,p_assignment_type               =>  p_rec.assignment_type
2363     ,p_effective_date                =>  p_effective_date
2364     ,p_validation_start_date         =>  p_validation_start_date
2365 
2366     ,p_validation_end_date           =>  p_validation_end_date
2367     ,p_object_version_number         =>  p_rec.object_version_number
2368     );
2369  if g_debug then
2370   hr_utility.set_location(l_proc, 170);
2371  end if;
2372   --
2373   per_asg_bus2.chk_perf_rp_freq_perf_rp
2374     (p_assignment_id                 =>  p_rec.assignment_id
2375     ,p_perf_review_period_frequency  =>  p_rec.perf_review_period_frequency
2376     ,p_perf_review_period            =>  p_rec.perf_review_period
2377     ,p_effective_date                =>  p_effective_date
2378     ,p_object_version_number         =>  p_rec.object_version_number
2379     );
2380  if g_debug then
2381   hr_utility.set_location(l_proc, 180);
2382  end if;
2383 
2384   --
2385   per_asg_bus1.chk_frequency
2386     (p_assignment_id           =>  p_rec.assignment_id
2387     ,p_frequency               =>  p_rec.frequency
2388     ,p_effective_date          =>  p_effective_date
2389     ,p_validation_start_date   =>  p_validation_start_date
2390     ,p_validation_end_date     =>  p_validation_end_date
2391     ,p_object_version_number   =>  p_rec.object_version_number
2392     );
2393  if g_debug then
2394   hr_utility.set_location(l_proc, 190);
2395  end if;
2396   --
2397   per_asg_bus1.chk_frequency_normal_hours
2398     (p_assignment_id           =>  p_rec.assignment_id
2399 
2400     ,p_frequency               =>  p_rec.frequency
2401     ,p_normal_hours            =>  p_rec.normal_hours
2402     ,p_effective_date          =>  p_effective_date
2403     ,p_object_version_number   =>  p_rec.object_version_number
2404     );
2405  if g_debug then
2406   hr_utility.set_location(l_proc, 200);
2407  end if;
2408   --
2409   per_asg_bus2.chk_set_of_books_id
2410     (p_assignment_id          =>  p_rec.assignment_id
2411     ,p_assignment_type        =>  p_rec.assignment_type
2412     ,p_business_group_id      =>  p_rec.business_group_id
2413     ,p_set_of_books_id        =>  p_rec.set_of_books_id
2414     ,p_effective_date         =>  p_effective_date
2415 
2416     ,p_object_version_number  =>  p_rec.object_version_number
2417     );
2418  if g_debug then
2419   hr_utility.set_location(l_proc, 210);
2420  end if;
2421   --
2422   per_asg_bus2.chk_source_organization_id
2423     (p_assignment_id          =>  p_rec.assignment_id
2424     ,p_assignment_type        =>  p_rec.assignment_type
2425     ,p_business_group_id      =>  p_rec.business_group_id
2426     ,p_source_organization_id =>  p_rec.source_organization_id
2427     ,p_effective_date         =>  p_effective_date
2428     ,p_object_version_number  =>  p_rec.object_version_number
2429     ,p_validation_start_date  =>  p_validation_start_date
2430     ,p_validation_end_date    =>  p_validation_end_date
2431 
2432     );
2433  if g_debug then
2434   hr_utility.set_location(l_proc, 220);
2435  end if;
2436   --
2437   per_asg_bus2.chk_soft_coding_keyflex_id
2438     (p_assignment_id          =>  p_rec.assignment_id
2439     ,p_assignment_type        =>  p_rec.assignment_type
2440     ,p_soft_coding_keyflex_id =>  p_rec.soft_coding_keyflex_id
2441     ,p_effective_date         =>  p_effective_date
2442     ,p_validation_start_date  =>  p_validation_start_date
2443     ,p_object_version_number  =>  p_rec.object_version_number
2444     ,p_payroll_id             =>  p_rec.payroll_id
2445     ,p_business_group_id      =>  p_rec.business_group_id
2446     );
2447  if g_debug then
2448   hr_utility.set_location(l_proc, 230);
2449  end if;
2450   --
2451 
2452   per_asg_bus2.chk_pay_basis_id
2453     (p_assignment_id         =>  p_rec.assignment_id
2454     ,p_pay_basis_id          =>  p_rec.pay_basis_id
2455     ,p_assignment_type       =>  p_rec.assignment_type
2456     ,p_business_group_id     =>  p_rec.business_group_id
2457     ,p_effective_date        =>  p_effective_date
2458     ,p_validation_start_date =>  p_validation_start_date
2459     ,p_object_version_number =>  p_rec.object_version_number
2460     );
2461  if g_debug then
2462   hr_utility.set_location(l_proc, 240);
2463  end if;
2464   --
2465   per_asg_bus2.chk_recruitment_activity_id
2466     (p_assignment_id           =>  p_rec.assignment_id
2467     ,p_assignment_type         =>  p_rec.assignment_type
2468     ,p_business_group_id       =>  p_rec.business_group_id
2469     ,p_recruitment_activity_id =>  p_rec.recruitment_activity_id
2470     ,p_effective_date          =>  p_effective_date
2471     ,p_object_version_number   =>  p_rec.object_version_number
2472     ,p_validation_start_date   =>  p_validation_start_date
2473     ,p_validation_end_date     =>  p_validation_end_date
2474     );
2475  if g_debug then
2476   hr_utility.set_location(l_proc, 250);
2477  end if;
2478   --
2479   per_asg_bus2.chk_vacancy_id
2480     (p_assignment_id         =>  p_rec.assignment_id
2481     ,p_assignment_type       =>  p_rec.assignment_type
2482 
2483     ,p_business_group_id     =>  p_rec.business_group_id
2484     ,p_vacancy_id            =>  p_rec.vacancy_id
2485     ,p_effective_date        =>  p_effective_date
2486     ,p_object_version_number =>  p_rec.object_version_number
2487     ,p_validation_start_date =>  p_validation_start_date
2488     ,p_validation_end_date   =>  p_validation_end_date
2489     );
2490  if g_debug then
2491   hr_utility.set_location(l_proc, 260);
2492  end if;
2493   --
2494   per_asg_bus1.chk_location_id
2495     (p_assignment_id          =>  p_rec.assignment_id
2496      ,p_location_id           =>  p_rec.location_id
2497      ,p_assignment_type       =>  p_rec.assignment_type
2498 
2499      ,p_vacancy_id            =>  p_rec.vacancy_id
2500      ,p_validation_start_date =>  p_validation_start_date
2501      ,p_validation_end_date   =>  p_validation_end_date
2502      ,p_effective_date        =>  p_effective_date
2503      ,p_object_version_number =>  p_rec.object_version_number
2504     );
2505  if g_debug then
2506   hr_utility.set_location(l_proc, 270);
2507  end if;
2508   --
2509   per_asg_bus2.chk_people_group_id
2510     (p_assignment_id          =>  p_rec.assignment_id
2511     ,p_business_group_id      =>  p_rec.business_group_id
2512     ,p_assignment_type        =>  p_rec.assignment_type
2513     ,p_people_group_id        =>  p_rec.people_group_id
2514 
2515     ,p_vacancy_id             =>  p_rec.vacancy_id
2516     ,p_validation_start_date  =>  p_validation_start_date
2517     ,p_validation_end_date    =>  p_validation_end_date
2518     ,p_effective_date         =>  p_effective_date
2519     ,p_object_version_number  =>  p_rec.object_version_number
2520     );
2521  if g_debug then
2522   hr_utility.set_location(l_proc, 280);
2523  end if;
2524   --
2525  if g_debug then
2526   hr_utility.set_location(p_validation_start_date, 290);
2527  end if;
2528  if g_debug then
2529   hr_utility.set_location(p_validation_end_date, 290);
2530  end if;
2531   per_asg_bus2.chk_position_id
2532     (p_assignment_id          =>  p_rec.assignment_id
2533      ,p_position_id           =>  p_rec.position_id
2534      ,p_business_group_id     =>  p_rec.business_group_id
2535      ,p_assignment_type       =>  p_rec.assignment_type
2536 
2537      ,p_vacancy_id            =>  p_rec.vacancy_id
2538      ,p_validation_start_date =>  p_validation_start_date
2539      ,p_validation_end_date   =>  p_validation_end_date
2540      ,p_effective_date        =>  p_effective_date
2541      ,p_object_version_number =>  p_rec.object_version_number
2542     );
2543  if g_debug then
2544   hr_utility.set_location(l_proc, 290);
2545  end if;
2546   --
2547   per_asg_bus1.chk_job_id
2548     (p_assignment_id         =>  p_rec.assignment_id
2549     ,p_business_group_id     =>  p_rec.business_group_id
2550     ,p_assignment_type       =>  p_rec.assignment_type
2551     ,p_job_id                =>  p_rec.job_id
2552 
2553     ,p_vacancy_id            =>  p_rec.vacancy_id
2554     ,p_effective_date        =>  p_effective_date
2555     ,p_validation_start_date =>  p_validation_start_date
2556     ,p_validation_end_date   =>  p_validation_end_date
2557     ,p_object_version_number =>  p_rec.object_version_number
2558     );
2559  if g_debug then
2560   hr_utility.set_location(l_proc, 300);
2561  end if;
2562   --
2563   per_asg_bus2.chk_position_id_job_id
2564     (p_assignment_id          =>  p_rec.assignment_id
2565      ,p_position_id           =>  p_rec.position_id
2566      ,p_job_id                =>  p_rec.job_id
2567      ,p_validation_start_date =>  p_validation_start_date
2568 
2569      ,p_validation_end_date   =>  p_validation_end_date
2570      ,p_effective_date        =>  p_effective_date
2571      ,p_object_version_number =>  p_rec.object_version_number
2572     );
2573  if g_debug then
2574   hr_utility.set_location(l_proc, 310);
2575  end if;
2576   --
2577   per_asg_bus1.chk_grade_id
2578     (p_assignment_id            =>  p_rec.assignment_id
2579     ,p_business_group_id        =>  p_rec.business_group_id
2580     ,p_assignment_type          =>  p_rec.assignment_type
2581     ,p_grade_id                 =>  p_rec.grade_id
2582     ,p_vacancy_id               =>  p_rec.vacancy_id
2583     ,p_special_ceiling_step_id  =>  p_rec.special_ceiling_step_id
2584 
2585     ,p_effective_date           =>  p_effective_date
2586     ,p_validation_start_date    =>  p_validation_start_date
2587     ,p_validation_end_date      =>  p_validation_end_date
2588     ,p_object_version_number    =>  p_rec.object_version_number
2589     );
2590  if g_debug then
2591   hr_utility.set_location(l_proc, 320);
2592  end if;
2593   --
2594   per_asg_bus2.chk_special_ceiling_step_id
2595     (p_assignment_id            =>  p_rec.assignment_id
2596     ,p_assignment_type          =>  p_rec.assignment_type
2597     ,p_special_ceiling_step_id  =>  p_rec.special_ceiling_step_id
2598     ,p_grade_id                 =>  p_rec.grade_id
2599     ,p_business_group_id        =>  p_rec.business_group_id
2600 
2601     ,p_validation_start_date    =>  p_validation_start_date
2602     ,p_validation_end_date      =>  p_validation_end_date
2603     ,p_effective_date           =>  p_effective_date
2604     ,p_object_version_number    =>  p_rec.object_version_number
2605     );
2606  if g_debug then
2607   hr_utility.set_location(l_proc, 330);
2608  end if;
2609   --
2610   per_asg_bus2.chk_position_id_grade_id
2611     (p_assignment_id          =>  p_rec.assignment_id
2612      ,p_position_id           =>  p_rec.position_id
2613      ,p_grade_id              =>  p_rec.grade_id
2614      ,p_validation_start_date =>  p_validation_start_date
2615      ,p_validation_end_date   =>  p_validation_end_date
2616 
2617      ,p_effective_date        =>  p_effective_date
2618      ,p_object_version_number =>  p_rec.object_version_number
2619      ,p_inv_pos_grade_warning =>  l_inv_pos_grade_warning
2620     );
2621  if g_debug then
2622   hr_utility.set_location(l_proc, 340);
2623  end if;
2624   --
2625   per_asg_bus1.chk_job_id_grade_id
2626     (p_assignment_id          =>  p_rec.assignment_id
2627     ,p_job_id                 =>  p_rec.job_id
2628     ,p_grade_id               =>  p_rec.grade_id
2629     ,p_validation_start_date  =>  p_validation_start_date
2630     ,p_validation_end_date    =>  p_validation_end_date
2631     ,p_effective_date         =>  p_effective_date
2632 
2633     ,p_object_version_number  =>  p_rec.object_version_number
2634     ,p_inv_job_grade_warning  =>  l_inv_pos_grade_warning
2635     );
2636  if g_debug then
2637   hr_utility.set_location(l_proc, 350);
2638  end if;
2639   --
2640   per_asg_bus2.chk_supervisor_id
2641     (p_assignment_id          =>  p_rec.assignment_id
2642     ,p_supervisor_id          =>  p_rec.supervisor_id
2643     ,p_person_id              =>  p_rec.person_id
2644     ,p_business_group_id      =>  p_rec.business_group_id
2645     ,p_validation_start_date  =>  p_validation_start_date
2646     ,p_effective_date         =>  p_effective_date
2647     ,p_object_version_number  =>  p_rec.object_version_number
2648     );
2649  if g_debug then
2650   hr_utility.set_location(l_proc, 360);
2651  end if;
2652   --
2653   per_asg_bus2.chk_supervisor_assignment_id
2654     (p_assignment_id            =>  p_rec.assignment_id
2655     ,p_supervisor_id            =>  p_rec.supervisor_id
2656     ,p_supervisor_assignment_id =>  p_rec.supervisor_assignment_id
2657     ,p_validation_start_date    =>  p_validation_start_date
2658     ,p_effective_date           =>  p_effective_date
2659     ,p_object_version_number    =>  p_rec.object_version_number
2660     );
2661  if g_debug then
2662   hr_utility.set_location(l_proc, 350);
2663  end if;
2664   --
2665   per_asg_bus2.chk_person_referred_by_id
2666     (p_assignment_id           =>  p_rec.assignment_id
2667     ,p_assignment_type         =>  p_rec.assignment_type
2668     ,p_person_id               =>  p_rec.person_id
2669     ,p_person_referred_by_id   =>  p_rec.person_referred_by_id
2670     ,p_business_group_id       =>  p_rec.business_group_id
2671     ,p_effective_date          =>  p_effective_date
2672     ,p_object_version_number   =>  p_rec.object_version_number
2673     ,p_validation_start_date   =>  p_validation_start_date
2674     ,p_validation_end_date     =>  p_validation_end_date
2675 
2676     );
2677  if g_debug then
2678   hr_utility.set_location(l_proc, 370);
2679  end if;
2680   --
2681   per_asg_bus2.chk_recruiter_id
2682     (p_assignment_id          =>  p_rec.assignment_id
2683     ,p_person_id              =>  p_rec.person_id
2684     ,p_assignment_type        =>  p_rec.assignment_type
2685     ,p_business_group_id      =>  p_rec.business_group_id
2686     ,p_recruiter_id           =>  p_rec.recruiter_id
2687     ,p_vacancy_id             =>  p_rec.vacancy_id
2688     ,p_effective_date         =>  p_effective_date
2689     ,p_object_version_number  =>  p_rec.object_version_number
2690     ,p_validation_start_date  =>  p_validation_start_date
2691 
2692     ,p_validation_end_date    =>  p_validation_end_date
2693     );
2694  if g_debug then
2695   hr_utility.set_location(l_proc, 380);
2696  end if;
2697   --
2698   per_asg_bus2.chk_period_of_service_id
2699     (p_assignment_id          =>  p_rec.assignment_id
2700     ,p_business_group_id      =>  p_rec.business_group_id
2701     ,p_person_id              =>  p_rec.person_id
2702     ,p_assignment_type        =>  p_rec.assignment_type
2703     ,p_period_of_service_id   =>  p_rec.period_of_service_id
2704     ,p_validation_start_date  =>  p_validation_start_date
2705     ,p_validation_end_date    =>  p_validation_end_date
2706     ,p_effective_date         =>  p_effective_date
2707     ,p_object_version_number  =>  p_rec.object_version_number
2708     );
2709  if g_debug then
2710   hr_utility.set_location(l_proc, 385);
2711  end if;
2712   --
2713    -- bug 5404529
2714    l_api_updating := per_asg_shd.api_updating
2715          (p_assignment_id          => p_rec.assignment_id
2716          ,p_effective_date         => p_effective_date
2717          ,p_object_version_number  => p_rec.object_version_number
2718          );
2719 
2720   if(l_api_updating and
2721    nvl(per_asg_shd.g_old_rec.assignment_type, hr_api.g_varchar2)
2722 	          = 'A' and p_rec.assignment_type = 'E') THEN
2723 
2724    hr_assignment.gen_new_ass_sequence
2725                           ( p_rec.person_id
2726                           , 'E'
2727                           , l_assignment_sequence
2728                          );
2729 
2730    end if;
2731   if ( l_assignment_sequence =1 )  then
2732   hr_utility.set_location(l_proc, 386);
2733   p_rec.assignment_sequence:=1;
2734   per_asg_bus1.gen_chk_assignment_number
2735     (p_assignment_id          =>  p_rec.assignment_id
2736     ,p_business_group_id      =>  p_rec.business_group_id
2737     ,p_assignment_type        =>  p_rec.assignment_type
2738     ,p_assignment_sequence    =>  p_rec.assignment_sequence
2739     ,p_assignment_number      =>  p_rec.assignment_number
2740     ,p_person_id              =>  p_rec.person_id
2741     ,p_effective_date         =>  p_effective_date
2742     ,p_object_version_number  =>  p_rec.object_version_number
2743     );
2744     hr_utility.set_location(l_proc, 387);
2745     else
2746     hr_utility.set_location(l_proc, 388);
2747     per_asg_bus1.gen_chk_assignment_number
2748     (p_assignment_id          =>  p_rec.assignment_id
2749     ,p_business_group_id      =>  p_rec.business_group_id
2750     ,p_assignment_type        =>  p_rec.assignment_type
2751     ,p_assignment_sequence    =>  p_rec.assignment_sequence
2752     ,p_assignment_number      =>  p_rec.assignment_number
2753     ,p_person_id              =>  p_rec.person_id
2754     ,p_effective_date         =>  p_effective_date
2755     ,p_object_version_number  =>  p_rec.object_version_number
2756     );
2757     hr_utility.set_location(l_proc, 389);
2758     end if;
2759 
2760     -- end of bug 5404529
2761 
2762  if g_debug then
2763   hr_utility.set_location(l_proc, 390);
2764  end if;
2765   --
2766   per_asg_bus2.chk_primary_flag
2767     (p_assignment_id         =>  p_rec.assignment_id
2768     ,p_primary_flag          =>  p_rec.primary_flag
2769     ,p_assignment_type       =>  p_rec.assignment_type
2770     ,p_person_id             =>  p_rec.person_id
2771     ,p_period_of_service_id  =>  p_rec.period_of_service_id
2772    ,p_pop_date_start        =>  p_rec.period_of_placement_date_start
2773     ,p_effective_date        =>  p_effective_date
2774     ,p_object_version_number =>  p_rec.object_version_number
2775     ,p_validation_start_date =>  p_validation_start_date
2776     ,p_validation_end_date   =>  p_validation_end_date
2777     );
2778  if g_debug then
2779   hr_utility.set_location(l_proc, 430);
2780  end if;
2781   --
2782   per_asg_bus1.chk_manager_flag
2783     (p_assignment_id         =>  p_rec.assignment_id
2784     ,p_assignment_type       =>  p_rec.assignment_type
2785     ,p_organization_id       =>  p_rec.organization_id
2786     ,p_manager_flag          =>  p_rec.manager_flag
2787     ,p_effective_date        =>  p_effective_date
2788     ,p_object_version_number =>  p_rec.object_version_number
2789     ,p_other_manager_warning =>  l_other_manager_warning
2790     ,p_no_managers_warning   =>  l_no_managers_warning
2791     );
2792 
2793  if g_debug then
2794   hr_utility.set_location(l_proc, 400);
2795  end if;
2796   --
2797   per_asg_bus1.chk_organization_id
2798     (p_assignment_id               =>  p_rec.assignment_id
2799     ,p_primary_flag                =>  p_rec.primary_flag
2800     ,p_organization_id             =>  p_rec.organization_id
2801     ,p_business_group_id           =>  p_rec.business_group_id
2802     ,p_assignment_type             =>  p_rec.assignment_type
2803     ,p_vacancy_id                  =>  p_rec.vacancy_id
2804     ,p_validation_start_date       =>  p_validation_start_date
2805     ,p_validation_end_date         =>  p_validation_end_date
2806     ,p_effective_date              =>  p_effective_date
2807 
2808     ,p_object_version_number       =>  p_rec.object_version_number
2809     ,p_manager_flag                =>  p_rec.manager_flag
2810     ,p_org_now_no_manager_warning  =>  l_temp_flag
2811     ,p_other_manager_warning       =>  l_other_manager_warning
2812     );
2813  if g_debug then
2814   hr_utility.set_location(l_proc, 410);
2815  end if;
2816   --
2817   per_asg_bus2.chk_position_id_org_id
2818     (p_assignment_id          =>  p_rec.assignment_id
2819      ,p_position_id           =>  p_rec.position_id
2820      ,p_organization_id       =>  p_rec.organization_id
2821      ,p_validation_start_date =>  p_validation_start_date
2822      ,p_validation_end_date   =>  p_validation_end_date
2823 
2824      ,p_effective_date        =>  p_effective_date
2825      ,p_object_version_number =>  p_rec.object_version_number
2826     );
2827  if g_debug then
2828   hr_utility.set_location(l_proc, 420);
2829  end if;
2830   --
2831   per_asg_bus1.chk_application_id
2832     (p_assignment_id          =>  p_rec.assignment_id
2833     ,p_assignment_type        =>  p_rec.assignment_type
2834     ,p_business_group_id      =>  p_rec.business_group_id
2835     ,p_assignment_sequence    =>  p_rec.assignment_sequence
2836     ,p_application_id         =>  p_rec.application_id
2837     ,p_effective_date         =>  p_effective_date
2838     ,p_object_version_number  =>  p_rec.object_version_number
2839 
2840     ,p_validation_start_date  =>  p_validation_start_date
2841     );
2842  if g_debug then
2843   hr_utility.set_location(l_proc, 430);
2844  end if;
2845   --
2846   per_asg_bus2.chk_payroll_id
2847     (p_assignment_id          =>  p_rec.assignment_id
2848     ,p_business_group_id      =>  p_rec.business_group_id
2849     ,p_person_id              =>  p_rec.person_id
2850     ,p_payroll_id             =>  p_rec.payroll_id
2851     ,p_assignment_type        =>  p_rec.assignment_type
2852     ,p_validation_start_date  =>  p_validation_start_date
2853     ,p_validation_end_date    =>  p_validation_end_date
2854     ,p_effective_date         =>  p_effective_date
2855 
2856     ,p_datetrack_mode         =>  p_datetrack_mode
2857     ,p_payroll_id_updated     =>  l_payroll_id_updated
2858     ,p_object_version_number  =>  p_rec.object_version_number
2859     );
2860  if g_debug then
2861   hr_utility.set_location(l_proc, 440);
2862  end if;
2863   --
2864   per_asg_bus1.chk_assignment_status_type_id
2865     (p_rec                       => p_rec
2866     ,p_effective_date            => p_effective_date
2867     ,p_validation_start_date     => p_validation_start_date
2868     );
2869  if g_debug then
2870   hr_utility.set_location(l_proc, 450);
2871  end if;
2872   --
2873   per_asg_bus1.chk_bargaining_unit_code
2874     (p_assignment_id         =>  p_rec.assignment_id
2875     ,p_bargaining_unit_code  =>  p_rec.bargaining_unit_code
2876     ,p_effective_date        =>  p_effective_date
2877     ,p_object_version_number =>  p_rec.object_version_number
2878     ,p_validation_start_date =>  p_validation_start_date
2879     ,p_validation_end_date   =>  p_validation_end_date
2880     );
2881  if g_debug then
2882   hr_utility.set_location(l_proc, 451);
2883  end if;
2884 --
2885  per_asg_bus1.chk_hourly_salaried_code
2886     (p_assignment_id         =>  p_rec.assignment_id
2887     ,p_hourly_salaried_code  =>  p_rec.hourly_salaried_code
2888     ,p_effective_date        =>  p_effective_date
2889     ,p_object_version_number =>  p_rec.object_version_number
2890     ,p_validation_start_date =>  p_validation_start_date
2891     ,p_validation_end_date   =>  p_validation_end_date
2892     ,p_pay_basis_id          =>  p_rec.pay_basis_id
2893     ,p_hourly_salaried_warning => l_hourly_salaried_warning
2894    ,p_assignment_type         => p_rec.assignment_type);
2895   --
2896  if g_debug then
2897   hr_utility.set_location(l_proc, 452);
2898  end if;
2899   --
2900   per_asg_bus1.chk_single_position
2901     (p_assignment_id         =>  p_rec.assignment_id
2902     ,p_position_id        =>  p_rec.position_id
2903     ,p_effective_date        =>  p_effective_date
2904     ,p_object_version_number =>  p_rec.object_version_number
2905     ,p_assignment_type       =>  p_rec.assignment_type
2906     );
2907   --
2908  if g_debug then
2909   hr_utility.set_location(l_proc, 453);
2910  end if;
2911   --
2912   per_asg_bus3.chk_contract_id
2913   (p_assignment_id           => p_rec.assignment_id
2914   ,p_effective_date          => p_effective_date
2915   ,p_object_version_number   => p_rec.object_version_number
2916   ,p_contract_id             => p_rec.contract_id
2917   ,p_person_id               => p_rec.person_id
2918   ,p_validation_start_date   => p_validation_start_date
2919   ,p_business_group_id       => p_rec.business_group_id
2920   ) ;
2921  if g_debug then
2922   hr_utility.set_location(l_proc, 510);
2923  end if;
2924   --
2925   per_asg_bus3.chk_establishment_id
2926   (p_assignment_id           => p_rec.assignment_id
2927   ,p_effective_date          => p_effective_date
2928   ,p_object_version_number   => p_rec.object_version_number
2929   ,p_establishment_id        => p_rec.establishment_id
2930   ,p_assignment_type         => p_rec.assignment_type
2931   ,p_business_group_id       => p_rec.business_group_id
2932    );
2933  if g_debug then
2934   hr_utility.set_location(l_proc, 520);
2935  end if;
2936   --
2937   per_asg_bus3.chk_collective_agreement_id
2938   (p_assignment_id           => p_rec.assignment_id
2939   ,p_effective_date          => p_effective_date
2940   ,p_object_version_number   => p_rec.object_version_number
2941   ,p_collective_agreement_id => p_rec.collective_agreement_id
2942   ,p_business_group_id       => p_rec.business_group_id
2943   ,p_establishment_id        => p_rec.establishment_id
2944   );
2945  if g_debug then
2946   hr_utility.set_location(l_proc, 530);
2947  end if;
2948   --
2949   per_asg_bus3.chk_cagr_id_flex_num
2950   (p_assignment_id           => p_rec.assignment_id
2951   ,p_effective_date          => p_effective_date
2952   ,p_object_version_number   => p_rec.object_version_number
2953   ,p_cagr_id_flex_num        => p_rec.cagr_id_flex_num
2954   ,p_collective_agreement_id => p_rec.collective_agreement_id
2955   ) ;
2956  if g_debug then
2957   hr_utility.set_location(l_proc, 535);
2958  end if;
2959   --
2960   per_asg_bus3.chk_cagr_grade_def_id
2961   (p_assignment_id           => p_rec.assignment_id
2962   ,p_effective_date          => p_effective_date
2963   ,p_object_version_number   => p_rec.object_version_number
2964   ,p_cagr_grade_def_id       => p_rec.cagr_grade_def_id
2965   ,p_collective_agreement_id => p_rec.collective_agreement_id
2966   ,p_cagr_id_flex_num        => p_rec.cagr_id_flex_num
2967   );
2968 
2969   per_asg_bus3.chk_notice_period
2970   (p_assignment_id           => p_rec.assignment_id
2971   ,p_notice_period           => p_rec.notice_period
2972   );
2973 
2974   per_asg_bus3.chk_notice_period_uom
2975   (p_assignment_id           => p_rec.assignment_id
2976   ,p_notice_period_uom       => p_rec.notice_period_uom
2977   ,p_notice_period           => p_rec.notice_period
2978   ,p_effective_date          => p_effective_date
2979   ,p_validation_start_date  =>  p_validation_start_date
2980   ,p_validation_end_date    =>  p_validation_end_date
2981   );
2982 
2983   per_asg_bus3.chk_work_at_home
2984   (p_assignment_id           => p_rec.assignment_id
2985   ,p_effective_date          => p_effective_date
2986   ,p_work_at_home      => p_rec.work_at_home
2987   ,p_validation_start_date  =>  p_validation_start_date
2988   ,p_validation_end_date    =>  p_validation_end_date
2989   );
2990 
2991   per_asg_bus3.chk_employee_category
2992   (p_assignment_id           => p_rec.assignment_id
2993   ,p_effective_date          => p_effective_date
2994   ,p_employee_category       => p_rec.employee_category
2995   ,p_validation_start_date  =>  p_validation_start_date
2996   ,p_validation_end_date    =>  p_validation_end_date
2997   );
2998     --
2999  if g_debug then
3000   hr_utility.set_location(l_proc, 600);
3001  end if;
3002   --
3003   per_asg_bus1.chk_assignment_category
3004     (p_assignment_id           => p_rec.assignment_id
3005     ,p_assignment_type         => p_rec.assignment_type
3006     ,p_effective_date          => p_effective_date
3007     ,p_assignment_category     => p_rec.assignment_category
3008     ,p_object_version_number   => p_rec.object_version_number
3009     ,p_validation_start_date   => p_validation_start_date
3010     ,p_validation_end_date     => p_validation_end_date);
3011   --
3012  if g_debug then
3013   hr_utility.set_location(l_proc, 610);
3014  end if;
3015   --
3016   per_asg_bus3.chk_vendor_id
3017     (p_assignment_id          => p_rec.assignment_id
3018     ,p_assignment_type        => p_rec.assignment_type
3019     ,p_vendor_id              => p_rec.vendor_id
3020     ,p_business_group_id      => p_rec.business_group_id
3021     ,p_object_version_number  => p_rec.object_version_number
3022     ,p_effective_date         => p_effective_date);
3023   --
3024  if g_debug then
3025   hr_utility.set_location(l_proc, 620);
3026  end if;
3027   per_asg_bus3.chk_vendor_site_id
3028     (p_assignment_id          => p_rec.assignment_id
3029     ,p_assignment_type        => p_rec.assignment_type
3030     ,p_vendor_site_id         => p_rec.vendor_site_id
3031     ,p_object_version_number  => p_rec.object_version_number
3032     ,p_effective_date         => p_effective_date);
3033   --
3034  if g_debug then
3035   hr_utility.set_location(l_proc, 630);
3036  end if;
3037   --
3038   per_asg_bus3.chk_po_header_id
3039     (p_assignment_id          => p_rec.assignment_id
3040     ,p_assignment_type        => p_rec.assignment_type
3041     ,p_po_header_id           => p_rec.po_header_id
3042     ,p_business_group_id      => p_rec.business_group_id
3043     ,p_object_version_number  => p_rec.object_version_number
3044     ,p_effective_date         => p_effective_date);
3045   --
3046  if g_debug then
3047   hr_utility.set_location(l_proc, 640);
3048  end if;
3049   --
3050   per_asg_bus3.chk_po_line_id
3051     (p_assignment_id          => p_rec.assignment_id
3052     ,p_assignment_type        => p_rec.assignment_type
3053     ,p_po_line_id             => p_rec.po_line_id
3054     ,p_object_version_number  => p_rec.object_version_number
3055     ,p_effective_date         => p_effective_date);
3056   --
3057  if g_debug then
3058   hr_utility.set_location(l_proc, 650);
3059  end if;
3060   --
3061   per_asg_bus3.chk_projected_assignment_end
3062     (p_assignment_id            => p_rec.assignment_id
3063     ,p_assignment_type          => p_rec.assignment_type
3064     ,p_effective_start_date     => p_rec.effective_start_date
3065     ,p_projected_assignment_end => p_rec.projected_assignment_end
3066     ,p_object_version_number    => p_rec.object_version_number
3067     ,p_effective_date           => p_effective_date);
3068   --
3069  if g_debug then
3070   hr_utility.set_location(l_proc, 660);
3071  end if;
3072   --
3073   per_asg_bus3.chk_vendor_id_site_id
3074     (p_assignment_id          => p_rec.assignment_id
3075     ,p_vendor_id              => p_rec.vendor_id
3076     ,p_vendor_site_id         => p_rec.vendor_site_id
3077     ,p_object_version_number  => p_rec.object_version_number
3078     ,p_effective_date         => p_effective_date);
3079   --
3080  if g_debug then
3081   hr_utility.set_location(l_proc, 670);
3082  end if;
3083   --
3084   per_asg_bus3.chk_po_header_id_line_id
3085     (p_assignment_id          => p_rec.assignment_id
3086     ,p_po_header_id           => p_rec.po_header_id
3087     ,p_po_line_id             => p_rec.po_line_id
3088     ,p_object_version_number  => p_rec.object_version_number
3089     ,p_effective_date         => p_effective_date);
3090   --
3091  if g_debug then
3092   hr_utility.set_location(l_proc, 680);
3093  end if;
3094   --
3095   per_asg_bus3.chk_vendor_po_match
3096     (p_assignment_id          => p_rec.assignment_id
3097     ,p_vendor_id              => p_rec.vendor_id
3098     ,p_vendor_site_id         => p_rec.vendor_site_id
3099     ,p_po_header_id           => p_rec.po_header_id
3100     ,p_object_version_number  => p_rec.object_version_number
3101     ,p_effective_date         => p_effective_date);
3102   --
3103  if g_debug then
3104   hr_utility.set_location(l_proc, 690);
3105  end if;
3106   --
3107   per_asg_bus3.chk_po_job_match
3108     (p_assignment_id          => p_rec.assignment_id
3109     ,p_job_id                 => p_rec.job_id
3110     ,p_po_line_id             => p_rec.po_line_id
3111     ,p_object_version_number  => p_rec.object_version_number
3112     ,p_effective_date         => p_effective_date);
3113   --
3114   if g_debug then
3115     hr_utility.set_location(l_proc, 700);
3116   end if;
3117   --
3118   per_asg_bus3.chk_vendor_assignment_number
3119     (p_assignment_id            => p_rec.assignment_id
3120     ,p_assignment_type          => p_rec.assignment_type
3121     ,p_vendor_assignment_number => p_rec.vendor_assignment_number
3122     ,p_business_group_id        => p_rec.business_group_id
3123     ,p_object_version_number    => p_rec.object_version_number
3124     ,p_effective_date           => p_effective_date);
3125   --
3126  if g_debug then
3127   hr_utility.set_location(l_proc, 710);
3128  end if;
3129   --
3130   per_asg_bus3.chk_vendor_employee_number
3131     (p_assignment_id            => p_rec.assignment_id
3132     ,p_assignment_type          => p_rec.assignment_type
3133     ,p_vendor_employee_number   => p_rec.vendor_employee_number
3134     ,p_business_group_id        => p_rec.business_group_id
3135     ,p_object_version_number    => p_rec.object_version_number
3136     ,p_effective_date           => p_effective_date);
3137   --
3138  if g_debug then
3139   hr_utility.set_location(l_proc, 720);
3140  end if;
3141   --
3142   per_asg_bus3.chk_pop_date_start
3143     (p_assignment_id            => p_rec.assignment_id
3144     ,p_business_group_id        => p_rec.business_group_id
3145     ,p_person_id                => p_rec.person_id
3146     ,p_assignment_type          => p_rec.assignment_type
3147     ,p_pop_date_start           => p_rec.period_of_placement_date_start
3148     ,p_validation_start_date    => p_validation_start_date
3149     ,p_validation_end_date      => p_validation_end_date
3150     ,p_effective_date           => p_effective_date
3151     ,p_object_version_number    => p_rec.object_version_number);
3152   --
3153  if g_debug then
3154   hr_utility.set_location(l_proc, 730);
3155  end if;
3156   --
3157 per_asg_bus2.chk_applicant_rank
3158         (p_applicant_rank        =>  p_rec.applicant_rank
3159         ,p_assignment_type       =>  p_rec.assignment_type
3160         ,p_assignment_id         =>  p_rec.assignment_id
3161         ,p_object_version_number =>  p_rec.object_version_number
3162         ,p_effective_date        =>  p_effective_date);
3163 
3164 per_asg_bus2.chk_posting_content_id
3165         (p_posting_content_id    =>  p_rec.posting_content_id
3166         ,p_assignment_type       =>  p_rec.assignment_type
3167         ,p_assignment_id         =>  p_rec.assignment_id
3168         ,p_object_version_number =>  p_rec.object_version_number
3169         ,p_effective_date        =>  p_effective_date);
3170   --
3171  if g_debug then
3172   hr_utility.set_location(l_proc, 740);
3173  end if;
3174   --
3175   per_asg_bus3.chk_grade_ladder_pgm_id
3176     (p_grade_id                 => p_rec.grade_id
3177     ,p_grade_ladder_pgm_id      => p_rec.grade_ladder_pgm_id
3178     ,p_business_group_id        => p_rec.business_group_id
3179     ,p_effective_date           => p_effective_date);
3180 
3181   --
3182   --
3183   -- Call descriptive flexfield validation routines
3184   --
3185   per_asg_bus1.chk_df(p_rec => p_rec);
3186 
3187  if g_debug then
3188   hr_utility.set_location(l_proc, 750);
3189  end if;
3190   --
3191   -- Call the datetrack update integrity operation
3192   --
3193   per_asg_bus1.dt_update_validate
3194     (p_payroll_id                    => p_rec.payroll_id,
3195      p_person_id                     => p_rec.person_id,
3196      p_datetrack_mode                => p_datetrack_mode,
3197      p_validation_start_date         => p_validation_start_date,
3198      p_validation_end_date         => p_validation_end_date);
3199   --
3200   p_other_manager_warning      := l_other_manager_warning;
3201   p_hourly_salaried_warning    := l_hourly_salaried_warning;
3202   p_no_managers_warning        := l_no_managers_warning;
3203 
3204   p_org_now_no_manager_warning := l_org_now_no_manager_warning;
3205   p_inv_pos_grade_warning      := l_inv_pos_grade_warning;
3206   p_payroll_id_updated         := l_payroll_id_updated;
3207   --
3208   --
3209   --
3210   -- Call to validate Position Control Business Rules
3211   --
3212     per_pqh_shr.per_asg_bus('UPDATE_VALIDATE',
3213                 p_rec,
3214                             p_effective_date,
3215                             p_validation_start_date,
3216                             p_validation_end_date,
3217                             p_datetrack_mode);
3218   --
3219   -- End of call to Position Control Business Rules
3220   --
3221 /*
3222   --
3223   -- Call to validate Position Control Business Rules
3224   --
3225   if (pqh_psf_bus.position_control_enabled
3226       ( p_organization_id => p_rec.organization_id
3227       , p_effective_date  => p_effective_date
3228       ) = 'Y') then
3229     pqh_psf_bus.per_asg_bus_update_validate
3230          (p_position_id    => p_rec.position_id
3231          ,p_assignment_id  => p_rec.assignment_id
3232          ,p_assignment_date   => p_rec.effective_start_date
3233          ,p_assignment_grade_id  => p_rec.grade_id
3234          ,p_assignment_emp_cat   => p_rec.employment_category
3235          );
3236   end if;
3237   --
3238   -- End of call to Position Control Business Rules
3239   --
3240 */
3241   --
3242   --
3243  if g_debug then
3244   hr_utility.set_location(' Leaving:'||l_proc, 999);
3245  end if;
3246 End update_validate;
3247 --
3248 --  ---------------------------------------------------------------------------
3249 --  |-----------------------< chk_application_id >----------------------------|
3250 --  ---------------------------------------------------------------------------
3251 --
3252 procedure chk_application_id
3253   (p_assignment_id            in per_all_assignments_f.assignment_id%TYPE
3254   ,p_assignment_type          in per_all_assignments_f.assignment_type%TYPE
3255   ,p_business_group_id        in per_all_assignments_f.business_group_id%TYPE
3256   ,p_assignment_sequence      in per_all_assignments_f.assignment_sequence%TYPE
3257   ,p_application_id           in per_all_assignments_f.application_id%TYPE
3258   ,p_effective_date           in date
3259   ,p_object_version_number    in per_all_assignments_f.object_version_number%TYPE
3260   ,p_validation_start_date    in date
3261   )
3262   is
3263 --
3264   l_proc              varchar2(72)  :=  g_package||'chk_application_id';
3265   l_exists            varchar2(1);
3266   l_api_updating      boolean;
3267   l_business_group_id per_all_assignments_f.business_group_id%TYPE;
3268   --
3269   cursor csr_valid_apl_1 is
3270     select   business_group_id
3271     from     per_applications
3272     where    application_id = p_application_id
3273     and      date_received = p_validation_start_date;
3274   --
3275   cursor csr_valid_apl_2 is
3276     select   business_group_id
3277     from     per_applications
3278     where    application_id = p_application_id
3279     and      p_validation_start_date
3280       between date_received
3281       and     nvl(date_end,hr_api.g_eot);
3282   --
3283 begin
3284  if g_debug then
3285   hr_utility.set_location('Entering:'|| l_proc, 10);
3286  end if;
3287   --
3288     --
3289     -- Check mandatory parameters have been set
3290     --
3291     hr_api.mandatory_arg_error
3292       (p_api_name       => l_proc
3293       ,p_argument       => 'effective_date'
3294       ,p_argument_value => p_effective_date
3295       );
3296     --
3297     hr_api.mandatory_arg_error
3298       (p_api_name       => l_proc
3299       ,p_argument       => 'validation_start_date'
3300       ,p_argument_value => p_validation_start_date
3301       );
3302  if g_debug then
3303     hr_utility.set_location(l_proc, 20);
3304  end if;
3305     --
3306     -- Check if the assignment is being updated.
3307     --
3308     l_api_updating := per_asg_shd.api_updating
3309           (p_assignment_id          => p_assignment_id
3310           ,p_effective_date         => p_effective_date
3311           ,p_object_version_number  => p_object_version_number);
3312  if g_debug then
3313     hr_utility.set_location(l_proc, 30);
3314  end if;
3315     --
3316     -- Check if the assignment is being inserted or updated.
3317     --
3318     if ((l_api_updating and
3319        nvl(per_asg_shd.g_old_rec.application_id, hr_api.g_number)
3320        <> nvl(p_application_id, hr_api.g_number))
3321       or (NOT l_api_updating))
3322     then
3323  if g_debug then
3324       hr_utility.set_location(l_proc, 40);
3325  end if;
3326       --
3327       -- Check if the assignment is an applicant assignment or
3328       -- offer assignment or an employee assignment which is being updated.
3329       --
3330       if p_assignment_type = 'A'
3331         or p_assignment_type = 'O'
3332         or (p_assignment_type = 'E' and l_api_updating)
3333         then
3334         --
3335         -- Check if the application is null
3336         --
3337         if p_application_id is null then
3338           --
3339           -- Check if the assignment is an applicant or offer assignment
3340           --
3341           if  p_assignment_type = 'A'
3342            or p_assignment_type = 'O' then
3343             --
3344             hr_utility.set_message(801, 'HR_51212_ASG_INV_APL_ASG_APL');
3345             hr_utility.raise_error;
3346            /* hr_multi_message.add
3347               (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3348          );*/
3349             --
3350           end if;
3351  if g_debug then
3352           hr_utility.set_location(l_proc, 50);
3353  end if;
3354           --
3355           -- Check if the existing application is set
3356           --
3357           If per_asg_shd.g_old_rec.application_id is not null then
3358             --
3359             hr_utility.set_message(801, 'HR_51213_ASG_INV_UPD_APL');
3360             hr_utility.raise_error;
3361            /*hr_multi_message.add
3362               (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3363          );  */          --
3364             --
3365           end if;
3366 if g_debug then
3367           hr_utility.set_location(l_proc, 60);
3368  end if;
3369           --
3370         end if;
3371         --
3372         -- Check if the assignment is the first applicant assignment.
3373         --
3374         IF   p_assignment_sequence = 1
3375          and (not l_api_updating)
3376          and p_assignment_type <> 'O'
3377         then
3378           --
3379           -- Check if the application exists in PER_APPLICATIONS
3380           -- and the application date received is the same as the
3381           -- assignment effective start date.
3382           --
3383           open csr_valid_apl_1;
3384           fetch csr_valid_apl_1 into l_business_group_id;
3385           if csr_valid_apl_1%notfound then
3386             close csr_valid_apl_1;
3387             hr_utility.set_message(801, 'HR_51210_ASG_INV_APL');
3388             hr_utility.raise_error;
3389            /* hr_multi_message.add
3390               (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3391          ,p_associated_column2 =>
3392          'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
3393          ,p_associated_column3 =>
3394          'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_SEQUENCE'
3395          ); */
3396             --
3397           else
3398        close csr_valid_apl_1;
3399      end if;
3400         else -- not the first applicant assignment
3401           --
3402           -- Check if the application exists in PER_APPLICATIONS
3403           -- and the assignment effective start date is between the
3404           -- date received and the date end of the application when
3405           -- the application date end is set.
3406           --
3407           open csr_valid_apl_2;
3408           fetch csr_valid_apl_2 into l_business_group_id;
3409           if csr_valid_apl_2%notfound then
3410             close csr_valid_apl_2;
3411             hr_utility.set_message(801, 'HR_51375_ASG_INV_APL_NOT_1_ASG');
3412             hr_multi_message.add
3413               (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3414          ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
3415               ,p_associated_column3 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_SEQUENCE'
3416          );
3417             --
3418           else
3419        close csr_valid_apl_2;
3420        --
3421             -- Check that the application is in the same business group
3422             -- as the business group of the assignment.
3423             --
3424 if g_debug then
3425             hr_utility.set_location(l_proc, 90);
3426  end if;
3427        If p_business_group_id <> l_business_group_id then
3428               --
3429               hr_utility.set_message(801, 'HR_51214_ASG_INV_APL_BUS_GRP');
3430               hr_multi_message.add
3431                 (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3432       );
3433               --
3434              end if;
3435           end if;
3436 if g_debug then
3437      hr_utility.set_location(l_proc, 100);
3438  end if;
3439           --
3440         end if;
3441         --
3442       else -- inserted an employee assignment
3443         --
3444         -- Check that application is null
3445         --
3446         If p_application_id is not null then
3447           --
3448           hr_utility.set_message(801, 'HR_51211_ASG_INV_E_ASG_APL_ID');
3449           hr_multi_message.add
3450               (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.APPLICATION_ID'
3451          );
3452           --
3453         end if;
3454 if g_debug then
3455         hr_utility.set_location(l_proc, 110);
3456  end if;
3457         --
3458       end if;
3459       --
3460     end if;
3461     --
3462 if g_debug then
3463   hr_utility.set_location(' Leaving:'|| l_proc, 120);
3464  end if;
3465 end chk_application_id;
3466 --
3467 --  ---------------------------------------------------------------------------
3468 --  |---------------------< gen_chk_assignment_number >-----------------------|
3469 --  ---------------------------------------------------------------------------
3470 --
3471 procedure gen_chk_assignment_number
3472   (p_assignment_id         in per_all_assignments_f.assignment_id%TYPE
3473   ,p_business_group_id     in per_all_assignments_f.business_group_id%TYPE
3474   ,p_assignment_type       in per_all_assignments_f.assignment_type%TYPE
3475   ,p_assignment_sequence   in per_all_assignments_f.assignment_sequence%TYPE
3476   ,p_assignment_number     in out nocopy per_all_assignments_f.assignment_number%TYPE
3477   ,p_person_id             in per_all_assignments_f.person_id%TYPE
3478   ,p_effective_date        in date
3479   ,p_object_version_number in per_all_assignments_f.object_version_number%TYPE
3480   )
3481   is
3482 --
3483    l_proc            varchar2(72)  :=  g_package||'gen_chk_assignment_number';
3484    l_api_updating    boolean;
3485    l_worker_number varchar2(30);
3486    --
3487    cursor csr_get_work_no is
3488      select   decode(p_assignment_type,'E',employee_number,'C',npw_number)
3489      from     per_all_people_f --#3663845 per_people_f
3490      where    person_id = p_person_id
3491      and      p_effective_date between effective_start_date
3492                                and     effective_end_date;
3493    --
3494 begin
3495   --
3496 if g_debug then
3497   hr_utility.set_location('Entering: '|| l_proc, 10);
3498  end if;
3499   --
3500   hr_api.mandatory_arg_error
3501     (p_api_name       => l_proc
3502     ,p_argument       => 'person_id'
3503     ,p_argument_value => p_person_id
3504     );
3505   --
3506   hr_api.mandatory_arg_error
3507     (p_api_name       => l_proc
3508     ,p_argument       => 'business_group_id'
3509     ,p_argument_value => p_business_group_id
3510     );
3511   --
3512   hr_api.mandatory_arg_error
3513     (p_api_name       => l_proc
3514     ,p_argument       => 'assignment_type'
3515     ,p_argument_value => p_assignment_type
3516     );
3517   --
3518   hr_api.mandatory_arg_error
3519     (p_api_name       => l_proc
3520     ,p_argument       => 'assignment_sequence'
3521     ,p_argument_value => p_assignment_sequence
3522     );
3523 if g_debug then
3524   hr_utility.set_location(l_proc, 20);
3525  end if;
3526   --
3527   -- Only proceed with validation if :
3528   -- a) The current g_old_rec is current and
3529   -- b) The value for assignment number has changed
3530   --    to a not null value
3531   --
3532   l_api_updating := per_asg_shd.api_updating
3533          (p_assignment_id          => p_assignment_id
3534          ,p_effective_date         => p_effective_date
3535          ,p_object_version_number  => p_object_version_number
3536          );
3537 if g_debug then
3538   hr_utility.set_location(l_proc, 30);
3539  end if;
3540   --
3541   -- Amended for bug 942142
3542   -- Removed p_assignment_number is not null from the check condition
3543   -- of the top level if statement
3544   --
3545   if ((l_api_updating and
3546        nvl(per_asg_shd.g_old_rec.assignment_number, hr_api.g_varchar2) <>
3547        nvl(p_assignment_number, hr_api.g_varchar2)) or
3548       (NOT l_api_updating)) then
3549     --
3550 if g_debug then
3551     hr_utility.set_location(l_proc, 40);
3552  end if;
3553     --
3554     -- For applicant and offer assignments ensure the assignment_number
3555     -- is null
3556     -- <OAB_CHANGE> - Extend restriction to allow assignment type 'B'
3557     --
3558     if p_assignment_type in ('A','B','O') then
3559       --
3560       -- Check if the assignment number is set.
3561       --
3562       if p_assignment_number is not null then
3563        --
3564         -- Raise an error: Assignment Number must be null for
3565         -- applicant, offer and benefit assignments
3566         hr_utility.set_message(801, 'HR_51017_ASG_NUM_NULL_FOR_APL');
3567         hr_multi_message.add
3568           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_NUMBER');
3569         --
3570       end if;
3571      --
3572 if g_debug then
3573       hr_utility.set_location(l_proc, 50);
3574  end if;
3575    --
3576    -- For Employee and Contingent Labour assignments derive the
3577    -- assignment number.
3578    --
3579     elsif p_assignment_type In ('E','C') then
3580       --
3581       if hr_multi_message.no_exclusive_error
3582        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID') then
3583         --
3584         -- For worker assignments validate or generate the assignment number
3585         --
3586         open csr_get_work_no;
3587         fetch csr_get_work_no into l_worker_number;
3588       --
3589         if csr_get_work_no%found then
3590         --
3591           close csr_get_work_no;
3592 if g_debug then
3593           hr_utility.set_location(l_proc, 60);
3594  end if;
3595           --
3596            hr_assignment.gen_new_ass_number
3597             (p_assignment_id       => p_assignment_id
3598             ,p_business_group_id   => p_business_group_id
3599             ,p_worker_number       => l_worker_number
3600             ,p_assignment_type     => p_assignment_type
3601             ,p_assignment_sequence => p_assignment_sequence
3602             ,p_assignment_number   => p_assignment_number);
3603           --
3604 if g_debug then
3605           hr_utility.set_location(l_proc, 70);
3606  end if;
3607           --
3608         else
3609           --
3610           -- No worker number found for assignment
3611           --
3612           close csr_get_work_no;
3613           hr_utility.set_message(801, 'HR_7390_ASG_NO_EMP_NO');
3614           hr_multi_message.add
3615            (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID'
3616       ,p_associated_column2 =>
3617       'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE');
3618           --
3619         end if;
3620         --
3621       end if; -- no exclusive error
3622      --
3623 if g_debug then
3624       hr_utility.set_location(l_proc, 90);
3625  end if;
3626      --
3627     end if;
3628   --
3629   -- Check if the applicant assignment is being converted to an employee
3630   -- assignment.
3631   --
3632   elsif (l_api_updating and
3633          nvl(per_asg_shd.g_old_rec.assignment_type, hr_api.g_varchar2)
3634          = 'A' and p_assignment_type = 'E') then
3635     --
3636     if hr_multi_message.no_exclusive_error
3637       (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID') then
3638       --
3639       -- For employee assignments validate or generate the assignment number
3640       --
3641       open csr_get_work_no;
3642       fetch csr_get_work_no into l_worker_number;
3643       --
3644       if csr_get_work_no%found then
3645        --
3646         close csr_get_work_no;
3647 if g_debug then
3648         hr_utility.set_location(l_proc, 60);
3649  end if;
3650         --
3651         hr_assignment.gen_new_ass_number
3652           (p_assignment_id       => p_assignment_id
3653           ,p_business_group_id   => p_business_group_id
3654           ,p_worker_number       => l_worker_number
3655           ,p_assignment_type     => p_assignment_type
3656           ,p_assignment_sequence => p_assignment_sequence
3657           ,p_assignment_number   => p_assignment_number);
3658         --
3659 if g_debug then
3660         hr_utility.set_location(l_proc, 70);
3661  end if;
3662         --
3663       else
3664         --
3665         -- No employee number found for assignment
3666         --
3667         close csr_get_work_no;
3668       --
3669         hr_utility.set_message(801, 'HR_7390_ASG_NO_EMP_NO');
3670         hr_multi_message.add
3671          (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID'
3672         ,p_associated_column2 =>
3673         'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE');
3674         --
3675       end if;
3676      --
3677     end if; -- no exclusive error
3678    --
3679 if g_debug then
3680     hr_utility.set_location(l_proc, 90);
3681  end if;
3682    --
3683   end if;
3684   --
3685 if g_debug then
3686   hr_utility.set_location(' Leaving:'|| l_proc, 91);
3687  end if;
3688   --
3689 end gen_chk_assignment_number;
3690 --
3691 --  ---------------------------------------------------------------------------
3692 --  |-----------------------< chk_assignment_category >------------------------|
3693 --  ---------------------------------------------------------------------------
3694 --
3695 PROCEDURE chk_assignment_category
3696   (p_assignment_id         in     per_all_assignments_f.assignment_id%TYPE
3697   ,p_assignment_type       in     per_all_assignments_f.assignment_type%TYPE
3698   ,p_effective_date        in     date
3699   ,p_assignment_category   in     per_assignments_f.assignment_category%TYPE
3700   ,p_object_version_number in     per_all_assignments_f.object_version_number%TYPE
3701   ,p_validation_start_date in     date
3702   ,p_validation_end_date   in     date) IS
3703   --
3704   l_proc          varchar2(72);
3705   l_api_updating  boolean;
3706   --
3707 BEGIN
3708   --
3709 if g_debug then
3710   l_proc :=  g_package||'chk_assignment_category';
3711   hr_utility.set_location('Entering:'|| l_proc, 10);
3712  end if;
3713   --
3714   -- Check if inserting or updating the assignment
3715   --
3716   l_api_updating := per_asg_shd.api_updating
3717          (p_assignment_id          => p_assignment_id
3718          ,p_effective_date         => p_effective_date
3719          ,p_object_version_number  => p_object_version_number);
3720   --
3721 if g_debug then
3722   hr_utility.set_location(l_proc, 30);
3723  end if;
3724   --
3725   -- Check if inserting or assignment type has changed
3726   --
3727   IF ((l_api_updating AND
3728        nvl(per_asg_shd.g_old_rec.assignment_category, hr_api.g_varchar2) <>
3729        nvl(p_assignment_category, hr_api.g_varchar2)) OR
3730       (NOT l_api_updating)) THEN
3731     --
3732 if g_debug then
3733     hr_utility.set_location(l_proc, 40);
3734  end if;
3735     --
3736     -- Check that assignment type is 'C' (Contingent Worker) and
3737    -- that the value entered exists in the CWK_ASG_CATEOGRY lookup
3738     --
3739     IF p_assignment_type = 'C' AND
3740       p_assignment_category IS NOT NULL THEN
3741       --
3742       IF hr_api.not_exists_in_dt_hr_lookups
3743         (p_effective_date         => p_effective_date
3744         ,p_validation_start_date  => p_validation_start_date
3745         ,p_validation_end_date    => p_validation_end_date
3746         ,p_lookup_type            => 'CWK_ASG_CATEGORY'
3747         ,p_lookup_code            => p_assignment_category) THEN
3748         --
3749         hr_utility.set_message(800,'HR_289642_INV_CWK_ASG_CAT');
3750         hr_utility.raise_error;
3751         --
3752       END IF;
3753     --
3754    -- Check that if the assignment type is not a CWK assignment that
3755    -- the assignment cateogory is blank.
3756    --
3757    ELSIF p_assignment_type <> 'C' AND
3758          p_assignment_category IS NOT NULL THEN
3759       --
3760       hr_utility.set_message(800,'HR_289643_CWK_ASG_CAT_NULL');
3761       hr_utility.raise_error;
3762       --
3763     END IF;
3764    --
3765   END IF;
3766   --
3767 if g_debug then
3768   hr_utility.set_location(' Leaving:'|| l_proc, 997);
3769  end if;
3770   --
3771 EXCEPTION
3772   --
3773   WHEN app_exception.application_exception THEN
3774     --
3775     IF hr_multi_message.exception_add
3776       (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_CATEGORY') THEN
3777       --
3778 if g_debug then
3779       hr_utility.set_location(' Leaving:'|| l_proc, 998);
3780  end if;
3781       --
3782       RAISE;
3783       --
3784     END IF;
3785     --
3786 if g_debug then
3787     hr_utility.set_location(' Leaving:'|| l_proc, 999);
3788  end if;
3789     --
3790 END chk_assignment_category;
3791 -- ----------------------------------------------------------------------------
3792 -- |----------------------< chk_assignment_status_type >----------------------|
3793 -- ----------------------------------------------------------------------------
3794 --
3795 --  Description:
3796 --    If the assignment status type id is passed in, then it is validated
3797 --    against the expected system status and business group, otherwise the
3798 --    default assignment status type id for the specified system status,
3799 --    business group and legislation code is returned.
3800 --
3801 --  Pre-conditions:
3802 --    None
3803 --
3804 --  In Arguments:
3805 --    p_assignment_status_type_id
3806 --    p_business_group_id
3807 --    p_legislation_code
3808 --    p_expected_system_status
3809 --
3810 --  Post Success:
3811 --    If assignment_status_type_id is valid or can be derived then processing
3812 --    continues
3813 --
3814 --  Post Failure:
3815 --    If assignment_status_type_id is not valid or cannot be derived then an
3816 --    application error is raised and processing is terminated
3817 --
3818 --  Access Status:
3819 --    HR Development Use Only.
3820 --
3821 --
3822 procedure chk_assignment_status_type
3823   (p_assignment_status_type_id in out nocopy number
3824   ,p_business_group_id         in     number
3825   ,p_legislation_code          in     varchar2
3826   ,p_expected_system_status    in     varchar2
3827   ) is
3828   --
3829   -- Declare cursors and local variables
3830   --
3831   -- Out variables
3832   --
3833   l_ast_business_group_id per_all_assignments_f.business_group_id%TYPE;
3834   l_per_system_status     per_assignment_status_types.per_system_status%TYPE;
3835   l_proc                  varchar2(72);
3836   --
3837   cursor csr_get_ast_details is
3838     select ast.per_system_status
3839          , ast.business_group_id
3840       from per_assignment_status_types ast
3841      where ast.assignment_status_type_id = p_assignment_status_type_id;
3842   --
3843 begin
3844 if g_debug then
3845   l_proc := g_package || 'chk_assignment_status_type';
3846   hr_utility.set_location('Entering:'|| l_proc, 1);
3847  end if;
3848   --
3849   if hr_multi_message.no_exclusive_error
3850        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
3851        ) then
3852   --
3853   -- If p_assignment_status_type_id is g_number then derive it's default value.
3854   --
3855   if nvl(p_assignment_status_type_id, hr_api.g_number) = hr_api.g_number then
3856     --
3857 if g_debug then
3858     hr_utility.set_location(l_proc, 10);
3859  end if;
3860     --
3861     -- Derive default value.
3862     --
3863 if g_debug then
3864     hr_utility.set_location(l_proc, 20);
3865  end if;
3866     --
3867     per_people3_pkg.get_default_person_type
3868       (p_required_type     => p_expected_system_status
3869       ,p_business_group_id => p_business_group_id
3870       ,p_legislation_code  => p_legislation_code
3871       ,p_person_type       => p_assignment_status_type_id
3872       );
3873   else
3874     --
3875 if g_debug then
3876     hr_utility.set_location(l_proc, 30);
3877  end if;
3878     --
3879     -- Validate that assignment status type id is for the expected system
3880     -- status in the assignment's business group.
3881     --
3882     open  csr_get_ast_details;
3883     fetch csr_get_ast_details
3884      into l_per_system_status
3885         , l_ast_business_group_id;
3886     --
3887     if csr_get_ast_details%NOTFOUND then
3888       --
3889 if g_debug then
3890       hr_utility.set_location(l_proc, 40);
3891  end if;
3892       --
3893       close csr_get_ast_details;
3894       --
3895       hr_utility.set_message(801,'HR_7940_ASG_INV_ASG_STAT_TYPE');
3896       hr_utility.raise_error;
3897       --
3898     elsif l_per_system_status <> p_expected_system_status
3899     then
3900       --
3901 if g_debug then
3902       hr_utility.set_location(l_proc, 50);
3903  end if;
3904       --
3905       close csr_get_ast_details;
3906       --
3907       hr_utility.set_message(801,'HR_7949_ASG_DIF_SYSTEM_TYPES');
3908       hr_utility.set_message_token('SYSTYPE', p_expected_system_status);
3909       hr_utility.raise_error;
3910       --
3911       --
3912     elsif nvl(l_ast_business_group_id, p_business_group_id) <>
3913           p_business_group_id
3914     then
3915       --
3916 if g_debug then
3917       hr_utility.set_location(l_proc, 60);
3918  end if;
3919       --
3920       close csr_get_ast_details;
3921       --
3922       hr_utility.set_message(801,'HR_7372_ASG_INV_BG_ASS_STATUS');
3923       hr_utility.raise_error;
3924     else
3925       --
3926 if g_debug then
3927       hr_utility.set_location(l_proc, 70);
3928  end if;
3929       --
3930       -- No error.
3931       --
3932       close csr_get_ast_details;
3933     end if;
3934     --
3935 if g_debug then
3936     hr_utility.set_location(l_proc, 80);
3937  end if;
3938   end if;
3939   end if;
3940   --
3941 if g_debug then
3942   hr_utility.set_location(' Leaving:'|| l_proc, 200);
3943  end if;
3944 end chk_assignment_status_type;
3945 --
3946 --  ---------------------------------------------------------------------------
3947 --  |--------------------< chk_assignment_status_type_id >--------------------|
3948 --  ---------------------------------------------------------------------------
3949 --
3950 procedure chk_assignment_status_type_id
3951   (p_rec                       in per_asg_shd.g_rec_type
3952   ,p_effective_date            in per_all_assignments_f.effective_start_date%TYPE
3953   ,p_validation_start_date     in per_all_assignments_f.effective_start_date%TYPE
3954   )
3955   is
3956 --
3957   l_api_updating          boolean;
3958   l_proc                  varchar2(72) :=
3959                                      g_package||'chk_assignment_status_type_id';
3960   l_exists            varchar2(1);
3961   --
3962   l_ast_legislation_code  per_business_groups.legislation_code%TYPE;
3963   l_bus_legislation_code  per_business_groups.legislation_code%TYPE;
3964   l_active_flag           per_assignment_status_types.active_flag%TYPE;
3965   l_ast_active_flag       per_assignment_status_types.active_flag%TYPE;
3966   l_business_group_id     per_all_assignments_f.business_group_id%TYPE;
3967   l_per_system_status     per_assignment_status_types.per_system_status%TYPE;
3968   l_ast_per_system_status per_assignment_status_types.per_system_status%TYPE;
3969   l_ast_business_group_id per_all_assignments_f.business_group_id%TYPE;
3970   l_old_per_system_status per_assignment_status_types.per_system_status%TYPE;
3971   l_initial_ins_date      per_all_assignments_f.effective_start_date%TYPE;
3972   l_apl_asg_min_esd       per_all_assignments_f.effective_start_date%TYPE;
3973   l_fir_dt_ast_pss        per_assignment_status_types.per_system_status%TYPE;
3974   --
3975   --  Cursor to check that a assignment status type exists in
3976   --  PER_ASSIGNMENT_STATUS_TYPES.
3977   --
3978   cursor csr_valid_ast is
3979     select   legislation_code, active_flag, business_group_id, per_system_status
3980     from     per_assignment_status_types
3981     where    assignment_status_type_id = p_rec.assignment_status_type_id;
3982   --
3983   --  Cursor to retrieve the legislation code of the assignment's
3984   --  business group.
3985   --
3986   cursor csr_get_bus_legislation_code is
3987     select legislation_code
3988     from   per_business_groups_perf
3989     where  business_group_id = p_rec.business_group_id;
3990   --
3991   --  Cursor to check if the assignment status type exists in
3992   --  PER_ASS_STATUS_TYPE_AMENDS for the assignment business group.
3993   --
3994   cursor csr_chk_amends is
3995     select   active_flag, per_system_status
3996     from     per_ass_status_type_amends
3997     where    assignment_status_type_id = p_rec.assignment_status_type_id
3998     and      business_group_id = p_rec.business_group_id;
3999   --
4000   --  Cursor to retrieve the existing PER_SYSTEM_STATUS for the
4001   --  assignment status type of the assignment.
4002   --
4003   cursor csr_get_old_per_system_type is
4004     select per_system_status
4005     from   per_assignment_status_types
4006     where  assignment_status_type_id =
4007            per_asg_shd.g_old_rec.assignment_status_type_id;
4008   --
4009   --  Cursor to retrieve the effective start date of
4010   --  the first assignment datetracked instance with assignment
4011   --  status type PER_SYSTEM_STATUS of 'ACTIVE_ASSIGN'
4012   --
4013   cursor csr_get_initial_ins_date is
4014     select nvl(min(asg.effective_start_date), hr_api.g_eot)
4015     from   per_all_assignments_f           asg
4016           ,per_assignment_status_types ast
4017     where asg.assignment_id             = p_rec.assignment_id
4018     and   ast.assignment_status_type_id = asg.assignment_status_type_id
4019     and   ast.per_system_status         = 'ACTIVE_ASSIGN';
4020   --
4021   -- Cursor to retrieve the earliest effective start date for an applicant
4022   -- assignment
4023   --
4024   cursor csr_get_apl_asg_min_esd is
4025     select min(effective_start_date)
4026     from per_all_assignments_f
4027     where assignment_id = p_rec.assignment_id
4028     and   assignment_type = 'A';
4029   --
4030   -- Cursor to retrieve the PER SYSTEM STATUS for the first datetracked
4031   -- instance of an applicant assignment.
4032   --
4033   cursor csr_get_fir_dt_inst_ast_pss
4034     (c_effective_start_date     per_all_assignments_f.effective_start_date%TYPE)
4035   is
4036     select ast.per_system_status
4037     from   per_all_assignments_f           asg
4038           ,per_assignment_status_types ast
4039     where asg.assignment_id             = p_rec.assignment_id
4040     and   asg.effective_start_date      = c_effective_start_date
4041     and   ast.assignment_status_type_id = asg.assignment_status_type_id;
4042   --
4043 begin
4044 if g_debug then
4045   hr_utility.set_location('Entering:'|| l_proc, 1);
4046  end if;
4047   --
4048   -- Check mandatory parameters have been set.
4049   --
4050   hr_api.mandatory_arg_error
4051     (p_api_name       => l_proc
4052     ,p_argument       => 'assignment_status_type_id'
4053     ,p_argument_value => p_rec.assignment_status_type_id
4054     );
4055   --
4056   hr_api.mandatory_arg_error
4057     (p_api_name       => l_proc
4058     ,p_argument       => 'effective_date'
4059     ,p_argument_value => p_effective_date
4060     );
4061   --
4062   hr_api.mandatory_arg_error
4063     (p_api_name       => l_proc
4064     ,p_argument       => 'validation_start_date'
4065     ,p_argument_value => p_validation_start_date
4066     );
4067   --
4068   hr_api.mandatory_arg_error
4069     (p_api_name       => l_proc
4070     ,p_argument       => 'business_group_id'
4071     ,p_argument_value => p_rec.business_group_id
4072     );
4073   --
4074 if g_debug then
4075   hr_utility.set_location(l_proc, 10);
4076  end if;
4077   --
4078   --  Check if the assignment is being updated.
4079   --
4080   l_api_updating := per_asg_shd.api_updating
4081          (p_assignment_id         => p_rec.assignment_id
4082          ,p_effective_date        => p_effective_date
4083          ,p_object_version_number => p_rec.object_version_number);
4084 if g_debug then
4085   hr_utility.set_location(l_proc, 15);
4086  end if;
4087   --
4088   --  Check if the assignment is being updated.
4089   --
4090   if l_api_updating then
4091     --
4092     -- Retrieve existing PER_SYSTEM_STATUS for the assignment status type
4093     -- of the assignment.
4094     --
4095     open  csr_get_old_per_system_type;
4096     fetch csr_get_old_per_system_type into l_old_per_system_status;
4097     close csr_get_old_per_system_type;
4098 if g_debug then
4099     hr_utility.set_location(l_proc, 20);
4100  end if;
4101     --
4102     --  Check if the assignment is an employee assignment
4103     --
4104     If p_rec.assignment_type = 'E' then
4105       --
4106       -- Check if the existing PER_SYSTEM_STATUS of the assignment status
4107       -- type is 'TERM_ASSIGN'.
4108       --
4109       if l_old_per_system_status = 'TERM_ASSIGN'
4110       then
4111         --
4112         -- Check that no other attributes have been changed.
4113         -- Note that the if ... statement has to be split because of server
4114         -- parser limitations.
4115         --
4116         if (p_rec.recruiter_id                                       <>
4117             per_asg_shd.g_old_rec.recruiter_id
4118           or  p_rec.grade_id                                         <>
4119             per_asg_shd.g_old_rec.grade_id
4120           or  p_rec.position_id                                      <>
4121             per_asg_shd.g_old_rec.position_id
4122           or  p_rec.job_id                                           <>
4123             per_asg_shd.g_old_rec.job_id
4124           or  p_rec.payroll_id                                       <>
4125             per_asg_shd.g_old_rec.payroll_id
4126           or  p_rec.location_id                                      <>
4127             per_asg_shd.g_old_rec.location_id
4128           or  p_rec.person_referred_by_id                            <>
4129             per_asg_shd.g_old_rec.person_referred_by_id
4130          --
4131          -- Fix for bug 3499996 starts here. coment out code.
4132          --
4133         --  or  p_rec.supervisor_id                                    <>
4134         --    per_asg_shd.g_old_rec.supervisor_id
4135          --
4136          -- Fix for bug 3499996 ends here.
4137          --
4138           or  p_rec.special_ceiling_step_id                          <>
4139             per_asg_shd.g_old_rec.special_ceiling_step_id
4140           or  p_rec.recruitment_activity_id                          <>
4141             per_asg_shd.g_old_rec.recruitment_activity_id
4142           or  p_rec.source_organization_id                           <>
4143             per_asg_shd.g_old_rec.source_organization_id
4144           or  p_rec.organization_id                                  <>
4145             per_asg_shd.g_old_rec.organization_id
4146           or  p_rec.people_group_id                                  <>
4147             per_asg_shd.g_old_rec.people_group_id
4148           -- Bug 4190473
4149           --or  p_rec.soft_coding_keyflex_id                         <>
4150           --  per_asg_shd.g_old_rec.soft_coding_keyflex_id
4151           or  p_rec.vacancy_id                                       <>
4152             per_asg_shd.g_old_rec.vacancy_id
4153           or  p_rec.pay_basis_id                                     <>
4154             per_asg_shd.g_old_rec.pay_basis_id
4155           or  p_rec.application_id                                   <>
4156             per_asg_shd.g_old_rec.application_id
4157           or  p_rec.assignment_number                                <>
4158             per_asg_shd.g_old_rec.assignment_number
4159           or  p_rec.change_reason                                    <>
4160             per_asg_shd.g_old_rec.change_reason
4161           or  p_rec.comment_text                                     <>
4162             per_asg_shd.g_old_rec.comment_text
4163           or  p_rec.date_probation_end                               <>
4164             per_asg_shd.g_old_rec.date_probation_end
4165           or  p_rec.default_code_comb_id                             <>
4166             per_asg_shd.g_old_rec.default_code_comb_id
4167           or  p_rec.employment_category                              <>
4168             per_asg_shd.g_old_rec.employment_category
4169           or  p_rec.frequency                                        <>
4170             per_asg_shd.g_old_rec.frequency
4171           or  p_rec.internal_address_line                            <>
4172             per_asg_shd.g_old_rec.internal_address_line
4173           or  p_rec.manager_flag                                     <>
4174             per_asg_shd.g_old_rec.manager_flag
4175           or  p_rec.normal_hours                                     <>
4176             per_asg_shd.g_old_rec.normal_hours
4177           or  p_rec.perf_review_period                               <>
4178             per_asg_shd.g_old_rec.perf_review_period
4179           or  p_rec.perf_review_period_frequency                     <>
4180             per_asg_shd.g_old_rec.perf_review_period_frequency
4181           or  p_rec.probation_period                                 <>
4182             per_asg_shd.g_old_rec.probation_period
4183           or  p_rec.probation_unit                                   <>
4184             per_asg_shd.g_old_rec.probation_unit
4185           or  p_rec.sal_review_period                                <>
4186             per_asg_shd.g_old_rec.sal_review_period
4187           or  p_rec.sal_review_period_frequency                      <>
4188             per_asg_shd.g_old_rec.sal_review_period_frequency
4189           or  p_rec.set_of_books_id                                  <>
4190             per_asg_shd.g_old_rec.set_of_books_id
4191           or  p_rec.source_type                                      <>
4192             per_asg_shd.g_old_rec.source_type
4193           or  p_rec.time_normal_finish                               <>
4194             per_asg_shd.g_old_rec.time_normal_finish
4195           or  p_rec.time_normal_start                                <>
4196             per_asg_shd.g_old_rec.time_normal_start
4197           or  p_rec.bargaining_unit_code                             <>
4198             per_asg_shd.g_old_rec.bargaining_unit_code
4199           or  p_rec.labour_union_member_flag                         <>
4200             per_asg_shd.g_old_rec.labour_union_member_flag
4201           or  p_rec.hourly_salaried_code                             <>
4202             per_asg_shd.g_old_rec.hourly_salaried_code
4203           or  p_rec.request_id                                       <>
4204             per_asg_shd.g_old_rec.request_id
4205           or  p_rec.program_application_id                           <>
4206             per_asg_shd.g_old_rec.program_application_id
4207           or  p_rec.program_id                                       <>
4208             per_asg_shd.g_old_rec.program_id
4209           or  p_rec.program_update_date                              <>
4210             per_asg_shd.g_old_rec.program_update_date
4211           or  p_rec.ass_attribute_category                           <>
4212             per_asg_shd.g_old_rec.ass_attribute_category
4213           )
4214           then
4215           --
4216           hr_utility.set_message(801, 'HR_7946_ASG_INV_TERM_ASS_UPD');
4217           hr_multi_message.add
4218           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4219      );
4220           --
4221 	-- fix for bug  4557189. Commented out code.
4222         elsif (
4223 	/*p_rec.ass_attribute1  <> per_asg_shd.g_old_rec.ass_attribute1
4224            or  p_rec.ass_attribute2  <> per_asg_shd.g_old_rec.ass_attribute2
4225            or  p_rec.ass_attribute3  <> per_asg_shd.g_old_rec.ass_attribute3
4226            or  p_rec.ass_attribute4  <> per_asg_shd.g_old_rec.ass_attribute4
4227            or  p_rec.ass_attribute5  <> per_asg_shd.g_old_rec.ass_attribute5
4228            or  p_rec.ass_attribute6  <> per_asg_shd.g_old_rec.ass_attribute6
4229            or  p_rec.ass_attribute7  <> per_asg_shd.g_old_rec.ass_attribute7
4230            or  p_rec.ass_attribute8  <> per_asg_shd.g_old_rec.ass_attribute8
4231            or  p_rec.ass_attribute9  <> per_asg_shd.g_old_rec.ass_attribute9
4232            or  p_rec.ass_attribute10 <> per_asg_shd.g_old_rec.ass_attribute10
4233            or  p_rec.ass_attribute11 <> per_asg_shd.g_old_rec.ass_attribute11
4234            or  p_rec.ass_attribute12 <> per_asg_shd.g_old_rec.ass_attribute12
4235            or  p_rec.ass_attribute13 <> per_asg_shd.g_old_rec.ass_attribute13
4236            or  p_rec.ass_attribute14 <> per_asg_shd.g_old_rec.ass_attribute14
4237            or  p_rec.ass_attribute15 <> per_asg_shd.g_old_rec.ass_attribute15
4238            or  p_rec.ass_attribute16 <> per_asg_shd.g_old_rec.ass_attribute16
4239            or  p_rec.ass_attribute17 <> per_asg_shd.g_old_rec.ass_attribute17
4240            or  p_rec.ass_attribute18 <> per_asg_shd.g_old_rec.ass_attribute18
4241            or  p_rec.ass_attribute19 <> per_asg_shd.g_old_rec.ass_attribute19
4242            or  p_rec.ass_attribute20 <> per_asg_shd.g_old_rec.ass_attribute20
4243            or  p_rec.ass_attribute21 <> per_asg_shd.g_old_rec.ass_attribute21
4244            or  p_rec.ass_attribute22 <> per_asg_shd.g_old_rec.ass_attribute22
4245            or  p_rec.ass_attribute23 <> per_asg_shd.g_old_rec.ass_attribute23
4246            or  p_rec.ass_attribute24 <> per_asg_shd.g_old_rec.ass_attribute24
4247            or  p_rec.ass_attribute25 <> per_asg_shd.g_old_rec.ass_attribute25
4248            or  p_rec.ass_attribute26 <> per_asg_shd.g_old_rec.ass_attribute26
4249            or  p_rec.ass_attribute27 <> per_asg_shd.g_old_rec.ass_attribute27
4250            or  p_rec.ass_attribute28 <> per_asg_shd.g_old_rec.ass_attribute28
4251            or  p_rec.ass_attribute29 <> per_asg_shd.g_old_rec.ass_attribute29
4252            or  p_rec.ass_attribute30 <> per_asg_shd.g_old_rec.ass_attribute30
4253            or */
4254 	 p_rec.title           <> per_asg_shd.g_old_rec.title
4255           )
4256           then
4257           --
4258           hr_utility.set_message(801, 'HR_7946_ASG_INV_TERM_ASS_UPD');
4259           hr_multi_message.add
4260           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4261      );
4262           --
4263         end if;
4264 if g_debug then
4265         hr_utility.set_location(l_proc, 25);
4266  end if;
4267         --
4268       end if;
4269       --
4270     else -- Applicant assignments
4271       --
4272       -- Retrieve the earliest effective start date of the applicant assignment
4273       --
4274       open csr_get_apl_asg_min_esd;
4275       fetch csr_get_apl_asg_min_esd into l_apl_asg_min_esd;
4276       close csr_get_apl_asg_min_esd;
4277 if g_debug then
4278       hr_utility.set_location(l_proc, 160);
4279  end if;
4280       --
4281       -- Check if the first dt instance of an applicant assignment has an
4282       -- assignment status type PER SYSTEM STATUS of 'TERM_APL'
4283       --
4284       open csr_get_fir_dt_inst_ast_pss(l_apl_asg_min_esd);
4285       fetch csr_get_fir_dt_inst_ast_pss into l_fir_dt_ast_pss;
4286       close csr_get_fir_dt_inst_ast_pss;
4287 if g_debug then
4288       hr_utility.set_location(l_proc, 170);
4289  end if;
4290       --
4291       If l_fir_dt_ast_pss = 'TERM_APL' then
4292         --
4293         hr_utility.set_message(801, 'HR_51275_ASG_INV_F_DT_AST_PSS');
4294         hr_multi_message.add
4295         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4296    );
4297         --
4298       end if;
4299 if g_debug then
4300       hr_utility.set_location(l_proc, 180);
4301  end if;
4302       --
4303     end if;
4304     --
4305   end if;
4306   --
4307   -- Only proceed with validation if :
4308   -- a) The current g_old_rec is current and
4309   -- b) The value for assignment status type has changed
4310   --
4311   if  (l_api_updating
4312     and  nvl(per_asg_shd.g_old_rec.assignment_status_type_id, hr_api.g_number)
4313          <> nvl(p_rec.assignment_status_type_id, hr_api.g_number)
4314       )
4315     or  not l_api_updating
4316   then
4317 if g_debug then
4318     hr_utility.set_location(l_proc, 30);
4319  end if;
4320     --
4321     -- Check if the assignment status type exists in
4322     -- PER_ASSIGNMENT_STATUS_TYPES.
4323     --
4324     open csr_valid_ast;
4325     fetch csr_valid_ast
4326     into l_ast_legislation_code
4327         ,l_ast_active_flag
4328         ,l_business_group_id
4329         ,l_ast_per_system_status;
4330     --
4331     if csr_valid_ast%notfound then
4332       close csr_valid_ast;
4333       hr_utility.set_message(801, 'HR_7940_ASG_INV_ASG_STAT_TYPE');
4334       hr_multi_message.add
4335         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4336    );
4337     else
4338       close csr_valid_ast;
4339     end if;
4340 if g_debug then
4341     hr_utility.set_location(l_proc, 40);
4342  end if;
4343     --
4344     -- Check that when set the business group for the assignment status type
4345     -- is the same as the business group of the assignment.
4346     --
4347     If l_business_group_id is not null
4348       and l_business_group_id <> p_rec.business_group_id then
4349       --
4350       hr_utility.set_message(801, 'HR_51207_ASG_INV_AST_BUS_GRP');
4351       hr_multi_message.add
4352         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4353    );
4354       --
4355     end if;
4356 if g_debug then
4357     hr_utility.set_location(l_proc, 50);
4358  end if;
4359     --
4360     -- Retrieve the legislation code for the business group of the assignment.
4361     --
4362     open  csr_get_bus_legislation_code;
4363     fetch csr_get_bus_legislation_code into l_bus_legislation_code;
4364     close csr_get_bus_legislation_code;
4365 if g_debug then
4366     hr_utility.set_location(l_proc, 60);
4367  end if;
4368     --
4369     if  l_ast_legislation_code is not null
4370     and (nvl(l_bus_legislation_code, l_ast_legislation_code) <>
4371              l_ast_legislation_code)
4372     then
4373       --
4374       hr_utility.set_message(801, 'HR_7964_ASG_INV_BUS_ATT_LEG');
4375       hr_multi_message.add;
4376       --
4377     end if;
4378 if g_debug then
4379     hr_utility.set_location(l_proc, 70);
4380  end if;
4381     --
4382     -- Check if the assignment status type exists in
4383     -- PER_ASS_STATUS_TYPE_AMENDS for the assignment business group.
4384     --
4385     open csr_chk_amends;
4386     fetch csr_chk_amends into l_active_flag, l_per_system_status;
4387     if csr_chk_amends%notfound then
4388       --
4389       --  Use active flag and business group values from
4390       --  PER_ASSIGNMENT_STATUS_TYPES for the assignment status type.
4391       --
4392       l_active_flag       := l_ast_active_flag;
4393       l_per_system_status := l_ast_per_system_status;
4394       --
4395     end if;
4396     close csr_chk_amends;
4397 if g_debug then
4398     hr_utility.set_location(l_proc, 80);
4399  end if;
4400     --
4401     -- Check that active flag for the assignment status type is set to 'Y'
4402     --
4403     If l_active_flag <> 'Y' then
4404       --
4405       hr_utility.set_message(801, 'HR_51206_ASG_INV_AST_ACT_FLG');
4406       hr_multi_message.add
4407         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4408    );
4409       --
4410     end if;
4411 if g_debug then
4412     hr_utility.set_location(l_proc, 90);
4413  end if;
4414     --
4415     --  Check if the assignment is an employee assignment
4416     --
4417     If p_rec.assignment_type = 'E' then
4418       --
4419       -- Check if updating the employee assignment
4420       --
4421       if l_api_updating then
4422         --
4423         -- Check that the PER_SYSTEM_STATUS is one of the following:
4424         --   'ACTIVE_ASSIGN', 'SUSP_ASSIGN' and 'TERM_ASSIGN'.
4425         --
4426         if  l_per_system_status <> 'ACTIVE_ASSIGN'
4427           and l_per_system_status <> 'SUSP_ASSIGN'
4428           and l_per_system_status <> 'TERM_ASSIGN'
4429         then
4430           --
4431           hr_utility.set_message(801, 'HR_7917_ASG_INV_STAT_TYPE');
4432           hr_multi_message.add
4433           (p_associated_column1 =>
4434      'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4435      );
4436           --
4437         end if;
4438 if g_debug then
4439         hr_utility.set_location(l_proc, 100);
4440  end if;
4441         --
4442         -- Check that the new PER_SYSTEM_STATUS for the assignment status type
4443         -- of the employee assignment is also 'TERM_ASSIGN' when the existing
4444         -- PER_SYSTEM_STATUS is 'TERM_ASSIGN'.
4445         --
4446         if  l_old_per_system_status  = 'TERM_ASSIGN'
4447           and l_per_system_status     <> 'TERM_ASSIGN'
4448           then
4449             --
4450             hr_utility.set_message(801, 'HR_7942_ASG_INV_STAT_NOT_TERM');
4451             hr_multi_message.add
4452             (p_associated_column1 =>
4453        'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4454        );
4455             --
4456         end if;
4457 if g_debug then
4458         hr_utility.set_location(l_proc, 110);
4459  end if;
4460         --
4461         -- Check that the change of assignment_status_type_id to represent a
4462         -- per_system_status other than ACTIVE_ASSIGN is not effective as of the
4463         -- date of the initial insert.
4464         --
4465         if l_per_system_status <> 'ACTIVE_ASSIGN'
4466           then
4467           --
4468           --  Retrieve the effective start date of the first assignment
4469           --  datetracked instance with assignment status type PER_SYSTEM_STATUS
4470           --  of 'ACTIVE_ASSIGN'.
4471           --
4472           open  csr_get_initial_ins_date;
4473           fetch csr_get_initial_ins_date into  l_initial_ins_date;
4474           close csr_get_initial_ins_date;
4475 if g_debug then
4476           hr_utility.set_location(l_proc, 120);
4477  end if;
4478           --
4479           if p_validation_start_date <= l_initial_ins_date
4480           then
4481             --
4482             hr_utility.set_message(800,'HR_7915_ASG_INV_STAT_UPD_DATE');
4483             hr_multi_message.add
4484             (p_associated_column1 =>
4485        'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4486        ,p_associated_column2 =>
4487        'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
4488        );
4489             --
4490           end if;
4491 if g_debug then
4492           hr_utility.set_location(l_proc, 130);
4493  end if;
4494           --
4495         end if;
4496 if g_debug then
4497         hr_utility.set_location(l_proc, 150);
4498  end if;
4499         --
4500       else  -- Inserting Employee assignment
4501         --
4502         -- Check that the per_system_status is 'ACTIVE_ASSIGN'
4503         --
4504         if l_per_system_status <> 'ACTIVE_ASSIGN'
4505           then
4506           --
4507           hr_utility.set_message(801, 'HR_7941_ASG_INV_STAT_NOT_ACT');
4508           hr_multi_message.add
4509             (p_associated_column1 =>
4510        'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4511        );
4512           --
4513         end if;
4514         --
4515       end if;
4516 if g_debug then
4517       hr_utility.set_location(l_proc, 160);
4518  end if;
4519     elsif p_rec.assignment_type = 'B' then
4520       --
4521       -- <OAB_CHANGE> - Extend restriction to allow assignment type 'B'
4522       --                NB For 'B' assignments no validation is performed on
4523       --                assignment status type.
4524       null;
4525     --
4526    -- If the assigment type is a non payrolled worker then
4527    -- check to see if the assignment_status is valid
4528    --
4529     ELSIF p_rec.assignment_type = 'C' THEN
4530      --
4531 if g_debug then
4532       hr_utility.set_location(l_proc, 170);
4533  end if;
4534      --
4535      -- If Updating then check that the assignment status type id
4536      -- is set to either ACTIVE_NPW_ASG or SUSP_NPW_ASG
4537      --
4538      IF l_api_updating THEN
4539        --
4540 if g_debug then
4541       hr_utility.set_location(l_proc, 180);
4542  end if;
4543       --
4544       IF l_per_system_status NOT IN ('ACTIVE_CWK','SUSP_CWK_ASG') AND
4545            l_old_per_system_status  = 'ACTIVE_CWK' THEN
4546           --
4547         hr_utility.set_message(801, 'HR_289644_CWL_INV_ASS_STAT_TYP');
4548           hr_utility.raise_error;
4549         --
4550       END IF;
4551       --
4552      ELSE -- Inserting
4553        --
4554 if g_debug then
4555       hr_utility.set_location(l_proc, 190);
4556  end if;
4557       --
4558       IF l_per_system_status <> 'ACTIVE_CWK' THEN
4559         --
4560         hr_utility.set_message(801, 'HR_289645_CWK_INV_INS_ASS_TYPE');
4561           hr_utility.raise_error;
4562         --
4563       END IF;
4564       --
4565      END IF;
4566      --
4567     else  -- Applicant assignments
4568       --
4569       -- Check if updating
4570       --
4571       If l_api_updating then
4572         --
4573         -- Check that assignment status type is either 'ACTIVE_APL', 'OFFER'
4574         -- or 'ACCEPTED'.
4575     -- New functionality means that assignment status types of
4576     -- 'INTERVIEW1' and 'INTERVIEW2' are also allowed
4577         --
4578         if  l_per_system_status <> 'ACTIVE_APL'
4579           and l_per_system_status <> 'OFFER'
4580           and l_per_system_status <> 'ACCEPTED'
4581       and l_per_system_status <> 'INTERVIEW1'
4582       and l_per_system_status <> 'INTERVIEW2'
4583           then
4584           hr_utility.set_message(801, 'HR_51232_ASG_INV_AASG_AST');
4585           hr_multi_message.add
4586             (p_associated_column1 =>
4587        'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_STATUS_TYPE_ID'
4588        );
4589           --
4590         end if;
4591 if g_debug then
4592         hr_utility.set_location(l_proc, 170);
4593  end if;
4594         --
4595       end if;
4596       --
4597     end if;
4598     --
4599   end if;
4600 if g_debug then
4601   hr_utility.set_location(' Leaving:'|| l_proc, 220);
4602  end if;
4603   --
4604 end chk_assignment_status_type_id;
4605 --
4606 --  ---------------------------------------------------------------------------
4607 --  |-----------------------< chk_assignment_type >---------------------------|
4608 --  ---------------------------------------------------------------------------
4609 --
4610 procedure chk_assignment_type
4611   (p_assignment_id         in     per_all_assignments_f.assignment_id%TYPE
4612   ,p_assignment_type       in     per_all_assignments_f.assignment_type%TYPE
4613   ,p_person_id             in     per_all_assignments_f.person_id%TYPE
4614   ,p_effective_date        in     date
4615   ,p_object_version_number in     per_all_assignments_f.object_version_number%TYPE
4616   ,p_validation_start_date in     date
4617   )
4618 is
4619   --
4620   l_proc                varchar2(72)  :=  g_package||'chk_assignment_type';
4621   l_api_updating        boolean;
4622   l_system_person_type  per_person_types.system_person_type%TYPE;
4623   --
4624   cursor csr_get_sys_per_typ is
4625     select   pet.system_person_type
4626     from     per_people_f per,
4627              per_person_types pet
4628     where    per.person_id      = p_person_id
4629     and      per.person_type_id = pet.person_type_id
4630     and      p_validation_start_date
4631       between  effective_start_date
4632         and    effective_end_date;
4633   --
4634 begin
4635   --
4636 if g_debug then
4637   hr_utility.set_location('Entering:'|| l_proc, 10);
4638  end if;
4639   --
4640   -- Check mandatory parameters have been set
4641   --
4642   hr_api.mandatory_arg_error
4643     (p_api_name       => l_proc
4644     ,p_argument       => 'assignment_type'
4645 
4646     ,p_argument_value => p_assignment_type
4647     );
4648 if g_debug then
4649   hr_utility.set_location(l_proc, 20);
4650  end if;
4651   --
4652   -- Check if inserting or updating the assignment
4653   --
4654   l_api_updating := per_asg_shd.api_updating
4655          (p_assignment_id          => p_assignment_id
4656          ,p_effective_date         => p_effective_date
4657          ,p_object_version_number  => p_object_version_number
4658          );
4659 if g_debug then
4660   hr_utility.set_location(l_proc, 30);
4661  end if;
4662   --
4663   -- Check if inserting or assignment type has changed
4664   --
4665   if ((l_api_updating and
4666      nvl(per_asg_shd.g_old_rec.assignment_type, hr_api.g_varchar2) <>
4667      nvl(p_assignment_type, hr_api.g_varchar2))
4668    or
4669      (NOT l_api_updating))
4670   then
4671 if g_debug then
4672     hr_utility.set_location(l_proc, 40);
4673  end if;
4674     --
4675     -- Check that assignment type is either 'E' or 'A'
4676     --
4677     --
4678     -- <OAB_CHANGE> - Extend restriction to allow assignment type 'B'
4679     -- Extend restriction to allow assignment type 'O' (Offers)
4680     --
4681     If p_assignment_type not in('E','A','B','C','O') then
4682       --
4683       per_asg_shd.constraint_error
4684         (p_constraint_name => 'PER_ASS_ASSIGNMENT_TYPE_CHK');
4685       --
4686     end if;
4687 if g_debug then
4688     hr_utility.set_location(l_proc, 50);
4689  end if;
4690     --
4691     open csr_get_sys_per_typ;
4692     fetch csr_get_sys_per_typ into l_system_person_type;
4693     close csr_get_sys_per_typ;
4694 if g_debug then
4695     hr_utility.set_location(l_proc, 60);
4696  end if;
4697     --
4698     -- Check for an applicant or offer assignment
4699     --
4700     if   p_assignment_type = 'A'
4701       or p_assignment_type = 'O' then
4702       --
4703       -- Check the system person type of the person of the applicant
4704       -- assignment.
4705       --
4706       if l_system_person_type
4707         not in ('APL', 'APL_EX_APL', 'EMP_APL', 'EX_EMP_APL')
4708       then
4709         --
4710         hr_utility.set_message(801, 'HR_51294_ASG_INV_AASG_PET');
4711         hr_utility.raise_error;
4712         --
4713 
4714       end if;
4715 if g_debug then
4716       hr_utility.set_location(l_proc, 70);
4717  end if;
4718       --
4719     elsif p_assignment_type = 'B' then -- benefit assignments
4720       --
4721       -- <OAB_CHANGE> - No person type validation required
4722       --
4723       null;
4724     --
4725    -- When assignment is for contingent labour, check that the
4726     -- person type usage of the person on the assignment is 'CWK'.
4727       --
4728    ELSIF p_assignment_type = 'C' THEN
4729       --
4730 if g_debug then
4731      hr_utility.set_location(l_proc, 75);
4732  end if;
4733       --
4734       -- If the person is not a contractor then raise an error
4735       --
4736       IF NOT hr_general2.is_person_type(p_person_id,'CWK',p_effective_date) THEN
4737        --
4738       hr_utility.set_message(801, 'HR_289646_PER_TYPE_NOT_CWK');
4739         hr_utility.raise_error;
4740       --
4741      END IF;
4742      --
4743     else -- employee assignments
4744       --
4745       -- Check the system person type of the person of the employee
4746       -- assignment.
4747       --
4748       if l_system_person_type
4749         not in ('EMP', 'EMP_APL', 'EX_EMP')
4750       then
4751         --
4752         hr_utility.set_message(801, 'HR_51329_ASG_INV_EASG_PET');
4753 
4754         hr_utility.raise_error;
4755         --
4756       end if;
4757 if g_debug then
4758       hr_utility.set_location(l_proc, 80);
4759  end if;
4760       --
4761     end if;
4762 if g_debug then
4763     hr_utility.set_location(l_proc, 90);
4764  end if;
4765     --
4766   end if;
4767 if g_debug then
4768   hr_utility.set_location(' Leaving:'|| l_proc, 100);
4769  end if;
4770   exception
4771   when app_exception.application_exception then
4772     if hr_multi_message.exception_add
4773          (p_associated_column1      =>
4774     'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
4775     ,p_associated_column2      => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID'
4776          ) then
4777 if g_debug then
4778       hr_utility.set_location(' Leaving:'|| l_proc, 110);
4779  end if;
4780       raise;
4781     end if;
4782 if g_debug then
4783     hr_utility.set_location(' Leaving:'|| l_proc, 120);
4784  end if;
4785 --
4786 end chk_assignment_type;
4787 --
4788 --  ---------------------------------------------------------------------------
4789 --  |-------------------------< chk_change_reason >---------------------------|
4790 --  ---------------------------------------------------------------------------
4791 --
4792 procedure chk_change_reason
4793   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
4794   ,p_assignment_type        in     per_all_assignments_f.assignment_type%TYPE
4795   ,p_change_reason          in     per_all_assignments_f.change_reason%TYPE
4796   ,p_effective_date         in     date
4797   ,p_validation_start_date  in     date
4798   ,p_validation_end_date    in     date
4799   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
4800   )
4801   is
4802   --
4803    l_api_updating   boolean;
4804    l_proc           varchar2(72)  :=  g_package||'chk_change_reason';
4805   --
4806 begin
4807 if g_debug then
4808   hr_utility.set_location('Entering:'|| l_proc, 10);
4809  end if;
4810   --
4811   -- Check mandatory arguments
4812   --
4813   hr_api.mandatory_arg_error
4814     (p_api_name       => l_proc
4815     ,p_argument       => 'effective_date'
4816     ,p_argument_value => p_effective_date
4817     );
4818   --
4819   hr_api.mandatory_arg_error
4820     (p_api_name       =>  l_proc
4821     ,p_argument       =>  'validation_start_date'
4822     ,p_argument_value =>  p_validation_start_date
4823     );
4824   --
4825   hr_api.mandatory_arg_error
4826     (p_api_name        =>  l_proc
4827     ,p_argument       =>  'validation_end_date'
4828     ,p_argument_value =>  p_validation_end_date
4829     );
4830 if g_debug then
4831   hr_utility.set_location(l_proc, 20);
4832  end if;
4833   --
4834   l_api_updating := per_asg_shd.api_updating
4835          (p_assignment_id          => p_assignment_id
4836          ,p_effective_date         => p_effective_date
4837          ,p_object_version_number  => p_object_version_number
4838          );
4839 if g_debug then
4840   hr_utility.set_location(l_proc, 30);
4841  end if;
4842   --
4843   if ((l_api_updating and
4844      nvl(per_asg_shd.g_old_rec.change_reason, hr_api.g_varchar2) <>
4845      nvl(p_change_reason, hr_api.g_varchar2))
4846    or
4847      (NOT l_api_updating))
4848    then
4849 if g_debug then
4850     hr_utility.set_location(l_proc, 40);
4851  end if;
4852     --
4853     -- Check if the change reason is set
4854     --
4855     if p_change_reason is not null then
4856       --
4857       -- Check if the assignment is an employee or benefits assignment.
4858       --
4859       if p_assignment_type in ('E','B') then
4860         --
4861         -- Check that the change reason exists in hr_lookups for the
4862         -- lookup type 'EMP_ASSIGN_REASON' with an enabled flag set to 'Y'
4863         -- and that the effective strt date of the assignment is between
4864         -- start date active and end date active in hr_lookups.
4865         --
4866         if hr_api.not_exists_in_dt_hr_lookups
4867           (p_effective_date        => p_effective_date
4868           ,p_validation_start_date => p_validation_start_date
4869           ,p_validation_end_date   => p_validation_end_date
4870           ,p_lookup_type           => 'EMP_ASSIGN_REASON'
4871           ,p_lookup_code           => p_change_reason
4872           )
4873         then
4874           --
4875           hr_utility.set_message(801, 'HR_51228_ASG_INV_EASG_CH_REAS');
4876           hr_utility.raise_error;
4877           --
4878         end if;
4879 if g_debug then
4880         hr_utility.set_location(l_proc, 50);
4881  end if;
4882         --
4883       ELSIF p_assignment_type = 'C' THEN
4884        --
4885 if g_debug then
4886       hr_utility.set_location(l_proc, 50);
4887  end if;
4888       --
4889       -- Check that the change reason exists in hr_lookups for the
4890         -- lookup type 'CWK_ASSIGN_REASON' with an enabled flag set to 'Y'
4891         -- and that the effective start date of the assignment is between
4892         -- start date active and end date active in hr_lookups.
4893         --
4894         IF hr_api.not_exists_in_dt_hr_lookups
4895           (p_effective_date        => p_effective_date
4896           ,p_validation_start_date => p_validation_start_date
4897           ,p_validation_end_date   => p_validation_end_date
4898           ,p_lookup_type           => 'CWK_ASSIGN_REASON'
4899           ,p_lookup_code           => p_change_reason) THEN
4900           --
4901 if g_debug then
4902         hr_utility.set_location(l_proc, 52);
4903  end if;
4904         --
4905         hr_utility.set_message(800, 'HR_289647_INV_CWK_CH_REASON');
4906           hr_utility.raise_error;
4907           --
4908         END IF;
4909       --
4910       else -- applicant assignment
4911         --
4912         -- Check that the change reason exists in hr_lookups for the
4913         -- lookup type 'APL_ASSIGN_REASON' with an enabled flag set to 'Y'
4914         -- and that the effective strt date of the assignment is between
4915         -- start date active and end date active in hr_lookups.
4916         --
4917         if hr_api.not_exists_in_dt_hr_lookups
4918           (p_effective_date        => p_effective_date
4919           ,p_validation_start_date => p_validation_start_date
4920           ,p_validation_end_date   => p_validation_end_date
4921           ,p_lookup_type           => 'APL_ASSIGN_REASON'
4922           ,p_lookup_code           => p_change_reason
4923           )
4924         then
4925           --
4926           hr_utility.set_message(801, 'HR_51229_ASG_INV_AASG_CH_REAS');
4927            hr_utility.raise_error;
4928           --
4929         end if;
4930 if g_debug then
4931         hr_utility.set_location(l_proc, 60);
4932  end if;
4933         --
4934       end if;
4935 if g_debug then
4936       hr_utility.set_location(l_proc, 70);
4937  end if;
4938     end if;
4939   end if;
4940   --
4941 if g_debug then
4942   hr_utility.set_location(' Leaving:'|| l_proc, 80);
4943  end if;
4944   exception
4945   when app_exception.application_exception then
4946     if hr_multi_message.exception_add
4947          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.CHANGE_REASON'
4948          ) then
4949 if g_debug then
4950       hr_utility.set_location(' Leaving:'|| l_proc, 90);
4951  end if;
4952       raise;
4953     end if;
4954 if g_debug then
4955     hr_utility.set_location(' Leaving:'|| l_proc, 100);
4956  end if;
4957 --
4958 end chk_change_reason;
4959 --
4960 --  ---------------------------------------------------------------------------
4961 --  |-------------------------< chk_contig_ass >------------------------------|
4962 --  ---------------------------------------------------------------------------
4963 --
4964 --  Description:
4965 --    Validates that if an attempt is made to date effectively delete
4966 --    a primary assignment, another contiguous non-primary assignment must
4967 --    exist in order to be converted to a primary assignment.
4968 --
4969 --  Pre-conditions:
4970 --    None
4971 --
4972 --  In Arguments:
4973 --    p_primary_flag
4974 --    p_person_id
4975 --    p_effective_date
4976 --    p_datetrack_mode
4977 --
4978 --  Post Success:
4979 --    If a contiguous non-primary assignment can be found then processing
4980 --    continues.
4981 --
4982 --  Post Failure:
4983 --    If no contiguous non-primary assignments can be found then an
4984 --    application error is raised and processing is terminated.
4985 --
4986 --  Access Status:
4987 --    Internal Table Handler Use Only.
4988 --
4989 procedure chk_contig_ass
4990   (p_primary_flag   in per_all_assignments_f.primary_flag%TYPE
4991   ,p_person_id      in per_all_assignments_f.person_id%TYPE
4992   ,p_effective_date in date
4993   ,p_datetrack_mode in varchar2
4994   )
4995   is
4996 --
4997    l_exists         varchar2(1);
4998    l_proc           varchar2(72)  :=  g_package||'chk_contig_ass';
4999 --
5000    cursor csr_chk_contig_ass is
5001 
5002      select   null
5003      from     sys.dual
5004      where exists(select  null
5005                   from    per_all_assignments_f pas
5006                   ,       per_periods_of_service ppos
5007                   where   pas.effective_start_date <= p_effective_date
5008                   and     ppos.period_of_service_id = pas.period_of_service_id
5009                   and     pas.person_id = p_person_id
5010                   and     pas.primary_flag = 'N'
5011                   and (exists(select null
5012                               from   per_all_assignments_f pas2
5013                               ,      per_periods_of_service ppos2
5014                               where  pas2.effective_end_date =
5015                                 nvl(ppos2.actual_termination_date, hr_api.g_eot)
5016                               and    pas.assignment_id = pas2.assignment_id
5017                               and    pas2.period_of_service_id = ppos2.period_of_service_id )));  -- Added this last filter for Bug 4300591.
5018 --
5019 begin
5020 if g_debug then
5021   hr_utility.set_location('Entering:'|| l_proc, 1);
5022  end if;
5023   --
5024   -- Check mandatory parameters have been set
5025   --
5026   hr_api.mandatory_arg_error
5027     (p_api_name       => l_proc
5028     ,p_argument       => 'primary_flag'
5029     ,p_argument_value => p_primary_flag
5030     );
5031   --
5032 if g_debug then
5033   hr_utility.set_location(l_proc, 2);
5034  end if;
5035   --
5036   -- Check that contiguous non-primary assignment exists
5037   --
5038   if p_datetrack_mode = 'DELETE' and p_primary_flag = 'Y' then
5039     open csr_chk_contig_ass;
5040     fetch csr_chk_contig_ass into l_exists;
5041     if csr_chk_contig_ass%notfound then
5042       close csr_chk_contig_ass;
5043       hr_utility.set_message(801, 'HR_7392_ASG_INV_DEL_OF_ASS');
5044       hr_utility.raise_error;
5045     end if;
5046     close csr_chk_contig_ass;
5047   end if;
5048   --
5049 if g_debug then
5050   hr_utility.set_location(' Leaving:'|| l_proc, 3);
5051  end if;
5052   exception
5053   when app_exception.application_exception then
5054     if hr_multi_message.exception_add
5055          (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.PERSON_ID'
5056     ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
5057          ) then
5058 if g_debug then
5059       hr_utility.set_location(' Leaving:'|| l_proc, 4);
5060  end if;
5061       raise;
5062     end if;
5063 if g_debug then
5064     hr_utility.set_location(' Leaving:'|| l_proc, 5);
5065  end if;
5066 end chk_contig_ass;
5067 --
5068 --  ---------------------------------------------------------------------------
5069 --  |---------------------< chk_date_probation_end >--------------------------|
5070 --  ---------------------------------------------------------------------------
5071 --
5072 procedure chk_date_probation_end
5073   (p_assignment_id         in     per_all_assignments_f.assignment_id%TYPE
5074   ,p_date_probation_end    in     per_all_assignments_f.date_probation_end%TYPE
5075   ,p_assignment_type       in     per_all_assignments_f.assignment_type%TYPE
5076   ,p_probation_period      in     per_all_assignments_f.probation_period%TYPE
5077   ,p_probation_unit        in     per_all_assignments_f.probation_unit%TYPE
5078   ,p_validation_start_date in     date
5079   ,p_effective_date        in     date
5080   ,p_object_version_number in     per_all_assignments_f.object_version_number%TYPE
5081   )
5082 is
5083   --
5084   l_proc               varchar2(72)  :=  g_package||'chk_date_probation_end';
5085   l_api_updating       boolean;
5086   --
5087   l_min_effective_start_date   date;
5088   --
5089   cursor csr_get_min_asg_esd is
5090     select   min(effective_start_date)
5091     from     per_all_assignments_f
5092     where    assignment_id = p_assignment_id;
5093   --
5094 begin
5095 if g_debug then
5096   hr_utility.set_location('Entering:'|| l_proc, 10);
5097  end if;
5098   --
5099   -- Check mandatory parameters have been set
5100   --
5101   hr_api.mandatory_arg_error
5102     (p_api_name       => l_proc
5103     ,p_argument       => 'assignment_type'
5104     ,p_argument_value => p_assignment_type
5105     );
5106   --
5107   hr_api.mandatory_arg_error
5108     (p_api_name       => l_proc
5109     ,p_argument       => 'validation_start_date'
5110     ,p_argument_value => p_validation_start_date
5111     );
5112   --
5113   hr_api.mandatory_arg_error
5114     (p_api_name       => l_proc
5115     ,p_argument       => 'effective_date'
5116     ,p_argument_value => p_effective_date
5117     );
5118 if g_debug then
5119   hr_utility.set_location(l_proc, 20);
5120  end if;
5121   --
5122   -- Only proceed with validation if :
5123   -- a) The current g_old_rec is current and
5124   -- b) The value for date probation end has changed
5125   --
5126   l_api_updating := per_asg_shd.api_updating
5127         (p_assignment_id          => p_assignment_id
5128         ,p_effective_date         => p_effective_date
5129         ,p_object_version_number  => p_object_version_number);
5130   --
5131   if ((l_api_updating and
5132        nvl(per_asg_shd.g_old_rec.date_probation_end, hr_api.g_date)
5133        <> nvl(p_date_probation_end, hr_api.g_date))
5134     or
5135       (NOT l_api_updating))
5136     then
5137 if g_debug then
5138     hr_utility.set_location(l_proc, 30);
5139  end if;
5140     --
5141     -- Check if date probation end is not null
5142     --
5143     if p_date_probation_end is not null then
5144       --
5145       -- Check if the assignment is being inserted or updated
5146       --
5147       If l_api_updating then
5148         --
5149         -- Check that date probation end is the same as or after the
5150         -- earliest effective start date for all date tracked instances
5151         -- of the assignment being updated.
5152         --
5153         open csr_get_min_asg_esd;
5154         fetch csr_get_min_asg_esd into l_min_effective_start_date;
5155         close csr_get_min_asg_esd;
5156 if g_debug then
5157         hr_utility.set_location(l_proc, 40);
5158  end if;
5159         --
5160         if p_date_probation_end < l_min_effective_start_date then
5161           --
5162           hr_utility.set_message(801, 'HR_51147_ASG_DPE_BEF_MIN_ESD');
5163           hr_multi_message.add
5164           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.DATE_PROBATION_END'
5165      );
5166           --
5167         end if;
5168 if g_debug then
5169         hr_utility.set_location(l_proc, 50);
5170  end if;
5171         --
5172       else
5173         --
5174         -- Checks that the date probation end is the same as or after the
5175         -- validation start date on insert.
5176         --
5177         if p_date_probation_end < p_validation_start_date then
5178           --
5179           hr_utility.set_message(801, 'HR_51147_ASG_DPE_BEF_MIN_ESD');
5180           hr_multi_message.add
5181           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.DATE_PROBATION_END'
5182      ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
5183      );
5184           --
5185         end if;
5186 if g_debug then
5187         hr_utility.set_location(l_proc, 60);
5188  end if;
5189         --
5190       end if;
5191 if g_debug then
5192       hr_utility.set_location(l_proc, 70);
5193  end if;
5194       --
5195     end if;
5196 if g_debug then
5197     hr_utility.set_location(l_proc, 80);
5198  end if;
5199     --
5200   end if;
5201   --
5202 if g_debug then
5203   hr_utility.set_location(' Leaving:'|| l_proc, 90);
5204  end if;
5205 --
5206 end chk_date_probation_end;
5207 --
5208 --  ---------------------------------------------------------------------------
5209 --  |--------------------< chk_default_code_comb_id >-------------------------|
5210 --  ---------------------------------------------------------------------------
5211 --
5212 procedure chk_default_code_comb_id
5213   (p_assignment_id           in     per_all_assignments_f.assignment_id%TYPE
5214   ,p_default_code_comb_id    in     per_all_assignments_f.default_code_comb_id%TYPE
5215   ,p_assignment_type         in     per_all_assignments_f.assignment_type%TYPE
5216   ,p_effective_date          in     date
5217   ,p_validation_start_date   in     date
5218   ,p_object_version_number   in     per_all_assignments_f.object_version_number%TYPE
5219   )
5220 is
5221   --
5222   l_api_updating   boolean;
5223   l_proc           varchar2(72)  :=  g_package||'chk_default_code_comb_id';
5224   l_exists         varchar2(1);
5225   --
5226   cursor csr_valid_def_cod_comb is
5227     select   null
5228     from     gl_code_combinations
5229     where    code_combination_id = p_default_code_comb_id
5230     and      enabled_flag = 'Y'
5231     and      p_validation_start_date
5232       between nvl(start_date_active,hr_api.g_sot)
5233         and     nvl(end_date_active,hr_api.g_eot);
5234   --
5235 begin
5236 if g_debug then
5237   hr_utility.set_location('Entering:'|| l_proc, 10);
5238  end if;
5239   --
5240   -- Check mandatory parameters have been set
5241   --
5242   hr_api.mandatory_arg_error
5243     (p_api_name       => l_proc
5244     ,p_argument       => 'effective_date'
5245     ,p_argument_value => p_effective_date
5246     );
5247 if g_debug then
5248   hr_utility.set_location(l_proc, 20);
5249  end if;
5250   --
5251   -- Only proceed with validation if :
5252   -- a) The current g_old_rec is current and
5253   -- b) The value for default code comb has changed
5254   --
5255   l_api_updating := per_asg_shd.api_updating
5256          (p_assignment_id          => p_assignment_id
5257          ,p_effective_date         => p_effective_date
5258          ,p_object_version_number  => p_object_version_number
5259          );
5260 if g_debug then
5261   hr_utility.set_location(l_proc, 30);
5262  end if;
5263   --
5264   if ((l_api_updating and
5265        nvl(per_asg_shd.g_old_rec.default_code_comb_id, hr_api.g_number) <>
5266        nvl(p_default_code_comb_id, hr_api.g_number)) or
5267       (NOT l_api_updating))
5268     then
5269 if g_debug then
5270     hr_utility.set_location(l_proc, 40);
5271  end if;
5272     --
5273     -- Check if default code comb is not null
5274     --
5275     if p_default_code_comb_id is not null then
5276       --
5277       -- Check that the assignment is an employee assignment.
5278       -- modified to allow applicant to have this set.
5279       --
5280       -- <OAB_CHANGE> - Extend restriction to allow assignment type 'B'
5281       --
5282       -- Added 'C' for Contingent Worker
5283       -- modified to allow offer to have this set
5284       --
5285       if p_assignment_type not in ('E','A','B','C','O') then
5286         --
5287         hr_utility.set_message(801, 'HR_51177_ASG_INV_ASG_TYP_DCC');
5288         hr_multi_message.add
5289         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.DEFAULT_CODE_COMB_ID'
5290    );
5291         --
5292       end if;
5293 if g_debug then
5294       hr_utility.set_location(l_proc, 50);
5295  end if;
5296       --
5297       -- Check that the default code comb exists in GL_CODE_COMBINATIONS
5298       --
5299       open csr_valid_def_cod_comb;
5300       fetch csr_valid_def_cod_comb into l_exists;
5301       if csr_valid_def_cod_comb%notfound then
5302         close csr_valid_def_cod_comb;
5303         hr_utility.set_message(801, 'HR_51148_ASG_INV_DEF_COD_COM');
5304         hr_multi_message.add
5305         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.DEFAULT_CODE_COMB_ID'
5306    ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
5307    );
5308         --
5309       else
5310         close csr_valid_def_cod_comb;
5311       end if;
5312 if g_debug then
5313       hr_utility.set_location(l_proc, 60);
5314  end if;
5315       --
5316     end if;
5317     --
5318   end if;
5319 if g_debug then
5320   hr_utility.set_location(' Leaving:'|| l_proc, 70);
5321  end if;
5322 end chk_default_code_comb_id;
5323 --
5324 --  ---------------------------------------------------------------------------
5325 --  |----------------------< chk_del_organization_id >------------------------|
5326 --  ---------------------------------------------------------------------------
5327 --
5328 --  Description:
5329 --    Checks to see if manager_flag is set to 'Y' on delete whether another
5330 --    assignment also has the manager_flag set within the same organization.
5331 --
5332 --  Pre-conditions:
5333 --    A valid Organization ID
5334 --
5335 --  In Arguments:
5336 --    p_assignment_id
5337 --    p_effective_date
5338 --    p_manager_flag
5339 --    p_organization_id
5340 --
5341 --  Post Success:
5342 --    Boolean flags set as approrpiate.
5343 --
5344 --  Post Failure:
5345 --    An application error is raised and processing is terminated if any
5346 --    of the following cases are found :
5347 --      - The organization_id is does not exists or is not date effective
5348 --      - The business group of the organization is invalid
5349 --
5350 --  Access Status:
5351 --    Internal Table Handler Use Only.
5352 --
5353 procedure chk_del_organization_id
5354   (p_assignment_id              in per_all_assignments_f.assignment_id%TYPE
5355   ,p_effective_date             in date
5356   ,p_manager_flag               in per_all_assignments_f.manager_flag%TYPE
5357   ,p_organization_id            in per_all_assignments_f.organization_id%TYPE
5358   ,p_org_now_no_manager_warning in out nocopy boolean
5359   )
5360   is
5361 --
5362    l_proc           varchar2(72);
5363    l_api_updating   boolean;
5364 --
5365 begin
5366 if g_debug then
5367    l_proc :=  g_package||'chk_del_organization_id';
5368   hr_utility.set_location('Entering:'|| l_proc, 1);
5369  end if;
5370   --
5371   if p_manager_flag = 'Y' then
5372     --
5373     -- Check whether another current assignment exists in the same
5374     -- organization with manager flag set to 'Y'.
5375     --
5376     if not per_asg_bus2.other_managers_in_org
5377              (p_organization_id => p_organization_id
5378              ,p_assignment_id   => p_assignment_id
5379              ,p_effective_date  => p_effective_date
5380              )
5381     then
5382       --
5383 if g_debug then
5384       hr_utility.set_location(l_proc, 3);
5385  end if;
5386       --
5387       p_org_now_no_manager_warning := TRUE;
5388     end if;
5389   end if;
5390   --
5391 if g_debug then
5392   hr_utility.set_location(' Leaving:'|| l_proc, 4);
5393  end if;
5394 end chk_del_organization_id;
5395 --
5396 --  ---------------------------------------------------------------------------
5397 --  |-----------------------< chk_employment_category >-----------------------|
5398 --  ---------------------------------------------------------------------------
5399 --
5400 procedure chk_employment_category
5401  (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
5402  ,p_assignment_type        in     per_all_assignments_f.assignment_type%TYPE
5403  ,p_employment_category    in     per_all_assignments_f.employment_category%TYPE
5404  ,p_effective_date         in     date
5405  ,p_validation_start_date  in     date
5406  ,p_validation_end_date    in     date
5407  ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
5408  )
5409   is
5410 --
5411    l_proc           varchar2(72)  :=  g_package||'chk_employment_category';
5412    l_exists         varchar2(1);
5413    l_api_updating   boolean;
5414 --
5415 begin
5416 if g_debug then
5417   hr_utility.set_location('Entering:'|| l_proc, 10);
5418  end if;
5419   --
5420   -- Check mandatory parameters have been set
5421   --
5422   hr_api.mandatory_arg_error
5423     (p_api_name       => l_proc
5424     ,p_argument       => 'effective_date'
5425     ,p_argument_value => p_effective_date
5426     );
5427   --
5428   hr_api.mandatory_arg_error
5429     (p_api_name       =>  l_proc
5430     ,p_argument       =>  'validation_start_date'
5431     ,p_argument_value =>  p_validation_start_date
5432     );
5433   --
5434   hr_api.mandatory_arg_error
5435     (p_api_name        =>  l_proc
5436     ,p_argument       =>  'validation_end_date'
5437     ,p_argument_value =>  p_validation_end_date
5438     );
5439 if g_debug then
5440   hr_utility.set_location(l_proc, 20);
5441  end if;
5442   --
5443   l_api_updating := per_asg_shd.api_updating
5444          (p_assignment_id          => p_assignment_id
5445          ,p_effective_date         => p_effective_date
5446          ,p_object_version_number  => p_object_version_number
5447          );
5448 if g_debug then
5449   hr_utility.set_location(l_proc, 30);
5450  end if;
5451   --
5452   if ((l_api_updating and
5453        nvl(per_asg_shd.g_old_rec.employment_category, hr_api.g_varchar2) <>
5454        nvl(p_employment_category, hr_api.g_varchar2))
5455     or (NOT l_api_updating))
5456   then
5457 if g_debug then
5458     hr_utility.set_location(l_proc, 40);
5459  end if;
5460     --
5461     if p_employment_category is not null then
5462       --
5463       -- Check that the assignment is of a valid type.
5464       --
5465       if p_assignment_type not in ('E','A','B','C','O') then
5466         --
5467         hr_utility.set_message(801, 'HR_51217_ASG_INV_ASG_TYP_ECAT');
5468         hr_utility.raise_error;
5469         --
5470       end if;
5471 if g_debug then
5472       hr_utility.set_location(l_proc, 50);
5473  end if;
5474       --
5475       -- Check that the employment category exists in hr_lookups for the
5476       -- lookup type 'EMP_CAT' with an enabled flag set to 'Y' and that
5477       -- the effective start date of the assignment is between start date
5478       -- active and end date active in hr_lookups.
5479       --
5480       -- Bug 1472162.
5481       --
5482 /*
5483       if hr_api.not_exists_in_dt_hr_lookups
5484         (p_effective_date        => p_effective_date
5485         ,p_validation_start_date => p_validation_start_date
5486         ,p_validation_end_date   => p_validation_end_date
5487         ,p_lookup_type           => 'EMP_CAT'
5488         ,p_lookup_code           => p_employment_category
5489         )
5490 */
5491 
5492       if p_assignment_type <> 'C' then
5493         --
5494         -- Use the employment category for non-contingent worker assignments.
5495         --
5496 if g_debug then
5497         hr_utility.set_location(l_proc, 60);
5498  end if;
5499 
5500         if hr_api.not_exists_in_leg_lookups
5501           (p_effective_date        => p_effective_date
5502             ,p_lookup_type           => 'EMP_CAT'
5503           ,p_lookup_code           => p_employment_category
5504           )
5505         then
5506           --
5507           hr_utility.set_message(801, 'HR_51028_ASG_INV_EMP_CATEGORY');
5508           hr_utility.raise_error;
5509           --
5510         end if;
5511 
5512       elsif p_assignment_type = 'C' then
5513         --
5514         -- Use the contingent worker lookup. Originally this information
5515         -- was to be stored in the assignment category column only but
5516         -- is now stored in employment category. The assignment_category
5517         -- column itself is redundant.
5518         --
5519         -- Here the assignment category chk procedure is called to validate
5520         -- for contingent workers.
5521         --
5522 if g_debug then
5523         hr_utility.set_location(l_proc, 65);
5524  end if;
5525 
5526         per_asg_bus1.chk_assignment_category
5527           (p_assignment_id          => p_assignment_id
5528           ,p_assignment_type        => p_assignment_type
5529           ,p_effective_date         => p_effective_date
5530           ,p_assignment_category    => p_employment_category
5531           ,p_object_version_number  => p_object_version_number
5532           ,p_validation_start_date  => p_validation_start_date
5533           ,p_validation_end_date    => p_validation_end_date);
5534 
5535       end if;
5536       --
5537     end if;
5538 if g_debug then
5539     hr_utility.set_location(l_proc, 70);
5540  end if;
5541     --
5542   end if;
5543   --
5544 if g_debug then
5545   hr_utility.set_location(' Leaving:'|| l_proc, 80);
5546  end if;
5547   exception
5548   when app_exception.application_exception then
5549     if hr_multi_message.exception_add
5550          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.EMPLOYMENT_CATEGORY'
5551          ) then
5552 if g_debug then
5553       hr_utility.set_location(' Leaving:'|| l_proc, 90);
5554  end if;
5555       raise;
5556     end if;
5557 if g_debug then
5558    hr_utility.set_location(' Leaving:'|| l_proc, 100);
5559  end if;
5560 end chk_employment_category;
5561 --
5562 --  ---------------------------------------------------------------------------
5563 --  |-------------------------< chk_frequency >-------------------------------|
5564 --  ---------------------------------------------------------------------------
5565 --
5566 procedure chk_frequency
5567   (p_assignment_id         in     per_all_assignments_f.assignment_id%TYPE
5568   ,p_frequency             in     per_all_assignments_f.frequency%TYPE
5569   ,p_effective_date        in     date
5570   ,p_validation_start_date in     date
5571   ,p_validation_end_date   in     date
5572   ,p_object_version_number in     per_all_assignments_f.object_version_number%TYPE
5573   )
5574 is
5575   --
5576   l_api_updating   boolean;
5577   l_exists         varchar2(1);
5578   l_proc           varchar2(72)  :=  g_package||'chk_frequency';
5579   --
5580 begin
5581 if g_debug then
5582   hr_utility.set_location('Entering:'|| l_proc, 10);
5583  end if;
5584   --
5585   -- Check mandatory parameters
5586   --
5587   hr_api.mandatory_arg_error
5588     (p_api_name       =>  l_proc
5589     ,p_argument       =>  'effective_date'
5590     ,p_argument_value =>  p_effective_date
5591     );
5592   --
5593   hr_api.mandatory_arg_error
5594     (p_api_name       =>  l_proc
5595     ,p_argument       =>  'validation_start_date'
5596     ,p_argument_value =>  p_validation_start_date
5597     );
5598   --
5599   hr_api.mandatory_arg_error
5600     (p_api_name        =>  l_proc
5601     ,p_argument       =>  'validation_end_date'
5602     ,p_argument_value =>  p_validation_end_date
5603     );
5604 if g_debug then
5605   hr_utility.set_location(l_proc, 20);
5606  end if;
5607   --
5608   -- Only proceed with validation if :
5609   -- a) The current g_old_rec is current and
5610   -- b) The value for frequency has changed
5611   --
5612   l_api_updating := per_asg_shd.api_updating
5613          (p_assignment_id          => p_assignment_id
5614          ,p_effective_date         => p_effective_date
5615          ,p_object_version_number  => p_object_version_number
5616          );
5617 if g_debug then
5618   hr_utility.set_location(l_proc, 30);
5619  end if;
5620   --
5621   if ((l_api_updating and
5622        nvl(per_asg_shd.g_old_rec.frequency, hr_api.g_varchar2) <>
5623        nvl(p_frequency, hr_api.g_varchar2)) or
5624       (NOT l_api_updating))
5625   then
5626 if g_debug then
5627     hr_utility.set_location(l_proc||' '||p_frequency, 40);
5628  end if;
5629     --
5630     -- Check if frequency is set.
5631     --
5632     if p_frequency is not null then
5633       --
5634       -- Check that the frequency exists in hr_lookups for the lookup
5635       -- type 'FREQUENCY' with an enabled flag set to 'Y' and that the
5636       -- effective start date of the assignment is between start date
5637       -- active and end date active in hr_lookups.
5638       --
5639       if hr_api.not_exists_in_dt_hr_lookups
5640         (p_effective_date        => p_effective_date
5641         ,p_validation_start_date => p_validation_start_date
5642         ,p_validation_end_date   => p_validation_end_date
5643         ,p_lookup_type           => 'FREQUENCY'
5644         ,p_lookup_code           => p_frequency
5645         )
5646       then
5647         --
5648         hr_utility.set_message(801, 'HR_7388_ASG_INVALID_FREQUENCY');
5649         hr_utility.raise_error;
5650         --
5651       end if;
5652 if g_debug then
5653       hr_utility.set_location(l_proc, 60);
5654  end if;
5655       --
5656     end if;
5657 if g_debug then
5658     hr_utility.set_location(l_proc, 70);
5659  end if;
5660     --
5661   end if;
5662   --
5663 if g_debug then
5664   hr_utility.set_location(' Leaving:'|| l_proc, 80);
5665  end if;
5666   exception
5667   when app_exception.application_exception then
5668     if hr_multi_message.exception_add
5669          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.FREQUENCY'
5670          ) then
5671 if g_debug then
5672       hr_utility.set_location(' Leaving:'|| l_proc, 90);
5673  end if;
5674       raise;
5675     end if;
5676 if g_debug then
5677     hr_utility.set_location(' Leaving:'|| l_proc, 100);
5678  end if;
5679 end chk_frequency;
5680 --
5681 --  ---------------------------------------------------------------------------
5682 --  |------------------------< chk_future_primary >---------------------------|
5683 --  ---------------------------------------------------------------------------
5684 --
5685 --  Description:
5686 --    Validates that a non-primary assignment cannot be date effectively
5687 --    deleted if it is update to a primary assignment in the future.
5688 --
5689 --  Pre-conditions:
5690 --    None
5691 --
5692 --  In Arguments:
5693 --    p_assignment_id
5694 --    p_primary_flag
5695 --    p_effective_date
5696 --
5697 --  Post Success:
5698 --    If the non-primary assignment does not become primary in the future
5699 --    then processing continues.
5700 --
5701 --  Post Failure:
5702 --    If the non-primary assignment becomes primary in the future then an
5703 --    application error is raised and processing is terminated.
5704 --
5705 --  Access Status:
5706 --    Internal Table Handler Use Only.
5707 --
5708 procedure chk_future_primary
5709   (p_assignment_id     in per_all_assignments_f.assignment_id%TYPE
5710   ,p_primary_flag      in per_all_assignments_f.primary_flag%TYPE
5711   ,p_datetrack_mode    in varchar2
5712   ,p_effective_date    in date
5713   )
5714   is
5715 --
5716    l_exists         varchar2(1);
5717    l_proc           varchar2(72)  :=  g_package||'chk_future_primary';
5718 --
5719    cursor csr_chk_fut_prim is
5720      select   null
5721      from     per_all_assignments_f
5722      where    assignment_id = p_assignment_id
5723      and      effective_start_date >= p_effective_date
5724      and      primary_flag = 'Y';
5725 --
5726 begin
5727 if g_debug then
5728   hr_utility.set_location('Entering:'|| l_proc, 1);
5729  end if;
5730   --
5731   -- Check mandatory parameters have been set
5732   --
5733   hr_api.mandatory_arg_error
5734     (p_api_name       => l_proc
5735     ,p_argument       => 'primary flag'
5736     ,p_argument_value => p_primary_flag
5737     );
5738   --
5739 if g_debug then
5740   hr_utility.set_location(l_proc, 2);
5741  end if;
5742   --
5743   if p_datetrack_mode = 'DELETE' and
5744      p_primary_flag = 'N' then
5745     open csr_chk_fut_prim;
5746     fetch csr_chk_fut_prim into l_exists;
5747     if csr_chk_fut_prim%found then
5748       close csr_chk_fut_prim;
5749       hr_utility.set_message(801, 'HR_7399_ASG_NO_DEL_NON_PRIM');
5750       hr_utility.raise_error;
5751     end if;
5752     close csr_chk_fut_prim;
5753   end if;
5754   --
5755 if g_debug then
5756   hr_utility.set_location(' Leaving:'|| l_proc, 3);
5757  end if;
5758   exception
5759   when app_exception.application_exception then
5760     if hr_multi_message.exception_add
5761          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.ASSIGNMENT_ID'
5762          ) then
5763 if g_debug then
5764       hr_utility.set_location(' Leaving:'|| l_proc, 4);
5765  end if;
5766       raise;
5767     end if;
5768 if g_debug then
5769     hr_utility.set_location(' Leaving:'|| l_proc, 5);
5770  end if;
5771 end chk_future_primary;
5772 --
5773 --  ---------------------------------------------------------------------------
5774 --  |---------------------------< chk_grade_id >------------------------------|
5775 --  ---------------------------------------------------------------------------
5776 --
5777 procedure chk_grade_id
5778   (p_assignment_id            in     per_all_assignments_f.assignment_id%TYPE
5779   ,p_business_group_id        in     per_all_assignments_f.business_group_id%TYPE
5780   ,p_assignment_type          in     per_all_assignments_f.assignment_type%TYPE
5781   ,p_grade_id                 in     per_all_assignments_f.grade_id%TYPE
5782   ,p_vacancy_id               in     per_all_assignments_f.vacancy_id%TYPE
5783   ,p_special_ceiling_step_id  in     per_all_assignments_f.special_ceiling_step_id%TYPE
5784   ,p_effective_date           in     date
5785   ,p_validation_start_date    in     per_all_assignments_f.effective_start_date%TYPE
5786   ,p_validation_end_date      in     per_all_assignments_f.effective_end_date%TYPE
5787   ,p_object_version_number    in     per_all_assignments_f.object_version_number%TYPE
5788   )
5789   is
5790 --
5791   l_exists                        varchar2(1);
5792   l_api_updating                  boolean;
5793   l_business_group_id             number(15);
5794   l_proc                          varchar2(72)  :=  g_package||'chk_grade_id';
5795   l_vac_grade_id                  per_all_assignments_f.grade_id%TYPE;
5796   --
5797   cursor csr_valid_grade is
5798     select   business_group_id
5799     from     per_grades
5800     where    grade_id = p_grade_id
5801     and      p_validation_start_date
5802       between date_from and nvl(date_to, hr_api.g_eot);
5803   --
5804 begin
5805 if g_debug then
5806   hr_utility.set_location('Entering:'|| l_proc, 10);
5807  end if;
5808   --
5809     --
5810     -- Check mandatory parameters have been set
5811     --
5812     hr_api.mandatory_arg_error
5813       (p_api_name       => l_proc
5814       ,p_argument       => 'effective_date'
5815       ,p_argument_value => p_effective_date
5816       );
5817     --
5818     hr_api.mandatory_arg_error
5819       (p_api_name       => l_proc
5820       ,p_argument       => 'validation_start_date'
5821       ,p_argument_value => p_validation_start_date
5822       );
5823     --
5824     hr_api.mandatory_arg_error
5825       (p_api_name       => l_proc
5826       ,p_argument       => 'validation_end_date'
5827       ,p_argument_value => p_validation_end_date
5828       );
5829     --
5830     hr_api.mandatory_arg_error
5831       (p_api_name       => l_proc
5832       ,p_argument       => 'business_group_id'
5833       ,p_argument_value => p_business_group_id
5834       );
5835 if g_debug then
5836     hr_utility.set_location(l_proc, 20);
5837  end if;
5838     --
5839     -- Only proceed with validation if :
5840     -- a) The current  g_old_rec is current and
5841     -- b) The value for grade has changed
5842     --
5843     l_api_updating := per_asg_shd.api_updating
5844         (p_assignment_id          => p_assignment_id
5845         ,p_effective_date         => p_effective_date
5846         ,p_object_version_number  => p_object_version_number
5847         );
5848 if g_debug then
5849     hr_utility.set_location(l_proc, 30);
5850  end if;
5851     --
5852     if ((l_api_updating and
5853        nvl(per_asg_shd.g_old_rec.grade_id, hr_api.g_number) <>
5854        nvl(p_grade_id, hr_api.g_number)) or
5855       (NOT l_api_updating)) then
5856 if g_debug then
5857       hr_utility.set_location(l_proc, 40);
5858  end if;
5859       --
5860       -- Check if the grade is set.
5861       --
5862       if p_grade_id is not null then
5863         --
5864         -- Check that the grade exists between date from and date to in
5865         -- PER_GRADES.
5866         --
5867         open csr_valid_grade;
5868         fetch csr_valid_grade into l_business_group_id;
5869         if csr_valid_grade%notfound then
5870          close csr_valid_grade;
5871          hr_utility.set_message(801, 'HR_7393_ASG_INVALID_GRADE');
5872          hr_multi_message.add
5873            (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.GRADE_ID'
5874       ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
5875       );
5876          --
5877         else
5878          close csr_valid_grade;
5879         end if;
5880 if g_debug then
5881         hr_utility.set_location(l_proc, 50);
5882  end if;
5883         --
5884         -- Check that the business group for the grade is the same
5885         -- as that of the assignment
5886         --
5887         if l_business_group_id <> p_business_group_id then
5888          --
5889          hr_utility.set_message(801, 'HR_7371_ASG_INVALID_BG_GRADE');
5890          hr_multi_message.add
5891           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.GRADE_ID'
5892      );
5893          --
5894         end if;
5895 if g_debug then
5896         hr_utility.set_location(l_proc, 60);
5897  end if;
5898         --
5899       elsif p_special_ceiling_step_id is not null then
5900         -- When grade is null special ceiling step should be null
5901          --
5902          hr_utility.set_message(801, 'HR_7434_ASG_GRADE_REQUIRED');
5903          hr_multi_message.add
5904          (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.GRADE_ID'
5905     ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.SPECIAL_CEILING_STEP_ID'
5906     );
5907        --
5908    end if;
5909 if g_debug then
5910    hr_utility.set_location(l_proc, 80);
5911  end if;
5912    --
5913   end if;
5914 if g_debug then
5915   hr_utility.set_location(' Leaving:'|| l_proc, 110);
5916  end if;
5917   --
5918 end chk_grade_id;
5919 --
5920 --  ---------------------------------------------------------------------------
5921 --  |-----------------------------< chk_job_id >------------------------------|
5922 --  ---------------------------------------------------------------------------
5923 --
5924 procedure chk_job_id
5925   (p_assignment_id           in     per_all_assignments_f.assignment_id%TYPE
5926   ,p_business_group_id       in     per_all_assignments_f.business_group_id%TYPE
5927   ,p_assignment_type         in     per_all_assignments_f.assignment_type%TYPE
5928   ,p_job_id                  in     per_all_assignments_f.job_id%TYPE
5929   ,p_vacancy_id              in     per_all_assignments_f.vacancy_id%TYPE
5930   ,p_effective_date          in     date
5931   ,p_validation_start_date   in     date
5932   ,p_validation_end_date     in     date
5933   ,p_object_version_number   in     per_all_assignments_f.object_version_number%TYPE
5934   )
5935   is
5936   --
5937   l_proc                     varchar2(72)  :=  g_package||'chk_job_id';
5938   l_exists                   varchar2(1);
5939   l_api_updating             boolean;
5940   l_business_group_id        per_all_assignments_f.business_group_id%TYPE;
5941   l_vac_job_id               per_all_assignments_f.job_id%TYPE;
5942   --
5943 --
5944 -- Bug 33552211 Start Here
5945 -- Description : Changed the cursor sql query to improve the performance
5946 --
5947 /*  cursor csr_valid_job is
5948     select   business_group_id
5949     from     per_jobs_v
5950     where    job_id = p_job_id
5951     and      p_validation_start_date
5952       between  date_from
5953       and      nvl(date_to, hr_api.g_eot);
5954 */
5955   cursor csr_valid_job is
5956     select  job.business_group_id
5957     from     per_jobs job
5958            , per_job_groups jgr
5959     where    job.job_id = p_job_id
5960     and      (p_validation_start_date
5961        between  job.date_from
5962        and      nvl(job.date_to, hr_api.g_eot))
5963     and     job.job_group_id = jgr.job_group_id
5964     and jgr.internal_name = 'HR_'||jgr.business_group_id
5965     and (jgr.business_group_id = job.business_group_id
5966          or jgr.business_group_id is null);
5967 
5968 -- Bug 33552211 End Here
5969   --
5970 begin
5971 if g_debug then
5972   hr_utility.set_location('Entering:'|| l_proc, 10);
5973  end if;
5974   --
5975   --
5976   -- Check mandatory arguments
5977   --
5978   hr_api.mandatory_arg_error
5979     (p_api_name       => l_proc
5980     ,p_argument       => 'effective_date'
5981     ,p_argument_value => p_effective_date
5982     );
5983   --
5984   hr_api.mandatory_arg_error
5985     (p_api_name       =>  l_proc
5986     ,p_argument       =>  'validation_start_date'
5987     ,p_argument_value =>  p_validation_start_date
5988     );
5989   --
5990   hr_api.mandatory_arg_error
5991     (p_api_name        =>  l_proc
5992     ,p_argument       =>  'validation_end_date'
5993     ,p_argument_value =>  p_validation_end_date
5994     );
5995 if g_debug then
5996   hr_utility.set_location(l_proc, 20);
5997  end if;
5998   --
5999   --  Check if the assignment is being updated.
6000   --
6001   l_api_updating := per_asg_shd.api_updating
6002         (p_assignment_id          => p_assignment_id
6003         ,p_effective_date         => p_effective_date
6004         ,p_object_version_number  => p_object_version_number
6005         );
6006 if g_debug then
6007   hr_utility.set_location(l_proc, 30);
6008  end if;
6009   --
6010   -- Only proceed with validation if :
6011   -- a) The current g_old_rec is current and
6012   -- b) The value for job has changed
6013   --
6014   if ((l_api_updating and
6015        nvl(per_asg_shd.g_old_rec.job_id,
6016        hr_api.g_number) <> nvl(p_job_id, hr_api.g_number))
6017     or
6018       NOT l_api_updating) then
6019 if g_debug then
6020     hr_utility.set_location(l_proc, 40);
6021  end if;
6022     --
6023     -- Check if job is set
6024     --
6025     if p_job_id is not null then
6026       --
6027       -- Check if the job exists in PER_JOBS where the effective start
6028       -- date of the assignment is between the job date from and date to.
6029       --
6030       open csr_valid_job;
6031       fetch csr_valid_job into l_business_group_id;
6032       if csr_valid_job%notfound then
6033         close csr_valid_job;
6034         hr_utility.set_message(801, 'HR_51172_ASG_INV_DT_JOB');
6035         hr_multi_message.add
6036         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.JOB_ID'
6037    ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
6038    );
6039         --
6040       else
6041         close csr_valid_job;
6042       end if;
6043 if g_debug then
6044       hr_utility.set_location(l_proc, 50);
6045  end if;
6046       --
6047       -- Check that the job is in the same business group as the job of the
6048       -- assignment date effectively.
6049       --
6050       If p_business_group_id <> l_business_group_id then
6051         --
6052         hr_utility.set_message(801, 'HR_51173_ASG_INV_DT_JOB_BG');
6053         hr_multi_message.add
6054         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.JOB_ID'
6055    );
6056         --
6057       end if;
6058 if g_debug then
6059       hr_utility.set_location(l_proc, 60);
6060  end if;
6061       --
6062     end if;
6063 if g_debug then
6064     hr_utility.set_location(l_proc, 70);
6065  end if;
6066     --
6067   end if;
6068 if g_debug then
6069   hr_utility.set_location(' Leaving:'|| l_proc, 100);
6070  end if;
6071   --
6072 end chk_job_id;
6073 --
6074 --  ---------------------------------------------------------------------------
6075 --  |----------------------< chk_job_id_grade_id >----------------------------|
6076 --  ---------------------------------------------------------------------------
6077 --
6078 procedure chk_job_id_grade_id
6079   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
6080   ,p_job_id                 in     per_all_assignments_f.job_id%TYPE
6081   ,p_grade_id               in     per_all_assignments_f.grade_id%TYPE
6082   ,p_effective_date         in     date
6083   ,p_validation_start_date  in     date
6084   ,p_validation_end_date    in     date
6085   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
6086   ,p_inv_job_grade_warning     out nocopy boolean
6087   )
6088   is
6089   --
6090    l_proc                   varchar2(72)  :=  g_package||'chk_job_id_grade_id';
6091    l_api_updating           boolean;
6092    l_exists                 varchar2(1);
6093    l_exists1                varchar2(1); -- Bug 3566686
6094    l_inv_job_grade_warning  boolean := false;
6095 --
6096 -- Bug 3566686 Starts Here
6097 -- Description : The cursor checks whether ther are any grades defined as
6098 --               the valid grades for the selected JOB.
6099 --
6100   cursor csr_val_job_grade_exists is
6101     select   null
6102     from     per_valid_grades
6103     where    job_id = p_job_id
6104     and      p_validation_start_date
6105       between  date_from
6106       and      nvl(date_to, hr_api.g_eot);
6107 --
6108 -- Bug 3566686 Ends Here
6109 --
6110   cursor csr_val_job_grade is
6111     select   null
6112     from     per_valid_grades
6113     where    job_id = p_job_id
6114     and      grade_id = p_grade_id
6115     and      p_validation_start_date
6116       between  date_from
6117       and      nvl(date_to, hr_api.g_eot);
6118   --
6119 begin
6120 if g_debug then
6121   hr_utility.set_location('Entering:'|| l_proc, 10);
6122  end if;
6123   --
6124    if hr_multi_message.no_exclusive_error
6125        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.JOB_ID'
6126        ,p_check_column2      => 'PER_ALL_ASSIGNMENTS_F.GRADE_ID'
6127        ) then
6128   --
6129   -- Check mandatory arguments
6130   --
6131   hr_api.mandatory_arg_error
6132     (p_api_name       => l_proc
6133     ,p_argument       => 'effective_date'
6134     ,p_argument_value => p_effective_date
6135     );
6136   --
6137   hr_api.mandatory_arg_error
6138     (p_api_name       =>  l_proc
6139     ,p_argument       =>  'validation_start_date'
6140     ,p_argument_value =>  p_validation_start_date
6141     );
6142   --
6143   hr_api.mandatory_arg_error
6144     (p_api_name        =>  l_proc
6145     ,p_argument       =>  'validation_end_date'
6146     ,p_argument_value =>  p_validation_end_date
6147     );
6148 if g_debug then
6149   hr_utility.set_location(l_proc, 20);
6150  end if;
6151   --
6152   --  Check if the assignment is being updated.
6153   --
6154   l_api_updating := per_asg_shd.api_updating
6155         (p_assignment_id          => p_assignment_id
6156         ,p_effective_date         => p_effective_date
6157         ,p_object_version_number  => p_object_version_number
6158         );
6159 if g_debug then
6160   hr_utility.set_location(l_proc, 30);
6161  end if;
6162   --
6163   -- Only proceed with validation if :
6164   -- a) The current g_old_rec is current and
6165   -- b) The value for job or grade has changed.
6166   --
6167   if (l_api_updating
6168     and
6169       ((nvl(per_asg_shd.g_old_rec.job_id, hr_api.g_number)
6170       <> nvl(p_job_id, hr_api.g_number))
6171       or
6172       (nvl(per_asg_shd.g_old_rec.grade_id, hr_api.g_number)
6173       <> nvl(p_grade_id, hr_api.g_number))))
6174     or
6175       NOT l_api_updating then
6176 if g_debug then
6177     hr_utility.set_location(l_proc, 40);
6178  end if;
6179     --
6180     -- Check that both job and grade are set.
6181     --
6182     if p_job_id is not null and p_grade_id is not null then
6183       --
6184       -- Check if the job and grade exists date effectively in
6185       -- PER_VALID_GRADES.
6186       --
6187       -- Bug 3566686 Starts Here
6188       -- Description : The first if condition checks whether there are any
6189       --               grades defined as the valid grades for the selected
6190       --               JOB, if atleast one such grade exists then only it
6191       --               will check for the validity of the grade selected
6192       --               for the JOB.
6193       --
6194       open csr_val_job_grade_exists;
6195       fetch csr_val_job_grade_exists into l_exists1;
6196       if csr_val_job_grade_exists%found then
6197           close csr_val_job_grade_exists;
6198           open csr_val_job_grade;
6199           fetch csr_val_job_grade into l_exists;
6200           if csr_val_job_grade%notfound then
6201             p_inv_job_grade_warning := true;
6202           end if;
6203           close csr_val_job_grade;
6204       else
6205       close csr_val_job_grade_exists;
6206       end if;
6207       --
6208       -- Bug 3566686 Ends Here
6209       --
6210 if g_debug then
6211       hr_utility.set_location(l_proc, 50);
6212  end if;
6213       --
6214     end if;
6215 if g_debug then
6216     hr_utility.set_location(l_proc, 60);
6217  end if;
6218     --
6219   end if;
6220   end if;
6221   --
6222 if g_debug then
6223   hr_utility.set_location(' Leaving:'|| l_proc, 70);
6224  end if;
6225 end chk_job_id_grade_id;
6226 --
6227 --  ---------------------------------------------------------------------------
6228 --  |--------------------------< chk_location_id >----------------------------|
6229 --  ---------------------------------------------------------------------------
6230 --
6231 procedure chk_location_id
6232   (p_assignment_id         in per_all_assignments_f.assignment_id%TYPE
6233   ,p_location_id           in per_all_assignments_f.location_id%TYPE
6234   ,p_assignment_type       in per_all_assignments_f.assignment_type%TYPE
6235   ,p_vacancy_id            in per_all_assignments_f.vacancy_id%TYPE
6236   ,p_effective_date        in date
6237   ,p_validation_start_date in per_all_assignments_f.effective_start_date%TYPE
6238   ,p_validation_end_date   in per_all_assignments_f.effective_end_date%TYPE
6239   ,p_object_version_number in per_all_assignments_f.object_version_number%TYPE
6240   )
6241   is
6242 --
6243    l_exists          varchar2(1);
6244    l_api_updating    boolean;
6245    l_proc            varchar2(72)  :=  g_package||'chk_location_id';
6246    l_inactive_date   date;
6247    l_vac_location_id per_all_assignments_f.location_id%TYPE;
6248 -- Bug 4116879 Starts
6249 -- Desc : The fix made for the bug 3895708, not considerd the INSERT scenario.
6250 --        While creating the Assignment per_all_assignments_f is not populated
6251 --        so the sub query fails. Re-write the cursor to implement INSERT too.
6252 --        Also, fix for the bug 4105698 is modified to make the cursor
6253 --        compatible with 8i.
6254 cursor csr_valid_location_upd is
6255        select inactive_date
6256        from  hr_locations_all
6257        where  location_id =  p_location_id
6258        and (business_group_id= (
6259                select distinct business_group_id
6260                from per_all_assignments_f
6261                where assignment_id= p_assignment_id)
6262        or business_group_id is null);
6263 
6264 -- bug 4318990 added an nvl in the where condition for relaxing the validation
6265 cursor csr_valid_location_ins is
6266        select inactive_date
6267        from  hr_locations_all
6268        where  location_id =  p_location_id
6269        and (business_group_id= nvl(hr_general.get_business_group_id,business_group_id)
6270        or business_group_id is null);
6271 -- Bug 4116879 Ends
6272 --
6273 begin
6274 if g_debug then
6275   hr_utility.set_location('Entering:'|| l_proc, 10);
6276  end if;
6277   --
6278   --
6279   -- Check mandatory parameters have been set
6280   --
6281   hr_api.mandatory_arg_error
6282     (p_api_name       => l_proc
6283     ,p_argument       => 'effective_date'
6284     ,p_argument_value => p_effective_date
6285     );
6286   --
6287   hr_api.mandatory_arg_error
6288     (p_api_name       => l_proc
6289     ,p_argument       => 'validation_start_date'
6290     ,p_argument_value => p_validation_start_date
6291     );
6292   --
6293   hr_api.mandatory_arg_error
6294     (p_api_name       => l_proc
6295     ,p_argument       => 'validation_end_date'
6296     ,p_argument_value => p_validation_end_date
6297     );
6298 if g_debug then
6299   hr_utility.set_location('Entering:'|| l_proc, 20);
6300  end if;
6301   --
6302   -- Only proceed with validation if :
6303   -- a) The current g_old_rec is current and
6304   -- b) The value for location_id has changed
6305   --
6306   l_api_updating := per_asg_shd.api_updating
6307          (p_assignment_id          => p_assignment_id
6308          ,p_effective_date         => p_effective_date
6309          ,p_object_version_number  => p_object_version_number
6310          );
6311 if g_debug then
6312   hr_utility.set_location('Entering:'|| l_proc, 30);
6313  end if;
6314   --
6315   if ((l_api_updating and
6316        nvl(per_asg_shd.g_old_rec.location_id, hr_api.g_number) <>
6317        nvl(p_location_id, hr_api.g_number)) or
6318       (NOT l_api_updating))
6319   then
6320     --
6321 if g_debug then
6322     hr_utility.set_location('Entering:'|| l_proc, 40);
6323  end if;
6324     --
6325     if p_location_id is not null then
6326 --
6327 -- Bug 4116879 Starts
6328 -- Desc: On update p_assignment_id is not null. On insert p_assignment_id
6329 --       will be null.
6330        if p_assignment_id is not null then
6331           open csr_valid_location_upd;
6332           fetch csr_valid_location_upd into l_inactive_date;
6333           if csr_valid_location_upd%notfound then
6334              close csr_valid_location_upd;
6335              hr_utility.set_message(801, 'HR_7382_ASG_NON_EXIST_LOCATION');
6336              hr_multi_message.add
6337             (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.LOCATION_ID');
6338           --
6339           else
6340              close csr_valid_location_upd;
6341           end if;
6342        else
6343           open csr_valid_location_ins;
6344           fetch csr_valid_location_ins into l_inactive_date;
6345           if csr_valid_location_ins%notfound then
6346              close csr_valid_location_ins;
6347              hr_utility.set_message(801, 'HR_7382_ASG_NON_EXIST_LOCATION');
6348              hr_multi_message.add
6349             (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.LOCATION_ID');
6350           --
6351           else
6352              close csr_valid_location_ins;
6353           end if;
6354        end if;
6355 -- Bug 4116879 Ends
6356 --
6357 if g_debug then
6358       hr_utility.set_location('Entering:'|| l_proc, 50);
6359  end if;
6360       --
6361       -- Check if the assignment ESD is before the location inactive date
6362       -- on insert
6363       --
6364       if p_validation_start_date >= nvl(l_inactive_date,hr_api.g_eot)
6365       then
6366         --
6367         hr_utility.set_message(801, 'HR_51215_ASG_INACT_LOCATION');
6368         hr_multi_message.add
6369         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.LOCATION_ID'
6370    ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
6371    );
6372         --
6373       end if;
6374 if g_debug then
6375       hr_utility.set_location('Entering:'|| l_proc, 60);
6376  end if;
6377       --
6378     end if;
6379     --
6380   end if;
6381   --
6382 if g_debug then
6383   hr_utility.set_location('Entering:'|| l_proc, 90);
6384  end if;
6385 end chk_location_id;
6386 --
6387 --  ---------------------------------------------------------------------------
6388 --  |-------------------------< chk_manager_flag >----------------------------|
6389 --  ---------------------------------------------------------------------------
6390 --
6391 procedure chk_manager_flag
6392   (p_assignment_id         in     per_all_assignments_f.assignment_id%TYPE
6393   ,p_assignment_type       in     per_all_assignments_f.assignment_type%TYPE
6394   ,p_organization_id       in     per_all_assignments_f.organization_id%TYPE
6395   ,p_manager_flag          in     per_all_assignments_f.manager_flag%TYPE
6396   ,p_effective_date        in     date
6397   ,p_object_version_number in     per_all_assignments_f.object_version_number%TYPE
6398   ,p_other_manager_warning in out nocopy boolean
6399   ,p_no_managers_warning   in out nocopy boolean
6400   )
6401   is
6402   --
6403    l_proc           varchar2(72)  :=  g_package||'chk_manager_flag';
6404    l_api_updating   boolean;
6405 --
6406 begin
6407 if g_debug then
6408   hr_utility.set_location('Entering:'|| l_proc, 10);
6409  end if;
6410   --
6411   -- Check mandatory parameters have been set
6412   --
6413   hr_api.mandatory_arg_error
6414     (p_api_name       => l_proc
6415     ,p_argument       => 'effective_date'
6416     ,p_argument_value => p_effective_date
6417     );
6418   --
6419   hr_api.mandatory_arg_error
6420     (p_api_name       => l_proc
6421     ,p_argument       => 'organization_id'
6422     ,p_argument_value => p_organization_id
6423     );
6424 if g_debug then
6425   hr_utility.set_location(l_proc, 20);
6426  end if;
6427   --
6428   -- Only proceed with validation if :
6429   -- a) The current g_old_rec is current and
6430   -- b) The value for manager flag has changed
6431   --
6432   l_api_updating := per_asg_shd.api_updating
6433          (p_assignment_id          => p_assignment_id
6434          ,p_effective_date         => p_effective_date
6435          ,p_object_version_number  => p_object_version_number
6436          );
6437 if g_debug then
6438   hr_utility.set_location(l_proc, 30);
6439  end if;
6440   --
6441   if ((l_api_updating and
6442        nvl(per_asg_shd.g_old_rec.manager_flag, hr_api.g_varchar2) <>
6443        nvl(p_manager_flag, hr_api.g_varchar2))
6444     or
6445       (NOT l_api_updating))
6446     then
6447 if g_debug then
6448     hr_utility.set_location(l_proc, 40);
6449  end if;
6450     --
6451     -- Check if manager flag is set and is either 'Y' or 'N'.
6452     --
6453     If p_manager_flag is not null
6454       and p_manager_flag not in('Y','N')
6455     then
6456       --
6457       per_asg_shd.constraint_error
6458       (p_constraint_name => 'PER_ASS_MANAGER_FLAG_CHK');
6459 if g_debug then
6460       hr_utility.set_location(l_proc, 50);
6461  end if;
6462       --
6463     end if;
6464 if g_debug then
6465     hr_utility.set_location(l_proc, 60);
6466  end if;
6467     --
6468     -- Check if the assignment is an employee assignment.
6469     --
6470     --
6471     -- Remainder of procedure modidied as part of bug 892583. Changes
6472     -- made have effected the call to the per_asg_bus2.other_managers_in_org
6473     -- function. Previously ALL new employees, regardless of their
6474     -- manager flag, called this function. Now only NEW MANAGERS will call
6475     -- this function.
6476     --
6477     --
6478     -- Check if the assignment is an employee assignment.
6479     --
6480     if p_assignment_type = 'E' then
6481       --
6482       -- Check to see if adding a NEW employee only.
6483       --
6484       if NOT l_api_updating then
6485         --
6486         -- Check to see if new employee is a manager
6487         --
6488         if p_manager_flag = 'Y' then
6489           --
6490           -- Check whether another current assignment exists in the same
6491           -- organization with manager flag set to 'Y'.
6492           --
6493           if per_asg_bus2.other_managers_in_org
6494             (p_organization_id => p_organization_id
6495             ,p_assignment_id   => p_assignment_id
6496             ,p_effective_date  => p_effective_date) then
6497             --
6498             p_other_manager_warning := TRUE;
6499             --
6500           end if;
6501           --
6502         end if; -- Employee is a Manager check
6503       --
6504       -- Check if UPDATING employee
6505       --
6506       elsif l_api_updating then
6507         --
6508         -- Check whether another current assignment exists in the
6509         -- same organization with manager flag set to 'Y'
6510         --
6511         if per_asg_bus2.other_managers_in_org
6512             (p_organization_id => p_organization_id
6513             ,p_assignment_id   => p_assignment_id
6514             ,p_effective_date  => p_effective_date) then
6515           --
6516           -- If the new employee is a manager then
6517           -- set the warning flag to true
6518           --
6519           if p_manager_flag = 'Y' then
6520             --
6521             p_other_manager_warning := TRUE;
6522             --
6523           end if;
6524         --
6525         -- No other current assignments exists in the same
6526         -- organization with a manager flag set to 'Y''
6527         --
6528         else
6529           --
6530           -- Check if employee is being changed from
6531           -- a manager to a non-manager
6532           --
6533           if p_manager_flag = 'N' and
6534              per_asg_shd.g_old_rec.manager_flag = 'Y' then
6535             --
6536             p_no_managers_warning := TRUE;
6537             --
6538           end if;
6539           --
6540         end if; -- Manager check in same organization
6541         --
6542       end if; -- New or Updating employee
6543       --
6544     end if; -- Check if assignment is an employee assignment
6545     --
6546   end if;
6547   --
6548 if g_debug then
6549   hr_utility.set_location(' Leaving:'|| l_proc, 110);
6550  end if;
6551 --
6552 end chk_manager_flag;
6553 --
6554 --  ---------------------------------------------------------------------------
6555 --  |---------------------< chk_frequency_normal_hours >----------------------|
6556 --  ---------------------------------------------------------------------------
6557 --
6558 procedure chk_frequency_normal_hours
6559   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
6560   ,p_frequency              in     per_all_assignments_f.frequency%TYPE
6561   ,p_normal_hours           in     per_all_assignments_f.normal_hours%TYPE
6562   ,p_effective_date         in     date
6563   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
6564   )
6565   is
6566 --
6567    l_api_updating   boolean;
6568    l_proc           varchar2(72)  :=  g_package||'chk_frequency_normal_hours';
6569 --
6570 begin
6571 if g_debug then
6572   hr_utility.set_location('Entering:'|| l_proc, 10);
6573  end if;
6574   --
6575   if hr_multi_message.no_all_inclusive_error
6576        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.FREQUENCY'
6577        ) then
6578   --
6579   -- Check mandatory parameters have been set
6580   --
6581   hr_api.mandatory_arg_error
6582     (p_api_name       => l_proc
6583     ,p_argument       => 'effective_date'
6584     ,p_argument_value => p_effective_date
6585     );
6586 if g_debug then
6587   hr_utility.set_location(l_proc, 20);
6588  end if;
6589   --
6590   -- Only proceed with validation if :
6591   -- a) The current g_old_rec is current and
6592   -- b) The value for normal hours has changed
6593   --
6594   l_api_updating := per_asg_shd.api_updating
6595          (p_assignment_id          => p_assignment_id
6596          ,p_effective_date         => p_effective_date
6597          ,p_object_version_number  => p_object_version_number
6598          );
6599 if g_debug then
6600   hr_utility.set_location(l_proc, 30);
6601  end if;
6602   --
6603   if (l_api_updating and
6604        ((nvl(per_asg_shd.g_old_rec.frequency, hr_api.g_varchar2) <>
6605        nvl(p_frequency, hr_api.g_varchar2))
6606          or
6607        (nvl(per_asg_shd.g_old_rec.normal_hours, hr_api.g_number) <>
6608        nvl(p_normal_hours, hr_api.g_number))))
6609     or
6610        (NOT l_api_updating)
6611   then
6612 if g_debug then
6613     hr_utility.set_location(l_proc, 40);
6614  end if;
6615       --
6616       -- Check if normal hours is set
6617       --
6618       If p_frequency is not null and p_normal_hours is null then
6619         --
6620         hr_utility.set_message(801, 'HR_7387_ASG_NORMAL_HOURS_REQD');
6621         hr_utility.raise_error;
6622         --
6623       elsif p_normal_hours is not null and p_frequency is null then
6624         --
6625         hr_utility.set_message(801, 'HR_7396_ASG_FREQUENCY_REQD');
6626         hr_utility.raise_error;
6627         --
6628       elsif p_frequency is not null and p_normal_hours is not null then
6629         --
6630         -- Check that value for working_hours does not
6631         -- exceed the frequency
6632         --
6633         hr_assignment.check_hours
6634           (p_frequency     =>  p_frequency
6635           ,p_normal_hours  =>  p_normal_hours
6636           );
6637 if g_debug then
6638         hr_utility.set_location(l_proc, 50);
6639  end if;
6640         --
6641     end if;
6642 if g_debug then
6643     hr_utility.set_location(l_proc, 60);
6644  end if;
6645     --
6646   end if;
6647   end if;
6648   --
6649 if g_debug then
6650   hr_utility.set_location(' Leaving:'|| l_proc, 70);
6651  end if;
6652    exception
6653   when app_exception.application_exception then
6654     if hr_multi_message.exception_add
6655          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.FREQUENCY'
6656          ,p_associated_column2      => 'PER_ALL_ASSIGNMENTS_F.NORMAL_HOURS'
6657          ) then
6658 if g_debug then
6659       hr_utility.set_location(' Leaving:'|| l_proc, 80);
6660  end if;
6661       raise;
6662     end if;
6663 if g_debug then
6664     hr_utility.set_location(' Leaving:'|| l_proc, 90);
6665  end if;
6666 end chk_frequency_normal_hours;
6667 --
6668 --  ---------------------------------------------------------------------------
6669 --  |-----------------------< chk_organization_id >---------------------------|
6670 --  ---------------------------------------------------------------------------
6671 --
6672 procedure chk_organization_id
6673   (p_primary_flag            in  per_all_assignments_f.primary_flag%TYPE
6674   ,p_assignment_id           in  per_all_assignments_f.assignment_id%TYPE
6675   ,p_organization_id         in  per_all_assignments_f.organization_id%TYPE
6676   ,p_business_group_id       in  per_all_assignments_f.business_group_id%TYPE
6677   ,p_assignment_type         in  per_all_assignments_f.assignment_type%TYPE
6678   ,p_vacancy_id              in  per_all_assignments_f.vacancy_id%TYPE
6679   ,p_validation_start_date   in  per_all_assignments_f.effective_start_date%TYPE
6680   ,p_validation_end_date     in  per_all_assignments_f.effective_end_date%TYPE
6681   ,p_effective_date          in  date
6682   ,p_object_version_number   in  per_all_assignments_f.object_version_number%TYPE
6683   ,p_manager_flag               in  per_all_assignments_f.manager_flag%TYPE
6684   ,p_org_now_no_manager_warning in out nocopy boolean
6685   ,p_other_manager_warning      in out nocopy boolean
6686   )
6687 is
6688   --
6689   l_exists               varchar2(1);
6690   l_api_updating         boolean;
6691   l_proc                 varchar2(72)  :=  g_package||'chk_organization_id';
6692   l_vac_organization_id  per_all_assignments_f.organization_id%TYPE;
6693   l_business_group_id    per_all_assignments_f.business_group_id%TYPE;
6694   --
6695   -- bugfix 2452613: use full table not secure view for validation
6696   --
6697   cursor csr_valid_int_hr_org is
6698     select   business_group_id
6699     from     hr_all_organization_units
6700     where    organization_id     = p_organization_id
6701     and      internal_external_flag = 'INT';
6702    --
6703   cursor csr_valid_per_org is
6704     select   null
6705     from     per_organization_units
6706     where    organization_id     = p_organization_id;
6707   --
6708 begin
6709 if g_debug then
6710   hr_utility.set_location('Entering:'|| l_proc, 10);
6711  end if;
6712   --
6713   --
6714   -- Check mandatory parameters have been set
6715   --
6716   hr_api.mandatory_arg_error
6717     (p_api_name       => l_proc
6718     ,p_argument       => 'effective_date'
6719     ,p_argument_value => p_effective_date
6720     );
6721   --
6722   hr_api.mandatory_arg_error
6723     (p_api_name       => l_proc
6724     ,p_argument       => 'organization_id'
6725     ,p_argument_value => p_organization_id
6726     );
6727   --
6728   hr_api.mandatory_arg_error
6729     (p_api_name       => l_proc
6730     ,p_argument       => 'business_group_id'
6731     ,p_argument_value => p_business_group_id
6732     );
6733   --
6734   hr_api.mandatory_arg_error
6735     (p_api_name       => l_proc
6736     ,p_argument       => 'validation_start_date'
6737     ,p_argument_value => p_validation_start_date
6738     );
6739   --
6740   hr_api.mandatory_arg_error
6741     (p_api_name       => l_proc
6742     ,p_argument       => 'validation_end_date'
6743     ,p_argument_value => p_validation_end_date
6744     );
6745 if g_debug then
6746   hr_utility.set_location(l_proc, 20);
6747  end if;
6748   --
6749   -- Only proceed with validation if :
6750   -- a) The current  g_old_rec is current and
6751   -- b) The value for organization_id has changed
6752   --
6753   l_api_updating := per_asg_shd.api_updating
6754          (p_assignment_id          => p_assignment_id
6755          ,p_effective_date         => p_effective_date
6756          ,p_object_version_number  => p_object_version_number
6757          );
6758 if g_debug then
6759   hr_utility.set_location(l_proc, 30);
6760  end if;
6761   --
6762   if (l_api_updating and
6763      per_asg_shd.g_old_rec.organization_id <> p_organization_id)
6764     or
6765       NOT l_api_updating
6766   then
6767 if g_debug then
6768     hr_utility.set_location(l_proc, 40);
6769  end if;
6770 
6771     --
6772     -- Check that organization exists and is date effective
6773     -- on hr_organization_units for an internal organization.
6774     --
6775     open csr_valid_int_hr_org;
6776     fetch csr_valid_int_hr_org into l_business_group_id;
6777     --
6778     if csr_valid_int_hr_org%notfound then
6779       close csr_valid_int_hr_org;
6780       hr_utility.set_message(801, 'HR_34983_ASG_INVALID_ORG');
6781       hr_multi_message.add
6782         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ORGANIZATION_ID'
6783    );
6784       --
6785     else
6786       close csr_valid_int_hr_org;
6787     end if;
6788 if g_debug then
6789     hr_utility.set_location(l_proc, 50);
6790  end if;
6791     --
6792     -- Check that the organization is in the same business group
6793     -- as the business group of the assignment.
6794     --
6795     If p_business_group_id <> l_business_group_id then
6796       --
6797       hr_utility.set_message(801, 'HR_7376_ASG_INVALID_BG_ORG');
6798       hr_multi_message.add
6799         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ORGANIZATION_ID'
6800    );
6801       --
6802     end if;
6803 if g_debug then
6804     hr_utility.set_location(l_proc, 60);
6805  end if;
6806     --
6807     -- Check if an insert is taking place.
6808     --
6809     if NOT l_api_updating and p_primary_flag = 'Y' then
6810       --
6811       null;
6812       --
6813     else
6814       -- Check for a primary assignment
6815       --
6816       if p_primary_flag = 'Y' then
6817         --
6818         -- Check that the organization exists in PER_ORGANIZATION_UNITS.
6819         --
6820         open csr_valid_per_org;
6821         fetch csr_valid_per_org into l_exists;
6822         if csr_valid_per_org%notfound then
6823           close csr_valid_per_org;
6824           hr_utility.set_message(801, 'HR_51277_ASG_INV_HR_ORG');
6825           hr_multi_message.add
6826           (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.ORGANIZATION_ID'
6827      );
6828           --
6829         else
6830           close csr_valid_per_org;
6831         end if;
6832 if g_debug then
6833    hr_utility.set_location(l_proc, 70);
6834  end if;
6835         --
6836       end if;
6837       --
6838     end if;
6839     --
6840     -- Check if the assignment is an employee assignment
6841     --
6842     If p_assignment_type = 'E' then
6843       --
6844       if hr_multi_message.no_exclusive_error
6845        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.MANAGER_FLAG'
6846        ) then
6847       --
6848       -- Check if manager flag is 'Y'
6849       --
6850       if p_manager_flag = 'Y' then
6851         --
6852         -- Check whether another current assignment exists in the same
6853         -- organization with manager flag set to 'Y'.
6854         --
6855         if per_asg_bus2.other_managers_in_org
6856           (p_organization_id => p_organization_id
6857           ,p_assignment_id   => p_assignment_id
6858           ,p_effective_date  => p_effective_date
6859           )
6860           then
6861           --
6862 if g_debug then
6863           hr_utility.set_location(l_proc, 100);
6864  end if;
6865           --
6866           p_other_manager_warning := TRUE;
6867         else
6868           --
6869 if g_debug then
6870           hr_utility.set_location(l_proc, 110);
6871  end if;
6872           --
6873           p_org_now_no_manager_warning := TRUE;
6874         end if;
6875         --
6876       end if;
6877       end if; -- no exclusive error
6878       --
6879     end if; -- p_assignment_type = 'E'
6880 if g_debug then
6881         hr_utility.set_location(l_proc, 130);
6882  end if;
6883         --
6884     end if;
6885     --
6886   --
6887 if g_debug then
6888   hr_utility.set_location(' Leaving:'|| l_proc, 140);
6889  end if;
6890 end chk_organization_id;
6891 --
6892 --
6893 -- ----------------------------------------------------------------------------
6894 -- |----------------------< chk_bargaining_unit_code >------------------------|
6895 -- ----------------------------------------------------------------------------
6896 --
6897 --  Description:
6898 --     Validates that the bargaining_unit_code entered exists in fnd_common_lookups
6899 --     on the effective date.
6900 --
6901 --  Pre-conditions:
6902 --    A valid bargaining_unit_code
6903 --
6904 --  In Arguments:
6905 --    p_assignment_id
6906 --    p_bargaining_unit_code
6907 --    p_effective_date
6908 --    p_object_version_number
6909 --    p_validation_start_date
6910 --    p_validation_end_date
6911 --
6912 --  Post Success:
6913 --    Processing continues if :
6914 --      - the bargaining_unit_code is valid
6915 --
6916 --  Post Failure:
6917 --    An application error is raised and processing ends if:
6918 --      - the bargaining_unit_code does not exist in fnd_common_lookups on the
6919 --        effective date.
6920 --
6921 --  Access Status:
6922 --    Internal Table Handler Use Only
6923 --
6924 procedure chk_bargaining_unit_code
6925   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
6926   ,p_bargaining_unit_code   in     per_all_assignments_f.bargaining_unit_code%TYPE
6927   ,p_effective_date         in     date
6928   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
6929   ,p_validation_start_date  in     date
6930   ,p_validation_end_date    in     date
6931   )
6932   is
6933 --
6934   l_proc           varchar2(72)  :=  g_package||'chk_bargaining_unit_code';
6935   l_bargaining_unit_code varchar2(72);
6936   --
6937   begin
6938 if g_debug then
6939   hr_utility.set_location('Entering:'|| l_proc, 10);
6940  end if;
6941   --
6942   -- Check mandatory parameters have been set
6943   --
6944   hr_api.mandatory_arg_error
6945     (p_api_name       => l_proc
6946     ,p_argument       => 'effective_date'
6947     ,p_argument_value => p_effective_date
6948     );
6949 if g_debug then
6950   hr_utility.set_location(l_proc, 20);
6951  end if;
6952   --
6953   if p_bargaining_unit_code is NOT NULL then
6954     if hr_api.not_exists_in_dt_hr_lookups
6955       (p_effective_date   => p_effective_date
6956       ,p_validation_start_date => p_validation_start_date
6957       ,p_validation_end_date   => p_validation_end_date
6958       ,p_lookup_type           => 'BARGAINING_UNIT_CODE'
6959       ,p_lookup_code           => p_bargaining_unit_code
6960       )
6961     then
6962       hr_utility.set_message(800, 'PER_52383_ASG_BARG_UNIT_CODE');
6963       hr_utility.raise_error;
6964     end if;
6965   end if;
6966   --
6967 if g_debug then
6968   hr_utility.set_location(' Leaving:'||l_proc, 30);
6969  end if;
6970    exception
6971   when app_exception.application_exception then
6972     if hr_multi_message.exception_add
6973          (p_associated_column1      => 'PER_ALL_ASSIGNMENTS_F.BARGAINING_UNIT_CODE'
6974          ) then
6975 if g_debug then
6976       hr_utility.set_location(' Leaving:'|| l_proc, 40);
6977  end if;
6978       raise;
6979     end if;
6980 if g_debug then
6981     hr_utility.set_location(' Leaving:'|| l_proc, 50);
6982  end if;
6983 --
6984 end chk_bargaining_unit_code;
6985 --
6986 -- ----------------------------------------------------------------------------
6987 -- |----------------------< chk_hourly_salaried_code >------------------------|
6988 -- ----------------------------------------------------------------------------
6989 --
6990 --  Description:
6991 --     Validates that the hourly_salaried_code entered exists in fnd_common_lookups
6992 --     on the effective date.
6993 --
6994 --  Pre-conditions:
6995 --    A valid hourly_salaried_code
6996 --
6997 --  In Arguments:
6998 --    p_assignment_id
6999 --    p_hourly_salaried_code
7000 --    p_effective_date
7001 --    p_object_version_number
7002 --    p_validation_start_date
7003 --    p_validation_end_date
7004 --    p_pay_basis_id
7005 --  Out Argument
7006 --    p_hourly_salaried_warning
7007 --
7008 --  Post Success:
7009 --    Processing continues if :
7010 --      - the hourly_salaried_code is valid
7011 --
7012 --  Post Failure:
7013 --    An application error is raised and processing ends if:
7014 --      - the hourly_salaried_code does not exist in fnd_common_lookups on the
7015 --        effective date.
7016 --
7017 --  Access Status:
7018 --    Internal Table Handler Use Only
7019 --
7020 procedure chk_hourly_salaried_code
7021   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
7022   ,p_hourly_salaried_code   in     per_all_assignments_f.hourly_salaried_code%TYPE
7023   ,p_effective_date         in     date
7024   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
7025   ,p_validation_start_date  in     date
7026   ,p_validation_end_date    in     date
7027   ,p_pay_basis_id           in     per_all_assignments_f.pay_basis_id%TYPE
7028   ,p_hourly_salaried_warning in out nocopy boolean
7029   ,p_assignment_type         in     per_all_assignments_f.assignment_type%TYPE)
7030   is
7031 --
7032   l_proc           varchar2(72)  :=  g_package||'chk_hourly_salaried_code';
7033   l_hourly_salaried_code varchar2(72);
7034   l_pay_basis      varchar2(72);
7035   --
7036   cursor csr_hourly_salaried is
7037   select pay.pay_basis
7038   from per_pay_bases pay
7039   where pay.pay_basis_id = p_pay_basis_id;
7040 
7041   begin
7042 if g_debug then
7043   hr_utility.set_location('Entering:'|| l_proc, 10);
7044  end if;
7045   --
7046   --
7047   -- Check mandatory parameters have been set
7048   --
7049   hr_api.mandatory_arg_error
7050     (p_api_name       => l_proc
7051     ,p_argument       => 'effective_date'
7052     ,p_argument_value => p_effective_date
7053     );
7054 if g_debug then
7055   hr_utility.set_location(l_proc, 20);
7056  end if;
7057   --
7058   -- If the assignment is a CWK and the hourly salary
7059   -- code has been set then raise an error.
7060   --
7061   IF p_assignment_type = 'C' AND
7062      p_hourly_salaried_code IS NOT NULL THEN
7063     --
7064    hr_utility.set_message(800,'HR_289648_CWK_HR_CODE_NOT_NULL');
7065     hr_utility.raise_error;
7066    --
7067   END IF;
7068   --
7069   if p_hourly_salaried_code is NOT NULL then
7070     if hr_api.not_exists_in_dt_hr_lookups
7071       (p_effective_date   => p_effective_date
7072       ,p_validation_start_date  => p_validation_start_date
7073       ,p_validation_end_date    => p_validation_end_date
7074       ,p_lookup_type            => 'HOURLY_SALARIED_CODE'
7075       ,p_lookup_code            => p_hourly_salaried_code
7076       )
7077     then
7078       hr_utility.set_message(800,'PER_52407_HOUR_SAL_CODE');
7079       hr_multi_message.add
7080         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.HOURLY_SALARIED_CODE'
7081    );
7082     else
7083       --
7084       if hr_multi_message.no_exclusive_error
7085        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.PAY_BASIS_ID'
7086        ) then
7087       open csr_hourly_salaried;
7088       fetch csr_hourly_salaried into l_pay_basis;
7089       if csr_hourly_salaried%FOUND then
7090         if (p_hourly_salaried_code = 'H' and
7091            l_pay_basis <> 'HOURLY')
7092            or (p_hourly_salaried_code = 'S' and
7093            l_pay_basis = 'HOURLY')
7094         then
7095 
7096    p_hourly_salaried_warning := TRUE;
7097 -- updated for bug 2033513
7098 
7099 --           hr_utility.set_message(800,'PER_6997_HOUR_SAL_BASIS');
7100 --           hr_utility.raise_error;
7101 
7102         else null;
7103         end if;
7104       end if;
7105       close csr_hourly_salaried;
7106      end if;
7107    end if; -- no exclusive error
7108    end if;
7109   --
7110 if g_debug then
7111   hr_utility.set_location(' Leaving:'||l_proc, 30);
7112  end if;
7113 --
7114 end chk_hourly_salaried_code;
7115 --
7116 --  ---------------------------------------------------------------------------
7117 --  |---------------------< return_legislation_code >-------------------------|
7118 --  ---------------------------------------------------------------------------
7119 --
7120 function return_legislation_code
7121   (p_assignment_id           in number
7122   ) return varchar2 is
7123   --
7124   -- Declare cursor
7125   -- -- --Bug fix 3604024. modified cursor to improve performance
7126   --
7127   cursor csr_leg_code is
7128   select pbg.legislation_code
7129       from per_business_groups_perf  pbg
7130       where  pbg.business_group_id =  (select distinct asg.business_group_id  from
7131                                      per_all_assignments_f    asg
7132                                     where asg.assignment_id  = p_assignment_id);
7133 
7134   --
7135   -- Declare local variables
7136   --
7137   l_legislation_code  varchar2(150);
7138   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
7139 begin
7140 if g_debug then
7141   hr_utility.set_location('Entering:'|| l_proc, 10);
7142  end if;
7143   --
7144   -- Ensure that all the mandatory parameter are not null
7145   --
7146   hr_api.mandatory_arg_error(p_api_name       => l_proc,
7147                              p_argument       => 'assignment_id',
7148                              p_argument_value => p_assignment_id);
7149   --
7150  --
7151   if nvl(g_assignment_id, hr_api.g_number) = p_assignment_id then
7152     --
7153     -- The legislation code has already been found with a previous
7154     -- call to this function. Just return the value in the global
7155     -- variable.
7156     --
7157     l_legislation_code := g_legislation_code;
7158 if g_debug then
7159     hr_utility.set_location(l_proc, 20);
7160  end if;
7161   else
7162     --
7163     -- The ID is different to the last call to this function
7164     -- or this is the first call to this function.
7165   --
7166   open csr_leg_code;
7167   fetch csr_leg_code into l_legislation_code;
7168   if csr_leg_code%notfound then
7169     close csr_leg_code;
7170     --
7171     -- The primary key is invalid therefore we must error
7172     --
7173     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
7174     hr_utility.raise_error;
7175   end if;
7176   --
7177   close csr_leg_code;
7178 if g_debug then
7179   hr_utility.set_location(' Leaving:'|| l_proc, 20);
7180  end if;
7181   --
7182     g_assignment_id    := p_assignment_id;
7183     g_legislation_code := l_legislation_code;
7184   end if;
7185 if g_debug then
7186   hr_utility.set_location(' Leaving:'|| l_proc, 30);
7187  end if;
7188   return l_legislation_code;
7189 end return_legislation_code;
7190 --
7191 --
7192 --  ---------------------------------------------------------------------------
7193 --  |----------------------<   chk_overlap_dates   >--------------------------|
7194 --  ---------------------------------------------------------------------------
7195 --  Description:
7196 --    Checks the overlap_dates of the position.
7197 --
7198 function chk_overlap_dates
7199          (p_position_id  in number, p_assignment_start_date date) return boolean is
7200 l_dummy         varchar2(30);
7201 l_position_id   number(10);
7202 l_proc          varchar2(72)  :=  g_package||'chk_overlap_dates ';
7203 
7204 /*- This cursor added for the bug 5840410 --*/
7205 
7206 cursor c1 is
7207  select 'x'
7208  from per_position_extra_info
7209  where position_id= p_position_id
7210    and information_type = 'PER_OVERLAP';
7211 
7212 cursor c2(l_position_id number) is
7213 select 'x'
7214 from per_position_extra_info
7215 where p_assignment_start_date
7216       between fnd_date.canonical_to_date(poei_information3)
7217       and fnd_date.canonical_to_date(poei_information4)
7218       and position_id= p_position_id -- l_position_id -- for bug 7129787
7219       and information_type = 'PER_OVERLAP';
7220 --
7221 begin
7222  if g_debug then
7223   hr_utility.set_location('Entering:'|| l_proc, 10);
7224  end if;
7225    if p_position_id is not null and p_assignment_start_date is not null then
7226 
7227     /*- Start Change open cursor c1 added for the bug 5840410 --*/
7228      hr_utility.set_location('Pos id and assg start date is not null ', 20);
7229      open c1;
7230      fetch c1 into l_dummy;--l_position_id; commented for 6331872
7231      if c1%found then
7232      hr_utility.set_location('Records found for cursor c1 ', 20);
7233 
7234      open c2(l_position_id);
7235      /*- End changes for the bug 5840410 --*/
7236      fetch c2 into l_dummy;
7237      if c2%found then
7238       hr_utility.set_location('Records found for cursor c2 ', 30);
7239        close c2;
7240        return(true);
7241       else
7242        hr_utility.set_location('No Records found for cursor c2 ', 40);
7243        close c2;
7244        return(false);
7245      end if;  -- c2
7246    /*- Start Change open cursor c1 added for the bug 5840410 --*/
7247    else
7248     hr_utility.set_location('No Records found for cursor c1 ', 50);
7249     close c1;
7250     return(false);
7251    end if; -- c1
7252   /*- End changes for the bug 5840410 --*/
7253   end if; -- position id not null
7254    return(false);
7255 end;
7256 --
7257 --
7258 -- ----------------------------------------------------------------------------
7259 -- |----------------------< chk_frozen_single_pos >------------------------|
7260 -- ----------------------------------------------------------------------------
7261 --
7262 --  Description:
7263 --     Validates that the whether Position attached is Frozen or another assignment
7264 --     exists for a Single Position as on the effective date.
7265 --
7266 --  Pre-conditions:
7267 --    A valid position_id
7268 --
7269 --  In Arguments:
7270 --    p_assignment_id
7271 --    p_position_id
7272 --    p_effective_date
7273 --
7274 --  Post Success:
7275 --    Processing continues if :
7276 --      - Position is not Frozen or the no assignment exist if the position
7277 --   is Single position
7278 --
7279 --  Post Failure:
7280 --    An application error is raised and processing ends if:
7281 --      - the position attached is Frozen or an assignment exists and the position
7282 --        is Single position as of effective date.
7283 --
7284 --  Access Status:
7285 --    Internal Table Handler Use Only
7286 --
7287 procedure chk_frozen_single_pos
7288   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
7289   ,p_position_id      in     per_all_assignments_f.position_id%TYPE
7290   ,p_effective_date         in     date
7291   ,p_assignment_type        in     varchar2 default 'E'
7292   )
7293   is
7294 --
7295   l_proc                varchar2(72)  :=  g_package||'chk_frozen_single_pos';
7296   l_position_type       varchar2(72);
7297   l_availability_status_id number;
7298   l_business_group_id      number;
7299   l_asg_in_overlap_dates        boolean;
7300   --
7301   cursor c_position_type(p_position_id number, p_effective_date date) is
7302   select position_type, availability_status_id, business_group_id
7303   from hr_all_positions_f
7304   where position_id = p_position_id
7305   and p_effective_date between effective_start_date and effective_end_date;
7306   --
7307   begin
7308 if g_debug then
7309   hr_utility.set_location('Entering:'|| l_proc, 10);
7310  end if;
7311   --
7312   -- Check mandatory parameters have been set
7313   --
7314   hr_api.mandatory_arg_error
7315     (p_api_name       => l_proc
7316     ,p_argument       => 'effective_date'
7317     ,p_argument_value => p_effective_date
7318     );
7319 if g_debug then
7320   hr_utility.set_location(l_proc, 20);
7321  end if;
7322   --
7323   if p_position_id is NOT NULL then
7324     open c_position_type(p_position_id, p_effective_date);
7325     fetch c_position_type into l_position_type, l_availability_status_id, l_business_group_id;
7326     close c_position_type;
7327     -- Check that the currne position is not Frozen
7328     if hr_psf_shd.get_availability_status(l_availability_status_id,l_business_group_id) ='FROZEN'
7329     then
7330       hr_utility.set_message(800, 'PER_NO_ASG_FOR_FROZEN_POS');
7331       hr_multi_message.add
7332         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.POSITION_ID'
7333    ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
7334    );
7335     end if;
7336     if (l_position_type = 'SINGLE') then
7337      l_asg_in_overlap_dates := chk_overlap_dates(p_position_id, p_effective_date);
7338      if not l_asg_in_overlap_dates then
7339       -- Check whether there are any assignments attached to a Single Position
7340       if (p_assignment_type = 'E' or p_assignment_type = 'C') then -- 6397484(forward port of 6356978)
7341       /*---- Start change for the bug 5854568  ----(modified for the bug 6331872)*/
7342       if (per_asg_bus1.pos_assignments_exists(p_position_id, p_effective_date, p_assignment_id) and p_assignment_type in ('E','C'))
7343       /*---- End change for the bug 5854568  ----(modified for the bug 6331872)*/
7344       then
7345         hr_utility.set_message(800, 'PER_ASG_EXISTS_FOR_SINGLE_POS');
7346         hr_multi_message.add
7347         (p_associated_column1 => 'PER_ALL_ASSIGNMENTS_F.POSITION_ID'
7348    ,p_associated_column2 => 'PER_ALL_ASSIGNMENTS_F.EFFECTIVE_START_DATE'
7349    );
7350       end if;
7351      end if; -- 6397484(forward port of 6356978)
7352      end if;
7353     end if;
7354   end if;
7355   --
7356 if g_debug then
7357   hr_utility.set_location(' Leaving:'||l_proc, 30);
7358  end if;
7359 --
7360 end chk_frozen_single_pos;
7361 --
7362 procedure chk_single_position
7363   (p_assignment_id          in     per_all_assignments_f.assignment_id%TYPE
7364   ,p_position_id      in     per_all_assignments_f.position_id%TYPE
7365   ,p_effective_date         in     date
7366   ,p_object_version_number  in     per_all_assignments_f.object_version_number%TYPE
7367   ,p_assignment_type        in     per_all_assignments_f.assignment_type%TYPE default 'E'
7368   )
7369   is
7370 --
7371   l_proc                varchar2(72)  :=  g_package||'chk_single_position';
7372   l_api_updating     boolean;
7373   --
7374   begin
7375  if g_debug then
7376   hr_utility.set_location('Entering:'|| l_proc, 10);
7377  end if;
7378   --
7379   if hr_multi_message.no_exclusive_error
7380        (p_check_column1      => 'PER_ALL_ASSIGNMENTS_F.POSITION_ID'
7381        ) then
7382   --
7383   -- Check mandatory parameters have been set
7384   --
7385   hr_api.mandatory_arg_error
7386     (p_api_name       => l_proc
7387     ,p_argument       => 'effective_date'
7388     ,p_argument_value => p_effective_date
7389     );
7390  if g_debug then
7391   hr_utility.set_location(l_proc, 20);
7392  end if;
7393   --
7394   l_api_updating := per_asg_shd.api_updating
7395          (p_assignment_id          => p_assignment_id
7396          ,p_effective_date         => p_effective_date
7397          ,p_object_version_number  => p_object_version_number
7398          );
7399  if g_debug then
7400   hr_utility.set_location(l_proc, 30);
7401  end if;
7402   --
7403   if (l_api_updating and
7404        (nvl(per_asg_shd.g_old_rec.position_id, hr_api.g_number) <>
7405        nvl(p_position_id, hr_api.g_number)))
7406     or
7407        (NOT l_api_updating)
7408   then
7409     per_asg_bus1.chk_frozen_single_pos
7410     (p_assignment_id         =>  p_assignment_id
7411     ,p_position_id        =>  p_position_id
7412     ,p_effective_date        =>  p_effective_date
7413     ,p_assignment_type       =>  p_assignment_type
7414     );
7415   end if;
7416   --
7417  if g_debug then
7418   hr_utility.set_location(' Leaving:'||l_proc, 30);
7419  end if;
7420 
7421   end if;
7422 --
7423 end chk_single_position;
7424 --
7425 --
7426 --
7427 -- ----------------------------------------------------------------------------
7428 -- |----------------------< pos_assignments_exists >--------------------------|
7429 -- ----------------------------------------------------------------------------
7430 --
7431 --  Description:
7432 --     Returns whether the assignment exists for the position passed or not as of
7433 --       effective_date
7434 --
7435 --  Pre-conditions:
7436 --    A valid position_id
7437 --
7438 --  In Arguments:
7439 --    p_position_id
7440 --    p_effective_date
7441 --
7442 --  Post Success:
7443 --    Returns true is assignment exists otherwise false
7444 --
7445 --  Post Failure:
7446 --    An application error is raised and processing ends if:
7447 --      No failure
7448 --
7449 --  Access Status:
7450 --    Internal Table Handler Use Only
7451 --
7452 function pos_assignments_exists(
7453    p_position_id number,
7454    p_effective_date date,
7455    p_except_assignment_id number) return boolean is
7456 l_dummy   varchar2(1);
7457 cursor c1 is
7458 select 'x'
7459 from per_all_assignments_f asg, per_assignment_status_types ast
7460 where position_id = p_position_id
7461 and assignment_id <> nvl(p_except_assignment_id, -1)
7462 and ( assignment_type = 'E' /*or assignment_type = 'A'*/)  -- change for the bug 5854568(modified for 6331872)
7463 and p_effective_date between effective_start_date and effective_end_date
7464 and asg.assignment_status_type_id = ast.assignment_status_type_id
7465 and ast.per_system_status <> 'TERM_ASSIGN';
7466 begin
7467   open c1;
7468   fetch c1 into l_dummy;
7469   close c1;
7470   if l_dummy is not null then
7471      return(true);
7472   else
7473      return(false);
7474   end if;
7475 end;
7476 --
7477 end per_asg_bus1;