DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ASG_BUS1

Source


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