DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ASSIGNMENT_API

Source


1 Package Body hr_assignment_api as
2 /* $Header: peasgapi.pkb 120.20.12010000.4 2008/09/29 13:00:03 ubhat ship $ */
3 --
4 -- Package Variables
5 --
6 g_package  CONSTANT varchar2(33) := '  hr_assignment_api.';
7 g_debug boolean := hr_utility.debug_enabled;
8 --
9 ----------------------------------------------------------------------------
10 -- |----------------------< update_pgp_concat_segs >------------------------|
11 ----------------------------------------------------------------------------
12 -- {Start Of Comments}
13 --
14 -- Description:
15 --   When required this procedure updates the pay_people_groups table after
16 --   the flexfield segments have been inserted to keep the concatenated
17 --   segment string up-to-date.
18 --
19 -- Prerequisites:
20 --   A row must exist in the pay_people_groups table for the
21 --   given people_group_id.
22 --
23 -- In Parameters:
24 --   Name                           Reqd Type     Description
25 --   p_people_group_id              Yes  number   The primary key
26 --   p_group_name                   Yes  varchar2 The concatenated segments
27 --
28 -- Post Success:
29 --   If required the row is updated and committed.
30 --
31 -- Post Failure:
32 --   The procedure will raise an error.
33 --
34 -- Access Status:
35 --   Internal use only.
36 --
37 -- {End Of Comments}
38 --
39 procedure update_pgp_concat_segs
40   (p_people_group_id              in     number
41   ,p_group_name                   in     varchar2
42   ) is
43   --
44   CURSOR csr_chk_pgp is
45     SELECT null
46       FROM pay_people_groups
47      where people_group_id = p_people_group_id
48        and (group_name     <> p_group_name
49         or group_name is null);
50   --
51   l_exists  varchar2(30);
52   l_proc   varchar2(72) := g_package||'update_pgp_concat_segs';
53   --
54   procedure update_pgp_concat_segs_auto
55     (p_people_group_id              in     number
56     ,p_group_name                   in     varchar2
57     ) is
58     PRAGMA AUTONOMOUS_TRANSACTION;
59     --
60     CURSOR csr_pgp_lock is
61       SELECT null
62         FROM pay_people_groups
63        where people_group_id = p_people_group_id
64          for update nowait;
65     --
66     l_exists  varchar2(30);
67     l_proc    varchar2(72) := g_package||'update_pgp_concat_segs_auto';
68     --
69   begin
70     if g_debug then
71     hr_utility.set_location('Entering:'|| l_proc, 10);
72     end if;
73     --
74     -- The outer procedure has already establish that an update is
75     -- required. This sub-procedure uses an autonomous transaction
76     -- to ensure that any commits do not impact the main transaction.
77     -- If the row is successfully locked then continue and update the
78     -- row. If the row cannot be locked then another transaction must
79     -- be performing the update. So it is acceptable for this
80     -- transaction to silently trap the error and continue.
81     --
82     -- Note: It is necessary to perform the lock test because in
83     -- a batch data upload scenario multiple sessions could be
84     -- attempting to insert or update the same Key Flexfield
85     -- combination at the same time. Just directly updating the row,
86     -- without first locking, can cause sessions to hang and reduce
87     -- batch throughput.
88     --
89     open csr_pgp_lock;
90     fetch csr_pgp_lock into l_exists;
91     if csr_pgp_lock%found then
92       close csr_pgp_lock;
93 
94       if g_debug then
95       hr_utility.set_location(l_proc, 20);
96       end if;
97       --
98       -- Lock obtained by this transaction, updating the concatenated
99       -- segment string should be performed.
100       --
101       update pay_people_groups
102          set group_name      = p_group_name
103        where people_group_id = p_people_group_id
104          and (group_name     <> p_group_name
105           or group_name is null);
106       --
107       -- Commit this change so the change is immediately visible to
108       -- other transactions. Also ensuring that it is not undone if
109       -- the main transaction is rolled back. This commit is only
110       -- acceptable inside an API because it is being performed inside
111       -- an autonomous transaction and AOL code has previously
112       -- inserted the Key Flexfield combination row in another
113       -- autonomous transaction.
114       commit;
115     else
116       close csr_pgp_lock;
117       rollback; -- Added for bug 3578845.
118     end if;
119     --
120     if g_debug then
121     hr_utility.set_location('Leaving:'|| l_proc, 30);
122     end if;
123 
124   Exception
125     When HR_Api.Object_Locked then
126       --
127       -- This autonomous transaction was unable to lock the row.
128       -- It can be assumed that another transaction has locked the
129       -- row and is performing the update. Hence the error can
130       -- be suppressed without raising it to the end user.
131       --
132       rollback; -- Added for bug 3578845.
133       hr_utility.set_location('Leaving:'|| l_proc, 40);
134   end update_pgp_concat_segs_auto;
135 begin
136 --
137   if g_debug then
138   hr_utility.set_location('Entering:'|| l_proc, 10);
139   end if;
140   --
141   -- First find out if it is necessary to update the concatenated
142   -- segment string column. This select is being done to avoid the
143   -- performance unnecessary overhead of set-up an autonomous
144   -- transaction when an update is not required. Updates are only
145   -- expected immediately after the combination row was first inserted.
146   --
147   open csr_chk_pgp;
148   fetch csr_chk_pgp into l_exists;
149   if csr_chk_pgp%found then
150     close csr_chk_pgp;
151     update_pgp_concat_segs_auto
152       (p_people_group_id => p_people_group_id
153       ,p_group_name      => p_group_name
154       );
155   else
156     close csr_chk_pgp;
157   end if;
158   --
159  if g_debug then
160   hr_utility.set_location('Leaving:'|| l_proc, 20);
161  end if;
162   --
163 end update_pgp_concat_segs;
164 --
165 -- Start of fix for bug 6008188
166 ----------------------------------------------------------------------------
167 -- |----------------------< reverse_term_apln >------------------------|
168 ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 
172 -- Description:
173 --   This procedure is used to reverse the termination of an applicant at
174 -- application level.
175 --
176 -- Prerequisites:
177 --   data must exists in the table per_all_assignments_f for an Person
178 --
179 -- In Parameters:
180 --   Name                           Reqd Type     Description
181 --  p_effective_date			yes        Effective date
182 --  p_business_group_id			yes        Business Group id
183 --  p_assignment_id			yes	   Assignment id
184 --   p_person_id			yes	   Person id of the person
185 -- p_status_change_reason               No         Reason for reverse termination .
186 --
187 -- Post Success:
188 --   The row is updated
189 --
190 -- Post Failure:
191 --   The procedure will raise an error.
192 --
193 -- Access Status:
194 --   Internal use only.
195 --
196 -- {End Of Comments}
197 
198 PROCEDURE reverse_term_apln ( p_effective_date date ,p_business_group_id number ,
199                                p_assignment_id number, p_person_id number,
200 			       p_status_change_reason   in  varchar2 default null
201 			       ,p_return_status out nocopy varchar2) is
202 -- declare all cursors and variables
203 l_proc               varchar2(72);
204 l_date_end          date;
205 l_asg_end_date      date;
206 l_cost_warning      boolean;
207 l_assignment_status_id number;
208 l_date_recieved date;
209 l_eot date := hr_api.g_eot;
210 l_ass_status varchar2(20);
211 l_dummy varchar2(10);
212 l_asg_status_id  number;
213 l_object_version_number number;
214 l_ptu_date_end date;
215 l_application_id number;
216 l_asg_start_date date;
217 l_ovn number;
218 
219 l_validation_start_date  date;
220 l_validation_end_date date;
221 
222 
223 cursor c1 is
224 select date_end ,date_received, application_id
225 from per_applications papp
226 where application_id =
227            ( select distinct (application_id)
228          from per_all_assignments_f
229             where assignment_id = p_assignment_id and
230                 business_group_id = p_business_group_id )
231 for update nowait;
232 
233 cursor c2 is
234   select 1
235   from per_all_assignments_f a
236   where assignment_id = p_assignment_id
237   and exists
238        (select null
239         from   per_assignment_status_types b
240         where  b.per_system_status in ('TERM_APL','ACTIVE_ASSIGN')
241         and    a.assignment_status_type_id = b.assignment_status_type_id) ;
242 
243 cursor c3(p_date_end date) is
244   SELECT 1
245   FROM   PER_ALL_PEOPLE_F PAPF
246   WHERE  PAPF.PERSON_ID = P_PERSON_ID
247   AND    PAPF.EFFECTIVE_START_DATE > p_DATE_END + 1 ;
248 
249 
250 cursor csr_ptu_row (p_date_received in date ) is
251 select   ptu.effective_start_date
252 from  per_person_type_usages_f ptu
253       ,per_person_types ppt
254 where    ptu.person_id = p_person_id
255 and   ptu.effective_start_date > p_date_received
256 and   ptu.person_type_id = ppt.person_type_id
257 and     ppt.system_person_type = 'EX_APL'
258 order by ptu.effective_start_date;
259 
260 -- end of declaration
261 begin
262 --            l_proc := 'REVERSE_TERM_APLN';
263 p_return_status:='S';
264   hr_multi_message.enable_message_list;
265  hr_utility.set_location('Entering:'|| l_proc, 10);
266  -- check whether the Person is an Applicant or an Ex-applicant
267  open c1;
268  fetch c1 into l_date_end ,l_date_recieved, l_application_id;
269  --close c1;
270  --
271 
272 
273  --hr_multi_message.enable_message_list;
274 
275 
276   --fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
277   --fnd_message.raise_error ;
278   --  hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
279   --  hr_utility.raise_error ;
280   --fnd_message.set_token('ATTRIBUTE_NAME','ERROR');
281   -- hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
282    --                      , p_message_type  => hr_multi_message.g_error_msg);
283 
284 
285 
286  hr_utility.set_location('REVERSE_TERM_APLN - p_effective_date:'|| p_effective_date, 10);
287  hr_utility.set_location('REVERSE_TERM_APLN - p_business_group_id:'|| p_business_group_id, 10);
288  hr_utility.set_location('REVERSE_TERM_APLN - p_assignment_id:'|| p_assignment_id, 10);
289  hr_utility.set_location('REVERSE_TERM_APLN - p_person_id:'|| p_person_id, 10);
290  hr_utility.set_location('REVERSE_TERM_APLN - l_date_end:'|| l_date_end, 10);
291 
292 
293  select effective_start_date, effective_end_date,object_version_number into l_asg_start_date,l_asg_end_date,l_ovn
294  from per_all_assignments_f
295  where assignment_id = p_assignment_id
296  and effective_end_date = (select max(effective_end_date)
297  from per_all_assignments_f
298  where assignment_id = p_assignment_id );
299 
300  hr_utility.set_location('REVERSE_TERM_APLN - l_asg_end_date:'|| l_asg_end_date, 20);
301 
302    select assignment_status_type_id into l_assignment_status_id
303    from per_all_assignments_f
304    where assignment_id = p_assignment_id
305    and effective_end_date = l_asg_end_date ;
306 
307  hr_utility.set_location('REVERSE_TERM_APLN - l_assignment_status_id:'|| l_assignment_status_id, 30);
308 
309 if l_date_end is null then
310   --  then the person is currently an Applicant with any flavour of persontype
311    hr_utility.set_location('REVERSE_TERM_APLN - Entering:'|| l_proc, 40);
312  open c2;
313  fetch c2 into l_dummy;
314  if c2%found then
315     close c2 ;
316     fnd_message.set_name ( 'PAY', 'HR_6083_APP_ASS_APPL_STAT_END' );
317     app_exception.raise_exception ;
318  end if;
319  close c2;
320 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
321 --to be in sync with the  assignments data
322 
323  hr_utility.set_location('Entering:'|| l_proc, 50);
324  hr_assignment.tidy_up_ref_int ( p_assignment_id,
325                                  'FUTURE',
326                                   null,
327                                   l_asg_end_date,
328                                   null,
329                                   null,
330                                  l_cost_warning ) ;
331 -- clean up the letter requests.
332  per_app_asg_pkg.cleanup_letters
333    (p_assignment_id => p_assignment_id);
334     hr_utility.set_location('Entering:'|| l_proc, 60);
335 
336 -- calling the IRC packages to maintain the IRC Assignment Statuses
337 
338 
339        IRC_ASG_STATUS_API.create_irc_asg_status
340            ( p_validate                   => FALSE
341            , p_assignment_id              => p_assignment_id
342             , p_assignment_status_type_id  => l_assignment_status_id
343            , p_status_change_date         =>  p_effective_date
344            , p_assignment_status_id       => l_asg_status_id
345            , p_object_version_number      => l_object_version_number
346 	   ,p_status_change_reason         => p_status_change_reason
347             );
348 
349 -- now update the assignments table
350 -- we must lock the row before we update it
351 
352 per_asg_shd.lck (p_effective_date =>l_asg_end_date ,
353      p_datetrack_mode => 'CORRECTION',
354      p_assignment_id  =>p_assignment_id,
355      p_object_version_number =>l_ovn,
356      p_validation_start_date =>l_validation_start_date,
357      p_validation_end_date => l_validation_end_date);
358 
359 
360  hr_utility.set_location('Entering:'|| l_proc, 70);
361 
362    update per_all_assignments_f
363    set effective_end_date =  l_eot
364    where assignment_id = p_assignment_id
365       and person_id=p_person_id
366       and business_group_id= p_business_group_id
367       and effective_end_date = l_asg_end_date;
368 
369 hr_utility.set_location(' Leaving : '||l_proc  ,80);
370 
371 
372  else  --  CASE  2
373 
374  hr_utility.set_location('Entering:'|| l_proc, 90);
375 
376  -- Person is currently an Ex-Applicant with any falvour of Person Type
377 -- Check if the person is currently hired as Emp with that Assignment if so raise an error
378 
379 PER_APPLICATIONS_PKG .cancel_chk_current_emp(p_person_id  => p_person_id ,
380                                              p_business_group_id => p_business_group_id ,
381                                               p_date_end          => l_date_end );
382 
383  hr_utility.set_location('Entering:'|| l_proc, 100);
384 
385  --Check for Future Person type changes
386 
387  open c3(l_date_end) ;
388  fetch c3 into l_dummy ;
389  if c3%found then
390     close c3 ;
391     fnd_message.set_name ( 'PER', 'HR_6385_APP_TERM_FUT_CHANGES' );
392     hr_utility.set_message(801,'HR_6385_APP_TERM_FUT_CHANGES' );
393     hr_multi_message.add (p_associated_column1 => 'ATTR_NAME'
394                          , p_message_type  => hr_multi_message.g_error_msg);
395 
396     hr_utility.raise_error ;
397  end if;
398  close c3 ;
399 
400   hr_utility.set_location('Entering:'|| l_proc, 110);
401 
402 -- Maintain the Person data by deleting the Ex-Appl Record and the same with PTU Data.
403 
404   DELETE FROM per_all_people_f papf
405    WHERE       papf.person_id               = p_person_id
406    AND         papf.business_group_id + 0   = p_Business_group_id
407    AND         papf.effective_start_date    = l_date_end + 1;
408 --
409 
410  hr_utility.set_location('REVERSE_TERM_APLN - l_date_end:'|| l_date_end, 120);
411 
412     UPDATE  per_all_people_f papf
413     SET     papf.effective_end_date  = l_eot
414     WHERE   papf.person_id           = p_person_id
415     AND     papf.BUSINESS_GROUP_ID + 0  = p_Business_group_id
416     AND     papf.effective_end_date  = l_date_end;
417 
418      hr_utility.set_location('Entering:'|| l_proc, 130);
419 
420   hr_utility.set_location('REVERSE_TERM_APLN - l_date_recieved:'|| l_date_recieved, 140);
421     hr_utility.set_location('REVERSE_TERM_APLN - l_application_id:'|| l_application_id, 140);
422 
423  open csr_ptu_row (l_date_recieved );
424      fetch csr_ptu_row into l_ptu_date_end;
425      close csr_ptu_row;
426 
427   hr_utility.set_location('REVERSE_TERM_APLN - l_ptu_date_end:'|| l_ptu_date_end, 150);
428 
429  hr_per_type_usage_internal.cancel_person_type_usage
430      (
431         p_effective_date         => l_ptu_date_end
432        ,p_person_id              => p_person_id
433        ,p_system_person_type     => 'EX_APL'
434      );
435 
436        hr_utility.set_location('Entering:'|| l_proc, 160);
437 
438 -- Make a call to the IRC packages to maintain the IRC Assignment Statuses hr_utility.set_location('PER_APPLICATIONS_PKG.maintain_irc_ass_status', 30);
439 
440 irc_asg_status_api.create_irc_asg_status
441                 (p_validate                => FALSE,
442                  p_assignment_id              => p_assignment_id,
443                  p_assignment_status_type_id  => l_assignment_status_id,
444                  p_status_change_date         => p_effective_date,
445                  p_assignment_status_id       => l_asg_status_id,
446                  p_object_version_number      => l_object_version_number,
447 		 p_status_change_reason         => p_status_change_reason);
448 
449 hr_utility.set_location('Entering:'|| l_proc, 170);
450 
451 -- make the data in the other tables ( namely tax records , secondary assignments statuses , letter requests )
452 --to be in sync with the  assignments data
453 
454  hr_assignment.tidy_up_ref_int ( p_assignment_id,
455                                  'FUTURE',
456                                   null,
457                                   l_asg_end_date,
458                                   null,
459                                   null,
460                                  l_cost_warning ) ;
461 -- clean up the letter requests.
462 hr_utility.set_location('Entering:'|| l_proc, 180);
463 
464  per_app_asg_pkg.cleanup_letters
465    (p_assignment_id => p_assignment_id);
466 
467     UPDATE PER_APPLICATIONS
468     SET date_end =null
469     where APPLICATION_ID =l_application_id
470           and person_id= p_person_id ;
471 
472 -- now update the assignments table
473 -- we must lock the row before we update it
474 
475 per_asg_shd.lck (p_effective_date =>l_asg_end_date ,
476      p_datetrack_mode => 'CORRECTION',
477      p_assignment_id  =>p_assignment_id,
478      p_object_version_number =>l_ovn,
479      p_validation_start_date =>l_validation_start_date,
480      p_validation_end_date => l_validation_end_date);
481 
482 
483    update per_all_assignments_f
484    set effective_end_date =  l_eot
485    where assignment_id = p_assignment_id
486       and person_id=p_person_id
487       and business_group_id= p_business_group_id
488         and effective_end_date = l_asg_end_date;
489 
490    hr_utility.set_location('Entering:'|| l_proc, 190);
491 end if;
492 close c1;
493 p_return_status := hr_multi_message.get_return_status_disable;
494 EXCEPTION
495 
496 when hr_multi_message.error_message_exist then
497 
498     p_return_status:='E';
499     hr_utility.set_location(' Leaving:' || l_proc, 30);
500   when others then
501   if c1%isopen then
502   close c1;
503   end if;
504   p_return_status:='E';
505   hr_utility.set_location('Entering:'|| l_proc, 200);
506     --raise;
507 end;
508 --
509 --
510 -- end of fix for bug 6008188
511 ----------------------------------------------------------------------------
512 -- |----------------------< update_scl_concat_segs >------------------------|
513 ----------------------------------------------------------------------------
514 -- {Start Of Comments}
515 --
516 -- Description:
517 --   This procedure updates the hr_soft_coding_keyflex table after the flexfield
518 --   segments have been inserted to keep the concatenated segment field up to
519 --   date.
520 --
521 -- Prerequisites:
522 --   A row must exist in the hr_soft_coding_keyflex table for p_soft_coding_keyflex_id
523 --
524 -- In Parameters:
525 --   Name                           Reqd Type     Description
526 --   p_soft_coding_keyflex_id       Yes  number   The primary key
527 --   p_concatenated_segments        Yes  varchar2 The concatenated segments
528 --
529 -- Post Success:
530 --   The row is updated
531 --
532 -- Post Failure:
533 --   The procedure will raise an error.
534 --
535 -- Access Status:
536 --   Internal use only.
537 --
538 -- {End Of Comments}
539 --
540 procedure update_scl_concat_segs
541   (p_soft_coding_keyflex_id       in     number
542   ,p_concatenated_segments        in     varchar2
543   ) is
544   --
545   --
546   CURSOR csr_chk_scl is
547     SELECT null
548       FROM 	hr_soft_coding_keyflex
549      where  soft_coding_keyflex_id =  p_soft_coding_keyflex_id
550        and (concatenated_segments  <> p_concatenated_segments
551         or concatenated_segments is null);
552   --
553   l_exists  varchar2(30);
554   l_proc   varchar2(72) := g_package||'update_scl_concat_segs ';
555   --
556   procedure update_scl_concat_segs_auto
557    ( p_soft_coding_keyflex_id       in     number
558     ,p_concatenated_segments        in     varchar2
559    ) is
560     PRAGMA AUTONOMOUS_TRANSACTION;
561     --
562     CURSOR csr_scl_lock is
563       SELECT null
564        FROM 	hr_soft_coding_keyflex
565        where  soft_coding_keyflex_id =  p_soft_coding_keyflex_id
566          for update nowait;
567     --
568     l_exists  varchar2(30);
569     l_proc    varchar2(72) := g_package||'update_scl_concat_segs_auto';
570     --
571   begin
572     if g_debug then
573     hr_utility.set_location('Entering:'|| l_proc, 10);
574     end if;
575     --
576     -- The outer procedure has already establish that an update is
577     -- required. This sub-procedure uses an autonomous transaction
578     -- to ensure that any commits do not impact the main transaction.
579     -- If the row is successfully locked then continue and update the
580     -- row. If the row cannot be locked then another transaction must
581     -- be performing the update. So it is acceptable for this
582     -- transaction to silently trap the error and continue.
583     --
584     -- Note: It is necessary to perform the lock test because in
585     -- a batch data upload scenario multiple sessions could be
586     -- attempting to insert or update the same Key Flexfield
587     -- combination at the same time. Just directly updating the row,
588     -- without first locking, can cause sessions to hang and reduce
589     -- batch throughput.
590     --
591     open csr_scl_lock;
592     fetch csr_scl_lock into l_exists;
593     if csr_scl_lock%found then
594       close csr_scl_lock;
595 
596       if g_debug then
597       hr_utility.set_location(l_proc, 20);
598       end if;
599       --
600       -- Lock obtained by this transaction, updating the concatenated
601       -- segment string should be performed.
602       --
603       update  hr_soft_coding_keyflex
604   	  set     concatenated_segments  = p_concatenated_segments
605   	  where   soft_coding_keyflex_id = p_soft_coding_keyflex_id
606          and (concatenated_segments   <> p_concatenated_segments
607           or  concatenated_segments is null);
608       --
609       -- Commit this change so the change is immediately visible to
610       -- other transactions. Also ensuring that it is not undone if
611       -- the main transaction is rolled back. This commit is only
612       -- acceptable inside an API because it is being performed inside
613       -- an autonomous transaction and AOL code has previously
614       -- inserted the Key Flexfield combination row in another
615       -- autonomous transaction.
616       commit;
617     else
618       close csr_scl_lock;
619       rollback; -- Added for bug 3578845.
620     end if;
621     --
622     if g_debug then
623     hr_utility.set_location('Leaving:'|| l_proc, 30);
624     end if;
625 
626   Exception
627     When HR_Api.Object_Locked then
628       --
629       -- This autonomous transaction was unable to lock the row.
630       -- It can be assumed that another transaction has locked the
631       -- row and is performing the update. Hence the error can
632       -- be suppressed without raising it to the end user.
633       --
634       rollback; -- Added for bug 3578845.
635       hr_utility.set_location('Leaving:'|| l_proc, 40);
636   end update_scl_concat_segs_auto;
637 begin
638 --
639   if g_debug then
640   hr_utility.set_location('Entering:'|| l_proc, 10);
641   end if;
642   --
643   -- First find out if it is necessary to update the concatenated
644   -- segment string column. This select is being done to avoid the
645   -- performance unnecessary overhead of set-up an autonomous
646   -- transaction when an update is not required. Updates are only
647   -- expected immediately after the combination row was first inserted.
648   --
649   open csr_chk_scl;
650   fetch csr_chk_scl into l_exists;
651   if csr_chk_scl%found then
652     close csr_chk_scl;
653     update_scl_concat_segs_auto
654       (p_soft_coding_keyflex_id  => p_soft_coding_keyflex_id
655       ,p_concatenated_segments   => p_concatenated_segments
656       );
657   else
658     close csr_chk_scl;
659   end if;
660   --
661  if g_debug then
662   hr_utility.set_location('Leaving:'|| l_proc, 20);
663  end if;
664   --
665 end update_scl_concat_segs;
666 -----------------------------------------------------------------------
667 -- | ---------------<validate_SCL > --------------------------------| --
668 -----------------------------------------------------------------------
669 --
670 -- Start of fix for bug 2622747
671 procedure validate_SCL (
672    p_validate                     in     boolean
673   ,p_assignment_id                in     number
674   ,p_effective_date               in     date
675   ,p_business_group_id            in     number
676   ,p_soft_coding_keyflex_id       in out nocopy number
677   ,p_concatenated_segments           out nocopy varchar2
678   ,p_concat_segments              in     varchar2
679   ,p_segment1                     in     varchar2
680   ,p_segment2                     in     varchar2
681   ,p_segment3                     in     varchar2
682   ,p_segment4                     in     varchar2
683   ,p_segment5                     in     varchar2
684   ,p_segment6                     in     varchar2
685   ,p_segment7                     in     varchar2
686   ,p_segment8                     in     varchar2
687   ,p_segment9                     in     varchar2
688   ,p_segment10                    in     varchar2
689   ,p_segment11                    in     varchar2
690   ,p_segment12                    in     varchar2
691   ,p_segment13                    in     varchar2
692   ,p_segment14                    in     varchar2
693   ,p_segment15                    in     varchar2
694   ,p_segment16                    in     varchar2
695   ,p_segment17                    in     varchar2
696   ,p_segment18                    in     varchar2
697   ,p_segment19                    in     varchar2
698   ,p_segment20                    in     varchar2
699   ,p_segment21                    in     varchar2
700   ,p_segment22                    in     varchar2
701   ,p_segment23                    in     varchar2
702   ,p_segment24                    in     varchar2
703   ,p_segment25                    in     varchar2
704   ,p_segment26                    in     varchar2
705   ,p_segment27                    in     varchar2
706   ,p_segment28                    in     varchar2
707   ,p_segment29                    in     varchar2
708   ,p_segment30                    in     varchar2
709   )
710  AS
711   --
712   -- Local Variables
713   --
714   --
715   l_proc                         VARCHAR2(72) := g_package||'validate_scl';
716   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
717   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
718   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
719   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
720   l_scl_null_ind               number(1) := 0;
721 
722   l_scl_segment1               varchar2(60) := p_segment1;
723   l_scl_segment2               varchar2(60) := p_segment2;
724   l_scl_segment3               varchar2(60) := p_segment3;
725   l_scl_segment4               varchar2(60) := p_segment4;
726   l_scl_segment5               varchar2(60) := p_segment5;
727   l_scl_segment6               varchar2(60) := p_segment6;
728   l_scl_segment7               varchar2(60) := p_segment7;
729   l_scl_segment8               varchar2(60) := p_segment8;
730   l_scl_segment9               varchar2(60) := p_segment9;
731   l_scl_segment10              varchar2(60) := p_segment10;
732   l_scl_segment11              varchar2(60) := p_segment11;
733   l_scl_segment12              varchar2(60) := p_segment12;
734   l_scl_segment13              varchar2(60) := p_segment13;
735   l_scl_segment14              varchar2(60) := p_segment14;
736   l_scl_segment15              varchar2(60) := p_segment15;
737   l_scl_segment16              varchar2(60) := p_segment16;
738   l_scl_segment17              varchar2(60) := p_segment17;
739   l_scl_segment18              varchar2(60) := p_segment18;
740   l_scl_segment19              varchar2(60) := p_segment19;
741   l_scl_segment20              varchar2(60) := p_segment20;
742   l_scl_segment21              varchar2(60) := p_segment21;
743   l_scl_segment22              varchar2(60) := p_segment22;
744   l_scl_segment23              varchar2(60) := p_segment23;
745   l_scl_segment24              varchar2(60) := p_segment24;
746   l_scl_segment25              varchar2(60) := p_segment25;
747   l_scl_segment26              varchar2(60) := p_segment26;
748   l_scl_segment27              varchar2(60) := p_segment27;
749   l_scl_segment28              varchar2(60) := p_segment28;
750   l_scl_segment29              varchar2(60) := p_segment29;
751   l_scl_segment30              varchar2(60) := p_segment30;
752 
753   --
754   -- Cursor Defination.
755   --
756   cursor csr_get_soft_coding_keyflex is
757     select asg.soft_coding_keyflex_id
758       from per_all_assignments_f asg
759      where asg.assignment_id = p_assignment_id
760        and p_effective_date  between asg.effective_start_date
761                            and     asg.effective_end_date;
762 
763   --
764   cursor csr_scl_idsel is
765     select plr.rule_mode                       id_flex_num
766     from   pay_legislation_rules               plr,
767            per_business_groups_perf            pgr
768     where  plr.legislation_code                = pgr.legislation_code
769     and    pgr.business_group_id               = p_business_group_id
770     and    plr.rule_type                       = 'S'
771     and    exists
772           (select 1
773            from   fnd_segment_attribute_values fsav
774            where  fsav.id_flex_num             = plr.rule_mode
775            and    fsav.application_id          = 800
776            and    fsav.id_flex_code            = 'SCL'
777            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
778            and    fsav.attribute_value         = 'Y')
779     and    exists
780           (select 1
781            from   pay_legislation_rules        plr2
782            where  plr2.legislation_code        = plr.legislation_code
783            and    plr2.rule_type               = 'SDL'
784            and    plr2.rule_mode               = 'A') ;
785   --
786   --
787   cursor c_scl_segments is
788      select concatenated_segments,
789 	    segment1,
790             segment2,
791             segment3,
792             segment4,
793             segment5,
794             segment6,
795             segment7,
796             segment8,
797             segment9,
798             segment10,
799             segment11,
800             segment12,
801             segment13,
802             segment14,
803             segment15,
804             segment16,
805             segment17,
806             segment18,
807             segment19,
808             segment20,
809             segment21,
810             segment22,
811             segment23,
812             segment24,
813             segment25,
814             segment26,
815             segment27,
816             segment28,
817             segment29,
818             segment30
819      from   hr_soft_coding_keyflex
820      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
821 
822 --
823 --  Start of Fix for Bug 2643451
824      l_old_conc_segs      hr_soft_coding_keyflex.concatenated_segments%TYPE;
825      l_old_scl_segments   c_scl_segments%rowtype;
826 --  End of Fix for Bug 2643451
827 --
828 
829 
830   BEGIN
831 
832  if g_debug then
833  hr_utility.set_location('Entering:'|| l_proc, 5);
834  end if;
835 
836  l_old_conc_segments:=p_concat_segments;
837 
838   --
839   -- Issue a savepoint.
840   --
841   savepoint validate_SCL;
842   --
843 
844   --
845   -- If SCL ID is passed then
846   -- Select Segments from SCL table
847   --
848 
849     if l_soft_coding_keyflex_id is not null
850     then
851        l_scl_null_ind := 1;
852        open c_scl_segments;
853        fetch c_scl_segments into l_old_conc_segs,
854 				 l_scl_segment1,
855                                  l_scl_segment2,
856                                  l_scl_segment3,
857                                  l_scl_segment4,
858                                  l_scl_segment5,
859                                  l_scl_segment6,
860                                  l_scl_segment7,
861                                  l_scl_segment8,
862                                  l_scl_segment9,
863                                  l_scl_segment10,
864                                  l_scl_segment11,
865                                  l_scl_segment12,
866                                  l_scl_segment13,
867                                  l_scl_segment14,
868                                  l_scl_segment15,
869                                  l_scl_segment16,
870                                  l_scl_segment17,
871                                  l_scl_segment18,
872                                  l_scl_segment19,
873                                  l_scl_segment20,
874                                  l_scl_segment21,
875                                  l_scl_segment22,
876                                  l_scl_segment23,
877                                  l_scl_segment24,
878                                  l_scl_segment25,
879                                  l_scl_segment26,
880                                  l_scl_segment27,
881                                  l_scl_segment28,
882                                  l_scl_segment29,
883                                  l_scl_segment30;
884     close c_scl_segments;
885   else
886     l_scl_null_ind := 0;
887  if g_debug then
888     hr_utility.set_location(l_proc, 16);
889  end if;
890   end if;
891 
892 
893 
894 
895  if l_scl_null_ind = 0
896  then
897        open csr_get_soft_coding_keyflex;
898          fetch csr_get_soft_coding_keyflex into l_soft_coding_keyflex_id;
899 
900 
901  if g_debug then
902         hr_utility.set_location('SCL ID' ||l_soft_coding_keyflex_id, 10);
903  end if;
904        --
905        if csr_get_soft_coding_keyflex%NOTFOUND then
906          close csr_get_soft_coding_keyflex;
907          hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
908          hr_utility.raise_error;
909  --
910  -- Start of Fix for bug 2643451
911  --
912      else
913        if l_soft_coding_keyflex_id is not null then
914         open c_scl_segments;
915         fetch c_scl_segments into l_old_scl_segments;
916         close c_scl_segments;
917        end if;
918  --
919  -- End of Fix for Bug 2643451
920  --
921      end if;
922 
923        --
924        close csr_get_soft_coding_keyflex;
925 
926 
927     -- Start of Fix for Bug 2643451
928     -- Start of Fix for   Bug 2548555
929      --
930      if   nvl(l_scl_segment1,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment1 ,hr_api.g_varchar2)
931        or nvl(l_scl_segment2,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment2 ,hr_api.g_varchar2)
932        or nvl(l_scl_segment3,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment3 ,hr_api.g_varchar2)
933        or nvl(l_scl_segment4,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment4 ,hr_api.g_varchar2)
934        or nvl(l_scl_segment5,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment5 ,hr_api.g_varchar2)
935        or nvl(l_scl_segment6,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment6 ,hr_api.g_varchar2)
936        or nvl(l_scl_segment7,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment7 ,hr_api.g_varchar2)
937        or nvl(l_scl_segment8,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment8 ,hr_api.g_varchar2)
938        or nvl(l_scl_segment9,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment9 ,hr_api.g_varchar2)
939        or nvl(l_scl_segment10,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment10 ,hr_api.g_varchar2)
940        or nvl(l_scl_segment11,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment11 ,hr_api.g_varchar2)
941        or nvl(l_scl_segment12,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment12 ,hr_api.g_varchar2)
942        or nvl(l_scl_segment13,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment13 ,hr_api.g_varchar2)
943        or nvl(l_scl_segment14,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment14 ,hr_api.g_varchar2)
944        or nvl(l_scl_segment15,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment15 ,hr_api.g_varchar2)
945        or nvl(l_scl_segment16,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment16 ,hr_api.g_varchar2)
946        or nvl(l_scl_segment17,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment17 ,hr_api.g_varchar2)
947        or nvl(l_scl_segment18,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment18 ,hr_api.g_varchar2)
948        or nvl(l_scl_segment19,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment19 ,hr_api.g_varchar2)
949        or nvl(l_scl_segment20,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment20 ,hr_api.g_varchar2)
950        or nvl(l_scl_segment21,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment21 ,hr_api.g_varchar2)
951        or nvl(l_scl_segment22,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment22 ,hr_api.g_varchar2)
952        or nvl(l_scl_segment23,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment23 ,hr_api.g_varchar2)
953        or nvl(l_scl_segment24,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment24 ,hr_api.g_varchar2)
954        or nvl(l_scl_segment25,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment25 ,hr_api.g_varchar2)
955        or nvl(l_scl_segment26,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment26 ,hr_api.g_varchar2)
956        or nvl(l_scl_segment27,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment27 ,hr_api.g_varchar2)
957        or nvl(l_scl_segment28,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment28 ,hr_api.g_varchar2)
958        or nvl(l_scl_segment29,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment29 ,hr_api.g_varchar2)
959        or nvl(l_scl_segment30,hr_api.g_varchar2) <> nvl(l_old_scl_segments.segment30 ,hr_api.g_varchar2)
960        -- bug 944911
961        -- changed p_concatenated_segments to p_concat_segments
962         or nvl(p_concat_segments,hr_api.g_varchar2) <> nvl(l_old_scl_segments.concatenated_segments ,hr_api.g_varchar2)
963  --
964  -- End of Fix for Bug 2548555
965  -- End of Fix for Bug 2643451
966  --
967 
968 
969        then
970            open csr_scl_idsel;
971            fetch csr_scl_idsel into l_flex_num;
972 
973  if g_debug then
974            hr_utility.set_location('SCL_ID_SEL'||l_flex_num, 10);
975  end if;
976            --
977            if csr_scl_idsel%NOTFOUND then
978               close csr_scl_idsel;
979 
980               if   l_scl_segment1 is not null
981                 or l_scl_segment2 is not null
982                 or l_scl_segment3 is not null
983                 or l_scl_segment4 is not null
984                 or l_scl_segment5 is not null
985                 or l_scl_segment6 is not null
986                 or l_scl_segment7 is not null
987                 or l_scl_segment8 is not null
988                 or l_scl_segment9 is not null
989                 or l_scl_segment10 is not null
990                 or l_scl_segment11 is not null
991                 or l_scl_segment12 is not null
992                 or l_scl_segment13 is not null
993                 or l_scl_segment14 is not null
994                 or l_scl_segment15 is not null
995                 or l_scl_segment16 is not null
996                 or l_scl_segment17 is not null
997                 or l_scl_segment18 is not null
998                 or l_scl_segment19 is not null
999                 or l_scl_segment20 is not null
1000                 or l_scl_segment21 is not null
1001                 or l_scl_segment22 is not null
1002                 or l_scl_segment23 is not null
1003                 or l_scl_segment24 is not null
1004                 or l_scl_segment25 is not null
1005                 or l_scl_segment26 is not null
1006                 or l_scl_segment27 is not null
1007                 or l_scl_segment28 is not null
1008                 or l_scl_segment29 is not null
1009                 or l_scl_segment30 is not null
1010                 or p_concat_segments is not null
1011               then
1012               --
1013               hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
1014               hr_utility.set_message_token('PROCEDURE', l_proc);
1015               hr_utility.set_message_token('STEP','6');
1016               hr_utility.raise_error;
1017               end if;
1018            else -- csr_scl_idsel is found
1019               close csr_scl_idsel;
1020               --
1021               -- Process Logic
1022               --
1023               --
1024               -- Update or select the soft_coding_keyflex_id
1025               --
1026               hr_kflex_utility.upd_or_sel_keyflex_comb
1027               (p_appl_short_name        => 'PER'
1028               ,p_flex_code              => 'SCL'
1029               ,p_flex_num               => l_flex_num
1030               ,p_segment1               => l_scl_segment1
1031               ,p_segment2               => l_scl_segment2
1032               ,p_segment3               => l_scl_segment3
1033               ,p_segment4               => l_scl_segment4
1034               ,p_segment5               => l_scl_segment5
1035               ,p_segment6               => l_scl_segment6
1036               ,p_segment7               => l_scl_segment7
1037               ,p_segment8               => l_scl_segment8
1038               ,p_segment9               => l_scl_segment9
1039               ,p_segment10              => l_scl_segment10
1040               ,p_segment11              => l_scl_segment11
1041               ,p_segment12              => l_scl_segment12
1042               ,p_segment13              => l_scl_segment13
1043               ,p_segment14              => l_scl_segment14
1044               ,p_segment15              => l_scl_segment15
1045               ,p_segment16              => l_scl_segment16
1046               ,p_segment17              => l_scl_segment17
1047               ,p_segment18              => l_scl_segment18
1048               ,p_segment19              => l_scl_segment19
1049               ,p_segment20              => l_scl_segment20
1050               ,p_segment21              => l_scl_segment21
1051               ,p_segment22              => l_scl_segment22
1052               ,p_segment23              => l_scl_segment23
1053               ,p_segment24              => l_scl_segment24
1054               ,p_segment25              => l_scl_segment25
1055               ,p_segment26              => l_scl_segment26
1056               ,p_segment27              => l_scl_segment27
1057               ,p_segment28              => l_scl_segment28
1058               ,p_segment29              => l_scl_segment29
1059               ,p_segment30              => l_scl_segment30
1060               ,p_concat_segments_in     => l_old_conc_segments
1061               ,p_ccid                   => l_soft_coding_keyflex_id
1062               ,p_concat_segments_out    => l_concatenated_segments
1063               );
1064               --
1065               -- update the combinations column
1066               --
1067  if g_debug then
1068               hr_utility.set_location(l_proc, 17);
1069  end if;
1070               update_scl_concat_segs
1071               (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
1072               ,p_concatenated_segments   => l_concatenated_segments
1073               );
1074              --
1075            end if; -- csr_scl_idsel%NOTFOUND
1076            --
1077        end if;  -- l_scl_segment1 <> hr_api.g_varchar2
1078        --
1079  end if; -- l_soft_coding_key_flex_id is null
1080 
1081   --
1082   -- When in validation only mode raise the Validate_Enabled exception
1083   --
1084   if p_validate then
1085     raise hr_api.validate_enabled;
1086   end if;
1087 
1088  --
1089  -- Setting Output Variables
1090  --
1091   p_concatenated_segments        := l_concatenated_segments;
1092   p_soft_coding_keyflex_id       := l_soft_coding_keyflex_id;
1093 
1094 
1095 EXCEPTION
1096   when hr_api.validate_enabled then
1097      ROLLBACK TO validate_SCL;
1098 
1099      p_concatenated_segments  := l_old_conc_segments;
1100 
1101      if l_scl_null_ind = 0
1102      then
1103        p_soft_coding_keyflex_id  := null;
1104      end if;
1105 
1106   when others then
1107     --
1108     -- A validation or unexpected error has occurred
1109 
1110     IF csr_get_soft_coding_keyflex%isopen then
1111        close csr_get_soft_coding_keyflex;
1112     END IF;
1113 
1114     IF 	csr_scl_idsel%isOpen then
1115        close csr_scl_idsel;
1116     END IF;
1117 
1118     IF 	c_scl_segments%isOpen then
1119        close c_scl_segments;
1120     END IF;
1121 
1122     RAISE;
1123 
1124 END validate_SCL;
1125 
1126 -- End of fix for Bug 2622747
1127 
1128 -- -----------------------------------------------------------------------------
1129 -- |--------------------------< last_apl_asg >---------------------------------|
1130 -- -----------------------------------------------------------------------------
1131 --
1132 
1133 -- {Start of Comments}
1134 --
1135 -- Description:
1136 --   Determines if the assignment is the last applicant assignment on a given
1137 --   date
1138 --
1139 -- Prerequisites:
1140 --   None
1141 --
1142 -- In Parameters
1143 --   Name                           Reqd Type     Description
1144 --   p_assignment_id                Yes  number   Assignment id
1145 --   p_effective_date               Yes  date     Effective date
1146 --
1147 -- Post Success:
1148 --   A boolean indicator signifying if the assignment is the last applicant
1149 --   assignment on the effective date is returned.
1150 --
1151 -- Post Failure:
1152 --   An error is raised
1153 --
1154 -- Access Status:
1155 --   Internal Development Use Only
1156 --
1157 -- {End of Comments}
1158 --
1159 FUNCTION last_apl_asg
1160   (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
1161   ,p_effective_date               IN     DATE
1162   )
1163 RETURN BOOLEAN
1164 IS
1165   --
1166   -- Local variables
1167   --
1168   l_proc                         VARCHAR2(72) ;
1169   --
1170   l_last_apl_asg                 BOOLEAN;
1171   --
1172   -- Local cursors
1173   --
1174   CURSOR csr_last_apl_asg
1175     (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
1176     ,p_effective_date               IN     DATE
1177     )
1178   IS
1179     SELECT as2.assignment_id
1180       FROM per_all_assignments_f as2
1181           ,per_all_assignments_f as1
1182      WHERE as2.person_id = as1.person_id
1183        AND as2.assignment_type = as1.assignment_type
1184        AND csr_last_apl_asg.p_effective_date BETWEEN as2.effective_start_date
1185                                                  AND as2.effective_end_date
1186        AND as2.assignment_id <> as1.assignment_id
1187        AND as1.assignment_id = csr_last_apl_asg.p_assignment_id;
1188   l_last_apl_asg_rec             csr_last_apl_asg%ROWTYPE;
1189 --
1190 BEGIN
1191   --
1192  if g_debug then
1193   l_proc := g_package||'last_apl_asg';
1194   hr_utility.set_location('Entering:'||l_proc,10);
1195  end if;
1196   --
1197   -- If another applicant assignment exists on this date
1198   -- then this is NOT the last applicant assignment
1199   --
1200   OPEN csr_last_apl_asg
1201     (p_assignment_id                => p_assignment_id
1202     ,p_effective_date               => p_effective_date
1203     );
1204   FETCH csr_last_apl_asg INTO l_last_apl_asg_rec;
1205   l_last_apl_asg := csr_last_apl_asg%NOTFOUND;
1206   CLOSE csr_last_apl_asg;
1207   --
1208  if g_debug then
1209   hr_utility.set_location(' Leaving:'||l_proc,10);
1210  end if;
1211   --
1212   RETURN(l_last_apl_asg);
1213 --
1214 EXCEPTION
1215   WHEN OTHERS
1216   THEN
1217     IF csr_last_apl_asg%ISOPEN
1218     THEN
1219       CLOSE csr_last_apl_asg;
1220     END IF;
1221     RAISE;
1222 --
1223 END last_apl_asg;
1224 --
1225 -- ----------------------------------------------------------------------------
1226 -- |--------------------------< activate_emp_asg >----------------------------|
1227 -- ----------------------------------------------------------------------------
1228 --
1229 procedure activate_emp_asg
1230   (p_validate                     in     boolean
1231   ,p_effective_date               in     date     -- default value removed. Bug 2364484
1232   ,p_datetrack_update_mode        in     varchar2
1233   ,p_assignment_id                in     number
1234   ,p_change_reason                in     varchar2
1235   ,p_object_version_number        in out nocopy number
1236   ,p_assignment_status_type_id    in     number
1237   ,p_effective_start_date            out nocopy date
1238   ,p_effective_end_date              out nocopy date
1239   ) is
1240   --
1241   -- Declare cursors and local variables
1242   --
1243   l_effective_date             date;
1244   --
1245   -- Out variables
1246   --
1247   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1248   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1249   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1250   --
1251   lv_object_version_number     number := p_object_version_number ;
1252   --
1253   l_proc                       varchar2(72);
1254   --
1255 begin
1256  if g_debug then
1257   l_proc := g_package||'activate_emp_asg';
1258   hr_utility.set_location('Entering:'|| l_proc, 5);
1259  end if;
1260   --
1261   --
1262   l_object_version_number := p_object_version_number;
1263   --
1264   -- Corrected assignment from trunc(l_effective_date) to
1265   -- trunc(p_effective_date). RMF 25-Aug-97.
1266   --
1267   l_effective_date        := trunc(p_effective_date);
1268   --
1269   -- Issue a savepoint.
1270   --
1271   savepoint activate_emp_asg;
1272   --
1273  if g_debug then
1274   hr_utility.set_location(l_proc, 10);
1275  end if;
1276   --
1277   -- Validation in addition to Table Handlers
1278   --
1279   -- None required.
1280   --
1281   -- Process Logic
1282   --
1283   --
1284   -- Start of API User Hook for the before hook of activate_emp_asg.
1285   --
1286   begin
1287      hr_assignment_bk6.activate_emp_asg_b
1288           (p_effective_date               => l_effective_date
1289           ,p_datetrack_update_mode        => p_datetrack_update_mode
1290           ,p_assignment_id                => p_assignment_id
1291           ,p_change_reason                => p_change_reason
1292           ,p_object_version_number        => p_object_version_number
1293           ,p_assignment_status_type_id    => p_assignment_status_type_id
1294           );
1295   exception
1296      when hr_api.cannot_find_prog_unit then
1297        hr_api.cannot_find_prog_unit_error
1298          (p_module_name       => 'ACTIVATE_EMP_ASG',
1299           p_hook_type         => 'BP'
1300          );
1301   end;
1302   --
1303   -- Update employee assignment.
1304   --
1305   hr_assignment_internal.update_status_type_emp_asg
1306     (p_effective_date               => l_effective_date
1307     ,p_datetrack_update_mode        => p_datetrack_update_mode
1308     ,p_assignment_id                => p_assignment_id
1309     ,p_change_reason                => p_change_reason
1310     ,p_object_version_number        => l_object_version_number
1311     ,p_expected_system_status       => 'ACTIVE_ASSIGN'
1312     ,p_assignment_status_type_id    => p_assignment_status_type_id
1313     ,p_effective_start_date         => l_effective_start_date
1314     ,p_effective_end_date           => l_effective_end_date
1315     );
1316   --
1317  if g_debug then
1318   hr_utility.set_location(l_proc, 20);
1319  end if;
1320   --
1321   -- Start of API User Hook for the after hook of activate_emp_asg.
1322   --
1323   begin
1324      hr_assignment_bk6.activate_emp_asg_a
1325            (p_effective_date               => l_effective_date
1326            ,p_datetrack_update_mode        => p_datetrack_update_mode
1327            ,p_assignment_id                => p_assignment_id
1328            ,p_change_reason                => p_change_reason
1329            ,p_object_version_number        => l_object_version_number
1330            ,p_assignment_status_type_id    => p_assignment_status_type_id
1331            ,p_effective_start_date         => l_effective_start_date
1332            ,p_effective_end_date           => l_effective_end_date
1333            );
1334   exception
1335      when hr_api.cannot_find_prog_unit then
1336        hr_api.cannot_find_prog_unit_error
1337          (p_module_name       => 'ACTIVATE_EMP_ASG',
1338           p_hook_type         => 'AP'
1339          );
1340   end;
1341   --
1342   -- End of API User Hook for the after hook of activate_emp_asg.
1343   --
1344   --
1345   -- When in validation only mode raise the Validate_Enabled exception
1346   --
1347   if p_validate then
1348     raise hr_api.validate_enabled;
1349   end if;
1350   --
1351   -- Set all output arguments
1352   --
1353   p_object_version_number := l_object_version_number;
1354   p_effective_start_date  := l_effective_start_date;
1355   p_effective_end_date    := l_effective_end_date;
1356   --
1357  if g_debug then
1358   hr_utility.set_location(' Leaving:'||l_proc, 100);
1359  end if;
1360 exception
1361   when hr_api.validate_enabled then
1362     --
1363     -- As the Validate_Enabled exception has been raised
1364     -- we must rollback to the savepoint
1365     --
1366     ROLLBACK TO activate_emp_asg;
1367     --
1368     -- Only set output warning arguments
1369     -- (Any key or derived arguments must be set to null
1370     -- when validation only mode is being used.)
1371     --
1372     p_object_version_number  := p_object_version_number;
1373     p_effective_start_date   := null;
1374     p_effective_end_date     := null;
1375     --
1376   when others then
1377     --
1378     -- A validation or unexpected error has occurred
1379     --
1380     -- Added as part of fix to bug 632479
1381     --
1382     p_object_version_number   := lv_object_version_number ;
1383     p_effective_start_date    := null ;
1384     p_effective_end_date      := null ;
1385 
1386     ROLLBACK TO activate_emp_asg;
1387     raise;
1388     --
1389     -- End of fix.
1390     --
1391 end activate_emp_asg;
1392 --
1393 -- ----------------------------------------------------------------------------
1394 -- |--------------------------< activate_cwk_asg >----------------------------|
1395 -- ----------------------------------------------------------------------------
1396 --
1397 procedure activate_cwk_asg
1398   (p_validate                     in     boolean
1399   ,p_effective_date               in     date
1400   ,p_datetrack_update_mode        in     varchar2
1401   ,p_assignment_id                in     number
1402   ,p_change_reason                in     varchar2
1403   ,p_object_version_number        in out nocopy number
1404   ,p_assignment_status_type_id    in     number
1405   ,p_effective_start_date            out nocopy date
1406   ,p_effective_end_date              out nocopy date
1407   ) is
1408   --
1409   -- Declare cursors and local variables
1410   --
1411   l_effective_date             date;
1412   --
1413   -- Out variables
1414   --
1415   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1416   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1417   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1418   --
1419   lv_object_version_number     number := p_object_version_number ;
1420   --
1421   l_proc                       varchar2(72);
1422   --
1423 begin
1424  if g_debug then
1425   l_proc := g_package||'activate_cwk_asg';
1426   hr_utility.set_location('Entering:'|| l_proc, 5);
1427  end if;
1428   --
1429   --
1430   l_object_version_number := p_object_version_number;
1431   --
1432   -- Corrected assignment from trunc(l_effective_date) to
1433   -- trunc(p_effective_date). RMF 25-Aug-97.
1434   --
1435   l_effective_date        := trunc(p_effective_date);
1436   --
1437   -- Issue a savepoint.
1438   --
1439   savepoint activate_cwk_asg;
1440   --
1441  if g_debug then
1442   hr_utility.set_location(l_proc, 10);
1443  end if;
1444   --
1445   -- Validation in addition to Table Handlers
1446   --
1447   -- None required.
1448   --
1449   -- Process Logic
1450   --
1451   --
1452   -- Start of API User Hook for the before hook of activate_cwk_asg.
1453   --
1454   begin
1455      hr_assignment_bkj.activate_cwk_asg_b
1456           (p_effective_date               => l_effective_date
1457           ,p_datetrack_update_mode        => p_datetrack_update_mode
1458           ,p_assignment_id                => p_assignment_id
1459           ,p_change_reason                => p_change_reason
1460           ,p_object_version_number        => p_object_version_number
1461           ,p_assignment_status_type_id    => p_assignment_status_type_id
1462           );
1463   exception
1464      when hr_api.cannot_find_prog_unit then
1465        hr_api.cannot_find_prog_unit_error
1466          (p_module_name       => 'ACTIVATE_CWK_ASG',
1467           p_hook_type         => 'BP'
1468          );
1469   end;
1470   --
1471   -- Update contingent worker assignment.
1472   --
1473   hr_assignment_internal.update_status_type_cwk_asg
1474     (p_effective_date               => l_effective_date
1475     ,p_datetrack_update_mode        => p_datetrack_update_mode
1476     ,p_assignment_id                => p_assignment_id
1477     ,p_change_reason                => p_change_reason
1478     ,p_object_version_number        => l_object_version_number
1479     ,p_expected_system_status       => 'ACTIVE_CWK'
1480     ,p_assignment_status_type_id    => p_assignment_status_type_id
1481     ,p_effective_start_date         => l_effective_start_date
1482     ,p_effective_end_date           => l_effective_end_date
1483     );
1484   --
1485  if g_debug then
1486   hr_utility.set_location(l_proc, 20);
1487  end if;
1488   --
1489   -- Start of API User Hook for the after hook of activate_cwk_asg.
1490   --
1491   begin
1492      hr_assignment_bkj.activate_cwk_asg_a
1493            (p_effective_date               => l_effective_date
1494            ,p_datetrack_update_mode        => p_datetrack_update_mode
1495            ,p_assignment_id                => p_assignment_id
1496            ,p_change_reason                => p_change_reason
1497            ,p_object_version_number        => l_object_version_number
1498            ,p_assignment_status_type_id    => p_assignment_status_type_id
1499            ,p_effective_start_date         => l_effective_start_date
1500            ,p_effective_end_date           => l_effective_end_date
1501            );
1502   exception
1503      when hr_api.cannot_find_prog_unit then
1504        hr_api.cannot_find_prog_unit_error
1505          (p_module_name       => 'ACTIVATE_CWK_ASG',
1506           p_hook_type         => 'AP'
1507          );
1508   end;
1509   --
1510   -- End of API User Hook for the after hook of activate_cwk_asg.
1511   --
1512   --
1513   -- When in validation only mode raise the Validate_Enabled exception
1514   --
1515   if p_validate then
1516     raise hr_api.validate_enabled;
1517   end if;
1518   --
1519   -- Set all output arguments
1520   --
1521   p_object_version_number := l_object_version_number;
1522   p_effective_start_date  := l_effective_start_date;
1523   p_effective_end_date    := l_effective_end_date;
1524   --
1525  if g_debug then
1526   hr_utility.set_location(' Leaving:'||l_proc, 100);
1527  end if;
1528 exception
1529   when hr_api.validate_enabled then
1530     --
1531     -- As the Validate_Enabled exception has been raised
1532     -- we must rollback to the savepoint
1533     --
1534     ROLLBACK TO activate_cwk_asg;
1535     --
1536     -- Only set output warning arguments
1537     -- (Any key or derived arguments must be set to null
1538     -- when validation only mode is being used.)
1539     --
1540     p_object_version_number  := p_object_version_number;
1541     p_effective_start_date   := null;
1542     p_effective_end_date     := null;
1543     --
1544   when others then
1545     --
1546     -- A validation or unexpected error has occurred
1547     --
1548     -- Added as part of fix to bug 632479
1549     --
1550     p_object_version_number := lv_object_version_number;
1551     p_effective_start_date   := null;
1552     p_effective_end_date     := null;
1553 
1554     ROLLBACK TO activate_cwk_asg;
1555     raise;
1556     --
1557     -- End of fix.
1558     --
1559 end activate_cwk_asg;
1560 --
1561 -- ----------------------------------------------------------------------------
1562 -- |---------------------< actual_termination_cwk_asg >-----------------------|
1563 -- ----------------------------------------------------------------------------
1564 --
1565 procedure actual_termination_cwk_asg
1566   (p_validate                     in     boolean
1567   ,p_assignment_id                in     number
1568   ,p_object_version_number        in out nocopy number
1569   ,p_actual_termination_date      in     date
1570   ,p_assignment_status_type_id    in     number
1571   ,p_effective_start_date            out nocopy date
1572   ,p_effective_end_date              out nocopy date
1573   ,p_asg_future_changes_warning      out nocopy boolean
1574   ,p_entries_changed_warning         out nocopy varchar2
1575   ,p_pay_proposal_warning            out nocopy boolean
1576   ) is
1577   --
1578   -- Declare cursors and local variables
1579   --
1580   -- Out variables
1581   --
1582   l_asg_future_changes_warning boolean := FALSE;
1583   l_pay_proposal_warning       boolean := FALSE;
1584   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1585   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1586   l_entries_changed_warning    varchar2(1) := 'N';
1587   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1588   --
1589   l_assignment_status_type_id
1590                                per_all_assignments_f.assignment_status_type_id%TYPE;
1591   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
1592   l_asg_business_group_id      per_all_assignments_f.business_group_id%TYPE;
1593   l_exists                     varchar2(1);
1594   l_last_standard_process_date
1595                        per_periods_of_service.last_standard_process_date%TYPE;
1596   l_actual_termination_date
1597 		       per_periods_of_service.actual_termination_date%TYPE;
1598   l_legislation_code           per_business_groups.legislation_code%TYPE;
1599   l_payroll_id                 per_all_assignments_f.payroll_id%TYPE;
1600   l_per_system_status      per_assignment_status_types.per_system_status%TYPE;
1601   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
1602   l_proc                       varchar2(72)
1603                                := g_package || 'actual_termination_cwk_asg';
1604   --
1605   lv_object_version_number     number := p_object_version_number ;
1606   --
1607   cursor csr_get_asg_details is
1608     select asg.assignment_type
1609          , asg.payroll_id
1610          , asg.primary_flag
1611          , bus.business_group_id
1612          , bus.legislation_code
1613       from per_all_assignments_f   asg
1614 	     , per_business_groups_perf bus
1615      where asg.assignment_id         = p_assignment_id
1616        and l_actual_termination_date between asg.effective_start_date
1617                                      and     asg.effective_end_date
1618        and bus.business_group_id+0    = asg.business_group_id;
1619   --
1620   cursor csr_invalid_term_assign is
1621     select null
1622       from per_all_assignments_f           asg
1623          , per_assignment_status_types ast
1624      where asg.assignment_id             =  p_assignment_id
1625        and asg.effective_end_date        >= l_actual_termination_date
1626        and ast.assignment_status_type_id =  asg.assignment_status_type_id
1627        and ast.per_system_status         =  'TERM_CWK_ASG';
1628   --
1629   cursor csr_get_period_end_date is
1630     select tpe.end_date
1631       from per_time_periods tpe
1632      where tpe.payroll_id            = l_payroll_id
1633        and l_actual_termination_date between tpe.start_date
1634                                      and     tpe.end_date;
1635   --
1636 begin
1637  if g_debug then
1638   hr_utility.set_location('Entering:'|| l_proc, 1);
1639  end if;
1640   --
1641   l_assignment_status_type_id := p_assignment_status_type_id;
1642   l_object_version_number     := p_object_version_number;
1643   l_actual_termination_date   := trunc(p_actual_termination_date);
1644   --
1645   -- Issue a savepoint.
1646   --
1647   savepoint actual_termination_cwk_asg;
1648   --
1649  if g_debug then
1650   hr_utility.set_location(l_proc, 10);
1651  end if;
1652   --
1653   -- Validation in addition to Table Handlers
1654   --
1655   -- Get assignment and business group details for validation.
1656   --
1657   hr_api.mandatory_arg_error
1658      (p_api_name       => l_proc
1659      ,p_argument       => 'assignment_id'
1660      ,p_argument_value => p_assignment_id
1661      );
1662   --
1663   hr_api.mandatory_arg_error
1664      (p_api_name       => l_proc
1665      ,p_argument       => 'actual_termination_date'
1666      ,p_argument_value => l_actual_termination_date
1667      );
1668   --
1669  if g_debug then
1670   hr_utility.set_location(l_proc, 20);
1671  end if;
1672   --
1673   open  csr_get_asg_details;
1674   fetch csr_get_asg_details
1675    into l_assignment_type
1676       , l_payroll_id
1677       , l_primary_flag
1678       , l_asg_business_group_id
1679       , l_legislation_code;
1680   --
1681   if csr_get_asg_details%NOTFOUND
1682   then
1683     --
1684  if g_debug then
1685     hr_utility.set_location(l_proc, 30);
1686  end if;
1687     --
1688     close csr_get_asg_details;
1689     --
1690     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
1691     hr_utility.raise_error;
1692   end if;
1693   --
1694   close csr_get_asg_details;
1695   --
1696   -- Start of API User Hook for the before hook of actual_termination_cwk_asg.
1697   --
1698   begin
1699      hr_assignment_bkk.actual_termination_cwk_asg_b
1700        (p_assignment_id                 =>  p_assignment_id
1701        ,p_object_version_number         =>  p_object_version_number
1702        ,p_actual_termination_date       =>  l_actual_termination_date
1703        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
1704        ,p_business_group_id             =>  l_asg_business_group_id
1705        );
1706   exception
1707      when hr_api.cannot_find_prog_unit then
1708        hr_api.cannot_find_prog_unit_error
1709          (p_module_name       => 'ACTUAL_TERMINATION_CWK_ASG',
1710           p_hook_type         => 'BP'
1711          );
1712   end;
1713   --
1714   -- End of API User Hook for the before hook of actual_termination_cwk_asg.
1715   --
1716  if g_debug then
1717   hr_utility.set_location(l_proc, 40);
1718  end if;
1719   --
1720   -- The assignment must not be a primary assignment.
1721   --
1722   if l_primary_flag <> 'N'
1723   then
1724     --
1725  if g_debug then
1726     hr_utility.set_location(l_proc, 50);
1727  end if;
1728     --
1729     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
1730     hr_utility.raise_error;
1731   end if;
1732   --
1733  if g_debug then
1734   hr_utility.set_location(l_proc, 60);
1735  end if;
1736   --
1737   -- The assignment must be a contingent worker assignment.
1738   --
1739   if l_assignment_type <> 'C'
1740   then
1741     --
1742  if g_debug then
1743     hr_utility.set_location(l_proc, 70);
1744  end if;
1745     --
1746     hr_utility.set_message('PER','HR_289616_ASG_NOT_CWK');
1747     hr_utility.raise_error;
1748   end if;
1749   --
1750  if g_debug then
1751   hr_utility.set_location(l_proc, 80);
1752  end if;
1753   --
1754   -- The assignment status type must not already be TERM_CWK_ASSIGN on
1755   -- or after the actual termination date.
1756   --
1757   open  csr_invalid_term_assign;
1758   fetch csr_invalid_term_assign
1759    into l_exists;
1760   --
1761   if csr_invalid_term_assign%FOUND
1762   then
1763     --
1764  if g_debug then
1765     hr_utility.set_location(l_proc, 90);
1766  end if;
1767     --
1768     close csr_invalid_term_assign;
1769     --
1770     hr_utility.set_message('PER','HR_289617_ASG_ALREADY_TERM');
1771     hr_utility.raise_error;
1772   end if;
1773   --
1774   close csr_invalid_term_assign;
1775   --
1776  if g_debug then
1777   hr_utility.set_location(l_proc, 100);
1778  end if;
1779   --
1780   -- Process Logic
1781   --
1782   -- If p_assignment_status_type_id is g_number then derive it's default value,
1783   -- otherwise validate it.
1784   --
1785   per_asg_bus1.chk_assignment_status_type
1786     (p_assignment_status_type_id => l_assignment_status_type_id
1787     ,p_business_group_id         => l_asg_business_group_id
1788     ,p_legislation_code          => l_legislation_code
1789     ,p_expected_system_status    => 'TERM_CWK_ASG'
1790     );
1791   --
1792  if g_debug then
1793   hr_utility.set_location(l_proc, 110);
1794  end if;
1795   --
1796   -- Derive the last standard process date.
1797   --
1798   -- Bug 1711085. VS. 27-MAR-01. Commented out the code associated with
1799   -- disabling last_standard_process  for US legislature.
1800   --
1801   -- if l_legislation_code = 'US'
1802   -- then
1803     --
1804  if g_debug then
1805      hr_utility.set_location(l_proc, 120);
1806  end if;
1807     --
1808     -- l_last_standard_process_date := l_actual_termination_date;
1809   -- else
1810     --
1811  if g_debug then
1812     hr_utility.set_location(l_proc, 130);
1813  end if;
1814     --
1815     if l_payroll_id is not null
1816     then
1817       --
1818  if g_debug then
1819       hr_utility.set_location(l_proc, 140);
1820  end if;
1821       --
1822       -- Assignment is assigned to a payroll, so set the last standard process
1823       -- to date to the payroll's period end date as of the actual termination
1824       -- date.
1825       --
1826       open  csr_get_period_end_date;
1827       fetch csr_get_period_end_date
1828        into l_last_standard_process_date;
1829       --
1830       if csr_get_period_end_date%NOTFOUND then
1831         --
1832  if g_debug then
1833         hr_utility.set_location(l_proc, 150);
1834  end if;
1835         --
1836         -- No payroll period found for the actual termination date.
1837         --
1838         close csr_get_period_end_date;
1839         --
1840         hr_utility.set_message(801,'HR_51003_ASG_INV_NO_TERM_PRD');
1841         hr_utility.raise_error;
1842       end if;
1843       --
1844       close csr_get_period_end_date;
1845       --
1846  if g_debug then
1847       hr_utility.set_location(l_proc, 160);
1848  end if;
1849     else
1850       --
1851  if g_debug then
1852       hr_utility.set_location(l_proc, 170);
1853  end if;
1854       --
1855       -- Assignment is not assigned to a payroll, so set the last standard
1856       -- process date to the actual termination date.
1857       --
1858       l_last_standard_process_date := l_actual_termination_date;
1859     end if;
1860   -- end if;
1861   --
1862  if g_debug then
1863   hr_utility.set_location(l_proc, 180);
1864  end if;
1865   --
1866   -- Call the business support process to update assignment and maintain the
1867   -- element entries. We call this procedure for contingent workers
1868   -- because they are processed in the same way as employees.
1869   --
1870   hr_assignment_internal.actual_term_cwk_asg
1871     (p_assignment_id              => p_assignment_id
1872     ,p_object_version_number      => l_object_version_number
1873     ,p_actual_termination_date    => l_actual_termination_date
1874     ,p_last_standard_process_date => l_last_standard_process_date
1875     ,p_assignment_status_type_id  => l_assignment_status_type_id
1876     ,p_effective_start_date       => l_effective_start_date
1877     ,p_effective_end_date         => l_effective_end_date
1878     ,p_asg_future_changes_warning => l_asg_future_changes_warning
1879     ,p_entries_changed_warning    => l_entries_changed_warning
1880     ,p_pay_proposal_warning       => l_pay_proposal_warning
1881     );
1882   --
1883  if g_debug then
1884   hr_utility.set_location(l_proc, 190);
1885  end if;
1886   --
1887   -- When in validation only mode raise the Validate_Enabled exception
1888   --
1889   --
1890   -- Start of API User Hook for the after hook of actual_termination_cwk_asg.
1891   -- Local vars are passed in for all OUT parms because the hook needs to
1892   -- be placed before the validate check and therefore before the code that
1893   -- sets all out parms.
1894   --
1895   begin
1896      hr_assignment_bkk.actual_termination_cwk_asg_a
1897        (p_assignment_id                 =>  p_assignment_id
1898        ,p_object_version_number         =>  l_object_version_number
1899        ,p_actual_termination_date       =>  l_actual_termination_date
1900        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
1901        ,p_effective_start_date          =>  l_effective_start_date
1902        ,p_effective_end_date            =>  l_effective_end_date
1903        ,p_asg_future_changes_warning    =>  l_asg_future_changes_warning
1904        ,p_entries_changed_warning       =>  l_entries_changed_warning
1905        ,p_pay_proposal_warning          =>  l_pay_proposal_warning
1906        ,p_business_group_id             =>  l_asg_business_group_id
1907        );
1908   exception
1909      when hr_api.cannot_find_prog_unit then
1910        hr_api.cannot_find_prog_unit_error
1911          (p_module_name       => 'ACTUAL_TERMINATION_CWK_ASG',
1912           p_hook_type         => 'AP'
1913          );
1914   end;
1915   --
1916   -- End of API User Hook for the after hook of actual_termination_cwk_asg.
1917   --
1918   if p_validate then
1919     raise hr_api.validate_enabled;
1920   end if;
1921   --
1922   -- Set all output arguments
1923   --
1924   p_asg_future_changes_warning := l_asg_future_changes_warning;
1925   p_effective_end_date         := l_effective_end_date;
1926   p_effective_start_date       := l_effective_start_date;
1927   p_entries_changed_warning    := l_entries_changed_warning;
1928   p_pay_proposal_warning       := l_pay_proposal_warning;
1929   p_object_version_number      := l_object_version_number;
1930   --
1931  if g_debug then
1932   hr_utility.set_location(' Leaving:'||l_proc, 200);
1933  end if;
1934 exception
1935   when hr_api.validate_enabled then
1936     --
1937     -- As the Validate_Enabled exception has been raised
1938     -- we must rollback to the savepoint
1939     --
1940     ROLLBACK TO actual_termination_cwk_asg;
1941     --
1942     -- Only set output warning arguments
1943     -- (Any key or derived arguments must be set to null
1944     -- when validation only mode is being used.)
1945     --
1946     p_asg_future_changes_warning := l_asg_future_changes_warning;
1947     p_effective_end_date         := null;
1948     p_effective_start_date       := null;
1949     p_entries_changed_warning    := l_entries_changed_warning;
1950     p_pay_proposal_warning       := l_pay_proposal_warning;
1951     p_object_version_number      := p_object_version_number;
1952     --
1953   when others then
1954     --
1955     -- A validation or unexpected error has occurred
1956     --
1957     -- Added as part of fix to bug 632479
1958     --
1959     p_object_version_number := lv_object_version_number;
1960     p_effective_start_date       := null ;
1961     p_effective_end_date         := null ;
1962     p_asg_future_changes_warning  := null ;
1963     p_entries_changed_warning     := null ;
1964     p_pay_proposal_warning        := null ;
1965 
1966     ROLLBACK TO actual_termination_cwk_asg;
1967     raise;
1968     --
1969 end actual_termination_cwk_asg;
1970 --
1971 -- ----------------------------------------------------------------------------
1972 -- |------------------------< final_process_cwk_asg >-------------------------|
1973 -- ----------------------------------------------------------------------------
1974 --
1975 procedure final_process_cwk_asg
1976   (p_validate                     in     boolean
1977   ,p_assignment_id                in     number
1978   ,p_object_version_number        in out nocopy number
1979   ,p_final_process_date           in     date
1980   ,p_effective_start_date            out nocopy date
1981   ,p_effective_end_date              out nocopy date
1982   ,p_org_now_no_manager_warning      out nocopy boolean
1983   ,p_asg_future_changes_warning      out nocopy boolean
1984   ,p_entries_changed_warning         out nocopy varchar2
1985   ) is
1986   --
1987   -- Declare cursors and local variables
1988   --
1989   -- Out variables
1990   --
1991   l_asg_future_changes_warning boolean := FALSE;
1992   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
1993   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
1994   l_entries_changed_warning    varchar2(1) := 'N';
1995   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
1996   l_org_now_no_manager_warning boolean := FALSE;
1997   --
1998   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
1999   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
2000   l_proc                       varchar2(72)
2001                                      := g_package || 'final_process_cwk_asg';
2002   l_actual_termination_date    date;
2003   l_final_process_date         date;
2004   l_max_asg_end_date           date;
2005   --
2006   lv_object_version_number     number := p_object_version_number ;
2007   --
2008   cursor csr_get_derived_details is
2009     select asg.assignment_type
2010          , asg.primary_flag
2011       from per_all_assignments_f      asg
2012      where asg.assignment_id        = p_assignment_id
2013        and l_final_process_date     between asg.effective_start_date
2014                                     and     asg.effective_end_date;
2015   --
2016   cursor csr_valid_term_assign is
2017     select min(asg.effective_start_date) - 1
2018       from per_all_assignments_f           asg
2019      where asg.assignment_id             = p_assignment_id
2020        and exists ( select null
2021 		    from per_assignment_status_types ast
2022 		    where ast.assignment_status_type_id
2023 		     = asg.assignment_status_type_id
2024                      and ast.per_system_status = 'TERM_CWK_ASG');
2025 
2026 --
2027   cursor csr_invalid_term_assign is
2028     select max(asg.effective_end_date)
2029       from per_all_assignments_f           asg
2030      where asg.assignment_id      = p_assignment_id
2031        and exists ( select null
2032 		    from per_assignment_status_types ast
2033 		    where ast.assignment_status_type_id
2034 		     = asg.assignment_status_type_id
2035                      and ast.per_system_status = 'TERM_CWK_ASG');
2036 
2037 --
2038 begin
2039  if g_debug then
2040   hr_utility.set_location('Entering:'|| l_proc, 1);
2041  end if;
2042   --
2043   l_object_version_number := p_object_version_number;
2044   l_final_process_date    := trunc(p_final_process_date);
2045   --
2046   -- Issue a savepoint.
2047   --
2048   savepoint final_process_cwk_asg;
2049   --
2050  if g_debug then
2051   hr_utility.set_location(l_proc, 10);
2052  end if;
2053   --
2054   -- Validation in addition to Table Handlers
2055   --
2056   -- Get assignment and business group details for validation.
2057   --
2058   hr_api.mandatory_arg_error
2059      (p_api_name       => l_proc
2060      ,p_argument       => 'assignment_id'
2061      ,p_argument_value => p_assignment_id
2062      );
2063   --
2064   hr_api.mandatory_arg_error
2065      (p_api_name       => l_proc
2066      ,p_argument       => 'final_process_date'
2067      ,p_argument_value => l_final_process_date
2068      );
2069   --
2070  if g_debug then
2071   hr_utility.set_location(l_proc, 20);
2072  end if;
2073   --
2074   open  csr_get_derived_details;
2075   fetch csr_get_derived_details
2076    into l_assignment_type
2077       , l_primary_flag;
2078   --
2079   if csr_get_derived_details%NOTFOUND
2080   then
2081     --
2082  if g_debug then
2083     hr_utility.set_location(l_proc, 30);
2084  end if;
2085     --
2086     close csr_get_derived_details;
2087     --
2088     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
2089     hr_utility.raise_error;
2090   end if;
2091   --
2092   close csr_get_derived_details;
2093   --
2094   -- Start of API User Hook for the before hook of final_process_cwk_asg.
2095   --
2096   begin
2097      hr_assignment_bkh.final_process_cwk_asg_b
2098        (p_assignment_id                 =>  p_assignment_id
2099        ,p_object_version_number         =>  p_object_version_number
2100        ,p_final_process_date            =>  l_final_process_date
2101        );
2102   exception
2103      when hr_api.cannot_find_prog_unit then
2104        hr_api.cannot_find_prog_unit_error
2105          (p_module_name       => 'FINAL_PROCESS_CWK_ASG',
2106           p_hook_type         => 'BP'
2107          );
2108   end;
2109   --
2110   --
2111  if g_debug then
2112   hr_utility.set_location(l_proc, 40);
2113  end if;
2114   --
2115   -- The assignment must not be a primary assignment.
2116   --
2117   if l_primary_flag <> 'N'
2118   then
2119     --
2120  if g_debug then
2121     hr_utility.set_location(l_proc, 50);
2122  end if;
2123     --
2124     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
2125     hr_utility.raise_error;
2126   end if;
2127   --
2128  if g_debug then
2129   hr_utility.set_location(l_proc, 60);
2130  end if;
2131   --
2132   -- The assignment must be an contingent worker assignment.
2133   --
2134   if l_assignment_type <> 'C'
2135   then
2136     --
2137  if g_debug then
2138     hr_utility.set_location(l_proc, 70);
2139  end if;
2140     --
2141     hr_utility.set_message('PER','HR_289616_ASG_NOT_CWK');
2142     hr_utility.raise_error;
2143   end if;
2144 
2145   -- Ensure that the assignment has not been terminated previously
2146 
2147   --
2148   open  csr_invalid_term_assign;
2149   fetch csr_invalid_term_assign
2150    into l_max_asg_end_date;
2151   close csr_invalid_term_assign;
2152 
2153   --
2154   if l_max_asg_end_date <> hr_api.g_eot
2155   then
2156     --
2157  if g_debug then
2158     hr_utility.set_location(l_proc, 90);
2159  end if;
2160     --
2161     hr_utility.set_message(801,'HR_7962_PDS_INV_FP_CHANGE');
2162     hr_utility.raise_error;
2163   end if;
2164   --
2165  if g_debug then
2166   hr_utility.set_location(l_proc, 80);
2167  end if;
2168   --
2169   -- Ensure that the the final process date is on or after the actual
2170   -- termination date by checking that the assignment status is
2171   -- TERM_CWK_ASG for the day after the final process date.
2172   --
2173   open  csr_valid_term_assign;
2174   fetch csr_valid_term_assign
2175    into l_actual_termination_date;
2176   close csr_valid_term_assign;
2177 
2178   --
2179   if l_actual_termination_date is null
2180   then
2181     --
2182  if g_debug then
2183     hr_utility.set_location(l_proc, 90);
2184  end if;
2185     --
2186     hr_utility.set_message(801,'HR_51007_ASG_INV_NOT_ACT_TERM');
2187     hr_utility.raise_error;
2188   end if;
2189 
2190   if l_final_process_date < l_actual_termination_date then
2191 
2192  if g_debug then
2193     hr_utility.set_location(l_proc, 95);
2194  end if;
2195 
2196     -- This error message has been set temporarily
2197 
2198     hr_utility.set_message(801,'HR_7963_PDS_INV_FP_BEFORE_ATT');
2199     hr_utility.raise_error;
2200   end if;
2201   --
2202   --
2203  if g_debug then
2204   hr_utility.set_location(l_proc, 100);
2205  end if;
2206   --
2207   -- Process Logic
2208   --
2209   -- Call the business support process to update assignment and maintain the
2210   -- element entries. Here we call the emp procedure because processing
2211   -- for a contingent worker is identical from this point.
2212   --
2213   hr_assignment_internal.final_process_cwk_asg
2214     (p_assignment_id              => p_assignment_id
2215     ,p_object_version_number      => l_object_version_number
2216     ,p_final_process_date         => l_final_process_date
2217     ,p_actual_termination_date    => l_actual_termination_date
2218     ,p_effective_start_date       => l_effective_start_date
2219     ,p_effective_end_date         => l_effective_end_date
2220     ,p_org_now_no_manager_warning => l_org_now_no_manager_warning
2221     ,p_asg_future_changes_warning => l_asg_future_changes_warning
2222     ,p_entries_changed_warning    => l_entries_changed_warning
2223     );
2224   --
2225  if g_debug then
2226   hr_utility.set_location(l_proc, 110);
2227  end if;
2228   --
2229   -- Start of API User Hook for the after hook of final_process_cwk_asg.
2230   --
2231   begin
2232      hr_assignment_bkh.final_process_cwk_asg_a
2233         (p_assignment_id                 =>     p_assignment_id
2234         ,p_object_version_number         =>     l_object_version_number
2235         ,p_final_process_date            =>     p_final_process_date
2236         ,p_effective_start_date          =>     l_effective_start_date
2237         ,p_effective_end_date            =>     l_effective_end_date
2238         ,p_org_now_no_manager_warning    =>     l_org_now_no_manager_warning
2239         ,p_asg_future_changes_warning    =>     l_asg_future_changes_warning
2240         ,p_entries_changed_warning       =>     l_entries_changed_warning
2241         );
2242   exception
2243      when hr_api.cannot_find_prog_unit then
2244        hr_api.cannot_find_prog_unit_error
2245          (p_module_name       => 'FINAL_PROCESS_CWK_ASG',
2246           p_hook_type         => 'AP'
2247          );
2248   end;
2249   --
2250   -- End of API User Hook for the after hook of final_process_cwk_asg.
2251   --
2252   --
2253   -- When in validation only mode raise the Validate_Enabled exception
2254   --
2255   if p_validate then
2256     raise hr_api.validate_enabled;
2257   end if;
2258   --
2259   -- Set all output arguments
2260   --
2261   p_asg_future_changes_warning := l_asg_future_changes_warning;
2262   p_effective_end_date         := l_effective_end_date;
2263   p_effective_start_date       := l_effective_start_date;
2264   p_entries_changed_warning    := l_entries_changed_warning;
2265   p_object_version_number      := l_object_version_number;
2266   p_org_now_no_manager_warning := l_org_now_no_manager_warning;
2267   --
2268  if g_debug then
2269   hr_utility.set_location(' Leaving:'||l_proc, 300);
2270  end if;
2271 exception
2272   when hr_api.validate_enabled then
2273     --
2274     -- As the Validate_Enabled exception has been raised
2275     -- we must rollback to the savepoint
2276     --
2277     ROLLBACK TO final_process_cwk_asg;
2278     --
2279     -- Only set output warning arguments
2280     -- (Any key or derived arguments must be set to null
2281     -- when validation only mode is being used.)
2282     --
2283     p_asg_future_changes_warning := l_asg_future_changes_warning;
2284     p_effective_end_date         := null;
2285     p_effective_start_date       := null;
2286     p_entries_changed_warning    := l_entries_changed_warning;
2287     p_org_now_no_manager_warning := l_org_now_no_manager_warning;
2288     --
2289   when others then
2290     --
2291     -- A validation or unexpected error has occurred
2292     --
2293     -- Added as part of fix to bug 632479
2294     --
2295     p_object_version_number := lv_object_version_number;
2296 
2297     p_effective_start_date           := null;
2298     p_effective_end_date              := null;
2299     p_org_now_no_manager_warning      := null;
2300     p_asg_future_changes_warning      := null;
2301     p_entries_changed_warning         := null;
2302 
2303     ROLLBACK TO final_process_cwk_asg;
2304     raise;
2305     --
2306     -- End of fix.
2307     --
2308 end final_process_cwk_asg;
2309 --
2310 -- ----------------------------------------------------------------------------
2311 -- |---------------------------< suspend_cwk_asg >----------------------------|
2312 -- ----------------------------------------------------------------------------
2313 --
2314 procedure suspend_cwk_asg
2315   (p_validate                     in     boolean
2316   ,p_effective_date               in     date
2317   ,p_datetrack_update_mode        in     varchar2
2318   ,p_assignment_id                in     number
2319   ,p_change_reason                in     varchar2
2320   ,p_object_version_number        in out nocopy number
2321   ,p_assignment_status_type_id    in     number
2322   ,p_effective_start_date            out nocopy date
2323   ,p_effective_end_date              out nocopy date
2324   ) is
2325   --
2326   -- Declare cursors and local variables
2327   --
2328   l_effective_date             date;
2329   --
2330   -- Out variables
2331   --
2332   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
2333   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
2334   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
2335   --
2336   l_proc                       varchar2(72);
2337   --
2338 begin
2339  if g_debug then
2340   l_proc := g_package||'suspend_cwk_asg';
2341   hr_utility.set_location('Entering:'|| l_proc, 5);
2342  end if;
2343   --
2344   --
2345   l_object_version_number := p_object_version_number;
2346   --
2347   -- Issue a savepoint.
2348   --
2349   savepoint suspend_cwk_asg;
2350   --
2351  if g_debug then
2352   hr_utility.set_location(l_proc, 10);
2353  end if;
2354   --
2355   -- Initialise local variable - added 25-Aug-97. RMF.
2356   --
2357   l_effective_date := trunc(p_effective_date);
2358   --
2359   -- Validation in addition to Table Handlers
2360   --
2361   -- None required.
2362   --
2363   -- Process Logic
2364   --
2365   -- Start of API User Hook for the before hook of suspend_cwk_asg.
2366   --
2367   begin
2368      hr_assignment_bkl.suspend_cwk_asg_b
2369        (p_effective_date               => l_effective_date
2370        ,p_datetrack_update_mode        => p_datetrack_update_mode
2371        ,p_assignment_id                => p_assignment_id
2372        ,p_change_reason                => p_change_reason
2373        ,p_object_version_number        => p_object_version_number
2374        ,p_assignment_status_type_id    => p_assignment_status_type_id
2375        );
2376   exception
2377      when hr_api.cannot_find_prog_unit then
2378        hr_api.cannot_find_prog_unit_error
2379          (p_module_name       => 'SUSPEND_CWK_ASG',
2380           p_hook_type         => 'BP'
2381          );
2382   end;
2383   --
2384   --
2385   -- Update contingent worker assignment.
2386   --
2387   hr_assignment_internal.update_status_type_cwk_asg
2388     (p_effective_date               => l_effective_date
2389     ,p_datetrack_update_mode        => p_datetrack_update_mode
2390     ,p_assignment_id                => p_assignment_id
2391     ,p_change_reason                => p_change_reason
2392     ,p_object_version_number        => l_object_version_number
2393     ,p_expected_system_status       => 'SUSP_CWK_ASG'
2394     ,p_assignment_status_type_id    => p_assignment_status_type_id
2395     ,p_effective_start_date         => l_effective_start_date
2396     ,p_effective_end_date           => l_effective_end_date
2397     );
2398   --
2399  if g_debug then
2400   hr_utility.set_location(l_proc, 20);
2401  end if;
2402   --
2403   -- Start of API User Hook for the after hook of suspend_cwk_asg.
2404   --
2405   begin
2406      hr_assignment_bkl.suspend_cwk_asg_a
2407         (p_effective_date               => l_effective_date
2408         ,p_datetrack_update_mode        => p_datetrack_update_mode
2409         ,p_assignment_id                => p_assignment_id
2410         ,p_change_reason                => p_change_reason
2411         ,p_object_version_number        => l_object_version_number
2412         ,p_assignment_status_type_id    => p_assignment_status_type_id
2413         ,p_effective_start_date         => l_effective_start_date
2414         ,p_effective_end_date           => l_effective_end_date
2415         );
2416   exception
2417      when hr_api.cannot_find_prog_unit then
2418        hr_api.cannot_find_prog_unit_error
2419          (p_module_name       => 'SUSPEND_CWK_ASG',
2420           p_hook_type         => 'AP'
2421          );
2422   end;
2423   --
2424   -- End of API User Hook for the after hook of suspend_cwk_asg.
2425   --
2426   --
2427   -- When in validation only mode raise the Validate_Enabled exception
2428   --
2429   if p_validate then
2430     raise hr_api.validate_enabled;
2431   end if;
2432   --
2433   -- Set all output arguments
2434   --
2435   p_object_version_number := l_object_version_number;
2436   p_effective_start_date  := l_effective_start_date;
2437   p_effective_end_date    := l_effective_end_date;
2438   --
2439  if g_debug then
2440   hr_utility.set_location(' Leaving:'||l_proc, 100);
2441  end if;
2442 exception
2443   when hr_api.validate_enabled then
2444     --
2445     -- As the Validate_Enabled exception has been raised
2446     -- we must rollback to the savepoint
2447     --
2448     ROLLBACK TO suspend_cwk_asg;
2449     --
2450     -- Only set output warning arguments
2451     -- (Any key or derived arguments must be set to null
2452     -- when validation only mode is being used.)
2453     --
2454     p_object_version_number  := p_object_version_number;
2455     p_effective_start_date   := null;
2456     p_effective_end_date     := null;
2457     --
2458   when others then
2459     --
2460     -- A validation or unexpected error has occurred
2461     --
2462     -- Added as part of fix to bug 632479
2463     --
2464     ROLLBACK TO suspend_cwk_asg;
2465     raise;
2466     --
2467     -- End of fix.
2468     --
2469 end suspend_cwk_asg;
2470 --
2471 -- ----------------------------------------------------------------------------
2472 -- |---------------------< actual_termination_emp_asg >-----------------------|
2473 -- ----------------------------------------------------------------------------
2474 --
2475 procedure actual_termination_emp_asg
2476   (p_validate                     in     boolean
2477   ,p_assignment_id                in     number
2478   ,p_object_version_number        in out nocopy number
2479   ,p_actual_termination_date      in     date
2480   ,p_assignment_status_type_id    in     number
2481   ,p_effective_start_date            out nocopy date
2482   ,p_effective_end_date              out nocopy date
2483   ,p_asg_future_changes_warning      out nocopy boolean
2484   ,p_entries_changed_warning         out nocopy varchar2
2485   ,p_pay_proposal_warning            out nocopy boolean
2486   ) is
2487   --
2488   -- Declare cursors and local variables
2489   --
2490   -- Out variables
2491   --
2492   l_asg_future_changes_warning boolean := FALSE;
2493   l_pay_proposal_warning       boolean := FALSE;
2494   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
2495   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
2496   l_entries_changed_warning    varchar2(1) := 'N';
2497   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
2498   --
2499   l_assignment_status_type_id
2500                                per_all_assignments_f.assignment_status_type_id%TYPE;
2501   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
2502   l_asg_business_group_id      per_all_assignments_f.business_group_id%TYPE;
2503   l_exists                     varchar2(1);
2504   l_last_standard_process_date
2505                        per_periods_of_service.last_standard_process_date%TYPE;
2506   l_actual_termination_date
2507 		       per_periods_of_service.actual_termination_date%TYPE;
2508   l_legislation_code           per_business_groups.legislation_code%TYPE;
2509   l_payroll_id                 per_all_assignments_f.payroll_id%TYPE;
2510   l_per_system_status      per_assignment_status_types.per_system_status%TYPE;
2511   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
2512   l_proc                       varchar2(72)
2513                                := g_package || 'actual_termination_emp_asg';
2514   --
2515   lv_object_version_number     number := p_object_version_number ;
2516   --
2517   cursor csr_get_asg_details is
2518     select asg.assignment_type
2519          , asg.payroll_id
2520          , asg.primary_flag
2521          , bus.business_group_id
2522          , bus.legislation_code
2523       from per_all_assignments_f   asg
2524 	     , per_business_groups_perf bus
2525      where asg.assignment_id         = p_assignment_id
2526        and l_actual_termination_date between asg.effective_start_date
2527                                      and     asg.effective_end_date
2528        and bus.business_group_id+0     = asg.business_group_id;
2529   --
2530   cursor csr_invalid_term_assign is
2531     select null
2532       from per_all_assignments_f           asg
2533          , per_assignment_status_types ast
2534      where asg.assignment_id             =  p_assignment_id
2535        and asg.effective_end_date        >= l_actual_termination_date
2536        and ast.assignment_status_type_id =  asg.assignment_status_type_id
2537        and ast.per_system_status         =  'TERM_ASSIGN';
2538   --
2539   cursor csr_get_period_end_date is
2540     select tpe.end_date
2541       from per_time_periods tpe
2542      where tpe.payroll_id            = l_payroll_id
2543        and l_actual_termination_date between tpe.start_date
2544                                      and     tpe.end_date;
2545   --
2546 begin
2547  if g_debug then
2548   hr_utility.set_location('Entering:'|| l_proc, 1);
2549  end if;
2550   --
2551   l_assignment_status_type_id := p_assignment_status_type_id;
2552   l_object_version_number     := p_object_version_number;
2553   l_actual_termination_date   := trunc(p_actual_termination_date);
2554   --
2555   -- Issue a savepoint.
2556   --
2557   savepoint actual_termination_emp_asg;
2558   --
2559  if g_debug then
2560   hr_utility.set_location(l_proc, 10);
2561  end if;
2562   --
2563   -- Validation in addition to Table Handlers
2564   --
2565   -- Get assignment and business group details for validation.
2566   --
2567   hr_api.mandatory_arg_error
2568      (p_api_name       => l_proc
2569      ,p_argument       => 'assignment_id'
2570      ,p_argument_value => p_assignment_id
2571      );
2572   --
2573   hr_api.mandatory_arg_error
2574      (p_api_name       => l_proc
2575      ,p_argument       => 'actual_termination_date'
2576      ,p_argument_value => l_actual_termination_date
2577      );
2578   --
2579  if g_debug then
2580   hr_utility.set_location(l_proc, 20);
2581  end if;
2582   --
2583   open  csr_get_asg_details;
2584   fetch csr_get_asg_details
2585    into l_assignment_type
2586       , l_payroll_id
2587       , l_primary_flag
2588       , l_asg_business_group_id
2589       , l_legislation_code;
2590   --
2591   if csr_get_asg_details%NOTFOUND
2592   then
2593     --
2594  if g_debug then
2595     hr_utility.set_location(l_proc, 30);
2596  end if;
2597     --
2598     close csr_get_asg_details;
2599     --
2600     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
2601     hr_utility.raise_error;
2602   end if;
2603   --
2604   close csr_get_asg_details;
2605   --
2606   -- Start of API User Hook for the before hook of actual_termination_emp_asg.
2607   --
2608   begin
2609      hr_assignment_bk4.actual_termination_emp_asg_b
2610        (p_assignment_id                 =>  p_assignment_id
2611        ,p_object_version_number         =>  p_object_version_number
2612        ,p_actual_termination_date       =>  l_actual_termination_date
2613        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
2614        ,p_business_group_id             =>  l_asg_business_group_id
2615        );
2616   exception
2617      when hr_api.cannot_find_prog_unit then
2618        hr_api.cannot_find_prog_unit_error
2619          (p_module_name       => 'ACTUAL_TERMINATION_EMP_ASG',
2620           p_hook_type         => 'BP'
2621          );
2622   end;
2623   --
2624   -- End of API User Hook for the before hook of actual_termination_emp_asg.
2625   --
2626  if g_debug then
2627   hr_utility.set_location(l_proc, 40);
2628  end if;
2629   --
2630   -- The assignment must not be a primary assignment.
2631   --
2632   if l_primary_flag <> 'N'
2633   then
2634     --
2635  if g_debug then
2636     hr_utility.set_location(l_proc, 50);
2637  end if;
2638     --
2639     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
2640     hr_utility.raise_error;
2641   end if;
2642   --
2643  if g_debug then
2644   hr_utility.set_location(l_proc, 60);
2645  end if;
2646   --
2647   -- The assignment must be an employee assignment.
2648   --
2649   if l_assignment_type <> 'E'
2650   then
2651     --
2652  if g_debug then
2653     hr_utility.set_location(l_proc, 70);
2654  end if;
2655     --
2656     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
2657     hr_utility.raise_error;
2658   end if;
2659   --
2660  if g_debug then
2661   hr_utility.set_location(l_proc, 80);
2662  end if;
2663   --
2664   -- The assignment status type must not already be TERM_ASSIGN on or after
2665   -- the actual termination date.
2666   --
2667   open  csr_invalid_term_assign;
2668   fetch csr_invalid_term_assign
2669    into l_exists;
2670   --
2671   if csr_invalid_term_assign%FOUND
2672   then
2673     --
2674  if g_debug then
2675     hr_utility.set_location(l_proc, 90);
2676  end if;
2677     --
2678     close csr_invalid_term_assign;
2679     --
2680     hr_utility.set_message(800,'PER_52108_ASG_INV_TERM_ASSIGN');
2681     hr_utility.raise_error;
2682   end if;
2683   --
2684   close csr_invalid_term_assign;
2685   --
2686  if g_debug then
2687   hr_utility.set_location(l_proc, 100);
2688  end if;
2689   --
2690   -- Process Logic
2691   --
2692   -- If p_assignment_status_type_id is g_number then derive it's default value,
2693   -- otherwise validate it.
2694   --
2695   per_asg_bus1.chk_assignment_status_type
2696     (p_assignment_status_type_id => l_assignment_status_type_id
2697     ,p_business_group_id         => l_asg_business_group_id
2698     ,p_legislation_code          => l_legislation_code
2699     ,p_expected_system_status    => 'TERM_ASSIGN'
2700     );
2701   --
2702  if g_debug then
2703   hr_utility.set_location(l_proc, 110);
2704  end if;
2705   --
2706   -- Derive the last standard process date.
2707   --
2708   -- Bug 1711085. VS. 27-MAR-01. Commented out the code associated with
2709   -- disabling last_standard_process  for US legislature.
2710   --
2711   -- if l_legislation_code = 'US'
2712   -- then
2713     --
2714  if g_debug then
2715      hr_utility.set_location(l_proc, 120);
2716  end if;
2717     --
2718     -- l_last_standard_process_date := l_actual_termination_date;
2719   -- else
2720     --
2721  if g_debug then
2722     hr_utility.set_location(l_proc, 130);
2723  end if;
2724     --
2725     if l_payroll_id is not null
2726     then
2727       --
2728  if g_debug then
2729       hr_utility.set_location(l_proc, 140);
2730  end if;
2731       --
2732       -- Assignment is assigned to a payroll, so set the last standard process
2733       -- to date to the payroll's period end date as of the actual termination
2734       -- date.
2735       --
2736       open  csr_get_period_end_date;
2737       fetch csr_get_period_end_date
2738        into l_last_standard_process_date;
2739       --
2740       if csr_get_period_end_date%NOTFOUND then
2741         --
2742  if g_debug then
2743         hr_utility.set_location(l_proc, 150);
2744  end if;
2745         --
2746         -- No payroll period found for the actual termination date.
2747         --
2748         close csr_get_period_end_date;
2749         --
2750         hr_utility.set_message(801,'HR_51003_ASG_INV_NO_TERM_PRD');
2751         hr_utility.raise_error;
2752       end if;
2753       --
2754       close csr_get_period_end_date;
2755       --
2756  if g_debug then
2757       hr_utility.set_location(l_proc, 160);
2758  end if;
2759     else
2760       --
2761  if g_debug then
2762       hr_utility.set_location(l_proc, 170);
2763  end if;
2764       --
2765       -- Assignment is not assigned to a payroll, so set the last standard
2766       -- process date to the actual termination date.
2767       --
2768       l_last_standard_process_date := l_actual_termination_date;
2769     end if;
2770   -- end if;
2771   --
2772  if g_debug then
2773   hr_utility.set_location(l_proc, 180);
2774  end if;
2775   --
2776   -- Call the business support process to update assignment and maintain the
2777   -- element entries.
2778   --
2779   hr_assignment_internal.actual_term_emp_asg_sup
2780     (p_assignment_id              => p_assignment_id
2781     ,p_object_version_number      => l_object_version_number
2782     ,p_actual_termination_date    => l_actual_termination_date
2783     ,p_last_standard_process_date => l_last_standard_process_date
2784     ,p_assignment_status_type_id  => l_assignment_status_type_id
2785     ,p_effective_start_date       => l_effective_start_date
2786     ,p_effective_end_date         => l_effective_end_date
2787     ,p_asg_future_changes_warning => l_asg_future_changes_warning
2788     ,p_entries_changed_warning    => l_entries_changed_warning
2789     ,p_pay_proposal_warning       => l_pay_proposal_warning
2790     );
2791   --
2792  if g_debug then
2793   hr_utility.set_location(l_proc, 190);
2794  end if;
2795   --
2796   -- When in validation only mode raise the Validate_Enabled exception
2797   --
2798   --
2799   -- Start of API User Hook for the after hook of actual_termination_emp_asg.
2800   -- Local vars are passed in for all OUT parms because the hook needs to
2801   -- be placed before the validate check and therefore before the code that
2802   -- sets all out parms.
2803   --
2804   begin
2805      hr_assignment_bk4.actual_termination_emp_asg_a
2806        (p_assignment_id                 =>  p_assignment_id
2807        ,p_object_version_number         =>  l_object_version_number
2808        ,p_actual_termination_date       =>  l_actual_termination_date
2809        ,p_assignment_status_type_id     =>  p_assignment_status_type_id
2810        ,p_effective_start_date          =>  l_effective_start_date
2811        ,p_effective_end_date            =>  l_effective_end_date
2812        ,p_asg_future_changes_warning    =>  l_asg_future_changes_warning
2813        ,p_entries_changed_warning       =>  l_entries_changed_warning
2814        ,p_pay_proposal_warning          =>  l_pay_proposal_warning
2815        ,p_business_group_id             =>  l_asg_business_group_id
2816        );
2817   exception
2818      when hr_api.cannot_find_prog_unit then
2819        hr_api.cannot_find_prog_unit_error
2820          (p_module_name       => 'ACTUAL_TERMINATION_EMP_ASG',
2821           p_hook_type         => 'AP'
2822          );
2823   end;
2824   --
2825   -- End of API User Hook for the after hook of actual_termination_emp_asg.
2826   --
2827   if p_validate then
2828     raise hr_api.validate_enabled;
2829   end if;
2830   --
2831   -- Set all output arguments
2832   --
2833   p_asg_future_changes_warning := l_asg_future_changes_warning;
2834   p_effective_end_date         := l_effective_end_date;
2835   p_effective_start_date       := l_effective_start_date;
2836   p_entries_changed_warning    := l_entries_changed_warning;
2837   p_pay_proposal_warning       := l_pay_proposal_warning;
2838   p_object_version_number      := l_object_version_number;
2839   --
2840  if g_debug then
2841   hr_utility.set_location(' Leaving:'||l_proc, 200);
2842  end if;
2843 exception
2844   when hr_api.validate_enabled then
2845     --
2846     -- As the Validate_Enabled exception has been raised
2847     -- we must rollback to the savepoint
2848     --
2849     ROLLBACK TO actual_termination_emp_asg;
2850     --
2851     -- Only set output warning arguments
2852     -- (Any key or derived arguments must be set to null
2853     -- when validation only mode is being used.)
2854     --
2855     p_asg_future_changes_warning := l_asg_future_changes_warning;
2856     p_effective_end_date         := null;
2857     p_effective_start_date       := null;
2858     p_entries_changed_warning    := l_entries_changed_warning;
2859     p_pay_proposal_warning       := l_pay_proposal_warning;
2860     p_object_version_number      := p_object_version_number;
2861     --
2862   when others then
2863     --
2864     -- A validation or unexpected error has occurred
2865     --
2866     -- Added as part of fix to bug 632479
2867     --
2868     p_object_version_number := lv_object_version_number;
2869     p_effective_start_date        := null;
2870     p_effective_end_date          := null;
2871     p_asg_future_changes_warning  := null;
2872     p_entries_changed_warning     := null;
2873     p_pay_proposal_warning        := null;
2874 
2875     ROLLBACK TO actual_termination_emp_asg;
2876     raise;
2877     --
2878     -- End of fix.
2879     --
2880 end actual_termination_emp_asg;
2881 --
2882 -- 70.2 change end.
2883 --
2884 -- ----------------------------------------------------------------------------
2885 -- |---------------------< create_secondary_emp_asg >--OLD---------------------|
2886 -- ----------------------------------------------------------------------------
2887 --
2888 -- This is the 'old' interface which now simply calls the
2889 -- 'new' interface and passes nulls for the new parms and
2890 -- assigns local variables to capture the new outs.
2891 --
2892 procedure create_secondary_emp_asg
2893   (p_validate                     in     boolean
2894   ,p_effective_date               in     date
2895   ,p_person_id                    in     number
2896   ,p_organization_id              in     number
2897   ,p_grade_id                     in     number
2898   ,p_position_id                  in     number
2899   ,p_job_id                       in     number
2900   ,p_assignment_status_type_id    in     number
2901   ,p_payroll_id                   in     number
2902   ,p_location_id                  in     number
2903   ,p_supervisor_id                in     number
2904   ,p_special_ceiling_step_id      in     number
2905   ,p_pay_basis_id                 in     number
2906   ,p_assignment_number            in out nocopy varchar2
2907   ,p_change_reason                in     varchar2
2908   ,p_comments                     in     varchar2
2909   ,p_date_probation_end           in     date
2910   ,p_default_code_comb_id         in     number
2911   ,p_employment_category          in     varchar2
2912   ,p_frequency                    in     varchar2
2913   ,p_internal_address_line        in     varchar2
2914   ,p_manager_flag                 in     varchar2
2915   ,p_normal_hours                 in     number
2916   ,p_perf_review_period           in     number
2917   ,p_perf_review_period_frequency in     varchar2
2918   ,p_probation_period             in     number
2919   ,p_probation_unit               in     varchar2
2920   ,p_sal_review_period            in     number
2921   ,p_sal_review_period_frequency  in     varchar2
2922   ,p_set_of_books_id              in     number
2923   ,p_source_type                  in     varchar2
2924   ,p_time_normal_finish           in     varchar2
2925   ,p_time_normal_start            in     varchar2
2926   ,p_bargaining_unit_code         in     varchar2
2927   ,p_labour_union_member_flag     in     varchar2
2928   ,p_hourly_salaried_code         in     varchar2
2929   ,p_ass_attribute_category       in     varchar2
2930   ,p_ass_attribute1               in     varchar2
2931   ,p_ass_attribute2               in     varchar2
2932   ,p_ass_attribute3               in     varchar2
2933   ,p_ass_attribute4               in     varchar2
2934   ,p_ass_attribute5               in     varchar2
2935   ,p_ass_attribute6               in     varchar2
2936   ,p_ass_attribute7               in     varchar2
2937   ,p_ass_attribute8               in     varchar2
2938   ,p_ass_attribute9               in     varchar2
2939   ,p_ass_attribute10              in     varchar2
2940   ,p_ass_attribute11              in     varchar2
2941   ,p_ass_attribute12              in     varchar2
2942   ,p_ass_attribute13              in     varchar2
2943   ,p_ass_attribute14              in     varchar2
2944   ,p_ass_attribute15              in     varchar2
2945   ,p_ass_attribute16              in     varchar2
2946   ,p_ass_attribute17              in     varchar2
2947   ,p_ass_attribute18              in     varchar2
2948   ,p_ass_attribute19              in     varchar2
2949   ,p_ass_attribute20              in     varchar2
2950   ,p_ass_attribute21              in     varchar2
2951   ,p_ass_attribute22              in     varchar2
2952   ,p_ass_attribute23              in     varchar2
2953   ,p_ass_attribute24              in     varchar2
2954   ,p_ass_attribute25              in     varchar2
2955   ,p_ass_attribute26              in     varchar2
2956   ,p_ass_attribute27              in     varchar2
2957   ,p_ass_attribute28              in     varchar2
2958   ,p_ass_attribute29              in     varchar2
2959   ,p_ass_attribute30              in     varchar2
2960   ,p_title                        in     varchar2
2961   ,p_scl_segment1                 in     varchar2
2962   ,p_scl_segment2                 in     varchar2
2963   ,p_scl_segment3                 in     varchar2
2964   ,p_scl_segment4                 in     varchar2
2965   ,p_scl_segment5                 in     varchar2
2966   ,p_scl_segment6                 in     varchar2
2967   ,p_scl_segment7                 in     varchar2
2968   ,p_scl_segment8                 in     varchar2
2969   ,p_scl_segment9                 in     varchar2
2970   ,p_scl_segment10                in     varchar2
2971   ,p_scl_segment11                in     varchar2
2972   ,p_scl_segment12                in     varchar2
2973   ,p_scl_segment13                in     varchar2
2974   ,p_scl_segment14                in     varchar2
2975   ,p_scl_segment15                in     varchar2
2976   ,p_scl_segment16                in     varchar2
2977   ,p_scl_segment17                in     varchar2
2978   ,p_scl_segment18                in     varchar2
2979   ,p_scl_segment19                in     varchar2
2980   ,p_scl_segment20                in     varchar2
2981   ,p_scl_segment21                in     varchar2
2982   ,p_scl_segment22                in     varchar2
2983   ,p_scl_segment23                in     varchar2
2984   ,p_scl_segment24                in     varchar2
2985   ,p_scl_segment25                in     varchar2
2986   ,p_scl_segment26                in     varchar2
2987   ,p_scl_segment27                in     varchar2
2988   ,p_scl_segment28                in     varchar2
2989   ,p_scl_segment29                in     varchar2
2990   ,p_scl_segment30                in     varchar2
2991    -- Bug 944911
2992    -- Added scl_concat_segments and amended scl_concatenated_segments
2993    -- to be an out instead of in out
2994   ,p_scl_concat_segments    	  in 	 varchar2
2995   ,p_pgp_segment1                 in     varchar2
2996   ,p_pgp_segment2                 in     varchar2
2997   ,p_pgp_segment3                 in     varchar2
2998   ,p_pgp_segment4                 in     varchar2
2999   ,p_pgp_segment5                 in     varchar2
3000   ,p_pgp_segment6                 in     varchar2
3001   ,p_pgp_segment7                 in     varchar2
3002   ,p_pgp_segment8                 in     varchar2
3003   ,p_pgp_segment9                 in     varchar2
3004   ,p_pgp_segment10                in     varchar2
3005   ,p_pgp_segment11                in     varchar2
3006   ,p_pgp_segment12                in     varchar2
3007   ,p_pgp_segment13                in     varchar2
3008   ,p_pgp_segment14                in     varchar2
3009   ,p_pgp_segment15                in     varchar2
3010   ,p_pgp_segment16                in     varchar2
3011   ,p_pgp_segment17                in     varchar2
3012   ,p_pgp_segment18                in     varchar2
3013   ,p_pgp_segment19                in     varchar2
3014   ,p_pgp_segment20                in     varchar2
3015   ,p_pgp_segment21                in     varchar2
3016   ,p_pgp_segment22                in     varchar2
3017   ,p_pgp_segment23                in     varchar2
3018   ,p_pgp_segment24                in     varchar2
3019   ,p_pgp_segment25                in     varchar2
3020   ,p_pgp_segment26                in     varchar2
3021   ,p_pgp_segment27                in     varchar2
3022   ,p_pgp_segment28                in     varchar2
3023   ,p_pgp_segment29                in     varchar2
3024   ,p_pgp_segment30                in     varchar2
3025 -- Bug 944911
3026 -- Made p_group_name to be out param
3027 -- and add p_concat_segment to be IN
3028 -- in case of sec_asg alone made p_pgp_concat_segments as in param
3029   ,p_pgp_concat_segments	  in     varchar2
3030   ,p_supervisor_assignment_id     in     number
3031   ,p_group_name                      out nocopy varchar2
3032 -- Bug 944911
3033 -- Added scl_concat_segments and amended scl_concatenated_segments
3034 -- to be an out instead of in out
3035 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
3036 -- This has been done through out the procedures
3037   ,p_concatenated_segments           out nocopy varchar2
3038   ,p_assignment_id                   out nocopy number
3039   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
3040   ,p_people_group_id              in out nocopy number  -- bug 2359997
3041   ,p_object_version_number           out nocopy number
3042   ,p_effective_start_date            out nocopy date
3043   ,p_effective_end_date              out nocopy date
3044   ,p_assignment_sequence             out nocopy number
3045   ,p_comment_id                      out nocopy number
3046   ,p_other_manager_warning           out nocopy boolean
3047   ) is
3048   --
3049   -- Declare cursors and local variables
3050   --
3051   -- Out variables
3052   --
3053   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
3054   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
3055   := p_soft_coding_keyflex_id;  -- bug 2359997
3056   l_people_group_id        per_all_assignments_f.people_group_id%TYPE
3057   := p_people_group_id; -- bug 2359997
3058   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
3059   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
3060   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
3061   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
3062   l_assignment_number      per_all_assignments_f.assignment_number%TYPE;
3063   l_comment_id             per_all_assignments_f.comment_id%TYPE;
3064   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3065   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3066   l_group_name             pay_people_groups.group_name%TYPE;
3067   l_old_group_name         pay_people_groups.group_name%TYPE;
3068   l_other_manager_warning  boolean;
3069   l_effective_date         date;
3070   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
3071   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
3072   l_scl_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3073   l_grp_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3074   --
3075   l_business_group_id    per_business_groups.business_group_id%TYPE;
3076   l_legislation_code     per_business_groups.legislation_code%TYPE;
3077   l_period_of_service_id per_all_assignments_f.period_of_service_id%TYPE;
3078   l_proc                 varchar2(72);
3079   l_session_id           number;
3080   l_cagr_grade_def_id    number;
3081   l_cagr_concatenated_segments number;
3082   --
3083 --
3084 begin
3085 --
3086  if g_debug then
3087   l_proc := g_package||'create_secondary_emp_asg';
3088   hr_utility.set_location('Entering:'|| l_proc, 5);
3089  end if;
3090   --
3091   l_assignment_number := p_assignment_number;
3092   --
3093   -- Call the new code
3094   --
3095   hr_assignment_api.create_secondary_emp_asg(
3096    p_validate                     => p_validate
3097   ,p_effective_date               => p_effective_date
3098   ,p_person_id                    => p_person_id
3099   ,p_organization_id              => p_organization_id
3100   ,p_grade_id                     => p_grade_id
3101   ,p_position_id                  => p_position_id
3102   ,p_job_id                       => p_job_id
3103   ,p_assignment_status_type_id    => p_assignment_status_type_id
3104   ,p_payroll_id                   => p_payroll_id
3105   ,p_location_id                  => p_location_id
3106   ,p_supervisor_id                => p_supervisor_id
3107   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
3108   ,p_pay_basis_id                 => p_pay_basis_id
3109   ,p_assignment_number            => l_assignment_number
3110   ,p_change_reason                => p_change_reason
3111   ,p_comments                     => p_comments
3112   ,p_date_probation_end           => p_date_probation_end
3113   ,p_default_code_comb_id         => p_default_code_comb_id
3114   ,p_employment_category          => p_employment_category
3115   ,p_frequency                    => p_frequency
3116   ,p_internal_address_line        => p_internal_address_line
3117   ,p_manager_flag                 => p_manager_flag
3118   ,p_normal_hours                 => p_normal_hours
3119   ,p_perf_review_period           => p_perf_review_period
3120   ,p_perf_review_period_frequency => p_perf_review_period_frequency
3121   ,p_probation_period             => p_probation_period
3122   ,p_probation_unit               => p_probation_unit
3123   ,p_sal_review_period            => p_sal_review_period
3124   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
3125   ,p_set_of_books_id              => p_set_of_books_id
3126   ,p_source_type                  => p_source_type
3127   ,p_time_normal_finish           => p_time_normal_finish
3128   ,p_time_normal_start            => p_time_normal_start
3129   ,p_bargaining_unit_code         => p_bargaining_unit_code
3130   ,p_labour_union_member_flag     => p_labour_union_member_flag
3131   ,p_hourly_salaried_code         => p_hourly_salaried_code
3132   ,p_ass_attribute_category       => p_ass_attribute_category
3133   ,p_ass_attribute1               => p_ass_attribute1
3134   ,p_ass_attribute2               => p_ass_attribute2
3135   ,p_ass_attribute3               => p_ass_attribute3
3136   ,p_ass_attribute4               => p_ass_attribute4
3137   ,p_ass_attribute5               => p_ass_attribute5
3138   ,p_ass_attribute6               => p_ass_attribute6
3139   ,p_ass_attribute7               => p_ass_attribute7
3140   ,p_ass_attribute8               => p_ass_attribute8
3141   ,p_ass_attribute9               => p_ass_attribute9
3142   ,p_ass_attribute10              => p_ass_attribute10
3143   ,p_ass_attribute11              => p_ass_attribute11
3144   ,p_ass_attribute12              => p_ass_attribute12
3145   ,p_ass_attribute13              => p_ass_attribute13
3146   ,p_ass_attribute14              => p_ass_attribute14
3147   ,p_ass_attribute15              => p_ass_attribute15
3148   ,p_ass_attribute16              => p_ass_attribute16
3149   ,p_ass_attribute17              => p_ass_attribute17
3150   ,p_ass_attribute18              => p_ass_attribute18
3151   ,p_ass_attribute19              => p_ass_attribute19
3152   ,p_ass_attribute20              => p_ass_attribute20
3153   ,p_ass_attribute21              => p_ass_attribute21
3154   ,p_ass_attribute22              => p_ass_attribute22
3155   ,p_ass_attribute23              => p_ass_attribute23
3156   ,p_ass_attribute24              => p_ass_attribute24
3157   ,p_ass_attribute25              => p_ass_attribute25
3158   ,p_ass_attribute26              => p_ass_attribute26
3159   ,p_ass_attribute27              => p_ass_attribute27
3160   ,p_ass_attribute28              => p_ass_attribute28
3161   ,p_ass_attribute29              => p_ass_attribute29
3162   ,p_ass_attribute30              => p_ass_attribute30
3163   ,p_title                        => p_title
3164   ,p_scl_segment1                 => p_scl_segment1
3165   ,p_scl_segment2                 => p_scl_segment2
3166   ,p_scl_segment3                 => p_scl_segment3
3167   ,p_scl_segment4                 => p_scl_segment4
3168   ,p_scl_segment5                 => p_scl_segment5
3169   ,p_scl_segment6                 => p_scl_segment6
3170   ,p_scl_segment7                 => p_scl_segment7
3171   ,p_scl_segment8                 => p_scl_segment8
3172   ,p_scl_segment9                 => p_scl_segment9
3173   ,p_scl_segment10                => p_scl_segment10
3174   ,p_scl_segment11                => p_scl_segment11
3175   ,p_scl_segment12                => p_scl_segment12
3176   ,p_scl_segment13                => p_scl_segment13
3177   ,p_scl_segment14                => p_scl_segment14
3178   ,p_scl_segment15                => p_scl_segment15
3179   ,p_scl_segment16                => p_scl_segment16
3180   ,p_scl_segment17                => p_scl_segment17
3181   ,p_scl_segment18                => p_scl_segment18
3182   ,p_scl_segment19                => p_scl_segment19
3183   ,p_scl_segment20                => p_scl_segment20
3184   ,p_scl_segment21                => p_scl_segment21
3185   ,p_scl_segment22                => p_scl_segment22
3186   ,p_scl_segment23                => p_scl_segment23
3187   ,p_scl_segment24                => p_scl_segment24
3188   ,p_scl_segment25                => p_scl_segment25
3189   ,p_scl_segment26                => p_scl_segment26
3190   ,p_scl_segment27                => p_scl_segment27
3191   ,p_scl_segment28                => p_scl_segment28
3192   ,p_scl_segment29                => p_scl_segment29
3193   ,p_scl_segment30                => p_scl_segment30
3194   ,p_scl_concat_segments          => p_scl_concat_segments
3195   ,p_pgp_segment1                 => p_pgp_segment1
3196   ,p_pgp_segment2                 => p_pgp_segment2
3197   ,p_pgp_segment3                 => p_pgp_segment3
3198   ,p_pgp_segment4                 => p_pgp_segment4
3199   ,p_pgp_segment5                 => p_pgp_segment5
3200   ,p_pgp_segment6                 => p_pgp_segment6
3201   ,p_pgp_segment7                 => p_pgp_segment7
3202   ,p_pgp_segment8                 => p_pgp_segment8
3203   ,p_pgp_segment9                 => p_pgp_segment9
3204   ,p_pgp_segment10                => p_pgp_segment10
3205   ,p_pgp_segment11                => p_pgp_segment11
3206   ,p_pgp_segment12                => p_pgp_segment12
3207   ,p_pgp_segment13                => p_pgp_segment13
3208   ,p_pgp_segment14                => p_pgp_segment14
3209   ,p_pgp_segment15                => p_pgp_segment15
3210   ,p_pgp_segment16                => p_pgp_segment16
3211   ,p_pgp_segment17                => p_pgp_segment17
3212   ,p_pgp_segment18                => p_pgp_segment18
3213   ,p_pgp_segment19                => p_pgp_segment19
3214   ,p_pgp_segment20                => p_pgp_segment20
3215   ,p_pgp_segment21                => p_pgp_segment21
3216   ,p_pgp_segment22                => p_pgp_segment22
3217   ,p_pgp_segment23                => p_pgp_segment23
3218   ,p_pgp_segment24                => p_pgp_segment24
3219   ,p_pgp_segment25                => p_pgp_segment25
3220   ,p_pgp_segment26                => p_pgp_segment26
3221   ,p_pgp_segment27                => p_pgp_segment27
3222   ,p_pgp_segment28                => p_pgp_segment28
3223   ,p_pgp_segment29                => p_pgp_segment29
3224   ,p_pgp_segment30                => p_pgp_segment30
3225   ,p_pgp_concat_segments          => p_pgp_concat_segments
3226   ,p_contract_id                  => null
3227   ,p_establishment_id             => null
3228   ,p_collective_agreement_id      => null
3229   ,p_cagr_id_flex_num             => null
3230   ,p_cag_segment1                 => null
3231   ,p_cag_segment2                 => null
3232   ,p_cag_segment3                 => null
3233   ,p_cag_segment4                 => null
3234   ,p_cag_segment5                 => null
3235   ,p_cag_segment6                 => null
3236   ,p_cag_segment7                 => null
3237   ,p_cag_segment8                 => null
3238   ,p_cag_segment9                 => null
3239   ,p_cag_segment10                => null
3240   ,p_cag_segment11                => null
3241   ,p_cag_segment12                => null
3242   ,p_cag_segment13                => null
3243   ,p_cag_segment14                => null
3244   ,p_cag_segment15                => null
3245   ,p_cag_segment16                => null
3246   ,p_cag_segment17                => null
3247   ,p_cag_segment18                => null
3248   ,p_cag_segment19                => null
3249   ,p_cag_segment20                => null
3250   ,p_grade_ladder_pgm_id          => null
3251   ,p_supervisor_assignment_id     => null
3252   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
3253   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
3254   ,p_assignment_id                => l_assignment_id
3255   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
3256   ,p_people_group_id              => l_people_group_id
3257   ,p_object_version_number        => l_object_version_number
3258   ,p_effective_start_date         => l_effective_start_date
3259   ,p_effective_end_date           => l_effective_end_date
3260   ,p_assignment_sequence          => l_assignment_sequence
3261   ,p_comment_id                   => l_comment_id
3262   ,p_concatenated_segments        => l_concatenated_segments
3263   ,p_group_name                   => l_group_name
3264   ,p_other_manager_warning        => l_other_manager_warning
3265    );
3266   --
3267   -- Set remaining output arguments
3268   --
3269   p_assignment_id          := l_assignment_id;
3270   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
3271   p_people_group_id        := l_people_group_id;
3272   p_object_version_number  := l_object_version_number;
3273   p_effective_start_date   := l_effective_start_date;
3274   p_effective_end_date     := l_effective_end_date;
3275   p_assignment_sequence    := l_assignment_sequence;
3276   p_comment_id             := l_comment_id;
3277   p_concatenated_segments  := l_concatenated_segments;
3278   p_group_name             := l_group_name;
3279   p_other_manager_warning  := l_other_manager_warning;
3280   --
3281  if g_debug then
3282   hr_utility.set_location(' Leaving:'||l_proc, 50);
3283  end if;
3284 end create_secondary_emp_asg;
3285 --
3286 -- ----------------------------------------------------------------------------
3287 -- |---------------------< create_secondary_emp_asg >-NEW----------------------|
3288 -- ----------------------------------------------------------------------------
3289 --
3290 -- This is the new interface that contains the extra parms
3291 -- for collective agreements and contracts.
3292 -- added new parameters notice_period, units, employee_category,
3293 -- work_at_home and job_source on 05-OCT-01
3294 --
3295 procedure create_secondary_emp_asg
3296   (p_validate                     in     boolean
3297   ,p_effective_date               in     date
3298   ,p_person_id                    in     number
3299   ,p_organization_id              in     number
3300   ,p_grade_id                     in     number
3301   ,p_position_id                  in     number
3302   ,p_job_id                       in     number
3303   ,p_assignment_status_type_id    in     number
3304   ,p_payroll_id                   in     number
3305   ,p_location_id                  in     number
3306   ,p_supervisor_id                in     number
3307   ,p_special_ceiling_step_id      in     number
3308   ,p_pay_basis_id                 in     number
3309   ,p_assignment_number            in out nocopy varchar2
3310   ,p_change_reason                in     varchar2
3311   ,p_comments                     in     varchar2
3312   ,p_date_probation_end           in     date
3313   ,p_default_code_comb_id         in     number
3314   ,p_employment_category          in     varchar2
3315   ,p_frequency                    in     varchar2
3316   ,p_internal_address_line        in     varchar2
3317   ,p_manager_flag                 in     varchar2
3318   ,p_normal_hours                 in     number
3319   ,p_perf_review_period           in     number
3320   ,p_perf_review_period_frequency in     varchar2
3321   ,p_probation_period             in     number
3322   ,p_probation_unit               in     varchar2
3323   ,p_sal_review_period            in     number
3324   ,p_sal_review_period_frequency  in     varchar2
3325   ,p_set_of_books_id              in     number
3326   ,p_source_type                  in     varchar2
3327   ,p_time_normal_finish           in     varchar2
3328   ,p_time_normal_start            in     varchar2
3329   ,p_bargaining_unit_code         in     varchar2
3330   ,p_labour_union_member_flag     in     varchar2
3331   ,p_hourly_salaried_code         in     varchar2
3332   ,p_ass_attribute_category       in     varchar2
3333   ,p_ass_attribute1               in     varchar2
3334   ,p_ass_attribute2               in     varchar2
3335   ,p_ass_attribute3               in     varchar2
3336   ,p_ass_attribute4               in     varchar2
3337   ,p_ass_attribute5               in     varchar2
3338   ,p_ass_attribute6               in     varchar2
3339   ,p_ass_attribute7               in     varchar2
3340   ,p_ass_attribute8               in     varchar2
3341   ,p_ass_attribute9               in     varchar2
3342   ,p_ass_attribute10              in     varchar2
3343   ,p_ass_attribute11              in     varchar2
3344   ,p_ass_attribute12              in     varchar2
3345   ,p_ass_attribute13              in     varchar2
3346   ,p_ass_attribute14              in     varchar2
3347   ,p_ass_attribute15              in     varchar2
3348   ,p_ass_attribute16              in     varchar2
3349   ,p_ass_attribute17              in     varchar2
3350   ,p_ass_attribute18              in     varchar2
3351   ,p_ass_attribute19              in     varchar2
3352   ,p_ass_attribute20              in     varchar2
3353   ,p_ass_attribute21              in     varchar2
3354   ,p_ass_attribute22              in     varchar2
3355   ,p_ass_attribute23              in     varchar2
3356   ,p_ass_attribute24              in     varchar2
3357   ,p_ass_attribute25              in     varchar2
3358   ,p_ass_attribute26              in     varchar2
3359   ,p_ass_attribute27              in     varchar2
3360   ,p_ass_attribute28              in     varchar2
3361   ,p_ass_attribute29              in     varchar2
3362   ,p_ass_attribute30              in     varchar2
3363   ,p_title                        in     varchar2
3364   ,p_scl_segment1                 in     varchar2
3365   ,p_scl_segment2                 in     varchar2
3366   ,p_scl_segment3                 in     varchar2
3367   ,p_scl_segment4                 in     varchar2
3368   ,p_scl_segment5                 in     varchar2
3369   ,p_scl_segment6                 in     varchar2
3370   ,p_scl_segment7                 in     varchar2
3371   ,p_scl_segment8                 in     varchar2
3372   ,p_scl_segment9                 in     varchar2
3373   ,p_scl_segment10                in     varchar2
3374   ,p_scl_segment11                in     varchar2
3375   ,p_scl_segment12                in     varchar2
3376   ,p_scl_segment13                in     varchar2
3377   ,p_scl_segment14                in     varchar2
3378   ,p_scl_segment15                in     varchar2
3379   ,p_scl_segment16                in     varchar2
3380   ,p_scl_segment17                in     varchar2
3381   ,p_scl_segment18                in     varchar2
3382   ,p_scl_segment19                in     varchar2
3383   ,p_scl_segment20                in     varchar2
3384   ,p_scl_segment21                in     varchar2
3385   ,p_scl_segment22                in     varchar2
3386   ,p_scl_segment23                in     varchar2
3387   ,p_scl_segment24                in     varchar2
3388   ,p_scl_segment25                in     varchar2
3389   ,p_scl_segment26                in     varchar2
3390   ,p_scl_segment27                in     varchar2
3391   ,p_scl_segment28                in     varchar2
3392   ,p_scl_segment29                in     varchar2
3393   ,p_scl_segment30                in     varchar2
3394 -- Bug 944911
3395 -- Added scl_concat_segments and amended scl_concatenated_segments
3396 -- to be an out instead of in out
3397   ,p_scl_concat_segments    	  in 	 varchar2
3398   ,p_pgp_segment1                 in     varchar2
3399   ,p_pgp_segment2                 in     varchar2
3400   ,p_pgp_segment3                 in     varchar2
3401   ,p_pgp_segment4                 in     varchar2
3402   ,p_pgp_segment5                 in     varchar2
3403   ,p_pgp_segment6                 in     varchar2
3404   ,p_pgp_segment7                 in     varchar2
3405   ,p_pgp_segment8                 in     varchar2
3406   ,p_pgp_segment9                 in     varchar2
3407   ,p_pgp_segment10                in     varchar2
3408   ,p_pgp_segment11                in     varchar2
3409   ,p_pgp_segment12                in     varchar2
3410   ,p_pgp_segment13                in     varchar2
3411   ,p_pgp_segment14                in     varchar2
3412   ,p_pgp_segment15                in     varchar2
3413   ,p_pgp_segment16                in     varchar2
3414   ,p_pgp_segment17                in     varchar2
3415   ,p_pgp_segment18                in     varchar2
3416   ,p_pgp_segment19                in     varchar2
3417   ,p_pgp_segment20                in     varchar2
3418   ,p_pgp_segment21                in     varchar2
3419   ,p_pgp_segment22                in     varchar2
3420   ,p_pgp_segment23                in     varchar2
3421   ,p_pgp_segment24                in     varchar2
3422   ,p_pgp_segment25                in     varchar2
3423   ,p_pgp_segment26                in     varchar2
3424   ,p_pgp_segment27                in     varchar2
3425   ,p_pgp_segment28                in     varchar2
3426   ,p_pgp_segment29                in     varchar2
3427   ,p_pgp_segment30                in     varchar2
3428 -- Bug 944911
3429 -- Made p_group_name to be out param
3430 -- and add p_concat_segment to be IN
3431 -- in case of sec_asg alone made p_pgp_concat_segments as in param
3432   ,p_pgp_concat_segments	  in     varchar2
3433   ,p_contract_id                  in     number
3434   ,p_establishment_id             in     number
3435   ,p_collective_agreement_id      in     number
3436   ,p_cagr_id_flex_num             in     number
3437   ,p_cag_segment1                 in     varchar2
3438   ,p_cag_segment2                 in     varchar2
3439   ,p_cag_segment3                 in     varchar2
3440   ,p_cag_segment4                 in     varchar2
3441   ,p_cag_segment5                 in     varchar2
3442   ,p_cag_segment6                 in     varchar2
3443   ,p_cag_segment7                 in     varchar2
3444   ,p_cag_segment8                 in     varchar2
3445   ,p_cag_segment9                 in     varchar2
3446   ,p_cag_segment10                in     varchar2
3447   ,p_cag_segment11                in     varchar2
3448   ,p_cag_segment12                in     varchar2
3449   ,p_cag_segment13                in     varchar2
3450   ,p_cag_segment14                in     varchar2
3451   ,p_cag_segment15                in     varchar2
3452   ,p_cag_segment16                in     varchar2
3453   ,p_cag_segment17                in     varchar2
3454   ,p_cag_segment18                in     varchar2
3455   ,p_cag_segment19                in     varchar2
3456   ,p_cag_segment20                in     varchar2
3457   ,p_notice_period		  in	 number
3458   ,p_notice_period_uom		  in     varchar2
3459   ,p_employee_category		  in     varchar2
3460   ,p_work_at_home		  in	 varchar2
3461   ,p_job_post_source_name         in     varchar2
3462   ,p_grade_ladder_pgm_id          in     number
3463   ,p_supervisor_assignment_id     in     number
3464   ,p_group_name                      out nocopy varchar2
3465 -- Bug 944911
3466 -- Added scl_concat_segments and amended scl_concatenated_segments
3467 -- to be an out instead of in out
3468 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
3469 -- This has been done through out the procedures
3470   ,p_concatenated_segments           out nocopy varchar2
3471   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
3472   ,p_cagr_concatenated_segments      out nocopy varchar2
3473   ,p_assignment_id                   out nocopy number
3474   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
3475   ,p_people_group_id              in out nocopy number  -- bug 2359997
3476   ,p_object_version_number           out nocopy number
3477   ,p_effective_start_date            out nocopy date
3478   ,p_effective_end_date              out nocopy date
3479   ,p_assignment_sequence             out nocopy number
3480   ,p_comment_id                      out nocopy number
3481   ,p_other_manager_warning           out nocopy boolean
3482   ) is
3483   --
3484   -- Declare cursors and local variables
3485   --
3486   -- Out variables
3487   --
3488   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
3489   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
3490   := p_soft_coding_keyflex_id;  -- bug 2359997 added initialization
3491   l_people_group_id        per_all_assignments_f.people_group_id%TYPE
3492   := p_people_group_id;    -- bug 2359997 added initialization
3493   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
3494   := p_cagr_grade_def_id;   -- bug 2359997, added this local variable
3495   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
3496   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
3497   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
3498   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
3499   l_assignment_number      per_all_assignments_f.assignment_number%TYPE;
3500   l_comment_id             per_all_assignments_f.comment_id%TYPE;
3501   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3502   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
3503   l_group_name             pay_people_groups.group_name%TYPE;
3504   l_old_group_name         pay_people_groups.group_name%TYPE;
3505   l_other_manager_warning  boolean;
3506   l_effective_date         date;
3507   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
3508   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
3509   l_scl_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3510   l_grp_flex_num           fnd_id_flex_segments.id_flex_num%TYPE;
3511   l_hourly_salaried_warning boolean;
3512   l_proc                 varchar2(72);
3513 --
3514 begin
3515 --
3516  if g_debug then
3517   l_proc := g_package||'create_secondary_emp_asg';
3518   hr_utility.set_location('Entering:'|| l_proc, 5);
3519  end if;
3520   --
3521   l_assignment_number := p_assignment_number;
3522   --
3523   -- Call the new code
3524   --
3525   hr_assignment_api.create_secondary_emp_asg(
3526    p_validate                     => p_validate
3527   ,p_effective_date               => p_effective_date
3528   ,p_person_id                    => p_person_id
3529   ,p_organization_id              => p_organization_id
3530   ,p_grade_id                     => p_grade_id
3531   ,p_position_id                  => p_position_id
3532   ,p_job_id                       => p_job_id
3533   ,p_assignment_status_type_id    => p_assignment_status_type_id
3534   ,p_payroll_id                   => p_payroll_id
3535   ,p_location_id                  => p_location_id
3536   ,p_supervisor_id                => p_supervisor_id
3537   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
3538   ,p_pay_basis_id                 => p_pay_basis_id
3539   ,p_assignment_number            => l_assignment_number
3540   ,p_change_reason                => p_change_reason
3541   ,p_comments                     => p_comments
3542   ,p_date_probation_end           => p_date_probation_end
3543   ,p_default_code_comb_id         => p_default_code_comb_id
3544   ,p_employment_category          => p_employment_category
3545   ,p_frequency                    => p_frequency
3546   ,p_internal_address_line        => p_internal_address_line
3547   ,p_manager_flag                 => p_manager_flag
3548   ,p_normal_hours                 => p_normal_hours
3549   ,p_perf_review_period           => p_perf_review_period
3550   ,p_perf_review_period_frequency => p_perf_review_period_frequency
3551   ,p_probation_period             => p_probation_period
3552   ,p_probation_unit               => p_probation_unit
3553   ,p_sal_review_period            => p_sal_review_period
3554   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
3555   ,p_set_of_books_id              => p_set_of_books_id
3556   ,p_source_type                  => p_source_type
3557   ,p_time_normal_finish           => p_time_normal_finish
3558   ,p_time_normal_start            => p_time_normal_start
3559   ,p_bargaining_unit_code         => p_bargaining_unit_code
3560   ,p_labour_union_member_flag     => p_labour_union_member_flag
3561   ,p_hourly_salaried_code         => p_hourly_salaried_code
3562   ,p_notice_period                => p_notice_period
3563   ,p_notice_period_uom            => p_notice_period_uom
3564   ,p_employee_category            => p_employee_category
3565   ,p_work_at_home                 => p_work_at_home
3566   ,p_job_post_source_name         => p_job_post_source_name
3567   ,p_ass_attribute_category       => p_ass_attribute_category
3568   ,p_ass_attribute1               => p_ass_attribute1
3569   ,p_ass_attribute2               => p_ass_attribute2
3570   ,p_ass_attribute3               => p_ass_attribute3
3571   ,p_ass_attribute4               => p_ass_attribute4
3572   ,p_ass_attribute5               => p_ass_attribute5
3573   ,p_ass_attribute6               => p_ass_attribute6
3574   ,p_ass_attribute7               => p_ass_attribute7
3575   ,p_ass_attribute8               => p_ass_attribute8
3576   ,p_ass_attribute9               => p_ass_attribute9
3577   ,p_ass_attribute10              => p_ass_attribute10
3578   ,p_ass_attribute11              => p_ass_attribute11
3579   ,p_ass_attribute12              => p_ass_attribute12
3580   ,p_ass_attribute13              => p_ass_attribute13
3581   ,p_ass_attribute14              => p_ass_attribute14
3582   ,p_ass_attribute15              => p_ass_attribute15
3583   ,p_ass_attribute16              => p_ass_attribute16
3584   ,p_ass_attribute17              => p_ass_attribute17
3585   ,p_ass_attribute18              => p_ass_attribute18
3586   ,p_ass_attribute19              => p_ass_attribute19
3587   ,p_ass_attribute20              => p_ass_attribute20
3588   ,p_ass_attribute21              => p_ass_attribute21
3589   ,p_ass_attribute22              => p_ass_attribute22
3590   ,p_ass_attribute23              => p_ass_attribute23
3591   ,p_ass_attribute24              => p_ass_attribute24
3592   ,p_ass_attribute25              => p_ass_attribute25
3593   ,p_ass_attribute26              => p_ass_attribute26
3594   ,p_ass_attribute27              => p_ass_attribute27
3595   ,p_ass_attribute28              => p_ass_attribute28
3596   ,p_ass_attribute29              => p_ass_attribute29
3597   ,p_ass_attribute30              => p_ass_attribute30
3598   ,p_title                        => p_title
3599   ,p_scl_segment1                 => p_scl_segment1
3600   ,p_scl_segment2                 => p_scl_segment2
3601   ,p_scl_segment3                 => p_scl_segment3
3602   ,p_scl_segment4                 => p_scl_segment4
3603   ,p_scl_segment5                 => p_scl_segment5
3604   ,p_scl_segment6                 => p_scl_segment6
3605   ,p_scl_segment7                 => p_scl_segment7
3606   ,p_scl_segment8                 => p_scl_segment8
3607   ,p_scl_segment9                 => p_scl_segment9
3608   ,p_scl_segment10                => p_scl_segment10
3609   ,p_scl_segment11                => p_scl_segment11
3610   ,p_scl_segment12                => p_scl_segment12
3611   ,p_scl_segment13                => p_scl_segment13
3612   ,p_scl_segment14                => p_scl_segment14
3613   ,p_scl_segment15                => p_scl_segment15
3614   ,p_scl_segment16                => p_scl_segment16
3615   ,p_scl_segment17                => p_scl_segment17
3616   ,p_scl_segment18                => p_scl_segment18
3617   ,p_scl_segment19                => p_scl_segment19
3618   ,p_scl_segment20                => p_scl_segment20
3619   ,p_scl_segment21                => p_scl_segment21
3620   ,p_scl_segment22                => p_scl_segment22
3621   ,p_scl_segment23                => p_scl_segment23
3622   ,p_scl_segment24                => p_scl_segment24
3623   ,p_scl_segment25                => p_scl_segment25
3624   ,p_scl_segment26                => p_scl_segment26
3625   ,p_scl_segment27                => p_scl_segment27
3626   ,p_scl_segment28                => p_scl_segment28
3627   ,p_scl_segment29                => p_scl_segment29
3628   ,p_scl_segment30                => p_scl_segment30
3629   ,p_scl_concat_segments          => p_scl_concat_segments
3630   ,p_pgp_segment1                 => p_pgp_segment1
3631   ,p_pgp_segment2                 => p_pgp_segment2
3632   ,p_pgp_segment3                 => p_pgp_segment3
3633   ,p_pgp_segment4                 => p_pgp_segment4
3634   ,p_pgp_segment5                 => p_pgp_segment5
3635   ,p_pgp_segment6                 => p_pgp_segment6
3636   ,p_pgp_segment7                 => p_pgp_segment7
3637   ,p_pgp_segment8                 => p_pgp_segment8
3638   ,p_pgp_segment9                 => p_pgp_segment9
3639   ,p_pgp_segment10                => p_pgp_segment10
3640   ,p_pgp_segment11                => p_pgp_segment11
3641   ,p_pgp_segment12                => p_pgp_segment12
3642   ,p_pgp_segment13                => p_pgp_segment13
3643   ,p_pgp_segment14                => p_pgp_segment14
3644   ,p_pgp_segment15                => p_pgp_segment15
3645   ,p_pgp_segment16                => p_pgp_segment16
3646   ,p_pgp_segment17                => p_pgp_segment17
3647   ,p_pgp_segment18                => p_pgp_segment18
3648   ,p_pgp_segment19                => p_pgp_segment19
3649   ,p_pgp_segment20                => p_pgp_segment20
3650   ,p_pgp_segment21                => p_pgp_segment21
3651   ,p_pgp_segment22                => p_pgp_segment22
3652   ,p_pgp_segment23                => p_pgp_segment23
3653   ,p_pgp_segment24                => p_pgp_segment24
3654   ,p_pgp_segment25                => p_pgp_segment25
3655   ,p_pgp_segment26                => p_pgp_segment26
3656   ,p_pgp_segment27                => p_pgp_segment27
3657   ,p_pgp_segment28                => p_pgp_segment28
3658   ,p_pgp_segment29                => p_pgp_segment29
3659   ,p_pgp_segment30                => p_pgp_segment30
3660   ,p_pgp_concat_segments          => p_pgp_concat_segments
3661   ,p_contract_id                  => p_contract_id
3662   ,p_establishment_id             => p_establishment_id
3663   ,p_collective_agreement_id      => p_collective_agreement_id
3664   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
3665   ,p_cag_segment1                 => p_cag_segment1
3666   ,p_cag_segment2                 => p_cag_segment2
3667   ,p_cag_segment3                 => p_cag_segment3
3668   ,p_cag_segment4                 => p_cag_segment4
3669   ,p_cag_segment5                 => p_cag_segment5
3670   ,p_cag_segment6                 => p_cag_segment6
3671   ,p_cag_segment7                 => p_cag_segment7
3672   ,p_cag_segment8                 => p_cag_segment8
3673   ,p_cag_segment9                 => p_cag_segment9
3674   ,p_cag_segment10                => p_cag_segment10
3675   ,p_cag_segment11                => p_cag_segment11
3676   ,p_cag_segment12                => p_cag_segment12
3677   ,p_cag_segment13                => p_cag_segment13
3678   ,p_cag_segment14                => p_cag_segment14
3679   ,p_cag_segment15                => p_cag_segment15
3680   ,p_cag_segment16                => p_cag_segment16
3681   ,p_cag_segment17                => p_cag_segment17
3682   ,p_cag_segment18                => p_cag_segment18
3683   ,p_cag_segment19                => p_cag_segment19
3684   ,p_cag_segment20                => p_cag_segment20
3685   ,p_cagr_grade_def_id            => l_cagr_grade_def_id -- bug 2359997
3686   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
3687   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
3688   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
3689   ,p_assignment_id                => l_assignment_id
3690   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
3691   ,p_people_group_id              => l_people_group_id
3692   ,p_object_version_number        => l_object_version_number
3693   ,p_effective_start_date         => l_effective_start_date
3694   ,p_effective_end_date           => l_effective_end_date
3695   ,p_assignment_sequence          => l_assignment_sequence
3696   ,p_comment_id                   => l_comment_id
3697   ,p_concatenated_segments        => l_concatenated_segments
3698   ,p_group_name                   => l_group_name
3699   ,p_other_manager_warning        => l_other_manager_warning
3700   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
3701    );
3702   --
3703   -- Set remaining output arguments
3704   --
3705   p_assignment_id           := l_assignment_id;
3706   p_soft_coding_keyflex_id  := l_soft_coding_keyflex_id;
3707   p_people_group_id         := l_people_group_id;
3708   p_cagr_grade_def_id       := l_cagr_grade_def_id;  -- bug 2359997 added
3709   p_object_version_number   := l_object_version_number;
3710   p_effective_start_date    := l_effective_start_date;
3711   p_effective_end_date      := l_effective_end_date;
3712   p_assignment_sequence     := l_assignment_sequence;
3713   p_comment_id              := l_comment_id;
3714   p_concatenated_segments   := l_concatenated_segments;
3715   p_group_name              := l_group_name;
3716   p_other_manager_warning   := l_other_manager_warning;
3717   --
3718  if g_debug then
3719   hr_utility.set_location(' Leaving:'||l_proc, 50);
3720  end if;
3721 end create_secondary_emp_asg;
3722 --
3723 -- ----------------------------------------------------------------------------
3724 -- |---------------------< create_secondary_emp_asg >-NEW2---------------------|
3725 -- ----------------------------------------------------------------------------
3726 --
3727 --   This is the new Overloded procedure to include p_hourly_salaried_warning
3728 --   parameter
3729 --
3730 procedure create_secondary_emp_asg
3731   (p_validate                     in     boolean
3732   ,p_effective_date               in     date
3733   ,p_person_id                    in     number
3734   ,p_organization_id              in     number
3735   ,p_grade_id                     in     number
3736   ,p_position_id                  in     number
3737   ,p_job_id                       in     number
3738   ,p_assignment_status_type_id    in     number
3739   ,p_payroll_id                   in     number
3740   ,p_location_id                  in     number
3741   ,p_supervisor_id                in     number
3742   ,p_special_ceiling_step_id      in     number
3743   ,p_pay_basis_id                 in     number
3744   ,p_assignment_number            in out nocopy varchar2
3745   ,p_change_reason                in     varchar2
3746   ,p_comments                     in     varchar2
3747   ,p_date_probation_end           in     date
3748   ,p_default_code_comb_id         in     number
3749   ,p_employment_category          in     varchar2
3750   ,p_frequency                    in     varchar2
3751   ,p_internal_address_line        in     varchar2
3752   ,p_manager_flag                 in     varchar2
3753   ,p_normal_hours                 in     number
3754   ,p_perf_review_period           in     number
3755   ,p_perf_review_period_frequency in     varchar2
3756   ,p_probation_period             in     number
3757   ,p_probation_unit               in     varchar2
3758   ,p_sal_review_period            in     number
3759   ,p_sal_review_period_frequency  in     varchar2
3760   ,p_set_of_books_id              in     number
3761   ,p_source_type                  in     varchar2
3762   ,p_time_normal_finish           in     varchar2
3763   ,p_time_normal_start            in     varchar2
3764   ,p_bargaining_unit_code         in     varchar2
3765   ,p_labour_union_member_flag     in     varchar2
3766   ,p_hourly_salaried_code         in     varchar2
3767   ,p_ass_attribute_category       in     varchar2
3768   ,p_ass_attribute1               in     varchar2
3769   ,p_ass_attribute2               in     varchar2
3770   ,p_ass_attribute3               in     varchar2
3771   ,p_ass_attribute4               in     varchar2
3772   ,p_ass_attribute5               in     varchar2
3773   ,p_ass_attribute6               in     varchar2
3774   ,p_ass_attribute7               in     varchar2
3775   ,p_ass_attribute8               in     varchar2
3776   ,p_ass_attribute9               in     varchar2
3777   ,p_ass_attribute10              in     varchar2
3778   ,p_ass_attribute11              in     varchar2
3779   ,p_ass_attribute12              in     varchar2
3780   ,p_ass_attribute13              in     varchar2
3781   ,p_ass_attribute14              in     varchar2
3782   ,p_ass_attribute15              in     varchar2
3783   ,p_ass_attribute16              in     varchar2
3784   ,p_ass_attribute17              in     varchar2
3785   ,p_ass_attribute18              in     varchar2
3786   ,p_ass_attribute19              in     varchar2
3787   ,p_ass_attribute20              in     varchar2
3788   ,p_ass_attribute21              in     varchar2
3789   ,p_ass_attribute22              in     varchar2
3790   ,p_ass_attribute23              in     varchar2
3791   ,p_ass_attribute24              in     varchar2
3792   ,p_ass_attribute25              in     varchar2
3793   ,p_ass_attribute26              in     varchar2
3794   ,p_ass_attribute27              in     varchar2
3795   ,p_ass_attribute28              in     varchar2
3796   ,p_ass_attribute29              in     varchar2
3797   ,p_ass_attribute30              in     varchar2
3798   ,p_title                        in     varchar2
3799   ,p_scl_segment1                 in     varchar2
3800   ,p_scl_segment2                 in     varchar2
3801   ,p_scl_segment3                 in     varchar2
3802   ,p_scl_segment4                 in     varchar2
3803   ,p_scl_segment5                 in     varchar2
3804   ,p_scl_segment6                 in     varchar2
3805   ,p_scl_segment7                 in     varchar2
3806   ,p_scl_segment8                 in     varchar2
3807   ,p_scl_segment9                 in     varchar2
3808   ,p_scl_segment10                in     varchar2
3809   ,p_scl_segment11                in     varchar2
3810   ,p_scl_segment12                in     varchar2
3811   ,p_scl_segment13                in     varchar2
3812   ,p_scl_segment14                in     varchar2
3813   ,p_scl_segment15                in     varchar2
3814   ,p_scl_segment16                in     varchar2
3815   ,p_scl_segment17                in     varchar2
3816   ,p_scl_segment18                in     varchar2
3817   ,p_scl_segment19                in     varchar2
3818   ,p_scl_segment20                in     varchar2
3819   ,p_scl_segment21                in     varchar2
3820   ,p_scl_segment22                in     varchar2
3821   ,p_scl_segment23                in     varchar2
3822   ,p_scl_segment24                in     varchar2
3823   ,p_scl_segment25                in     varchar2
3824   ,p_scl_segment26                in     varchar2
3825   ,p_scl_segment27                in     varchar2
3826   ,p_scl_segment28                in     varchar2
3827   ,p_scl_segment29                in     varchar2
3828   ,p_scl_segment30                in     varchar2
3829 -- Bug 944911
3830 -- Added scl_concat_segments and amended scl_concatenated_segments
3831 -- to be an out instead of in out
3832   ,p_scl_concat_segments    	  in 	 varchar2
3833   ,p_pgp_segment1                 in     varchar2
3834   ,p_pgp_segment2                 in     varchar2
3835   ,p_pgp_segment3                 in     varchar2
3836   ,p_pgp_segment4                 in     varchar2
3837   ,p_pgp_segment5                 in     varchar2
3838   ,p_pgp_segment6                 in     varchar2
3839   ,p_pgp_segment7                 in     varchar2
3840   ,p_pgp_segment8                 in     varchar2
3841   ,p_pgp_segment9                 in     varchar2
3842   ,p_pgp_segment10                in     varchar2
3843   ,p_pgp_segment11                in     varchar2
3844   ,p_pgp_segment12                in     varchar2
3845   ,p_pgp_segment13                in     varchar2
3846   ,p_pgp_segment14                in     varchar2
3847   ,p_pgp_segment15                in     varchar2
3848   ,p_pgp_segment16                in     varchar2
3849   ,p_pgp_segment17                in     varchar2
3850   ,p_pgp_segment18                in     varchar2
3851   ,p_pgp_segment19                in     varchar2
3852   ,p_pgp_segment20                in     varchar2
3853   ,p_pgp_segment21                in     varchar2
3854   ,p_pgp_segment22                in     varchar2
3855   ,p_pgp_segment23                in     varchar2
3856   ,p_pgp_segment24                in     varchar2
3857   ,p_pgp_segment25                in     varchar2
3858   ,p_pgp_segment26                in     varchar2
3859   ,p_pgp_segment27                in     varchar2
3860   ,p_pgp_segment28                in     varchar2
3861   ,p_pgp_segment29                in     varchar2
3862   ,p_pgp_segment30                in     varchar2
3863 -- Bug 944911
3864 -- Made p_group_name to be out param
3865 -- and add p_concat_segment to be IN
3866 -- in case of sec_asg alone made p_pgp_concat_segments as in param
3867   ,p_pgp_concat_segments	  in     varchar2
3868   ,p_contract_id                  in     number
3869   ,p_establishment_id             in     number
3870   ,p_collective_agreement_id      in     number
3871   ,p_cagr_id_flex_num             in     number
3872   ,p_cag_segment1                 in     varchar2
3873   ,p_cag_segment2                 in     varchar2
3874   ,p_cag_segment3                 in     varchar2
3875   ,p_cag_segment4                 in     varchar2
3876   ,p_cag_segment5                 in     varchar2
3877   ,p_cag_segment6                 in     varchar2
3878   ,p_cag_segment7                 in     varchar2
3879   ,p_cag_segment8                 in     varchar2
3880   ,p_cag_segment9                 in     varchar2
3881   ,p_cag_segment10                in     varchar2
3882   ,p_cag_segment11                in     varchar2
3883   ,p_cag_segment12                in     varchar2
3884   ,p_cag_segment13                in     varchar2
3885   ,p_cag_segment14                in     varchar2
3886   ,p_cag_segment15                in     varchar2
3887   ,p_cag_segment16                in     varchar2
3888   ,p_cag_segment17                in     varchar2
3889   ,p_cag_segment18                in     varchar2
3890   ,p_cag_segment19                in     varchar2
3891   ,p_cag_segment20                in     varchar2
3892   ,p_notice_period		  in	 number
3893   ,p_notice_period_uom		  in     varchar2
3894   ,p_employee_category		  in     varchar2
3895   ,p_work_at_home		  in	 varchar2
3896   ,p_job_post_source_name         in     varchar2
3897   ,p_grade_ladder_pgm_id          in     number
3898   ,p_supervisor_assignment_id     in     number
3899   ,p_group_name                      out nocopy varchar2
3900 -- Bug 944911
3901 -- Added scl_concat_segments and amended scl_concatenated_segments
3902 -- to be an out instead of in out
3903 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
3904 -- This has been done through out the procedures
3905   ,p_concatenated_segments           out nocopy varchar2
3906   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
3907   ,p_cagr_concatenated_segments      out nocopy varchar2
3908   ,p_assignment_id                   out nocopy number
3909   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
3910   ,p_people_group_id              in out nocopy number  -- bug 2359997
3911   ,p_object_version_number           out nocopy number
3912   ,p_effective_start_date            out nocopy date
3913   ,p_effective_end_date              out nocopy date
3914   ,p_assignment_sequence             out nocopy number
3915   ,p_comment_id                      out nocopy number
3916   ,p_other_manager_warning           out nocopy boolean
3917   ,p_hourly_salaried_warning         out nocopy boolean
3918   ) is
3919   --
3920   -- Declare cursors and local variables
3921   --
3922   -- Out variables
3923   --
3924   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
3925   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
3926   := p_soft_coding_keyflex_id;
3927   l_people_group_id         per_all_assignments_f.people_group_id%TYPE
3928   := p_people_group_id;
3929   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
3930   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
3931   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
3932   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
3933   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
3934   l_comment_id              per_all_assignments_f.comment_id%TYPE;
3935   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
3936   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
3937   l_group_name              pay_people_groups.group_name%TYPE;
3938   l_old_group_name          pay_people_groups.group_name%TYPE;
3939   l_other_manager_warning   boolean;
3940   l_hourly_salaried_warning boolean;
3941   l_effective_date          date;
3942   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
3943   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
3944   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
3945   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
3946   --
3947   l_business_group_id       per_business_groups.business_group_id%TYPE;
3948   l_legislation_code        per_business_groups.legislation_code%TYPE;
3949   l_period_of_service_id    per_all_assignments_f.period_of_service_id%TYPE;
3950   l_proc                    varchar2(72) := g_package||
3951   'create_secondary_emp_asg';
3952   l_session_id              number;
3953   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
3954   := p_cagr_grade_def_id;
3955   l_cagr_concatenated_segments varchar2(2000);
3956 
3957   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
3958 --
3959 begin
3960 --
3961  if g_debug then
3962   hr_utility.set_location('Entering:'|| l_proc, 5);
3963  end if;
3964   --
3965   l_assignment_number := p_assignment_number;
3966   --
3967   -- Call the new code
3968   --
3969   hr_assignment_api.create_secondary_emp_asg(
3970    p_validate                     => p_validate
3971   ,p_effective_date               => p_effective_date
3972   ,p_person_id                    => p_person_id
3973   ,p_organization_id              => p_organization_id
3974   ,p_grade_id                     => p_grade_id
3975   ,p_position_id                  => p_position_id
3976   ,p_job_id                       => p_job_id
3977   ,p_assignment_status_type_id    => p_assignment_status_type_id
3978   ,p_payroll_id                   => p_payroll_id
3979   ,p_location_id                  => p_location_id
3980   ,p_supervisor_id                => p_supervisor_id
3981   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
3982   ,p_pay_basis_id                 => p_pay_basis_id
3983   ,p_assignment_number            => l_assignment_number
3984   ,p_change_reason                => p_change_reason
3985   ,p_comments                     => p_comments
3986   ,p_date_probation_end           => p_date_probation_end
3987   ,p_default_code_comb_id         => p_default_code_comb_id
3988   ,p_employment_category          => p_employment_category
3989   ,p_frequency                    => p_frequency
3990   ,p_internal_address_line        => p_internal_address_line
3991   ,p_manager_flag                 => p_manager_flag
3992   ,p_normal_hours                 => p_normal_hours
3993   ,p_perf_review_period           => p_perf_review_period
3994   ,p_perf_review_period_frequency => p_perf_review_period_frequency
3995   ,p_probation_period             => p_probation_period
3996   ,p_probation_unit               => p_probation_unit
3997   ,p_sal_review_period            => p_sal_review_period
3998   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
3999   ,p_set_of_books_id              => p_set_of_books_id
4000   ,p_source_type                  => p_source_type
4001   ,p_time_normal_finish           => p_time_normal_finish
4002   ,p_time_normal_start            => p_time_normal_start
4003   ,p_bargaining_unit_code         => p_bargaining_unit_code
4004   ,p_labour_union_member_flag     => p_labour_union_member_flag
4005   ,p_hourly_salaried_code         => p_hourly_salaried_code
4006   ,p_notice_period                => p_notice_period
4007   ,p_notice_period_uom            => p_notice_period_uom
4008   ,p_employee_category            => p_employee_category
4009   ,p_work_at_home                 => p_work_at_home
4010   ,p_job_post_source_name         => p_job_post_source_name
4011   ,p_ass_attribute_category       => p_ass_attribute_category
4012   ,p_ass_attribute1               => p_ass_attribute1
4013   ,p_ass_attribute2               => p_ass_attribute2
4014   ,p_ass_attribute3               => p_ass_attribute3
4015   ,p_ass_attribute4               => p_ass_attribute4
4016   ,p_ass_attribute5               => p_ass_attribute5
4017   ,p_ass_attribute6               => p_ass_attribute6
4018   ,p_ass_attribute7               => p_ass_attribute7
4019   ,p_ass_attribute8               => p_ass_attribute8
4020   ,p_ass_attribute9               => p_ass_attribute9
4021   ,p_ass_attribute10              => p_ass_attribute10
4022   ,p_ass_attribute11              => p_ass_attribute11
4023   ,p_ass_attribute12              => p_ass_attribute12
4024   ,p_ass_attribute13              => p_ass_attribute13
4025   ,p_ass_attribute14              => p_ass_attribute14
4026   ,p_ass_attribute15              => p_ass_attribute15
4027   ,p_ass_attribute16              => p_ass_attribute16
4028   ,p_ass_attribute17              => p_ass_attribute17
4029   ,p_ass_attribute18              => p_ass_attribute18
4030   ,p_ass_attribute19              => p_ass_attribute19
4031   ,p_ass_attribute20              => p_ass_attribute20
4032   ,p_ass_attribute21              => p_ass_attribute21
4033   ,p_ass_attribute22              => p_ass_attribute22
4034   ,p_ass_attribute23              => p_ass_attribute23
4035   ,p_ass_attribute24              => p_ass_attribute24
4036   ,p_ass_attribute25              => p_ass_attribute25
4037   ,p_ass_attribute26              => p_ass_attribute26
4038   ,p_ass_attribute27              => p_ass_attribute27
4039   ,p_ass_attribute28              => p_ass_attribute28
4040   ,p_ass_attribute29              => p_ass_attribute29
4041   ,p_ass_attribute30              => p_ass_attribute30
4042   ,p_title                        => p_title
4043   ,p_scl_segment1                 => p_scl_segment1
4044   ,p_scl_segment2                 => p_scl_segment2
4045   ,p_scl_segment3                 => p_scl_segment3
4046   ,p_scl_segment4                 => p_scl_segment4
4047   ,p_scl_segment5                 => p_scl_segment5
4048   ,p_scl_segment6                 => p_scl_segment6
4049   ,p_scl_segment7                 => p_scl_segment7
4050   ,p_scl_segment8                 => p_scl_segment8
4051   ,p_scl_segment9                 => p_scl_segment9
4052   ,p_scl_segment10                => p_scl_segment10
4053   ,p_scl_segment11                => p_scl_segment11
4054   ,p_scl_segment12                => p_scl_segment12
4055   ,p_scl_segment13                => p_scl_segment13
4056   ,p_scl_segment14                => p_scl_segment14
4057   ,p_scl_segment15                => p_scl_segment15
4058   ,p_scl_segment16                => p_scl_segment16
4059   ,p_scl_segment17                => p_scl_segment17
4060   ,p_scl_segment18                => p_scl_segment18
4061   ,p_scl_segment19                => p_scl_segment19
4062   ,p_scl_segment20                => p_scl_segment20
4063   ,p_scl_segment21                => p_scl_segment21
4064   ,p_scl_segment22                => p_scl_segment22
4065   ,p_scl_segment23                => p_scl_segment23
4066   ,p_scl_segment24                => p_scl_segment24
4067   ,p_scl_segment25                => p_scl_segment25
4068   ,p_scl_segment26                => p_scl_segment26
4069   ,p_scl_segment27                => p_scl_segment27
4070   ,p_scl_segment28                => p_scl_segment28
4071   ,p_scl_segment29                => p_scl_segment29
4072   ,p_scl_segment30                => p_scl_segment30
4073   ,p_scl_concat_segments          => p_scl_concat_segments
4074   ,p_pgp_segment1                 => p_pgp_segment1
4075   ,p_pgp_segment2                 => p_pgp_segment2
4076   ,p_pgp_segment3                 => p_pgp_segment3
4077   ,p_pgp_segment4                 => p_pgp_segment4
4078   ,p_pgp_segment5                 => p_pgp_segment5
4079   ,p_pgp_segment6                 => p_pgp_segment6
4080   ,p_pgp_segment7                 => p_pgp_segment7
4081   ,p_pgp_segment8                 => p_pgp_segment8
4082   ,p_pgp_segment9                 => p_pgp_segment9
4083   ,p_pgp_segment10                => p_pgp_segment10
4084   ,p_pgp_segment11                => p_pgp_segment11
4085   ,p_pgp_segment12                => p_pgp_segment12
4086   ,p_pgp_segment13                => p_pgp_segment13
4087   ,p_pgp_segment14                => p_pgp_segment14
4088   ,p_pgp_segment15                => p_pgp_segment15
4089   ,p_pgp_segment16                => p_pgp_segment16
4090   ,p_pgp_segment17                => p_pgp_segment17
4091   ,p_pgp_segment18                => p_pgp_segment18
4092   ,p_pgp_segment19                => p_pgp_segment19
4093   ,p_pgp_segment20                => p_pgp_segment20
4094   ,p_pgp_segment21                => p_pgp_segment21
4095   ,p_pgp_segment22                => p_pgp_segment22
4096   ,p_pgp_segment23                => p_pgp_segment23
4097   ,p_pgp_segment24                => p_pgp_segment24
4098   ,p_pgp_segment25                => p_pgp_segment25
4099   ,p_pgp_segment26                => p_pgp_segment26
4100   ,p_pgp_segment27                => p_pgp_segment27
4101   ,p_pgp_segment28                => p_pgp_segment28
4102   ,p_pgp_segment29                => p_pgp_segment29
4103   ,p_pgp_segment30                => p_pgp_segment30
4104   ,p_pgp_concat_segments          => p_pgp_concat_segments
4105   ,p_contract_id                  => p_contract_id
4106   ,p_establishment_id             => p_establishment_id
4107   ,p_collective_agreement_id      => p_collective_agreement_id
4108   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
4109   ,p_cag_segment1                 => p_cag_segment1
4110   ,p_cag_segment2                 => p_cag_segment2
4111   ,p_cag_segment3                 => p_cag_segment3
4112   ,p_cag_segment4                 => p_cag_segment4
4113   ,p_cag_segment5                 => p_cag_segment5
4114   ,p_cag_segment6                 => p_cag_segment6
4115   ,p_cag_segment7                 => p_cag_segment7
4116   ,p_cag_segment8                 => p_cag_segment8
4117   ,p_cag_segment9                 => p_cag_segment9
4118   ,p_cag_segment10                => p_cag_segment10
4119   ,p_cag_segment11                => p_cag_segment11
4120   ,p_cag_segment12                => p_cag_segment12
4121   ,p_cag_segment13                => p_cag_segment13
4122   ,p_cag_segment14                => p_cag_segment14
4123   ,p_cag_segment15                => p_cag_segment15
4124   ,p_cag_segment16                => p_cag_segment16
4125   ,p_cag_segment17                => p_cag_segment17
4126   ,p_cag_segment18                => p_cag_segment18
4127   ,p_cag_segment19                => p_cag_segment19
4128   ,p_cag_segment20                => p_cag_segment20
4129   ,p_cagr_grade_def_id            => l_cagr_grade_def_id -- bug 2359997
4130   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
4131   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
4132   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
4133   ,p_assignment_id                => l_assignment_id
4134   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
4135   ,p_people_group_id              => l_people_group_id
4136   ,p_object_version_number        => l_object_version_number
4137   ,p_effective_start_date         => l_effective_start_date
4138   ,p_effective_end_date           => l_effective_end_date
4139   ,p_assignment_sequence          => l_assignment_sequence
4140   ,p_comment_id                   => l_comment_id
4141   ,p_concatenated_segments        => l_concatenated_segments
4142   ,p_group_name                   => l_group_name
4143   ,p_other_manager_warning        => l_other_manager_warning
4144   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
4145   ,p_gsp_post_process_warning     => l_gsp_post_process_warning -- bug 2999562
4146    );
4147   --
4148   -- Set remaining output arguments
4149   --
4150   p_assignment_id               := l_assignment_id;
4151   p_soft_coding_keyflex_id      := l_soft_coding_keyflex_id;
4152   p_people_group_id             := l_people_group_id;
4153   p_object_version_number       := l_object_version_number;
4154   p_effective_start_date        := l_effective_start_date;
4155   p_effective_end_date          := l_effective_end_date;
4156   p_assignment_sequence         := l_assignment_sequence;
4157   p_comment_id                  := l_comment_id;
4158   p_concatenated_segments       := l_concatenated_segments;
4159   p_group_name                  := l_group_name;
4160   p_other_manager_warning       := l_other_manager_warning;
4161   p_cagr_grade_def_id           := l_cagr_grade_def_id;
4162   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
4163   p_hourly_salaried_warning     := l_hourly_salaried_warning;
4164   --
4165   --
4166  if g_debug then
4167   hr_utility.set_location(' Leaving:'||l_proc, 50);
4168  end if;
4169 end create_secondary_emp_asg;
4170 --
4171 -- ----------------------------------------------------------------------------
4172 -- |---------------------< create_secondary_emp_asg >-NEW3---------------------|
4173 -- ----------------------------------------------------------------------------
4174 --
4175 --   This is the new Overloded procedure to include p_post_process_warning_msg
4176 --   out parameter
4177 --
4178 procedure create_secondary_emp_asg
4179   (p_validate                     in     boolean
4180   ,p_effective_date               in     date
4181   ,p_person_id                    in     number
4182   ,p_organization_id              in     number
4183   ,p_grade_id                     in     number
4184   ,p_position_id                  in     number
4185   ,p_job_id                       in     number
4186   ,p_assignment_status_type_id    in     number
4187   ,p_payroll_id                   in     number
4188   ,p_location_id                  in     number
4189   ,p_supervisor_id                in     number
4190   ,p_special_ceiling_step_id      in     number
4191   ,p_pay_basis_id                 in     number
4192   ,p_assignment_number            in out nocopy varchar2
4193   ,p_change_reason                in     varchar2
4194   ,p_comments                     in     varchar2
4195   ,p_date_probation_end           in     date
4196   ,p_default_code_comb_id         in     number
4197   ,p_employment_category          in     varchar2
4198   ,p_frequency                    in     varchar2
4199   ,p_internal_address_line        in     varchar2
4200   ,p_manager_flag                 in     varchar2
4201   ,p_normal_hours                 in     number
4202   ,p_perf_review_period           in     number
4203   ,p_perf_review_period_frequency in     varchar2
4204   ,p_probation_period             in     number
4205   ,p_probation_unit               in     varchar2
4206   ,p_sal_review_period            in     number
4207   ,p_sal_review_period_frequency  in     varchar2
4208   ,p_set_of_books_id              in     number
4209   ,p_source_type                  in     varchar2
4210   ,p_time_normal_finish           in     varchar2
4211   ,p_time_normal_start            in     varchar2
4212   ,p_bargaining_unit_code         in     varchar2
4213   ,p_labour_union_member_flag     in     varchar2
4214   ,p_hourly_salaried_code         in     varchar2
4215   ,p_ass_attribute_category       in     varchar2
4216   ,p_ass_attribute1               in     varchar2
4217   ,p_ass_attribute2               in     varchar2
4218   ,p_ass_attribute3               in     varchar2
4219   ,p_ass_attribute4               in     varchar2
4220   ,p_ass_attribute5               in     varchar2
4221   ,p_ass_attribute6               in     varchar2
4222   ,p_ass_attribute7               in     varchar2
4223   ,p_ass_attribute8               in     varchar2
4224   ,p_ass_attribute9               in     varchar2
4225   ,p_ass_attribute10              in     varchar2
4226   ,p_ass_attribute11              in     varchar2
4227   ,p_ass_attribute12              in     varchar2
4228   ,p_ass_attribute13              in     varchar2
4229   ,p_ass_attribute14              in     varchar2
4230   ,p_ass_attribute15              in     varchar2
4231   ,p_ass_attribute16              in     varchar2
4232   ,p_ass_attribute17              in     varchar2
4233   ,p_ass_attribute18              in     varchar2
4234   ,p_ass_attribute19              in     varchar2
4235   ,p_ass_attribute20              in     varchar2
4236   ,p_ass_attribute21              in     varchar2
4237   ,p_ass_attribute22              in     varchar2
4238   ,p_ass_attribute23              in     varchar2
4239   ,p_ass_attribute24              in     varchar2
4240   ,p_ass_attribute25              in     varchar2
4241   ,p_ass_attribute26              in     varchar2
4242   ,p_ass_attribute27              in     varchar2
4243   ,p_ass_attribute28              in     varchar2
4244   ,p_ass_attribute29              in     varchar2
4245   ,p_ass_attribute30              in     varchar2
4246   ,p_title                        in     varchar2
4247   ,p_scl_segment1                 in     varchar2
4248   ,p_scl_segment2                 in     varchar2
4249   ,p_scl_segment3                 in     varchar2
4250   ,p_scl_segment4                 in     varchar2
4251   ,p_scl_segment5                 in     varchar2
4252   ,p_scl_segment6                 in     varchar2
4253   ,p_scl_segment7                 in     varchar2
4254   ,p_scl_segment8                 in     varchar2
4255   ,p_scl_segment9                 in     varchar2
4256   ,p_scl_segment10                in     varchar2
4257   ,p_scl_segment11                in     varchar2
4258   ,p_scl_segment12                in     varchar2
4259   ,p_scl_segment13                in     varchar2
4260   ,p_scl_segment14                in     varchar2
4261   ,p_scl_segment15                in     varchar2
4262   ,p_scl_segment16                in     varchar2
4263   ,p_scl_segment17                in     varchar2
4264   ,p_scl_segment18                in     varchar2
4265   ,p_scl_segment19                in     varchar2
4266   ,p_scl_segment20                in     varchar2
4267   ,p_scl_segment21                in     varchar2
4268   ,p_scl_segment22                in     varchar2
4269   ,p_scl_segment23                in     varchar2
4270   ,p_scl_segment24                in     varchar2
4271   ,p_scl_segment25                in     varchar2
4272   ,p_scl_segment26                in     varchar2
4273   ,p_scl_segment27                in     varchar2
4274   ,p_scl_segment28                in     varchar2
4275   ,p_scl_segment29                in     varchar2
4276   ,p_scl_segment30                in     varchar2
4277 -- Bug 944911
4278 -- Added scl_concat_segments and amended scl_concatenated_segments
4279 -- to be an out instead of in out
4280   ,p_scl_concat_segments    	  in 	 varchar2
4281   ,p_pgp_segment1                 in     varchar2
4282   ,p_pgp_segment2                 in     varchar2
4283   ,p_pgp_segment3                 in     varchar2
4284   ,p_pgp_segment4                 in     varchar2
4285   ,p_pgp_segment5                 in     varchar2
4286   ,p_pgp_segment6                 in     varchar2
4287   ,p_pgp_segment7                 in     varchar2
4288   ,p_pgp_segment8                 in     varchar2
4289   ,p_pgp_segment9                 in     varchar2
4290   ,p_pgp_segment10                in     varchar2
4291   ,p_pgp_segment11                in     varchar2
4292   ,p_pgp_segment12                in     varchar2
4293   ,p_pgp_segment13                in     varchar2
4294   ,p_pgp_segment14                in     varchar2
4295   ,p_pgp_segment15                in     varchar2
4296   ,p_pgp_segment16                in     varchar2
4297   ,p_pgp_segment17                in     varchar2
4298   ,p_pgp_segment18                in     varchar2
4299   ,p_pgp_segment19                in     varchar2
4300   ,p_pgp_segment20                in     varchar2
4301   ,p_pgp_segment21                in     varchar2
4302   ,p_pgp_segment22                in     varchar2
4303   ,p_pgp_segment23                in     varchar2
4304   ,p_pgp_segment24                in     varchar2
4305   ,p_pgp_segment25                in     varchar2
4306   ,p_pgp_segment26                in     varchar2
4307   ,p_pgp_segment27                in     varchar2
4308   ,p_pgp_segment28                in     varchar2
4309   ,p_pgp_segment29                in     varchar2
4310   ,p_pgp_segment30                in     varchar2
4311 -- Bug 944911
4312 -- Made p_group_name to be out param
4313 -- and add p_concat_segment to be IN
4314 -- in case of sec_asg alone made p_pgp_concat_segments as in param
4315   ,p_pgp_concat_segments	  in     varchar2
4316   ,p_contract_id                  in     number
4317   ,p_establishment_id             in     number
4318   ,p_collective_agreement_id      in     number
4319   ,p_cagr_id_flex_num             in     number
4320   ,p_cag_segment1                 in     varchar2
4321   ,p_cag_segment2                 in     varchar2
4322   ,p_cag_segment3                 in     varchar2
4323   ,p_cag_segment4                 in     varchar2
4324   ,p_cag_segment5                 in     varchar2
4325   ,p_cag_segment6                 in     varchar2
4326   ,p_cag_segment7                 in     varchar2
4327   ,p_cag_segment8                 in     varchar2
4328   ,p_cag_segment9                 in     varchar2
4329   ,p_cag_segment10                in     varchar2
4330   ,p_cag_segment11                in     varchar2
4331   ,p_cag_segment12                in     varchar2
4332   ,p_cag_segment13                in     varchar2
4333   ,p_cag_segment14                in     varchar2
4334   ,p_cag_segment15                in     varchar2
4335   ,p_cag_segment16                in     varchar2
4336   ,p_cag_segment17                in     varchar2
4337   ,p_cag_segment18                in     varchar2
4338   ,p_cag_segment19                in     varchar2
4339   ,p_cag_segment20                in     varchar2
4340   ,p_notice_period		  in	 number
4341   ,p_notice_period_uom		  in     varchar2
4342   ,p_employee_category		  in     varchar2
4343   ,p_work_at_home		  in	 varchar2
4344   ,p_job_post_source_name         in     varchar2
4345   ,p_grade_ladder_pgm_id          in     number
4346   ,p_supervisor_assignment_id     in     number
4347   ,p_group_name                      out nocopy varchar2
4348 -- Bug 944911
4349 -- Added scl_concat_segments and amended scl_concatenated_segments
4350 -- to be an out instead of in out
4351 -- As advised renaming p_scl_concatenated_segments to p_concatenated_segments
4352 -- This has been done through out the procedures
4353   ,p_concatenated_segments           out nocopy varchar2
4354   ,p_cagr_grade_def_id            in out nocopy number  -- bug 2359997
4355   ,p_cagr_concatenated_segments      out nocopy varchar2
4356   ,p_assignment_id                   out nocopy number
4357   ,p_soft_coding_keyflex_id       in out nocopy number  -- bug 2359997
4358   ,p_people_group_id              in out nocopy number  -- bug 2359997
4359   ,p_object_version_number           out nocopy number
4360   ,p_effective_start_date            out nocopy date
4361   ,p_effective_end_date              out nocopy date
4362   ,p_assignment_sequence             out nocopy number
4363   ,p_comment_id                      out nocopy number
4364   ,p_other_manager_warning           out nocopy boolean
4365   ,p_hourly_salaried_warning         out nocopy boolean
4366   ,p_gsp_post_process_warning        out nocopy varchar2
4367   ) is
4368   --
4369   -- Declare cursors and local variables
4370   --
4371   -- Out variables
4372   --
4373   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
4374   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
4375   := p_soft_coding_keyflex_id;
4376   l_people_group_id         per_all_assignments_f.people_group_id%TYPE
4377   := p_people_group_id;
4378   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
4379   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
4380   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
4381   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
4382   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
4383   l_comment_id              per_all_assignments_f.comment_id%TYPE;
4384   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4385   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
4386   l_group_name              pay_people_groups.group_name%TYPE;
4387   l_old_group_name          pay_people_groups.group_name%TYPE;
4388   l_other_manager_warning   boolean;
4389   l_hourly_salaried_warning boolean;
4390   l_effective_date          date;
4391   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
4392   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
4393   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4394   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
4395   --
4396   l_business_group_id       per_business_groups.business_group_id%TYPE;
4397   l_legislation_code        per_business_groups.legislation_code%TYPE;
4398   l_period_of_service_id    per_all_assignments_f.period_of_service_id%TYPE;
4399   l_proc                    varchar2(72) := g_package||
4400   'create_secondary_emp_asg';
4401   l_session_id              number;
4402   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
4403   := p_cagr_grade_def_id;
4404   l_cagr_concatenated_segments varchar2(2000);
4405 
4406   l_gsp_post_process_warning   varchar2(2000); -- bug 2999562
4407   --
4408   -- bug 2359997 new variables to indicate whether key flex id parameters
4409   -- enter the program with a value.
4410   --
4411   l_pgp_null_ind               number(1) := 0;
4412   l_scl_null_ind               number(1) := 0;
4413   l_cag_null_ind               number(1) := 0;
4414   --
4415   -- Bug 2359997 new variables for derived values where key flex id is known.
4416   --
4417   l_scl_segment1               varchar2(60) := p_scl_segment1;
4418   l_scl_segment2               varchar2(60) := p_scl_segment2;
4419   l_scl_segment3               varchar2(60) := p_scl_segment3;
4420   l_scl_segment4               varchar2(60) := p_scl_segment4;
4421   l_scl_segment5               varchar2(60) := p_scl_segment5;
4422   l_scl_segment6               varchar2(60) := p_scl_segment6;
4423   l_scl_segment7               varchar2(60) := p_scl_segment7;
4424   l_scl_segment8               varchar2(60) := p_scl_segment8;
4425   l_scl_segment9               varchar2(60) := p_scl_segment9;
4426   l_scl_segment10              varchar2(60) := p_scl_segment10;
4427   l_scl_segment11              varchar2(60) := p_scl_segment11;
4428   l_scl_segment12              varchar2(60) := p_scl_segment12;
4429   l_scl_segment13              varchar2(60) := p_scl_segment13;
4430   l_scl_segment14              varchar2(60) := p_scl_segment14;
4431   l_scl_segment15              varchar2(60) := p_scl_segment15;
4432   l_scl_segment16              varchar2(60) := p_scl_segment16;
4433   l_scl_segment17              varchar2(60) := p_scl_segment17;
4434   l_scl_segment18              varchar2(60) := p_scl_segment18;
4435   l_scl_segment19              varchar2(60) := p_scl_segment19;
4436   l_scl_segment20              varchar2(60) := p_scl_segment20;
4437   l_scl_segment21              varchar2(60) := p_scl_segment21;
4438   l_scl_segment22              varchar2(60) := p_scl_segment22;
4439   l_scl_segment23              varchar2(60) := p_scl_segment23;
4440   l_scl_segment24              varchar2(60) := p_scl_segment24;
4441   l_scl_segment25              varchar2(60) := p_scl_segment25;
4442   l_scl_segment26              varchar2(60) := p_scl_segment26;
4443   l_scl_segment27              varchar2(60) := p_scl_segment27;
4444   l_scl_segment28              varchar2(60) := p_scl_segment28;
4445   l_scl_segment29              varchar2(60) := p_scl_segment29;
4446   l_scl_segment30              varchar2(60) := p_scl_segment30;
4447   --
4448   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
4449   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
4450   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
4451   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
4452   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
4453   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
4454   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
4455   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
4456   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
4457   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
4458   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
4459   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
4460   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
4461   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
4462   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
4463   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
4464   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
4465   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
4466   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
4467   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
4468   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
4469   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
4470   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
4471   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
4472   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
4473   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
4474   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
4475   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
4476   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
4477   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
4478   --
4479   l_cag_segment1               varchar2(60) := p_cag_segment1;
4480   l_cag_segment2               varchar2(60) := p_cag_segment2;
4481   l_cag_segment3               varchar2(60) := p_cag_segment3;
4482   l_cag_segment4               varchar2(60) := p_cag_segment4;
4483   l_cag_segment5               varchar2(60) := p_cag_segment5;
4484   l_cag_segment6               varchar2(60) := p_cag_segment6;
4485   l_cag_segment7               varchar2(60) := p_cag_segment7;
4486   l_cag_segment8               varchar2(60) := p_cag_segment8;
4487   l_cag_segment9               varchar2(60) := p_cag_segment9;
4488   l_cag_segment10              varchar2(60) := p_cag_segment10;
4489   l_cag_segment11              varchar2(60) := p_cag_segment11;
4490   l_cag_segment12              varchar2(60) := p_cag_segment12;
4491   l_cag_segment13              varchar2(60) := p_cag_segment13;
4492   l_cag_segment14              varchar2(60) := p_cag_segment14;
4493   l_cag_segment15              varchar2(60) := p_cag_segment15;
4494   l_cag_segment16              varchar2(60) := p_cag_segment16;
4495   l_cag_segment17              varchar2(60) := p_cag_segment17;
4496   l_cag_segment18              varchar2(60) := p_cag_segment18;
4497   l_cag_segment19              varchar2(60) := p_cag_segment19;
4498   l_cag_segment20              varchar2(60) := p_cag_segment20;
4499   --
4500   lv_assignment_number         varchar2(2000) := p_assignment_number ;
4501   lv_cagr_grade_def_id         number         := p_cagr_grade_def_id ;
4502   lv_soft_coding_keyflex_id    number         := p_soft_coding_keyflex_id ;
4503   lv_people_group_id           number         := p_people_group_id ;
4504 
4505   --
4506   cursor csr_get_derived_details is
4507     select bus.business_group_id
4508          , bus.legislation_code
4509       from per_all_people_f    per
4510          , per_business_groups_perf bus
4511      where per.person_id         = p_person_id
4512      and   l_effective_date      between per.effective_start_date
4513                                  and     per.effective_end_date
4514      and   bus.business_group_id = per.business_group_id;
4515   --
4516   cursor csr_get_period_of_service is
4517     select asg.period_of_service_id
4518       from per_all_assignments_f asg
4519      where asg.person_id    = p_person_id
4520      and   l_effective_date between asg.effective_start_date
4521                             and     asg.effective_end_date
4522      and   asg.primary_flag = 'Y'
4523   --
4524   -- Start of Bug: 2288629.
4525      and   asg.assignment_type = 'E';
4526   -- End  of  Bug: 2288629.
4527   --
4528   --
4529   -- the cursor csr_grp_idsel selects the valid id_flex_num
4530   -- (grp keyflex) for the specified business group
4531   --
4532   cursor csr_grp_idsel is
4533     select people_group_structure
4534       from per_business_groups_perf
4535       where business_group_id = l_business_group_id;
4536   --
4537   --
4538   -- the cursor csr_scl_idsel selects the valid id_flex_num
4539   -- (scl keyflex) for the specified business group
4540   --
4541   cursor csr_scl_idsel is
4542     select plr.rule_mode                       id_flex_num
4543     from   pay_legislation_rules               plr
4544     where  plr.legislation_code                = l_legislation_code
4545     and    plr.rule_type                       = 'S'
4546     and    exists
4547           (select 1
4548            from   fnd_segment_attribute_values fsav
4549            where  fsav.id_flex_num             = plr.rule_mode
4550            and    fsav.application_id          = 800
4551            and    fsav.id_flex_code            = 'SCL'
4552            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
4553            and    fsav.attribute_value         = 'Y')
4554     and    exists
4555           (select 1
4556            from   pay_legislation_rules        plr2
4557            where  plr2.legislation_code        = l_legislation_code
4558            and    plr2.rule_type               = 'SDL'
4559            and    plr2.rule_mode               = 'A') ;
4560   --
4561   --
4562   -- bug 2359997 get pay_people_group segment values where
4563   -- people_group_id is known
4564   --
4565   cursor c_pgp_segments is
4566      select segment1,
4567             segment2,
4568             segment3,
4569             segment4,
4570             segment5,
4571             segment6,
4572             segment7,
4573             segment8,
4574             segment9,
4575             segment10,
4576             segment11,
4577             segment12,
4578             segment13,
4579             segment14,
4580             segment15,
4581             segment16,
4582             segment17,
4583             segment18,
4584             segment19,
4585             segment20,
4586             segment21,
4587             segment22,
4588             segment23,
4589             segment24,
4590             segment25,
4591             segment26,
4592             segment27,
4593             segment28,
4594             segment29,
4595             segment30
4596      from   pay_people_groups
4597      where  people_group_id = l_people_group_id;
4598   --
4599   -- bug 2359997 get hr_soft_coding_keyflex segment values where
4600   -- soft_coding_keyflex_id is known
4601   --
4602   cursor c_scl_segments is
4603      select segment1,
4604             segment2,
4605             segment3,
4606             segment4,
4607             segment5,
4608             segment6,
4609             segment7,
4610             segment8,
4611             segment9,
4612             segment10,
4613             segment11,
4614             segment12,
4615             segment13,
4616             segment14,
4617             segment15,
4618             segment16,
4619             segment17,
4620             segment18,
4621             segment19,
4622             segment20,
4623             segment21,
4624             segment22,
4625             segment23,
4626             segment24,
4627             segment25,
4628             segment26,
4629             segment27,
4630             segment28,
4631             segment29,
4632             segment30
4633      from   hr_soft_coding_keyflex
4634      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
4635   --
4636   -- bug 2359997 get per_cagr_grades_def segment values where
4637   -- cagr_grade_def_id is known
4638   --
4639   cursor c_cag_segments is
4640      select segment1,
4641             segment2,
4642             segment3,
4643             segment4,
4644             segment5,
4645             segment6,
4646             segment7,
4647             segment8,
4648             segment9,
4649             segment10,
4650             segment11,
4651             segment12,
4652             segment13,
4653             segment14,
4654             segment15,
4655             segment16,
4656             segment17,
4657             segment18,
4658             segment19,
4659             segment20
4660      from   per_cagr_grades_def
4661      where  cagr_grade_def_id = l_cagr_grade_def_id;
4662 --
4663 begin
4664 --
4665  if g_debug then
4666   hr_utility.set_location('Entering:'|| l_proc, 5);
4667  end if;
4668   --
4669   -- Issue a savepoint.
4670   --
4671   -- Truncate the parameter p_effective_date and p_date_probation_end
4672   -- into local variables
4673   --
4674   l_effective_date := trunc(p_effective_date);
4675   l_date_probation_end := trunc(p_date_probation_end);
4676   --
4677   -- Bug 944911
4678   -- Amended p_scl_concatenated_segments to p_scl_concat_segments
4679   -- to be an out instead of in out
4680   l_old_scl_conc_segments:=p_scl_concat_segments;
4681   -- Bug 944911
4682   -- Made p_group_name to be out param
4683   -- and add p_concat_segment to be IN
4684   -- in case of sec_asg alone made p_pgp_concat_segments as in param
4685   -- Replaced p_group_name by p_pgp_concat_segments
4686   l_old_group_name:=p_pgp_concat_segments;
4687   --
4688   -- Bug 2359997 - if p_people_group_id enters with
4689   -- a value then get segment values from pay_people_groups.
4690   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
4691   -- per_cagr_grades_def
4692   --
4693   --
4694  if g_debug then
4695   hr_utility.set_location(l_proc, 20);
4696  end if;
4697   --
4698   if l_people_group_id is not null
4699   then
4700      l_pgp_null_ind := 1;
4701      --
4702      open c_pgp_segments;
4703        fetch c_pgp_segments into l_pgp_segment1,
4704                                  l_pgp_segment2,
4705                                  l_pgp_segment3,
4706                                  l_pgp_segment4,
4707                                  l_pgp_segment5,
4708                                  l_pgp_segment6,
4709                                  l_pgp_segment7,
4710                                  l_pgp_segment8,
4711                                  l_pgp_segment9,
4712                                  l_pgp_segment10,
4713                                  l_pgp_segment11,
4714                                  l_pgp_segment12,
4715                                  l_pgp_segment13,
4716                                  l_pgp_segment14,
4717                                  l_pgp_segment15,
4718                                  l_pgp_segment16,
4719                                  l_pgp_segment17,
4720                                  l_pgp_segment18,
4721                                  l_pgp_segment19,
4722                                  l_pgp_segment20,
4723                                  l_pgp_segment21,
4724                                  l_pgp_segment22,
4725                                  l_pgp_segment23,
4726                                  l_pgp_segment24,
4727                                  l_pgp_segment25,
4728                                  l_pgp_segment26,
4729                                  l_pgp_segment27,
4730                                  l_pgp_segment28,
4731                                  l_pgp_segment29,
4732                                  l_pgp_segment30;
4733      close c_pgp_segments;
4734   else
4735      l_pgp_null_ind := 0;
4736   end if;
4737   --
4738   --  use cursor c_scl_segments to bring back segment values if
4739   --  l_soft_coding_keyflex has a value.
4740   if l_soft_coding_keyflex_id is not null
4741   then
4742      l_scl_null_ind := 1;
4743      open c_scl_segments;
4744        fetch c_scl_segments into l_scl_segment1,
4745                                  l_scl_segment2,
4746                                  l_scl_segment3,
4747                                  l_scl_segment4,
4748                                  l_scl_segment5,
4749                                  l_scl_segment6,
4750                                  l_scl_segment7,
4751                                  l_scl_segment8,
4752                                  l_scl_segment9,
4753                                  l_scl_segment10,
4754                                  l_scl_segment11,
4755                                  l_scl_segment12,
4756                                  l_scl_segment13,
4757                                  l_scl_segment14,
4758                                  l_scl_segment15,
4759                                  l_scl_segment16,
4760                                  l_scl_segment17,
4761                                  l_scl_segment18,
4762                                  l_scl_segment19,
4763                                  l_scl_segment20,
4764                                  l_scl_segment21,
4765                                  l_scl_segment22,
4766                                  l_scl_segment23,
4767                                  l_scl_segment24,
4768                                  l_scl_segment25,
4769                                  l_scl_segment26,
4770                                  l_scl_segment27,
4771                                  l_scl_segment28,
4772                                  l_scl_segment29,
4773                                  l_scl_segment30;
4774      close c_scl_segments;
4775   else
4776      l_scl_null_ind := 0;
4777   end if;
4778   --
4779   -- if cagr_grade_def_id has a value then use it to get segment values using
4780   -- cursor cag_segments
4781   --
4782   if l_cagr_grade_def_id is not null
4783   then
4784      l_cag_null_ind := 1;
4785      open c_cag_segments;
4786        fetch c_cag_segments into l_cag_segment1,
4787                                  l_cag_segment2,
4788                                  l_cag_segment3,
4789                                  l_cag_segment4,
4790                                  l_cag_segment5,
4791                                  l_cag_segment6,
4792                                  l_cag_segment7,
4793                                  l_cag_segment8,
4794                                  l_cag_segment9,
4795                                  l_cag_segment10,
4796                                  l_cag_segment11,
4797                                  l_cag_segment12,
4798                                  l_cag_segment13,
4799                                  l_cag_segment14,
4800                                  l_cag_segment15,
4801                                  l_cag_segment16,
4802                                  l_cag_segment17,
4803                                  l_cag_segment18,
4804                                  l_cag_segment19,
4805                                  l_cag_segment20;
4806      close c_cag_segments;
4807   else
4808      l_cag_null_ind := 0;
4809   end if;
4810   --
4811   savepoint create_secondary_emp_asg;
4812   --
4813   begin
4814   --
4815     --
4816     -- Start of API User Hook for the before hook of create_secondary_emp_asg
4817     --
4818     hr_assignment_bk1.create_secondary_emp_asg_b
4819       (p_effective_date               => l_effective_date
4820       ,p_person_id                    => p_person_id
4821       ,p_organization_id              => p_organization_id
4822       ,p_grade_id                     => p_grade_id
4823       ,p_position_id                  => p_position_id
4824       ,p_job_id                       => p_job_id
4825       ,p_assignment_status_type_id    => p_assignment_status_type_id
4826       ,p_payroll_id                   => p_payroll_id
4827       ,p_location_id                  => p_location_id
4828       ,p_supervisor_id                => p_supervisor_id
4829       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
4830       ,p_pay_basis_id                 => p_pay_basis_id
4831       ,p_assignment_number            => p_assignment_number
4832       ,p_change_reason                => p_change_reason
4833       ,p_comments                     => p_comments
4834       ,p_date_probation_end           => l_date_probation_end
4835       ,p_default_code_comb_id         => p_default_code_comb_id
4836       ,p_employment_category          => p_employment_category
4837       ,p_frequency                    => p_frequency
4838       ,p_internal_address_line        => p_internal_address_line
4839       ,p_manager_flag                 => p_manager_flag
4840       ,p_normal_hours                 => p_normal_hours
4841       ,p_perf_review_period           => p_perf_review_period
4842       ,p_perf_review_period_frequency => p_perf_review_period_frequency
4843       ,p_probation_period             => p_probation_period
4844       ,p_probation_unit               => p_probation_unit
4845       ,p_sal_review_period            => p_sal_review_period
4846       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
4847       ,p_set_of_books_id              => p_set_of_books_id
4848       ,p_source_type                  => p_source_type
4849       ,p_time_normal_finish           => p_time_normal_finish
4850       ,p_time_normal_start            => p_time_normal_start
4851       ,p_bargaining_unit_code         => p_bargaining_unit_code
4852       ,p_labour_union_member_flag     => p_labour_union_member_flag
4853       ,p_hourly_salaried_code         => p_hourly_salaried_code
4854       ,p_ass_attribute_category       => p_ass_attribute_category
4855       ,p_ass_attribute1               => p_ass_attribute1
4856       ,p_ass_attribute2               => p_ass_attribute2
4857       ,p_ass_attribute3               => p_ass_attribute3
4858       ,p_ass_attribute4               => p_ass_attribute4
4859       ,p_ass_attribute5               => p_ass_attribute5
4860       ,p_ass_attribute6               => p_ass_attribute6
4861       ,p_ass_attribute7               => p_ass_attribute7
4862       ,p_ass_attribute8               => p_ass_attribute8
4863       ,p_ass_attribute9               => p_ass_attribute9
4864       ,p_ass_attribute10              => p_ass_attribute10
4865       ,p_ass_attribute11              => p_ass_attribute11
4866       ,p_ass_attribute12              => p_ass_attribute12
4867       ,p_ass_attribute13              => p_ass_attribute13
4868       ,p_ass_attribute14              => p_ass_attribute14
4869       ,p_ass_attribute15              => p_ass_attribute15
4870       ,p_ass_attribute16              => p_ass_attribute16
4871       ,p_ass_attribute17              => p_ass_attribute17
4872       ,p_ass_attribute18              => p_ass_attribute18
4873       ,p_ass_attribute19              => p_ass_attribute19
4874       ,p_ass_attribute20              => p_ass_attribute20
4875       ,p_ass_attribute21              => p_ass_attribute21
4876       ,p_ass_attribute22              => p_ass_attribute22
4877       ,p_ass_attribute23              => p_ass_attribute23
4878       ,p_ass_attribute24              => p_ass_attribute24
4879       ,p_ass_attribute25              => p_ass_attribute25
4880       ,p_ass_attribute26              => p_ass_attribute26
4881       ,p_ass_attribute27              => p_ass_attribute27
4882       ,p_ass_attribute28              => p_ass_attribute28
4883       ,p_ass_attribute29              => p_ass_attribute29
4884       ,p_ass_attribute30              => p_ass_attribute30
4885       ,p_title                        => p_title
4886        --
4887        -- Bug 2359997
4888        -- Amended p_scl/pgp/cag_segments to be l_scl/pgp/cag_segments
4889        --
4890       ,p_scl_segment1                 => l_scl_segment1
4891       ,p_scl_segment2                 => l_scl_segment2
4892       ,p_scl_segment3                 => l_scl_segment3
4893       ,p_scl_segment4                 => l_scl_segment4
4894       ,p_scl_segment5                 => l_scl_segment5
4895       ,p_scl_segment6                 => l_scl_segment6
4896       ,p_scl_segment7                 => l_scl_segment7
4897       ,p_scl_segment8                 => l_scl_segment8
4898       ,p_scl_segment9                 => l_scl_segment9
4899       ,p_scl_segment10                => l_scl_segment10
4900       ,p_scl_segment11                => l_scl_segment11
4901       ,p_scl_segment12                => l_scl_segment12
4902       ,p_scl_segment13                => l_scl_segment13
4903       ,p_scl_segment14                => l_scl_segment14
4904       ,p_scl_segment15                => l_scl_segment15
4905       ,p_scl_segment16                => l_scl_segment16
4906       ,p_scl_segment17                => l_scl_segment17
4907       ,p_scl_segment18                => l_scl_segment18
4908       ,p_scl_segment19                => l_scl_segment19
4909       ,p_scl_segment20                => l_scl_segment20
4910       ,p_scl_segment21                => l_scl_segment21
4911       ,p_scl_segment22                => l_scl_segment22
4912       ,p_scl_segment23                => l_scl_segment23
4913       ,p_scl_segment24                => l_scl_segment24
4914       ,p_scl_segment25                => l_scl_segment25
4915       ,p_scl_segment26                => l_scl_segment26
4916       ,p_scl_segment27                => l_scl_segment27
4917       ,p_scl_segment28                => l_scl_segment28
4918       ,p_scl_segment29                => l_scl_segment29
4919       ,p_scl_segment30                => l_scl_segment30
4920       --
4921       -- Bug 944911
4922       -- Amended p_scl_concatenated_Segments by p_scl_concat_segments
4923       --
4924       ,p_scl_concat_segments          => l_old_scl_conc_segments
4925       ,p_pgp_segment1                 => l_pgp_segment1
4926       ,p_pgp_segment2                 => l_pgp_segment2
4927       ,p_pgp_segment3                 => l_pgp_segment3
4928       ,p_pgp_segment4                 => l_pgp_segment4
4929       ,p_pgp_segment5                 => l_pgp_segment5
4930       ,p_pgp_segment6                 => l_pgp_segment6
4931       ,p_pgp_segment7                 => l_pgp_segment7
4932       ,p_pgp_segment8                 => l_pgp_segment8
4933       ,p_pgp_segment9                 => l_pgp_segment9
4934       ,p_pgp_segment10                => l_pgp_segment10
4935       ,p_pgp_segment11                => l_pgp_segment11
4936       ,p_pgp_segment12                => l_pgp_segment12
4937       ,p_pgp_segment13                => l_pgp_segment13
4938       ,p_pgp_segment14                => l_pgp_segment14
4939       ,p_pgp_segment15                => l_pgp_segment15
4940       ,p_pgp_segment16                => l_pgp_segment16
4941       ,p_pgp_segment17                => l_pgp_segment17
4942       ,p_pgp_segment18                => l_pgp_segment18
4943       ,p_pgp_segment19                => l_pgp_segment19
4944       ,p_pgp_segment20                => l_pgp_segment20
4945       ,p_pgp_segment21                => l_pgp_segment21
4946       ,p_pgp_segment22                => l_pgp_segment22
4947       ,p_pgp_segment23                => l_pgp_segment23
4948       ,p_pgp_segment24                => l_pgp_segment24
4949       ,p_pgp_segment25                => l_pgp_segment25
4950       ,p_pgp_segment26                => l_pgp_segment26
4951       ,p_pgp_segment27                => l_pgp_segment27
4952       ,p_pgp_segment28                => l_pgp_segment28
4953       ,p_pgp_segment29                => l_pgp_segment29
4954       ,p_pgp_segment30                => l_pgp_segment30
4955       --
4956       -- Bug 944911
4957       -- Replaced p_group_name with p_pgp_concat_segments
4958       --
4959       ,p_pgp_concat_segments          => l_old_group_name
4960       ,p_contract_id                  => p_contract_id
4961       ,p_establishment_id             => p_establishment_id
4962       ,p_collective_agreement_id      => p_collective_agreement_id
4963       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
4964       ,p_cag_segment1                 => l_cag_segment1
4965       ,p_cag_segment2                 => l_cag_segment2
4966       ,p_cag_segment3                 => l_cag_segment3
4967       ,p_cag_segment4                 => l_cag_segment4
4968       ,p_cag_segment5                 => l_cag_segment5
4969       ,p_cag_segment6                 => l_cag_segment6
4970       ,p_cag_segment7                 => l_cag_segment7
4971       ,p_cag_segment8                 => l_cag_segment8
4972       ,p_cag_segment9                 => l_cag_segment9
4973       ,p_cag_segment10                => l_cag_segment10
4974       ,p_cag_segment11                => l_cag_segment11
4975       ,p_cag_segment12                => l_cag_segment12
4976       ,p_cag_segment13                => l_cag_segment13
4977       ,p_cag_segment14                => l_cag_segment14
4978       ,p_cag_segment15                => l_cag_segment15
4979       ,p_cag_segment16                => l_cag_segment16
4980       ,p_cag_segment17                => l_cag_segment17
4981       ,p_cag_segment18                => l_cag_segment18
4982       ,p_cag_segment19                => l_cag_segment19
4983       ,p_cag_segment20                => l_cag_segment20
4984       ,p_notice_period		      => p_notice_period
4985       ,p_notice_period_uom	      => p_notice_period_uom
4986       ,p_employee_category	      => p_employee_category
4987       ,p_work_at_home		      => p_work_at_home
4988       ,p_job_post_source_name	      => p_job_post_source_name
4989       ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
4990       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
4991       );
4992   exception
4993     when hr_api.cannot_find_prog_unit then
4994       hr_api.cannot_find_prog_unit_error
4995         (p_module_name => 'CREATE_SECONDARY_EMP_ASG'
4996         ,p_hook_type   => 'BP'
4997         );
4998     --
4999     -- End of API User Hook for the before hook of create_secondary_emp_asg
5000   --
5001   end;
5002   --
5003  if g_debug then
5004   hr_utility.set_location(l_proc, 10);
5005  end if;
5006   --
5007   -- Validation in addition to Table Handlers
5008   --
5009   -- Get person details.
5010   --
5011   hr_api.mandatory_arg_error
5012      (p_api_name       => l_proc
5013      ,p_argument       => 'person_id'
5014      ,p_argument_value => p_person_id
5015      );
5016   --
5017   hr_api.mandatory_arg_error
5018      (p_api_name       => l_proc
5019      ,p_argument       => 'effective_date'
5020      ,p_argument_value => l_effective_date
5021      );
5022   --
5023   -- Record the value of in out parameters
5024   --
5025   l_assignment_number := p_assignment_number;
5026   --
5027   open  csr_get_derived_details;
5028   fetch csr_get_derived_details
5029    into l_business_group_id
5030       , l_legislation_code;
5031   --
5032   if csr_get_derived_details%NOTFOUND then
5033     --
5034     close csr_get_derived_details;
5035     --
5036  if g_debug then
5037     hr_utility.set_location(l_proc, 15);
5038  end if;
5039     --
5040     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
5041     hr_utility.raise_error;
5042   end if;
5043   --
5044   close csr_get_derived_details;
5045   --
5046  if g_debug then
5047   hr_utility.set_location(l_proc, 20);
5048  end if;
5049   --
5050   -- Process Logic
5051   --
5052   -- Get period of service from primary assignment.
5053   --
5054   open  csr_get_period_of_service;
5055   fetch csr_get_period_of_service
5056    into l_period_of_service_id;
5057   --
5058   if csr_get_period_of_service%NOTFOUND then
5059     --
5060     close csr_get_period_of_service;
5061     --
5062  if g_debug then
5063     hr_utility.set_location(l_proc, 25);
5064  end if;
5065     --
5066     hr_utility.set_message(801,'HR_7436_ASG_NO_PRIM_ASS');
5067     hr_utility.raise_error;
5068   end if;
5069   --
5070   close csr_get_period_of_service;
5071  if g_debug then
5072   hr_utility.set_location(l_proc, 26);
5073  end if;
5074   --
5075   -- insert the profile options and effective date for the flexfield
5076   -- validation to work
5077   --
5078   hr_kflex_utility.set_profiles
5079   (p_business_group_id => l_business_group_id
5080   ,p_assignment_id     => l_assignment_id
5081   ,p_organization_id   => p_organization_id
5082   ,p_location_id       => p_location_id);
5083   --
5084   hr_kflex_utility.set_session_date
5085   (p_effective_date => l_effective_date
5086   ,p_session_id     => l_session_id);
5087   --
5088   open csr_grp_idsel;
5089   fetch csr_grp_idsel into l_grp_flex_num;
5090     if csr_grp_idsel%NOTFOUND then
5091        close csr_grp_idsel;
5092           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
5093           hr_utility.set_message_token('PROCEDURE', l_proc);
5094           hr_utility.set_message_token('STEP','5');
5095           hr_utility.raise_error;
5096     else
5097       close csr_grp_idsel;
5098     end if;
5099  if g_debug then
5100   hr_utility.set_location(l_proc, 27);
5101  end if;
5102   --
5103   --
5104   -- Bug 2359997 - if key flex parameters have a value then derive segment
5105   -- values from them
5106   --
5107   if l_scl_null_ind = 0
5108   then
5109     if l_scl_segment1 is not null
5110     or l_scl_segment2 is not null
5111     or l_scl_segment3 is not null
5112     or l_scl_segment4 is not null
5113     or l_scl_segment5 is not null
5114     or l_scl_segment6 is not null
5115     or l_scl_segment7 is not null
5116     or l_scl_segment8 is not null
5117     or l_scl_segment9 is not null
5118     or l_scl_segment10 is not null
5119     or l_scl_segment11 is not null
5120     or l_scl_segment12 is not null
5121     or l_scl_segment13 is not null
5122     or l_scl_segment14 is not null
5123     or l_scl_segment15 is not null
5124     or l_scl_segment16 is not null
5125     or l_scl_segment17 is not null
5126     or l_scl_segment18 is not null
5127     or l_scl_segment19 is not null
5128     or l_scl_segment20 is not null
5129     or l_scl_segment21 is not null
5130     or l_scl_segment22 is not null
5131     or l_scl_segment23 is not null
5132     or l_scl_segment24 is not null
5133     or l_scl_segment25 is not null
5134     or l_scl_segment26 is not null
5135     or l_scl_segment27 is not null
5136     or l_scl_segment28 is not null
5137     or l_scl_segment29 is not null
5138     or l_scl_segment30 is not null
5139     --
5140     -- Bug 944911
5141     -- Added this clause
5142     --
5143     --
5144     or p_scl_concat_segments is not null
5145     then
5146       open csr_scl_idsel;
5147       fetch csr_scl_idsel into l_scl_flex_num;
5148       if csr_scl_idsel%NOTFOUND
5149       then
5150         close csr_scl_idsel;
5151  if g_debug then
5152         hr_utility.set_location(l_proc, 28);
5153  end if;
5154         --
5155         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
5156         hr_utility.set_message_token('PROCEDURE', l_proc);
5157         hr_utility.set_message_token('STEP','10');
5158         hr_utility.raise_error;
5159       else
5160         close csr_scl_idsel;
5161         --
5162         --
5163  if g_debug then
5164         hr_utility.set_location(l_proc, 30);
5165  end if;
5166         --
5167         -- Insert or select the soft_coding_keyflex_id
5168         --
5169         hr_kflex_utility.ins_or_sel_keyflex_comb
5170         (p_appl_short_name        => 'PER'
5171         ,p_flex_code              => 'SCL'
5172         ,p_flex_num               => l_scl_flex_num
5173         ,p_segment1               => l_scl_segment1
5174         ,p_segment2               => l_scl_segment2
5175         ,p_segment3               => l_scl_segment3
5176         ,p_segment4               => l_scl_segment4
5177         ,p_segment5               => l_scl_segment5
5178         ,p_segment6               => l_scl_segment6
5179         ,p_segment7               => l_scl_segment7
5180         ,p_segment8               => l_scl_segment8
5181         ,p_segment9               => l_scl_segment9
5182         ,p_segment10              => l_scl_segment10
5183         ,p_segment11              => l_scl_segment11
5184         ,p_segment12              => l_scl_segment12
5185         ,p_segment13              => l_scl_segment13
5186         ,p_segment14              => l_scl_segment14
5187         ,p_segment15              => l_scl_segment15
5188         ,p_segment16              => l_scl_segment16
5189         ,p_segment17              => l_scl_segment17
5190         ,p_segment18              => l_scl_segment18
5191         ,p_segment19              => l_scl_segment19
5192         ,p_segment20              => l_scl_segment20
5193         ,p_segment21              => l_scl_segment21
5194         ,p_segment22              => l_scl_segment22
5195         ,p_segment23              => l_scl_segment23
5196         ,p_segment24              => l_scl_segment24
5197         ,p_segment25              => l_scl_segment25
5198         ,p_segment26              => l_scl_segment26
5199         ,p_segment27              => l_scl_segment27
5200         ,p_segment28              => l_scl_segment28
5201         ,p_segment29              => l_scl_segment29
5202         ,p_segment30              => l_scl_segment30
5203         ,p_concat_segments_in     => l_old_scl_conc_segments
5204         ,p_ccid                   => l_soft_coding_keyflex_id
5205         ,p_concat_segments_out    => l_concatenated_segments
5206         );
5207         --
5208         -- update the combinations column
5209         --
5210         update_scl_concat_segs  -- shd this be available for when id known.
5211         (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
5212         ,p_concatenated_segments   => l_concatenated_segments
5213         );
5214       --
5215       end if; --  if csr_scl_idsel%NOTFOUND
5216     --
5217     end if; -- l_scl_segment1 is not null
5218   --
5219   end if; -- bug 2359997 if soft coding key flex id came in null
5220   --
5221   --
5222   if l_pgp_null_ind = 0
5223   then
5224     --
5225     -- Insert or select the people_group_id.
5226     --
5227     hr_kflex_utility.ins_or_sel_keyflex_comb
5228     (p_appl_short_name        => 'PAY'
5229     ,p_flex_code              => 'GRP'
5230     ,p_flex_num               => l_grp_flex_num
5231     ,p_segment1               => l_pgp_segment1
5232     ,p_segment2               => l_pgp_segment2
5233     ,p_segment3               => l_pgp_segment3
5234     ,p_segment4               => l_pgp_segment4
5235     ,p_segment5               => l_pgp_segment5
5236     ,p_segment6               => l_pgp_segment6
5237     ,p_segment7               => l_pgp_segment7
5238     ,p_segment8               => l_pgp_segment8
5239     ,p_segment9               => l_pgp_segment9
5240     ,p_segment10              => l_pgp_segment10
5241     ,p_segment11              => l_pgp_segment11
5242     ,p_segment12              => l_pgp_segment12
5243     ,p_segment13              => l_pgp_segment13
5244     ,p_segment14              => l_pgp_segment14
5245     ,p_segment15              => l_pgp_segment15
5246     ,p_segment16              => l_pgp_segment16
5247     ,p_segment17              => l_pgp_segment17
5248     ,p_segment18              => l_pgp_segment18
5249     ,p_segment19              => l_pgp_segment19
5250     ,p_segment20              => l_pgp_segment20
5251     ,p_segment21              => l_pgp_segment21
5252     ,p_segment22              => l_pgp_segment22
5253     ,p_segment23              => l_pgp_segment23
5254     ,p_segment24              => l_pgp_segment24
5255     ,p_segment25              => l_pgp_segment25
5256     ,p_segment26              => l_pgp_segment26
5257     ,p_segment27              => l_pgp_segment27
5258     ,p_segment28              => l_pgp_segment28
5259     ,p_segment29              => l_pgp_segment29
5260     ,p_segment30              => l_pgp_segment30
5261     ,p_concat_segments_in     => l_old_group_name
5262     ,p_ccid                   => l_people_group_id
5263     ,p_concat_segments_out    => l_group_name
5264     );
5265     --
5266  if g_debug then
5267     hr_utility.set_location(l_proc, 35);
5268  end if;
5269   --
5270   end if;  -- bug 2359997 end if people group id null
5271   --
5272   -- update the combinations column
5273   --
5274   update_pgp_concat_segs
5275   (p_people_group_id        => l_people_group_id
5276   ,p_group_name             => l_group_name
5277   );
5278   --
5279   --
5280   if l_cag_null_ind = 0
5281   then
5282     --
5283     -- select or insert the Collective Agreement grade
5284     --
5285     hr_cgd_ins.ins_or_sel
5286     (p_segment1               => l_cag_segment1
5287     ,p_segment2               => l_cag_segment2
5288     ,p_segment3               => l_cag_segment3
5289     ,p_segment4               => l_cag_segment4
5290     ,p_segment5               => l_cag_segment5
5291     ,p_segment6               => l_cag_segment6
5292     ,p_segment7               => l_cag_segment7
5293     ,p_segment8               => l_cag_segment8
5294     ,p_segment9               => l_cag_segment9
5295     ,p_segment10              => l_cag_segment10
5296     ,p_segment11              => l_cag_segment11
5297     ,p_segment12              => l_cag_segment12
5298     ,p_segment13              => l_cag_segment13
5299     ,p_segment14              => l_cag_segment14
5300     ,p_segment15              => l_cag_segment15
5301     ,p_segment16              => l_cag_segment16
5302     ,p_segment17              => l_cag_segment17
5303     ,p_segment18              => l_cag_segment18
5304     ,p_segment19              => l_cag_segment19
5305     ,p_segment20              => l_cag_segment20
5306     ,p_id_flex_num            => p_cagr_id_flex_num
5307     ,p_business_group_id      => l_business_group_id
5308     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
5309     ,p_concatenated_segments  => l_cagr_concatenated_segments
5310      );
5311   --
5312   end if; -- l_cag_null_ind = 0 bug 2359997
5313   --
5314  if g_debug then
5315   hr_utility.set_location(l_proc, 35);
5316  end if;
5317   --
5318   --
5319   -- Insert secondary assignment
5320   --
5321   hr_assignment_internal.create_emp_asg
5322     (p_effective_date               => l_effective_date
5323     ,p_legislation_code             => l_legislation_code
5324     ,p_business_group_id            => l_business_group_id
5325     ,p_person_id                    => p_person_id
5326     ,p_organization_id              => p_organization_id
5327     ,p_primary_flag                 => 'N'
5328     ,p_period_of_service_id         => l_period_of_service_id
5329     ,p_grade_id                     => p_grade_id
5330     ,p_position_id                  => p_position_id
5331     ,p_job_id                       => p_job_id
5332     ,p_assignment_status_type_id    => p_assignment_status_type_id
5333     ,p_payroll_id                   => p_payroll_id
5334     ,p_location_id                  => p_location_id
5335     ,p_supervisor_id                => p_supervisor_id
5336     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
5337     ,p_people_group_id              => l_people_group_id
5338     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
5339     ,p_pay_basis_id                 => p_pay_basis_id
5340     ,p_assignment_number            => p_assignment_number
5341     ,p_change_reason                => p_change_reason
5342     ,p_comments                     => p_comments
5343     ,p_date_probation_end           => l_date_probation_end
5344     ,p_default_code_comb_id         => p_default_code_comb_id
5345     ,p_employment_category          => p_employment_category
5346     ,p_frequency                    => p_frequency
5347     ,p_internal_address_line        => p_internal_address_line
5348     ,p_manager_flag                 => p_manager_flag
5349     ,p_normal_hours                 => p_normal_hours
5350     ,p_perf_review_period           => p_perf_review_period
5351     ,p_perf_review_period_frequency => p_perf_review_period_frequency
5352     ,p_probation_period             => p_probation_period
5353     ,p_probation_unit               => p_probation_unit
5354     ,p_sal_review_period            => p_sal_review_period
5355     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
5356     ,p_set_of_books_id              => p_set_of_books_id
5357     ,p_source_type                  => p_source_type
5358     ,p_time_normal_finish           => p_time_normal_finish
5359     ,p_time_normal_start            => p_time_normal_start
5360     ,p_bargaining_unit_code         => p_bargaining_unit_code
5361     ,p_labour_union_member_flag     => p_labour_union_member_flag
5362     ,p_hourly_salaried_code         => p_hourly_salaried_code
5363     ,p_ass_attribute_category       => p_ass_attribute_category
5364     ,p_ass_attribute1               => p_ass_attribute1
5365     ,p_ass_attribute2               => p_ass_attribute2
5366     ,p_ass_attribute3               => p_ass_attribute3
5367     ,p_ass_attribute4               => p_ass_attribute4
5368     ,p_ass_attribute5               => p_ass_attribute5
5369     ,p_ass_attribute6               => p_ass_attribute6
5370     ,p_ass_attribute7               => p_ass_attribute7
5371     ,p_ass_attribute8               => p_ass_attribute8
5372     ,p_ass_attribute9               => p_ass_attribute9
5373     ,p_ass_attribute10              => p_ass_attribute10
5374     ,p_ass_attribute11              => p_ass_attribute11
5375     ,p_ass_attribute12              => p_ass_attribute12
5376     ,p_ass_attribute13              => p_ass_attribute13
5377     ,p_ass_attribute14              => p_ass_attribute14
5378     ,p_ass_attribute15              => p_ass_attribute15
5379     ,p_ass_attribute16              => p_ass_attribute16
5380     ,p_ass_attribute17              => p_ass_attribute17
5381     ,p_ass_attribute18              => p_ass_attribute18
5382     ,p_ass_attribute19              => p_ass_attribute19
5383     ,p_ass_attribute20              => p_ass_attribute20
5384     ,p_ass_attribute21              => p_ass_attribute21
5385     ,p_ass_attribute22              => p_ass_attribute22
5386     ,p_ass_attribute23              => p_ass_attribute23
5387     ,p_ass_attribute24              => p_ass_attribute24
5388     ,p_ass_attribute25              => p_ass_attribute25
5389     ,p_ass_attribute26              => p_ass_attribute26
5390     ,p_ass_attribute27              => p_ass_attribute27
5391     ,p_ass_attribute28              => p_ass_attribute28
5392     ,p_ass_attribute29              => p_ass_attribute29
5393     ,p_ass_attribute30              => p_ass_attribute30
5394     ,p_notice_period		    => p_notice_period
5395     ,p_notice_period_uom	    => p_notice_period_uom
5396     ,p_employee_category	    => p_employee_category
5397     ,p_work_at_home		    => p_work_at_home
5398     ,p_job_post_source_name	    => p_job_post_source_name
5399     ,p_title                        => p_title
5400     ,p_contract_id                  => p_contract_id
5401     ,p_establishment_id             => p_establishment_id
5402     ,p_collective_agreement_id      => p_collective_agreement_id
5403     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
5404     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
5405     ,p_assignment_id                => l_assignment_id
5406     ,p_object_version_number        => l_object_version_number
5407     ,p_effective_start_date         => l_effective_start_date
5408     ,p_effective_end_date           => l_effective_end_date
5409     ,p_assignment_sequence          => l_assignment_sequence
5410     ,p_comment_id                   => l_comment_id
5411     ,p_other_manager_warning        => l_other_manager_warning
5412     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
5413     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
5414     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
5415     );
5416   --
5417   -- add rows to the security table if it is a current assignment.
5418   --
5419   if(l_effective_date <= sysdate) then
5420     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
5421   end if;
5422   --
5423  if g_debug then
5424   hr_utility.set_location(l_proc, 40);
5425  end if;
5426   --
5427   begin
5428     --
5429     -- Start of API User Hook for the after hook of create_secondary_emp_asg
5430     --
5431     -- Bug 944911
5432     -- No amendments required for outs as the values carried forward
5433     -- Adding the 2 additional ins - p_concat_segments and p_pgp_concat_segments
5434     -- Both with the same value as passed to _b proc
5435     hr_assignment_bk1.create_secondary_emp_asg_a
5436       (p_effective_date               => l_effective_date
5437       ,p_person_id                    => p_person_id
5438       ,p_organization_id              => p_organization_id
5439       ,p_grade_id                     => p_grade_id
5440       ,p_position_id                  => p_position_id
5441       ,p_job_id                       => p_job_id
5442       ,p_assignment_status_type_id    => p_assignment_status_type_id
5443       ,p_payroll_id                   => p_payroll_id
5444       ,p_location_id                  => p_location_id
5445       ,p_supervisor_id                => p_supervisor_id
5446       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
5447       ,p_pay_basis_id                 => p_pay_basis_id
5448       ,p_assignment_number            => p_assignment_number
5449       ,p_change_reason                => p_change_reason
5450       ,p_comments                     => p_comments
5451       ,p_date_probation_end           => l_date_probation_end
5452       ,p_default_code_comb_id         => p_default_code_comb_id
5453       ,p_employment_category          => p_employment_category
5454       ,p_frequency                    => p_frequency
5455       ,p_internal_address_line        => p_internal_address_line
5456       ,p_manager_flag                 => p_manager_flag
5457       ,p_normal_hours                 => p_normal_hours
5458       ,p_perf_review_period           => p_perf_review_period
5459       ,p_perf_review_period_frequency => p_perf_review_period_frequency
5460       ,p_probation_period             => p_probation_period
5461       ,p_probation_unit               => p_probation_unit
5462       ,p_sal_review_period            => p_sal_review_period
5463       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
5464       ,p_set_of_books_id              => p_set_of_books_id
5465       ,p_source_type                  => p_source_type
5466       ,p_time_normal_finish           => p_time_normal_finish
5467       ,p_time_normal_start            => p_time_normal_start
5468       ,p_bargaining_unit_code         => p_bargaining_unit_code
5469       ,p_labour_union_member_flag     => p_labour_union_member_flag
5470       ,p_hourly_salaried_code         => p_hourly_salaried_code
5471       ,p_ass_attribute_category       => p_ass_attribute_category
5472       ,p_ass_attribute1               => p_ass_attribute1
5473       ,p_ass_attribute2               => p_ass_attribute2
5474       ,p_ass_attribute3               => p_ass_attribute3
5475       ,p_ass_attribute4               => p_ass_attribute4
5476       ,p_ass_attribute5               => p_ass_attribute5
5477       ,p_ass_attribute6               => p_ass_attribute6
5478       ,p_ass_attribute7               => p_ass_attribute7
5479       ,p_ass_attribute8               => p_ass_attribute8
5480       ,p_ass_attribute9               => p_ass_attribute9
5481       ,p_ass_attribute10              => p_ass_attribute10
5482       ,p_ass_attribute11              => p_ass_attribute11
5483       ,p_ass_attribute12              => p_ass_attribute12
5484       ,p_ass_attribute13              => p_ass_attribute13
5485       ,p_ass_attribute14              => p_ass_attribute14
5486       ,p_ass_attribute15              => p_ass_attribute15
5487       ,p_ass_attribute16              => p_ass_attribute16
5488       ,p_ass_attribute17              => p_ass_attribute17
5489       ,p_ass_attribute18              => p_ass_attribute18
5490       ,p_ass_attribute19              => p_ass_attribute19
5491       ,p_ass_attribute20              => p_ass_attribute20
5492       ,p_ass_attribute21              => p_ass_attribute21
5493       ,p_ass_attribute22              => p_ass_attribute22
5494       ,p_ass_attribute23              => p_ass_attribute23
5495       ,p_ass_attribute24              => p_ass_attribute24
5496       ,p_ass_attribute25              => p_ass_attribute25
5497       ,p_ass_attribute26              => p_ass_attribute26
5498       ,p_ass_attribute27              => p_ass_attribute27
5499       ,p_ass_attribute28              => p_ass_attribute28
5500       ,p_ass_attribute29              => p_ass_attribute29
5501       ,p_ass_attribute30              => p_ass_attribute30
5502       ,p_title                        => p_title
5503       ,p_scl_segment1                 => l_scl_segment1
5504       ,p_scl_segment2                 => l_scl_segment2
5505       ,p_scl_segment3                 => l_scl_segment3
5506       ,p_scl_segment4                 => l_scl_segment4
5507       ,p_scl_segment5                 => l_scl_segment5
5508       ,p_scl_segment6                 => l_scl_segment6
5509       ,p_scl_segment7                 => l_scl_segment7
5510       ,p_scl_segment8                 => l_scl_segment8
5511       ,p_scl_segment9                 => l_scl_segment9
5512       ,p_scl_segment10                => l_scl_segment10
5513       ,p_scl_segment11                => l_scl_segment11
5514       ,p_scl_segment12                => l_scl_segment12
5515       ,p_scl_segment13                => l_scl_segment13
5516       ,p_scl_segment14                => l_scl_segment14
5517       ,p_scl_segment15                => l_scl_segment15
5518       ,p_scl_segment16                => l_scl_segment16
5519       ,p_scl_segment17                => l_scl_segment17
5520       ,p_scl_segment18                => l_scl_segment18
5521       ,p_scl_segment19                => l_scl_segment19
5522       ,p_scl_segment20                => l_scl_segment20
5523       ,p_scl_segment21                => l_scl_segment21
5524       ,p_scl_segment22                => l_scl_segment22
5525       ,p_scl_segment23                => l_scl_segment23
5526       ,p_scl_segment24                => l_scl_segment24
5527       ,p_scl_segment25                => l_scl_segment25
5528       ,p_scl_segment26                => l_scl_segment26
5529       ,p_scl_segment27                => l_scl_segment27
5530       ,p_scl_segment28                => l_scl_segment28
5531       ,p_scl_segment29                => l_scl_segment29
5532       ,p_scl_segment30                => l_scl_segment30
5533       --
5534       -- Bug 944911
5535       -- Amended p_scl_concatenated_segments to p_concatenated_segments
5536       --
5537       ,p_concatenated_segments        => l_concatenated_segments
5538       ,p_pgp_segment1                 => l_pgp_segment1
5539       ,p_pgp_segment2                 => l_pgp_segment2
5540       ,p_pgp_segment3                 => l_pgp_segment3
5541       ,p_pgp_segment4                 => l_pgp_segment4
5542       ,p_pgp_segment5                 => l_pgp_segment5
5543       ,p_pgp_segment6                 => l_pgp_segment6
5544       ,p_pgp_segment7                 => l_pgp_segment7
5545       ,p_pgp_segment8                 => l_pgp_segment8
5546       ,p_pgp_segment9                 => l_pgp_segment9
5547       ,p_pgp_segment10                => l_pgp_segment10
5548       ,p_pgp_segment11                => l_pgp_segment11
5549       ,p_pgp_segment12                => l_pgp_segment12
5550       ,p_pgp_segment13                => l_pgp_segment13
5551       ,p_pgp_segment14                => l_pgp_segment14
5552       ,p_pgp_segment15                => l_pgp_segment15
5553       ,p_pgp_segment16                => l_pgp_segment16
5554       ,p_pgp_segment17                => l_pgp_segment17
5555       ,p_pgp_segment18                => l_pgp_segment18
5556       ,p_pgp_segment19                => l_pgp_segment19
5557       ,p_pgp_segment20                => l_pgp_segment20
5558       ,p_pgp_segment21                => l_pgp_segment21
5559       ,p_pgp_segment22                => l_pgp_segment22
5560       ,p_pgp_segment23                => l_pgp_segment23
5561       ,p_pgp_segment24                => l_pgp_segment24
5562       ,p_pgp_segment25                => l_pgp_segment25
5563       ,p_pgp_segment26                => l_pgp_segment26
5564       ,p_pgp_segment27                => l_pgp_segment27
5565       ,p_pgp_segment28                => l_pgp_segment28
5566       ,p_pgp_segment29                => l_pgp_segment29
5567       ,p_pgp_segment30                => l_pgp_segment30
5568       ,p_contract_id                  => p_contract_id
5569       ,p_establishment_id             => p_establishment_id
5570       ,p_collective_agreement_id      => p_collective_agreement_id
5571       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
5572       ,p_cag_segment1                 => l_cag_segment1
5573       ,p_cag_segment2                 => l_cag_segment2
5574       ,p_cag_segment3                 => l_cag_segment3
5575       ,p_cag_segment4                 => l_cag_segment4
5576       ,p_cag_segment5                 => l_cag_segment5
5577       ,p_cag_segment6                 => l_cag_segment6
5578       ,p_cag_segment7                 => l_cag_segment7
5579       ,p_cag_segment8                 => l_cag_segment8
5580       ,p_cag_segment9                 => l_cag_segment9
5581       ,p_cag_segment10                => l_cag_segment10
5582       ,p_cag_segment11                => l_cag_segment11
5583       ,p_cag_segment12                => l_cag_segment12
5584       ,p_cag_segment13                => l_cag_segment13
5585       ,p_cag_segment14                => l_cag_segment14
5586       ,p_cag_segment15                => l_cag_segment15
5587       ,p_cag_segment16                => l_cag_segment16
5588       ,p_cag_segment17                => l_cag_segment17
5589       ,p_cag_segment18                => l_cag_segment18
5590       ,p_cag_segment19                => l_cag_segment19
5591       ,p_cag_segment20                => l_cag_segment20
5592       ,p_notice_period		      => p_notice_period
5593       ,p_notice_period_uom	      => p_notice_period_uom
5594       ,p_employee_category	      => p_employee_category
5595       ,p_work_at_home		      => p_work_at_home
5596       ,p_job_post_source_name	      => p_job_post_source_name
5597       ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
5598       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
5599       ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
5600       ,p_cagr_grade_def_id            => l_cagr_grade_def_id
5601       ,p_group_name                   => l_group_name
5602       ,p_assignment_id                => l_assignment_id
5603       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
5604       ,p_people_group_id              => l_people_group_id
5605       ,p_object_version_number        => l_object_version_number
5606       ,p_effective_start_date         => l_effective_start_date
5607       ,p_effective_end_date           => l_effective_end_date
5608       ,p_assignment_sequence          => l_assignment_sequence
5609       ,p_comment_id                   => l_comment_id
5610       ,p_other_manager_warning        => l_other_manager_warning
5611       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
5612       --
5613       -- Bug 944911
5614       -- Replaced p_group_name with p_pgp_concat_segments
5615       --
5616       ,p_pgp_concat_segments          => l_old_group_name
5617       --
5618       -- Bug 944911
5619       -- Amended p_scl_concatenated_Segments by p_scl_concat_segments
5620       --
5621       ,p_scl_concat_segments          => l_old_scl_conc_segments
5622       );
5623   exception
5624     when hr_api.cannot_find_prog_unit then
5625       hr_api.cannot_find_prog_unit_error
5626         (p_module_name => 'CREATE_SECONDARY_EMP_ASG'
5627         ,p_hook_type   => 'AP'
5628         );
5629     --
5630     -- End of API User Hook for the after hook of create_secondary_emp_asg
5631     --
5632   end;
5633 
5634   --
5635   -- call pqh post process procedure -- bug 2999562
5636   --
5637   pqh_gsp_post_process.call_pp_from_assignments(
5638       p_effective_date    => p_effective_date
5639      ,p_assignment_id     => l_assignment_id    -- BUG 3336246
5640      ,p_date_track_mode   => NULL
5641      ,p_warning_mesg      => l_gsp_post_process_warning
5642   );
5643 
5644   --
5645   -- When in validation only mode raise the Validate_Enabled exception
5646   --
5647   if p_validate then
5648     raise hr_api.validate_enabled;
5649   end if;
5650   --
5651   -- Set remaining output arguments
5652   --
5653   p_assignment_id          := l_assignment_id;
5654   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
5655   p_people_group_id        := l_people_group_id;
5656   p_object_version_number  := l_object_version_number;
5657   p_effective_start_date   := l_effective_start_date;
5658   p_effective_end_date     := l_effective_end_date;
5659   p_assignment_sequence    := l_assignment_sequence;
5660   p_comment_id             := l_comment_id;
5661   p_concatenated_segments  := l_concatenated_segments;
5662   p_group_name             := l_group_name;
5663   p_other_manager_warning  := l_other_manager_warning;
5664   p_cagr_grade_def_id           := l_cagr_grade_def_id;
5665   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
5666   p_hourly_salaried_warning     := l_hourly_salaried_warning;
5667   p_gsp_post_process_warning    := l_gsp_post_process_warning; -- bug 2999562
5668   --
5669   -- remove data from the session table
5670   hr_kflex_utility.unset_session_date
5671   (p_session_id     => l_session_id);
5672   --
5673  if g_debug then
5674   hr_utility.set_location(' Leaving:'||l_proc, 50);
5675  end if;
5676 exception
5677   when hr_api.validate_enabled then
5678     --
5679     -- As the Validate_Enabled exception has been raised
5680     -- we must rollback to the savepoint
5681     --
5682     ROLLBACK TO create_secondary_emp_asg;
5683     --
5684     -- Only set output warning arguments
5685     -- (Any key or derived arguments must be set to null
5686     -- when validation only mode is being used.)
5687     --
5688     p_assignment_number      := l_assignment_number;
5689     p_assignment_id          := null;
5690     p_object_version_number  := null;
5691     p_effective_start_date   := null;
5692     p_effective_end_date     := null;
5693     p_assignment_sequence    := null;
5694     p_comment_id             := null;
5695     p_concatenated_segments  := l_old_scl_conc_segments;  -- Bug 944911
5696     p_group_name             := l_old_group_name;
5697     p_other_manager_warning  := l_other_manager_warning;
5698     p_hourly_salaried_warning     := l_hourly_salaried_warning;
5699     --
5700     p_cagr_concatenated_segments  := null;
5701     --
5702     -- bug 2359997 only re-set to null if key flex ids came in as null.
5703     --
5704     if l_pgp_null_ind = 0
5705     then
5706        p_people_group_id           := null;
5707     end if;
5708     if l_scl_null_ind = 0
5709     then
5710        p_soft_coding_keyflex_id    := null;
5711     end if;
5712     if l_cag_null_ind = 0
5713     then
5714        p_cagr_grade_def_id         := null;
5715     end if;
5716     --
5717     --
5718   when others then
5719     --
5720     -- A validation or unexpected error has occurred
5721     --
5722     -- Added as part of fix to bug 632479
5723     --
5724     p_assignment_number      := lv_assignment_number ;
5725     p_cagr_grade_def_id      := lv_cagr_grade_def_id ;
5726     p_soft_coding_keyflex_id := lv_soft_coding_keyflex_id ;
5727     p_people_group_id        := lv_people_group_id ;
5728 
5729     p_object_version_number      := null;
5730     p_effective_start_date       := null;
5731     p_effective_end_date         := null;
5732     p_assignment_sequence        := null;
5733     p_comment_id                 := null;
5734     p_other_manager_warning      := null;
5735     p_hourly_salaried_warning    := null;
5736     p_cagr_concatenated_segments := null;
5737     p_assignment_id              := null;
5738     p_concatenated_segments      := null;
5739     p_group_name                 := null;
5740     p_gsp_post_process_warning   := null;
5741 
5742     ROLLBACK TO create_secondary_emp_asg;
5743     raise;
5744     --
5745     -- End of fix.
5746     --
5747 end create_secondary_emp_asg;
5748 --
5749 -- ----------------------------------------------------------------------------
5750 -- |---------------------< create_secondary_cwk_asg >-------------------------|
5751 -- ----------------------------------------------------------------------------
5752 --
5753 procedure create_secondary_cwk_asg
5754   (p_validate                     in     boolean
5755   ,p_effective_date               in     date
5756   ,p_business_group_id            in     number
5757   ,p_person_id                    in     number
5758   ,p_organization_id              in     number
5759   ,p_assignment_number            in out nocopy varchar2
5760   ,p_assignment_category          in     varchar2
5761   ,p_assignment_status_type_id    in     number
5762   ,p_change_reason                in     varchar2
5763   ,p_comments                     in     varchar2
5764   ,p_default_code_comb_id         in     number
5765   ,p_establishment_id             in     number
5766   ,p_frequency                    in     varchar2
5767   ,p_internal_address_line        in     varchar2
5768   ,p_job_id                       in     number
5769   ,p_labour_union_member_flag     in     varchar2
5770   ,p_location_id                  in     number
5771   ,p_manager_flag                 in     varchar2
5772   ,p_normal_hours                 in     number
5773   ,p_position_id                  in     number
5774   ,p_grade_id                     in     number
5775   ,p_project_title                in     varchar2
5776   ,p_set_of_books_id              in     number
5777   ,p_source_type                  in     varchar2
5778   ,p_supervisor_id                in     number
5779   ,p_time_normal_finish           in     varchar2
5780   ,p_time_normal_start            in     varchar2
5781   ,p_title                        in     varchar2
5782   ,p_vendor_assignment_number     in     varchar2
5783   ,p_vendor_employee_number       in     varchar2
5784   ,p_vendor_id                    in     number
5785   ,p_vendor_site_id               in     number
5786   ,p_po_header_id                 in     number
5787   ,p_po_line_id                   in     number
5788   ,p_projected_assignment_end     in     date
5789   ,p_attribute_category           in     varchar2
5790   ,p_attribute1                   in     varchar2
5791   ,p_attribute2                   in     varchar2
5792   ,p_attribute3                   in     varchar2
5793   ,p_attribute4                   in     varchar2
5794   ,p_attribute5                   in     varchar2
5795   ,p_attribute6                   in     varchar2
5796   ,p_attribute7                   in     varchar2
5797   ,p_attribute8                   in     varchar2
5798   ,p_attribute9                   in     varchar2
5799   ,p_attribute10                  in     varchar2
5800   ,p_attribute11                  in     varchar2
5801   ,p_attribute12                  in     varchar2
5802   ,p_attribute13                  in     varchar2
5803   ,p_attribute14                  in     varchar2
5804   ,p_attribute15                  in     varchar2
5805   ,p_attribute16                  in     varchar2
5806   ,p_attribute17                  in     varchar2
5807   ,p_attribute18                  in     varchar2
5808   ,p_attribute19                  in     varchar2
5809   ,p_attribute20                  in     varchar2
5810   ,p_attribute21                  in     varchar2
5811   ,p_attribute22                  in     varchar2
5812   ,p_attribute23                  in     varchar2
5813   ,p_attribute24                  in     varchar2
5814   ,p_attribute25                  in     varchar2
5815   ,p_attribute26                  in     varchar2
5816   ,p_attribute27                  in     varchar2
5817   ,p_attribute28                  in     varchar2
5818   ,p_attribute29                  in     varchar2
5819   ,p_attribute30                  in     varchar2
5820   ,p_pgp_segment1                 in     varchar2
5821   ,p_pgp_segment2                 in     varchar2
5822   ,p_pgp_segment3                 in     varchar2
5823   ,p_pgp_segment4                 in     varchar2
5824   ,p_pgp_segment5                 in     varchar2
5825   ,p_pgp_segment6                 in     varchar2
5826   ,p_pgp_segment7                 in     varchar2
5827   ,p_pgp_segment8                 in     varchar2
5828   ,p_pgp_segment9                 in     varchar2
5829   ,p_pgp_segment10                in     varchar2
5830   ,p_pgp_segment11                in     varchar2
5831   ,p_pgp_segment12                in     varchar2
5832   ,p_pgp_segment13                in     varchar2
5833   ,p_pgp_segment14                in     varchar2
5834   ,p_pgp_segment15                in     varchar2
5835   ,p_pgp_segment16                in     varchar2
5836   ,p_pgp_segment17                in     varchar2
5837   ,p_pgp_segment18                in     varchar2
5838   ,p_pgp_segment19                in     varchar2
5839   ,p_pgp_segment20                in     varchar2
5840   ,p_pgp_segment21                in     varchar2
5841   ,p_pgp_segment22                in     varchar2
5842   ,p_pgp_segment23                in     varchar2
5843   ,p_pgp_segment24                in     varchar2
5844   ,p_pgp_segment25                in     varchar2
5845   ,p_pgp_segment26                in     varchar2
5846   ,p_pgp_segment27                in     varchar2
5847   ,p_pgp_segment28                in     varchar2
5848   ,p_pgp_segment29                in     varchar2
5849   ,p_pgp_segment30                in     varchar2
5850   ,p_scl_segment1                 in     varchar2
5851   ,p_scl_segment2                 in     varchar2
5852   ,p_scl_segment3                 in     varchar2
5853   ,p_scl_segment4                 in     varchar2
5854   ,p_scl_segment5                 in     varchar2
5855   ,p_scl_segment6                 in     varchar2
5856   ,p_scl_segment7                 in     varchar2
5857   ,p_scl_segment8                 in     varchar2
5858   ,p_scl_segment9                 in     varchar2
5859   ,p_scl_segment10                in     varchar2
5860   ,p_scl_segment11                in     varchar2
5861   ,p_scl_segment12                in     varchar2
5862   ,p_scl_segment13                in     varchar2
5863   ,p_scl_segment14                in     varchar2
5864   ,p_scl_segment15                in     varchar2
5865   ,p_scl_segment16                in     varchar2
5866   ,p_scl_segment17                in     varchar2
5867   ,p_scl_segment18                in     varchar2
5868   ,p_scl_segment19                in     varchar2
5869   ,p_scl_segment20                in     varchar2
5870   ,p_scl_segment21                in     varchar2
5871   ,p_scl_segment22                in     varchar2
5872   ,p_scl_segment23                in     varchar2
5873   ,p_scl_segment24                in     varchar2
5874   ,p_scl_segment25                in     varchar2
5875   ,p_scl_segment26                in     varchar2
5876   ,p_scl_segment27                in     varchar2
5877   ,p_scl_segment28                in     varchar2
5878   ,p_scl_segment29                in     varchar2
5879   ,p_scl_segment30                in     varchar2
5880   ,p_scl_concat_segments          in     varchar2
5881   ,p_pgp_concat_segments	  in     varchar2
5882   ,p_supervisor_assignment_id     in     number
5883   ,p_assignment_id                   out nocopy number
5884   ,p_object_version_number           out nocopy number
5885   ,p_effective_start_date            out nocopy date
5886   ,p_effective_end_date              out nocopy date
5887   ,p_assignment_sequence             out nocopy number
5888   ,p_comment_id                      out nocopy number
5889   ,p_people_group_id                 out nocopy number
5890   ,p_people_group_name               out nocopy varchar2
5891   ,p_other_manager_warning           out nocopy boolean
5892   ,p_hourly_salaried_warning         out nocopy boolean
5893   ,p_soft_coding_keyflex_id          out nocopy number) IS
5894   --
5895   -- Declare LOCAL Variables
5896   --
5897   l_proc                    VARCHAR2(72) := g_package||'create_secondary_cwk_asg';
5898   l_effective_date          DATE;
5899   l_old_scl_conc_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
5900   l_old_group_name          pay_people_groups.group_name%TYPE;
5901   l_assignment_number       per_all_assignments_f.assignment_number%TYPE;
5902   l_other_manager_warning   BOOLEAN;
5903   l_hourly_salaried_warning BOOLEAN;
5904   l_assignment_id           per_all_assignments_f.assignment_id%TYPE;
5905   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE;
5906   l_people_group_id         per_all_assignments_f.people_group_id%TYPE;
5907   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
5908   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
5909   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
5910   l_assignment_sequence     per_all_assignments_f.assignment_sequence%TYPE;
5911   l_comment_id              per_all_assignments_f.comment_id%TYPE;
5912   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
5913   l_group_name              pay_people_groups.group_name%TYPE;
5914   l_session_id              NUMBER;
5915   l_business_group_id       per_business_groups.business_group_id%TYPE;
5916   l_legislation_code        per_business_groups.legislation_code%TYPE;
5917   l_pop_date_start          DATE;
5918   --l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
5919   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
5920   l_scl_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
5921   l_grp_flex_num            fnd_id_flex_segments.id_flex_num%TYPE;
5922   l_vendor_id               NUMBER := p_vendor_id;
5923   l_vendor_site_id          NUMBER := p_vendor_site_id;
5924   l_po_header_id            NUMBER := p_po_header_id;
5925   l_vendor_id_temp          NUMBER;
5926   l_vendor_site_id_temp     NUMBER;
5927   l_grade_id                NUMBER := Null; -- Bug 3545065
5928   --
5929   lv_assignment_number      varchar2(2000) :=   p_assignment_number ;
5930   --
5931   -- Declare Cursors
5932   --
5933   cursor csr_get_derived_details is
5934     select bus.business_group_id
5935          , bus.legislation_code
5936       from per_all_people_f    per
5937          , per_business_groups_perf bus
5938      where per.person_id         = p_person_id
5939      and   l_effective_date      between per.effective_start_date
5940                                  and     per.effective_end_date
5941      and   bus.business_group_id = per.business_group_id;
5942   --
5943   cursor csr_get_period_of_placement is
5944     select asg.period_of_placement_date_start
5945       from per_all_assignments_f asg
5946      where asg.person_id    = p_person_id
5947      and   l_effective_date between asg.effective_start_date
5948                             and     asg.effective_end_date
5949      and   asg.primary_flag = 'Y'
5950      and asg.assignment_type = 'C'; -- Bug fix 3266813
5951   --
5952   -- the cursor csr_grp_idsel selects the valid id_flex_num
5953   -- (grp keyflex) for the specified business group
5954   --
5955   cursor csr_grp_idsel is
5956     select people_group_structure
5957       from per_business_groups_perf
5958       where business_group_id = l_business_group_id;
5959   --
5960   --
5961   -- the cursor csr_scl_idsel selects the valid id_flex_num
5962   -- (scl keyflex) for the specified business group
5963   --
5964   cursor csr_scl_idsel is
5965     select plr.rule_mode                       id_flex_num
5966     from   pay_legislation_rules               plr
5967     where  plr.legislation_code                = l_legislation_code
5968     and    plr.rule_type                       = 'S'
5969     and    exists
5970           (select 1
5971            from   fnd_segment_attribute_values fsav
5972            where  fsav.id_flex_num             = plr.rule_mode
5973            and    fsav.application_id          = 800
5974            and    fsav.id_flex_code            = 'SCL'
5975            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
5976            and    fsav.attribute_value         = 'Y')
5977     and    exists
5978           (select 1
5979            from   pay_legislation_rules        plr2
5980            where  plr2.legislation_code        = l_legislation_code
5981            and    plr2.rule_type               = 'SDL'
5982            and    plr2.rule_mode               = 'A') ;
5983   --
5984 
5985 BEGIN
5986   --
5987  if g_debug then
5988   hr_utility.set_location('Entering:'|| l_proc, 5);
5989  end if;
5990   --
5991   -- Issue a savepoint.
5992   --
5993   -- Truncate the parameter p_effective_date and p_date_probation_end
5994   -- into local variables
5995   --
5996   l_effective_date := trunc(p_effective_date);
5997   --
5998   -- Bug 944911
5999   -- Amended p_scl_concatenated_segments to p_scl_concat_segments
6000   -- to be an out instead of in out
6001   --
6002   l_old_scl_conc_segments := p_scl_concat_segments;
6003   --
6004   -- Bug 944911
6005   -- Made p_group_name to be out param
6006   -- and add p_concat_segment to be IN
6007   -- in case of sec_asg alone made p_pgp_concat_segments as in param
6008   -- Replaced p_group_name by p_pgp_concat_segments
6009   --
6010   l_old_group_name := p_pgp_concat_segments;
6011   --
6012   SAVEPOINT create_secondary_cwk_asg;
6013   --
6014   BEGIN
6015     --
6016     -- Start of API User Hook for the before hook of create_secondary_emp_asg
6017     --
6018     hr_assignment_bkn.create_secondary_cwk_asg_b
6019       (p_effective_date               => l_effective_date
6020       ,p_business_group_id            => p_business_group_id
6021       ,p_person_id                    => p_person_id
6022       ,p_organization_id              => p_organization_id
6023       ,p_assignment_number            => p_assignment_number
6024       ,p_assignment_category          => p_assignment_category
6025       ,p_assignment_status_type_id    => p_assignment_status_type_id
6026       ,p_change_reason                => p_change_reason
6027       ,p_comments                     => p_comments
6028       ,p_default_code_comb_id         => p_default_code_comb_id
6029       ,p_establishment_id             => p_establishment_id
6030       ,p_frequency                    => p_frequency
6031       ,p_internal_address_line        => p_internal_address_line
6032       ,p_job_id                       => p_job_id
6033       ,p_labour_union_member_flag     => p_labour_union_member_flag
6034       ,p_location_id                  => p_location_id
6035       ,p_manager_flag                 => p_manager_flag
6036       ,p_normal_hours                 => p_normal_hours
6037       ,p_position_id                  => p_position_id
6038       ,p_grade_id                     => l_grade_id -- Bug 3545065
6039       ,p_project_title                => p_project_title
6040       ,p_set_of_books_id              => p_set_of_books_id
6041       ,p_source_type                  => p_source_type
6042       ,p_supervisor_id                => p_supervisor_id
6043       ,p_time_normal_finish           => p_time_normal_finish
6044       ,p_time_normal_start            => p_time_normal_start
6045       ,p_title                        => p_title
6046       ,p_vendor_assignment_number     => p_vendor_assignment_number
6047       ,p_vendor_employee_number       => p_vendor_employee_number
6048       ,p_vendor_id                    => p_vendor_id
6049       ,p_vendor_site_id               => p_vendor_site_id
6050       ,p_po_header_id                 => p_po_header_id
6051       ,p_po_line_id                   => p_po_line_id
6052       ,p_projected_assignment_end     => p_projected_assignment_end
6053       ,p_attribute_category           => p_attribute_category
6054       ,p_attribute1                   => p_attribute1
6055       ,p_attribute2                   => p_attribute2
6056       ,p_attribute3                   => p_attribute3
6057       ,p_attribute4                   => p_attribute4
6058       ,p_attribute5                   => p_attribute5
6059       ,p_attribute6                   => p_attribute6
6060       ,p_attribute7                   => p_attribute7
6061       ,p_attribute8                   => p_attribute8
6062       ,p_attribute9                   => p_attribute9
6063       ,p_attribute10                  => p_attribute10
6064       ,p_attribute11                  => p_attribute11
6065       ,p_attribute12                  => p_attribute12
6066       ,p_attribute13                  => p_attribute13
6067       ,p_attribute14                  => p_attribute14
6068       ,p_attribute15                  => p_attribute15
6069       ,p_attribute16                  => p_attribute16
6070       ,p_attribute17                  => p_attribute17
6071       ,p_attribute18                  => p_attribute18
6072       ,p_attribute19                  => p_attribute19
6073       ,p_attribute20                  => p_attribute20
6074       ,p_attribute21                  => p_attribute21
6075       ,p_attribute22                  => p_attribute22
6076       ,p_attribute23                  => p_attribute23
6077       ,p_attribute24                  => p_attribute24
6078       ,p_attribute25                  => p_attribute25
6079       ,p_attribute26                  => p_attribute26
6080       ,p_attribute27                  => p_attribute27
6081       ,p_attribute28                  => p_attribute28
6082       ,p_attribute29                  => p_attribute29
6083       ,p_attribute30                  => p_attribute30
6084    	  ,p_scl_concat_segments          => l_old_scl_conc_segments
6085       ,p_pgp_segment1                 => p_pgp_segment1
6086       ,p_pgp_segment2                 => p_pgp_segment2
6087       ,p_pgp_segment3                 => p_pgp_segment3
6088       ,p_pgp_segment4                 => p_pgp_segment4
6089       ,p_pgp_segment5                 => p_pgp_segment5
6090       ,p_pgp_segment6                 => p_pgp_segment6
6091       ,p_pgp_segment7                 => p_pgp_segment7
6092       ,p_pgp_segment8                 => p_pgp_segment8
6093       ,p_pgp_segment9                 => p_pgp_segment9
6094       ,p_pgp_segment10                => p_pgp_segment10
6095       ,p_pgp_segment11                => p_pgp_segment11
6096       ,p_pgp_segment12                => p_pgp_segment12
6097       ,p_pgp_segment13                => p_pgp_segment13
6098       ,p_pgp_segment14                => p_pgp_segment14
6099       ,p_pgp_segment15                => p_pgp_segment15
6100       ,p_pgp_segment16                => p_pgp_segment16
6101       ,p_pgp_segment17                => p_pgp_segment17
6102       ,p_pgp_segment18                => p_pgp_segment18
6103       ,p_pgp_segment19                => p_pgp_segment19
6104       ,p_pgp_segment20                => p_pgp_segment20
6105       ,p_pgp_segment21                => p_pgp_segment21
6106       ,p_pgp_segment22                => p_pgp_segment22
6107       ,p_pgp_segment23                => p_pgp_segment23
6108       ,p_pgp_segment24                => p_pgp_segment24
6109       ,p_pgp_segment25                => p_pgp_segment25
6110       ,p_pgp_segment26                => p_pgp_segment26
6111       ,p_pgp_segment27                => p_pgp_segment27
6112       ,p_pgp_segment28                => p_pgp_segment28
6113       ,p_pgp_segment29                => p_pgp_segment29
6114       ,p_pgp_segment30                => p_pgp_segment30
6115       ,p_scl_segment1                 => p_scl_segment1
6116       ,p_scl_segment2                 => p_scl_segment2
6117       ,p_scl_segment3                 => p_scl_segment3
6118       ,p_scl_segment4                 => p_scl_segment4
6119       ,p_scl_segment5                 => p_scl_segment5
6120       ,p_scl_segment6                 => p_scl_segment6
6121       ,p_scl_segment7                 => p_scl_segment7
6122       ,p_scl_segment8                 => p_scl_segment8
6123       ,p_scl_segment9                 => p_scl_segment9
6124       ,p_scl_segment10                => p_scl_segment10
6125       ,p_scl_segment11                => p_scl_segment11
6126       ,p_scl_segment12                => p_scl_segment12
6127       ,p_scl_segment13                => p_scl_segment13
6128       ,p_scl_segment14                => p_scl_segment14
6129       ,p_scl_segment15                => p_scl_segment15
6130       ,p_scl_segment16                => p_scl_segment16
6131       ,p_scl_segment17                => p_scl_segment17
6132       ,p_scl_segment18                => p_scl_segment18
6133       ,p_scl_segment19                => p_scl_segment19
6134       ,p_scl_segment20                => p_scl_segment20
6135       ,p_scl_segment21                => p_scl_segment21
6136       ,p_scl_segment22                => p_scl_segment22
6137       ,p_scl_segment23                => p_scl_segment23
6138       ,p_scl_segment24                => p_scl_segment24
6139       ,p_scl_segment25                => p_scl_segment25
6140       ,p_scl_segment26                => p_scl_segment26
6141       ,p_scl_segment27                => p_scl_segment27
6142       ,p_scl_segment28                => p_scl_segment28
6143       ,p_scl_segment29                => p_scl_segment29
6144       ,p_scl_segment30                => p_scl_segment30
6145       ,p_pgp_concat_segments          => l_old_group_name
6146       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
6147       );
6148     --
6149   EXCEPTION
6150     WHEN hr_api.cannot_find_prog_unit THEN
6151       hr_api.cannot_find_prog_unit_error
6152         (p_module_name => 'CREATE_SECONDARY_CWK_ASG'
6153         ,p_hook_type   => 'BP');
6154     --
6155     -- End of API User Hook for the before hook of create_secondary_emp_asg
6156     --
6157   END;
6158   --
6159  if g_debug then
6160   hr_utility.set_location(l_proc, 10);
6161  end if;
6162   --
6163   -- Validation in addition to Table Handlers
6164   --
6165   -- Get person details.
6166   --
6167   hr_api.mandatory_arg_error
6168      (p_api_name       => l_proc
6169      ,p_argument       => 'person_id'
6170      ,p_argument_value => p_person_id
6171      );
6172   --
6173   hr_api.mandatory_arg_error
6174      (p_api_name       => l_proc
6175      ,p_argument       => 'effective_date'
6176      ,p_argument_value => l_effective_date
6177      );
6178   --
6179   -- Record the value of in out parameters
6180   --
6181   l_assignment_number := p_assignment_number;
6182   --
6183   OPEN  csr_get_derived_details;
6184   FETCH csr_get_derived_details
6185    INTO l_business_group_id
6186       , l_legislation_code;
6187   --
6188   if csr_get_derived_details%NOTFOUND then
6189     --
6190     close csr_get_derived_details;
6191     --
6192  if g_debug then
6193     hr_utility.set_location(l_proc, 15);
6194  end if;
6195     --
6196     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
6197     hr_utility.raise_error;
6198 	--
6199   end if;
6200   --
6201   close csr_get_derived_details;
6202   --
6203  if g_debug then
6204   hr_utility.set_location(l_proc, 20);
6205  end if;
6206   --
6207   -- Process Logic
6208   --
6209   -- Get period of service from primary assignment.
6210   --
6211   OPEN  csr_get_period_of_placement;
6212   FETCH csr_get_period_of_placement INTO l_pop_date_start;
6213   --
6214   IF csr_get_period_of_placement%NOTFOUND THEN
6215     --
6216     CLOSE csr_get_period_of_placement;
6217     --
6218  if g_debug then
6219     hr_utility.set_location(l_proc, 25);
6220  end if;
6221     --
6222 	hr_utility.set_message(801,'HR_7436_ASG_NO_PRIM_ASS');
6223     hr_utility.raise_error;
6224 	--
6225   END IF;
6226   --
6227   CLOSE csr_get_period_of_placement;
6228   --
6229  if g_debug then
6230   hr_utility.set_location(l_proc, 26);
6231  end if;
6232   --
6233   -- insert the profile options and effective date for the flexfield
6234   -- validation to work
6235   --
6236   hr_kflex_utility.set_profiles
6237     (p_business_group_id => l_business_group_id
6238     ,p_assignment_id     => l_assignment_id
6239     ,p_organization_id   => p_organization_id
6240     ,p_location_id       => p_location_id);
6241   --
6242   hr_kflex_utility.set_session_date
6243     (p_effective_date => l_effective_date
6244     ,p_session_id     => l_session_id);
6245   --
6246   open csr_grp_idsel;
6247   fetch csr_grp_idsel into l_grp_flex_num;
6248   --
6249   if csr_grp_idsel%NOTFOUND then
6250     --
6251     close csr_grp_idsel;
6252 	--
6253     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
6254     hr_utility.set_message_token('PROCEDURE', l_proc);
6255     hr_utility.set_message_token('STEP','5');
6256     hr_utility.raise_error;
6257 	--
6258   else
6259     --
6260     close csr_grp_idsel;
6261 	--
6262   end if;
6263   --
6264  if g_debug then
6265   hr_utility.set_location(l_proc, 27);
6266  end if;
6267   --
6268   if   p_scl_segment1 is not null
6269     or p_scl_segment2 is not null
6270     or p_scl_segment3 is not null
6271     or p_scl_segment4 is not null
6272     or p_scl_segment5 is not null
6273     or p_scl_segment6 is not null
6274     or p_scl_segment7 is not null
6275     or p_scl_segment8 is not null
6276     or p_scl_segment9 is not null
6277     or p_scl_segment10 is not null
6278     or p_scl_segment11 is not null
6279     or p_scl_segment12 is not null
6280     or p_scl_segment13 is not null
6281     or p_scl_segment14 is not null
6282     or p_scl_segment15 is not null
6283     or p_scl_segment16 is not null
6284     or p_scl_segment17 is not null
6285     or p_scl_segment18 is not null
6286     or p_scl_segment19 is not null
6287     or p_scl_segment20 is not null
6288     or p_scl_segment21 is not null
6289     or p_scl_segment22 is not null
6290     or p_scl_segment23 is not null
6291     or p_scl_segment24 is not null
6292     or p_scl_segment25 is not null
6293     or p_scl_segment26 is not null
6294     or p_scl_segment27 is not null
6295     or p_scl_segment28 is not null
6296     or p_scl_segment29 is not null
6297     or p_scl_segment30 is not null
6298     or p_scl_concat_segments is not null then
6299 	--
6300     open csr_scl_idsel;
6301     fetch csr_scl_idsel into l_scl_flex_num;
6302 	--
6303     if csr_scl_idsel%NOTFOUND then
6304 	  --
6305       close csr_scl_idsel;
6306 	  --
6307  if g_debug then
6308       hr_utility.set_location(l_proc, 28);
6309  end if;
6310       hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
6311       hr_utility.set_message_token('PROCEDURE', l_proc);
6312       hr_utility.set_message_token('STEP','10');
6313       hr_utility.raise_error;
6314 	  --
6315     else
6316 	  --
6317       close csr_scl_idsel;
6318       --
6319  if g_debug then
6320       hr_utility.set_location(l_proc, 30);
6321  end if;
6322       --
6323       -- Insert or select the soft_coding_keyflex_id
6324       --
6325       hr_kflex_utility.ins_or_sel_keyflex_comb
6326         (p_appl_short_name        => 'PER'
6327         ,p_flex_code              => 'SCL'
6328         ,p_flex_num               => l_scl_flex_num
6329         ,p_segment1               => p_scl_segment1
6330         ,p_segment2               => p_scl_segment2
6331         ,p_segment3               => p_scl_segment3
6332         ,p_segment4               => p_scl_segment4
6333         ,p_segment5               => p_scl_segment5
6334         ,p_segment6               => p_scl_segment6
6335         ,p_segment7               => p_scl_segment7
6336         ,p_segment8               => p_scl_segment8
6337         ,p_segment9               => p_scl_segment9
6338         ,p_segment10              => p_scl_segment10
6339         ,p_segment11              => p_scl_segment11
6340         ,p_segment12              => p_scl_segment12
6341         ,p_segment13              => p_scl_segment13
6342         ,p_segment14              => p_scl_segment14
6343         ,p_segment15              => p_scl_segment15
6344         ,p_segment16              => p_scl_segment16
6345         ,p_segment17              => p_scl_segment17
6346         ,p_segment18              => p_scl_segment18
6347         ,p_segment19              => p_scl_segment19
6348         ,p_segment20              => p_scl_segment20
6349         ,p_segment21              => p_scl_segment21
6350         ,p_segment22              => p_scl_segment22
6351         ,p_segment23              => p_scl_segment23
6352         ,p_segment24              => p_scl_segment24
6353         ,p_segment25              => p_scl_segment25
6354         ,p_segment26              => p_scl_segment26
6355         ,p_segment27              => p_scl_segment27
6356         ,p_segment28              => p_scl_segment28
6357         ,p_segment29              => p_scl_segment29
6358         ,p_segment30              => p_scl_segment30
6359         ,p_concat_segments_in     => l_old_scl_conc_segments
6360         ,p_ccid                   => l_soft_coding_keyflex_id
6361         ,p_concat_segments_out    => l_concatenated_segments);
6362       --
6363       -- update the combinations column
6364       --
6365       update_scl_concat_segs
6366       (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
6367       ,p_concatenated_segments   => l_concatenated_segments
6368       );
6369       --
6370     end if;
6371     --
6372   end if;
6373   --
6374   -- Insert of select the people_group_id.
6375   --
6376   hr_kflex_utility.ins_or_sel_keyflex_comb
6377     (p_appl_short_name        => 'PAY'
6378     ,p_flex_code              => 'GRP'
6379     ,p_flex_num               => l_grp_flex_num
6380     ,p_segment1               => p_pgp_segment1
6381     ,p_segment2               => p_pgp_segment2
6382     ,p_segment3               => p_pgp_segment3
6383     ,p_segment4               => p_pgp_segment4
6384     ,p_segment5               => p_pgp_segment5
6385     ,p_segment6               => p_pgp_segment6
6386     ,p_segment7               => p_pgp_segment7
6387     ,p_segment8               => p_pgp_segment8
6388     ,p_segment9               => p_pgp_segment9
6389     ,p_segment10              => p_pgp_segment10
6390     ,p_segment11              => p_pgp_segment11
6391     ,p_segment12              => p_pgp_segment12
6392     ,p_segment13              => p_pgp_segment13
6393     ,p_segment14              => p_pgp_segment14
6394     ,p_segment15              => p_pgp_segment15
6395     ,p_segment16              => p_pgp_segment16
6396     ,p_segment17              => p_pgp_segment17
6397     ,p_segment18              => p_pgp_segment18
6398     ,p_segment19              => p_pgp_segment19
6399     ,p_segment20              => p_pgp_segment20
6400     ,p_segment21              => p_pgp_segment21
6401     ,p_segment22              => p_pgp_segment22
6402     ,p_segment23              => p_pgp_segment23
6403     ,p_segment24              => p_pgp_segment24
6404     ,p_segment25              => p_pgp_segment25
6405     ,p_segment26              => p_pgp_segment26
6406     ,p_segment27              => p_pgp_segment27
6407     ,p_segment28              => p_pgp_segment28
6408     ,p_segment29              => p_pgp_segment29
6409     ,p_segment30              => p_pgp_segment30
6410     ,p_concat_segments_in     => l_old_group_name
6411     ,p_ccid                   => l_people_group_id
6412     ,p_concat_segments_out    => l_group_name
6413     );
6414   --
6415  if g_debug then
6416   hr_utility.set_location(l_proc, 35);
6417  end if;
6418 
6419   --
6420   -- Default the PO Header if the line is passed in and the
6421   -- header is not.
6422   --
6423   IF p_po_line_id IS NOT NULL AND l_po_header_id IS NULL THEN
6424 
6425     l_po_header_id := get_po_for_line
6426       (p_po_line_id => p_po_line_id);
6427 
6428   END IF;
6429 
6430   --
6431   -- Default the Supplier if the Site is entered and Supplier is not.
6432   --
6433   IF l_vendor_site_id IS NOT NULL AND l_vendor_id IS NULL THEN
6434 
6435     l_vendor_id := get_supplier_for_site
6436       (p_vendor_site_id => l_vendor_site_id);
6437 
6438   END IF;
6439 
6440   --
6441   -- Default the supplier details if they are not entered and a
6442   -- PO is given.
6443   --
6444   IF l_po_header_id IS NOT NULL
6445   AND (l_vendor_id IS NULL OR l_vendor_site_id IS NULL) THEN
6446 
6447     --
6448     -- Copy the variables temporarily so that if one or the
6449     -- other values are passed in, the below call does not
6450     -- override them.  A single call is made because it is
6451     -- more performant.
6452     --
6453     get_supplier_info_for_po
6454       (p_po_header_id   => l_po_header_id
6455       ,p_vendor_id      => l_vendor_id_temp
6456       ,p_vendor_site_id => l_vendor_site_id_temp);
6457 
6458     IF l_vendor_id IS NULL THEN
6459       l_vendor_id := l_vendor_id_temp;
6460     END IF;
6461 
6462     IF l_vendor_site_id IS NULL THEN
6463       l_vendor_site_id := l_vendor_site_id_temp;
6464     END IF;
6465 
6466   END IF;
6467 
6468  if g_debug then
6469   hr_utility.set_location(l_proc, 37);
6470  end if;
6471 
6472   --
6473   -- update the combinations column
6474   --
6475   update_pgp_concat_segs
6476     (p_people_group_id        => l_people_group_id
6477     ,p_group_name             => l_group_name);
6478   --
6479   -- select or insert the Collective Agreement grade
6480   --
6481   /*
6482   hr_cgd_ins.ins_or_sel
6483     (p_segment1               => p_cag_segment1
6484     ,p_segment2               => p_cag_segment2
6485     ,p_segment3               => p_cag_segment3
6486     ,p_segment4               => p_cag_segment4
6487     ,p_segment5               => p_cag_segment5
6488     ,p_segment6               => p_cag_segment6
6489     ,p_segment7               => p_cag_segment7
6490     ,p_segment8               => p_cag_segment8
6491     ,p_segment9               => p_cag_segment9
6492     ,p_segment10              => p_cag_segment10
6493     ,p_segment11              => p_cag_segment11
6494     ,p_segment12              => p_cag_segment12
6495     ,p_segment13              => p_cag_segment13
6496     ,p_segment14              => p_cag_segment14
6497     ,p_segment15              => p_cag_segment15
6498     ,p_segment16              => p_cag_segment16
6499     ,p_segment17              => p_cag_segment17
6500     ,p_segment18              => p_cag_segment18
6501     ,p_segment19              => p_cag_segment19
6502     ,p_segment20              => p_cag_segment20
6503     ,p_id_flex_num            => p_cagr_id_flex_num
6504     ,p_business_group_id      => l_business_group_id
6505     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
6506     ,p_concatenated_segments  => l_cagr_concatenated_segments);
6507 	*/
6508   --
6509   -- Insert secondary assignment
6510   --
6511   hr_assignment_internal.create_cwk_asg
6512     (p_validate                     => p_validate
6513     ,p_effective_date               => l_effective_date
6514     ,p_business_group_id            => l_business_group_id
6515     ,p_legislation_code             => l_legislation_code
6516     ,p_person_id                    => p_person_id
6517     ,p_placement_date_start         => l_pop_date_start
6518     ,p_organization_id              => p_organization_id
6519     ,p_primary_flag                 => 'N'
6520     ,p_assignment_number            => l_assignment_number
6521     ,p_assignment_category          => null
6522     ,p_assignment_status_type_id    => p_assignment_status_type_id
6523     ,p_change_reason                => p_change_reason
6524     ,p_comments                     => p_comments
6525     ,p_default_code_comb_id         => p_default_code_comb_id
6526     ,p_employment_category          => p_assignment_category
6527     ,p_establishment_id             => p_establishment_id
6528     ,p_frequency                    => p_frequency
6529     ,p_internal_address_line        => p_internal_address_line
6530     ,p_job_id                       => p_job_id
6531     ,p_labor_union_member_flag      => p_labour_union_member_flag
6532     ,p_location_id                  => p_location_id
6533     ,p_manager_flag                 => p_manager_flag
6534     ,p_normal_hours                 => p_normal_hours
6535     ,p_position_id                  => p_position_id
6536     -- Bug 3545065, Grade should not be maintained for CWK asg
6537     -- ,p_grade_id                     => p_grade_id
6538     ,p_project_title                => p_project_title
6539     ,p_title                        => p_title
6540     ,p_set_of_books_id              => p_set_of_books_id
6541     ,p_source_type                  => p_source_type
6542     ,p_supervisor_id                => p_supervisor_id
6543     ,p_time_normal_start            => p_time_normal_start
6544     ,p_time_normal_finish           => p_time_normal_finish
6545     ,p_vendor_assignment_number     => p_vendor_assignment_number
6546     ,p_vendor_employee_number       => p_vendor_employee_number
6547     ,p_vendor_id                    => l_vendor_id
6548     ,p_vendor_site_id               => l_vendor_site_id
6549     ,p_po_header_id                 => l_po_header_id
6550     ,p_po_line_id                   => p_po_line_id
6551     ,p_projected_assignment_end     => p_projected_assignment_end
6552     ,p_people_group_id              => l_people_group_id
6553     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
6554     ,p_ass_attribute_category       => p_attribute_category
6555     ,p_ass_attribute1               => p_attribute1
6556     ,p_ass_attribute2               => p_attribute2
6557     ,p_ass_attribute3               => p_attribute3
6558     ,p_ass_attribute4               => p_attribute4
6559     ,p_ass_attribute5               => p_attribute5
6560     ,p_ass_attribute6               => p_attribute6
6561     ,p_ass_attribute7               => p_attribute7
6562     ,p_ass_attribute8               => p_attribute8
6563     ,p_ass_attribute9               => p_attribute9
6564     ,p_ass_attribute10              => p_attribute10
6565     ,p_ass_attribute11              => p_attribute11
6566     ,p_ass_attribute12              => p_attribute12
6567     ,p_ass_attribute13              => p_attribute13
6568     ,p_ass_attribute14              => p_attribute14
6569     ,p_ass_attribute15              => p_attribute15
6570     ,p_ass_attribute16              => p_attribute16
6571     ,p_ass_attribute17              => p_attribute17
6572     ,p_ass_attribute18              => p_attribute18
6573     ,p_ass_attribute19              => p_attribute19
6574     ,p_ass_attribute20              => p_attribute20
6575     ,p_ass_attribute21              => p_attribute21
6576     ,p_ass_attribute22              => p_attribute22
6577     ,p_ass_attribute23              => p_attribute23
6578     ,p_ass_attribute24              => p_attribute24
6579     ,p_ass_attribute25              => p_attribute25
6580     ,p_ass_attribute26              => p_attribute26
6581     ,p_ass_attribute27              => p_attribute27
6582     ,p_ass_attribute28              => p_attribute28
6583     ,p_ass_attribute29              => p_attribute29
6584     ,p_ass_attribute30              => p_attribute30
6585     ,p_assignment_id                => l_assignment_id
6586     ,p_object_version_number        => l_object_version_number
6587     ,p_effective_start_date         => l_effective_start_date
6588     ,p_effective_end_date           => l_effective_end_date
6589     ,p_assignment_sequence          => l_assignment_sequence
6590     ,p_comment_id                   => l_comment_id
6591     ,p_other_manager_warning        => l_other_manager_warning
6592     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
6593     );
6594   --
6595   -- add rows to the security table if it is a current assignment.
6596   --
6597   if(l_effective_date <= sysdate) then
6598     --
6599     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
6600 	--
6601   end if;
6602   --
6603  if g_debug then
6604   hr_utility.set_location(l_proc, 40);
6605  end if;
6606   --
6607   BEGIN
6608     --
6609     -- Start of API User Hook for the after hook of create_secondary_emp_asg
6610     --
6611     -- Bug 944911
6612     -- No amendments required for outs as the values carried forward
6613     -- Adding the 2 additional ins - p_concat_segments and p_pgp_concat_segments
6614     -- Both with the same value as passed to _b proc
6615 	--
6616     hr_assignment_bkn.create_secondary_cwk_asg_a
6617       (p_effective_date               => l_effective_date
6618       ,p_business_group_id            => p_business_group_id
6619       ,p_person_id                    => p_person_id
6620       ,p_organization_id              => p_organization_id
6621       ,p_assignment_number            => l_assignment_number
6622       ,p_assignment_category          => p_assignment_category
6623       ,p_assignment_status_type_id    => p_assignment_status_type_id
6624       ,p_change_reason                => p_change_reason
6625       ,p_comments                     => p_comments
6626       ,p_default_code_comb_id         => p_default_code_comb_id
6627       ,p_establishment_id             => p_establishment_id
6628       ,p_frequency                    => p_frequency
6629       ,p_internal_address_line        => p_internal_address_line
6630       ,p_job_id                       => p_job_id
6631       ,p_labour_union_member_flag     => p_labour_union_member_flag
6632       ,p_location_id                  => p_location_id
6633       ,p_manager_flag                 => p_manager_flag
6634       ,p_normal_hours                 => p_normal_hours
6635       ,p_position_id                  => p_position_id
6636       ,p_grade_id                     => l_grade_id -- Bug 3545065
6637       ,p_project_title                => p_project_title
6638       ,p_set_of_books_id              => p_set_of_books_id
6639       ,p_source_type                  => p_source_type
6640       ,p_supervisor_id                => p_supervisor_id
6641       ,p_time_normal_finish           => p_time_normal_finish
6642       ,p_time_normal_start            => p_time_normal_start
6643       ,p_title                        => p_title
6644       ,p_vendor_assignment_number     => p_vendor_assignment_number
6645       ,p_vendor_employee_number       => p_vendor_employee_number
6646       ,p_vendor_id                    => l_vendor_id
6647       ,p_vendor_site_id               => l_vendor_site_id
6648       ,p_po_header_id                 => l_po_header_id
6649       ,p_po_line_id                   => p_po_line_id
6650       ,p_projected_assignment_end     => p_projected_assignment_end
6651       ,p_attribute_category           => p_attribute_category
6652       ,p_attribute1                   => p_attribute1
6653       ,p_attribute2                   => p_attribute2
6654       ,p_attribute3                   => p_attribute3
6655       ,p_attribute4                   => p_attribute4
6656       ,p_attribute5                   => p_attribute5
6657       ,p_attribute6                   => p_attribute6
6658       ,p_attribute7                   => p_attribute7
6659       ,p_attribute8                   => p_attribute8
6660       ,p_attribute9                   => p_attribute9
6661       ,p_attribute10                  => p_attribute10
6662       ,p_attribute11                  => p_attribute11
6663       ,p_attribute12                  => p_attribute12
6664       ,p_attribute13                  => p_attribute13
6665       ,p_attribute14                  => p_attribute14
6666       ,p_attribute15                  => p_attribute15
6667       ,p_attribute16                  => p_attribute16
6668       ,p_attribute17                  => p_attribute17
6669       ,p_attribute18                  => p_attribute18
6670       ,p_attribute19                  => p_attribute19
6671       ,p_attribute20                  => p_attribute20
6672       ,p_attribute21                  => p_attribute21
6673       ,p_attribute22                  => p_attribute22
6674       ,p_attribute23                  => p_attribute23
6675       ,p_attribute24                  => p_attribute24
6676       ,p_attribute25                  => p_attribute25
6677       ,p_attribute26                  => p_attribute26
6678       ,p_attribute27                  => p_attribute27
6679       ,p_attribute28                  => p_attribute28
6680       ,p_attribute29                  => p_attribute29
6681       ,p_attribute30                  => p_attribute30
6682       ,p_scl_concat_segments          => l_old_scl_conc_segments
6683       ,p_pgp_segment1                 => p_pgp_segment1
6684       ,p_pgp_segment2                 => p_pgp_segment2
6685       ,p_pgp_segment3                 => p_pgp_segment3
6686       ,p_pgp_segment4                 => p_pgp_segment4
6687       ,p_pgp_segment5                 => p_pgp_segment5
6688       ,p_pgp_segment6                 => p_pgp_segment6
6689       ,p_pgp_segment7                 => p_pgp_segment7
6690       ,p_pgp_segment8                 => p_pgp_segment8
6691       ,p_pgp_segment9                 => p_pgp_segment9
6692       ,p_pgp_segment10                => p_pgp_segment10
6693       ,p_pgp_segment11                => p_pgp_segment11
6694       ,p_pgp_segment12                => p_pgp_segment12
6695       ,p_pgp_segment13                => p_pgp_segment13
6696       ,p_pgp_segment14                => p_pgp_segment14
6697       ,p_pgp_segment15                => p_pgp_segment15
6698       ,p_pgp_segment16                => p_pgp_segment16
6699       ,p_pgp_segment17                => p_pgp_segment17
6700       ,p_pgp_segment18                => p_pgp_segment18
6701       ,p_pgp_segment19                => p_pgp_segment19
6702       ,p_pgp_segment20                => p_pgp_segment20
6703       ,p_pgp_segment21                => p_pgp_segment21
6704       ,p_pgp_segment22                => p_pgp_segment22
6705       ,p_pgp_segment23                => p_pgp_segment23
6706       ,p_pgp_segment24                => p_pgp_segment24
6707       ,p_pgp_segment25                => p_pgp_segment25
6708       ,p_pgp_segment26                => p_pgp_segment26
6709       ,p_pgp_segment27                => p_pgp_segment27
6710       ,p_pgp_segment28                => p_pgp_segment28
6711       ,p_pgp_segment29                => p_pgp_segment29
6712       ,p_pgp_segment30                => p_pgp_segment30
6713       ,p_scl_segment1                 => p_scl_segment1
6714       ,p_scl_segment2                 => p_scl_segment2
6715       ,p_scl_segment3                 => p_scl_segment3
6716       ,p_scl_segment4                 => p_scl_segment4
6717       ,p_scl_segment5                 => p_scl_segment5
6718       ,p_scl_segment6                 => p_scl_segment6
6719       ,p_scl_segment7                 => p_scl_segment7
6720       ,p_scl_segment8                 => p_scl_segment8
6721       ,p_scl_segment9                 => p_scl_segment9
6722       ,p_scl_segment10                => p_scl_segment10
6723       ,p_scl_segment11                => p_scl_segment11
6724       ,p_scl_segment12                => p_scl_segment12
6725       ,p_scl_segment13                => p_scl_segment13
6726       ,p_scl_segment14                => p_scl_segment14
6727       ,p_scl_segment15                => p_scl_segment15
6728       ,p_scl_segment16                => p_scl_segment16
6729       ,p_scl_segment17                => p_scl_segment17
6730       ,p_scl_segment18                => p_scl_segment18
6731       ,p_scl_segment19                => p_scl_segment19
6732       ,p_scl_segment20                => p_scl_segment20
6733       ,p_scl_segment21                => p_scl_segment21
6734       ,p_scl_segment22                => p_scl_segment22
6735       ,p_scl_segment23                => p_scl_segment23
6736       ,p_scl_segment24                => p_scl_segment24
6737       ,p_scl_segment25                => p_scl_segment25
6738       ,p_scl_segment26                => p_scl_segment26
6739       ,p_scl_segment27                => p_scl_segment27
6740       ,p_scl_segment28                => p_scl_segment28
6741       ,p_scl_segment29                => p_scl_segment29
6742       ,p_scl_segment30                => p_scl_segment30
6743       ,p_pgp_concat_segments          => l_old_group_name
6744       ,p_assignment_id                => l_assignment_id
6745       ,p_object_version_number        => l_object_version_number
6746       ,p_effective_start_date         => l_effective_start_date
6747       ,p_effective_end_date           => l_effective_end_date
6748       ,p_assignment_sequence          => l_assignment_sequence
6749       ,p_comment_id                   => l_comment_id
6750       ,p_people_group_id              => l_people_group_id
6751       ,p_people_group_name            => l_group_name
6752       ,p_other_manager_warning        => l_other_manager_warning
6753       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
6754       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
6755       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
6756       );
6757     --
6758   EXCEPTION
6759     --
6760     WHEN hr_api.cannot_find_prog_unit THEN
6761 	  --
6762       hr_api.cannot_find_prog_unit_error
6763         (p_module_name => 'CREATE_SECONDARY_CWK_ASG'
6764         ,p_hook_type   => 'AP');
6765     --
6766     -- End of API User Hook for the after hook of create_secondary_emp_asg
6767     --
6768   END;
6769   --
6770   -- When in validation only mode raise the Validate_Enabled exception
6771   --
6772   IF p_validate THEN
6773     --
6774     RAISE hr_api.validate_enabled;
6775 	--
6776   END IF;
6777   --
6778   -- Set remaining output arguments
6779   --
6780   p_assignment_number          := l_assignment_number;
6781   p_assignment_id              := l_assignment_id;
6782   p_soft_coding_keyflex_id     := l_soft_coding_keyflex_id;
6783   p_people_group_id            := l_people_group_id;
6784   p_object_version_number      := l_object_version_number;
6785   p_effective_start_date       := l_effective_start_date;
6786   p_effective_end_date         := l_effective_end_date;
6787   p_assignment_sequence        := l_assignment_sequence;
6788   p_comment_id                 := l_comment_id;
6789   p_people_group_name          := l_group_name;
6790   p_other_manager_warning      := l_other_manager_warning;
6791   p_hourly_salaried_warning    := l_hourly_salaried_warning;
6792   --
6793   -- remove data from the session table
6794   --
6795   hr_kflex_utility.unset_session_date
6796     (p_session_id     => l_session_id);
6797   --
6798  if g_debug then
6799   hr_utility.set_location(' Leaving:'||l_proc, 999);
6800  end if;
6801   --
6802 EXCEPTION
6803   --
6804   WHEN hr_api.validate_enabled THEN
6805     --
6806     -- As the Validate_Enabled exception has been raised
6807     -- we must rollback to the savepoint
6808     --
6809     ROLLBACK TO create_secondary_cwk_asg;
6810     --
6811     -- Only set output warning arguments
6812     -- (Any key or derived arguments must be set to null
6813     -- when validation only mode is being used.)
6814     --
6815     p_assignment_number       := l_assignment_number;
6816     p_assignment_id           := NULL;
6817     p_soft_coding_keyflex_id  := NULL;
6818     p_people_group_id         := NULL;
6819     p_object_version_number   := NULL;
6820     p_effective_start_date    := NULL;
6821     p_effective_end_date      := NULL;
6822     p_assignment_sequence     := NULL;
6823     p_comment_id              := NULL;
6824     p_people_group_name       := l_old_group_name;
6825     p_other_manager_warning   := l_other_manager_warning;
6826     p_hourly_salaried_warning := l_hourly_salaried_warning;
6827     --
6828   WHEN others THEN
6829     --
6830     -- A validation or unexpected error has occurred
6831     --
6832     -- Added as part of fix to bug 632479
6833     --
6834     p_assignment_number := lv_assignment_number ;
6835 
6836     p_assignment_id             := NULL;
6837     p_object_version_number     := NULL;
6838     p_effective_start_date      := NULL;
6839     p_effective_end_date        := NULL;
6840     p_assignment_sequence       := NULL;
6841     p_comment_id                := NULL;
6842     p_people_group_id           := NULL;
6843     p_people_group_name         := NULL;
6844     p_other_manager_warning     := NULL;
6845     p_hourly_salaried_warning   := NULL;
6846     p_soft_coding_keyflex_id    := NULL;
6847 
6848     ROLLBACK TO create_secondary_cwk_asg;
6849     RAISE;
6850     --
6851     -- End of fix.
6852     --
6853 END create_secondary_cwk_asg;
6854 --
6855 -- ----------------------------------------------------------------------------
6856 -- |---------------------< get_supplier_info_for_po >--------------------------|
6857 -- ----------------------------------------------------------------------------
6858 --
6859 PROCEDURE get_supplier_info_for_po
6860   (p_po_header_id                 IN            NUMBER
6861   ,p_vendor_id                       OUT NOCOPY NUMBER
6862   ,p_vendor_site_id                  OUT NOCOPY NUMBER)
6863 IS
6864 
6865   l_proc              VARCHAR2(72)  :=  g_package||'get_supplier_info_for_po';
6866 
6867   --
6868   -- Fetch the Supplier and Supplier Site.
6869   --
6870   CURSOR csr_get_supplier_info IS
6871   SELECT poh.vendor_id
6872         ,poh.vendor_site_id
6873   FROM   po_temp_labor_headers_v poh
6874   WHERE  poh.po_header_id = p_po_header_id;
6875 
6876 BEGIN
6877 
6878   IF g_debug THEN
6879     hr_utility.set_location('Entering: ' || l_proc, 10);
6880   END IF;
6881 
6882   --
6883   -- If the header is not null, fetch the Supplier info.
6884   --
6885   IF p_po_header_id IS NOT NULL THEN
6886 
6887     IF g_debug THEN
6888       hr_utility.set_location(l_proc, 20);
6889     END IF;
6890 
6891     OPEN  csr_get_supplier_info;
6892     FETCH csr_get_supplier_info INTO p_vendor_id
6893                                     ,p_vendor_site_id;
6894     CLOSE csr_get_supplier_info;
6895 
6896   END IF;
6897 
6898   IF g_debug THEN
6899     hr_utility.set_location('Leaving: ' || l_proc, 999);
6900   END IF;
6901 
6902 END get_supplier_info_for_po;
6903 --
6904 -- ----------------------------------------------------------------------------
6905 -- |---------------------< get_supplier_for_site >-----------------------------|
6906 -- ----------------------------------------------------------------------------
6907 --
6908 FUNCTION get_supplier_for_site
6909   (p_vendor_site_id               IN     NUMBER)
6910 RETURN NUMBER IS
6911 
6912   l_proc              VARCHAR2(72)  :=  g_package||'get_supplier_for_site';
6913   l_vendor_id         NUMBER;
6914 
6915   --
6916   -- Fetch the Supplier and Supplier Site.
6917   --
6918   CURSOR csr_get_supplier IS
6919   SELECT povs.vendor_id
6920   FROM   po_vendor_sites_all povs
6921   WHERE  povs.vendor_site_id = p_vendor_site_id;
6922 
6923 BEGIN
6924 
6925   IF g_debug THEN
6926     hr_utility.set_location('Entering: ' || l_proc, 10);
6927   END IF;
6928 
6929   --
6930   -- If the Supplier Site is not null, fetch the Supplier.
6931   --
6932   IF p_vendor_site_id IS NOT NULL THEN
6933 
6934     IF g_debug THEN
6935       hr_utility.set_location(l_proc, 20);
6936     END IF;
6937 
6938     OPEN  csr_get_supplier;
6939     FETCH csr_get_supplier INTO l_vendor_id;
6940     CLOSE csr_get_supplier;
6941 
6942   END IF;
6943 
6944   IF g_debug THEN
6945     hr_utility.set_location('Leaving: ' || l_proc, 999);
6946   END IF;
6947 
6948   RETURN l_vendor_id;
6949 
6950 END get_supplier_for_site;
6951 --
6952 -- ----------------------------------------------------------------------------
6953 -- |---------------------< get_po_for_line >-----------------------------------|
6954 -- ----------------------------------------------------------------------------
6955 --
6956 FUNCTION get_po_for_line
6957   (p_po_line_id                   IN     NUMBER)
6958 RETURN NUMBER IS
6959 
6960   l_proc              VARCHAR2(72)  :=  g_package||'get_po_for_line';
6961   l_po_header_id      NUMBER;
6962 
6963   --
6964   -- Fetch the Purchase Order given a line.
6965   --
6966   CURSOR csr_get_po IS
6967   SELECT pol.po_header_id
6968   FROM   po_temp_labor_lines_v pol
6969   WHERE  pol.po_line_id = p_po_line_id;
6970 
6971 BEGIN
6972 
6973   IF g_debug THEN
6974     hr_utility.set_location('Entering: ' || l_proc, 10);
6975   END IF;
6976 
6977   --
6978   -- If the PO Line is not null, fetch the PO (header).
6979   --
6980   IF p_po_line_id IS NOT NULL THEN
6981 
6982     IF g_debug THEN
6983       hr_utility.set_location(l_proc, 20);
6984     END IF;
6985 
6986     OPEN  csr_get_po;
6987     FETCH csr_get_po INTO l_po_header_id;
6988     CLOSE csr_get_po;
6989 
6990   END IF;
6991 
6992   IF g_debug THEN
6993     hr_utility.set_location('Leaving: ' || l_proc, 999);
6994   END IF;
6995 
6996   RETURN l_po_header_id;
6997 
6998 END get_po_for_line;
6999 --
7000 -- ----------------------------------------------------------------------------
7001 -- |---------------------< get_job_for_po_line >-------------------------------|
7002 -- ----------------------------------------------------------------------------
7003 --
7004 FUNCTION get_job_for_po_line
7005   (p_po_line_id                   IN     NUMBER)
7006 RETURN NUMBER IS
7007 
7008   l_proc              VARCHAR2(72)  :=  g_package||'get_job_for_po_line';
7009   l_job_id            NUMBER;
7010 
7011   --
7012   -- Fetch the Purchase Order given a line.
7013   --
7014   CURSOR csr_get_job IS
7015   SELECT pol.job_id
7016   FROM   po_temp_labor_lines_v pol
7017   WHERE  pol.po_line_id = p_po_line_id;
7018 
7019 BEGIN
7020 
7021   IF g_debug THEN
7022     hr_utility.set_location('Entering: ' || l_proc, 10);
7023   END IF;
7024 
7025   --
7026   -- If the PO Line is not null, fetch the Job.
7027   --
7028   IF p_po_line_id IS NOT NULL THEN
7029 
7030     IF g_debug THEN
7031       hr_utility.set_location(l_proc, 20);
7032     END IF;
7033 
7034     OPEN  csr_get_job;
7035     FETCH csr_get_job INTO l_job_id;
7036     CLOSE csr_get_job;
7037 
7038   END IF;
7039 
7040   IF g_debug THEN
7041     hr_utility.set_location('Leaving: ' || l_proc, 999);
7042   END IF;
7043 
7044   RETURN l_job_id;
7045 
7046 END get_job_for_po_line;
7047 --
7048 -- ----------------------------------------------------------------------------
7049 -- |---------------------< create_gb_secondary_emp_asg >-----------------------|
7050 -- ----------------------------------------------------------------------------
7051 --
7052 procedure create_gb_secondary_emp_asg
7053   (p_validate                     in     boolean
7054   ,p_effective_date               in     date
7055   ,p_person_id                    in     number
7056   ,p_organization_id              in     number
7057   ,p_grade_id                     in     number
7058   ,p_position_id                  in     number
7059   ,p_job_id                       in     number
7060   ,p_assignment_status_type_id    in     number
7061   ,p_payroll_id                   in     number
7062   ,p_location_id                  in     number
7063   ,p_supervisor_id                in     number
7064   ,p_special_ceiling_step_id      in     number
7065   ,p_pay_basis_id                 in     number
7066   ,p_assignment_number            in out nocopy varchar2
7067   ,p_change_reason                in     varchar2
7068   ,p_comments                     in     varchar2
7069   ,p_date_probation_end           in     date
7070   ,p_default_code_comb_id         in     number
7071   ,p_employment_category          in     varchar2
7072   ,p_frequency                    in     varchar2
7073   ,p_internal_address_line        in     varchar2
7074   ,p_manager_flag                 in     varchar2
7075   ,p_normal_hours                 in     number
7076   ,p_perf_review_period           in     number
7077   ,p_perf_review_period_frequency in     varchar2
7078   ,p_probation_period             in     number
7079   ,p_probation_unit               in     varchar2
7080   ,p_sal_review_period            in     number
7081   ,p_sal_review_period_frequency  in     varchar2
7082   ,p_set_of_books_id              in     number
7083   ,p_source_type                  in     varchar2
7084   ,p_time_normal_finish           in     varchar2
7085   ,p_time_normal_start            in     varchar2
7086   ,p_bargaining_unit_code         in     varchar2
7087   ,p_labour_union_member_flag     in     varchar2
7088   ,p_hourly_salaried_code         in     varchar2
7089   ,p_ass_attribute_category       in     varchar2
7090   ,p_ass_attribute1               in     varchar2
7091   ,p_ass_attribute2               in     varchar2
7092   ,p_ass_attribute3               in     varchar2
7093   ,p_ass_attribute4               in     varchar2
7094   ,p_ass_attribute5               in     varchar2
7095   ,p_ass_attribute6               in     varchar2
7096   ,p_ass_attribute7               in     varchar2
7097   ,p_ass_attribute8               in     varchar2
7098   ,p_ass_attribute9               in     varchar2
7099   ,p_ass_attribute10              in     varchar2
7100   ,p_ass_attribute11              in     varchar2
7101   ,p_ass_attribute12              in     varchar2
7102   ,p_ass_attribute13              in     varchar2
7103   ,p_ass_attribute14              in     varchar2
7104   ,p_ass_attribute15              in     varchar2
7105   ,p_ass_attribute16              in     varchar2
7106   ,p_ass_attribute17              in     varchar2
7107   ,p_ass_attribute18              in     varchar2
7108   ,p_ass_attribute19              in     varchar2
7109   ,p_ass_attribute20              in     varchar2
7110   ,p_ass_attribute21              in     varchar2
7111   ,p_ass_attribute22              in     varchar2
7112   ,p_ass_attribute23              in     varchar2
7113   ,p_ass_attribute24              in     varchar2
7114   ,p_ass_attribute25              in     varchar2
7115   ,p_ass_attribute26              in     varchar2
7116   ,p_ass_attribute27              in     varchar2
7117   ,p_ass_attribute28              in     varchar2
7118   ,p_ass_attribute29              in     varchar2
7119   ,p_ass_attribute30              in     varchar2
7120   ,p_title                        in     varchar2
7121   ,p_pgp_segment1                 in     varchar2
7122   ,p_pgp_segment2                 in     varchar2
7123   ,p_pgp_segment3                 in     varchar2
7124   ,p_pgp_segment4                 in     varchar2
7125   ,p_pgp_segment5                 in     varchar2
7126   ,p_pgp_segment6                 in     varchar2
7127   ,p_pgp_segment7                 in     varchar2
7128   ,p_pgp_segment8                 in     varchar2
7129   ,p_pgp_segment9                 in     varchar2
7130   ,p_pgp_segment10                in     varchar2
7131   ,p_pgp_segment11                in     varchar2
7132   ,p_pgp_segment12                in     varchar2
7133   ,p_pgp_segment13                in     varchar2
7134   ,p_pgp_segment14                in     varchar2
7135   ,p_pgp_segment15                in     varchar2
7136   ,p_pgp_segment16                in     varchar2
7137   ,p_pgp_segment17                in     varchar2
7138   ,p_pgp_segment18                in     varchar2
7139   ,p_pgp_segment19                in     varchar2
7140   ,p_pgp_segment20                in     varchar2
7141   ,p_pgp_segment21                in     varchar2
7142   ,p_pgp_segment22                in     varchar2
7143   ,p_pgp_segment23                in     varchar2
7144   ,p_pgp_segment24                in     varchar2
7145   ,p_pgp_segment25                in     varchar2
7146   ,p_pgp_segment26                in     varchar2
7147   ,p_pgp_segment27                in     varchar2
7148   ,p_pgp_segment28                in     varchar2
7149   ,p_pgp_segment29                in     varchar2
7150   ,p_pgp_segment30                in     varchar2
7151 -- Bug 944911
7152 -- Made p_group_name to be out param
7153 -- and add p_concat_segment to be IN
7154 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7155   ,p_pgp_concat_segments	  in     varchar2
7156   ,p_supervisor_assignment_id     in     number
7157   ,p_group_name                      out nocopy varchar2
7158   ,p_assignment_id                   out nocopy number
7159   ,p_people_group_id                 out nocopy number
7160   ,p_object_version_number           out nocopy number
7161   ,p_effective_start_date            out nocopy date
7162   ,p_effective_end_date              out nocopy date
7163   ,p_assignment_sequence             out nocopy number
7164   ,p_comment_id                      out nocopy number
7165   ,p_other_manager_warning           out nocopy boolean
7166   ) is
7167   --
7168   -- Declare cursors and local variables
7169   --
7170   -- Assigned the value p_assignment_number for fix of #2823013
7171   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
7172   l_effective_date     date;
7173   l_legislation_code   per_business_groups.legislation_code%TYPE;
7174   l_proc               varchar2(72);
7175   --
7176   -- Declare dummy variables
7177   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
7178   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
7179   --
7180   -- Declare cursors
7181   --
7182   cursor csr_legislation is
7183     select null
7184     from per_all_assignments_f paf,
7185          per_business_groups_perf pbg
7186     where paf.person_id = p_person_id
7187     and   l_effective_date between paf.effective_start_date
7188                            and     paf.effective_end_date
7189     and   pbg.business_group_id = paf.business_group_id
7190     and   pbg.legislation_code = 'GB';
7191   --
7192   --
7193 begin
7194  if g_debug then
7195  l_proc := g_package||'create_gb_secondary_emp_asg';
7196   hr_utility.set_location('Entering:'|| l_proc, 10);
7197  end if;
7198   --
7199   -- Initialise local variable
7200   --
7201   l_effective_date := trunc(p_effective_date);
7202   --
7203   -- Validation in addition to Table Handlers
7204   --
7205   -- Ensure that the employee is within a GB business group
7206   --
7207   open csr_legislation;
7208   fetch csr_legislation
7209   into l_legislation_code;
7210   if csr_legislation%notfound then
7211     close csr_legislation;
7212     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
7213     hr_utility.set_message_token('LEG_CODE', 'GB');
7214     hr_utility.raise_error;
7215   end if;
7216   close csr_legislation;
7217   --
7218  if g_debug then
7219   hr_utility.set_location(l_proc, 20);
7220  end if;
7221   --
7222   -- Call create_secondary_emp_asg
7223   --
7224 -- Bug 944911
7225 -- Amended param p_scl_concatenated_segments to p_concatenated_segments
7226   hr_assignment_api.create_secondary_emp_asg
7227   (p_validate                     =>     p_validate
7228   ,p_effective_date               =>     l_effective_date
7229   ,p_person_id                    =>     p_person_id
7230   ,p_organization_id              =>     p_organization_id
7231   ,p_grade_id                     =>     p_grade_id
7232   ,p_position_id                  =>     p_position_id
7233   ,p_job_id                       =>     p_job_id
7234   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
7235   ,p_payroll_id                   =>     p_payroll_id
7236   ,p_location_id                  =>     p_location_id
7237   ,p_supervisor_id                =>     p_supervisor_id
7238   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
7239   ,p_pay_basis_id                 =>     p_pay_basis_id
7240   ,p_assignment_number            =>     l_assignment_number
7241   ,p_change_reason                =>     p_change_reason
7242   ,p_comments                     =>     p_comments
7243   ,p_date_probation_end           =>     trunc(p_date_probation_end)
7244   ,p_default_code_comb_id         =>     p_default_code_comb_id
7245   ,p_employment_category          =>     p_employment_category
7246   ,p_frequency                    =>     p_frequency
7247   ,p_internal_address_line        =>     p_internal_address_line
7248   ,p_manager_flag                 =>     p_manager_flag
7249   ,p_normal_hours                 =>     p_normal_hours
7250   ,p_perf_review_period           =>     p_perf_review_period
7251   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
7252   ,p_probation_period             =>     p_probation_period
7253   ,p_probation_unit               =>     p_probation_unit
7254   ,p_sal_review_period            =>     p_sal_review_period
7255   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
7256   ,p_set_of_books_id              =>     p_set_of_books_id
7257   ,p_source_type                  =>     p_source_type
7258   ,p_time_normal_finish           =>     p_time_normal_finish
7259   ,p_time_normal_start            =>     p_time_normal_start
7260   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
7261   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
7262   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
7263   ,p_ass_attribute_category       =>     p_ass_attribute_category
7264   ,p_ass_attribute1               =>     p_ass_attribute1
7265   ,p_ass_attribute2               =>     p_ass_attribute2
7266   ,p_ass_attribute3               =>     p_ass_attribute3
7267   ,p_ass_attribute4               =>     p_ass_attribute4
7268   ,p_ass_attribute5               =>     p_ass_attribute5
7269   ,p_ass_attribute6               =>     p_ass_attribute6
7270   ,p_ass_attribute7               =>     p_ass_attribute7
7271   ,p_ass_attribute8               =>     p_ass_attribute8
7272   ,p_ass_attribute9               =>     p_ass_attribute9
7273   ,p_ass_attribute10              =>     p_ass_attribute10
7274   ,p_ass_attribute11              =>     p_ass_attribute11
7275   ,p_ass_attribute12              =>     p_ass_attribute12
7276   ,p_ass_attribute13              =>     p_ass_attribute13
7277   ,p_ass_attribute14              =>     p_ass_attribute14
7278   ,p_ass_attribute15              =>     p_ass_attribute15
7279   ,p_ass_attribute16              =>     p_ass_attribute16
7280   ,p_ass_attribute17              =>     p_ass_attribute17
7281   ,p_ass_attribute18              =>     p_ass_attribute18
7282   ,p_ass_attribute19              =>     p_ass_attribute19
7283   ,p_ass_attribute20              =>     p_ass_attribute20
7284   ,p_ass_attribute21              =>     p_ass_attribute21
7285   ,p_ass_attribute22              =>     p_ass_attribute22
7286   ,p_ass_attribute23              =>     p_ass_attribute23
7287   ,p_ass_attribute24              =>     p_ass_attribute24
7288   ,p_ass_attribute25              =>     p_ass_attribute25
7289   ,p_ass_attribute26              =>     p_ass_attribute26
7290   ,p_ass_attribute27              =>     p_ass_attribute27
7291   ,p_ass_attribute28              =>     p_ass_attribute28
7292   ,p_ass_attribute29              =>     p_ass_attribute29
7293   ,p_ass_attribute30              =>     p_ass_attribute30
7294   ,p_title                        =>     p_title
7295   ,p_pgp_segment1                 =>     p_pgp_segment1
7296   ,p_pgp_segment2                 =>     p_pgp_segment2
7297   ,p_pgp_segment3                 =>     p_pgp_segment3
7298   ,p_pgp_segment4                 =>     p_pgp_segment4
7299   ,p_pgp_segment5                 =>     p_pgp_segment5
7300   ,p_pgp_segment6                 =>     p_pgp_segment6
7301   ,p_pgp_segment7                 =>     p_pgp_segment7
7302   ,p_pgp_segment8                 =>     p_pgp_segment8
7303   ,p_pgp_segment9                 =>     p_pgp_segment9
7304   ,p_pgp_segment10                =>     p_pgp_segment10
7305   ,p_pgp_segment11                =>     p_pgp_segment11
7306   ,p_pgp_segment12                =>     p_pgp_segment12
7307   ,p_pgp_segment13                =>     p_pgp_segment13
7308   ,p_pgp_segment14                =>     p_pgp_segment14
7309   ,p_pgp_segment15                =>     p_pgp_segment15
7310   ,p_pgp_segment16                =>     p_pgp_segment16
7311   ,p_pgp_segment17                =>     p_pgp_segment17
7312   ,p_pgp_segment18                =>     p_pgp_segment18
7313   ,p_pgp_segment19                =>     p_pgp_segment19
7314   ,p_pgp_segment20                =>     p_pgp_segment20
7315   ,p_pgp_segment21                =>     p_pgp_segment21
7316   ,p_pgp_segment22                =>     p_pgp_segment22
7317   ,p_pgp_segment23                =>     p_pgp_segment23
7318   ,p_pgp_segment24                =>     p_pgp_segment24
7319   ,p_pgp_segment25                =>     p_pgp_segment25
7320   ,p_pgp_segment26                =>     p_pgp_segment26
7321   ,p_pgp_segment27                =>     p_pgp_segment27
7322   ,p_pgp_segment28                =>     p_pgp_segment28
7323   ,p_pgp_segment29                =>     p_pgp_segment29
7324   ,p_pgp_segment30                =>     p_pgp_segment30
7325 -- Bug 944911
7326 -- Made p_group_name to be out param
7327 -- and add p_concat_segment to be IN
7328 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7329 -- Amended call - added new param p_pgp_concat_segments
7330   ,p_pgp_concat_segments          =>     p_pgp_concat_segments
7331   ,p_group_name                   =>     p_group_name
7332   ,p_assignment_id                =>     p_assignment_id
7333   ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
7334   ,p_people_group_id              =>     p_people_group_id
7335   ,p_object_version_number        =>     p_object_version_number
7336   ,p_effective_start_date         =>     p_effective_start_date
7337   ,p_effective_end_date           =>     p_effective_end_date
7338   ,p_assignment_sequence          =>     p_assignment_sequence
7339   ,p_comment_id                   =>     p_comment_id
7340   ,p_concatenated_segments        =>     l_concatenated_segments
7341   ,p_other_manager_warning        =>     p_other_manager_warning
7342   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
7343   );
7344   --
7345  if g_debug then
7346   hr_utility.set_location(' Leaving:'||l_proc, 30);
7347  end if;
7348   --
7349   end create_gb_secondary_emp_asg;
7350 
7351 --
7352 --
7353 -- ----------------------------------------------------------------------------
7354 -- |---------------------< create_gb_secondary_emp_asg >-----------------------|
7355 -- ----------------------------------------------------------------------------
7356 --   Overloded procedure to include p_hourly_salaried_warning
7357 --
7358 procedure create_gb_secondary_emp_asg
7359   (p_validate                     in     boolean
7360   ,p_effective_date               in     date
7361   ,p_person_id                    in     number
7362   ,p_organization_id              in     number
7363   ,p_grade_id                     in     number
7364   ,p_position_id                  in     number
7365   ,p_job_id                       in     number
7366   ,p_assignment_status_type_id    in     number
7367   ,p_payroll_id                   in     number
7368   ,p_location_id                  in     number
7369   ,p_supervisor_id                in     number
7370   ,p_special_ceiling_step_id      in     number
7371   ,p_pay_basis_id                 in     number
7372   ,p_assignment_number            in out nocopy varchar2
7373   ,p_change_reason                in     varchar2
7374   ,p_comments                     in     varchar2
7375   ,p_date_probation_end           in     date
7376   ,p_default_code_comb_id         in     number
7377   ,p_employment_category          in     varchar2
7378   ,p_frequency                    in     varchar2
7379   ,p_internal_address_line        in     varchar2
7380   ,p_manager_flag                 in     varchar2
7381   ,p_normal_hours                 in     number
7382   ,p_perf_review_period           in     number
7383   ,p_perf_review_period_frequency in     varchar2
7384   ,p_probation_period             in     number
7385   ,p_probation_unit               in     varchar2
7386   ,p_sal_review_period            in     number
7387   ,p_sal_review_period_frequency  in     varchar2
7388   ,p_set_of_books_id              in     number
7389   ,p_source_type                  in     varchar2
7390   ,p_time_normal_finish           in     varchar2
7391   ,p_time_normal_start            in     varchar2
7392   ,p_bargaining_unit_code         in     varchar2
7393   ,p_labour_union_member_flag     in     varchar2
7394   ,p_hourly_salaried_code         in     varchar2
7395   ,p_ass_attribute_category       in     varchar2
7396   ,p_ass_attribute1               in     varchar2
7397   ,p_ass_attribute2               in     varchar2
7398   ,p_ass_attribute3               in     varchar2
7399   ,p_ass_attribute4               in     varchar2
7400   ,p_ass_attribute5               in     varchar2
7401   ,p_ass_attribute6               in     varchar2
7402   ,p_ass_attribute7               in     varchar2
7403   ,p_ass_attribute8               in     varchar2
7404   ,p_ass_attribute9               in     varchar2
7405   ,p_ass_attribute10              in     varchar2
7406   ,p_ass_attribute11              in     varchar2
7407   ,p_ass_attribute12              in     varchar2
7408   ,p_ass_attribute13              in     varchar2
7409   ,p_ass_attribute14              in     varchar2
7410   ,p_ass_attribute15              in     varchar2
7411   ,p_ass_attribute16              in     varchar2
7412   ,p_ass_attribute17              in     varchar2
7413   ,p_ass_attribute18              in     varchar2
7414   ,p_ass_attribute19              in     varchar2
7415   ,p_ass_attribute20              in     varchar2
7416   ,p_ass_attribute21              in     varchar2
7417   ,p_ass_attribute22              in     varchar2
7418   ,p_ass_attribute23              in     varchar2
7419   ,p_ass_attribute24              in     varchar2
7420   ,p_ass_attribute25              in     varchar2
7421   ,p_ass_attribute26              in     varchar2
7422   ,p_ass_attribute27              in     varchar2
7423   ,p_ass_attribute28              in     varchar2
7424   ,p_ass_attribute29              in     varchar2
7425   ,p_ass_attribute30              in     varchar2
7426   ,p_title                        in     varchar2
7427   ,p_pgp_segment1                 in     varchar2
7428   ,p_pgp_segment2                 in     varchar2
7429   ,p_pgp_segment3                 in     varchar2
7430   ,p_pgp_segment4                 in     varchar2
7431   ,p_pgp_segment5                 in     varchar2
7432   ,p_pgp_segment6                 in     varchar2
7433   ,p_pgp_segment7                 in     varchar2
7434   ,p_pgp_segment8                 in     varchar2
7435   ,p_pgp_segment9                 in     varchar2
7436   ,p_pgp_segment10                in     varchar2
7437   ,p_pgp_segment11                in     varchar2
7438   ,p_pgp_segment12                in     varchar2
7439   ,p_pgp_segment13                in     varchar2
7440   ,p_pgp_segment14                in     varchar2
7441   ,p_pgp_segment15                in     varchar2
7442   ,p_pgp_segment16                in     varchar2
7443   ,p_pgp_segment17                in     varchar2
7444   ,p_pgp_segment18                in     varchar2
7445   ,p_pgp_segment19                in     varchar2
7446   ,p_pgp_segment20                in     varchar2
7447   ,p_pgp_segment21                in     varchar2
7448   ,p_pgp_segment22                in     varchar2
7449   ,p_pgp_segment23                in     varchar2
7450   ,p_pgp_segment24                in     varchar2
7451   ,p_pgp_segment25                in     varchar2
7452   ,p_pgp_segment26                in     varchar2
7453   ,p_pgp_segment27                in     varchar2
7454   ,p_pgp_segment28                in     varchar2
7455   ,p_pgp_segment29                in     varchar2
7456   ,p_pgp_segment30                in     varchar2
7457 -- Bug 944911
7458 -- Made p_group_name to be out param
7459 -- and add p_concat_segment to be IN
7460 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7461   ,p_pgp_concat_segments	  in     varchar2
7462   ,p_supervisor_assignment_id     in     number
7463   ,p_group_name                      out nocopy varchar2
7464   ,p_assignment_id                   out nocopy number
7465   ,p_people_group_id                 out nocopy number
7466   ,p_object_version_number           out nocopy number
7467   ,p_effective_start_date            out nocopy date
7468   ,p_effective_end_date              out nocopy date
7469   ,p_assignment_sequence             out nocopy number
7470   ,p_comment_id                      out nocopy number
7471   ,p_other_manager_warning           out nocopy boolean
7472   ,p_hourly_salaried_warning         out nocopy boolean
7473   ,p_cagr_grade_def_id               out nocopy number
7474   ,p_cagr_concatenated_segments      out nocopy varchar2
7475   ) is
7476   --
7477   -- Declare cursors and local variables
7478   --
7479   -- Assigned the value p_assignment_number for fix of #2823013
7480   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
7481   l_effective_date     date;
7482   l_legislation_code   per_business_groups.legislation_code%TYPE;
7483   l_proc               varchar2(72);
7484   --
7485   -- Declare dummy variables
7486   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
7487   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
7488   --
7489   -- Declare cursors
7490   --
7491   cursor csr_legislation is
7492     select null
7493     from per_all_assignments_f paf,
7494          per_business_groups_perf pbg
7495     where paf.person_id = p_person_id
7496     and   l_effective_date between paf.effective_start_date
7497                            and     paf.effective_end_date
7498     and   pbg.business_group_id = paf.business_group_id
7499     and   pbg.legislation_code = 'GB';
7500   --
7501   --
7502 begin
7503  if g_debug then
7504  l_proc := g_package||'create_gb_secondary_emp_asg';
7505   hr_utility.set_location('Entering:'|| l_proc, 10);
7506  end if;
7507   --
7508   -- Initialise local variable
7509   --
7510   l_effective_date := trunc(p_effective_date);
7511   --
7512   -- Validation in addition to Table Handlers
7513   --
7514   -- Ensure that the employee is within a GB business group
7515   --
7516   open csr_legislation;
7517   fetch csr_legislation
7518   into l_legislation_code;
7519   if csr_legislation%notfound then
7520     close csr_legislation;
7521     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
7522     hr_utility.set_message_token('LEG_CODE', 'GB');
7523     hr_utility.raise_error;
7524   end if;
7525   close csr_legislation;
7526   --
7527  if g_debug then
7528   hr_utility.set_location(l_proc, 20);
7529  end if;
7530   --
7531   -- Call create_secondary_emp_asg
7532   --
7533 -- Bug 944911
7534 -- Amended param p_scl_concatenated_segments to p_concatenated_segments
7535   hr_assignment_api.create_secondary_emp_asg
7536   (p_validate                     =>     p_validate
7537   ,p_effective_date               =>     l_effective_date
7538   ,p_person_id                    =>     p_person_id
7539   ,p_organization_id              =>     p_organization_id
7540   ,p_grade_id                     =>     p_grade_id
7541   ,p_position_id                  =>     p_position_id
7542   ,p_job_id                       =>     p_job_id
7543   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
7544   ,p_payroll_id                   =>     p_payroll_id
7545   ,p_location_id                  =>     p_location_id
7546   ,p_supervisor_id                =>     p_supervisor_id
7547   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
7548   ,p_pay_basis_id                 =>     p_pay_basis_id
7549   ,p_assignment_number            =>     l_assignment_number
7550   ,p_change_reason                =>     p_change_reason
7551   ,p_comments                     =>     p_comments
7552   ,p_date_probation_end           =>     trunc(p_date_probation_end)
7553   ,p_default_code_comb_id         =>     p_default_code_comb_id
7554   ,p_employment_category          =>     p_employment_category
7555   ,p_frequency                    =>     p_frequency
7556   ,p_internal_address_line        =>     p_internal_address_line
7557   ,p_manager_flag                 =>     p_manager_flag
7558   ,p_normal_hours                 =>     p_normal_hours
7559   ,p_perf_review_period           =>     p_perf_review_period
7560   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
7561   ,p_probation_period             =>     p_probation_period
7562   ,p_probation_unit               =>     p_probation_unit
7563   ,p_sal_review_period            =>     p_sal_review_period
7564   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
7565   ,p_set_of_books_id              =>     p_set_of_books_id
7566   ,p_source_type                  =>     p_source_type
7567   ,p_time_normal_finish           =>     p_time_normal_finish
7568   ,p_time_normal_start            =>     p_time_normal_start
7569   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
7570   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
7571   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
7572   ,p_ass_attribute_category       =>     p_ass_attribute_category
7573   ,p_ass_attribute1               =>     p_ass_attribute1
7574   ,p_ass_attribute2               =>     p_ass_attribute2
7575   ,p_ass_attribute3               =>     p_ass_attribute3
7576   ,p_ass_attribute4               =>     p_ass_attribute4
7577   ,p_ass_attribute5               =>     p_ass_attribute5
7578   ,p_ass_attribute6               =>     p_ass_attribute6
7579   ,p_ass_attribute7               =>     p_ass_attribute7
7580   ,p_ass_attribute8               =>     p_ass_attribute8
7581   ,p_ass_attribute9               =>     p_ass_attribute9
7582   ,p_ass_attribute10              =>     p_ass_attribute10
7583   ,p_ass_attribute11              =>     p_ass_attribute11
7584   ,p_ass_attribute12              =>     p_ass_attribute12
7585   ,p_ass_attribute13              =>     p_ass_attribute13
7586   ,p_ass_attribute14              =>     p_ass_attribute14
7587   ,p_ass_attribute15              =>     p_ass_attribute15
7588   ,p_ass_attribute16              =>     p_ass_attribute16
7589   ,p_ass_attribute17              =>     p_ass_attribute17
7590   ,p_ass_attribute18              =>     p_ass_attribute18
7591   ,p_ass_attribute19              =>     p_ass_attribute19
7592   ,p_ass_attribute20              =>     p_ass_attribute20
7593   ,p_ass_attribute21              =>     p_ass_attribute21
7594   ,p_ass_attribute22              =>     p_ass_attribute22
7595   ,p_ass_attribute23              =>     p_ass_attribute23
7596   ,p_ass_attribute24              =>     p_ass_attribute24
7597   ,p_ass_attribute25              =>     p_ass_attribute25
7598   ,p_ass_attribute26              =>     p_ass_attribute26
7599   ,p_ass_attribute27              =>     p_ass_attribute27
7600   ,p_ass_attribute28              =>     p_ass_attribute28
7601   ,p_ass_attribute29              =>     p_ass_attribute29
7602   ,p_ass_attribute30              =>     p_ass_attribute30
7603   ,p_title                        =>     p_title
7604   ,p_pgp_segment1                 =>     p_pgp_segment1
7605   ,p_pgp_segment2                 =>     p_pgp_segment2
7606   ,p_pgp_segment3                 =>     p_pgp_segment3
7607   ,p_pgp_segment4                 =>     p_pgp_segment4
7608   ,p_pgp_segment5                 =>     p_pgp_segment5
7609   ,p_pgp_segment6                 =>     p_pgp_segment6
7610   ,p_pgp_segment7                 =>     p_pgp_segment7
7611   ,p_pgp_segment8                 =>     p_pgp_segment8
7612   ,p_pgp_segment9                 =>     p_pgp_segment9
7613   ,p_pgp_segment10                =>     p_pgp_segment10
7614   ,p_pgp_segment11                =>     p_pgp_segment11
7615   ,p_pgp_segment12                =>     p_pgp_segment12
7616   ,p_pgp_segment13                =>     p_pgp_segment13
7617   ,p_pgp_segment14                =>     p_pgp_segment14
7618   ,p_pgp_segment15                =>     p_pgp_segment15
7619   ,p_pgp_segment16                =>     p_pgp_segment16
7620   ,p_pgp_segment17                =>     p_pgp_segment17
7621   ,p_pgp_segment18                =>     p_pgp_segment18
7622   ,p_pgp_segment19                =>     p_pgp_segment19
7623   ,p_pgp_segment20                =>     p_pgp_segment20
7624   ,p_pgp_segment21                =>     p_pgp_segment21
7625   ,p_pgp_segment22                =>     p_pgp_segment22
7626   ,p_pgp_segment23                =>     p_pgp_segment23
7627   ,p_pgp_segment24                =>     p_pgp_segment24
7628   ,p_pgp_segment25                =>     p_pgp_segment25
7629   ,p_pgp_segment26                =>     p_pgp_segment26
7630   ,p_pgp_segment27                =>     p_pgp_segment27
7631   ,p_pgp_segment28                =>     p_pgp_segment28
7632   ,p_pgp_segment29                =>     p_pgp_segment29
7633   ,p_pgp_segment30                =>     p_pgp_segment30
7634 -- Bug 944911
7635 -- Made p_group_name to be out param
7636 -- and add p_concat_segment to be IN
7637 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7638 -- Amended call - added new param p_pgp_concat_segments
7639   ,p_pgp_concat_segments          =>     p_pgp_concat_segments
7640   ,p_group_name                   =>     p_group_name
7641   ,p_assignment_id                =>     p_assignment_id
7642   ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
7643   ,p_people_group_id              =>     p_people_group_id
7644   ,p_object_version_number        =>     p_object_version_number
7645   ,p_effective_start_date         =>     p_effective_start_date
7646   ,p_effective_end_date           =>     p_effective_end_date
7647   ,p_assignment_sequence          =>     p_assignment_sequence
7648   ,p_comment_id                   =>     p_comment_id
7649   ,p_concatenated_segments        =>     l_concatenated_segments
7650   ,p_other_manager_warning        =>     p_other_manager_warning
7651   ,p_hourly_salaried_warning      =>     p_hourly_salaried_warning
7652   ,p_cagr_grade_def_id            =>     p_cagr_grade_def_id
7653   ,p_cagr_concatenated_segments   =>     p_cagr_concatenated_segments
7654   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
7655   );
7656   --
7657  if g_debug then
7658   hr_utility.set_location(' Leaving:'||l_proc, 30);
7659  end if;
7660   --
7661   end create_gb_secondary_emp_asg;
7662 
7663 --
7664 -- ----------------------------------------------------------------------------
7665 -- |---------------------< create_us_secondary_emp_asg >-----------------------|
7666 -- ----------------------------------------------------------------------------
7667 --
7668 procedure create_us_secondary_emp_asg
7669   (p_validate                     in     boolean
7670   ,p_effective_date               in     date
7671   ,p_person_id                    in     number
7672   ,p_organization_id              in     number
7673   ,p_grade_id                     in     number
7674   ,p_position_id                  in     number
7675   ,p_job_id                       in     number
7676   ,p_assignment_status_type_id    in     number
7677   ,p_payroll_id                   in     number
7678   ,p_location_id                  in     number
7679   ,p_supervisor_id                in     number
7680   ,p_special_ceiling_step_id      in     number
7681   ,p_pay_basis_id                 in     number
7682   ,p_assignment_number            in out nocopy varchar2
7683   ,p_change_reason                in     varchar2
7684   ,p_comments                     in     varchar2
7685   ,p_date_probation_end           in     date
7686   ,p_default_code_comb_id         in     number
7687   ,p_employment_category          in     varchar2
7688   ,p_frequency                    in     varchar2
7689   ,p_internal_address_line        in     varchar2
7690   ,p_manager_flag                 in     varchar2
7691   ,p_normal_hours                 in     number
7692   ,p_perf_review_period           in     number
7693   ,p_perf_review_period_frequency in     varchar2
7694   ,p_probation_period             in     number
7695   ,p_probation_unit               in     varchar2
7696   ,p_sal_review_period            in     number
7697   ,p_sal_review_period_frequency  in     varchar2
7698   ,p_set_of_books_id              in     number
7699   ,p_source_type                  in     varchar2
7700   ,p_time_normal_finish           in     varchar2
7701   ,p_time_normal_start            in     varchar2
7702   ,p_bargaining_unit_code         in     varchar2
7703   ,p_labour_union_member_flag     in     varchar2
7704   ,p_hourly_salaried_code         in     varchar2
7705   ,p_ass_attribute_category       in     varchar2
7706   ,p_ass_attribute1               in     varchar2
7707   ,p_ass_attribute2               in     varchar2
7708   ,p_ass_attribute3               in     varchar2
7709   ,p_ass_attribute4               in     varchar2
7710   ,p_ass_attribute5               in     varchar2
7711   ,p_ass_attribute6               in     varchar2
7712   ,p_ass_attribute7               in     varchar2
7713   ,p_ass_attribute8               in     varchar2
7714   ,p_ass_attribute9               in     varchar2
7715   ,p_ass_attribute10              in     varchar2
7716   ,p_ass_attribute11              in     varchar2
7717   ,p_ass_attribute12              in     varchar2
7718   ,p_ass_attribute13              in     varchar2
7719   ,p_ass_attribute14              in     varchar2
7720   ,p_ass_attribute15              in     varchar2
7721   ,p_ass_attribute16              in     varchar2
7722   ,p_ass_attribute17              in     varchar2
7723   ,p_ass_attribute18              in     varchar2
7724   ,p_ass_attribute19              in     varchar2
7725   ,p_ass_attribute20              in     varchar2
7726   ,p_ass_attribute21              in     varchar2
7727   ,p_ass_attribute22              in     varchar2
7728   ,p_ass_attribute23              in     varchar2
7729   ,p_ass_attribute24              in     varchar2
7730   ,p_ass_attribute25              in     varchar2
7731   ,p_ass_attribute26              in     varchar2
7732   ,p_ass_attribute27              in     varchar2
7733   ,p_ass_attribute28              in     varchar2
7734   ,p_ass_attribute29              in     varchar2
7735   ,p_ass_attribute30              in     varchar2
7736   ,p_title                        in     varchar2
7737   ,p_tax_unit                     in     varchar2
7738   ,p_timecard_approver            in     varchar2
7739   ,p_timecard_required            in     varchar2
7740   ,p_work_schedule                in     varchar2
7741   ,p_shift                        in     varchar2
7742   ,p_spouse_salary                in     varchar2
7743   ,p_legal_representative         in     varchar2
7744   ,p_wc_override_code             in     varchar2
7745   ,p_eeo_1_establishment          in     varchar2
7746   ,p_pgp_segment1                 in     varchar2
7747   ,p_pgp_segment2                 in     varchar2
7748   ,p_pgp_segment3                 in     varchar2
7749   ,p_pgp_segment4                 in     varchar2
7750   ,p_pgp_segment5                 in     varchar2
7751   ,p_pgp_segment6                 in     varchar2
7752   ,p_pgp_segment7                 in     varchar2
7753   ,p_pgp_segment8                 in     varchar2
7754   ,p_pgp_segment9                 in     varchar2
7755   ,p_pgp_segment10                in     varchar2
7756   ,p_pgp_segment11                in     varchar2
7757   ,p_pgp_segment12                in     varchar2
7758   ,p_pgp_segment13                in     varchar2
7759   ,p_pgp_segment14                in     varchar2
7760   ,p_pgp_segment15                in     varchar2
7761   ,p_pgp_segment16                in     varchar2
7762   ,p_pgp_segment17                in     varchar2
7763   ,p_pgp_segment18                in     varchar2
7764   ,p_pgp_segment19                in     varchar2
7765   ,p_pgp_segment20                in     varchar2
7766   ,p_pgp_segment21                in     varchar2
7767   ,p_pgp_segment22                in     varchar2
7768   ,p_pgp_segment23                in     varchar2
7769   ,p_pgp_segment24                in     varchar2
7770   ,p_pgp_segment25                in     varchar2
7771   ,p_pgp_segment26                in     varchar2
7772   ,p_pgp_segment27                in     varchar2
7773   ,p_pgp_segment28                in     varchar2
7774   ,p_pgp_segment29                in     varchar2
7775   ,p_pgp_segment30                in     varchar2
7776 -- Bug 944911
7777 -- Made p_group_name to be out param
7778 -- and add p_concat_segment to be IN
7779 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7780   ,p_pgp_concat_segments	  in     varchar2
7781   ,p_supervisor_assignment_id     in     number
7782   ,p_group_name                      out nocopy varchar2
7783   ,p_assignment_id                   out nocopy number
7784   ,p_soft_coding_keyflex_id          out nocopy number
7785   ,p_people_group_id                 out nocopy number
7786   ,p_object_version_number           out nocopy number
7787   ,p_effective_start_date            out nocopy date
7788   ,p_effective_end_date              out nocopy date
7789   ,p_assignment_sequence             out nocopy number
7790   ,p_comment_id                      out nocopy number
7791 -- Bug 944911
7792 -- Amended p_concatenated_segments to out from in out
7793 -- added new param p_concat_segments in
7794   ,p_concatenated_segments           out nocopy varchar2
7795   ,p_concat_segments              in     varchar2
7796   ,p_other_manager_warning           out nocopy boolean
7797   ) is
7798   --
7799   -- Declare cursors and local variables
7800   --
7801   -- Declare variables
7802   --
7803   -- WWBUG 2539685
7804   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
7805   l_effective_date     date;
7806   --
7807   l_business_group_id  per_business_groups.business_group_id%TYPE;
7808   l_legislation_code   per_business_groups.legislation_code%TYPE;
7809   l_proc               varchar2(72);
7810   --
7811   -- Declare cursors
7812   --
7813   cursor csr_legislation is
7814     select null
7815     from per_all_assignments_f paf,
7816          per_business_groups_perf pbg
7817     where paf.person_id = p_person_id
7818     and   l_effective_date between paf.effective_start_date
7819                            and     paf.effective_end_date
7820     and   pbg.business_group_id = paf.business_group_id
7821     and   pbg.legislation_code = 'US';
7822   --
7823   --
7824 begin
7825  if g_debug then
7826  l_proc := g_package||'create_secondary_us_emp_asg';
7827   hr_utility.set_location('Entering:'|| l_proc, 10);
7828  end if;
7829   --
7830   -- Initialise local variable
7831   --
7832   l_effective_date := trunc(p_effective_date);
7833   --
7834   -- Validation in addition to Table Handlers
7835   --
7836   -- Ensure that the employee is within a US business group
7837   --
7838   open csr_legislation;
7839   fetch csr_legislation
7840   into l_legislation_code;
7841   if csr_legislation%notfound then
7842     close csr_legislation;
7843     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
7844     hr_utility.set_message_token('LEG_CODE', 'US');
7845     hr_utility.raise_error;
7846   end if;
7847   close csr_legislation;
7848   --
7849   --
7850   -- Call create_secondary_emp_asg
7851   --
7852 -- Bug 944911
7853 -- Added new param p_concat_segments in
7854 -- made p_concatenated_segments to be out only
7855 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
7856 
7857   hr_assignment_api.create_secondary_emp_asg
7858   (p_validate                     =>     p_validate
7859   ,p_effective_date               =>     l_effective_date
7860   ,p_person_id                    =>     p_person_id
7861   ,p_organization_id              =>     p_organization_id
7862   ,p_grade_id                     =>     p_grade_id
7863   ,p_position_id                  =>     p_position_id
7864   ,p_job_id                       =>     p_job_id
7865   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
7866   ,p_payroll_id                   =>     p_payroll_id
7867   ,p_location_id                  =>     p_location_id
7868   ,p_supervisor_id                =>     p_supervisor_id
7869   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
7870   ,p_pay_basis_id                 =>     p_pay_basis_id
7871   ,p_assignment_number            =>     l_assignment_number
7872   ,p_change_reason                =>     p_change_reason
7873   ,p_comments                     =>     p_comments
7874   ,p_date_probation_end           =>     trunc(p_date_probation_end)
7875   ,p_default_code_comb_id         =>     p_default_code_comb_id
7876   ,p_employment_category          =>     p_employment_category
7877   ,p_frequency                    =>     p_frequency
7878   ,p_internal_address_line        =>     p_internal_address_line
7879   ,p_manager_flag                 =>     p_manager_flag
7880   ,p_normal_hours                 =>     p_normal_hours
7881   ,p_perf_review_period           =>     p_perf_review_period
7882   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
7883   ,p_probation_period             =>     p_probation_period
7884   ,p_probation_unit               =>     p_probation_unit
7885   ,p_sal_review_period            =>     p_sal_review_period
7886   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
7887   ,p_set_of_books_id              =>     p_set_of_books_id
7888   ,p_source_type                  =>     p_source_type
7889   ,p_time_normal_finish           =>     p_time_normal_finish
7890   ,p_time_normal_start            =>     p_time_normal_start
7891   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
7892   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
7893   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
7894   ,p_ass_attribute_category       =>     p_ass_attribute_category
7895   ,p_ass_attribute1               =>     p_ass_attribute1
7896   ,p_ass_attribute2               =>     p_ass_attribute2
7897   ,p_ass_attribute3               =>     p_ass_attribute3
7898   ,p_ass_attribute4               =>     p_ass_attribute4
7899   ,p_ass_attribute5               =>     p_ass_attribute5
7900   ,p_ass_attribute6               =>     p_ass_attribute6
7901   ,p_ass_attribute7               =>     p_ass_attribute7
7902   ,p_ass_attribute8               =>     p_ass_attribute8
7903   ,p_ass_attribute9               =>     p_ass_attribute9
7904   ,p_ass_attribute10              =>     p_ass_attribute10
7905   ,p_ass_attribute11              =>     p_ass_attribute11
7906   ,p_ass_attribute12              =>     p_ass_attribute12
7907   ,p_ass_attribute13              =>     p_ass_attribute13
7908   ,p_ass_attribute14              =>     p_ass_attribute14
7909   ,p_ass_attribute15              =>     p_ass_attribute15
7910   ,p_ass_attribute16              =>     p_ass_attribute16
7911   ,p_ass_attribute17              =>     p_ass_attribute17
7912   ,p_ass_attribute18              =>     p_ass_attribute18
7913   ,p_ass_attribute19              =>     p_ass_attribute19
7914   ,p_ass_attribute20              =>     p_ass_attribute20
7915   ,p_ass_attribute21              =>     p_ass_attribute21
7916   ,p_ass_attribute22              =>     p_ass_attribute22
7917   ,p_ass_attribute23              =>     p_ass_attribute23
7918   ,p_ass_attribute24              =>     p_ass_attribute24
7919   ,p_ass_attribute25              =>     p_ass_attribute25
7920   ,p_ass_attribute26              =>     p_ass_attribute26
7921   ,p_ass_attribute27              =>     p_ass_attribute27
7922   ,p_ass_attribute28              =>     p_ass_attribute28
7923   ,p_ass_attribute29              =>     p_ass_attribute29
7924   ,p_ass_attribute30              =>     p_ass_attribute30
7925   ,p_title                        =>     p_title
7926   ,p_scl_segment1                 =>     p_tax_unit
7927   ,p_scl_segment2                 =>     p_timecard_approver
7928   ,p_scl_segment3                 =>     p_timecard_required
7929   ,p_scl_segment4                 =>     p_work_schedule
7930   ,p_scl_segment5                 =>     p_shift
7931   ,p_scl_segment6                 =>     p_spouse_salary
7932   ,p_scl_segment7                 =>     p_legal_representative
7933   ,p_scl_segment8                 =>     p_wc_override_code
7934   ,p_scl_segment9                 =>     p_eeo_1_establishment
7935   ,p_pgp_segment1                 =>     p_pgp_segment1
7936   ,p_pgp_segment2                 =>     p_pgp_segment2
7937   ,p_pgp_segment3                 =>     p_pgp_segment3
7938   ,p_pgp_segment4                 =>     p_pgp_segment4
7939   ,p_pgp_segment5                 =>     p_pgp_segment5
7940   ,p_pgp_segment6                 =>     p_pgp_segment6
7941   ,p_pgp_segment7                 =>     p_pgp_segment7
7942   ,p_pgp_segment8                 =>     p_pgp_segment8
7943   ,p_pgp_segment9                 =>     p_pgp_segment9
7944   ,p_pgp_segment10                =>     p_pgp_segment10
7945   ,p_pgp_segment11                =>     p_pgp_segment11
7946   ,p_pgp_segment12                =>     p_pgp_segment12
7947   ,p_pgp_segment13                =>     p_pgp_segment13
7948   ,p_pgp_segment14                =>     p_pgp_segment14
7949   ,p_pgp_segment15                =>     p_pgp_segment15
7950   ,p_pgp_segment16                =>     p_pgp_segment16
7951   ,p_pgp_segment17                =>     p_pgp_segment17
7952   ,p_pgp_segment18                =>     p_pgp_segment18
7953   ,p_pgp_segment19                =>     p_pgp_segment19
7954   ,p_pgp_segment20                =>     p_pgp_segment20
7955   ,p_pgp_segment21                =>     p_pgp_segment21
7956   ,p_pgp_segment22                =>     p_pgp_segment22
7957   ,p_pgp_segment23                =>     p_pgp_segment23
7958   ,p_pgp_segment24                =>     p_pgp_segment24
7959   ,p_pgp_segment25                =>     p_pgp_segment25
7960   ,p_pgp_segment26                =>     p_pgp_segment26
7961   ,p_pgp_segment27                =>     p_pgp_segment27
7962   ,p_pgp_segment28                =>     p_pgp_segment28
7963   ,p_pgp_segment29                =>     p_pgp_segment29
7964   ,p_pgp_segment30                =>     p_pgp_segment30
7965 -- Bug 944911
7966 -- Made p_group_name to be out param
7967 -- and add p_concat_segment to be IN
7968 -- in case of sec_asg alone made p_pgp_concat_segments as in param
7969 -- Added new param p_pgp_concat_segments
7970   ,p_pgp_concat_segments	  =>	 p_pgp_concat_segments
7971   ,p_group_name                   =>     p_group_name
7972   ,p_assignment_id                =>     p_assignment_id
7973   ,p_soft_coding_keyflex_id       =>     p_soft_coding_keyflex_id
7974   ,p_people_group_id              =>     p_people_group_id
7975   ,p_object_version_number        =>     p_object_version_number
7976   ,p_effective_start_date         =>     p_effective_start_date
7977   ,p_effective_end_date           =>     p_effective_end_date
7978   ,p_assignment_sequence          =>     p_assignment_sequence
7979   ,p_comment_id                   =>     p_comment_id
7980   ,p_concatenated_segments        =>     p_concatenated_segments
7981   ,p_scl_concat_segments          =>     p_concat_segments
7982   ,p_other_manager_warning        =>     p_other_manager_warning
7983   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
7984   );
7985   --
7986  if g_debug then
7987   hr_utility.set_location(' Leaving:'||l_proc, 30);
7988  end if;
7989   --
7990   end create_us_secondary_emp_asg;
7991 
7992 --
7993 -- ----------------------------------------------------------------------------
7994 -- |---------------------< create_us_secondary_emp_asg >-----------------------|
7995 -- ----------------------------------------------------------------------------
7996 --   Overloded procedure to include p_hourly_salaried_warning
7997 --
7998 procedure create_us_secondary_emp_asg
7999   (p_validate                     in     boolean
8000   ,p_effective_date               in     date
8001   ,p_person_id                    in     number
8002   ,p_organization_id              in     number
8003   ,p_grade_id                     in     number
8004   ,p_position_id                  in     number
8005   ,p_job_id                       in     number
8006   ,p_assignment_status_type_id    in     number
8007   ,p_payroll_id                   in     number
8008   ,p_location_id                  in     number
8009   ,p_supervisor_id                in     number
8010   ,p_special_ceiling_step_id      in     number
8011   ,p_pay_basis_id                 in     number
8012   ,p_assignment_number            in out nocopy varchar2
8013   ,p_change_reason                in     varchar2
8014   ,p_comments                     in     varchar2
8015   ,p_date_probation_end           in     date
8016   ,p_default_code_comb_id         in     number
8017   ,p_employment_category          in     varchar2
8018   ,p_frequency                    in     varchar2
8019   ,p_internal_address_line        in     varchar2
8020   ,p_manager_flag                 in     varchar2
8021   ,p_normal_hours                 in     number
8022   ,p_perf_review_period           in     number
8023   ,p_perf_review_period_frequency in     varchar2
8024   ,p_probation_period             in     number
8025   ,p_probation_unit               in     varchar2
8026   ,p_sal_review_period            in     number
8027   ,p_sal_review_period_frequency  in     varchar2
8028   ,p_set_of_books_id              in     number
8029   ,p_source_type                  in     varchar2
8030   ,p_time_normal_finish           in     varchar2
8031   ,p_time_normal_start            in     varchar2
8032   ,p_bargaining_unit_code         in     varchar2
8033   ,p_labour_union_member_flag     in     varchar2
8034   ,p_hourly_salaried_code         in     varchar2
8035   ,p_ass_attribute_category       in     varchar2
8036   ,p_ass_attribute1               in     varchar2
8037   ,p_ass_attribute2               in     varchar2
8038   ,p_ass_attribute3               in     varchar2
8039   ,p_ass_attribute4               in     varchar2
8040   ,p_ass_attribute5               in     varchar2
8041   ,p_ass_attribute6               in     varchar2
8042   ,p_ass_attribute7               in     varchar2
8043   ,p_ass_attribute8               in     varchar2
8044   ,p_ass_attribute9               in     varchar2
8045   ,p_ass_attribute10              in     varchar2
8046   ,p_ass_attribute11              in     varchar2
8047   ,p_ass_attribute12              in     varchar2
8048   ,p_ass_attribute13              in     varchar2
8049   ,p_ass_attribute14              in     varchar2
8050   ,p_ass_attribute15              in     varchar2
8051   ,p_ass_attribute16              in     varchar2
8052   ,p_ass_attribute17              in     varchar2
8053   ,p_ass_attribute18              in     varchar2
8054   ,p_ass_attribute19              in     varchar2
8055   ,p_ass_attribute20              in     varchar2
8056   ,p_ass_attribute21              in     varchar2
8057   ,p_ass_attribute22              in     varchar2
8058   ,p_ass_attribute23              in     varchar2
8059   ,p_ass_attribute24              in     varchar2
8060   ,p_ass_attribute25              in     varchar2
8061   ,p_ass_attribute26              in     varchar2
8062   ,p_ass_attribute27              in     varchar2
8063   ,p_ass_attribute28              in     varchar2
8064   ,p_ass_attribute29              in     varchar2
8065   ,p_ass_attribute30              in     varchar2
8066   ,p_title                        in     varchar2
8067   ,p_tax_unit                     in     varchar2
8068   ,p_timecard_approver            in     varchar2
8069   ,p_timecard_required            in     varchar2
8070   ,p_work_schedule                in     varchar2
8071   ,p_shift                        in     varchar2
8072   ,p_spouse_salary                in     varchar2
8073   ,p_legal_representative         in     varchar2
8074   ,p_wc_override_code             in     varchar2
8075   ,p_eeo_1_establishment          in     varchar2
8076   ,p_pgp_segment1                 in     varchar2
8077   ,p_pgp_segment2                 in     varchar2
8078   ,p_pgp_segment3                 in     varchar2
8079   ,p_pgp_segment4                 in     varchar2
8080   ,p_pgp_segment5                 in     varchar2
8081   ,p_pgp_segment6                 in     varchar2
8082   ,p_pgp_segment7                 in     varchar2
8083   ,p_pgp_segment8                 in     varchar2
8084   ,p_pgp_segment9                 in     varchar2
8085   ,p_pgp_segment10                in     varchar2
8086   ,p_pgp_segment11                in     varchar2
8087   ,p_pgp_segment12                in     varchar2
8088   ,p_pgp_segment13                in     varchar2
8089   ,p_pgp_segment14                in     varchar2
8090   ,p_pgp_segment15                in     varchar2
8091   ,p_pgp_segment16                in     varchar2
8092   ,p_pgp_segment17                in     varchar2
8093   ,p_pgp_segment18                in     varchar2
8094   ,p_pgp_segment19                in     varchar2
8095   ,p_pgp_segment20                in     varchar2
8096   ,p_pgp_segment21                in     varchar2
8097   ,p_pgp_segment22                in     varchar2
8098   ,p_pgp_segment23                in     varchar2
8099   ,p_pgp_segment24                in     varchar2
8100   ,p_pgp_segment25                in     varchar2
8101   ,p_pgp_segment26                in     varchar2
8102   ,p_pgp_segment27                in     varchar2
8103   ,p_pgp_segment28                in     varchar2
8104   ,p_pgp_segment29                in     varchar2
8105   ,p_pgp_segment30                in     varchar2
8106 -- Bug 944911
8107 -- Made p_group_name to be out param
8108 -- and add p_concat_segment to be IN
8109 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8110   ,p_pgp_concat_segments	  in     varchar2
8111   ,p_supervisor_assignment_id     in     number
8112   ,p_group_name                      out nocopy varchar2
8113   ,p_assignment_id                   out nocopy number
8114   ,p_soft_coding_keyflex_id          out nocopy number
8115   ,p_people_group_id                 out nocopy number
8116   ,p_object_version_number           out nocopy number
8117   ,p_effective_start_date            out nocopy date
8118   ,p_effective_end_date              out nocopy date
8119   ,p_assignment_sequence             out nocopy number
8120   ,p_comment_id                      out nocopy number
8121 -- Bug 944911
8122 -- Amended p_concatenated_segments to out from in out
8123 -- added new param p_concat_segments in
8124   ,p_concatenated_segments           out nocopy varchar2
8125   ,p_concat_segments                 in     varchar2
8126   ,p_other_manager_warning           out nocopy boolean
8127   ,p_hourly_salaried_warning         out nocopy boolean
8128   ,p_cagr_grade_def_id               out nocopy number
8129   ,p_cagr_concatenated_segments      out nocopy varchar2
8130   ) is
8131   --
8132   -- Declare cursors and local variables
8133   --
8134   -- Declare variables
8135   --
8136   -- Assigned the value p_assignment_number for fix of #2823013
8137   l_assignment_number  per_all_assignments_f.assignment_number%TYPE := p_assignment_number;
8138   l_effective_date     date;
8139   --
8140   l_business_group_id  per_business_groups.business_group_id%TYPE;
8141   l_legislation_code   per_business_groups.legislation_code%TYPE;
8142   l_proc               varchar2(72);
8143   --
8144   -- Declare cursors
8145   --
8146   cursor csr_legislation is
8147     select null
8148     from per_all_assignments_f paf,
8149          per_business_groups_perf pbg
8150     where paf.person_id = p_person_id
8151     and   l_effective_date between paf.effective_start_date
8152                            and     paf.effective_end_date
8153     and   pbg.business_group_id = paf.business_group_id
8154     and   pbg.legislation_code = 'US';
8155   --
8156   --
8157 begin
8158  if g_debug then
8159  l_proc := g_package||'create_secondary_us_emp_asg';
8160   hr_utility.set_location('Entering:'|| l_proc, 10);
8161  end if;
8162   --
8163   -- Initialise local variable
8164   --
8165   l_effective_date := trunc(p_effective_date);
8166   --
8167   -- Validation in addition to Table Handlers
8168   --
8169   -- Ensure that the employee is within a US business group
8170   --
8171   open csr_legislation;
8172   fetch csr_legislation
8173   into l_legislation_code;
8174   if csr_legislation%notfound then
8175     close csr_legislation;
8176     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
8177     hr_utility.set_message_token('LEG_CODE', 'US');
8178     hr_utility.raise_error;
8179   end if;
8180   close csr_legislation;
8181   --
8182   --
8183   -- Call create_secondary_emp_asg
8184   --
8185 -- Bug 944911
8186 -- Added new param p_concat_segments in
8187 -- made p_concatenated_segments to be out only
8188 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
8189 
8190   hr_assignment_api.create_secondary_emp_asg
8191   (p_validate                     =>     p_validate
8192   ,p_effective_date               =>     l_effective_date
8193   ,p_person_id                    =>     p_person_id
8194   ,p_organization_id              =>     p_organization_id
8195   ,p_grade_id                     =>     p_grade_id
8196   ,p_position_id                  =>     p_position_id
8197   ,p_job_id                       =>     p_job_id
8198   ,p_assignment_status_type_id    =>     p_assignment_status_type_id
8199   ,p_payroll_id                   =>     p_payroll_id
8200   ,p_location_id                  =>     p_location_id
8201   ,p_supervisor_id                =>     p_supervisor_id
8202   ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
8203   ,p_pay_basis_id                 =>     p_pay_basis_id
8204   ,p_assignment_number            =>     l_assignment_number
8205   ,p_change_reason                =>     p_change_reason
8206   ,p_comments                     =>     p_comments
8207   ,p_date_probation_end           =>     trunc(p_date_probation_end)
8208   ,p_default_code_comb_id         =>     p_default_code_comb_id
8209   ,p_employment_category          =>     p_employment_category
8210   ,p_frequency                    =>     p_frequency
8211   ,p_internal_address_line        =>     p_internal_address_line
8212   ,p_manager_flag                 =>     p_manager_flag
8213   ,p_normal_hours                 =>     p_normal_hours
8214   ,p_perf_review_period           =>     p_perf_review_period
8215   ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
8216   ,p_probation_period             =>     p_probation_period
8217   ,p_probation_unit               =>     p_probation_unit
8218   ,p_sal_review_period            =>     p_sal_review_period
8219   ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
8220   ,p_set_of_books_id              =>     p_set_of_books_id
8221   ,p_source_type                  =>     p_source_type
8222   ,p_time_normal_finish           =>     p_time_normal_finish
8223   ,p_time_normal_start            =>     p_time_normal_start
8224   ,p_bargaining_unit_code         =>     p_bargaining_unit_code
8225   ,p_labour_union_member_flag     =>     p_labour_union_member_flag
8226   ,p_hourly_salaried_code         =>     p_hourly_salaried_code
8227   ,p_ass_attribute_category       =>     p_ass_attribute_category
8228   ,p_ass_attribute1               =>     p_ass_attribute1
8229   ,p_ass_attribute2               =>     p_ass_attribute2
8230   ,p_ass_attribute3               =>     p_ass_attribute3
8231   ,p_ass_attribute4               =>     p_ass_attribute4
8232   ,p_ass_attribute5               =>     p_ass_attribute5
8233   ,p_ass_attribute6               =>     p_ass_attribute6
8234   ,p_ass_attribute7               =>     p_ass_attribute7
8235   ,p_ass_attribute8               =>     p_ass_attribute8
8236   ,p_ass_attribute9               =>     p_ass_attribute9
8237   ,p_ass_attribute10              =>     p_ass_attribute10
8238   ,p_ass_attribute11              =>     p_ass_attribute11
8239   ,p_ass_attribute12              =>     p_ass_attribute12
8240   ,p_ass_attribute13              =>     p_ass_attribute13
8241   ,p_ass_attribute14              =>     p_ass_attribute14
8242   ,p_ass_attribute15              =>     p_ass_attribute15
8243   ,p_ass_attribute16              =>     p_ass_attribute16
8244   ,p_ass_attribute17              =>     p_ass_attribute17
8245   ,p_ass_attribute18              =>     p_ass_attribute18
8246   ,p_ass_attribute19              =>     p_ass_attribute19
8247   ,p_ass_attribute20              =>     p_ass_attribute20
8248   ,p_ass_attribute21              =>     p_ass_attribute21
8249   ,p_ass_attribute22              =>     p_ass_attribute22
8250   ,p_ass_attribute23              =>     p_ass_attribute23
8251   ,p_ass_attribute24              =>     p_ass_attribute24
8252   ,p_ass_attribute25              =>     p_ass_attribute25
8253   ,p_ass_attribute26              =>     p_ass_attribute26
8254   ,p_ass_attribute27              =>     p_ass_attribute27
8255   ,p_ass_attribute28              =>     p_ass_attribute28
8256   ,p_ass_attribute29              =>     p_ass_attribute29
8257   ,p_ass_attribute30              =>     p_ass_attribute30
8258   ,p_title                        =>     p_title
8259   ,p_scl_segment1                 =>     p_tax_unit
8260   ,p_scl_segment2                 =>     p_timecard_approver
8261   ,p_scl_segment3                 =>     p_timecard_required
8262   ,p_scl_segment4                 =>     p_work_schedule
8263   ,p_scl_segment5                 =>     p_shift
8264   ,p_scl_segment6                 =>     p_spouse_salary
8265   ,p_scl_segment7                 =>     p_legal_representative
8266   ,p_scl_segment8                 =>     p_wc_override_code
8267   ,p_scl_segment9                 =>     p_eeo_1_establishment
8268   ,p_pgp_segment1                 =>     p_pgp_segment1
8269   ,p_pgp_segment2                 =>     p_pgp_segment2
8270   ,p_pgp_segment3                 =>     p_pgp_segment3
8271   ,p_pgp_segment4                 =>     p_pgp_segment4
8272   ,p_pgp_segment5                 =>     p_pgp_segment5
8273   ,p_pgp_segment6                 =>     p_pgp_segment6
8274   ,p_pgp_segment7                 =>     p_pgp_segment7
8275   ,p_pgp_segment8                 =>     p_pgp_segment8
8276   ,p_pgp_segment9                 =>     p_pgp_segment9
8277   ,p_pgp_segment10                =>     p_pgp_segment10
8278   ,p_pgp_segment11                =>     p_pgp_segment11
8279   ,p_pgp_segment12                =>     p_pgp_segment12
8280   ,p_pgp_segment13                =>     p_pgp_segment13
8281   ,p_pgp_segment14                =>     p_pgp_segment14
8282   ,p_pgp_segment15                =>     p_pgp_segment15
8283   ,p_pgp_segment16                =>     p_pgp_segment16
8284   ,p_pgp_segment17                =>     p_pgp_segment17
8285   ,p_pgp_segment18                =>     p_pgp_segment18
8286   ,p_pgp_segment19                =>     p_pgp_segment19
8287   ,p_pgp_segment20                =>     p_pgp_segment20
8288   ,p_pgp_segment21                =>     p_pgp_segment21
8289   ,p_pgp_segment22                =>     p_pgp_segment22
8290   ,p_pgp_segment23                =>     p_pgp_segment23
8291   ,p_pgp_segment24                =>     p_pgp_segment24
8292   ,p_pgp_segment25                =>     p_pgp_segment25
8293   ,p_pgp_segment26                =>     p_pgp_segment26
8294   ,p_pgp_segment27                =>     p_pgp_segment27
8295   ,p_pgp_segment28                =>     p_pgp_segment28
8296   ,p_pgp_segment29                =>     p_pgp_segment29
8297   ,p_pgp_segment30                =>     p_pgp_segment30
8298 -- Bug 944911
8299 -- Made p_group_name to be out param
8300 -- and add p_concat_segment to be IN
8301 -- in case of sec_asg alone made p_pgp_concat_segments as in param
8302 -- Added new param p_pgp_concat_segments
8303   ,p_pgp_concat_segments	  =>	 p_pgp_concat_segments
8304   ,p_group_name                   =>     p_group_name
8305   ,p_assignment_id                =>     p_assignment_id
8306   ,p_soft_coding_keyflex_id       =>     p_soft_coding_keyflex_id
8307   ,p_people_group_id              =>     p_people_group_id
8308   ,p_object_version_number        =>     p_object_version_number
8309   ,p_effective_start_date         =>     p_effective_start_date
8310   ,p_effective_end_date           =>     p_effective_end_date
8311   ,p_assignment_sequence          =>     p_assignment_sequence
8312   ,p_comment_id                   =>     p_comment_id
8313   ,p_concatenated_segments        =>     p_concatenated_segments
8314   ,p_scl_concat_segments          =>     p_concat_segments
8315   ,p_other_manager_warning        =>     p_other_manager_warning
8316   ,p_hourly_salaried_warning      =>     p_hourly_salaried_warning
8317   ,p_cagr_grade_def_id            =>     p_cagr_grade_def_id
8318   ,p_cagr_concatenated_segments   =>     p_cagr_concatenated_segments
8319   ,p_supervisor_assignment_id     =>     p_supervisor_assignment_id
8320   );
8321   --
8322  if g_debug then
8323   hr_utility.set_location(' Leaving:'||l_proc, 30);
8324  end if;
8325   --
8326   end create_us_secondary_emp_asg;
8327 
8328 --
8329 -- ----------------------------------------------------------------------------
8330 -- |------------------------< final_process_emp_asg >-------------------------|
8331 -- ----------------------------------------------------------------------------
8332 --
8333 procedure final_process_emp_asg
8334   (p_validate                     in     boolean
8335   ,p_assignment_id                in     number
8336   ,p_object_version_number        in out nocopy number
8337   ,p_final_process_date           in     date
8338   ,p_effective_start_date            out nocopy date
8339   ,p_effective_end_date              out nocopy date
8340   ,p_org_now_no_manager_warning      out nocopy boolean
8341   ,p_asg_future_changes_warning      out nocopy boolean
8342   ,p_entries_changed_warning         out nocopy varchar2
8343   ) is
8344   --
8345   -- Declare cursors and local variables
8346   --
8347   -- Out variables
8348   --
8349   l_asg_future_changes_warning boolean := FALSE;
8350   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
8351   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
8352   l_entries_changed_warning    varchar2(1) := 'N';
8353   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
8354   l_org_now_no_manager_warning boolean := FALSE;
8355   --
8356   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
8357   l_primary_flag               per_all_assignments_f.primary_flag%TYPE;
8358   l_proc                       varchar2(72)
8359                                      := g_package || 'final_process_emp_asg';
8360   l_actual_termination_date    date;
8361   l_final_process_date         date;
8362   l_max_asg_end_date           date;
8363   --
8364   lv_object_version_number     number := p_object_version_number ;
8365   --
8366   cursor csr_get_derived_details is
8367     select asg.assignment_type
8368          , asg.primary_flag
8369       from per_all_assignments_f      asg
8370      where asg.assignment_id        = p_assignment_id
8371        and l_final_process_date     between asg.effective_start_date
8372                                     and     asg.effective_end_date;
8373   --
8374   cursor csr_valid_term_assign is
8375     select min(asg.effective_start_date) - 1
8376       from per_all_assignments_f           asg
8377      where asg.assignment_id             = p_assignment_id
8378        and exists ( select null
8379 		    from per_assignment_status_types ast
8380 		    where ast.assignment_status_type_id
8381 		     = asg.assignment_status_type_id
8382                      and ast.per_system_status = 'TERM_ASSIGN');
8383 
8384 --
8385   cursor csr_invalid_term_assign is
8386     select max(asg.effective_end_date)
8387       from per_all_assignments_f           asg
8388      where asg.assignment_id      = p_assignment_id
8389        and exists ( select null
8390 		    from per_assignment_status_types ast
8391 		    where ast.assignment_status_type_id
8392 		     = asg.assignment_status_type_id
8393                      and ast.per_system_status = 'TERM_ASSIGN');
8394 
8395 --
8396 begin
8397  if g_debug then
8398   hr_utility.set_location('Entering:'|| l_proc, 1);
8399  end if;
8400   --
8401   l_object_version_number := p_object_version_number;
8402   l_final_process_date    := trunc(p_final_process_date);
8403   --
8404   -- Issue a savepoint.
8405   --
8406   savepoint final_process_emp_asg;
8407   --
8408  if g_debug then
8409   hr_utility.set_location(l_proc, 10);
8410  end if;
8411   --
8412   -- Validation in addition to Table Handlers
8413   --
8414   -- Get assignment and business group details for validation.
8415   --
8416   hr_api.mandatory_arg_error
8417      (p_api_name       => l_proc
8418      ,p_argument       => 'assignment_id'
8419      ,p_argument_value => p_assignment_id
8420      );
8421   --
8422   hr_api.mandatory_arg_error
8423      (p_api_name       => l_proc
8424      ,p_argument       => 'final_process_date'
8425      ,p_argument_value => l_final_process_date
8426      );
8427   --
8428  if g_debug then
8429   hr_utility.set_location(l_proc, 20);
8430  end if;
8431   --
8432   open  csr_get_derived_details;
8433   fetch csr_get_derived_details
8434    into l_assignment_type
8435       , l_primary_flag;
8436   --
8437   if csr_get_derived_details%NOTFOUND
8438   then
8439     --
8440  if g_debug then
8441     hr_utility.set_location(l_proc, 30);
8442  end if;
8443     --
8444     close csr_get_derived_details;
8445     --
8446     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
8447     hr_utility.raise_error;
8448   end if;
8449   --
8450   close csr_get_derived_details;
8451   --
8452   -- Start of API User Hook for the before hook of final_process_emp_asg.
8453   --
8454   begin
8455      hr_assignment_bka.final_process_emp_asg_b
8456        (p_assignment_id                 =>  p_assignment_id
8457        ,p_object_version_number         =>  p_object_version_number
8458        ,p_final_process_date            =>  l_final_process_date
8459        );
8460   exception
8461      when hr_api.cannot_find_prog_unit then
8462        hr_api.cannot_find_prog_unit_error
8463          (p_module_name       => 'FINAL_PROCESS_EMP_ASG',
8464           p_hook_type         => 'BP'
8465          );
8466   end;
8467   --
8468   --
8469  if g_debug then
8470   hr_utility.set_location(l_proc, 40);
8471  end if;
8472   --
8473   -- The assignment must not be a primary assignment.
8474   --
8475   if l_primary_flag <> 'N'
8476   then
8477     --
8478  if g_debug then
8479     hr_utility.set_location(l_proc, 50);
8480  end if;
8481     --
8482     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
8483     hr_utility.raise_error;
8484   end if;
8485   --
8486  if g_debug then
8487   hr_utility.set_location(l_proc, 60);
8488  end if;
8489   --
8490   -- The assignment must be an employee assignment.
8491   --
8492   if l_assignment_type <> 'E'
8493   then
8494     --
8495  if g_debug then
8496     hr_utility.set_location(l_proc, 70);
8497  end if;
8498     --
8499     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
8500     hr_utility.raise_error;
8501   end if;
8502 
8503   -- Ensure that the assignment has not been terminated previously
8504 
8505   --
8506   open  csr_invalid_term_assign;
8507   fetch csr_invalid_term_assign
8508    into l_max_asg_end_date;
8509   close csr_invalid_term_assign;
8510 
8511   --
8512   if l_max_asg_end_date <> hr_api.g_eot
8513   then
8514     --
8515  if g_debug then
8516     hr_utility.set_location(l_proc, 90);
8517  end if;
8518     --
8519     hr_utility.set_message(801,'HR_7962_PDS_INV_FP_CHANGE');
8520     hr_utility.raise_error;
8521   end if;
8522   --
8523  if g_debug then
8524   hr_utility.set_location(l_proc, 80);
8525  end if;
8526   --
8527   -- Ensure that the the final process date is on or after the actual
8528   -- termination date by checking that the assignment status is TERM_ASSIGN for
8529   -- the day after the final process date.
8530   --
8531   open  csr_valid_term_assign;
8532   fetch csr_valid_term_assign
8533    into l_actual_termination_date;
8534   close csr_valid_term_assign;
8535 
8536   --
8537   if l_actual_termination_date is null
8538   then
8539     --
8540  if g_debug then
8541     hr_utility.set_location(l_proc, 90);
8542  end if;
8543     --
8544     hr_utility.set_message(801,'HR_51007_ASG_INV_NOT_ACT_TERM');
8545     hr_utility.raise_error;
8546   end if;
8547 
8548   if l_final_process_date < l_actual_termination_date then
8549 
8550  if g_debug then
8551     hr_utility.set_location(l_proc, 95);
8552  end if;
8553 
8554     -- This error message has been set temporarily
8555 
8556     hr_utility.set_message(801,'HR_7963_PDS_INV_FP_BEFORE_ATT');
8557     hr_utility.raise_error;
8558   end if;
8559   --
8560   --
8561  if g_debug then
8562   hr_utility.set_location(l_proc, 100);
8563  end if;
8564   --
8565   -- Process Logic
8566   --
8567   -- Call the business support process to update assignment and maintain the
8568   -- element entries.
8569   --
8570   hr_assignment_internal.final_process_emp_asg_sup
8571     (p_assignment_id              => p_assignment_id
8572     ,p_object_version_number      => l_object_version_number
8573     ,p_final_process_date         => l_final_process_date
8574     ,p_actual_termination_date    => l_actual_termination_date
8575     ,p_effective_start_date       => l_effective_start_date
8576     ,p_effective_end_date         => l_effective_end_date
8577     ,p_org_now_no_manager_warning => l_org_now_no_manager_warning
8578     ,p_asg_future_changes_warning => l_asg_future_changes_warning
8579     ,p_entries_changed_warning    => l_entries_changed_warning
8580     );
8581   --
8582  if g_debug then
8583   hr_utility.set_location(l_proc, 110);
8584  end if;
8585   --
8586   -- Start of API User Hook for the after hook of final_process_emp_asg.
8587   --
8588   begin
8589      hr_assignment_bka.final_process_emp_asg_a
8590         (p_assignment_id                 =>     p_assignment_id
8591         ,p_object_version_number         =>     l_object_version_number
8592         ,p_final_process_date            =>     p_final_process_date
8593         ,p_effective_start_date          =>     l_effective_start_date
8594         ,p_effective_end_date            =>     l_effective_end_date
8595         ,p_org_now_no_manager_warning    =>     l_org_now_no_manager_warning
8596         ,p_asg_future_changes_warning    =>     l_asg_future_changes_warning
8597         ,p_entries_changed_warning       =>     l_entries_changed_warning
8598         );
8599   exception
8600      when hr_api.cannot_find_prog_unit then
8601        hr_api.cannot_find_prog_unit_error
8602          (p_module_name       => 'FINAL_PROCESS_EMP_ASG',
8603           p_hook_type         => 'AP'
8604          );
8605   end;
8606   --
8607   -- End of API User Hook for the after hook of final_process_emp_asg.
8608   --
8609   --
8610   -- When in validation only mode raise the Validate_Enabled exception
8611   --
8612   if p_validate then
8613     raise hr_api.validate_enabled;
8614   end if;
8615   --
8616   -- Set all output arguments
8617   --
8618   p_asg_future_changes_warning := l_asg_future_changes_warning;
8619   p_effective_end_date         := l_effective_end_date;
8620   p_effective_start_date       := l_effective_start_date;
8621   p_entries_changed_warning    := l_entries_changed_warning;
8622   p_object_version_number      := l_object_version_number;
8623   p_org_now_no_manager_warning := l_org_now_no_manager_warning;
8624   --
8625  if g_debug then
8626   hr_utility.set_location(' Leaving:'||l_proc, 300);
8627  end if;
8628 exception
8629   when hr_api.validate_enabled then
8630     --
8631     -- As the Validate_Enabled exception has been raised
8632     -- we must rollback to the savepoint
8633     --
8634     ROLLBACK TO final_process_emp_asg;
8635     --
8636     -- Only set output warning arguments
8637     -- (Any key or derived arguments must be set to null
8638     -- when validation only mode is being used.)
8639     --
8640     p_asg_future_changes_warning := l_asg_future_changes_warning;
8641     p_effective_end_date         := null;
8642     p_effective_start_date       := null;
8643     p_entries_changed_warning    := l_entries_changed_warning;
8644     p_org_now_no_manager_warning := l_org_now_no_manager_warning;
8645     --
8646   when others then
8647     --
8648     -- A validation or unexpected error has occurred
8649     --
8650     -- Added as part of fix to bug 632479
8651     --
8652     p_object_version_number := lv_object_version_number;
8653 
8654     p_effective_start_date            := null;
8655     p_effective_end_date              := null;
8656     p_org_now_no_manager_warning      := null;
8657     p_asg_future_changes_warning      := null;
8658     p_entries_changed_warning         := null;
8659 
8660 
8661     ROLLBACK TO final_process_emp_asg;
8662     raise;
8663     --
8664     -- End of fix.
8665     --
8666 end final_process_emp_asg;
8667 --
8668 -- 70.4 change end.
8669 --
8670 -- ----------------------------------------------------------------------------
8671 -- |---------------------------< suspend_emp_asg >----------------------------|
8672 -- ----------------------------------------------------------------------------
8673 --
8674 procedure suspend_emp_asg
8675   (p_validate                     in     boolean
8676   ,p_effective_date               in     date
8677   ,p_datetrack_update_mode        in     varchar2
8678   ,p_assignment_id                in     number
8679   ,p_change_reason                in     varchar2
8680   ,p_object_version_number        in out nocopy number
8681   ,p_assignment_status_type_id    in     number
8682   ,p_effective_start_date            out nocopy date
8683   ,p_effective_end_date              out nocopy date
8684   ) is
8685   --
8686   -- Declare cursors and local variables
8687   --
8688   l_effective_date             date;
8689   --
8690   -- Out variables
8691   --
8692   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
8693   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
8694   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
8695   --
8696   lv_object_version_number     number := p_object_version_number ;
8697   --
8698   l_proc                       varchar2(72);
8699   --
8700 begin
8701  if g_debug then
8702  l_proc := g_package||'suspend_emp_asg';
8703   hr_utility.set_location('Entering:'|| l_proc, 5);
8704  end if;
8705   --
8706   --
8707   l_object_version_number := p_object_version_number;
8708   --
8709   -- Issue a savepoint.
8710   --
8711   savepoint suspend_emp_asg;
8712   --
8713  if g_debug then
8714   hr_utility.set_location(l_proc, 10);
8715  end if;
8716   --
8717   -- Initialise local variable - added 25-Aug-97. RMF.
8718   --
8719   l_effective_date := trunc(p_effective_date);
8720   --
8721   -- Validation in addition to Table Handlers
8722   --
8723   -- None required.
8724   --
8725   -- Process Logic
8726   --
8727   -- Start of API User Hook for the before hook of suspend_emp_asg.
8728   --
8729   begin
8730      hr_assignment_bk7.suspend_emp_asg_b
8731        (p_effective_date               => l_effective_date
8732        ,p_datetrack_update_mode        => p_datetrack_update_mode
8733        ,p_assignment_id                => p_assignment_id
8734        ,p_change_reason                => p_change_reason
8735        ,p_object_version_number        => p_object_version_number
8736        ,p_assignment_status_type_id    => p_assignment_status_type_id
8737        );
8738   exception
8739      when hr_api.cannot_find_prog_unit then
8740        hr_api.cannot_find_prog_unit_error
8741          (p_module_name       => 'SUSPEND_EMP_ASG',
8742           p_hook_type         => 'BP'
8743          );
8744   end;
8745   --
8746   --
8747   -- Update employee assignment.
8748   --
8749   hr_assignment_internal.update_status_type_emp_asg
8750     (p_effective_date               => l_effective_date
8751     ,p_datetrack_update_mode        => p_datetrack_update_mode
8752     ,p_assignment_id                => p_assignment_id
8753     ,p_change_reason                => p_change_reason
8754     ,p_object_version_number        => l_object_version_number
8755     ,p_expected_system_status       => 'SUSP_ASSIGN'
8756     ,p_assignment_status_type_id    => p_assignment_status_type_id
8757     ,p_effective_start_date         => l_effective_start_date
8758     ,p_effective_end_date           => l_effective_end_date
8759     );
8760   --
8761  if g_debug then
8762   hr_utility.set_location(l_proc, 20);
8763  end if;
8764   --
8765   -- Start of API User Hook for the after hook of suspend_emp_asg.
8766   --
8767   begin
8768      hr_assignment_bk7.suspend_emp_asg_a
8769         (p_effective_date               => l_effective_date
8770         ,p_datetrack_update_mode        => p_datetrack_update_mode
8771         ,p_assignment_id                => p_assignment_id
8772         ,p_change_reason                => p_change_reason
8773         ,p_object_version_number        => l_object_version_number
8774         ,p_assignment_status_type_id    => p_assignment_status_type_id
8775         ,p_effective_start_date         => l_effective_start_date
8776         ,p_effective_end_date           => l_effective_end_date
8777         );
8778   exception
8779      when hr_api.cannot_find_prog_unit then
8780        hr_api.cannot_find_prog_unit_error
8781          (p_module_name       => 'SUSPEND_EMP_ASG',
8782           p_hook_type         => 'AP'
8783          );
8784   end;
8785   --
8786   -- End of API User Hook for the after hook of suspend_emp_asg.
8787   --
8788   --
8789   -- When in validation only mode raise the Validate_Enabled exception
8790   --
8791   if p_validate then
8792     raise hr_api.validate_enabled;
8793   end if;
8794   --
8795   -- Set all output arguments
8796   --
8797   p_object_version_number := l_object_version_number;
8798   p_effective_start_date  := l_effective_start_date;
8799   p_effective_end_date    := l_effective_end_date;
8800   --
8801  if g_debug then
8802   hr_utility.set_location(' Leaving:'||l_proc, 100);
8803  end if;
8804 exception
8805   when hr_api.validate_enabled then
8806     --
8807     -- As the Validate_Enabled exception has been raised
8808     -- we must rollback to the savepoint
8809     --
8810     ROLLBACK TO suspend_emp_asg;
8811     --
8812     -- Only set output warning arguments
8813     -- (Any key or derived arguments must be set to null
8814     -- when validation only mode is being used.)
8815     --
8816     p_object_version_number  := p_object_version_number;
8817     p_effective_start_date   := null;
8818     p_effective_end_date     := null;
8819     --
8820   when others then
8821     --
8822     -- A validation or unexpected error has occurred
8823     --
8824     -- Added as part of fix to bug 632479
8825     --
8826     p_object_version_number := lv_object_version_number;
8827     p_effective_start_date   := null;
8828     p_effective_end_date     := null;
8829     --
8830     ROLLBACK TO suspend_emp_asg;
8831     raise;
8832     --
8833     -- End of fix.
8834     --
8835 end suspend_emp_asg;
8836 --
8837 -- ----------------------------------------------------------------------------
8838 -- |--------------------------< update_emp_asg >-OLD--------------------------|
8839 -- ----------------------------------------------------------------------------
8840 -- This is the old procedure that simply calls the new updated
8841 -- procedure passing in nulls for the new in parms and trapping
8842 -- new out parms in local variables.
8843 --
8844 procedure update_emp_asg
8845   (p_validate                     in     boolean
8846   ,p_effective_date               in     date
8847   ,p_datetrack_update_mode        in     varchar2
8848   ,p_assignment_id                in     number
8849   ,p_object_version_number        in out nocopy number
8850   ,p_supervisor_id                in     number
8851   ,p_assignment_number            in     varchar2
8852   ,p_change_reason                in     varchar2
8853   ,p_comments                     in     varchar2
8854   ,p_date_probation_end           in     date
8855   ,p_default_code_comb_id         in     number
8856   ,p_frequency                    in     varchar2
8857   ,p_internal_address_line        in     varchar2
8858   ,p_manager_flag                 in     varchar2
8859   ,p_normal_hours                 in     number
8860   ,p_perf_review_period           in     number
8861   ,p_perf_review_period_frequency in     varchar2
8862   ,p_probation_period             in     number
8863   ,p_probation_unit               in     varchar2
8864   ,p_sal_review_period            in     number
8865   ,p_sal_review_period_frequency  in     varchar2
8866   ,p_set_of_books_id              in     number
8867   ,p_source_type                  in     varchar2
8868   ,p_time_normal_finish           in     varchar2
8869   ,p_time_normal_start            in     varchar2
8870   ,p_bargaining_unit_code         in     varchar2
8871   ,p_labour_union_member_flag     in     varchar2
8872   ,p_hourly_salaried_code         in     varchar2
8873   ,p_ass_attribute_category       in     varchar2
8874   ,p_ass_attribute1               in     varchar2
8875   ,p_ass_attribute2               in     varchar2
8876   ,p_ass_attribute3               in     varchar2
8877   ,p_ass_attribute4               in     varchar2
8878   ,p_ass_attribute5               in     varchar2
8879   ,p_ass_attribute6               in     varchar2
8880   ,p_ass_attribute7               in     varchar2
8881   ,p_ass_attribute8               in     varchar2
8882   ,p_ass_attribute9               in     varchar2
8883   ,p_ass_attribute10              in     varchar2
8884   ,p_ass_attribute11              in     varchar2
8885   ,p_ass_attribute12              in     varchar2
8886   ,p_ass_attribute13              in     varchar2
8887   ,p_ass_attribute14              in     varchar2
8888   ,p_ass_attribute15              in     varchar2
8889   ,p_ass_attribute16              in     varchar2
8890   ,p_ass_attribute17              in     varchar2
8891   ,p_ass_attribute18              in     varchar2
8892   ,p_ass_attribute19              in     varchar2
8893   ,p_ass_attribute20              in     varchar2
8894   ,p_ass_attribute21              in     varchar2
8895   ,p_ass_attribute22              in     varchar2
8896   ,p_ass_attribute23              in     varchar2
8897   ,p_ass_attribute24              in     varchar2
8898   ,p_ass_attribute25              in     varchar2
8899   ,p_ass_attribute26              in     varchar2
8900   ,p_ass_attribute27              in     varchar2
8901   ,p_ass_attribute28              in     varchar2
8902   ,p_ass_attribute29              in     varchar2
8903   ,p_ass_attribute30              in     varchar2
8904   ,p_title                        in     varchar2
8905   ,p_segment1                     in     varchar2
8906   ,p_segment2                     in     varchar2
8907   ,p_segment3                     in     varchar2
8908   ,p_segment4                     in     varchar2
8909   ,p_segment5                     in     varchar2
8910   ,p_segment6                     in     varchar2
8911   ,p_segment7                     in     varchar2
8912   ,p_segment8                     in     varchar2
8913   ,p_segment9                     in     varchar2
8914   ,p_segment10                    in     varchar2
8915   ,p_segment11                    in     varchar2
8916   ,p_segment12                    in     varchar2
8917   ,p_segment13                    in     varchar2
8918   ,p_segment14                    in     varchar2
8919   ,p_segment15                    in     varchar2
8920   ,p_segment16                    in     varchar2
8921   ,p_segment17                    in     varchar2
8922   ,p_segment18                    in     varchar2
8923   ,p_segment19                    in     varchar2
8924   ,p_segment20                    in     varchar2
8925   ,p_segment21                    in     varchar2
8926   ,p_segment22                    in     varchar2
8927   ,p_segment23                    in     varchar2
8928   ,p_segment24                    in     varchar2
8929   ,p_segment25                    in     varchar2
8930   ,p_segment26                    in     varchar2
8931   ,p_segment27                    in     varchar2
8932   ,p_segment28                    in     varchar2
8933   ,p_segment29                    in     varchar2
8934   ,p_segment30                    in     varchar2
8935 -- Bug fix for 944911
8936 -- p_concatenated_segments has been changed from in out to out
8937 -- Added new param p_concat_segments as in param
8938   ,p_concat_segments              in     varchar2
8939   ,p_supervisor_assignment_id     in     number
8940   ,p_concatenated_segments           out nocopy varchar2
8941   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
8942   ,p_comment_id                      out nocopy number
8943   ,p_effective_start_date            out nocopy date
8944   ,p_effective_end_date              out nocopy date
8945   ,p_no_managers_warning             out nocopy boolean
8946   ,p_other_manager_warning           out nocopy boolean
8947   ) is
8948   --
8949   -- Declare cursors and local variables
8950   --
8951   -- Out variables
8952   --
8953   l_comment_id             per_all_assignments_f.comment_id%TYPE;
8954   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
8955   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
8956   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
8957   l_no_managers_warning    boolean;
8958   l_other_manager_warning  boolean;
8959   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
8960   := p_soft_coding_keyflex_id; -- bug 2359997
8961   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
8962   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
8963   l_effective_date         date;
8964   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
8965   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
8966   l_organization_id        per_all_assignments_f.organization_id%type;
8967   l_location_id            per_all_assignments_f.location_id%type;
8968   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE;
8969   l_cagr_concatenated_segments varchar2(2000);
8970   l_proc                       varchar2(72);
8971   --
8972   begin
8973   --
8974   l_object_version_number := p_object_version_number;
8975   --
8976  if g_debug then
8977  l_proc := g_package||'update_emp_asg';
8978   hr_utility.set_location('Entering:'|| l_proc, 5);
8979  end if;
8980   ---- Call the new code
8981  hr_assignment_api.update_emp_asg
8982   (p_validate                     => p_validate
8983   ,p_effective_date               => p_effective_date
8984   ,p_datetrack_update_mode        => p_datetrack_update_mode
8985   ,p_assignment_id                => p_assignment_id
8986   ,p_object_version_number        => l_object_version_number
8987   ,p_supervisor_id                => p_supervisor_id
8988   ,p_assignment_number            => p_assignment_number
8989   ,p_change_reason                => p_change_reason
8990   ,p_comments                     => p_comments
8991   ,p_date_probation_end           => p_date_probation_end
8992   ,p_default_code_comb_id         => p_default_code_comb_id
8993   ,p_frequency                    => p_frequency
8994   ,p_internal_address_line        => p_internal_address_line
8995   ,p_manager_flag                 => p_manager_flag
8996   ,p_normal_hours                 => p_normal_hours
8997   ,p_perf_review_period           => p_perf_review_period
8998   ,p_perf_review_period_frequency => p_perf_review_period_frequency
8999   ,p_probation_period             => p_probation_period
9000   ,p_probation_unit               => p_probation_unit
9001   ,p_sal_review_period            => p_sal_review_period
9002   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
9003   ,p_set_of_books_id              => p_set_of_books_id
9004   ,p_source_type                  => p_source_type
9005   ,p_time_normal_finish           => p_time_normal_finish
9006   ,p_time_normal_start            => p_time_normal_start
9007   ,p_bargaining_unit_code         => p_bargaining_unit_code
9008   ,p_labour_union_member_flag     => p_labour_union_member_flag
9009   ,p_hourly_salaried_code         => p_hourly_salaried_code
9010   ,p_ass_attribute_category       => p_ass_attribute_category
9011   ,p_ass_attribute1               => p_ass_attribute1
9012   ,p_ass_attribute2               => p_ass_attribute2
9013   ,p_ass_attribute3               => p_ass_attribute3
9014   ,p_ass_attribute4               => p_ass_attribute4
9015   ,p_ass_attribute5               => p_ass_attribute5
9016   ,p_ass_attribute6               => p_ass_attribute6
9017   ,p_ass_attribute7               => p_ass_attribute7
9018   ,p_ass_attribute8               => p_ass_attribute8
9019   ,p_ass_attribute9               => p_ass_attribute9
9020   ,p_ass_attribute10              => p_ass_attribute10
9021   ,p_ass_attribute11              => p_ass_attribute11
9022   ,p_ass_attribute12              => p_ass_attribute12
9023   ,p_ass_attribute13              => p_ass_attribute13
9024   ,p_ass_attribute14              => p_ass_attribute14
9025   ,p_ass_attribute15              => p_ass_attribute15
9026   ,p_ass_attribute16              => p_ass_attribute16
9027   ,p_ass_attribute17              => p_ass_attribute17
9028   ,p_ass_attribute18              => p_ass_attribute18
9029   ,p_ass_attribute19              => p_ass_attribute19
9030   ,p_ass_attribute20              => p_ass_attribute20
9031   ,p_ass_attribute21              => p_ass_attribute21
9032   ,p_ass_attribute22              => p_ass_attribute22
9033   ,p_ass_attribute23              => p_ass_attribute23
9034   ,p_ass_attribute24              => p_ass_attribute24
9035   ,p_ass_attribute25              => p_ass_attribute25
9036   ,p_ass_attribute26              => p_ass_attribute26
9037   ,p_ass_attribute27              => p_ass_attribute27
9038   ,p_ass_attribute28              => p_ass_attribute28
9039   ,p_ass_attribute29              => p_ass_attribute29
9040   ,p_ass_attribute30              => p_ass_attribute30
9041   ,p_title                        => p_title
9042   ,p_segment1                     => p_segment1
9043   ,p_segment2                     => p_segment2
9044   ,p_segment3                     => p_segment3
9045   ,p_segment4                     => p_segment4
9046   ,p_segment5                     => p_segment5
9047   ,p_segment6                     => p_segment6
9048   ,p_segment7                     => p_segment7
9049   ,p_segment8                     => p_segment8
9050   ,p_segment9                     => p_segment9
9051   ,p_segment10                    => p_segment10
9052   ,p_segment11                    => p_segment11
9053   ,p_segment12                    => p_segment12
9054   ,p_segment13                    => p_segment13
9055   ,p_segment14                    => p_segment14
9056   ,p_segment15                    => p_segment15
9057   ,p_segment16                    => p_segment16
9058   ,p_segment17                    => p_segment17
9059   ,p_segment18                    => p_segment18
9060   ,p_segment19                    => p_segment19
9061   ,p_segment20                    => p_segment20
9062   ,p_segment21                    => p_segment21
9063   ,p_segment22                    => p_segment22
9064   ,p_segment23                    => p_segment23
9065   ,p_segment24                    => p_segment24
9066   ,p_segment25                    => p_segment25
9067   ,p_segment26                    => p_segment26
9068   ,p_segment27                    => p_segment27
9069   ,p_segment28                    => p_segment28
9070   ,p_segment29                    => p_segment29
9071   ,p_segment30                    => p_segment30
9072   ,p_concat_segments              => p_concat_segments
9073   ,p_contract_id                  => hr_api.g_number
9074   ,p_establishment_id             => hr_api.g_number
9075   ,p_collective_agreement_id      => hr_api.g_number
9076   ,p_cagr_id_flex_num             => hr_api.g_number
9077   ,p_cag_segment1                 => hr_api.g_varchar2
9078   ,p_cag_segment2                 => hr_api.g_varchar2
9079   ,p_cag_segment3                 => hr_api.g_varchar2
9080   ,p_cag_segment4                 => hr_api.g_varchar2
9081   ,p_cag_segment5                 => hr_api.g_varchar2
9082   ,p_cag_segment6                 => hr_api.g_varchar2
9083   ,p_cag_segment7                 => hr_api.g_varchar2
9084   ,p_cag_segment8                 => hr_api.g_varchar2
9085   ,p_cag_segment9                 => hr_api.g_varchar2
9086   ,p_cag_segment10                => hr_api.g_varchar2
9087   ,p_cag_segment11                => hr_api.g_varchar2
9088   ,p_cag_segment12                => hr_api.g_varchar2
9089   ,p_cag_segment13                => hr_api.g_varchar2
9090   ,p_cag_segment14                => hr_api.g_varchar2
9091   ,p_cag_segment15                => hr_api.g_varchar2
9092   ,p_cag_segment16                => hr_api.g_varchar2
9093   ,p_cag_segment17                => hr_api.g_varchar2
9094   ,p_cag_segment18                => hr_api.g_varchar2
9095   ,p_cag_segment19                => hr_api.g_varchar2
9096   ,p_cag_segment20                => hr_api.g_varchar2
9097   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
9098   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
9099   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
9100   ,p_comment_id                   => l_comment_id
9101   ,p_effective_start_date         => l_effective_start_date
9102   ,p_effective_end_date           => l_effective_end_date
9103   ,p_concatenated_segments        => l_concatenated_segments
9104   ,p_no_managers_warning          => l_no_managers_warning
9105   ,p_other_manager_warning        => l_other_manager_warning
9106   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
9107 );
9108 
9109   -- Set all output arguments
9110   --
9111   p_object_version_number  := l_object_version_number;
9112   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
9113   p_comment_id             := l_comment_id;
9114   p_effective_start_date   := l_effective_start_date;
9115   p_effective_end_date     := l_effective_end_date;
9116   p_concatenated_segments  := l_concatenated_segments;
9117   p_no_managers_warning    := l_no_managers_warning;
9118   p_other_manager_warning  := l_other_manager_warning;
9119 
9120   --
9121  if g_debug then
9122   hr_utility.set_location(' Leaving:'||l_proc, 30);
9123  end if;
9124 end update_emp_asg;
9125 -- ----------------------------------------------------------------------------
9126 -- |--------------------------< update_emp_asg >--NEW--------------------------|
9127 -- ----------------------------------------------------------------------------
9128 --
9129 -- This is an overloaded procedure to include new parms
9130 -- for collective agreements and contracts
9131 -- added new parameters notice_period, units, employee_category,
9132 -- work_at_home and job_source on 05-OCT-01
9133 --
9134 procedure update_emp_asg
9135   (p_validate                     in     boolean
9136   ,p_effective_date               in     date
9137   ,p_datetrack_update_mode        in     varchar2
9138   ,p_assignment_id                in     number
9139   ,p_object_version_number        in out nocopy number
9140   ,p_supervisor_id                in     number
9141   ,p_assignment_number            in     varchar2
9142   ,p_change_reason                in     varchar2
9143   ,p_assignment_status_type_id    in     number
9144   ,p_comments                     in     varchar2
9145   ,p_date_probation_end           in     date
9146   ,p_default_code_comb_id         in     number
9147   ,p_frequency                    in     varchar2
9148   ,p_internal_address_line        in     varchar2
9149   ,p_manager_flag                 in     varchar2
9150   ,p_normal_hours                 in     number
9151   ,p_perf_review_period           in     number
9152   ,p_perf_review_period_frequency in     varchar2
9153   ,p_probation_period             in     number
9154   ,p_probation_unit               in     varchar2
9155   ,p_sal_review_period            in     number
9156   ,p_sal_review_period_frequency  in     varchar2
9157   ,p_set_of_books_id              in     number
9158   ,p_source_type                  in     varchar2
9159   ,p_time_normal_finish           in     varchar2
9160   ,p_time_normal_start            in     varchar2
9161   ,p_bargaining_unit_code         in     varchar2
9162   ,p_labour_union_member_flag     in     varchar2
9163   ,p_hourly_salaried_code         in     varchar2
9164   ,p_ass_attribute_category       in     varchar2
9165   ,p_ass_attribute1               in     varchar2
9166   ,p_ass_attribute2               in     varchar2
9167   ,p_ass_attribute3               in     varchar2
9168   ,p_ass_attribute4               in     varchar2
9169   ,p_ass_attribute5               in     varchar2
9170   ,p_ass_attribute6               in     varchar2
9171   ,p_ass_attribute7               in     varchar2
9172   ,p_ass_attribute8               in     varchar2
9173   ,p_ass_attribute9               in     varchar2
9174   ,p_ass_attribute10              in     varchar2
9175   ,p_ass_attribute11              in     varchar2
9176   ,p_ass_attribute12              in     varchar2
9177   ,p_ass_attribute13              in     varchar2
9178   ,p_ass_attribute14              in     varchar2
9179   ,p_ass_attribute15              in     varchar2
9180   ,p_ass_attribute16              in     varchar2
9181   ,p_ass_attribute17              in     varchar2
9182   ,p_ass_attribute18              in     varchar2
9183   ,p_ass_attribute19              in     varchar2
9184   ,p_ass_attribute20              in     varchar2
9185   ,p_ass_attribute21              in     varchar2
9186   ,p_ass_attribute22              in     varchar2
9187   ,p_ass_attribute23              in     varchar2
9188   ,p_ass_attribute24              in     varchar2
9189   ,p_ass_attribute25              in     varchar2
9190   ,p_ass_attribute26              in     varchar2
9191   ,p_ass_attribute27              in     varchar2
9192   ,p_ass_attribute28              in     varchar2
9193   ,p_ass_attribute29              in     varchar2
9194   ,p_ass_attribute30              in     varchar2
9195   ,p_title                        in     varchar2
9196   ,p_segment1                     in     varchar2
9197   ,p_segment2                     in     varchar2
9198   ,p_segment3                     in     varchar2
9199   ,p_segment4                     in     varchar2
9200   ,p_segment5                     in     varchar2
9201   ,p_segment6                     in     varchar2
9202   ,p_segment7                     in     varchar2
9203   ,p_segment8                     in     varchar2
9204   ,p_segment9                     in     varchar2
9205   ,p_segment10                    in     varchar2
9206   ,p_segment11                    in     varchar2
9207   ,p_segment12                    in     varchar2
9208   ,p_segment13                    in     varchar2
9209   ,p_segment14                    in     varchar2
9210   ,p_segment15                    in     varchar2
9211   ,p_segment16                    in     varchar2
9212   ,p_segment17                    in     varchar2
9213   ,p_segment18                    in     varchar2
9214   ,p_segment19                    in     varchar2
9215   ,p_segment20                    in     varchar2
9216   ,p_segment21                    in     varchar2
9217   ,p_segment22                    in     varchar2
9218   ,p_segment23                    in     varchar2
9219   ,p_segment24                    in     varchar2
9220   ,p_segment25                    in     varchar2
9221   ,p_segment26                    in     varchar2
9222   ,p_segment27                    in     varchar2
9223   ,p_segment28                    in     varchar2
9224   ,p_segment29                    in     varchar2
9225   ,p_segment30                    in     varchar2
9226 -- Bug fix for 944911
9227 -- p_concatenated_segments has been changed from in out to out
9228 -- Added new param p_concat_segments as in param
9229   ,p_concat_segments              in     varchar2
9230   ,p_contract_id                  in     number
9231   ,p_establishment_id             in     number
9232   ,p_collective_agreement_id      in     number
9233   ,p_cagr_id_flex_num             in     number
9234   ,p_cag_segment1                 in     varchar2
9235   ,p_cag_segment2                 in     varchar2
9236   ,p_cag_segment3                 in     varchar2
9237   ,p_cag_segment4                 in     varchar2
9238   ,p_cag_segment5                 in     varchar2
9239   ,p_cag_segment6                 in     varchar2
9240   ,p_cag_segment7                 in     varchar2
9241   ,p_cag_segment8                 in     varchar2
9242   ,p_cag_segment9                 in     varchar2
9243   ,p_cag_segment10                in     varchar2
9244   ,p_cag_segment11                in     varchar2
9245   ,p_cag_segment12                in     varchar2
9246   ,p_cag_segment13                in     varchar2
9247   ,p_cag_segment14                in     varchar2
9248   ,p_cag_segment15                in     varchar2
9249   ,p_cag_segment16                in     varchar2
9250   ,p_cag_segment17                in     varchar2
9251   ,p_cag_segment18                in     varchar2
9252   ,p_cag_segment19                in     varchar2
9253   ,p_cag_segment20                in     varchar2
9254   ,p_notice_period		  in     number
9255   ,p_notice_period_uom	      	  in     varchar2
9256   ,p_employee_category	          in     varchar2
9257   ,p_work_at_home		  in     varchar2
9258   ,p_job_post_source_name	  in     varchar2
9259   ,p_supervisor_assignment_id     in     number
9260   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
9261   ,p_cagr_concatenated_segments      out nocopy varchar2
9262   ,p_concatenated_segments           out nocopy varchar2
9263   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
9264   ,p_comment_id                      out nocopy number
9265   ,p_effective_start_date            out nocopy date
9266   ,p_effective_end_date              out nocopy date
9267   ,p_no_managers_warning             out nocopy boolean
9268   ,p_other_manager_warning           out nocopy boolean
9269   ) is
9270   --
9271   -- Declare cursors and local variables
9272   --
9273   -- Out variables
9274   --
9275   l_comment_id              per_all_assignments_f.comment_id%TYPE;
9276   l_effective_start_date    per_all_assignments_f.effective_start_date%TYPE;
9277   l_effective_end_date      per_all_assignments_f.effective_end_date%TYPE;
9278   l_object_version_number   per_all_assignments_f.object_version_number%TYPE;
9279   l_no_managers_warning     boolean;
9280   l_other_manager_warning   boolean;
9281   l_hourly_salaried_warning boolean;
9282   l_soft_coding_keyflex_id  per_all_assignments_f.soft_coding_keyflex_id%TYPE
9283   := p_soft_coding_keyflex_id; -- bug 2359997
9284   l_concatenated_segments   hr_soft_coding_keyflex.concatenated_segments%TYPE;
9285   l_old_conc_segments       hr_soft_coding_keyflex.concatenated_segments%TYPE;
9286   l_effective_date          date;
9287   l_date_probation_end      per_all_assignments_f.date_probation_end%TYPE;
9288   l_flex_num                fnd_id_flex_segments.id_flex_num%TYPE;
9289   l_organization_id         per_all_assignments_f.organization_id%type;
9290   l_location_id             per_all_assignments_f.location_id%type;
9291   l_cagr_grade_def_id       per_cagr_grades_def.cagr_grade_def_id%TYPE
9292   := p_cagr_grade_def_id;   -- bug 2359997
9293   l_cagr_id_flex_num        per_cagr_grades_def.id_flex_num%TYPE;
9294   l_cagr_concatenated_segments varchar2(2000);
9295   l_proc                       varchar2(72);
9296 
9297   begin
9298   --
9299   l_object_version_number := p_object_version_number;
9300   --
9301  if g_debug then
9302   l_proc := g_package||'update_emp_asg';
9303   hr_utility.set_location('Entering:'|| l_proc, 5);
9304  end if;
9305   ---- Call the new code
9306   -- Added notice_period through to job_post_source_name in this call as they
9307   -- were missing
9308   -- see bug 2122535 for details
9309   --
9310  hr_assignment_api.update_emp_asg
9311   (p_validate                     => p_validate
9312   ,p_effective_date               => p_effective_date
9313   ,p_datetrack_update_mode        => p_datetrack_update_mode
9314   ,p_assignment_id                => p_assignment_id
9315   ,p_object_version_number        => l_object_version_number
9316   ,p_supervisor_id                => p_supervisor_id
9317   ,p_assignment_number            => p_assignment_number
9318   ,p_change_reason                => p_change_reason
9319   ,p_assignment_status_type_id    => p_assignment_status_type_id
9320   ,p_comments                     => p_comments
9321   ,p_date_probation_end           => p_date_probation_end
9322   ,p_default_code_comb_id         => p_default_code_comb_id
9323   ,p_frequency                    => p_frequency
9324   ,p_internal_address_line        => p_internal_address_line
9325   ,p_manager_flag                 => p_manager_flag
9326   ,p_normal_hours                 => p_normal_hours
9327   ,p_perf_review_period           => p_perf_review_period
9328   ,p_perf_review_period_frequency => p_perf_review_period_frequency
9329   ,p_probation_period             => p_probation_period
9330   ,p_probation_unit               => p_probation_unit
9331   ,p_sal_review_period            => p_sal_review_period
9332   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
9333   ,p_set_of_books_id              => p_set_of_books_id
9334   ,p_source_type                  => p_source_type
9335   ,p_time_normal_finish           => p_time_normal_finish
9336   ,p_time_normal_start            => p_time_normal_start
9337   ,p_bargaining_unit_code         => p_bargaining_unit_code
9338   ,p_labour_union_member_flag     => p_labour_union_member_flag
9339   ,p_hourly_salaried_code         => p_hourly_salaried_code
9340   ,p_ass_attribute_category       => p_ass_attribute_category
9341   ,p_ass_attribute1               => p_ass_attribute1
9342   ,p_ass_attribute2               => p_ass_attribute2
9343   ,p_ass_attribute3               => p_ass_attribute3
9344   ,p_ass_attribute4               => p_ass_attribute4
9345   ,p_ass_attribute5               => p_ass_attribute5
9346   ,p_ass_attribute6               => p_ass_attribute6
9347   ,p_ass_attribute7               => p_ass_attribute7
9348   ,p_ass_attribute8               => p_ass_attribute8
9349   ,p_ass_attribute9               => p_ass_attribute9
9350   ,p_ass_attribute10              => p_ass_attribute10
9351   ,p_ass_attribute11              => p_ass_attribute11
9352   ,p_ass_attribute12              => p_ass_attribute12
9353   ,p_ass_attribute13              => p_ass_attribute13
9354   ,p_ass_attribute14              => p_ass_attribute14
9355   ,p_ass_attribute15              => p_ass_attribute15
9356   ,p_ass_attribute16              => p_ass_attribute16
9357   ,p_ass_attribute17              => p_ass_attribute17
9358   ,p_ass_attribute18              => p_ass_attribute18
9359   ,p_ass_attribute19              => p_ass_attribute19
9360   ,p_ass_attribute20              => p_ass_attribute20
9361   ,p_ass_attribute21              => p_ass_attribute21
9362   ,p_ass_attribute22              => p_ass_attribute22
9363   ,p_ass_attribute23              => p_ass_attribute23
9364   ,p_ass_attribute24              => p_ass_attribute24
9365   ,p_ass_attribute25              => p_ass_attribute25
9366   ,p_ass_attribute26              => p_ass_attribute26
9367   ,p_ass_attribute27              => p_ass_attribute27
9368   ,p_ass_attribute28              => p_ass_attribute28
9369   ,p_ass_attribute29              => p_ass_attribute29
9370   ,p_ass_attribute30              => p_ass_attribute30
9371   ,p_title                        => p_title
9372   ,p_segment1                     => p_segment1
9373   ,p_segment2                     => p_segment2
9374   ,p_segment3                     => p_segment3
9375   ,p_segment4                     => p_segment4
9376   ,p_segment5                     => p_segment5
9377   ,p_segment6                     => p_segment6
9378   ,p_segment7                     => p_segment7
9379   ,p_segment8                     => p_segment8
9380   ,p_segment9                     => p_segment9
9381   ,p_segment10                    => p_segment10
9382   ,p_segment11                    => p_segment11
9383   ,p_segment12                    => p_segment12
9384   ,p_segment13                    => p_segment13
9385   ,p_segment14                    => p_segment14
9386   ,p_segment15                    => p_segment15
9387   ,p_segment16                    => p_segment16
9388   ,p_segment17                    => p_segment17
9389   ,p_segment18                    => p_segment18
9390   ,p_segment19                    => p_segment19
9391   ,p_segment20                    => p_segment20
9392   ,p_segment21                    => p_segment21
9393   ,p_segment22                    => p_segment22
9394   ,p_segment23                    => p_segment23
9395   ,p_segment24                    => p_segment24
9396   ,p_segment25                    => p_segment25
9397   ,p_segment26                    => p_segment26
9398   ,p_segment27                    => p_segment27
9399   ,p_segment28                    => p_segment28
9400   ,p_segment29                    => p_segment29
9401   ,p_segment30                    => p_segment30
9402   ,p_concat_segments              => p_concat_segments
9403   ,p_contract_id                  => p_contract_id
9404   ,p_establishment_id             => p_establishment_id
9405   ,p_collective_agreement_id      => p_collective_agreement_id
9406   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
9407   ,p_cag_segment1                 => p_cag_segment1
9408   ,p_cag_segment2                 => p_cag_segment2
9409   ,p_cag_segment3                 => p_cag_segment3
9410   ,p_cag_segment4                 => p_cag_segment4
9411   ,p_cag_segment5                 => p_cag_segment5
9412   ,p_cag_segment6                 => p_cag_segment6
9413   ,p_cag_segment7                 => p_cag_segment7
9414   ,p_cag_segment8                 => p_cag_segment8
9415   ,p_cag_segment9                 => p_cag_segment9
9416   ,p_cag_segment10                => p_cag_segment10
9417   ,p_cag_segment11                => p_cag_segment11
9418   ,p_cag_segment12                => p_cag_segment12
9419   ,p_cag_segment13                => p_cag_segment13
9420   ,p_cag_segment14                => p_cag_segment14
9421   ,p_cag_segment15                => p_cag_segment15
9422   ,p_cag_segment16                => p_cag_segment16
9423   ,p_cag_segment17                => p_cag_segment17
9424   ,p_cag_segment18                => p_cag_segment18
9425   ,p_cag_segment19                => p_cag_segment19
9426   ,p_cag_segment20                => p_cag_segment20
9427   ,p_notice_period                => p_notice_period
9428   ,p_notice_period_uom            => p_notice_period_uom
9429   ,p_employee_category            => p_employee_category
9430   ,p_work_at_home                 => p_work_at_home
9431   ,p_job_post_source_name	  => p_job_post_source_name
9432   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
9433   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
9434   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
9435   ,p_comment_id                   => l_comment_id
9436   ,p_effective_start_date         => l_effective_start_date
9437   ,p_effective_end_date           => l_effective_end_date
9438   ,p_concatenated_segments        => l_concatenated_segments
9439   ,p_no_managers_warning          => l_no_managers_warning
9440   ,p_other_manager_warning        => l_other_manager_warning
9441   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
9442   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
9443 );
9444   --
9445   -- Set all output arguments
9446   --
9447   p_object_version_number  := l_object_version_number;
9448   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
9449   p_comment_id             := l_comment_id;
9450   p_effective_start_date   := l_effective_start_date;
9451   p_effective_end_date     := l_effective_end_date;
9452   p_concatenated_segments  := l_concatenated_segments;
9453   p_no_managers_warning    := l_no_managers_warning;
9454   p_other_manager_warning  := l_other_manager_warning;
9455   --
9456  if g_debug then
9457   hr_utility.set_location(' Leaving:'||l_proc, 30);
9458  end if;
9459 end update_emp_asg;
9460 -- ----------------------------------------------------------------------------
9461 -- |-------------------------< update_emp_asg >--NEW2-------------------------|
9462 -- ----------------------------------------------------------------------------
9463 --
9464 -- This is an overloaded procedure to include new parms
9465 -- for collective agreements and contracts
9466 -- added new parameters notice_period, units, employee_category,
9467 -- work_at_home and job_source on 05-OCT-01
9468 --
9469 procedure update_emp_asg
9470   (p_validate                     in     boolean
9471   ,p_effective_date               in     date
9472   ,p_datetrack_update_mode        in     varchar2
9473   ,p_assignment_id                in     number
9474   ,p_object_version_number        in out nocopy number
9475   ,p_supervisor_id                in     number
9476   ,p_assignment_number            in     varchar2
9477   ,p_change_reason                in     varchar2
9478   ,p_assignment_status_type_id    in     number
9479   ,p_comments                     in     varchar2
9480   ,p_date_probation_end           in     date
9481   ,p_default_code_comb_id         in     number
9482   ,p_frequency                    in     varchar2
9483   ,p_internal_address_line        in     varchar2
9484   ,p_manager_flag                 in     varchar2
9485   ,p_normal_hours                 in     number
9486   ,p_perf_review_period           in     number
9487   ,p_perf_review_period_frequency in     varchar2
9488   ,p_probation_period             in     number
9489   ,p_probation_unit               in     varchar2
9490   ,p_sal_review_period            in     number
9491   ,p_sal_review_period_frequency  in     varchar2
9492   ,p_set_of_books_id              in     number
9493   ,p_source_type                  in     varchar2
9494   ,p_time_normal_finish           in     varchar2
9495   ,p_time_normal_start            in     varchar2
9496   ,p_bargaining_unit_code         in     varchar2
9497   ,p_labour_union_member_flag     in     varchar2
9498   ,p_hourly_salaried_code         in     varchar2
9499   ,p_ass_attribute_category       in     varchar2
9500   ,p_ass_attribute1               in     varchar2
9501   ,p_ass_attribute2               in     varchar2
9502   ,p_ass_attribute3               in     varchar2
9503   ,p_ass_attribute4               in     varchar2
9504   ,p_ass_attribute5               in     varchar2
9505   ,p_ass_attribute6               in     varchar2
9506   ,p_ass_attribute7               in     varchar2
9507   ,p_ass_attribute8               in     varchar2
9508   ,p_ass_attribute9               in     varchar2
9509   ,p_ass_attribute10              in     varchar2
9510   ,p_ass_attribute11              in     varchar2
9511   ,p_ass_attribute12              in     varchar2
9512   ,p_ass_attribute13              in     varchar2
9513   ,p_ass_attribute14              in     varchar2
9514   ,p_ass_attribute15              in     varchar2
9515   ,p_ass_attribute16              in     varchar2
9516   ,p_ass_attribute17              in     varchar2
9517   ,p_ass_attribute18              in     varchar2
9518   ,p_ass_attribute19              in     varchar2
9519   ,p_ass_attribute20              in     varchar2
9520   ,p_ass_attribute21              in     varchar2
9521   ,p_ass_attribute22              in     varchar2
9522   ,p_ass_attribute23              in     varchar2
9523   ,p_ass_attribute24              in     varchar2
9524   ,p_ass_attribute25              in     varchar2
9525   ,p_ass_attribute26              in     varchar2
9526   ,p_ass_attribute27              in     varchar2
9527   ,p_ass_attribute28              in     varchar2
9528   ,p_ass_attribute29              in     varchar2
9529   ,p_ass_attribute30              in     varchar2
9530   ,p_title                        in     varchar2
9531   ,p_segment1                     in     varchar2
9532   ,p_segment2                     in     varchar2
9533   ,p_segment3                     in     varchar2
9534   ,p_segment4                     in     varchar2
9535   ,p_segment5                     in     varchar2
9536   ,p_segment6                     in     varchar2
9537   ,p_segment7                     in     varchar2
9538   ,p_segment8                     in     varchar2
9539   ,p_segment9                     in     varchar2
9540   ,p_segment10                    in     varchar2
9541   ,p_segment11                    in     varchar2
9542   ,p_segment12                    in     varchar2
9543   ,p_segment13                    in     varchar2
9544   ,p_segment14                    in     varchar2
9545   ,p_segment15                    in     varchar2
9546   ,p_segment16                    in     varchar2
9547   ,p_segment17                    in     varchar2
9548   ,p_segment18                    in     varchar2
9549   ,p_segment19                    in     varchar2
9550   ,p_segment20                    in     varchar2
9551   ,p_segment21                    in     varchar2
9552   ,p_segment22                    in     varchar2
9553   ,p_segment23                    in     varchar2
9554   ,p_segment24                    in     varchar2
9555   ,p_segment25                    in     varchar2
9556   ,p_segment26                    in     varchar2
9557   ,p_segment27                    in     varchar2
9558   ,p_segment28                    in     varchar2
9559   ,p_segment29                    in     varchar2
9560   ,p_segment30                    in     varchar2
9561 -- Bug fix for 944911
9562 -- p_concatenated_segments has been changed from in out to out
9563 -- Added new param p_concat_segments as in param
9564   ,p_concat_segments              in     varchar2
9565   ,p_contract_id                  in     number
9566   ,p_establishment_id             in     number
9567   ,p_collective_agreement_id      in     number
9568   ,p_cagr_id_flex_num             in     number
9569   ,p_cag_segment1                 in     varchar2
9570   ,p_cag_segment2                 in     varchar2
9571   ,p_cag_segment3                 in     varchar2
9572   ,p_cag_segment4                 in     varchar2
9573   ,p_cag_segment5                 in     varchar2
9574   ,p_cag_segment6                 in     varchar2
9575   ,p_cag_segment7                 in     varchar2
9576   ,p_cag_segment8                 in     varchar2
9577   ,p_cag_segment9                 in     varchar2
9578   ,p_cag_segment10                in     varchar2
9579   ,p_cag_segment11                in     varchar2
9580   ,p_cag_segment12                in     varchar2
9581   ,p_cag_segment13                in     varchar2
9582   ,p_cag_segment14                in     varchar2
9583   ,p_cag_segment15                in     varchar2
9584   ,p_cag_segment16                in     varchar2
9585   ,p_cag_segment17                in     varchar2
9586   ,p_cag_segment18                in     varchar2
9587   ,p_cag_segment19                in     varchar2
9588   ,p_cag_segment20                in     varchar2
9589   ,p_notice_period		  in     number
9590   ,p_notice_period_uom	      	  in     varchar2
9591   ,p_employee_category	          in     varchar2
9592   ,p_work_at_home		  in     varchar2
9593   ,p_job_post_source_name	  in     varchar2
9594   ,p_supervisor_assignment_id     in     number
9595   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
9596   ,p_cagr_concatenated_segments      out nocopy varchar2
9597   ,p_concatenated_segments           out nocopy varchar2
9598   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
9599   ,p_comment_id                      out nocopy number
9600   ,p_effective_start_date            out nocopy date
9601   ,p_effective_end_date              out nocopy date
9602   ,p_no_managers_warning             out nocopy boolean
9603   ,p_other_manager_warning           out nocopy boolean
9604   ,p_hourly_salaried_warning         out nocopy boolean
9605   ) is
9606   --
9607   -- Declare cursors and local variables
9608   --
9609   -- Out variables
9610   --
9611   l_comment_id             per_all_assignments_f.comment_id%TYPE;
9612   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
9613   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
9614   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
9615   l_no_managers_warning    boolean;
9616   l_other_manager_warning  boolean;
9617   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
9618   := p_soft_coding_keyflex_id;  -- bug 2359997
9619   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9620   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9621   l_effective_date         date;
9622   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
9623   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
9624   l_organization_id        per_all_assignments_f.organization_id%type;
9625   l_location_id            per_all_assignments_f.location_id%type;
9626   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
9627   := p_cagr_grade_def_id;  -- bug 2359997
9628   l_cagr_id_flex_num       per_cagr_grades_def.id_flex_num%TYPE;
9629   l_cagr_concatenated_segments varchar2(2000);
9630   l_hourly_salaried_warning boolean;
9631   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
9632   --
9633   -- Internal working variables
9634   --
9635   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
9636   l_business_group_id          per_business_groups.business_group_id%TYPE;
9637   l_payroll_id_updated         boolean;
9638   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
9639   l_org_now_no_manager_warning boolean;
9640   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
9641   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
9642   l_proc                       varchar2(72) := g_package||'update_emp_asg';
9643   l_session_id                 number;
9644   l_unused_start_date          date;
9645   l_unused_end_date            date;
9646   l_old_asg_status per_assignment_status_types.per_system_status%type;
9647   l_new_asg_status per_assignment_status_types.per_system_status%type;
9648 
9649 begin
9650  --
9651   l_object_version_number := p_object_version_number;
9652 
9653  if g_debug then
9654   hr_utility.set_location(' Entering:'||l_proc, 10);
9655  end if;
9656   --
9657   -- Call the new code
9658   -- Added p_gsp_post_process_warning
9659   --
9660   hr_assignment_api.update_emp_asg
9661   (p_validate                     => p_validate
9662   ,p_effective_date               => p_effective_date
9663   ,p_datetrack_update_mode        => p_datetrack_update_mode
9664   ,p_assignment_id                => p_assignment_id
9665   ,p_object_version_number        => l_object_version_number
9666   ,p_supervisor_id                => p_supervisor_id
9667   ,p_assignment_number            => p_assignment_number
9668   ,p_change_reason                => p_change_reason
9669   ,p_assignment_status_type_id    => p_assignment_status_type_id
9670   ,p_comments                     => p_comments
9671   ,p_date_probation_end           => p_date_probation_end
9672   ,p_default_code_comb_id         => p_default_code_comb_id
9673   ,p_frequency                    => p_frequency
9674   ,p_internal_address_line        => p_internal_address_line
9675   ,p_manager_flag                 => p_manager_flag
9676   ,p_normal_hours                 => p_normal_hours
9677   ,p_perf_review_period           => p_perf_review_period
9678   ,p_perf_review_period_frequency => p_perf_review_period_frequency
9679   ,p_probation_period             => p_probation_period
9680   ,p_probation_unit               => p_probation_unit
9681   ,p_sal_review_period            => p_sal_review_period
9682   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
9683   ,p_set_of_books_id              => p_set_of_books_id
9684   ,p_source_type                  => p_source_type
9685   ,p_time_normal_finish           => p_time_normal_finish
9686   ,p_time_normal_start            => p_time_normal_start
9687   ,p_bargaining_unit_code         => p_bargaining_unit_code
9688   ,p_labour_union_member_flag     => p_labour_union_member_flag
9689   ,p_hourly_salaried_code         => p_hourly_salaried_code
9690   ,p_ass_attribute_category       => p_ass_attribute_category
9691   ,p_ass_attribute1               => p_ass_attribute1
9692   ,p_ass_attribute2               => p_ass_attribute2
9693   ,p_ass_attribute3               => p_ass_attribute3
9694   ,p_ass_attribute4               => p_ass_attribute4
9695   ,p_ass_attribute5               => p_ass_attribute5
9696   ,p_ass_attribute6               => p_ass_attribute6
9697   ,p_ass_attribute7               => p_ass_attribute7
9698   ,p_ass_attribute8               => p_ass_attribute8
9699   ,p_ass_attribute9               => p_ass_attribute9
9700   ,p_ass_attribute10              => p_ass_attribute10
9701   ,p_ass_attribute11              => p_ass_attribute11
9702   ,p_ass_attribute12              => p_ass_attribute12
9703   ,p_ass_attribute13              => p_ass_attribute13
9704   ,p_ass_attribute14              => p_ass_attribute14
9705   ,p_ass_attribute15              => p_ass_attribute15
9706   ,p_ass_attribute16              => p_ass_attribute16
9707   ,p_ass_attribute17              => p_ass_attribute17
9708   ,p_ass_attribute18              => p_ass_attribute18
9709   ,p_ass_attribute19              => p_ass_attribute19
9710   ,p_ass_attribute20              => p_ass_attribute20
9711   ,p_ass_attribute21              => p_ass_attribute21
9712   ,p_ass_attribute22              => p_ass_attribute22
9713   ,p_ass_attribute23              => p_ass_attribute23
9714   ,p_ass_attribute24              => p_ass_attribute24
9715   ,p_ass_attribute25              => p_ass_attribute25
9716   ,p_ass_attribute26              => p_ass_attribute26
9717   ,p_ass_attribute27              => p_ass_attribute27
9718   ,p_ass_attribute28              => p_ass_attribute28
9719   ,p_ass_attribute29              => p_ass_attribute29
9720   ,p_ass_attribute30              => p_ass_attribute30
9721   ,p_title                        => p_title
9722   ,p_segment1                     => p_segment1
9723   ,p_segment2                     => p_segment2
9724   ,p_segment3                     => p_segment3
9725   ,p_segment4                     => p_segment4
9726   ,p_segment5                     => p_segment5
9727   ,p_segment6                     => p_segment6
9728   ,p_segment7                     => p_segment7
9729   ,p_segment8                     => p_segment8
9730   ,p_segment9                     => p_segment9
9731   ,p_segment10                    => p_segment10
9732   ,p_segment11                    => p_segment11
9733   ,p_segment12                    => p_segment12
9734   ,p_segment13                    => p_segment13
9735   ,p_segment14                    => p_segment14
9736   ,p_segment15                    => p_segment15
9737   ,p_segment16                    => p_segment16
9738   ,p_segment17                    => p_segment17
9739   ,p_segment18                    => p_segment18
9740   ,p_segment19                    => p_segment19
9741   ,p_segment20                    => p_segment20
9742   ,p_segment21                    => p_segment21
9743   ,p_segment22                    => p_segment22
9744   ,p_segment23                    => p_segment23
9745   ,p_segment24                    => p_segment24
9746   ,p_segment25                    => p_segment25
9747   ,p_segment26                    => p_segment26
9748   ,p_segment27                    => p_segment27
9749   ,p_segment28                    => p_segment28
9750   ,p_segment29                    => p_segment29
9751   ,p_segment30                    => p_segment30
9752   ,p_concat_segments              => p_concat_segments
9753   ,p_contract_id                  => p_contract_id
9754   ,p_establishment_id             => p_establishment_id
9755   ,p_collective_agreement_id      => p_collective_agreement_id
9756   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
9757   ,p_cag_segment1                 => p_cag_segment1
9758   ,p_cag_segment2                 => p_cag_segment2
9759   ,p_cag_segment3                 => p_cag_segment3
9760   ,p_cag_segment4                 => p_cag_segment4
9761   ,p_cag_segment5                 => p_cag_segment5
9762   ,p_cag_segment6                 => p_cag_segment6
9763   ,p_cag_segment7                 => p_cag_segment7
9764   ,p_cag_segment8                 => p_cag_segment8
9765   ,p_cag_segment9                 => p_cag_segment9
9766   ,p_cag_segment10                => p_cag_segment10
9767   ,p_cag_segment11                => p_cag_segment11
9768   ,p_cag_segment12                => p_cag_segment12
9769   ,p_cag_segment13                => p_cag_segment13
9770   ,p_cag_segment14                => p_cag_segment14
9771   ,p_cag_segment15                => p_cag_segment15
9772   ,p_cag_segment16                => p_cag_segment16
9773   ,p_cag_segment17                => p_cag_segment17
9774   ,p_cag_segment18                => p_cag_segment18
9775   ,p_cag_segment19                => p_cag_segment19
9776   ,p_cag_segment20                => p_cag_segment20
9777   ,p_notice_period                => p_notice_period
9778   ,p_notice_period_uom            => p_notice_period_uom
9779   ,p_employee_category            => p_employee_category
9780   ,p_work_at_home                 => p_work_at_home
9781   ,p_job_post_source_name	  => p_job_post_source_name
9782   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
9783   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
9784   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
9785   ,p_comment_id                   => l_comment_id
9786   ,p_effective_start_date         => l_effective_start_date
9787   ,p_effective_end_date           => l_effective_end_date
9788   ,p_concatenated_segments        => l_concatenated_segments
9789   ,p_no_managers_warning          => l_no_managers_warning
9790   ,p_other_manager_warning        => l_other_manager_warning
9791   ,p_hourly_salaried_warning      => l_hourly_salaried_warning
9792   ,p_gsp_post_process_warning     => l_gsp_post_process_warning
9793   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
9794 ); -- bug 2999562
9795 
9796   --
9797   -- Set all output arguments
9798   --
9799   p_object_version_number  := l_object_version_number;
9800   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
9801   p_comment_id             := l_comment_id;
9802   p_effective_start_date   := l_effective_start_date;
9803   p_effective_end_date     := l_effective_end_date;
9804   p_concatenated_segments  := l_concatenated_segments;
9805   p_no_managers_warning    := l_no_managers_warning;
9806   p_other_manager_warning  := l_other_manager_warning;
9807   p_cagr_grade_def_id          := l_cagr_grade_def_id;
9808   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
9809   p_hourly_salaried_warning    := l_hourly_salaried_warning;
9810   --
9811   --
9812  if g_debug then
9813   hr_utility.set_location(' Leaving:'||l_proc, 30);
9814  end if;
9815 end update_emp_asg;
9816 -- ----------------------------------------------------------------------------
9817 -- |-------------------------< update_emp_asg >--NEW3-------------------------|
9818 -- ----------------------------------------------------------------------------
9819 --
9820 -- This is an overloaded procedure to include p_gsp_post_process_warning
9821 -- OUT parameter.
9822 --
9823 procedure update_emp_asg
9824   (p_validate                     in     boolean
9825   ,p_effective_date               in     date
9826   ,p_datetrack_update_mode        in     varchar2
9827   ,p_assignment_id                in     number
9828   ,p_object_version_number        in out nocopy number
9829   ,p_supervisor_id                in     number
9830   ,p_assignment_number            in     varchar2
9831   ,p_change_reason                in     varchar2
9832   ,p_assignment_status_type_id    in     number
9833   ,p_comments                     in     varchar2
9834   ,p_date_probation_end           in     date
9835   ,p_default_code_comb_id         in     number
9836   ,p_frequency                    in     varchar2
9837   ,p_internal_address_line        in     varchar2
9838   ,p_manager_flag                 in     varchar2
9839   ,p_normal_hours                 in     number
9840   ,p_perf_review_period           in     number
9841   ,p_perf_review_period_frequency in     varchar2
9842   ,p_probation_period             in     number
9843   ,p_probation_unit               in     varchar2
9844   ,p_projected_assignment_end     in     varchar2
9845   ,p_sal_review_period            in     number
9846   ,p_sal_review_period_frequency  in     varchar2
9847   ,p_set_of_books_id              in     number
9848   ,p_source_type                  in     varchar2
9849   ,p_time_normal_finish           in     varchar2
9850   ,p_time_normal_start            in     varchar2
9851   ,p_bargaining_unit_code         in     varchar2
9852   ,p_labour_union_member_flag     in     varchar2
9853   ,p_hourly_salaried_code         in     varchar2
9854   ,p_ass_attribute_category       in     varchar2
9855   ,p_ass_attribute1               in     varchar2
9856   ,p_ass_attribute2               in     varchar2
9857   ,p_ass_attribute3               in     varchar2
9858   ,p_ass_attribute4               in     varchar2
9859   ,p_ass_attribute5               in     varchar2
9860   ,p_ass_attribute6               in     varchar2
9861   ,p_ass_attribute7               in     varchar2
9862   ,p_ass_attribute8               in     varchar2
9863   ,p_ass_attribute9               in     varchar2
9864   ,p_ass_attribute10              in     varchar2
9865   ,p_ass_attribute11              in     varchar2
9866   ,p_ass_attribute12              in     varchar2
9867   ,p_ass_attribute13              in     varchar2
9868   ,p_ass_attribute14              in     varchar2
9869   ,p_ass_attribute15              in     varchar2
9870   ,p_ass_attribute16              in     varchar2
9871   ,p_ass_attribute17              in     varchar2
9872   ,p_ass_attribute18              in     varchar2
9873   ,p_ass_attribute19              in     varchar2
9874   ,p_ass_attribute20              in     varchar2
9875   ,p_ass_attribute21              in     varchar2
9876   ,p_ass_attribute22              in     varchar2
9877   ,p_ass_attribute23              in     varchar2
9878   ,p_ass_attribute24              in     varchar2
9879   ,p_ass_attribute25              in     varchar2
9880   ,p_ass_attribute26              in     varchar2
9881   ,p_ass_attribute27              in     varchar2
9882   ,p_ass_attribute28              in     varchar2
9883   ,p_ass_attribute29              in     varchar2
9884   ,p_ass_attribute30              in     varchar2
9885   ,p_title                        in     varchar2
9886   ,p_segment1                     in     varchar2
9887   ,p_segment2                     in     varchar2
9888   ,p_segment3                     in     varchar2
9889   ,p_segment4                     in     varchar2
9890   ,p_segment5                     in     varchar2
9891   ,p_segment6                     in     varchar2
9892   ,p_segment7                     in     varchar2
9893   ,p_segment8                     in     varchar2
9894   ,p_segment9                     in     varchar2
9895   ,p_segment10                    in     varchar2
9896   ,p_segment11                    in     varchar2
9897   ,p_segment12                    in     varchar2
9898   ,p_segment13                    in     varchar2
9899   ,p_segment14                    in     varchar2
9900   ,p_segment15                    in     varchar2
9901   ,p_segment16                    in     varchar2
9902   ,p_segment17                    in     varchar2
9903   ,p_segment18                    in     varchar2
9904   ,p_segment19                    in     varchar2
9905   ,p_segment20                    in     varchar2
9906   ,p_segment21                    in     varchar2
9907   ,p_segment22                    in     varchar2
9908   ,p_segment23                    in     varchar2
9909   ,p_segment24                    in     varchar2
9910   ,p_segment25                    in     varchar2
9911   ,p_segment26                    in     varchar2
9912   ,p_segment27                    in     varchar2
9913   ,p_segment28                    in     varchar2
9914   ,p_segment29                    in     varchar2
9915   ,p_segment30                    in     varchar2
9916 -- Bug fix for 944911
9917 -- p_concatenated_segments has been changed from in out to out
9918 -- Added new param p_concat_segments as in param
9919   ,p_concat_segments              in     varchar2
9920   ,p_contract_id                  in     number
9921   ,p_establishment_id             in     number
9922   ,p_collective_agreement_id      in     number
9923   ,p_cagr_id_flex_num             in     number
9924   ,p_cag_segment1                 in     varchar2
9925   ,p_cag_segment2                 in     varchar2
9926   ,p_cag_segment3                 in     varchar2
9927   ,p_cag_segment4                 in     varchar2
9928   ,p_cag_segment5                 in     varchar2
9929   ,p_cag_segment6                 in     varchar2
9930   ,p_cag_segment7                 in     varchar2
9931   ,p_cag_segment8                 in     varchar2
9932   ,p_cag_segment9                 in     varchar2
9933   ,p_cag_segment10                in     varchar2
9934   ,p_cag_segment11                in     varchar2
9935   ,p_cag_segment12                in     varchar2
9936   ,p_cag_segment13                in     varchar2
9937   ,p_cag_segment14                in     varchar2
9938   ,p_cag_segment15                in     varchar2
9939   ,p_cag_segment16                in     varchar2
9940   ,p_cag_segment17                in     varchar2
9941   ,p_cag_segment18                in     varchar2
9942   ,p_cag_segment19                in     varchar2
9943   ,p_cag_segment20                in     varchar2
9944   ,p_notice_period		  in     number
9945   ,p_notice_period_uom	      	  in     varchar2
9946   ,p_employee_category	          in     varchar2
9947   ,p_work_at_home		  in     varchar2
9948   ,p_job_post_source_name	  in     varchar2
9949   ,p_supervisor_assignment_id     in     number
9950   ,p_cagr_grade_def_id            in out nocopy number -- bug 2359997
9951   ,p_cagr_concatenated_segments      out nocopy varchar2
9952   ,p_concatenated_segments           out nocopy varchar2
9953   ,p_soft_coding_keyflex_id       in out nocopy number -- bug 2359997
9954   ,p_comment_id                      out nocopy number
9955   ,p_effective_start_date            out nocopy date
9956   ,p_effective_end_date              out nocopy date
9957   ,p_no_managers_warning             out nocopy boolean
9958   ,p_other_manager_warning           out nocopy boolean
9959   ,p_hourly_salaried_warning         out nocopy boolean
9960   ,p_gsp_post_process_warning        out nocopy varchar2
9961   ) is
9962   --
9963   -- Declare cursors and local variables
9964   --
9965   -- Out variables
9966   --
9967   l_comment_id             per_all_assignments_f.comment_id%TYPE;
9968   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
9969   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
9970   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
9971   l_no_managers_warning    boolean;
9972   l_other_manager_warning  boolean;
9973   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE
9974   := p_soft_coding_keyflex_id;  -- bug 2359997
9975   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9976   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
9977   l_effective_date         date;
9978   l_date_probation_end     per_all_assignments_f.date_probation_end%TYPE;
9979   l_flex_num               fnd_id_flex_segments.id_flex_num%TYPE;
9980   l_organization_id        per_all_assignments_f.organization_id%type;
9981   l_location_id            per_all_assignments_f.location_id%type;
9982   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE
9983   := p_cagr_grade_def_id;  -- bug 2359997
9984   l_cagr_id_flex_num       per_cagr_grades_def.id_flex_num%TYPE;
9985   l_cagr_concatenated_segments varchar2(2000);
9986   l_hourly_salaried_warning boolean;
9987   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
9988   --
9989   -- Internal working variables
9990   --
9991   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
9992   l_business_group_id          per_business_groups.business_group_id%TYPE;
9993   l_payroll_id_updated         boolean;
9994   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
9995   l_org_now_no_manager_warning boolean;
9996   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
9997   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
9998   l_proc                       varchar2(72) := g_package||'update_emp_asg';
9999   l_session_id                 number;
10000   l_unused_start_date          date;
10001   l_unused_end_date            date;
10002   l_old_asg_status per_assignment_status_types.per_system_status%type;
10003   l_new_asg_status per_assignment_status_types.per_system_status%type;
10004   --
10005   -- bug 2359997 new variables to indicate whether key flex id parameters
10006   -- enter the program with a value.
10007   --
10008   --l_scl_null_ind               number(1) := 0;
10009   l_cag_null_ind               number(1) := 0;
10010   --
10011   -- bug 2359997 new variables for derived values where key flex id is known.
10012   --
10013   l_scl_segment1               varchar2(60) := p_segment1;
10014   l_scl_segment2               varchar2(60) := p_segment2;
10015   l_scl_segment3               varchar2(60) := p_segment3;
10016   l_scl_segment4               varchar2(60) := p_segment4;
10017   l_scl_segment5               varchar2(60) := p_segment5;
10018   l_scl_segment6               varchar2(60) := p_segment6;
10019   l_scl_segment7               varchar2(60) := p_segment7;
10020   l_scl_segment8               varchar2(60) := p_segment8;
10021   l_scl_segment9               varchar2(60) := p_segment9;
10022   l_scl_segment10              varchar2(60) := p_segment10;
10023   l_scl_segment11              varchar2(60) := p_segment11;
10024   l_scl_segment12              varchar2(60) := p_segment12;
10025   l_scl_segment13              varchar2(60) := p_segment13;
10026   l_scl_segment14              varchar2(60) := p_segment14;
10027   l_scl_segment15              varchar2(60) := p_segment15;
10028   l_scl_segment16              varchar2(60) := p_segment16;
10029   l_scl_segment17              varchar2(60) := p_segment17;
10030   l_scl_segment18              varchar2(60) := p_segment18;
10031   l_scl_segment19              varchar2(60) := p_segment19;
10032   l_scl_segment20              varchar2(60) := p_segment20;
10033   l_scl_segment21              varchar2(60) := p_segment21;
10034   l_scl_segment22              varchar2(60) := p_segment22;
10035   l_scl_segment23              varchar2(60) := p_segment23;
10036   l_scl_segment24              varchar2(60) := p_segment24;
10037   l_scl_segment25              varchar2(60) := p_segment25;
10038   l_scl_segment26              varchar2(60) := p_segment26;
10039   l_scl_segment27              varchar2(60) := p_segment27;
10040   l_scl_segment28              varchar2(60) := p_segment28;
10041   l_scl_segment29              varchar2(60) := p_segment29;
10042   l_scl_segment30              varchar2(60) := p_segment30;
10043   --
10044   l_cag_segment1               varchar2(60) := p_cag_segment1;
10045   l_cag_segment2               varchar2(60) := p_cag_segment2;
10046   l_cag_segment3               varchar2(60) := p_cag_segment3;
10047   l_cag_segment4               varchar2(60) := p_cag_segment4;
10048   l_cag_segment5               varchar2(60) := p_cag_segment5;
10049   l_cag_segment6               varchar2(60) := p_cag_segment6;
10050   l_cag_segment7               varchar2(60) := p_cag_segment7;
10051   l_cag_segment8               varchar2(60) := p_cag_segment8;
10052   l_cag_segment9               varchar2(60) := p_cag_segment9;
10053   l_cag_segment10              varchar2(60) := p_cag_segment10;
10054   l_cag_segment11              varchar2(60) := p_cag_segment11;
10055   l_cag_segment12              varchar2(60) := p_cag_segment12;
10056   l_cag_segment13              varchar2(60) := p_cag_segment13;
10057   l_cag_segment14              varchar2(60) := p_cag_segment14;
10058   l_cag_segment15              varchar2(60) := p_cag_segment15;
10059   l_cag_segment16              varchar2(60) := p_cag_segment16;
10060   l_cag_segment17              varchar2(60) := p_cag_segment17;
10061   l_cag_segment18              varchar2(60) := p_cag_segment18;
10062   l_cag_segment19              varchar2(60) := p_cag_segment19;
10063   l_cag_segment20              varchar2(60) := p_cag_segment20;
10064   --
10065   lv_object_version_number     number := p_object_version_number ;
10066   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
10067   lv_soft_coding_keyflex_id    number := p_soft_coding_keyflex_id ;
10068   --
10069   l_projected_assignment_end date;--fix for bug 6595592.
10070   cursor csr_old_asg_status is
10071   select ast.per_system_status
10072   from per_assignment_status_types ast,
10073        per_all_assignments_f asg
10074   where ast.assignment_status_type_id = asg.assignment_status_type_id
10075   and   asg.assignment_id = p_assignment_id
10076   and   l_effective_date between asg.effective_start_date
10077         and asg.effective_end_date;
10078   --
10079   cursor csr_new_asg_status is
10080   select ast.per_system_status
10081   from per_assignment_status_types ast
10082   where ast.assignment_status_type_id = p_assignment_status_type_id;
10083   --
10084   cursor csr_get_assignment_type is
10085     select asg.assignment_type
10086          , asg.business_group_id
10087          -- , asg.soft_coding_keyflex_id -- bug 2359997
10088          , asg.organization_id
10089          , asg.location_id
10090       from per_all_assignments_f asg
10091      where asg.assignment_id = p_assignment_id
10092        and l_effective_date  between asg.effective_start_date
10093                              and     asg.effective_end_date;
10094   --
10095 /* Added By Fs
10096   cursor csr_get_soft_coding_keyflex is  -- bug 2359997
10097     select asg.soft_coding_keyflex_id
10098       from per_all_assignments_f asg
10099      where asg.assignment_id = p_assignment_id
10100        and l_effective_date  between asg.effective_start_date
10101                              and     asg.effective_end_date;
10102   --
10103   cursor csr_scl_idsel is
10104     select plr.rule_mode                       id_flex_num
10105     from   pay_legislation_rules               plr,
10106            per_business_groups_perf            pgr
10107     where  plr.legislation_code                = pgr.legislation_code
10108     and    pgr.business_group_id               = l_business_group_id
10109     and    plr.rule_type                       = 'S'
10110     and    exists
10111           (select 1
10112            from   fnd_segment_attribute_values fsav
10113            where  fsav.id_flex_num             = plr.rule_mode
10114            and    fsav.application_id          = 800
10115            and    fsav.id_flex_code            = 'SCL'
10116            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
10117            and    fsav.attribute_value         = 'Y')
10118     and    exists
10119           (select 1
10120            from   pay_legislation_rules        plr2
10121            where  plr2.legislation_code        = plr.legislation_code
10122            and    plr2.rule_type               = 'SDL'
10123            and    plr2.rule_mode               = 'A') ;
10124   --
10125   -- bug 2359997 get hr_soft_coding_keyflex segment values where
10126   -- soft_coding_keyflex_id is known
10127   --
10128   cursor c_scl_segments is
10129      select segment1,
10130             segment2,
10131             segment3,
10132             segment4,
10133             segment5,
10134             segment6,
10135             segment7,
10136             segment8,
10137             segment9,
10138             segment10,
10139             segment11,
10140             segment12,
10141             segment13,
10142             segment14,
10143             segment15,
10144             segment16,
10145             segment17,
10146             segment18,
10147             segment19,
10148             segment20,
10149             segment21,
10150             segment22,
10151             segment23,
10152             segment24,
10153             segment25,
10154             segment26,
10155             segment27,
10156             segment28,
10157             segment29,
10158             segment30
10159      from   hr_soft_coding_keyflex
10160      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
10161   END */
10162   --
10163   -- bug 2359997 get per_cagr_grades_def segment values where
10164   -- cagr_grade_def_id is known
10165   --
10166   cursor c_cag_segments is
10167      select segment1,
10168             segment2,
10169             segment3,
10170             segment4,
10171             segment5,
10172             segment6,
10173             segment7,
10174             segment8,
10175             segment9,
10176             segment10,
10177             segment11,
10178             segment12,
10179             segment13,
10180             segment14,
10181             segment15,
10182             segment16,
10183             segment17,
10184             segment18,
10185             segment19,
10186             segment20
10187      from   per_cagr_grades_def
10188      where  cagr_grade_def_id = l_cagr_grade_def_id;
10189 --
10190 --
10191 begin
10192 --
10193  if g_debug then
10194   hr_utility.set_location('Entering:'|| l_proc, 5);
10195  end if;
10196  if g_debug then
10197   hr_utility.set_location('XXX'||l_proc||'/'||p_concat_segments,6);
10198  end if;
10199   --
10200   -- Truncate date and date_probation_end values,
10201   -- effectively removing time element.
10202   --
10203   l_effective_date     := trunc(p_effective_date);
10204   l_date_probation_end := trunc(p_date_probation_end);
10205   --
10206   l_object_version_number := p_object_version_number;
10207   --
10208   -- Bug 944911 - changed p_concatenated_segments to p_concat_segments
10209   --
10210   l_old_conc_segments:=p_concat_segments;
10211   --
10212   -- Issue a savepoint.
10213   --
10214   savepoint update_emp_asg;
10215   --
10216   --  bug 2359997 use cursor c_scl_segments to bring back segment values if
10217   --  l_soft_coding_keyflex_id has a value.
10218   --
10219 /* Added By FS
10220   if l_soft_coding_keyflex_id is not null
10221   then
10222      l_scl_null_ind := 1;
10223      open c_scl_segments;
10224      fetch c_scl_segments into l_scl_segment1,
10225                                l_scl_segment2,
10226                                l_scl_segment3,
10227                                l_scl_segment4,
10228                                l_scl_segment5,
10229                                l_scl_segment6,
10230                                l_scl_segment7,
10231                                l_scl_segment8,
10232                                l_scl_segment9,
10233                                l_scl_segment10,
10234                                l_scl_segment11,
10235                                l_scl_segment12,
10236                                l_scl_segment13,
10237                                l_scl_segment14,
10238                                l_scl_segment15,
10239                                l_scl_segment16,
10240                                l_scl_segment17,
10241                                l_scl_segment18,
10242                                l_scl_segment19,
10243                                l_scl_segment20,
10244                                l_scl_segment21,
10245                                l_scl_segment22,
10246                                l_scl_segment23,
10247                                l_scl_segment24,
10248                                l_scl_segment25,
10249                                l_scl_segment26,
10250                                l_scl_segment27,
10251                                l_scl_segment28,
10252                                l_scl_segment29,
10253                                l_scl_segment30;
10254     close c_scl_segments;
10255   else
10256     l_scl_null_ind := 0;
10257   end if;
10258 Added by FS */
10259   --
10260   -- if cagr_grade_def_id has a value then use it to get segment values using
10261   -- cursor cag_segments
10262   --
10263   if l_cagr_grade_def_id is not null
10264   then
10265     l_cag_null_ind := 1;
10266     open c_cag_segments;
10267       fetch c_cag_segments into l_cag_segment1,
10268                                 l_cag_segment2,
10269                                 l_cag_segment3,
10270                                 l_cag_segment4,
10271                                 l_cag_segment5,
10272                                 l_cag_segment6,
10273                                 l_cag_segment7,
10274                                 l_cag_segment8,
10275                                 l_cag_segment9,
10276                                 l_cag_segment10,
10277                                 l_cag_segment11,
10278                                 l_cag_segment12,
10279                                 l_cag_segment13,
10280                                 l_cag_segment14,
10281                                 l_cag_segment15,
10282                                 l_cag_segment16,
10283                                 l_cag_segment17,
10284                                 l_cag_segment18,
10285                                 l_cag_segment19,
10286                                 l_cag_segment20;
10287     close c_cag_segments;
10288   else
10289     l_cag_null_ind := 0;
10290   end if;
10291   --
10292   --
10293   begin
10294     --
10295     -- Start of API User Hook for the before hook of update_emp_asg
10296     --
10297     hr_assignment_bk2.update_emp_asg_b
10298       (p_effective_date               => l_effective_date
10299       ,p_datetrack_update_mode        => p_datetrack_update_mode
10300       ,p_assignment_id                => p_assignment_id
10301       ,p_object_version_number        => p_object_version_number
10302       ,p_supervisor_id                => p_supervisor_id
10303       ,p_assignment_number            => p_assignment_number
10304       ,p_change_reason                => p_change_reason
10305       ,p_assignment_status_type_id    => p_assignment_status_type_id
10306       ,p_comments                     => p_comments
10307       ,p_date_probation_end           => l_date_probation_end
10308       ,p_default_code_comb_id         => p_default_code_comb_id
10309       ,p_frequency                    => p_frequency
10310       ,p_internal_address_line        => p_internal_address_line
10311       ,p_manager_flag                 => p_manager_flag
10312       ,p_normal_hours                 => p_normal_hours
10313       ,p_perf_review_period           => p_perf_review_period
10314       ,p_perf_review_period_frequency => p_perf_review_period_frequency
10315       ,p_probation_period             => p_probation_period
10316       ,p_probation_unit               => p_probation_unit
10317       ,p_projected_assignment_end     => p_projected_assignment_end
10318       ,p_sal_review_period            => p_sal_review_period
10319       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
10320       ,p_set_of_books_id              => p_set_of_books_id
10321       ,p_source_type                  => p_source_type
10322       ,p_time_normal_finish           => p_time_normal_finish
10323       ,p_time_normal_start            => p_time_normal_start
10324       ,p_bargaining_unit_code         => p_bargaining_unit_code
10325       ,p_labour_union_member_flag     => p_labour_union_member_flag
10326       ,p_hourly_salaried_code         => p_hourly_salaried_code
10327       ,p_ass_attribute_category       => p_ass_attribute_category
10328       ,p_ass_attribute1               => p_ass_attribute1
10329       ,p_ass_attribute2               => p_ass_attribute2
10330       ,p_ass_attribute3               => p_ass_attribute3
10331       ,p_ass_attribute4               => p_ass_attribute4
10332       ,p_ass_attribute5               => p_ass_attribute5
10333       ,p_ass_attribute6               => p_ass_attribute6
10334       ,p_ass_attribute7               => p_ass_attribute7
10335       ,p_ass_attribute8               => p_ass_attribute8
10336       ,p_ass_attribute9               => p_ass_attribute9
10337       ,p_ass_attribute10              => p_ass_attribute10
10338       ,p_ass_attribute11              => p_ass_attribute11
10339       ,p_ass_attribute12              => p_ass_attribute12
10340       ,p_ass_attribute13              => p_ass_attribute13
10341       ,p_ass_attribute14              => p_ass_attribute14
10342       ,p_ass_attribute15              => p_ass_attribute15
10343       ,p_ass_attribute16              => p_ass_attribute16
10344       ,p_ass_attribute17              => p_ass_attribute17
10345       ,p_ass_attribute18              => p_ass_attribute18
10346       ,p_ass_attribute19              => p_ass_attribute19
10347       ,p_ass_attribute20              => p_ass_attribute20
10348       ,p_ass_attribute21              => p_ass_attribute21
10349       ,p_ass_attribute22              => p_ass_attribute22
10350       ,p_ass_attribute23              => p_ass_attribute23
10351       ,p_ass_attribute24              => p_ass_attribute24
10352       ,p_ass_attribute25              => p_ass_attribute25
10353       ,p_ass_attribute26              => p_ass_attribute26
10354       ,p_ass_attribute27              => p_ass_attribute27
10355       ,p_ass_attribute28              => p_ass_attribute28
10356       ,p_ass_attribute29              => p_ass_attribute29
10357       ,p_ass_attribute30              => p_ass_attribute30
10358       ,p_title                        => p_title
10359       ,p_segment1                     => l_scl_segment1
10360       ,p_segment2                     => l_scl_segment2
10361       ,p_segment3                     => l_scl_segment3
10362       ,p_segment4                     => l_scl_segment4
10363       ,p_segment5                     => l_scl_segment5
10364       ,p_segment6                     => l_scl_segment6
10365       ,p_segment7                     => l_scl_segment7
10366       ,p_segment8                     => l_scl_segment8
10367       ,p_segment9                     => l_scl_segment9
10368       ,p_segment10                    => l_scl_segment10
10369       ,p_segment11                    => l_scl_segment11
10370       ,p_segment12                    => l_scl_segment12
10371       ,p_segment13                    => l_scl_segment13
10372       ,p_segment14                    => l_scl_segment14
10373       ,p_segment15                    => l_scl_segment15
10374       ,p_segment16                    => l_scl_segment16
10375       ,p_segment17                    => l_scl_segment17
10376       ,p_segment18                    => l_scl_segment18
10377       ,p_segment19                    => l_scl_segment19
10378       ,p_segment20                    => l_scl_segment20
10379       ,p_segment21                    => l_scl_segment21
10380       ,p_segment22                    => l_scl_segment22
10381       ,p_segment23                    => l_scl_segment23
10382       ,p_segment24                    => l_scl_segment24
10383       ,p_segment25                    => l_scl_segment25
10384       ,p_segment26                    => l_scl_segment26
10385       ,p_segment27                    => l_scl_segment27
10386       ,p_segment28                    => l_scl_segment28
10387       ,p_segment29                    => l_scl_segment29
10388       ,p_segment30                    => l_scl_segment30
10389       -- Bug 944911
10390       -- Amended p_concatendated_segments by p_concat_segments
10391       ,p_concat_segments              => l_old_conc_segments
10392       ,p_contract_id                  => p_contract_id
10393       ,p_establishment_id             => p_establishment_id
10394       ,p_collective_agreement_id      => p_collective_agreement_id
10395       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
10396       ,p_cag_segment1                 => l_cag_segment1
10397       ,p_cag_segment2                 => l_cag_segment2
10398       ,p_cag_segment3                 => l_cag_segment3
10399       ,p_cag_segment4                 => l_cag_segment4
10400       ,p_cag_segment5                 => l_cag_segment5
10401       ,p_cag_segment6                 => l_cag_segment6
10402       ,p_cag_segment7                 => l_cag_segment7
10403       ,p_cag_segment8                 => l_cag_segment8
10404       ,p_cag_segment9                 => l_cag_segment9
10405       ,p_cag_segment10                => l_cag_segment10
10406       ,p_cag_segment11                => l_cag_segment11
10407       ,p_cag_segment12                => l_cag_segment12
10408       ,p_cag_segment13                => l_cag_segment13
10409       ,p_cag_segment14                => l_cag_segment14
10410       ,p_cag_segment15                => l_cag_segment15
10411       ,p_cag_segment16                => l_cag_segment16
10412       ,p_cag_segment17                => l_cag_segment17
10413       ,p_cag_segment18                => l_cag_segment18
10414       ,p_cag_segment19                => l_cag_segment19
10415       ,p_cag_segment20                => l_cag_segment20
10416       ,p_notice_period		      => p_notice_period
10417       ,p_notice_period_uom	      => p_notice_period_uom
10418       ,p_employee_category	      => p_employee_category
10419       ,p_work_at_home		      => p_work_at_home
10420       ,p_job_post_source_name	      => p_job_post_source_name
10421       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
10422        );
10423   exception
10424     when hr_api.cannot_find_prog_unit then
10425       hr_api.cannot_find_prog_unit_error
10426         (p_module_name => 'UPDATE_EMP_ASG'
10427         ,p_hook_type   => 'BP'
10428         );
10429     --
10430     -- End of API User Hook for the before hook of update_emp_asg
10431     --
10432   end;
10433   --
10434  if g_debug then
10435   hr_utility.set_location(l_proc, 10);
10436  end if;
10437   --
10438   -- Validation in addition to Table Handlers
10439   --
10440   -- Get assignment type.
10441   --
10442   hr_api.mandatory_arg_error
10443     (p_api_name       => l_proc
10444     ,p_argument       => 'assignment_id'
10445     ,p_argument_value => p_assignment_id);
10446   --
10447   hr_api.mandatory_arg_error
10448     (p_api_name       => l_proc
10449     ,p_argument       => 'effective_date'
10450     ,p_argument_value => l_effective_date);
10451   --
10452   open  csr_get_assignment_type;
10453   fetch csr_get_assignment_type
10454    into l_assignment_type
10455       , l_business_group_id
10456       -- , l_soft_coding_keyflex_id  -- bug 2359997
10457       , l_organization_id
10458       , l_location_id;
10459   --
10460   if csr_get_assignment_type%NOTFOUND then
10461     close csr_get_assignment_type;
10462     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
10463     hr_utility.raise_error;
10464   end if;
10465   --
10466   close csr_get_assignment_type;
10467   --
10468  if g_debug then
10469   hr_utility.set_location(l_proc, 20);
10470  end if;
10471   --
10472   if l_assignment_type <> 'E' then
10473     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
10474     hr_utility.raise_error;
10475   end if;
10476   --
10477  if g_debug then
10478   hr_utility.set_location(l_proc, 21);
10479  end if;
10480   --
10481   --added validation for bug 1867720
10482   --
10483   if p_assignment_status_type_id <> hr_api.g_number then
10484     open csr_old_asg_status;
10485     fetch csr_old_asg_status into l_old_asg_status;
10486     close csr_old_asg_status;
10487     --
10488     open csr_new_asg_status;
10489     fetch csr_new_asg_status into l_new_asg_status;
10490       if csr_new_asg_status%notfound
10491         OR (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status)
10492       then
10493       fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
10494       fnd_message.set_token('SYSTYPE',l_old_asg_status);
10495       fnd_message.raise_error;
10496     end if;
10497     close csr_new_asg_status;
10498   end if;
10499   --
10500  if g_debug then
10501   hr_utility.set_location(l_proc, 21);
10502  end if;
10503   --
10504   -- insert the profile options and effective date for the flexfield
10505   -- validation to work
10506   --
10507   hr_kflex_utility.set_profiles
10508   (p_business_group_id => l_business_group_id
10509   ,p_assignment_id     => p_assignment_id
10510   ,p_organization_id   => l_organization_id
10511   ,p_location_id       => l_location_id);
10512   --
10513   hr_kflex_utility.set_session_date
10514   (p_effective_date => l_effective_date
10515   ,p_session_id     => l_session_id);
10516   --
10517   -- Bug 944911
10518   -- Added to next 2 ifs check for p_concatenated_segments also
10519   --
10520     --
10521   -- Update or select the soft_coding_keyflex_id
10522   --
10523 /* Added By Fs
10524   if l_scl_null_ind = 0 -- bug 2359997 added this if statement
10525                         -- soft coding keyflex id came in null
10526   then
10527      open csr_get_soft_coding_keyflex;  -- bug 2359997 get soft coding keyflex
10528        fetch csr_get_soft_coding_keyflex
10529         into l_soft_coding_keyflex_id;
10530      --
10531      if csr_get_soft_coding_keyflex%NOTFOUND then
10532        close csr_get_soft_coding_keyflex;
10533        hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
10534        hr_utility.raise_error;
10535      end if;
10536      --
10537      close csr_get_soft_coding_keyflex;
10538      --
10539     -- Start of Fix for   Bug 2548555
10540      --
10541      if   nvl(l_scl_segment1,'x') <> hr_api.g_varchar2
10542        or nvl(l_scl_segment2,'x') <> hr_api.g_varchar2
10543        or nvl(l_scl_segment3,'x') <> hr_api.g_varchar2
10544        or nvl(l_scl_segment4,'x') <> hr_api.g_varchar2
10545        or nvl(l_scl_segment5,'x') <> hr_api.g_varchar2
10546        or nvl(l_scl_segment6,'x') <> hr_api.g_varchar2
10547        or nvl(l_scl_segment7,'x') <> hr_api.g_varchar2
10548        or nvl(l_scl_segment8,'x') <> hr_api.g_varchar2
10549        or nvl(l_scl_segment9,'x') <> hr_api.g_varchar2
10550        or nvl(l_scl_segment10,'x') <> hr_api.g_varchar2
10551        or nvl(l_scl_segment11,'x') <> hr_api.g_varchar2
10552        or nvl(l_scl_segment12,'x') <> hr_api.g_varchar2
10553        or nvl(l_scl_segment13,'x') <> hr_api.g_varchar2
10554        or nvl(l_scl_segment14,'x') <> hr_api.g_varchar2
10555        or nvl(l_scl_segment15,'x') <> hr_api.g_varchar2
10556        or nvl(l_scl_segment16,'x') <> hr_api.g_varchar2
10557        or nvl(l_scl_segment17,'x') <> hr_api.g_varchar2
10558        or nvl(l_scl_segment18,'x') <> hr_api.g_varchar2
10559        or nvl(l_scl_segment19,'x') <> hr_api.g_varchar2
10560        or nvl(l_scl_segment20,'x') <> hr_api.g_varchar2
10561        or nvl(l_scl_segment21,'x') <> hr_api.g_varchar2
10562        or nvl(l_scl_segment22,'x') <> hr_api.g_varchar2
10563        or nvl(l_scl_segment23,'x') <> hr_api.g_varchar2
10564        or nvl(l_scl_segment24,'x') <> hr_api.g_varchar2
10565        or nvl(l_scl_segment25,'x') <> hr_api.g_varchar2
10566        or nvl(l_scl_segment26,'x') <> hr_api.g_varchar2
10567        or nvl(l_scl_segment27,'x') <> hr_api.g_varchar2
10568        or nvl(l_scl_segment28,'x') <> hr_api.g_varchar2
10569        or nvl(l_scl_segment29,'x') <> hr_api.g_varchar2
10570        or nvl(l_scl_segment30,'x') <> hr_api.g_varchar2
10571        -- bug 944911
10572        -- changed p_concatenated_segments to p_concat_segments
10573        or nvl(p_concat_segments,'x') <> hr_api.g_varchar2
10574  --
10575  -- End of Fix for Bug 2548555
10576  --
10577     then
10578        open csr_scl_idsel;
10579        fetch csr_scl_idsel into l_flex_num;
10580        --
10581        if csr_scl_idsel%NOTFOUND
10582        then
10583          close csr_scl_idsel;
10584          if   l_scl_segment1 is not null
10585            or l_scl_segment2 is not null
10586            or l_scl_segment3 is not null
10587            or l_scl_segment4 is not null
10588            or l_scl_segment5 is not null
10589            or l_scl_segment6 is not null
10590            or l_scl_segment7 is not null
10591            or l_scl_segment8 is not null
10592            or l_scl_segment9 is not null
10593            or l_scl_segment10 is not null
10594            or l_scl_segment11 is not null
10595            or l_scl_segment12 is not null
10596            or l_scl_segment13 is not null
10597            or l_scl_segment14 is not null
10598            or l_scl_segment15 is not null
10599            or l_scl_segment16 is not null
10600            or l_scl_segment17 is not null
10601            or l_scl_segment18 is not null
10602            or l_scl_segment19 is not null
10603            or l_scl_segment20 is not null
10604            or l_scl_segment21 is not null
10605            or l_scl_segment22 is not null
10606            or l_scl_segment23 is not null
10607            or l_scl_segment24 is not null
10608            or l_scl_segment25 is not null
10609            or l_scl_segment26 is not null
10610            or l_scl_segment27 is not null
10611            or l_scl_segment28 is not null
10612            or l_scl_segment29 is not null
10613            or l_scl_segment30 is not null
10614            or p_concat_segments is not null
10615          then
10616             --
10617             hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
10618             hr_utility.set_message_token('PROCEDURE', l_proc);
10619             hr_utility.set_message_token('STEP','5');
10620             hr_utility.raise_error;
10621          end if;
10622       else -- csr_scl_idsel is found
10623          close csr_scl_idsel;
10624          --
10625          -- Process Logic
10626          --
10627          --
10628          -- Update or select the soft_coding_keyflex_id
10629          --
10630          hr_kflex_utility.upd_or_sel_keyflex_comb
10631            (p_appl_short_name        => 'PER'
10632            ,p_flex_code              => 'SCL'
10633            ,p_flex_num               => l_flex_num
10634            ,p_segment1               => l_scl_segment1
10635            ,p_segment2               => l_scl_segment2
10636            ,p_segment3               => l_scl_segment3
10637            ,p_segment4               => l_scl_segment4
10638            ,p_segment5               => l_scl_segment5
10639            ,p_segment6               => l_scl_segment6
10640            ,p_segment7               => l_scl_segment7
10641            ,p_segment8               => l_scl_segment8
10642            ,p_segment9               => l_scl_segment9
10643            ,p_segment10              => l_scl_segment10
10644            ,p_segment11              => l_scl_segment11
10645            ,p_segment12              => l_scl_segment12
10646            ,p_segment13              => l_scl_segment13
10647            ,p_segment14              => l_scl_segment14
10648            ,p_segment15              => l_scl_segment15
10649            ,p_segment16              => l_scl_segment16
10650            ,p_segment17              => l_scl_segment17
10651            ,p_segment18              => l_scl_segment18
10652            ,p_segment19              => l_scl_segment19
10653            ,p_segment20              => l_scl_segment20
10654            ,p_segment21              => l_scl_segment21
10655            ,p_segment22              => l_scl_segment22
10656            ,p_segment23              => l_scl_segment23
10657            ,p_segment24              => l_scl_segment24
10658            ,p_segment25              => l_scl_segment25
10659            ,p_segment26              => l_scl_segment26
10660            ,p_segment27              => l_scl_segment27
10661            ,p_segment28              => l_scl_segment28
10662            ,p_segment29              => l_scl_segment29
10663            ,p_segment30              => l_scl_segment30
10664            ,p_concat_segments_in     => l_old_conc_segments
10665            ,p_ccid                   => l_soft_coding_keyflex_id
10666            ,p_concat_segments_out    => l_concatenated_segments
10667            );
10668           --
10669           -- update the combinations column
10670           --
10671           update_scl_concat_segs
10672           (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
10673           ,p_concatenated_segments   => l_concatenated_segments
10674           );
10675        --
10676        end if; -- csr_scl_idsel%NOTFOUND
10677     --
10678     end if;  -- l_scl_segment1 <> hr_api.g_varchar2
10679   --
10680   end if; -- l_soft_coding_key_flex_id is null
10681   --
10682 Added By FS */
10683 
10684 
10685 --
10686 -- Start of fix for Bug 2622747
10687 --
10688   validate_SCL (
10689    p_validate                     => FALSE --Changed from p_validate to false for fix of #3180527
10690   ,p_assignment_id                => p_assignment_id
10691   ,p_effective_date               => l_effective_date
10692   ,p_business_group_id            => l_business_group_id
10693   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
10694   ,p_concatenated_segments        => l_concatenated_segments
10695   ,p_concat_segments              => NULL
10696   ,p_segment1                     => l_scl_segment1
10697   ,p_segment2                     => l_scl_segment2
10698   ,p_segment3                     => l_scl_segment3
10699   ,p_segment4                     => l_scl_segment4
10700   ,p_segment5                     => l_scl_segment5
10701   ,p_segment6                     => l_scl_segment6
10702   ,p_segment7                     => l_scl_segment7
10703   ,p_segment8                     => l_scl_segment8
10704   ,p_segment9                     => l_scl_segment9
10705   ,p_segment10                    => l_scl_segment10
10706   ,p_segment11                    => l_scl_segment11
10707   ,p_segment12                    => l_scl_segment12
10708   ,p_segment13                    => l_scl_segment13
10709   ,p_segment14                    => l_scl_segment14
10710   ,p_segment15                    => l_scl_segment15
10711   ,p_segment16                    => l_scl_segment16
10712   ,p_segment17                    => l_scl_segment17
10713   ,p_segment18                    => l_scl_segment18
10714   ,p_segment19                    => l_scl_segment19
10715   ,p_segment20                    => l_scl_segment20
10716   ,p_segment21                    => l_scl_segment21
10717   ,p_segment22                    => l_scl_segment22
10718   ,p_segment23                    => l_scl_segment23
10719   ,p_segment24                    => l_scl_segment24
10720   ,p_segment25                    => l_scl_segment25
10721   ,p_segment26                    => l_scl_segment26
10722   ,p_segment27                    => l_scl_segment27
10723   ,p_segment28                    => l_scl_segment28
10724   ,p_segment29                    => l_scl_segment29
10725   ,p_segment30                    => l_scl_segment30
10726   );
10727 --End of fix for Bug 2622747
10728   --
10729 
10730  if g_debug then
10731   hr_utility.set_location(l_proc, 23);
10732  end if;
10733   --
10734   --
10735   -- Update or select the cagr_grade_def_id
10736   --
10737   -- need to call the lck procedure early, to fetch the
10738   -- old value of cagr_id_flex_num
10739   -- before passing it into the hr_cgd_upd.upd_or_sel function.
10740   -- This is because the user may be updating a grade definition,
10741   -- but not changing
10742   -- or specifying the cagr_id_flex_num (ie the grade structure).
10743   -- Also, need to fetch the old cagr_grade_def_id, as
10744   -- the user may be updating some
10745   -- segments, and not changing others.
10746   -- Passing cagr_grade_id into the hr_cgd_upd.upd_or_sel
10747   -- function allows that function to derive the old values.
10748   --
10749   l_cagr_id_flex_num  := p_cagr_id_flex_num;
10750   --
10751   if (p_cagr_id_flex_num  = hr_api.g_number)
10752   then
10753      per_asg_shd.lck
10754       (p_effective_date          => l_effective_date,
10755        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
10756        p_datetrack_mode          => p_datetrack_update_mode,
10757        p_assignment_id           => p_assignment_id,
10758        p_object_version_number   => p_object_version_number,
10759        p_validation_start_date   => l_unused_start_date,
10760        p_validation_end_date     => l_unused_end_date
10761        );
10762      l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
10763      -- l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
10764      -- commented out for bug 2359997
10765   end if;
10766   --
10767   --
10768   -- Bug 4003788   added the check for the cagr_id_flex_num also
10769   if l_cag_null_ind = 0  and l_cagr_id_flex_num is not null -- bug 2359997
10770   then
10771      l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
10772      --
10773      hr_cgd_upd.upd_or_sel
10774      (p_segment1               => l_cag_segment1
10775      ,p_segment2               => l_cag_segment2
10776      ,p_segment3               => l_cag_segment3
10777      ,p_segment4               => l_cag_segment4
10778      ,p_segment5               => l_cag_segment5
10779      ,p_segment6               => l_cag_segment6
10780      ,p_segment7               => l_cag_segment7
10781      ,p_segment8               => l_cag_segment8
10782      ,p_segment9               => l_cag_segment9
10783      ,p_segment10              => l_cag_segment10
10784      ,p_segment11              => l_cag_segment11
10785      ,p_segment12              => l_cag_segment12
10786      ,p_segment13              => l_cag_segment13
10787      ,p_segment14              => l_cag_segment14
10788      ,p_segment15              => l_cag_segment15
10789      ,p_segment16              => l_cag_segment16
10790      ,p_segment17              => l_cag_segment17
10791      ,p_segment18              => l_cag_segment18
10792      ,p_segment19              => l_cag_segment19
10793      ,p_segment20              => l_cag_segment20
10794      ,p_id_flex_num            => l_cagr_id_flex_num
10795      ,p_business_group_id      => l_business_group_id
10796      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
10797      ,p_concatenated_segments  => l_cagr_concatenated_segments
10798       );
10799      --
10800  if g_debug then
10801      hr_utility.set_location(l_proc, 24);
10802  end if;
10803      --
10804   end if; --  l_cagr_grade_def_id is null
10805   --
10806  if g_debug then
10807   hr_utility.set_location(l_proc, 25);
10808  end if;
10809 
10810  -- fix for bug 6595592 starts here.
10811     if (p_projected_assignment_end = hr_api.g_date) then      -- fix for 6862763
10812      l_projected_assignment_end :=hr_api.g_date;
10813     else
10814      l_projected_assignment_end :=p_projected_assignment_end;
10815     end if;
10816  -- fix for bug 6595592 ends here.
10817   --
10818   --
10819   -- Update assignment.
10820   --
10821   per_asg_upd.upd
10822     (p_assignment_id                => p_assignment_id
10823     ,p_effective_start_date         => l_effective_start_date
10824     ,p_effective_end_date           => l_effective_end_date
10825     ,p_business_group_id            => l_business_group_id
10826     ,p_assignment_status_type_id    => p_assignment_status_type_id
10827     ,p_supervisor_id                => p_supervisor_id
10828     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
10829     ,p_assignment_number            => p_assignment_number
10830     ,p_change_reason                => p_change_reason
10831     ,p_comment_id                   => l_comment_id
10832     ,p_comments                     => p_comments
10833     ,p_date_probation_end           => l_date_probation_end
10834     ,p_default_code_comb_id         => p_default_code_comb_id
10835     ,p_frequency                    => p_frequency
10836     ,p_internal_address_line        => p_internal_address_line
10837     ,p_manager_flag                 => p_manager_flag
10838     ,p_normal_hours                 => p_normal_hours
10839     ,p_perf_review_period           => p_perf_review_period
10840     ,p_perf_review_period_frequency => p_perf_review_period_frequency
10841     ,p_probation_period             => p_probation_period
10842     ,p_probation_unit               => p_probation_unit
10843     ,p_projected_assignment_end     => l_projected_assignment_end -- fix for bug 6595592.
10844     ,p_sal_review_period            => p_sal_review_period
10845     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
10846     ,p_set_of_books_id              => p_set_of_books_id
10847     ,p_source_type                  => p_source_type
10848     ,p_time_normal_finish           => p_time_normal_finish
10849     ,p_time_normal_start            => p_time_normal_start
10850     ,p_bargaining_unit_code         => p_bargaining_unit_code
10851     ,p_labour_union_member_flag     => p_labour_union_member_flag
10852     ,p_hourly_salaried_code         => p_hourly_salaried_code
10853     ,p_ass_attribute_category       => p_ass_attribute_category
10854     ,p_ass_attribute1               => p_ass_attribute1
10855     ,p_ass_attribute2               => p_ass_attribute2
10856     ,p_ass_attribute3               => p_ass_attribute3
10857     ,p_ass_attribute4               => p_ass_attribute4
10858     ,p_ass_attribute5               => p_ass_attribute5
10859     ,p_ass_attribute6               => p_ass_attribute6
10860     ,p_ass_attribute7               => p_ass_attribute7
10861     ,p_ass_attribute8               => p_ass_attribute8
10862     ,p_ass_attribute9               => p_ass_attribute9
10863     ,p_ass_attribute10              => p_ass_attribute10
10864     ,p_ass_attribute11              => p_ass_attribute11
10865     ,p_ass_attribute12              => p_ass_attribute12
10866     ,p_ass_attribute13              => p_ass_attribute13
10867     ,p_ass_attribute14              => p_ass_attribute14
10868     ,p_ass_attribute15              => p_ass_attribute15
10869     ,p_ass_attribute16              => p_ass_attribute16
10870     ,p_ass_attribute17              => p_ass_attribute17
10871     ,p_ass_attribute18              => p_ass_attribute18
10872     ,p_ass_attribute19              => p_ass_attribute19
10873     ,p_ass_attribute20              => p_ass_attribute20
10874     ,p_ass_attribute21              => p_ass_attribute21
10875     ,p_ass_attribute22              => p_ass_attribute22
10876     ,p_ass_attribute23              => p_ass_attribute23
10877     ,p_ass_attribute24              => p_ass_attribute24
10878     ,p_ass_attribute25              => p_ass_attribute25
10879     ,p_ass_attribute26              => p_ass_attribute26
10880     ,p_ass_attribute27              => p_ass_attribute27
10881     ,p_ass_attribute28              => p_ass_attribute28
10882     ,p_ass_attribute29              => p_ass_attribute29
10883     ,p_ass_attribute30              => p_ass_attribute30
10884     ,p_notice_period		    => p_notice_period
10885     ,p_notice_period_uom	    => p_notice_period_uom
10886     ,p_employee_category	    => p_employee_category
10887     ,p_work_at_home		    => p_work_at_home
10888     ,p_job_post_source_name	    => p_job_post_source_name
10889     ,p_title                        => p_title
10890     ,p_payroll_id_updated           => l_payroll_id_updated
10891     ,p_other_manager_warning        => l_other_manager_warning
10892     ,p_no_managers_warning          => l_no_managers_warning
10893     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
10894     ,p_validation_start_date        => l_validation_start_date
10895     ,p_validation_end_date          => l_validation_end_date
10896     ,p_object_version_number        => l_object_version_number
10897     ,p_effective_date               => l_effective_date
10898     ,p_datetrack_mode               => p_datetrack_update_mode
10899     ,p_contract_id                  => p_contract_id
10900     ,p_establishment_id             => p_establishment_id
10901     ,p_collective_agreement_id      => p_collective_agreement_id
10902     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
10903     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
10904     ,p_validate                     => FALSE
10905     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
10906     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
10907     );
10908   --
10909  if g_debug then
10910   hr_utility.set_location(l_proc, 25);
10911  end if;
10912   --
10913   begin
10914     --
10915     -- Start of API User Hook for the after hook of update_emp_asg
10916     --
10917     hr_assignment_bk2.update_emp_asg_a
10918       (p_effective_date               => l_effective_date
10919       ,p_datetrack_update_mode        => p_datetrack_update_mode
10920       ,p_assignment_id                => p_assignment_id
10921       ,p_object_version_number        => p_object_version_number
10922       ,p_supervisor_id                => p_supervisor_id
10923       ,p_assignment_number            => p_assignment_number
10924       ,p_change_reason                => p_change_reason
10925       ,p_assignment_status_type_id    => p_assignment_status_type_id
10926       ,p_comments                     => p_comments
10927       ,p_date_probation_end           => l_date_probation_end
10928       ,p_default_code_comb_id         => p_default_code_comb_id
10929       ,p_frequency                    => p_frequency
10930       ,p_internal_address_line        => p_internal_address_line
10931       ,p_manager_flag                 => p_manager_flag
10932       ,p_normal_hours                 => p_normal_hours
10933       ,p_perf_review_period           => p_perf_review_period
10934       ,p_perf_review_period_frequency => p_perf_review_period_frequency
10935       ,p_probation_period             => p_probation_period
10936       ,p_probation_unit               => p_probation_unit
10937       ,p_projected_assignment_end     => p_projected_assignment_end
10938       ,p_sal_review_period            => p_sal_review_period
10939       ,p_sal_review_period_frequency  => p_sal_review_period_frequency
10940       ,p_set_of_books_id              => p_set_of_books_id
10941       ,p_source_type                  => p_source_type
10942       ,p_time_normal_finish           => p_time_normal_finish
10943       ,p_time_normal_start            => p_time_normal_start
10944       ,p_bargaining_unit_code         => p_bargaining_unit_code
10945       ,p_labour_union_member_flag     => p_labour_union_member_flag
10946       ,p_hourly_salaried_code         => p_hourly_salaried_code
10947       ,p_ass_attribute_category       => p_ass_attribute_category
10948       ,p_ass_attribute1               => p_ass_attribute1
10949       ,p_ass_attribute2               => p_ass_attribute2
10950       ,p_ass_attribute3               => p_ass_attribute3
10951       ,p_ass_attribute4               => p_ass_attribute4
10952       ,p_ass_attribute5               => p_ass_attribute5
10953       ,p_ass_attribute6               => p_ass_attribute6
10954       ,p_ass_attribute7               => p_ass_attribute7
10955       ,p_ass_attribute8               => p_ass_attribute8
10956       ,p_ass_attribute9               => p_ass_attribute9
10957       ,p_ass_attribute10              => p_ass_attribute10
10958       ,p_ass_attribute11              => p_ass_attribute11
10959       ,p_ass_attribute12              => p_ass_attribute12
10960       ,p_ass_attribute13              => p_ass_attribute13
10961       ,p_ass_attribute14              => p_ass_attribute14
10962       ,p_ass_attribute15              => p_ass_attribute15
10963       ,p_ass_attribute16              => p_ass_attribute16
10964       ,p_ass_attribute17              => p_ass_attribute17
10965       ,p_ass_attribute18              => p_ass_attribute18
10966       ,p_ass_attribute19              => p_ass_attribute19
10967       ,p_ass_attribute20              => p_ass_attribute20
10968       ,p_ass_attribute21              => p_ass_attribute21
10969       ,p_ass_attribute22              => p_ass_attribute22
10970       ,p_ass_attribute23              => p_ass_attribute23
10971       ,p_ass_attribute24              => p_ass_attribute24
10972       ,p_ass_attribute25              => p_ass_attribute25
10973       ,p_ass_attribute26              => p_ass_attribute26
10974       ,p_ass_attribute27              => p_ass_attribute27
10975       ,p_ass_attribute28              => p_ass_attribute28
10976       ,p_ass_attribute29              => p_ass_attribute29
10977       ,p_ass_attribute30              => p_ass_attribute30
10978       ,p_title                        => p_title
10979       ,p_segment1                     => l_scl_segment1
10980       ,p_segment2                     => l_scl_segment2
10981       ,p_segment3                     => l_scl_segment3
10982       ,p_segment4                     => l_scl_segment4
10983       ,p_segment5                     => l_scl_segment5
10984       ,p_segment6                     => l_scl_segment6
10985       ,p_segment7                     => l_scl_segment7
10986       ,p_segment8                     => l_scl_segment8
10987       ,p_segment9                     => l_scl_segment9
10988       ,p_segment10                    => l_scl_segment10
10989       ,p_segment11                    => l_scl_segment11
10990       ,p_segment12                    => l_scl_segment12
10991       ,p_segment13                    => l_scl_segment13
10992       ,p_segment14                    => l_scl_segment14
10993       ,p_segment15                    => l_scl_segment15
10994       ,p_segment16                    => l_scl_segment16
10995       ,p_segment17                    => l_scl_segment17
10996       ,p_segment18                    => l_scl_segment18
10997       ,p_segment19                    => l_scl_segment19
10998       ,p_segment20                    => l_scl_segment20
10999       ,p_segment21                    => l_scl_segment21
11000       ,p_segment22                    => l_scl_segment22
11001       ,p_segment23                    => l_scl_segment23
11002       ,p_segment24                    => l_scl_segment24
11003       ,p_segment25                    => l_scl_segment25
11004       ,p_segment26                    => l_scl_segment26
11005       ,p_segment27                    => l_scl_segment27
11006       ,p_segment28                    => l_scl_segment28
11007       ,p_segment29                    => l_scl_segment29
11008       ,p_segment30                    => l_scl_segment30
11009       ,p_concatenated_segments        => l_concatenated_segments
11010       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
11011       ,p_comment_id                   => l_comment_id
11012       ,p_effective_start_date         => l_effective_start_date
11013       ,p_effective_end_date           => l_effective_end_date
11014       ,p_no_managers_warning          => l_no_managers_warning
11015       ,p_other_manager_warning        => l_other_manager_warning
11016       -- Bug 944911
11017       -- Added the new input param
11018       ,p_concat_segments              => l_old_conc_segments
11019       ,p_contract_id                  => p_contract_id
11020       ,p_establishment_id             => p_establishment_id
11021       ,p_collective_agreement_id      => p_collective_agreement_id
11022       ,p_cagr_id_flex_num             => p_cagr_id_flex_num
11023       ,p_cag_segment1                 => l_cag_segment1
11024       ,p_cag_segment2                 => l_cag_segment2
11025       ,p_cag_segment3                 => l_cag_segment3
11026       ,p_cag_segment4                 => l_cag_segment4
11027       ,p_cag_segment5                 => l_cag_segment5
11028       ,p_cag_segment6                 => l_cag_segment6
11029       ,p_cag_segment7                 => l_cag_segment7
11030       ,p_cag_segment8                 => l_cag_segment8
11031       ,p_cag_segment9                 => l_cag_segment9
11032       ,p_cag_segment10                => l_cag_segment10
11033       ,p_cag_segment11                => l_cag_segment11
11034       ,p_cag_segment12                => l_cag_segment12
11035       ,p_cag_segment13                => l_cag_segment13
11036       ,p_cag_segment14                => l_cag_segment14
11037       ,p_cag_segment15                => l_cag_segment15
11038       ,p_cag_segment16                => l_cag_segment16
11039       ,p_cag_segment17                => l_cag_segment17
11040       ,p_cag_segment18                => l_cag_segment18
11041       ,p_cag_segment19                => l_cag_segment19
11042       ,p_cag_segment20                => l_cag_segment20
11043       ,p_notice_period		      => p_notice_period
11044       ,p_notice_period_uom	      => p_notice_period_uom
11045       ,p_employee_category	      => p_employee_category
11046       ,p_work_at_home		      => p_work_at_home
11047       ,p_job_post_source_name	      => p_job_post_source_name
11048       ,p_cagr_grade_def_id            => l_cagr_grade_def_id
11049       ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
11050       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
11051       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
11052       );
11053   exception
11054     when hr_api.cannot_find_prog_unit then
11055       hr_api.cannot_find_prog_unit_error
11056         (p_module_name => 'UPDATE_EMP_ASG'
11057         ,p_hook_type   => 'AP'
11058         );
11059     --
11060     -- End of API User Hook for the after hook of update_emp_asg
11061     --
11062   end;
11063 
11064   --
11065   -- call pqh post process procedure -- bug 2999562
11066   --
11067   pqh_gsp_post_process.call_pp_from_assignments(
11068       p_effective_date    => p_effective_date
11069      ,p_assignment_id     => p_assignment_id
11070      ,p_date_track_mode   => p_datetrack_update_mode
11071      ,p_warning_mesg      => l_gsp_post_process_warning
11072   );
11073 
11074   --
11075   -- When in validation only mode raise the Validate_Enabled exception
11076   --
11077   if p_validate then
11078     raise hr_api.validate_enabled;
11079   end if;
11080   --
11081   -- Set all output arguments
11082   --
11083   p_object_version_number  := l_object_version_number;
11084   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
11085   p_comment_id             := l_comment_id;
11086   p_effective_start_date   := l_effective_start_date;
11087   p_effective_end_date     := l_effective_end_date;
11088   p_concatenated_segments  := l_concatenated_segments;
11089   p_no_managers_warning    := l_no_managers_warning;
11090   p_other_manager_warning  := l_other_manager_warning;
11091   p_cagr_grade_def_id          := l_cagr_grade_def_id;
11092   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
11093   p_hourly_salaried_warning    := l_hourly_salaried_warning;
11094   p_gsp_post_process_warning   := l_gsp_post_process_warning; -- bug 2999562
11095   --
11096   -- remove data from the session table
11097   hr_kflex_utility.unset_session_date
11098     (p_session_id     => l_session_id);
11099   --
11100  if g_debug then
11101   hr_utility.set_location(' Leaving:'||l_proc, 30);
11102  end if;
11103 exception
11104   when hr_api.validate_enabled then
11105     --
11106     -- As the Validate_Enabled exception has been raised
11107     -- we must rollback to the savepoint
11108     --
11109     ROLLBACK TO update_emp_asg;
11110     --
11111     -- Only set output warning arguments
11112     -- (Any key or derived arguments must be set to null
11113     -- when validation only mode is being used.)
11114     --
11115     p_object_version_number  := p_object_version_number;
11116     p_comment_id             := null;
11117     p_effective_start_date   := null;
11118     p_effective_end_date     := null;
11119     p_concatenated_segments  := l_old_conc_segments;
11120     p_no_managers_warning    := l_no_managers_warning;
11121     p_other_manager_warning  := l_other_manager_warning;
11122     p_cagr_concatenated_segments := null;
11123     p_hourly_salaried_warning    := l_hourly_salaried_warning;
11124     p_soft_coding_keyflex_id     := l_soft_coding_keyflex_id;
11125     p_gsp_post_process_warning   := l_gsp_post_process_warning; -- bug 2999562
11126     --
11127     -- bug 2359997 only re-set to null if key flex ids came in as null.
11128     --
11129     --
11130     if l_cag_null_ind = 0
11131     then
11132        p_cagr_grade_def_id       := null;
11133     end if;
11134     --
11135   when others then
11136     --
11137     -- A validation or unexpected error has occurred
11138     --
11139     -- Added as part of fix to bug 632479
11140     --
11141     p_object_version_number      := lv_object_version_number ;
11142     p_cagr_grade_def_id          := lv_cagr_grade_def_id ;
11143     p_soft_coding_keyflex_id     := lv_soft_coding_keyflex_id ;
11144 
11145     p_cagr_concatenated_segments     := null;
11146     p_concatenated_segments          := null;
11147     p_comment_id                     := null;
11148     p_effective_start_date           := null;
11149     p_effective_end_date             := null;
11150     p_no_managers_warning            := null;
11151     p_other_manager_warning          := null;
11152     p_hourly_salaried_warning        := null;
11153     p_gsp_post_process_warning       := null;
11154 
11155     ROLLBACK TO update_emp_asg;
11156     raise;
11157     --
11158     -- End of fix.
11159     --
11160 end update_emp_asg;
11161 --
11162 -- ----------------------------------------------------------------------------
11163 -- |--------------------------< update_cwk_asg >-------------------------------|
11164 -- ----------------------------------------------------------------------------
11165 --
11166 procedure update_cwk_asg
11167   (p_validate                     in     boolean
11168   ,p_effective_date               in     date
11169   ,p_datetrack_update_mode        in     varchar2
11170   ,p_assignment_id                in     number
11171   ,p_object_version_number        in out nocopy number
11172   ,p_assignment_category          in     varchar2
11173   ,p_assignment_number            in     varchar2
11174   ,p_change_reason                in     varchar2
11175   ,p_comments                     in     varchar2
11176   ,p_default_code_comb_id         in     number
11177   ,p_establishment_id             in     number
11178   ,p_frequency                    in     varchar2
11179   ,p_internal_address_line        in     varchar2
11180   ,p_labour_union_member_flag     in     varchar2
11181   ,p_manager_flag                 in     varchar2
11182   ,p_normal_hours                 in     number
11183   ,p_project_title		  in     varchar2
11184   ,p_set_of_books_id              in     number
11185   ,p_source_type                  in     varchar2
11186   ,p_supervisor_id                in     number
11187   ,p_time_normal_finish           in     varchar2
11188   ,p_time_normal_start            in     varchar2
11189   ,p_title                        in     varchar2
11190   ,p_vendor_assignment_number     in     varchar2
11191   ,p_vendor_employee_number       in     varchar2
11192   ,p_vendor_id                    in     number
11193   ,p_vendor_site_id               in     number
11194   ,p_po_header_id                 in     number
11195   ,p_po_line_id                   in     number
11196   ,p_projected_assignment_end     in     date
11197   ,p_assignment_status_type_id    in     number
11198   ,p_concat_segments              in     varchar2
11199   ,p_attribute_category           in     varchar2
11200   ,p_attribute1                   in     varchar2
11201   ,p_attribute2                   in     varchar2
11202   ,p_attribute3                   in     varchar2
11203   ,p_attribute4                   in     varchar2
11204   ,p_attribute5                   in     varchar2
11205   ,p_attribute6                   in     varchar2
11206   ,p_attribute7                   in     varchar2
11207   ,p_attribute8                   in     varchar2
11208   ,p_attribute9                   in     varchar2
11209   ,p_attribute10                  in     varchar2
11210   ,p_attribute11                  in     varchar2
11211   ,p_attribute12                  in     varchar2
11212   ,p_attribute13                  in     varchar2
11213   ,p_attribute14                  in     varchar2
11214   ,p_attribute15                  in     varchar2
11215   ,p_attribute16                  in     varchar2
11216   ,p_attribute17                  in     varchar2
11217   ,p_attribute18                  in     varchar2
11218   ,p_attribute19                  in     varchar2
11219   ,p_attribute20                  in     varchar2
11220   ,p_attribute21                  in     varchar2
11221   ,p_attribute22                  in     varchar2
11222   ,p_attribute23                  in     varchar2
11223   ,p_attribute24                  in     varchar2
11224   ,p_attribute25                  in     varchar2
11225   ,p_attribute26                  in     varchar2
11226   ,p_attribute27                  in     varchar2
11227   ,p_attribute28                  in     varchar2
11228   ,p_attribute29                  in     varchar2
11229   ,p_attribute30                  in     varchar2
11230   ,p_scl_segment1                 in     varchar2
11231   ,p_scl_segment2                 in     varchar2
11232   ,p_scl_segment3                 in     varchar2
11233   ,p_scl_segment4                 in     varchar2
11234   ,p_scl_segment5                 in     varchar2
11235   ,p_scl_segment6                 in     varchar2
11236   ,p_scl_segment7                 in     varchar2
11237   ,p_scl_segment8                 in     varchar2
11238   ,p_scl_segment9                 in     varchar2
11239   ,p_scl_segment10                in     varchar2
11240   ,p_scl_segment11                in     varchar2
11241   ,p_scl_segment12                in     varchar2
11242   ,p_scl_segment13                in     varchar2
11243   ,p_scl_segment14                in     varchar2
11244   ,p_scl_segment15                in     varchar2
11245   ,p_scl_segment16                in     varchar2
11246   ,p_scl_segment17                in     varchar2
11247   ,p_scl_segment18                in     varchar2
11248   ,p_scl_segment19                in     varchar2
11249   ,p_scl_segment20                in     varchar2
11250   ,p_scl_segment21                in     varchar2
11251   ,p_scl_segment22                in     varchar2
11252   ,p_scl_segment23                in     varchar2
11253   ,p_scl_segment24                in     varchar2
11254   ,p_scl_segment25                in     varchar2
11255   ,p_scl_segment26                in     varchar2
11256   ,p_scl_segment27                in     varchar2
11257   ,p_scl_segment28                in     varchar2
11258   ,p_scl_segment29                in     varchar2
11259   ,p_scl_segment30                in     varchar2
11260   ,p_supervisor_assignment_id     in     number
11261   ,p_org_now_no_manager_warning      out nocopy boolean
11262   ,p_effective_start_date            out nocopy date
11263   ,p_effective_end_date              out nocopy date
11264   ,p_comment_id                      out nocopy number
11265   ,p_no_managers_warning             out nocopy boolean
11266   ,p_other_manager_warning           out nocopy boolean
11267   ,p_soft_coding_keyflex_id          out nocopy number
11268   ,p_concatenated_segments           out nocopy varchar2
11269   ,p_hourly_salaried_warning         out nocopy boolean) IS
11270   --
11271   -- Declare cursors and local variables
11272   --
11273   -- Out variables
11274   --
11275   l_org_now_no_manager_warning BOOLEAN;
11276   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
11277   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
11278   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
11279   l_no_managers_warning        BOOLEAN;
11280   l_other_manager_warning      BOOLEAN;
11281   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
11282   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
11283   l_concatenated_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
11284   l_old_conc_segments          hr_soft_coding_keyflex.concatenated_segments%TYPE;
11285   l_hourly_salaried_warning    BOOLEAN;
11286   l_session_id                 NUMBER;
11287   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
11288   l_payroll_id_updated         BOOLEAN;
11289   --
11290   -- Internal working variables
11291   --
11292   l_proc                       VARCHAR2(72) := g_package||'update_cwk_asg';
11293   l_effective_date             DATE;
11294   l_projected_assignment_end   DATE;
11295   l_organization_id            per_all_assignments_f.organization_id%TYPE;
11296   l_business_group_id          per_business_groups.business_group_id%TYPE;
11297   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
11298   l_location_id                per_all_assignments_f.location_id%TYPE;
11299   l_old_asg_status             per_assignment_status_types.per_system_status%TYPE;
11300   l_new_asg_status             per_assignment_status_types.per_system_status%TYPE;
11301   l_cagr_grade_def_id          NUMBER;
11302   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
11303   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
11304   l_po_header_id               NUMBER := p_po_header_id;
11305   l_vendor_id                  NUMBER := p_vendor_id;
11306   --
11307   /*
11308   l_old_conc_segments          hr_soft_coding_keyflex.concatenated_segments%TYPE;
11309   l_date_probation_end         per_all_assignments_f.date_probation_end%TYPE;
11310   l_assignment_type            per_all_assignments_f.assignment_type%TYPE;
11311   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
11312   l_unused_start_date          date;
11313   l_unused_end_date            date;
11314   */
11315   --
11316   lv_object_version_number     number := p_object_version_number ;
11317   --
11318   cursor csr_old_asg_status is
11319     select ast.per_system_status
11320     from   per_assignment_status_types ast,
11321            per_all_assignments_f asg
11322     where  ast.assignment_status_type_id = asg.assignment_status_type_id
11323     and    asg.assignment_id             = p_assignment_id
11324     and    l_effective_date between asg.effective_start_date and asg.effective_end_date;
11325   --
11326   cursor csr_new_asg_status is
11327     select ast.per_system_status
11328     from   per_assignment_status_types ast
11329     where  ast.assignment_status_type_id = p_assignment_status_type_id;
11330   --
11331   cursor csr_get_assignment_type is
11332     select asg.assignment_type
11333          , asg.business_group_id
11334          , asg.soft_coding_keyflex_id
11335          , asg.organization_id
11336          , asg.location_id
11337       from per_all_assignments_f asg
11338      where asg.assignment_id = p_assignment_id
11339        and l_effective_date  between asg.effective_start_date
11340                              and     asg.effective_end_date;
11341   --
11342   cursor csr_scl_idsel is
11343     select plr.rule_mode            id_flex_num
11344     from   pay_legislation_rules    plr,
11345            per_business_groups_perf pgr
11346     where  plr.legislation_code  = pgr.legislation_code
11347     and    pgr.business_group_id = l_business_group_id
11348     and    plr.rule_type         = 'CWK_S'
11349     and    exists
11350           (select 1
11351            from   fnd_segment_attribute_values fsav
11352            where  fsav.id_flex_num             = plr.rule_mode
11353            and    fsav.application_id          = 800
11354            and    fsav.id_flex_code            = 'SCL'
11355            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
11356            and    fsav.attribute_value         = 'Y')
11357     and    exists
11358           (select 1
11359            from   pay_legislation_rules        plr2
11360            where  plr2.legislation_code        = plr.legislation_code
11361            and    plr2.rule_type               = 'CWK_SDL'
11362            and    plr2.rule_mode               = 'A') ;
11363 
11364 	      --start code for bug 6961562
11365 		l_installed          boolean;
11366 		l_po_installed      VARCHAR2(1);
11367 		l_industry           VARCHAR2(1);
11368 		l_vendor_id_1      number default null;
11369 		l_vendor_site_id_1      number default null;
11370 
11371 		cursor po_cwk is
11372 		select vendor_id,vendor_site_id from
11373 		per_all_assignments_f paf
11374 		where paf.assignment_id = p_assignment_id
11375 		and nvl(l_effective_date,sysdate) between paf.effective_start_date
11376 		and paf.effective_end_date;
11377 	     --end code for bug 6961562
11378 
11379   --
11380 BEGIN
11381   --
11382  if g_debug then
11383   hr_utility.set_location('Entering:'|| l_proc, 5);
11384  end if;
11385   --
11386   -- Truncate date and date_probation_end values, effectively removing time element.
11387   --
11388   l_effective_date     := trunc(p_effective_date);
11389   l_projected_assignment_end := trunc(p_projected_assignment_end);
11390   --
11391   l_object_version_number := p_object_version_number;
11392   --
11393   -- Bug 944911 - changed p_concatenated_segments to p_concat_segments
11394   --
11395   l_old_conc_segments := p_concat_segments;
11396   --
11397   -- Issue a savepoint.
11398   --
11399   SAVEPOINT update_cwk_asg;
11400   --
11401   BEGIN
11402     --
11403     -- Start of API User Hook for the before hook of update_emp_asg
11404     --
11405     hr_assignment_bkm.update_cwk_asg_b
11406       (p_effective_date               => l_effective_date
11407       ,p_datetrack_update_mode        => p_datetrack_update_mode
11408       ,p_assignment_id                => p_assignment_id
11409       ,p_object_version_number        => p_object_version_number
11410       ,p_assignment_category		  => p_assignment_category
11411       ,p_assignment_number            => p_assignment_number
11412       ,p_change_reason                => p_change_reason
11413       ,p_comments                     => p_comments
11414       ,p_default_code_comb_id         => p_default_code_comb_id
11415       ,p_establishment_id             => p_establishment_id
11416       ,p_frequency                    => p_frequency
11417       ,p_internal_address_line        => p_internal_address_line
11418       ,p_labour_union_member_flag     => p_labour_union_member_flag
11419       ,p_manager_flag                 => p_manager_flag
11420       ,p_normal_hours                 => p_normal_hours
11421       ,p_project_title				  => p_project_title
11422       ,p_set_of_books_id              => p_set_of_books_id
11423       ,p_source_type                  => p_source_type
11424       ,p_supervisor_id                => p_supervisor_id
11425       ,p_time_normal_finish           => p_time_normal_finish
11426       ,p_time_normal_start            => p_time_normal_start
11427       ,p_title                        => p_title
11428       ,p_vendor_assignment_number     => p_vendor_assignment_number
11429       ,p_vendor_employee_number       => p_vendor_employee_number
11430       ,p_vendor_id                    => p_vendor_id
11431       ,p_vendor_site_id               => p_vendor_site_id
11432       ,p_po_header_id                 => p_po_header_id
11433       ,p_po_line_id                   => p_po_line_id
11434       ,p_projected_assignment_end     => l_projected_assignment_end
11435       ,p_assignment_status_type_id    => p_assignment_status_type_id
11436       ,p_attribute_category           => p_attribute_category
11437       ,p_attribute1                   => p_attribute1
11438       ,p_attribute2                   => p_attribute2
11439       ,p_attribute3                   => p_attribute3
11440       ,p_attribute4                   => p_attribute4
11441       ,p_attribute5                   => p_attribute5
11442       ,p_attribute6                   => p_attribute6
11443       ,p_attribute7                   => p_attribute7
11444       ,p_attribute8                   => p_attribute8
11445       ,p_attribute9                   => p_attribute9
11446       ,p_attribute10                  => p_attribute10
11447       ,p_attribute11                  => p_attribute11
11448       ,p_attribute12                  => p_attribute12
11449       ,p_attribute13                  => p_attribute13
11450       ,p_attribute14                  => p_attribute14
11451       ,p_attribute15                  => p_attribute15
11452       ,p_attribute16                  => p_attribute16
11453       ,p_attribute17                  => p_attribute17
11454       ,p_attribute18                  => p_attribute18
11455       ,p_attribute19                  => p_attribute19
11456       ,p_attribute20                  => p_attribute20
11457       ,p_attribute21                  => p_attribute21
11458       ,p_attribute22                  => p_attribute22
11459       ,p_attribute23                  => p_attribute23
11460       ,p_attribute24                  => p_attribute24
11461       ,p_attribute25                  => p_attribute25
11462       ,p_attribute26                  => p_attribute26
11463       ,p_attribute27                  => p_attribute27
11464       ,p_attribute28                  => p_attribute28
11465       ,p_attribute29                  => p_attribute29
11466       ,p_attribute30                  => p_attribute30
11467       ,p_scl_segment1                 => p_scl_segment1
11468       ,p_scl_segment2                 => p_scl_segment2
11469       ,p_scl_segment3                 => p_scl_segment3
11470       ,p_scl_segment4                 => p_scl_segment4
11471       ,p_scl_segment5                 => p_scl_segment5
11472       ,p_scl_segment6                 => p_scl_segment6
11473       ,p_scl_segment7                 => p_scl_segment7
11474       ,p_scl_segment8                 => p_scl_segment8
11475       ,p_scl_segment9                 => p_scl_segment9
11476       ,p_scl_segment10                => p_scl_segment10
11477       ,p_scl_segment11                => p_scl_segment11
11478       ,p_scl_segment12                => p_scl_segment12
11479       ,p_scl_segment13                => p_scl_segment13
11480       ,p_scl_segment14                => p_scl_segment14
11481       ,p_scl_segment15                => p_scl_segment15
11482       ,p_scl_segment16                => p_scl_segment16
11483       ,p_scl_segment17                => p_scl_segment17
11484       ,p_scl_segment18                => p_scl_segment18
11485       ,p_scl_segment19                => p_scl_segment19
11486       ,p_scl_segment20                => p_scl_segment20
11487       ,p_scl_segment21                => p_scl_segment21
11488       ,p_scl_segment22                => p_scl_segment22
11489       ,p_scl_segment23                => p_scl_segment23
11490       ,p_scl_segment24                => p_scl_segment24
11491       ,p_scl_segment25                => p_scl_segment25
11492       ,p_scl_segment26                => p_scl_segment26
11493       ,p_scl_segment27                => p_scl_segment27
11494       ,p_scl_segment28                => p_scl_segment28
11495       ,p_scl_segment29                => p_scl_segment29
11496       ,p_scl_segment30                => p_scl_segment30
11497       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
11498       );
11499     --
11500   EXCEPTION
11501     --
11502     WHEN hr_api.cannot_find_prog_unit THEN
11503 	  --
11504       hr_api.cannot_find_prog_unit_error
11505         (p_module_name => 'UPDATE_CWK_ASG'
11506         ,p_hook_type   => 'BP'
11507         );
11508       --
11509       -- End of API User Hook for the before hook of update_emp_asg
11510       --
11511   END;
11512   --
11513  if g_debug then
11514   hr_utility.set_location(l_proc, 10);
11515  end if;
11516   --
11517   -- Validation in addition to Table Handlers
11518   --
11519   -- Get assignment type.
11520   --
11521   hr_api.mandatory_arg_error
11522     (p_api_name       => l_proc
11523     ,p_argument       => 'assignment_id'
11524     ,p_argument_value => p_assignment_id);
11525   --
11526   hr_api.mandatory_arg_error
11527     (p_api_name       => l_proc
11528     ,p_argument       => 'effective_date'
11529     ,p_argument_value => l_effective_date);
11530   --
11531   OPEN  csr_get_assignment_type;
11532   FETCH csr_get_assignment_type
11533    INTO l_assignment_type
11534       , l_business_group_id
11535       , l_soft_coding_keyflex_id
11536       , l_organization_id
11537       , l_location_id;
11538   --
11539   IF csr_get_assignment_type%NOTFOUND THEN
11540     --
11541     CLOSE csr_get_assignment_type;
11542 	--
11543     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
11544     hr_utility.raise_error;
11545 	--
11546   END IF;
11547   --
11548   CLOSE csr_get_assignment_type;
11549   --
11550  if g_debug then
11551   hr_utility.set_location(l_proc, 20);
11552  end if;
11553   --
11554   IF l_assignment_type <> 'C' THEN
11555     --
11556 	hr_utility.set_message(801,'HR_289575_ASG_ASG_NOT_EMP');
11557     hr_utility.raise_error;
11558 	--
11559   END IF;
11560   --
11561  if g_debug then
11562   hr_utility.set_location(l_proc, 21);
11563  end if;
11564   --
11565   --added validation for bug 1867720
11566   --
11567   IF p_assignment_status_type_id <> hr_api.g_number THEN
11568     --
11569     OPEN csr_old_asg_status;
11570     FETCH csr_old_asg_status INTO l_old_asg_status;
11571     CLOSE csr_old_asg_status;
11572     --
11573     OPEN csr_new_asg_status;
11574     FETCH csr_new_asg_status INTO l_new_asg_status;
11575 	--
11576     IF csr_new_asg_status%notfound OR
11577 	  (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status) THEN
11578 	  --
11579       fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
11580       fnd_message.set_token('SYSTYPE',l_old_asg_status);
11581       fnd_message.raise_error;
11582 	  --
11583     END IF;
11584 	--
11585     CLOSE csr_new_asg_status;
11586 	--
11587   END IF;
11588   --
11589   -- insert the profile options and effective date for the flexfield
11590   -- validation to work
11591   --
11592   hr_kflex_utility.set_profiles
11593     (p_business_group_id => l_business_group_id
11594     ,p_assignment_id     => p_assignment_id
11595     ,p_organization_id   => l_organization_id
11596     ,p_location_id       => l_location_id);
11597   --
11598   hr_kflex_utility.set_session_date
11599     (p_effective_date => l_effective_date
11600     ,p_session_id     => l_session_id);
11601   --
11602   -- Bug 944911
11603   -- Added to next 2 ifs check for p_concatenated_segments also
11604   --
11605   if   p_scl_segment1 <> hr_api.g_varchar2
11606     or p_scl_segment2 <> hr_api.g_varchar2
11607     or p_scl_segment3 <> hr_api.g_varchar2
11608     or p_scl_segment4 <> hr_api.g_varchar2
11609     or p_scl_segment5 <> hr_api.g_varchar2
11610     or p_scl_segment6 <> hr_api.g_varchar2
11611     or p_scl_segment7 <> hr_api.g_varchar2
11612     or p_scl_segment8 <> hr_api.g_varchar2
11613     or p_scl_segment9 <> hr_api.g_varchar2
11614     or p_scl_segment10 <> hr_api.g_varchar2
11615     or p_scl_segment11 <> hr_api.g_varchar2
11616     or p_scl_segment12 <> hr_api.g_varchar2
11617     or p_scl_segment13 <> hr_api.g_varchar2
11618     or p_scl_segment14 <> hr_api.g_varchar2
11619     or p_scl_segment15 <> hr_api.g_varchar2
11620     or p_scl_segment16 <> hr_api.g_varchar2
11621     or p_scl_segment17 <> hr_api.g_varchar2
11622     or p_scl_segment18 <> hr_api.g_varchar2
11623     or p_scl_segment19 <> hr_api.g_varchar2
11624     or p_scl_segment20 <> hr_api.g_varchar2
11625     or p_scl_segment21 <> hr_api.g_varchar2
11626     or p_scl_segment22 <> hr_api.g_varchar2
11627     or p_scl_segment23 <> hr_api.g_varchar2
11628     or p_scl_segment24 <> hr_api.g_varchar2
11629     or p_scl_segment25 <> hr_api.g_varchar2
11630     or p_scl_segment26 <> hr_api.g_varchar2
11631     or p_scl_segment27 <> hr_api.g_varchar2
11632     or p_scl_segment28 <> hr_api.g_varchar2
11633     or p_scl_segment29 <> hr_api.g_varchar2
11634     or p_scl_segment30 <> hr_api.g_varchar2
11635     -- bug 944911
11636     -- changed p_concatenated_segments to p_concat_segments
11637     or p_concat_segments <> hr_api.g_varchar2 then
11638     --
11639     OPEN csr_scl_idsel;
11640     FETCH csr_scl_idsel INTO l_flex_num;
11641     --
11642     IF csr_scl_idsel%NOTFOUND THEN
11643 	  --
11644       CLOSE csr_scl_idsel;
11645 	  --
11646       if   p_scl_segment1 is not null
11647         or p_scl_segment2 is not null
11648         or p_scl_segment3 is not null
11649         or p_scl_segment4 is not null
11650         or p_scl_segment5 is not null
11651         or p_scl_segment6 is not null
11652         or p_scl_segment7 is not null
11653         or p_scl_segment8 is not null
11654         or p_scl_segment9 is not null
11655         or p_scl_segment10 is not null
11656         or p_scl_segment11 is not null
11657         or p_scl_segment12 is not null
11658         or p_scl_segment13 is not null
11659         or p_scl_segment14 is not null
11660         or p_scl_segment15 is not null
11661         or p_scl_segment16 is not null
11662         or p_scl_segment17 is not null
11663         or p_scl_segment18 is not null
11664         or p_scl_segment19 is not null
11665         or p_scl_segment20 is not null
11666         or p_scl_segment21 is not null
11667         or p_scl_segment22 is not null
11668         or p_scl_segment23 is not null
11669         or p_scl_segment24 is not null
11670         or p_scl_segment25 is not null
11671         or p_scl_segment26 is not null
11672         or p_scl_segment27 is not null
11673         or p_scl_segment28 is not null
11674         or p_scl_segment29 is not null
11675         or p_scl_segment30 is not null
11676         or p_concat_segments is not null then
11677         --
11678         hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
11679         hr_utility.set_message_token('PROCEDURE', l_proc);
11680         hr_utility.set_message_token('STEP','5');
11681         hr_utility.raise_error;
11682 		--
11683       END IF;
11684 	  --
11685     ELSE
11686 	  --
11687       CLOSE csr_scl_idsel;
11688       --
11689       -- Process Logic
11690       --
11691       -- Update or select the soft_coding_keyflex_id
11692       --
11693       hr_kflex_utility.upd_or_sel_keyflex_comb
11694       (p_appl_short_name        => 'PER'
11695       ,p_flex_code              => 'SCL'
11696       ,p_flex_num               => l_flex_num
11697       ,p_segment1               => p_scl_segment1
11698       ,p_segment2               => p_scl_segment2
11699       ,p_segment3               => p_scl_segment3
11700       ,p_segment4               => p_scl_segment4
11701       ,p_segment5               => p_scl_segment5
11702       ,p_segment6               => p_scl_segment6
11703       ,p_segment7               => p_scl_segment7
11704       ,p_segment8               => p_scl_segment8
11705       ,p_segment9               => p_scl_segment9
11706       ,p_segment10              => p_scl_segment10
11707       ,p_segment11              => p_scl_segment11
11708       ,p_segment12              => p_scl_segment12
11709       ,p_segment13              => p_scl_segment13
11710       ,p_segment14              => p_scl_segment14
11711       ,p_segment15              => p_scl_segment15
11712       ,p_segment16              => p_scl_segment16
11713       ,p_segment17              => p_scl_segment17
11714       ,p_segment18              => p_scl_segment18
11715       ,p_segment19              => p_scl_segment19
11716       ,p_segment20              => p_scl_segment20
11717       ,p_segment21              => p_scl_segment21
11718       ,p_segment22              => p_scl_segment22
11719       ,p_segment23              => p_scl_segment23
11720       ,p_segment24              => p_scl_segment24
11721       ,p_segment25              => p_scl_segment25
11722       ,p_segment26              => p_scl_segment26
11723       ,p_segment27              => p_scl_segment27
11724       ,p_segment28              => p_scl_segment28
11725       ,p_segment29              => p_scl_segment29
11726       ,p_segment30              => p_scl_segment30
11727       ,p_concat_segments_in     => l_old_conc_segments
11728       ,p_ccid                   => l_soft_coding_keyflex_id
11729       ,p_concat_segments_out    => l_concatenated_segments
11730       );
11731       --
11732       -- update the combinations column
11733       --
11734       update_scl_concat_segs
11735         (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
11736         ,p_concatenated_segments   => l_concatenated_segments);
11737       --
11738     END IF;
11739   --
11740   END IF;
11741 
11742  if g_debug then
11743   hr_utility.set_location(l_proc, 22);
11744  end if;
11745 
11746   --
11747   -- Default the PO Header if the line is passed in and the
11748   -- header is not.
11749   --
11750   IF p_po_line_id IS NOT NULL AND l_po_header_id IS NULL THEN
11751 
11752     l_po_header_id := get_po_for_line
11753       (p_po_line_id => p_po_line_id);
11754 
11755   END IF;
11756 
11757   --
11758   -- Default the Supplier if the Site is entered and Supplier is not.
11759   --
11760   IF p_vendor_site_id IS NOT NULL AND l_vendor_id IS NULL THEN
11761 
11762     l_vendor_id := get_supplier_for_site
11763       (p_vendor_site_id => p_vendor_site_id);
11764 
11765   END IF;
11766 
11767 
11768    --start code for bug 6961562
11769   -- PO
11770   l_installed := fnd_installation.get(appl_id => 210
11771 		,dep_appl_id => 210
11772           ,status => l_po_installed
11773           ,industry => l_industry);
11774 
11775   if l_po_installed <> 'N' then
11776     open po_cwk;
11777     fetch po_cwk into l_vendor_id_1,l_vendor_site_id_1;
11778     if po_cwk%found then
11779     if (l_vendor_id_1 <> p_vendor_id)
11780     or (l_vendor_site_id_1 <> p_vendor_site_id) then
11781 	PO_HR_INTERFACE_PVT.is_Supplier_Updatable( p_assignment_id => p_assignment_id,
11782                                                p_effective_date => l_effective_date );
11783         end if;
11784      end if;
11785      close po_cwk;
11786   end if;
11787   --end code for bug 6961562
11788 
11789 
11790  if g_debug then
11791   hr_utility.set_location(l_proc, 23);
11792  end if;
11793 
11794   /*
11795   --
11796  if g_debug then
11797   hr_utility.set_location(l_proc, 24);
11798  end if;
11799   --
11800   -- Update or select the cagr_grade_def_id
11801   --
11802   -- need to call the lck procedure early, to fetch the old value of cagr_id_flex_num
11803   -- before passing it into the hr_cgd_upd.upd_or_sel function.
11804   -- This is because the user may be updating a grade definition, but not changing
11805   -- or specifying the cagr_id_flex_num (ie the grade structure).
11806   -- Also, need to fetch the old cagr_grade_def_id, as the user may be updating some
11807   -- segments, and not changing others. Passing cagr_grade_id into the hr_cgd_upd.upd_or_sel
11808   -- function allows that function to derive the old values.
11809   --
11810   l_cagr_id_flex_num  := p_cagr_id_flex_num;
11811    --
11812   If (p_cagr_id_flex_num  = hr_api.g_number) THEN
11813     --
11814     per_asg_shd.lck
11815       (p_effective_date          => l_effective_date,
11816        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
11817        p_datetrack_mode          => p_datetrack_update_mode,
11818        p_assignment_id           => p_assignment_id,
11819        p_object_version_number   => p_object_version_number,
11820        p_validation_start_date   => l_unused_start_date,
11821        p_validation_end_date     => l_unused_end_date
11822        );
11823 	--
11824     l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
11825     l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
11826 	--
11827   End if;
11828   --
11829   hr_cgd_upd.upd_or_sel
11830     (p_segment1               => p_cag_segment1
11831     ,p_segment2               => p_cag_segment2
11832     ,p_segment3               => p_cag_segment3
11833     ,p_segment4               => p_cag_segment4
11834     ,p_segment5               => p_cag_segment5
11835     ,p_segment6               => p_cag_segment6
11836     ,p_segment7               => p_cag_segment7
11837     ,p_segment8               => p_cag_segment8
11838     ,p_segment9               => p_cag_segment9
11839     ,p_segment10              => p_cag_segment10
11840     ,p_segment11              => p_cag_segment11
11841     ,p_segment12              => p_cag_segment12
11842     ,p_segment13              => p_cag_segment13
11843     ,p_segment14              => p_cag_segment14
11844     ,p_segment15              => p_cag_segment15
11845     ,p_segment16              => p_cag_segment16
11846     ,p_segment17              => p_cag_segment17
11847     ,p_segment18              => p_cag_segment18
11848     ,p_segment19              => p_cag_segment19
11849     ,p_segment20              => p_cag_segment20
11850     ,p_id_flex_num            => l_cagr_id_flex_num
11851     ,p_business_group_id      => l_business_group_id
11852     ,p_cagr_grade_def_id      => l_cagr_grade_def_id
11853     ,p_concatenated_segments  => l_cagr_concatenated_segments);
11854   --
11855   */
11856  if g_debug then
11857   hr_utility.set_location(l_proc, 25);
11858  end if;
11859   --
11860   -- Update assignment.
11861   --
11862   per_asg_upd.upd
11863     (p_assignment_id                => p_assignment_id
11864     ,p_effective_start_date         => l_effective_start_date
11865     ,p_effective_end_date           => l_effective_end_date
11866     ,p_business_group_id            => l_business_group_id
11867     ,p_assignment_status_type_id    => p_assignment_status_type_id
11868     ,p_supervisor_id                => p_supervisor_id
11869     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
11870     ,p_assignment_number            => p_assignment_number
11871     ,p_employment_category          => p_assignment_category
11872     ,p_change_reason                => p_change_reason
11873     ,p_comment_id                   => l_comment_id
11874     ,p_comments                     => p_comments
11875     --,p_date_probation_end           => l_date_probation_end
11876     ,p_default_code_comb_id         => p_default_code_comb_id
11877     ,p_frequency                    => p_frequency
11878     ,p_internal_address_line        => p_internal_address_line
11879     ,p_manager_flag                 => p_manager_flag
11880     ,p_normal_hours                 => p_normal_hours
11881     ,p_project_title                => p_project_title
11882     --,p_perf_review_period           => p_perf_review_period
11883     --,p_perf_review_period_frequency => p_perf_review_period_frequency
11884     --,p_probation_period             => p_probation_period
11885     --,p_probation_unit               => p_probation_unit
11886     --,p_sal_review_period            => p_sal_review_period
11887     --,p_sal_review_period_frequency  => p_sal_review_period_frequency
11888     ,p_set_of_books_id              => p_set_of_books_id
11889     ,p_source_type                  => p_source_type
11890     ,p_time_normal_finish           => p_time_normal_finish
11891     ,p_time_normal_start            => p_time_normal_start
11892     --,p_bargaining_unit_code         => p_bargaining_unit_code
11893     ,p_labour_union_member_flag     => p_labour_union_member_flag
11894     --,p_hourly_salaried_code         => p_hourly_salaried_code
11895     ,p_ass_attribute_category       => p_attribute_category
11896     ,p_ass_attribute1               => p_attribute1
11897     ,p_ass_attribute2               => p_attribute2
11898     ,p_ass_attribute3               => p_attribute3
11899     ,p_ass_attribute4               => p_attribute4
11900     ,p_ass_attribute5               => p_attribute5
11901     ,p_ass_attribute6               => p_attribute6
11902     ,p_ass_attribute7               => p_attribute7
11903     ,p_ass_attribute8               => p_attribute8
11904     ,p_ass_attribute9               => p_attribute9
11905     ,p_ass_attribute10              => p_attribute10
11906     ,p_ass_attribute11              => p_attribute11
11907     ,p_ass_attribute12              => p_attribute12
11908     ,p_ass_attribute13              => p_attribute13
11909     ,p_ass_attribute14              => p_attribute14
11910     ,p_ass_attribute15              => p_attribute15
11911     ,p_ass_attribute16              => p_attribute16
11912     ,p_ass_attribute17              => p_attribute17
11913     ,p_ass_attribute18              => p_attribute18
11914     ,p_ass_attribute19              => p_attribute19
11915     ,p_ass_attribute20              => p_attribute20
11916     ,p_ass_attribute21              => p_attribute21
11917     ,p_ass_attribute22              => p_attribute22
11918     ,p_ass_attribute23              => p_attribute23
11919     ,p_ass_attribute24              => p_attribute24
11920     ,p_ass_attribute25              => p_attribute25
11921     ,p_ass_attribute26              => p_attribute26
11922     ,p_ass_attribute27              => p_attribute27
11923     ,p_ass_attribute28              => p_attribute28
11924     ,p_ass_attribute29              => p_attribute29
11925     ,p_ass_attribute30              => p_attribute30
11926     --,p_notice_period		        => p_notice_period
11927     --,p_notice_period_uom	        => p_notice_period_uom
11928     --,p_employee_category	        => p_employee_category
11929     --,p_work_at_home		            => p_work_at_home
11930     --,p_job_post_source_name	        => p_job_post_source_name
11931     ,p_title                        => p_title
11932     ,p_vendor_assignment_number     => p_vendor_assignment_number
11933     ,p_vendor_employee_number       => p_vendor_employee_number
11934     ,p_vendor_id                    => l_vendor_id
11935     ,p_vendor_site_id               => p_vendor_site_id
11936     ,p_po_header_id                 => l_po_header_id
11937     ,p_po_line_id                   => p_po_line_id
11938     ,p_projected_assignment_end     => l_projected_assignment_end
11939     ,p_payroll_id_updated           => l_payroll_id_updated
11940     ,p_other_manager_warning        => l_other_manager_warning
11941     ,p_no_managers_warning          => l_no_managers_warning
11942     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
11943     ,p_validation_start_date        => l_validation_start_date
11944     ,p_validation_end_date          => l_validation_end_date
11945     ,p_object_version_number        => l_object_version_number
11946     ,p_effective_date               => l_effective_date
11947     ,p_datetrack_mode               => p_datetrack_update_mode
11948     --,p_contract_id                  => p_contract_id
11949     ,p_establishment_id             => p_establishment_id
11950     --,p_collective_agreement_id      => p_collective_agreement_id
11951     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
11952     --,p_cagr_id_flex_num             => p_cagr_id_flex_num
11953     ,p_validate                     => FALSE
11954     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
11955     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
11956     );
11957   --
11958  if g_debug then
11959   hr_utility.set_location(l_proc, 26);
11960  end if;
11961   --
11962   BEGIN
11963     --
11964     -- Start of API User Hook for the after hook of update_cwk_asg
11965     --
11966     hr_assignment_bkm.update_cwk_asg_a
11967       (p_effective_date               => l_effective_date
11968       ,p_datetrack_update_mode        => p_datetrack_update_mode
11969       ,p_assignment_id                => p_assignment_id
11970       ,p_object_version_number        => p_object_version_number
11971       ,p_assignment_category		  => p_assignment_category
11972       ,p_assignment_number            => p_assignment_number
11973       ,p_change_reason                => p_change_reason
11974       ,p_comments                     => p_comments
11975       ,p_default_code_comb_id         => p_default_code_comb_id
11976       ,p_establishment_id             => p_establishment_id
11977       ,p_frequency                    => p_frequency
11978       ,p_internal_address_line        => p_internal_address_line
11979       ,p_labour_union_member_flag     => p_labour_union_member_flag
11980       ,p_manager_flag                 => p_manager_flag
11981       ,p_normal_hours                 => p_normal_hours
11982       ,p_project_title				  => p_project_title
11983       ,p_set_of_books_id              => p_set_of_books_id
11984       ,p_source_type                  => p_source_type
11985       ,p_supervisor_id                => p_supervisor_id
11986       ,p_time_normal_finish           => p_time_normal_finish
11987       ,p_time_normal_start            => p_time_normal_start
11988       ,p_title                        => p_title
11989       ,p_vendor_assignment_number     => p_vendor_assignment_number
11990       ,p_vendor_employee_number       => p_vendor_employee_number
11991       ,p_vendor_id                    => l_vendor_id
11992       ,p_vendor_site_id               => p_vendor_site_id
11993       ,p_po_header_id                 => l_po_header_id
11994       ,p_po_line_id                   => p_po_line_id
11995       ,p_projected_assignment_end     => l_projected_assignment_end
11996       ,p_assignment_status_type_id    => p_assignment_status_type_id
11997       ,p_attribute_category           => p_attribute_category
11998       ,p_attribute1                   => p_attribute1
11999       ,p_attribute2                   => p_attribute2
12000       ,p_attribute3                   => p_attribute3
12001       ,p_attribute4                   => p_attribute4
12002       ,p_attribute5                   => p_attribute5
12003       ,p_attribute6                   => p_attribute6
12004       ,p_attribute7                   => p_attribute7
12005       ,p_attribute8                   => p_attribute8
12006       ,p_attribute9                   => p_attribute9
12007       ,p_attribute10                  => p_attribute10
12008       ,p_attribute11                  => p_attribute11
12009       ,p_attribute12                  => p_attribute12
12010       ,p_attribute13                  => p_attribute13
12011       ,p_attribute14                  => p_attribute14
12012       ,p_attribute15                  => p_attribute15
12013       ,p_attribute16                  => p_attribute16
12014       ,p_attribute17                  => p_attribute17
12015       ,p_attribute18                  => p_attribute18
12016       ,p_attribute19                  => p_attribute19
12017       ,p_attribute20                  => p_attribute20
12018       ,p_attribute21                  => p_attribute21
12019       ,p_attribute22                  => p_attribute22
12020       ,p_attribute23                  => p_attribute23
12021       ,p_attribute24                  => p_attribute24
12022       ,p_attribute25                  => p_attribute25
12023       ,p_attribute26                  => p_attribute26
12024       ,p_attribute27                  => p_attribute27
12025       ,p_attribute28                  => p_attribute28
12026       ,p_attribute29                  => p_attribute29
12027       ,p_attribute30                  => p_attribute30
12028       ,p_scl_segment1                 => p_scl_segment1
12029       ,p_scl_segment2                 => p_scl_segment2
12030       ,p_scl_segment3                 => p_scl_segment3
12031       ,p_scl_segment4                 => p_scl_segment4
12032       ,p_scl_segment5                 => p_scl_segment5
12033       ,p_scl_segment6                 => p_scl_segment6
12034       ,p_scl_segment7                 => p_scl_segment7
12035       ,p_scl_segment8                 => p_scl_segment8
12036       ,p_scl_segment9                 => p_scl_segment9
12037       ,p_scl_segment10                => p_scl_segment10
12038       ,p_scl_segment11                => p_scl_segment11
12039       ,p_scl_segment12                => p_scl_segment12
12040       ,p_scl_segment13                => p_scl_segment13
12041       ,p_scl_segment14                => p_scl_segment14
12042       ,p_scl_segment15                => p_scl_segment15
12043       ,p_scl_segment16                => p_scl_segment16
12044       ,p_scl_segment17                => p_scl_segment17
12045       ,p_scl_segment18                => p_scl_segment18
12046       ,p_scl_segment19                => p_scl_segment19
12047       ,p_scl_segment20                => p_scl_segment20
12048       ,p_scl_segment21                => p_scl_segment21
12049       ,p_scl_segment22                => p_scl_segment22
12050       ,p_scl_segment23                => p_scl_segment23
12051       ,p_scl_segment24                => p_scl_segment24
12052       ,p_scl_segment25                => p_scl_segment25
12053       ,p_scl_segment26                => p_scl_segment26
12054       ,p_scl_segment27                => p_scl_segment27
12055       ,p_scl_segment28                => p_scl_segment28
12056       ,p_scl_segment29                => p_scl_segment29
12057       ,p_scl_segment30                => p_scl_segment30
12058       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
12059       ,p_effective_start_date         => l_effective_start_date
12060       ,p_effective_end_date           => l_effective_end_date
12061       ,p_comment_id                   => l_comment_id
12062       ,p_no_managers_warning          => l_no_managers_warning
12063       ,p_other_manager_warning        => l_other_manager_warning
12064       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
12065       ,p_concatenated_segments        => l_concatenated_segments
12066       ,p_hourly_salaried_warning      => l_hourly_salaried_warning
12067       ,p_supervisor_assignment_id     => p_supervisor_assignment_id
12068     );
12069     --
12070   EXCEPTION
12071     --
12072     WHEN hr_api.cannot_find_prog_unit THEN
12073 	  --
12074       hr_api.cannot_find_prog_unit_error
12075         (p_module_name => 'UPDATE_CWK_ASG'
12076         ,p_hook_type   => 'AP'
12077         );
12078       --
12079       -- End of API User Hook for the after hook of update_cwk_asg
12080       --
12081   END;
12082   --
12083   -- When in validation only mode raise the Validate_Enabled exception
12084   --
12085   IF p_validate THEN
12086     --
12087     RAISE hr_api.validate_enabled;
12088 	--
12089   END IF;
12090   --
12091   -- Set all output arguments
12092   --
12093   p_object_version_number   := l_object_version_number;
12094   p_soft_coding_keyflex_id  := l_soft_coding_keyflex_id;
12095   p_comment_id              := l_comment_id;
12096   p_effective_start_date    := l_effective_start_date;
12097   p_effective_end_date      := l_effective_end_date;
12098   p_concatenated_segments   := l_concatenated_segments;
12099   p_no_managers_warning     := l_no_managers_warning;
12100   p_other_manager_warning   := l_other_manager_warning;
12101   p_hourly_salaried_warning := l_hourly_salaried_warning;
12102   --
12103   -- remove data from the session table
12104   --
12105   hr_kflex_utility.unset_session_date
12106     (p_session_id     => l_session_id);
12107   --
12108  if g_debug then
12109   hr_utility.set_location(' Leaving:'||l_proc, 999);
12110  end if;
12111   --
12112 EXCEPTION
12113   --
12114   WHEN hr_api.validate_enabled THEN
12115     --
12116     -- As the Validate_Enabled exception has been raised
12117     -- we must rollback to the savepoint
12118     --
12119     ROLLBACK TO update_cwk_asg;
12120     --
12121     -- Only set output warning arguments
12122     -- (Any key or derived arguments must be set to null
12123     -- when validation only mode is being used.)
12124     --
12125     p_object_version_number      := p_object_version_number;
12126     p_soft_coding_keyflex_id     := null;
12127     p_comment_id                 := null;
12128     p_effective_start_date       := null;
12129     p_effective_end_date         := null;
12130     p_concatenated_segments      := l_old_conc_segments;
12131     p_no_managers_warning        := l_no_managers_warning;
12132     p_other_manager_warning      := l_other_manager_warning;
12133     p_hourly_salaried_warning    := l_hourly_salaried_warning;
12134     --
12135   WHEN others THEN
12136     --
12137     -- A validation or unexpected error has occurred
12138     --
12139     -- Added as part of fix to bug 632479
12140     --
12141     p_object_version_number := lv_object_version_number;
12142 
12143     p_org_now_no_manager_warning      := null;
12144     p_effective_start_date            := null;
12145     p_effective_end_date              := null;
12146     p_comment_id                      := null;
12147     p_no_managers_warning             := null;
12148     p_other_manager_warning           := null;
12149     p_soft_coding_keyflex_id          := null;
12150     p_concatenated_segments           := null;
12151     p_hourly_salaried_warning         := null;
12152 
12153     ROLLBACK TO update_cwk_asg;
12154     RAISE;
12155     --
12156     -- End of fix.
12157     --
12158 END update_cwk_asg;
12159 --
12160 -- ----------------------------------------------------------------------------
12161 -- |---------------------< update_cwk_asg_criteria >--------------------------|
12162 -- ----------------------------------------------------------------------------
12163 --
12164 procedure update_cwk_asg_criteria
12165   (p_validate                     in     boolean
12166   ,p_effective_date               in     date
12167   ,p_datetrack_update_mode        in     varchar2
12168   ,p_assignment_id                in     number
12169   ,p_called_from_mass_update      in     boolean
12170   ,p_object_version_number        in out nocopy number
12171   ,p_grade_id                     in     number
12172   ,p_position_id                  in     number
12173   ,p_job_id                       in     number
12174   --
12175   -- p_payroll_id included for future phases of cwk
12176   --
12177   --,p_payroll_id                   in     number
12178   ,p_location_id                  in     number
12179   ,p_organization_id              in     number
12180   --
12181   -- p_pay_basis_id for future phases of cwk
12182   --
12183   ,p_pay_basis_id                 in     number
12184   ,p_segment1                     in     varchar2
12185   ,p_segment2                     in     varchar2
12186   ,p_segment3                     in     varchar2
12187   ,p_segment4                     in     varchar2
12188   ,p_segment5                     in     varchar2
12189   ,p_segment6                     in     varchar2
12190   ,p_segment7                     in     varchar2
12191   ,p_segment8                     in     varchar2
12192   ,p_segment9                     in     varchar2
12193   ,p_segment10                    in     varchar2
12194   ,p_segment11                    in     varchar2
12195   ,p_segment12                    in     varchar2
12196   ,p_segment13                    in     varchar2
12197   ,p_segment14                    in     varchar2
12198   ,p_segment15                    in     varchar2
12199   ,p_segment16                    in     varchar2
12200   ,p_segment17                    in     varchar2
12201   ,p_segment18                    in     varchar2
12202   ,p_segment19                    in     varchar2
12203   ,p_segment20                    in     varchar2
12204   ,p_segment21                    in     varchar2
12205   ,p_segment22                    in     varchar2
12206   ,p_segment23                    in     varchar2
12207   ,p_segment24                    in     varchar2
12208   ,p_segment25                    in     varchar2
12209   ,p_segment26                    in     varchar2
12210   ,p_segment27                    in     varchar2
12211   ,p_segment28                    in     varchar2
12212   ,p_segment29                    in     varchar2
12213   ,p_segment30                    in     varchar2
12214   ,p_concat_segments              in     varchar2
12215   ,p_people_group_name               out nocopy varchar2
12216   ,p_effective_start_date            out nocopy date
12217   ,p_effective_end_date              out nocopy date
12218   ,p_people_group_id                 out nocopy number
12219   ,p_org_now_no_manager_warning      out nocopy boolean
12220   ,p_other_manager_warning           out nocopy boolean
12221   ,p_spp_delete_warning              out nocopy boolean
12222   --
12223   -- p_entries_changed_warning included for future phases of cwk
12224   --
12225   ,p_entries_changed_warning         out nocopy varchar2
12226   ,p_tax_district_changed_warning    out nocopy boolean
12227   ) is
12228   --
12229   -- Declare cursors and local variables
12230   --
12231   -- Out variables
12232   --
12233   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
12234   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
12235   l_entries_changed_warning      varchar2(1) := 'N';
12236   l_people_group_name            pay_people_groups.group_name%TYPE;
12237   l_old_group_name               pay_people_groups.group_name%TYPE;
12238   l_no_managers_warning          boolean;
12239   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
12240   l_org_now_no_manager_warning   boolean;
12241   l_other_manager_warning        boolean;
12242   l_hourly_salaried_warning      boolean;
12243   l_payroll_id_updated           boolean;
12244   l_people_group_id              per_all_assignments_f.people_group_id%TYPE;
12245   l_spp_delete_warning           boolean := false; -- Bug 3545065
12246   l_tax_district_changed_warning boolean;
12247   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
12248   --
12249   l_api_updating                 boolean;
12250   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
12251   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
12252   l_entries_changed              varchar2(1);
12253   l_legislation_code             per_business_groups.legislation_code%TYPE;
12254   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
12255   l_proc                         varchar2(72) :=
12256                                        g_package || 'update_cwk_asg_criteria';
12257   l_validation_end_date          date;
12258   l_validation_start_date        date;
12259   l_effective_date               date;
12260   l_element_entry_id             number;
12261   l_organization_id              per_all_assignments_f.organization_id%type;
12262   l_location_id                  per_all_assignments_f.location_id%type;
12263   l_session_id                   number;
12264   l_assignment_type              per_all_assignments_f.assignment_type%TYPE;
12265   --
12266   lv_object_version_number     number := p_object_version_number ;
12267   l_grade_id                   number := Null; -- Bug 3545065
12268   --
12269 
12270   cursor csr_get_legislation_code is
12271     select bus.legislation_code
12272       from per_business_groups_perf bus
12273      where bus.business_group_id = l_business_group_id;
12274   --
12275   cursor csr_get_salary is
12276   select element_entry_id
12277   from   pay_element_entries_f
12278   where  assignment_id = p_assignment_id
12279   and    creator_type = 'SP'
12280   and    l_validation_start_date between
12281          effective_start_date and effective_end_date;
12282   --
12283   cursor csr_grp_idsel is
12284   select bus.people_group_structure
12285   from  per_business_groups_perf bus
12286   where bus.business_group_id = l_business_group_id;
12287   --
12288   cursor get_sec_date_range is
12289   select asg.effective_start_date
12290   ,      asg.effective_end_date
12291   from   per_all_assignments_f asg
12292   where  asg.assignment_id=p_assignment_id
12293   and   ((sysdate between asg.effective_start_date
12294           and asg.effective_end_date)
12295          or
12296          (sysdate<asg.effective_start_date
12297           and not exists
12298           (select 1
12299            from per_all_assignments_f asg2
12300            where asg2.person_id=asg.person_id
12301            and asg2.period_of_service_id=asg.period_of_service_id
12302            and asg2.effective_start_date<asg.effective_start_date)
12303          )
12304         );
12305   --
12306   cursor csr_get_assignment_type is
12307     select asg.assignment_type
12308       from per_all_assignments_f asg
12309      where asg.assignment_id = p_assignment_id
12310        and l_effective_date  between asg.effective_start_date
12311                              and     asg.effective_end_date;
12312   --
12313   l_sec_effective_start_date date;
12314   l_sec_effective_end_date date;
12315   --
12316   l_dt_update_mode     VARCHAR2(30);
12317   l_new_dt_update_mode VARCHAR2(30);
12318   --
12319   -- Start of bug 3553286
12320   l_job_id                       number := p_job_id;
12321   l_org_id                       number := p_organization_id;
12322   -- End of 3553286
12323 BEGIN
12324   --
12325  if g_debug then
12326   hr_utility.set_location('Entering:'|| l_proc, 1);
12327  end if;
12328   --
12329    IF p_called_from_mass_update THEN
12330     --
12331     if g_debug then
12332       hr_utility.set_location(l_proc,40);
12333     end if;
12334     --
12335     l_dt_update_mode     := 'CORRECTION';
12336     l_new_dt_update_mode := p_datetrack_update_mode;
12337     --
12338   ELSE
12339     --
12340     if g_debug then
12341       hr_utility.set_location(l_proc,50);
12342     end if;
12343     --
12344     l_dt_update_mode     := p_datetrack_update_mode;
12345     l_new_dt_update_mode := p_datetrack_update_mode;
12346     --
12347   END IF;
12348   --
12349   -- Truncate the p_effective_date value to remove time element.
12350   --
12351   l_effective_date := TRUNC(p_effective_date);
12352   --
12353   -- Bug 944911
12354   -- Made p_group_name to be out param
12355   -- and add p_concat_segment to be IN
12356   -- in case of sec_asg alone made p_pgp_concat_segments as in param
12357   -- Replaced p_group_name by p_concat_segments
12358   --
12359   l_old_group_name := p_concat_segments;
12360   --
12361   -- Issue a savepoint.
12362   --
12363   SAVEPOINT update_cwk_asg_criteria;
12364   --
12365   -- Check assignment is a cwk assignment
12366   --
12367   OPEN  csr_get_assignment_type;
12368   FETCH csr_get_assignment_type INTO l_assignment_type;
12369   --
12370   IF csr_get_assignment_type%NOTFOUND THEN
12371     --
12372     CLOSE csr_get_assignment_type;
12373 	--
12374     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
12375     hr_utility.raise_error;
12376 	--
12377   END IF;
12378   --
12379   CLOSE csr_get_assignment_type;
12380   --
12381  if g_debug then
12382   hr_utility.set_location(l_proc, 20);
12383  end if;
12384   --
12385   IF l_assignment_type <> 'C' THEN
12386     --
12387 	hr_utility.set_message(801,'HR_289575_ASG_ASG_NOT_EMP');
12388     hr_utility.raise_error;
12389 	--
12390   END IF;
12391   --
12392   BEGIN
12393     --
12394     -- Start of API User Hook for the before hook of update_emp_asg_criteria
12395     --
12396     hr_assignment_bko.update_cwk_asg_criteria_b
12397       (p_effective_date               => l_effective_date
12398       ,p_datetrack_update_mode        => l_dt_update_mode
12399       ,p_assignment_id                => p_assignment_id
12400       ,p_object_version_number        => p_object_version_number
12401       ,p_grade_id                     => l_grade_id -- Bug 3545065
12402       ,p_position_id                  => p_position_id
12403       ,p_job_id                       => p_job_id
12404       --,p_payroll_id                   => p_payroll_id
12405       ,p_location_id                  => p_location_id
12406       ,p_organization_id              => p_organization_id
12407       ,p_pay_basis_id                 => p_pay_basis_id
12408       ,p_segment1                     => p_segment1
12409       ,p_segment2                     => p_segment2
12410       ,p_segment3                     => p_segment3
12411       ,p_segment4                     => p_segment4
12412       ,p_segment5                     => p_segment5
12413       ,p_segment6                     => p_segment6
12414       ,p_segment7                     => p_segment7
12415       ,p_segment8                     => p_segment8
12416       ,p_segment9                     => p_segment9
12417       ,p_segment10                    => p_segment10
12418       ,p_segment11                    => p_segment11
12419       ,p_segment12                    => p_segment12
12420       ,p_segment13                    => p_segment13
12421       ,p_segment14                    => p_segment14
12422       ,p_segment15                    => p_segment15
12423       ,p_segment16                    => p_segment16
12424       ,p_segment17                    => p_segment17
12425       ,p_segment18                    => p_segment18
12426       ,p_segment19                    => p_segment19
12427       ,p_segment20                    => p_segment20
12428       ,p_segment21                    => p_segment21
12429       ,p_segment22                    => p_segment22
12430       ,p_segment23                    => p_segment23
12431       ,p_segment24                    => p_segment24
12432       ,p_segment25                    => p_segment25
12433       ,p_segment26                    => p_segment26
12434       ,p_segment27                    => p_segment27
12435       ,p_segment28                    => p_segment28
12436       ,p_segment29                    => p_segment29
12437       ,p_segment30                    => p_segment30
12438       ,p_concat_segments              => l_old_group_name);
12439   --
12440   EXCEPTION
12441     --
12442     WHEN hr_api.cannot_find_prog_unit THEN
12443 	  --
12444       hr_api.cannot_find_prog_unit_error
12445         (p_module_name => 'UPDATE_CWK_ASG_CRITERIA'
12446         ,p_hook_type   => 'BP');
12447     --
12448     -- End of API User Hook for the before hook of update_emp_cwk_criteria
12449     --
12450   END;
12451   --
12452  if g_debug then
12453   hr_utility.set_location(l_proc, 10);
12454  end if;
12455   --
12456   l_object_version_number := p_object_version_number;
12457   --
12458   -- Validation in addition to Table Handlers
12459   --
12460   -- Retrieve current assignment details from database.
12461   --
12462   l_api_updating := per_asg_shd.api_updating
12463     (p_assignment_id         => p_assignment_id
12464     ,p_effective_date        => l_effective_date
12465     ,p_object_version_number => l_object_version_number);
12466   --
12467  if g_debug then
12468   hr_utility.set_location(l_proc, 20);
12469  end if;
12470   --
12471   IF NOT l_api_updating THEN
12472     --
12473  if g_debug then
12474     hr_utility.set_location(l_proc, 30);
12475  end if;
12476     --
12477     -- As this is an updating API, the assignment should already exist.
12478     --
12479     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
12480     hr_utility.raise_error;
12481 	--
12482   ELSE
12483     --
12484  if g_debug then
12485     hr_utility.set_location(l_proc, 40);
12486  end if;
12487     --
12488     l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
12489 	--
12490   END IF;
12491   --
12492  if g_debug then
12493   hr_utility.set_location(l_proc, 50);
12494  end if;
12495   --
12496   -- Check that the assignment is an employee assignment.
12497   --
12498   IF per_asg_shd.g_old_rec.assignment_type <> 'C' THEN
12499     --
12500  if g_debug then
12501     hr_utility.set_location(l_proc, 60);
12502  end if;
12503     --
12504 	hr_utility.set_message(801, 'HR_289575_ASG_ASG_NOT_EMP');
12505     hr_utility.raise_error;
12506 	--
12507   END IF;
12508   --
12509  if g_debug then
12510   hr_utility.set_location(l_proc, 70);
12511  end if;
12512   --
12513   -- Process Logic
12514   --
12515   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
12516   --
12517   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
12518   --
12519   -- Start of bug fix 3553286
12520   -- This procedure will return the job_id and organization_id of a position
12521   --
12522   if (p_called_from_mass_update = TRUE and p_position_id is not null) then
12523      if (l_job_id is null) or (l_org_id is null) then
12524          hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
12525                                          l_job_id, l_org_id);
12526      end if;
12527   end if;
12528   -- End of 3553286
12529   -- insert the profile options and effective date for the flexfield
12530   -- validation to work
12531   --
12532   --
12533   IF (l_org_id = hr_api.g_number) THEN -- Bug 3553286
12534     --
12535     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
12536     --
12537   ELSE
12538     --
12539     l_organization_id := l_org_id; -- Bug 3553286
12540 	--
12541   END IF;
12542   --
12543   IF (p_location_id=hr_api.g_number) THEN
12544     --
12545     l_location_id:=per_asg_shd.g_old_rec.location_id;
12546 	--
12547   ELSE
12548     --
12549     l_location_id:=p_location_id;
12550 	--
12551   END IF;
12552   --
12553   hr_kflex_utility.set_profiles
12554     (p_business_group_id => l_business_group_id
12555     ,p_assignment_id     => p_assignment_id
12556     ,p_organization_id   => l_organization_id
12557     ,p_location_id       => l_location_id);
12558   --
12559   hr_kflex_utility.set_session_date
12560     (p_effective_date => l_effective_date
12561     ,p_session_id     => l_session_id);
12562   --
12563   OPEN csr_grp_idsel;
12564   FETCH csr_grp_idsel INTO l_flex_num;
12565   --
12566   IF csr_grp_idsel%NOTFOUND THEN
12567     --
12568     CLOSE csr_grp_idsel;
12569 	--
12570     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
12571     hr_utility.set_message_token('PROCEDURE', l_proc);
12572     hr_utility.set_message_token('STEP','5');
12573     hr_utility.raise_error;
12574 	--
12575   END IF;
12576   --
12577   CLOSE csr_grp_idsel;
12578   --
12579  if g_debug then
12580   hr_utility.set_location(l_proc, 120);
12581  end if;
12582   --
12583   -- Maintain the people group key flexfields.
12584   --
12585   -- Only call the flex code if a non-default value(includng null) is passed
12586   -- to the procedure.
12587   --
12588   if     nvl(p_segment1,'X')  <> hr_api.g_varchar2
12589       or nvl(p_segment2,'X')  <> hr_api.g_varchar2
12590       or nvl(p_segment3,'X')  <> hr_api.g_varchar2
12591       or nvl(p_segment4,'X')  <> hr_api.g_varchar2
12592       or nvl(p_segment5,'X')  <> hr_api.g_varchar2
12593       or nvl(p_segment6,'X')  <> hr_api.g_varchar2
12594       or nvl(p_segment7,'X')  <> hr_api.g_varchar2
12595       or nvl(p_segment8,'X')  <> hr_api.g_varchar2
12596       or nvl(p_segment9,'X')  <> hr_api.g_varchar2
12597       or nvl(p_segment10,'X') <> hr_api.g_varchar2
12598       or nvl(p_segment11,'X') <> hr_api.g_varchar2
12599       or nvl(p_segment12,'X') <> hr_api.g_varchar2
12600       or nvl(p_segment13,'X') <> hr_api.g_varchar2
12601       or nvl(p_segment14,'X') <> hr_api.g_varchar2
12602       or nvl(p_segment15,'X') <> hr_api.g_varchar2
12603       or nvl(p_segment16,'X') <> hr_api.g_varchar2
12604       or nvl(p_segment17,'X') <> hr_api.g_varchar2
12605       or nvl(p_segment18,'X') <> hr_api.g_varchar2
12606       or nvl(p_segment19,'X') <> hr_api.g_varchar2
12607       or nvl(p_segment20,'X') <> hr_api.g_varchar2
12608       or nvl(p_segment21,'X') <> hr_api.g_varchar2
12609       or nvl(p_segment22,'X') <> hr_api.g_varchar2
12610       or nvl(p_segment23,'X') <> hr_api.g_varchar2
12611       or nvl(p_segment24,'X') <> hr_api.g_varchar2
12612       or nvl(p_segment25,'X') <> hr_api.g_varchar2
12613       or nvl(p_segment26,'X') <> hr_api.g_varchar2
12614       or nvl(p_segment27,'X') <> hr_api.g_varchar2
12615       or nvl(p_segment28,'X') <> hr_api.g_varchar2
12616       or nvl(p_segment29,'X') <> hr_api.g_varchar2
12617       or nvl(p_segment30,'X') <> hr_api.g_varchar2
12618       or nvl(l_old_group_name,'X') <> hr_api.g_varchar2 THEN
12619     --
12620     hr_kflex_utility.upd_or_sel_keyflex_comb
12621     (p_appl_short_name        => 'PAY'
12622     ,p_flex_code              => 'GRP'
12623     ,p_flex_num               => l_flex_num
12624     ,p_segment1               => p_segment1
12625     ,p_segment2               => p_segment2
12626     ,p_segment3               => p_segment3
12627     ,p_segment4               => p_segment4
12628     ,p_segment5               => p_segment5
12629     ,p_segment6               => p_segment6
12630     ,p_segment7               => p_segment7
12631     ,p_segment8               => p_segment8
12632     ,p_segment9               => p_segment9
12633     ,p_segment10              => p_segment10
12634     ,p_segment11              => p_segment11
12635     ,p_segment12              => p_segment12
12636     ,p_segment13              => p_segment13
12637     ,p_segment14              => p_segment14
12638     ,p_segment15              => p_segment15
12639     ,p_segment16              => p_segment16
12640     ,p_segment17              => p_segment17
12641     ,p_segment18              => p_segment18
12642     ,p_segment19              => p_segment19
12643     ,p_segment20              => p_segment20
12644     ,p_segment21              => p_segment21
12645     ,p_segment22              => p_segment22
12646     ,p_segment23              => p_segment23
12647     ,p_segment24              => p_segment24
12648     ,p_segment25              => p_segment25
12649     ,p_segment26              => p_segment26
12650     ,p_segment27              => p_segment27
12651     ,p_segment28              => p_segment28
12652     ,p_segment29              => p_segment29
12653     ,p_segment30              => p_segment30
12654     ,p_concat_segments_in     => l_old_group_name
12655     ,p_ccid                   => l_people_group_id
12656     ,p_concat_segments_out    => l_people_group_name);
12657 	--
12658   END IF;
12659   --
12660  if g_debug then
12661   hr_utility.set_location(l_proc, 130);
12662  end if;
12663   --
12664   -- update the combinations column
12665   --
12666   update_pgp_concat_segs
12667     (p_people_group_id        => l_people_group_id
12668     ,p_group_name             => l_people_group_name);
12669   --
12670   -- Update assignment.
12671   --
12672   per_asg_upd.upd
12673     (p_assignment_id                => p_assignment_id
12674     ,p_effective_start_date         => l_effective_start_date
12675     ,p_effective_end_date           => l_effective_end_date
12676     ,p_business_group_id            => l_business_group_id
12677     -- Bug 3545065, Grade should not be maintained for CWK asg
12678     -- ,p_grade_id                     => p_grade_id
12679     ,p_position_id                  => p_position_id
12680     ,p_job_id                       => l_job_id -- Bug 3553286
12681 	--
12682 	-- Removed until used in a later phase of cwk
12683 	--
12684     --,p_payroll_id                   => p_payroll_id
12685     ,p_location_id                  => p_location_id
12686     ,p_organization_id              => l_org_id -- Bug 3553286
12687     ,p_people_group_id              => l_people_group_id
12688 	--
12689 	-- Removed until used in a later phase of cwk
12690 	--
12691     --,p_pay_basis_id                 => p_pay_basis_id
12692     ,p_comment_id                   => l_comment_id
12693     ,p_payroll_id_updated           => l_payroll_id_updated
12694     ,p_other_manager_warning        => l_other_manager_warning
12695     ,p_no_managers_warning          => l_no_managers_warning
12696     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
12697     ,p_validation_start_date        => l_validation_start_date
12698     ,p_validation_end_date          => l_validation_end_date
12699     ,p_object_version_number        => l_object_version_number
12700     ,p_effective_date               => l_effective_date
12701     ,p_datetrack_mode               => l_dt_update_mode
12702     ,p_validate                     => FALSE
12703     ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
12704   --
12705  if g_debug then
12706   hr_utility.set_location(l_proc, 140);
12707  end if;
12708   --
12709   -- add to the security lists if neccesary
12710   --
12711   OPEN get_sec_date_range;
12712   FETCH get_sec_date_range INTO l_sec_effective_start_date
12713                                ,l_sec_effective_end_date;
12714   CLOSE get_sec_date_range;
12715   --
12716   IF l_effective_date BETWEEN l_sec_effective_start_date AND
12717                               l_sec_effective_end_date THEN
12718     --
12719     IF (per_asg_shd.g_old_rec.organization_id = l_business_group_id AND
12720       l_org_id <> l_business_group_id) THEN -- Bug 3553286
12721       --
12722       hr_security_internal.clear_from_person_list
12723                             (per_asg_shd.g_old_rec.person_id);
12724       --
12725     END IF;
12726 	--
12727     hr_security_internal.add_to_person_list(l_effective_date,p_assignment_id);
12728 	--
12729   END IF;
12730   --
12731  if g_debug then
12732   hr_utility.set_location(l_proc, 145);
12733  end if;
12734   --
12735   -- Bug 560185 fix starts
12736   --
12737   -- Delete the SP element entry if there is one when the pay_basis
12738   -- changes
12739   --
12740   --
12741   --Pay Basis functionality is not included in the 1st phase
12742   --of non payrolled worker. As a result this code has been commented
12743   --out, but left in as it is likely to form part of a later phase
12744   --
12745   /*
12746   IF (p_pay_basis_id <> hr_api.g_number or
12747       p_pay_basis_id is null ) and
12748      (nvl(p_pay_basis_id,hr_api.g_number) <>
12749       nvl(per_asg_shd.g_old_rec.pay_basis_id, hr_api.g_number))
12750   then
12751     open csr_get_salary;
12752     fetch csr_get_salary into l_element_entry_id;
12753     if csr_get_salary%found then
12754       close csr_get_salary;
12755       --
12756       hr_entry_api.delete_element_entry
12757         ('DELETE'
12758         ,l_validation_start_date - 1
12759         ,l_element_entry_id);
12760       --
12761       l_entries_changed_warning := 'S';
12762     else
12763        close csr_get_salary;
12764     end if;
12765   end if;
12766   */
12767   --
12768   -- Maintain standard element entries for this assignment.
12769   --
12770   -- Payroll functionality is not included in the 1st phase
12771   -- of non payrolled worker. As a result this code has been commented
12772   -- out, but left in as it is likely to form part of a later phase
12773   --
12774   /*
12775   if p_payroll_id = hr_api.g_number
12776    then
12777      --
12778  if g_debug then
12779      hr_utility.set_location(l_proc, 150);
12780  end if;
12781      --
12782      l_new_payroll_id := per_asg_shd.g_old_rec.payroll_id;
12783   else
12784      --
12785  if g_debug then
12786      hr_utility.set_location(l_proc, 160);
12787  end if;
12788      --
12789      l_new_payroll_id := p_payroll_id;
12790   end if;
12791   --
12792  if g_debug then
12793   hr_utility.set_location(l_proc, 170);
12794  end if;
12795   --
12796   hrentmnt.maintain_entries_asg
12797     (p_assignment_id                => p_assignment_id
12798     ,p_old_payroll_id               => per_asg_shd.g_old_rec.payroll_id
12799     ,p_new_payroll_id               => l_new_payroll_id
12800     ,p_business_group_id            => l_business_group_id
12801     ,p_operation                    => 'ASG_CRITERIA'
12802     ,p_actual_term_date             => null
12803     ,p_last_standard_date           => null
12804     ,p_final_process_date           => null
12805     ,p_dt_mode                      => p_datetrack_update_mode
12806     ,p_validation_start_date        => l_validation_start_date
12807     ,p_validation_end_date          => l_validation_end_date
12808     ,p_entries_changed              => l_entries_changed
12809     );
12810   --
12811   -- Bug 630826 fix ends
12812   --
12813  if g_debug then
12814   hr_utility.set_location(l_proc, 180);
12815  end if;
12816   --
12817   if l_entries_changed_warning <> 'S' then
12818     l_entries_changed_warning := nvl(l_entries_changed, 'N');
12819   end if;
12820   */
12821   --
12822   -- Bug 3545065, Grade should not be maintained for CWK asg
12823   /*
12824   IF (per_asg_shd.g_old_rec.grade_id IS NOT NULL AND
12825       p_grade_id IS NULL) OR
12826 	 (per_asg_shd.g_old_rec.grade_id IS NOT NULL AND
12827 	  p_grade_id IS NOT NULL AND
12828 	  per_asg_shd.g_old_rec.grade_id <> p_grade_id AND
12829 	  p_grade_id <> hr_api.g_number) THEN
12830     --
12831  if g_debug then
12832     hr_utility.set_location(l_proc, 190);
12833  end if;
12834     --
12835     -- Maintain spinal point placements.
12836     --
12837     hr_assignment_internal.maintain_spp_asg
12838       (p_assignment_id                => p_assignment_id
12839       ,p_datetrack_mode               => l_new_dt_update_mode
12840       ,p_validation_start_date        => l_validation_start_date
12841       ,p_validation_end_date          => l_validation_end_date
12842       ,p_grade_id		              => p_grade_id
12843       ,p_spp_delete_warning           => l_spp_delete_warning);
12844     --
12845   ELSE
12846     --
12847  if g_debug then
12848     hr_utility.set_location(l_proc, 200);
12849  end if;
12850     --
12851     -- No SPPs to maintain.
12852     --
12853     l_spp_delete_warning := FALSE;
12854 	--
12855   END IF;
12856   --
12857   */
12858   -- End of bug 3545065
12859   --
12860  if g_debug then
12861   hr_utility.set_location(l_proc, 210);
12862  end if;
12863   --
12864   -- IF GB legislation and payroll has changed, then delete latest balance
12865   -- values,
12866   --
12867   OPEN  csr_get_legislation_code;
12868   FETCH csr_get_legislation_code INTO l_legislation_code;
12869   --
12870   IF csr_get_legislation_code%NOTFOUND THEN
12871     --
12872     CLOSE csr_get_legislation_code;
12873     --
12874  if g_debug then
12875     hr_utility.set_location(l_proc, 220);
12876  end if;
12877     --
12878     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
12879     hr_utility.set_message_token('PROCEDURE', l_proc);
12880     hr_utility.set_message_token('STEP', '215');
12881     hr_utility.raise_error;
12882 	--
12883   END IF;
12884   --
12885   CLOSE csr_get_legislation_code;
12886   --
12887  if g_debug then
12888   hr_utility.set_location(l_proc, 230);
12889  end if;
12890   --
12891   IF  l_legislation_code = 'GB' AND l_payroll_id_updated THEN
12892     --
12893  if g_debug then
12894     hr_utility.set_location(l_proc, 240);
12895  end if;
12896     --
12897     -- Delete latest balance values.
12898     --
12899     py_gb_asg.payroll_transfer
12900       (p_assignment_id => p_assignment_id);
12901     --
12902     -- When GB legislation, and the business group and the payroll has changed,
12903     -- set the Print P45 flag on the assignments extra info flexfield, and set
12904     -- the changed tax district warning out parameter.
12905     -- This functionality will be supported at a later date.
12906     --
12907     l_tax_district_changed_warning := FALSE;
12908 	--
12909   ELSE
12910     --
12911  if g_debug then
12912     hr_utility.set_location(l_proc, 250);
12913  end if;
12914     --
12915     l_tax_district_changed_warning := FALSE;
12916 	--
12917   END IF;
12918   --
12919  if g_debug then
12920   hr_utility.set_location(l_proc, 260);
12921  end if;
12922   --
12923   BEGIN
12924     --
12925     -- Start of API User Hook for the after hook of update_emp_asg_criteria
12926     --
12927     hr_assignment_bko.update_cwk_asg_criteria_a
12928       (p_effective_date               => l_effective_date
12929       ,p_datetrack_update_mode        => l_dt_update_mode
12930       ,p_assignment_id                => p_assignment_id
12931       ,p_object_version_number        => p_object_version_number
12932       ,p_grade_id                     => p_grade_id -- Bug 3545065
12933       ,p_position_id                  => p_position_id
12934       ,p_job_id                       => l_job_id -- Bug 3553286
12935       --,p_payroll_id                   => p_payroll_id
12936       ,p_location_id                  => p_location_id
12937       ,p_organization_id              => l_org_id -- Bug 3553286
12938       ,p_pay_basis_id                 => p_pay_basis_id
12939       ,p_segment1                     => p_segment1
12940       ,p_segment2                     => p_segment2
12941       ,p_segment3                     => p_segment3
12942       ,p_segment4                     => p_segment4
12943       ,p_segment5                     => p_segment5
12944       ,p_segment6                     => p_segment6
12945       ,p_segment7                     => p_segment7
12946       ,p_segment8                     => p_segment8
12947       ,p_segment9                     => p_segment9
12948       ,p_segment10                    => p_segment10
12949       ,p_segment11                    => p_segment11
12950       ,p_segment12                    => p_segment12
12951       ,p_segment13                    => p_segment13
12952       ,p_segment14                    => p_segment14
12953       ,p_segment15                    => p_segment15
12954       ,p_segment16                    => p_segment16
12955       ,p_segment17                    => p_segment17
12956       ,p_segment18                    => p_segment18
12957       ,p_segment19                    => p_segment19
12958       ,p_segment20                    => p_segment20
12959       ,p_segment21                    => p_segment21
12960       ,p_segment22                    => p_segment22
12961       ,p_segment23                    => p_segment23
12962       ,p_segment24                    => p_segment24
12963       ,p_segment25                    => p_segment25
12964       ,p_segment26                    => p_segment26
12965       ,p_segment27                    => p_segment27
12966       ,p_segment28                    => p_segment28
12967       ,p_segment29                    => p_segment29
12968       ,p_segment30                    => p_segment30
12969       ,p_people_group_name            => l_people_group_name
12970       ,p_effective_start_date         => l_effective_start_date
12971       ,p_effective_end_date           => l_effective_end_date
12972       ,p_people_group_id              => l_people_group_id
12973       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
12974       ,p_other_manager_warning        => l_other_manager_warning
12975       ,p_spp_delete_warning           => l_spp_delete_warning
12976       ,p_entries_changed_warning      => l_entries_changed_warning
12977       ,p_tax_district_changed_warning => l_tax_district_changed_warning
12978       ,p_concat_segments              => l_old_group_name);
12979     --
12980   EXCEPTION
12981     --
12982     WHEN hr_api.cannot_find_prog_unit THEN
12983 	  --
12984       hr_api.cannot_find_prog_unit_error
12985         (p_module_name => 'UPDATE_CWK_ASG_CRITERIA'
12986         ,p_hook_type   => 'AP');
12987       --
12988       -- End of API User Hook for the after hook of update_emp_asg_criteria
12989       --
12990   END;
12991   --
12992   -- When in validation only mode raise the Validate_Enabled exception
12993   --
12994   IF p_validate THEN
12995     --
12996     RAISE hr_api.validate_enabled;
12997 	--
12998   END IF;
12999   --
13000   -- Set all output arguments
13001   --
13002   p_effective_end_date           := l_effective_end_date;
13003   p_effective_start_date         := l_effective_start_date;
13004   p_people_group_id              := l_people_group_id;
13005   p_people_group_name            := l_people_group_name;
13006   p_entries_changed_warning      := l_entries_changed_warning;
13007   p_object_version_number        := l_object_version_number;
13008   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
13009   p_other_manager_warning        := l_other_manager_warning;
13010   p_spp_delete_warning           := l_spp_delete_warning;
13011   p_tax_district_changed_warning := l_tax_district_changed_warning;
13012   --
13013   --
13014   -- remove data from the session table
13015   --
13016   hr_kflex_utility.unset_session_date
13017     (p_session_id     => l_session_id);
13018   --
13019  if g_debug then
13020   hr_utility.set_location(' Leaving:'||l_proc, 999);
13021  end if;
13022   --
13023 EXCEPTION
13024   --
13025   WHEN hr_api.validate_enabled THEN
13026     --
13027     -- As the Validate_Enabled exception has been raised
13028     -- we must rollback to the savepoint
13029     --
13030     ROLLBACK TO update_cwk_asg_criteria;
13031     --
13032     -- Only set output warning arguments
13033     -- (Any key or derived arguments must be set to null
13034     -- when validation only mode is being used.)
13035     --
13036     p_effective_end_date           := NULL;
13037     p_effective_start_date         := NULL;
13038     p_entries_changed_warning      := l_entries_changed_warning;
13039     p_people_group_name                   := l_old_group_name;
13040     p_object_version_number        := p_object_version_number;
13041     p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
13042     p_other_manager_warning        := l_other_manager_warning;
13043     p_people_group_id              := NULL;
13044     p_spp_delete_warning           := l_spp_delete_warning;
13045     p_tax_district_changed_warning := l_tax_district_changed_warning;
13046     --
13047   WHEN others THEN
13048     --
13049     -- A validation or unexpected error has occurred
13050     --
13051     -- Added as part of fix to bug 632479
13052     --
13053     p_object_version_number := lv_object_version_number;
13054 
13055     ROLLBACK TO update_cwk_asg_criteria;
13056     RAISE;
13057     --
13058     -- End of fix.
13059     --
13060 END update_cwk_asg_criteria;
13061 --
13062 --
13063 -- ----------------------------------------------------------------------------
13064 -- |--------------------------< update_gb_emp_asg >---------------------------|
13065 -- ----------------------------------------------------------------------------
13066 --
13067 procedure update_gb_emp_asg
13068   (p_validate                     in     boolean
13069   ,p_effective_date               in     date
13070   ,p_datetrack_update_mode        in     varchar2
13071   ,p_assignment_id                in     number
13072   ,p_object_version_number        in out nocopy number
13073   ,p_supervisor_id                in     number
13074   ,p_assignment_number            in     varchar2
13075   ,p_change_reason                in     varchar2
13076   ,p_comments                     in     varchar2
13077   ,p_date_probation_end           in     date
13078   ,p_default_code_comb_id         in     number
13079   ,p_frequency                    in     varchar2
13080   ,p_internal_address_line        in     varchar2
13081   ,p_manager_flag                 in     varchar2
13082   ,p_normal_hours                 in     number
13083   ,p_perf_review_period           in     number
13084   ,p_perf_review_period_frequency in     varchar2
13085   ,p_probation_period             in     number
13086   ,p_probation_unit               in     varchar2
13087   ,p_sal_review_period            in     number
13088   ,p_sal_review_period_frequency  in     varchar2
13089   ,p_set_of_books_id              in     number
13090   ,p_source_type                  in     varchar2
13091   ,p_time_normal_finish           in     varchar2
13092   ,p_time_normal_start            in     varchar2
13093   ,p_bargaining_unit_code         in     varchar2
13094   ,p_labour_union_member_flag     in     varchar2
13095   ,p_hourly_salaried_code         in     varchar2
13096   ,p_ass_attribute_category       in     varchar2
13097   ,p_ass_attribute1               in     varchar2
13098   ,p_ass_attribute2               in     varchar2
13099   ,p_ass_attribute3               in     varchar2
13100   ,p_ass_attribute4               in     varchar2
13101   ,p_ass_attribute5               in     varchar2
13102   ,p_ass_attribute6               in     varchar2
13103   ,p_ass_attribute7               in     varchar2
13104   ,p_ass_attribute8               in     varchar2
13105   ,p_ass_attribute9               in     varchar2
13106   ,p_ass_attribute10              in     varchar2
13107   ,p_ass_attribute11              in     varchar2
13108   ,p_ass_attribute12              in     varchar2
13109   ,p_ass_attribute13              in     varchar2
13110   ,p_ass_attribute14              in     varchar2
13111   ,p_ass_attribute15              in     varchar2
13112   ,p_ass_attribute16              in     varchar2
13113   ,p_ass_attribute17              in     varchar2
13114   ,p_ass_attribute18              in     varchar2
13115   ,p_ass_attribute19              in     varchar2
13116   ,p_ass_attribute20              in     varchar2
13117   ,p_ass_attribute21              in     varchar2
13118   ,p_ass_attribute22              in     varchar2
13119   ,p_ass_attribute23              in     varchar2
13120   ,p_ass_attribute24              in     varchar2
13121   ,p_ass_attribute25              in     varchar2
13122   ,p_ass_attribute26              in     varchar2
13123   ,p_ass_attribute27              in     varchar2
13124   ,p_ass_attribute28              in     varchar2
13125   ,p_ass_attribute29              in     varchar2
13126   ,p_ass_attribute30              in     varchar2
13127   ,p_title                        in     varchar2
13128   ,p_supervisor_assignment_id     in     number
13129   ,p_comment_id                      out nocopy number
13130   ,p_effective_start_date            out nocopy date
13131   ,p_effective_end_date              out nocopy date
13132   ,p_no_managers_warning             out nocopy boolean
13133   ,p_other_manager_warning           out nocopy boolean
13134   ) is
13135   --
13136   -- Declare cursors and local variables
13137   --
13138   l_proc                       varchar2(72);
13139   l_effective_date             date;
13140   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
13141   l_concatenated_segments      varchar2(2000);
13142   l_legislation_code           per_business_groups.legislation_code%TYPE;
13143   l_cagr_concatenated_segments varchar2(300);
13144   l_cagr_grade_def_id	       number;
13145   --
13146   --
13147 begin
13148  if g_debug then
13149   l_proc := g_package||'update_gb_emp_asg';
13150   hr_utility.set_location('Entering:'|| l_proc, 10);
13151  end if;
13152   --
13153   -- Call the overloaded procedure
13154   --
13155   hr_assignment_api.update_gb_emp_asg
13156     (p_validate                     => p_validate
13157     ,p_effective_date               => p_effective_date
13158     ,p_datetrack_update_mode        => p_datetrack_update_mode
13159     ,p_assignment_id                => p_assignment_id
13160     ,p_object_version_number        => p_object_version_number
13161     ,p_supervisor_id                => p_supervisor_id
13162     ,p_assignment_number            => p_assignment_number
13163     ,p_change_reason                => p_change_reason
13164     ,p_comments                     => p_comments
13165     ,p_date_probation_end           => p_date_probation_end
13166     ,p_default_code_comb_id         => p_default_code_comb_id
13167     ,p_frequency                    => p_frequency
13168     ,p_internal_address_line        => p_internal_address_line
13169     ,p_manager_flag                 => p_manager_flag
13170     ,p_normal_hours                 => p_normal_hours
13171     ,p_perf_review_period           => p_perf_review_period
13172     ,p_perf_review_period_frequency => p_perf_review_period_frequency
13173     ,p_probation_period             => p_probation_period
13174     ,p_probation_unit               => p_probation_unit
13175     ,p_sal_review_period            => p_sal_review_period
13176     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
13177     ,p_set_of_books_id              => p_set_of_books_id
13178     ,p_source_type                  => p_source_type
13179     ,p_time_normal_finish           => p_time_normal_finish
13180     ,p_time_normal_start            => p_time_normal_start
13181     ,p_bargaining_unit_code         => p_bargaining_unit_code
13182     ,p_labour_union_member_flag     => p_labour_union_member_flag
13183     ,p_hourly_salaried_code         => p_hourly_salaried_code
13184     ,p_ass_attribute_category       => p_ass_attribute_category
13185     ,p_ass_attribute1               => p_ass_attribute1
13186     ,p_ass_attribute2               => p_ass_attribute2
13187     ,p_ass_attribute3               => p_ass_attribute3
13188     ,p_ass_attribute4               => p_ass_attribute4
13189     ,p_ass_attribute5               => p_ass_attribute5
13190     ,p_ass_attribute6               => p_ass_attribute6
13191     ,p_ass_attribute7               => p_ass_attribute7
13192     ,p_ass_attribute8               => p_ass_attribute8
13193     ,p_ass_attribute9               => p_ass_attribute9
13194     ,p_ass_attribute10              => p_ass_attribute10
13195     ,p_ass_attribute11              => p_ass_attribute11
13196     ,p_ass_attribute12              => p_ass_attribute12
13197     ,p_ass_attribute13              => p_ass_attribute13
13198     ,p_ass_attribute14              => p_ass_attribute14
13199     ,p_ass_attribute15              => p_ass_attribute15
13200     ,p_ass_attribute16              => p_ass_attribute16
13201     ,p_ass_attribute17              => p_ass_attribute17
13202     ,p_ass_attribute18              => p_ass_attribute18
13203     ,p_ass_attribute19              => p_ass_attribute19
13204     ,p_ass_attribute20              => p_ass_attribute20
13205     ,p_ass_attribute21              => p_ass_attribute21
13206     ,p_ass_attribute22              => p_ass_attribute22
13207     ,p_ass_attribute23              => p_ass_attribute23
13208     ,p_ass_attribute24              => p_ass_attribute24
13209     ,p_ass_attribute25              => p_ass_attribute25
13210     ,p_ass_attribute26              => p_ass_attribute26
13211     ,p_ass_attribute27              => p_ass_attribute27
13212     ,p_ass_attribute28              => p_ass_attribute28
13213     ,p_ass_attribute29              => p_ass_attribute29
13214     ,p_ass_attribute30              => p_ass_attribute30
13215     ,p_title                        => p_title
13216     ,p_cagr_grade_def_id 	    => l_cagr_grade_def_id
13217     ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
13218     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
13219     ,p_comment_id                   => p_comment_id
13220     ,p_effective_start_date         => p_effective_start_date
13221     ,p_effective_end_date           => p_effective_end_date
13222     ,p_concatenated_segments        => l_concatenated_segments
13223     ,p_no_managers_warning          => p_no_managers_warning
13224     ,p_other_manager_warning        => p_other_manager_warning
13225     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
13226     );
13227  if g_debug then
13228   hr_utility.set_location(' Leaving:'||l_proc, 20);
13229  end if;
13230 end update_gb_emp_asg;
13231 --
13232 -- ----------------------------------------------------------------------------
13233 -- |--------------------------< update_gb_emp_asg >------ OVERLOADED ---------|
13234 -- ----------------------------------------------------------------------------
13235 --
13236 -- added new parameters notice_period, units, employee_category,
13237 -- work_at_home and job_source on 05-OCT-01
13238 
13239 procedure update_gb_emp_asg
13240   (p_validate                     in     boolean
13241   ,p_effective_date               in     date
13242   ,p_datetrack_update_mode        in     varchar2
13243   ,p_assignment_id                in     number
13244   ,p_object_version_number        in out nocopy number
13245   ,p_supervisor_id                in     number
13246   ,p_assignment_number            in     varchar2
13247   ,p_change_reason                in     varchar2
13248   ,p_comments                     in     varchar2
13249   ,p_date_probation_end           in     date
13250   ,p_default_code_comb_id         in     number
13251   ,p_frequency                    in     varchar2
13252   ,p_internal_address_line        in     varchar2
13253   ,p_manager_flag                 in     varchar2
13254   ,p_normal_hours                 in     number
13255   ,p_perf_review_period           in     number
13256   ,p_perf_review_period_frequency in     varchar2
13257   ,p_probation_period             in     number
13258   ,p_probation_unit               in     varchar2
13259   ,p_sal_review_period            in     number
13260   ,p_sal_review_period_frequency  in     varchar2
13261   ,p_set_of_books_id              in     number
13262   ,p_source_type                  in     varchar2
13263   ,p_time_normal_finish           in     varchar2
13264   ,p_time_normal_start            in     varchar2
13265   ,p_bargaining_unit_code         in     varchar2
13266   ,p_labour_union_member_flag     in     varchar2
13267   ,p_hourly_salaried_code         in     varchar2
13268   ,p_ass_attribute_category       in     varchar2
13269   ,p_ass_attribute1               in     varchar2
13270   ,p_ass_attribute2               in     varchar2
13271   ,p_ass_attribute3               in     varchar2
13272   ,p_ass_attribute4               in     varchar2
13273   ,p_ass_attribute5               in     varchar2
13274   ,p_ass_attribute6               in     varchar2
13275   ,p_ass_attribute7               in     varchar2
13276   ,p_ass_attribute8               in     varchar2
13277   ,p_ass_attribute9               in     varchar2
13278   ,p_ass_attribute10              in     varchar2
13279   ,p_ass_attribute11              in     varchar2
13280   ,p_ass_attribute12              in     varchar2
13281   ,p_ass_attribute13              in     varchar2
13282   ,p_ass_attribute14              in     varchar2
13283   ,p_ass_attribute15              in     varchar2
13284   ,p_ass_attribute16              in     varchar2
13285   ,p_ass_attribute17              in     varchar2
13286   ,p_ass_attribute18              in     varchar2
13287   ,p_ass_attribute19              in     varchar2
13288   ,p_ass_attribute20              in     varchar2
13289   ,p_ass_attribute21              in     varchar2
13290   ,p_ass_attribute22              in     varchar2
13291   ,p_ass_attribute23              in     varchar2
13292   ,p_ass_attribute24              in     varchar2
13293   ,p_ass_attribute25              in     varchar2
13294   ,p_ass_attribute26              in     varchar2
13295   ,p_ass_attribute27              in     varchar2
13296   ,p_ass_attribute28              in     varchar2
13297   ,p_ass_attribute29              in     varchar2
13298   ,p_ass_attribute30              in     varchar2
13299   ,p_title                        in     varchar2
13300   ,p_contract_id                  in     number
13301   ,p_establishment_id             in     number
13302   ,p_collective_agreement_id      in     number
13303   ,p_cagr_id_flex_num             in     number
13304   ,p_notice_period		  in     number
13305   ,p_notice_period_uom	      	  in     varchar2
13306   ,p_employee_category	          in     varchar2
13307   ,p_work_at_home		  in     varchar2
13308   ,p_job_post_source_name	  in     varchar2
13309   ,p_supervisor_assignment_id     in     number
13310   ,p_cagr_grade_def_id               out nocopy number
13311   ,p_cagr_concatenated_segments      out nocopy varchar2
13312   ,p_concatenated_segments           out nocopy varchar2
13313   ,p_soft_coding_keyflex_id          out nocopy number
13314   ,p_comment_id                      out nocopy number
13315   ,p_effective_start_date            out nocopy date
13316   ,p_effective_end_date              out nocopy date
13317   ,p_no_managers_warning             out nocopy boolean
13318   ,p_other_manager_warning           out nocopy boolean
13319   ) is
13320   --
13321   -- Declare cursors and local variables
13322   --
13323   l_proc                       varchar2(72);
13324   l_effective_date             date;
13325   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
13326   l_concatenated_segments      varchar2(2000);
13327   l_legislation_code           per_business_groups.legislation_code%TYPE;
13328   --
13329   cursor check_legislation
13330     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
13331      c_effective_date date
13332     )
13333   is
13334     select bgp.legislation_code
13335     from per_all_assignments_f asg,
13336          per_business_groups_perf bgp
13337     where asg.business_group_id = bgp.business_group_id
13338     and   asg.assignment_id     = c_assignment_id
13339     and   c_effective_date
13340       between effective_start_date and effective_end_date;
13341   --
13342 begin
13343  if g_debug then
13344   l_proc := g_package||'update_gb_emp_asg';
13345   hr_utility.set_location('Entering:'|| l_proc, 10);
13346  end if;
13347   --
13348   -- Truncate date variables
13349   --
13350   l_effective_date := trunc(p_effective_date);
13351   --
13352   -- Validate in addition to Table Handlers
13353   --
13354   -- Check that the assignment exists.
13355   --
13356   open check_legislation(p_assignment_id, l_effective_date);
13357   fetch check_legislation into l_legislation_code;
13358   if check_legislation%notfound then
13359     close check_legislation;
13360     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
13361     hr_utility.raise_error;
13362   end if;
13363   close check_legislation;
13364  if g_debug then
13365   hr_utility.set_location(l_proc, 20);
13366  end if;
13367   --
13368   -- Check that the legislation of the specified business group is 'GB'.
13369   --
13370   if l_legislation_code <> 'GB' then
13371     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
13372     hr_utility.set_message_token('LEG_CODE','GB');
13373     hr_utility.raise_error;
13374   end if;
13375  if g_debug then
13376   hr_utility.set_location(l_proc, 30);
13377  end if;
13378   --
13379   -- Call update_emp_asg business process
13380   --
13381   hr_assignment_api.update_emp_asg
13382     (p_validate                     => p_validate
13383     ,p_effective_date               => p_effective_date
13384     ,p_datetrack_update_mode        => p_datetrack_update_mode
13385     ,p_assignment_id                => p_assignment_id
13386     ,p_object_version_number        => p_object_version_number
13387     ,p_supervisor_id                => p_supervisor_id
13388     ,p_assignment_number            => p_assignment_number
13389     ,p_change_reason                => p_change_reason
13390     ,p_comments                     => p_comments
13391     ,p_date_probation_end           => p_date_probation_end
13392     ,p_default_code_comb_id         => p_default_code_comb_id
13393     ,p_frequency                    => p_frequency
13394     ,p_internal_address_line        => p_internal_address_line
13395     ,p_manager_flag                 => p_manager_flag
13396     ,p_normal_hours                 => p_normal_hours
13397     ,p_perf_review_period           => p_perf_review_period
13398     ,p_perf_review_period_frequency => p_perf_review_period_frequency
13399     ,p_probation_period             => p_probation_period
13400     ,p_probation_unit               => p_probation_unit
13401     ,p_sal_review_period            => p_sal_review_period
13402     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
13403     ,p_set_of_books_id              => p_set_of_books_id
13404     ,p_source_type                  => p_source_type
13405     ,p_time_normal_finish           => p_time_normal_finish
13406     ,p_time_normal_start            => p_time_normal_start
13407     ,p_bargaining_unit_code         => p_bargaining_unit_code
13408     ,p_labour_union_member_flag     => p_labour_union_member_flag
13409     ,p_hourly_salaried_code         => p_hourly_salaried_code
13410     ,p_ass_attribute_category       => p_ass_attribute_category
13411     ,p_ass_attribute1               => p_ass_attribute1
13412     ,p_ass_attribute2               => p_ass_attribute2
13413     ,p_ass_attribute3               => p_ass_attribute3
13414     ,p_ass_attribute4               => p_ass_attribute4
13415     ,p_ass_attribute5               => p_ass_attribute5
13416     ,p_ass_attribute6               => p_ass_attribute6
13417     ,p_ass_attribute7               => p_ass_attribute7
13418     ,p_ass_attribute8               => p_ass_attribute8
13419     ,p_ass_attribute9               => p_ass_attribute9
13420     ,p_ass_attribute10              => p_ass_attribute10
13421     ,p_ass_attribute11              => p_ass_attribute11
13422     ,p_ass_attribute12              => p_ass_attribute12
13423     ,p_ass_attribute13              => p_ass_attribute13
13424     ,p_ass_attribute14              => p_ass_attribute14
13425     ,p_ass_attribute15              => p_ass_attribute15
13426     ,p_ass_attribute16              => p_ass_attribute16
13427     ,p_ass_attribute17              => p_ass_attribute17
13428     ,p_ass_attribute18              => p_ass_attribute18
13429     ,p_ass_attribute19              => p_ass_attribute19
13430     ,p_ass_attribute20              => p_ass_attribute20
13431     ,p_ass_attribute21              => p_ass_attribute21
13432     ,p_ass_attribute22              => p_ass_attribute22
13433     ,p_ass_attribute23              => p_ass_attribute23
13434     ,p_ass_attribute24              => p_ass_attribute24
13435     ,p_ass_attribute25              => p_ass_attribute25
13436     ,p_ass_attribute26              => p_ass_attribute26
13437     ,p_ass_attribute27              => p_ass_attribute27
13438     ,p_ass_attribute28              => p_ass_attribute28
13439     ,p_ass_attribute29              => p_ass_attribute29
13440     ,p_ass_attribute30              => p_ass_attribute30
13441     ,p_notice_period		    => p_notice_period
13442     ,p_notice_period_uom	    => p_notice_period_uom
13443     ,p_employee_category	    => p_employee_category
13444     ,p_work_at_home		    => p_work_at_home
13445     ,p_job_post_source_name	    => p_job_post_source_name
13446     ,p_title                        => p_title
13447     ,p_contract_id		    => p_contract_id
13448     ,p_establishment_id		    => p_establishment_id
13449     ,p_collective_agreement_id	    => p_collective_agreement_id
13450     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
13451     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
13452     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
13453     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
13454     ,p_comment_id                   => p_comment_id
13455     ,p_effective_start_date         => p_effective_start_date
13456     ,p_effective_end_date           => p_effective_end_date
13457     ,p_concatenated_segments        => l_concatenated_segments
13458     ,p_no_managers_warning          => p_no_managers_warning
13459     ,p_other_manager_warning        => p_other_manager_warning
13460     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
13461     );
13462  if g_debug then
13463   hr_utility.set_location(' Leaving:'||l_proc, 40);
13464  end if;
13465 end update_gb_emp_asg;
13466 
13467 --
13468 -- ----------------------------------------------------------------------------
13469 -- |--------------------------< update_gb_emp_asg >------ OVERLOADED ---------|
13470 -- ----------------------------------------------------------------------------
13471 --
13472 -- added new OUT parameter p_hourly_salaried_warning
13473 
13474 
13475 procedure update_gb_emp_asg
13476   (p_validate                     in     boolean
13477   ,p_effective_date               in     date
13478   ,p_datetrack_update_mode        in     varchar2
13479   ,p_assignment_id                in     number
13480   ,p_object_version_number        in out nocopy number
13481   ,p_supervisor_id                in     number
13482   ,p_assignment_number            in     varchar2
13483   ,p_change_reason                in     varchar2
13484   ,p_comments                     in     varchar2
13485   ,p_date_probation_end           in     date
13486   ,p_default_code_comb_id         in     number
13487   ,p_frequency                    in     varchar2
13488   ,p_internal_address_line        in     varchar2
13489   ,p_manager_flag                 in     varchar2
13490   ,p_normal_hours                 in     number
13491   ,p_perf_review_period           in     number
13492   ,p_perf_review_period_frequency in     varchar2
13493   ,p_probation_period             in     number
13494   ,p_probation_unit               in     varchar2
13495   ,p_sal_review_period            in     number
13496   ,p_sal_review_period_frequency  in     varchar2
13497   ,p_set_of_books_id              in     number
13498   ,p_source_type                  in     varchar2
13499   ,p_time_normal_finish           in     varchar2
13500   ,p_time_normal_start            in     varchar2
13501   ,p_bargaining_unit_code         in     varchar2
13502   ,p_labour_union_member_flag     in     varchar2
13503   ,p_hourly_salaried_code         in     varchar2
13504   ,p_ass_attribute_category       in     varchar2
13505   ,p_ass_attribute1               in     varchar2
13506   ,p_ass_attribute2               in     varchar2
13507   ,p_ass_attribute3               in     varchar2
13508   ,p_ass_attribute4               in     varchar2
13509   ,p_ass_attribute5               in     varchar2
13510   ,p_ass_attribute6               in     varchar2
13511   ,p_ass_attribute7               in     varchar2
13512   ,p_ass_attribute8               in     varchar2
13513   ,p_ass_attribute9               in     varchar2
13514   ,p_ass_attribute10              in     varchar2
13515   ,p_ass_attribute11              in     varchar2
13516   ,p_ass_attribute12              in     varchar2
13517   ,p_ass_attribute13              in     varchar2
13518   ,p_ass_attribute14              in     varchar2
13519   ,p_ass_attribute15              in     varchar2
13520   ,p_ass_attribute16              in     varchar2
13521   ,p_ass_attribute17              in     varchar2
13522   ,p_ass_attribute18              in     varchar2
13523   ,p_ass_attribute19              in     varchar2
13524   ,p_ass_attribute20              in     varchar2
13525   ,p_ass_attribute21              in     varchar2
13526   ,p_ass_attribute22              in     varchar2
13527   ,p_ass_attribute23              in     varchar2
13528   ,p_ass_attribute24              in     varchar2
13529   ,p_ass_attribute25              in     varchar2
13530   ,p_ass_attribute26              in     varchar2
13531   ,p_ass_attribute27              in     varchar2
13532   ,p_ass_attribute28              in     varchar2
13533   ,p_ass_attribute29              in     varchar2
13534   ,p_ass_attribute30              in     varchar2
13535   ,p_title                        in     varchar2
13536   ,p_contract_id                  in     number
13537   ,p_establishment_id             in     number
13538   ,p_collective_agreement_id      in     number
13539   ,p_cagr_id_flex_num             in     number
13540   ,p_notice_period		  in     number
13541   ,p_notice_period_uom	      	  in     varchar2
13542   ,p_employee_category	          in     varchar2
13543   ,p_work_at_home		  in     varchar2
13544   ,p_job_post_source_name	  in     varchar2
13545   ,p_supervisor_assignment_id     in     number
13546   ,p_cagr_grade_def_id               out nocopy number
13547   ,p_cagr_concatenated_segments      out nocopy varchar2
13548   ,p_concatenated_segments           out nocopy varchar2
13549   ,p_soft_coding_keyflex_id          out nocopy number
13550   ,p_comment_id                      out nocopy number
13551   ,p_effective_start_date            out nocopy date
13552   ,p_effective_end_date              out nocopy date
13553   ,p_no_managers_warning             out nocopy boolean
13554   ,p_other_manager_warning           out nocopy boolean
13555   ,p_hourly_salaried_warning         out nocopy boolean
13556   ) is
13557   --
13558   -- Declare cursors and local variables
13559   --
13560   l_proc                       varchar2(72);
13561   l_effective_date             date;
13562   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE;
13563   l_concatenated_segments      varchar2(2000);
13564   l_legislation_code           per_business_groups.legislation_code%TYPE;
13565   --
13566   cursor check_legislation
13567     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
13568      c_effective_date date
13569     )
13570   is
13571     select bgp.legislation_code
13572     from per_all_assignments_f asg,
13573          per_business_groups_perf bgp
13574     where asg.business_group_id = bgp.business_group_id
13575     and   asg.assignment_id     = c_assignment_id
13576     and   c_effective_date
13577       between effective_start_date and effective_end_date;
13578   --
13579 begin
13580  if g_debug then
13581   l_proc := g_package||'update_gb_emp_asg';
13582   hr_utility.set_location('Entering:'|| l_proc, 10);
13583  end if;
13584   --
13585   -- Truncate date variables
13586   --
13587   l_effective_date := trunc(p_effective_date);
13588   --
13589   -- Validate in addition to Table Handlers
13590   --
13591   -- Check that the assignment exists.
13592   --
13593   open check_legislation(p_assignment_id, l_effective_date);
13594   fetch check_legislation into l_legislation_code;
13595   if check_legislation%notfound then
13596     close check_legislation;
13597     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
13598     hr_utility.raise_error;
13599   end if;
13600   close check_legislation;
13601  if g_debug then
13602   hr_utility.set_location(l_proc, 20);
13603  end if;
13604   --
13605   -- Check that the legislation of the specified business group is 'GB'.
13606   --
13607   if l_legislation_code <> 'GB' then
13608     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
13609     hr_utility.set_message_token('LEG_CODE','GB');
13610     hr_utility.raise_error;
13611   end if;
13612  if g_debug then
13613   hr_utility.set_location(l_proc, 30);
13614  end if;
13615   --
13616   -- Call update_emp_asg business process
13617   --
13618   hr_assignment_api.update_emp_asg
13619     (p_validate                     => p_validate
13620     ,p_effective_date               => p_effective_date
13621     ,p_datetrack_update_mode        => p_datetrack_update_mode
13622     ,p_assignment_id                => p_assignment_id
13623     ,p_object_version_number        => p_object_version_number
13624     ,p_supervisor_id                => p_supervisor_id
13625     ,p_assignment_number            => p_assignment_number
13626     ,p_change_reason                => p_change_reason
13627     ,p_comments                     => p_comments
13628     ,p_date_probation_end           => p_date_probation_end
13629     ,p_default_code_comb_id         => p_default_code_comb_id
13630     ,p_frequency                    => p_frequency
13631     ,p_internal_address_line        => p_internal_address_line
13632     ,p_manager_flag                 => p_manager_flag
13633     ,p_normal_hours                 => p_normal_hours
13634     ,p_perf_review_period           => p_perf_review_period
13635     ,p_perf_review_period_frequency => p_perf_review_period_frequency
13636     ,p_probation_period             => p_probation_period
13637     ,p_probation_unit               => p_probation_unit
13638     ,p_sal_review_period            => p_sal_review_period
13639     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
13640     ,p_set_of_books_id              => p_set_of_books_id
13641     ,p_source_type                  => p_source_type
13642     ,p_time_normal_finish           => p_time_normal_finish
13643     ,p_time_normal_start            => p_time_normal_start
13644     ,p_bargaining_unit_code         => p_bargaining_unit_code
13645     ,p_labour_union_member_flag     => p_labour_union_member_flag
13646     ,p_hourly_salaried_code         => p_hourly_salaried_code
13647     ,p_ass_attribute_category       => p_ass_attribute_category
13648     ,p_ass_attribute1               => p_ass_attribute1
13649     ,p_ass_attribute2               => p_ass_attribute2
13650     ,p_ass_attribute3               => p_ass_attribute3
13651     ,p_ass_attribute4               => p_ass_attribute4
13652     ,p_ass_attribute5               => p_ass_attribute5
13653     ,p_ass_attribute6               => p_ass_attribute6
13654     ,p_ass_attribute7               => p_ass_attribute7
13655     ,p_ass_attribute8               => p_ass_attribute8
13656     ,p_ass_attribute9               => p_ass_attribute9
13657     ,p_ass_attribute10              => p_ass_attribute10
13658     ,p_ass_attribute11              => p_ass_attribute11
13659     ,p_ass_attribute12              => p_ass_attribute12
13660     ,p_ass_attribute13              => p_ass_attribute13
13661     ,p_ass_attribute14              => p_ass_attribute14
13662     ,p_ass_attribute15              => p_ass_attribute15
13663     ,p_ass_attribute16              => p_ass_attribute16
13664     ,p_ass_attribute17              => p_ass_attribute17
13665     ,p_ass_attribute18              => p_ass_attribute18
13666     ,p_ass_attribute19              => p_ass_attribute19
13667     ,p_ass_attribute20              => p_ass_attribute20
13668     ,p_ass_attribute21              => p_ass_attribute21
13669     ,p_ass_attribute22              => p_ass_attribute22
13670     ,p_ass_attribute23              => p_ass_attribute23
13671     ,p_ass_attribute24              => p_ass_attribute24
13672     ,p_ass_attribute25              => p_ass_attribute25
13673     ,p_ass_attribute26              => p_ass_attribute26
13674     ,p_ass_attribute27              => p_ass_attribute27
13675     ,p_ass_attribute28              => p_ass_attribute28
13676     ,p_ass_attribute29              => p_ass_attribute29
13677     ,p_ass_attribute30              => p_ass_attribute30
13678     ,p_notice_period		    => p_notice_period
13679     ,p_notice_period_uom	    => p_notice_period_uom
13680     ,p_employee_category	    => p_employee_category
13681     ,p_work_at_home		    => p_work_at_home
13682     ,p_job_post_source_name	    => p_job_post_source_name
13683     ,p_title                        => p_title
13684     ,p_contract_id		    => p_contract_id
13685     ,p_establishment_id		    => p_establishment_id
13686     ,p_collective_agreement_id	    => p_collective_agreement_id
13687     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
13688     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
13689     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
13690     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
13691     ,p_comment_id                   => p_comment_id
13692     ,p_effective_start_date         => p_effective_start_date
13693     ,p_effective_end_date           => p_effective_end_date
13694     ,p_concatenated_segments        => l_concatenated_segments
13695     ,p_no_managers_warning          => p_no_managers_warning
13696     ,p_other_manager_warning        => p_other_manager_warning
13697     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
13698     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
13699     );
13700  if g_debug then
13701   hr_utility.set_location(' Leaving:'||l_proc, 40);
13702  end if;
13703 end update_gb_emp_asg;
13704 
13705 -- End of OVERLOADED procedure update_gb_emp_asg
13706 -- ----------------------------------------------------------------------------
13707 -- |--------------------------< update_us_emp_asg -- OLD >--------------------|
13708 -- ----------------------------------------------------------------------------
13709 --
13710 procedure update_us_emp_asg
13711   (p_validate                     in     boolean
13712   ,p_effective_date               in     date
13713   ,p_datetrack_update_mode        in     varchar2
13714   ,p_assignment_id                in     number
13715   ,p_object_version_number        in out nocopy number
13716   ,p_supervisor_id                in     number
13717   ,p_assignment_number            in     varchar2
13718   ,p_change_reason                in     varchar2
13719   ,p_comments                     in     varchar2
13720   ,p_date_probation_end           in     date
13721   ,p_default_code_comb_id         in     number
13722   ,p_frequency                    in     varchar2
13723   ,p_internal_address_line        in     varchar2
13724   ,p_manager_flag                 in     varchar2
13725   ,p_normal_hours                 in     number
13726   ,p_perf_review_period           in     number
13727   ,p_perf_review_period_frequency in     varchar2
13728   ,p_probation_period             in     number
13729   ,p_probation_unit               in     varchar2
13730   ,p_sal_review_period            in     number
13731   ,p_sal_review_period_frequency  in     varchar2
13732   ,p_set_of_books_id              in     number
13733   ,p_source_type                  in     varchar2
13734   ,p_time_normal_finish           in     varchar2
13735   ,p_time_normal_start            in     varchar2
13736   ,p_bargaining_unit_code         in     varchar2
13737   ,p_labour_union_member_flag     in     varchar2
13738   ,p_hourly_salaried_code         in     varchar2
13739   ,p_ass_attribute_category       in     varchar2
13740   ,p_ass_attribute1               in     varchar2
13741   ,p_ass_attribute2               in     varchar2
13742   ,p_ass_attribute3               in     varchar2
13743   ,p_ass_attribute4               in     varchar2
13744   ,p_ass_attribute5               in     varchar2
13745   ,p_ass_attribute6               in     varchar2
13746   ,p_ass_attribute7               in     varchar2
13747   ,p_ass_attribute8               in     varchar2
13748   ,p_ass_attribute9               in     varchar2
13749   ,p_ass_attribute10              in     varchar2
13750   ,p_ass_attribute11              in     varchar2
13751   ,p_ass_attribute12              in     varchar2
13752   ,p_ass_attribute13              in     varchar2
13753   ,p_ass_attribute14              in     varchar2
13754   ,p_ass_attribute15              in     varchar2
13755   ,p_ass_attribute16              in     varchar2
13756   ,p_ass_attribute17              in     varchar2
13757   ,p_ass_attribute18              in     varchar2
13758   ,p_ass_attribute19              in     varchar2
13759   ,p_ass_attribute20              in     varchar2
13760   ,p_ass_attribute21              in     varchar2
13761   ,p_ass_attribute22              in     varchar2
13762   ,p_ass_attribute23              in     varchar2
13763   ,p_ass_attribute24              in     varchar2
13764   ,p_ass_attribute25              in     varchar2
13765   ,p_ass_attribute26              in     varchar2
13766   ,p_ass_attribute27              in     varchar2
13767   ,p_ass_attribute28              in     varchar2
13768   ,p_ass_attribute29              in     varchar2
13769   ,p_ass_attribute30              in     varchar2
13770   ,p_title                        in     varchar2
13771   ,p_tax_unit                     in     varchar2
13772   ,p_timecard_approver            in     varchar2
13773   ,p_timecard_required            in     varchar2
13774   ,p_work_schedule                in     varchar2
13775   ,p_shift                        in     varchar2
13776   ,p_spouse_salary                in     varchar2
13777   ,p_legal_representative         in     varchar2
13778   ,p_wc_override_code             in     varchar2
13779   ,p_eeo_1_establishment          in     varchar2
13780   ,p_supervisor_assignment_id     in     number
13781   ,p_comment_id                      out nocopy number
13782   ,p_soft_coding_keyflex_id          out nocopy number
13783   ,p_effective_start_date            out nocopy date
13784   ,p_effective_end_date              out nocopy date
13785 -- Bug 944911
13786 -- Amended p_concatenated_segments to be out
13787 -- Added p_concat_segments  - in param
13788   ,p_concatenated_segments           out nocopy varchar2
13789   ,p_concat_segments              in     varchar2
13790   ,p_no_managers_warning             out nocopy boolean
13791   ,p_other_manager_warning           out nocopy boolean
13792   )
13793 is
13794   --
13795   -- Declare cursors and local variables
13796   --
13797   l_proc                       varchar2(72);
13798   l_effective_date             date;
13799   l_legislation_code           per_business_groups.legislation_code%TYPE;
13800   l_cagr_grade_def_id	       number;
13801   l_cagr_concatenated_segments number;
13802 
13803   --
13804 begin
13805  if g_debug then
13806   l_proc := g_package||'update_us_emp_asg';
13807   hr_utility.set_location('Entering:'|| l_proc, 10);
13808  end if;
13809   --
13810   -- Call the overloaded procedure update_us_emp_asg
13811   --
13812   hr_assignment_api.update_emp_asg
13813     (p_validate                     => p_validate
13814     ,p_effective_date               => p_effective_date
13815     ,p_datetrack_update_mode        => p_datetrack_update_mode
13816     ,p_assignment_id                => p_assignment_id
13817     ,p_object_version_number        => p_object_version_number
13818     ,p_supervisor_id                => p_supervisor_id
13819     ,p_assignment_number            => p_assignment_number
13820     ,p_change_reason                => p_change_reason
13821     ,p_comments                     => p_comments
13822     ,p_date_probation_end           => p_date_probation_end
13823     ,p_default_code_comb_id         => p_default_code_comb_id
13824     ,p_frequency                    => p_frequency
13825     ,p_internal_address_line        => p_internal_address_line
13826     ,p_manager_flag                 => p_manager_flag
13827     ,p_normal_hours                 => p_normal_hours
13828     ,p_perf_review_period           => p_perf_review_period
13829     ,p_perf_review_period_frequency => p_perf_review_period_frequency
13830     ,p_probation_period             => p_probation_period
13831     ,p_probation_unit               => p_probation_unit
13832     ,p_sal_review_period            => p_sal_review_period
13833     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
13834     ,p_set_of_books_id              => p_set_of_books_id
13835     ,p_source_type                  => p_source_type
13836     ,p_time_normal_finish           => p_time_normal_finish
13837     ,p_time_normal_start            => p_time_normal_start
13838     ,p_bargaining_unit_code         => p_bargaining_unit_code
13839     ,p_labour_union_member_flag     => p_labour_union_member_flag
13840     ,p_hourly_salaried_code         => p_hourly_salaried_code
13841     ,p_ass_attribute_category       => p_ass_attribute_category
13842     ,p_ass_attribute1               => p_ass_attribute1
13843     ,p_ass_attribute2               => p_ass_attribute2
13844     ,p_ass_attribute3               => p_ass_attribute3
13845     ,p_ass_attribute4               => p_ass_attribute4
13846     ,p_ass_attribute5               => p_ass_attribute5
13847     ,p_ass_attribute6               => p_ass_attribute6
13848     ,p_ass_attribute7               => p_ass_attribute7
13849     ,p_ass_attribute8               => p_ass_attribute8
13850     ,p_ass_attribute9               => p_ass_attribute9
13851     ,p_ass_attribute10              => p_ass_attribute10
13852     ,p_ass_attribute11              => p_ass_attribute11
13853     ,p_ass_attribute12              => p_ass_attribute12
13854     ,p_ass_attribute13              => p_ass_attribute13
13855     ,p_ass_attribute14              => p_ass_attribute14
13856     ,p_ass_attribute15              => p_ass_attribute15
13857     ,p_ass_attribute16              => p_ass_attribute16
13858     ,p_ass_attribute17              => p_ass_attribute17
13859     ,p_ass_attribute18              => p_ass_attribute18
13860     ,p_ass_attribute19              => p_ass_attribute19
13861     ,p_ass_attribute20              => p_ass_attribute20
13862     ,p_ass_attribute21              => p_ass_attribute21
13863     ,p_ass_attribute22              => p_ass_attribute22
13864     ,p_ass_attribute23              => p_ass_attribute23
13865     ,p_ass_attribute24              => p_ass_attribute24
13866     ,p_ass_attribute25              => p_ass_attribute25
13867     ,p_ass_attribute26              => p_ass_attribute26
13868     ,p_ass_attribute27              => p_ass_attribute27
13869     ,p_ass_attribute28              => p_ass_attribute28
13870     ,p_ass_attribute29              => p_ass_attribute29
13871     ,p_ass_attribute30              => p_ass_attribute30
13872     ,p_title                        => p_title
13873     ,p_segment1                     => p_tax_unit
13874     ,p_segment2                     => p_timecard_approver
13875     ,p_segment3                     => p_timecard_required
13876     ,p_segment4                     => p_work_schedule
13877     ,p_segment5                     => p_shift
13878     ,p_segment6                     => p_spouse_salary
13879     ,p_segment7                     => p_legal_representative
13880     ,p_segment8                     => p_wc_override_code
13881     ,p_segment9                     => p_eeo_1_establishment
13882     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
13883     ,p_comment_id                   => p_comment_id
13884     ,p_effective_start_date         => p_effective_start_date
13885     ,p_effective_end_date           => p_effective_end_date
13886     -- Bug 1889914
13887     ,p_cagr_grade_def_id	    => l_cagr_grade_def_id
13888     ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
13889 -- Bug 944911
13890 -- Added new param
13891     ,p_concatenated_segments        => p_concatenated_segments
13892     ,p_concat_segments              => p_concat_segments
13893     ,p_no_managers_warning          => p_no_managers_warning
13894     ,p_other_manager_warning        => p_other_manager_warning
13895     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
13896     );
13897  if g_debug then
13898   hr_utility.set_location(' Leaving:'||l_proc, 40);
13899  end if;
13900 end update_us_emp_asg;
13901 --
13902 -- ----------------------------------------------------------------------------
13903 -- |--------------------------< update_us_emp_asg --NEW>----------------------|
13904 -- ----------------------------------------------------------------------------
13905 --
13906 -- added new parameters notice_period, units, employee_category,
13907 -- work_at_home and job_source on 05-OCT-01
13908 
13909 procedure update_us_emp_asg
13910   (p_validate                     in     boolean
13911   ,p_effective_date               in     date
13912   ,p_datetrack_update_mode        in     varchar2
13913   ,p_assignment_id                in     number
13914   ,p_object_version_number        in out nocopy number
13915   ,p_supervisor_id                in     number
13916   ,p_assignment_number            in     varchar2
13917   ,p_change_reason                in     varchar2
13918   ,p_comments                     in     varchar2
13919   ,p_date_probation_end           in     date
13920   ,p_default_code_comb_id         in     number
13921   ,p_frequency                    in     varchar2
13922   ,p_internal_address_line        in     varchar2
13923   ,p_manager_flag                 in     varchar2
13924   ,p_normal_hours                 in     number
13925   ,p_perf_review_period           in     number
13926   ,p_perf_review_period_frequency in     varchar2
13927   ,p_probation_period             in     number
13928   ,p_probation_unit               in     varchar2
13929   ,p_sal_review_period            in     number
13930   ,p_sal_review_period_frequency  in     varchar2
13931   ,p_set_of_books_id              in     number
13932   ,p_source_type                  in     varchar2
13933   ,p_time_normal_finish           in     varchar2
13934   ,p_time_normal_start            in     varchar2
13935   ,p_bargaining_unit_code         in     varchar2
13936   ,p_labour_union_member_flag     in     varchar2
13937   ,p_hourly_salaried_code         in     varchar2
13938   ,p_ass_attribute_category       in     varchar2
13939   ,p_ass_attribute1               in     varchar2
13940   ,p_ass_attribute2               in     varchar2
13941   ,p_ass_attribute3               in     varchar2
13942   ,p_ass_attribute4               in     varchar2
13943   ,p_ass_attribute5               in     varchar2
13944   ,p_ass_attribute6               in     varchar2
13945   ,p_ass_attribute7               in     varchar2
13946   ,p_ass_attribute8               in     varchar2
13947   ,p_ass_attribute9               in     varchar2
13948   ,p_ass_attribute10              in     varchar2
13949   ,p_ass_attribute11              in     varchar2
13950   ,p_ass_attribute12              in     varchar2
13951   ,p_ass_attribute13              in     varchar2
13952   ,p_ass_attribute14              in     varchar2
13953   ,p_ass_attribute15              in     varchar2
13954   ,p_ass_attribute16              in     varchar2
13955   ,p_ass_attribute17              in     varchar2
13956   ,p_ass_attribute18              in     varchar2
13957   ,p_ass_attribute19              in     varchar2
13958   ,p_ass_attribute20              in     varchar2
13959   ,p_ass_attribute21              in     varchar2
13960   ,p_ass_attribute22              in     varchar2
13961   ,p_ass_attribute23              in     varchar2
13962   ,p_ass_attribute24              in     varchar2
13963   ,p_ass_attribute25              in     varchar2
13964   ,p_ass_attribute26              in     varchar2
13965   ,p_ass_attribute27              in     varchar2
13966   ,p_ass_attribute28              in     varchar2
13967   ,p_ass_attribute29              in     varchar2
13968   ,p_ass_attribute30              in     varchar2
13969   ,p_title                        in     varchar2
13970   ,p_tax_unit                     in     varchar2
13971   ,p_timecard_approver            in     varchar2
13972   ,p_timecard_required            in     varchar2
13973   ,p_work_schedule                in     varchar2
13974   ,p_shift                        in     varchar2
13975   ,p_spouse_salary                in     varchar2
13976   ,p_legal_representative         in     varchar2
13977   ,p_wc_override_code             in     varchar2
13978   ,p_eeo_1_establishment          in     varchar2
13979   -- Added for bug 1889914
13980   ,p_contract_id		  in     number
13981   ,p_establishment_id		  in 	 number
13982   ,p_collective_agreement_id	  in     number
13983   ,p_cagr_id_flex_num		  in     number
13984   ,p_notice_period		  in     number
13985   ,p_notice_period_uom	      	  in     varchar2
13986   ,p_employee_category	          in     varchar2
13987   ,p_work_at_home		  in     varchar2
13988   ,p_job_post_source_name	  in     varchar2
13989   ,p_supervisor_assignment_id     in     number
13990   ,p_cagr_grade_def_id		     out nocopy number
13991   ,p_cagr_concatenated_segments      out nocopy varchar2
13992   -- End 1889914
13993   ,p_comment_id                      out nocopy number
13994   ,p_soft_coding_keyflex_id          out nocopy number
13995   ,p_effective_start_date            out nocopy date
13996   ,p_effective_end_date              out nocopy date
13997 -- Bug 944911
13998 -- Amended p_concatenated_segments to be out
13999 -- Added p_concat_segments  - in param
14000   ,p_concatenated_segments           out nocopy varchar2
14001   ,p_concat_segments              in     varchar2
14002   ,p_no_managers_warning             out nocopy boolean
14003   ,p_other_manager_warning           out nocopy boolean
14004   )
14005 is
14006   --
14007   -- Declare cursors and local variables
14008   --
14009   l_proc                       varchar2(72);
14010   l_effective_date             date;
14011   l_legislation_code           per_business_groups.legislation_code%TYPE;
14012 
14013   --
14014   cursor check_legislation
14015     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14016      c_effective_date date
14017     )
14018   is
14019     select bgp.legislation_code
14020     from per_all_assignments_f asg,
14021          per_business_groups_perf bgp
14022     where asg.business_group_id = bgp.business_group_id
14023     and   asg.assignment_id     = c_assignment_id
14024     and   c_effective_date
14025       between effective_start_date and effective_end_date;
14026   --
14027 begin
14028  if g_debug then
14029   l_proc := g_package||'update_us_emp_asg';
14030   hr_utility.set_location('Entering:'|| l_proc, 10);
14031  end if;
14032   --
14033   -- Truncate date variables
14034   --
14035   l_effective_date := trunc(p_effective_date);
14036   --
14037   -- Validate in addition to Table Handlers
14038   --
14039   -- Check that the assignment exists.
14040   --
14041   open check_legislation(p_assignment_id, l_effective_date);
14042   fetch check_legislation into l_legislation_code;
14043   if check_legislation%notfound then
14044     close check_legislation;
14045     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14046     hr_utility.raise_error;
14047   end if;
14048   close check_legislation;
14049  if g_debug then
14050   hr_utility.set_location(l_proc, 20);
14051  end if;
14052   --
14053   -- Check that the legislation of the specified business group is 'US'.
14054   --
14055   if l_legislation_code <> 'US' then
14056     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14057     hr_utility.set_message_token('LEG_CODE','US');
14058     hr_utility.raise_error;
14059   end if;
14060  if g_debug then
14061   hr_utility.set_location(l_proc, 30);
14062  end if;
14063   --
14064   -- Call update_emp_asg business process
14065   --
14066   hr_assignment_api.update_emp_asg
14067     (p_validate                     => p_validate
14068     ,p_effective_date               => p_effective_date
14069     ,p_datetrack_update_mode        => p_datetrack_update_mode
14070     ,p_assignment_id                => p_assignment_id
14071     ,p_object_version_number        => p_object_version_number
14072     ,p_supervisor_id                => p_supervisor_id
14073     ,p_assignment_number            => p_assignment_number
14074     ,p_change_reason                => p_change_reason
14075     ,p_comments                     => p_comments
14076     ,p_date_probation_end           => p_date_probation_end
14077     ,p_default_code_comb_id         => p_default_code_comb_id
14078     ,p_frequency                    => p_frequency
14079     ,p_internal_address_line        => p_internal_address_line
14080     ,p_manager_flag                 => p_manager_flag
14081     ,p_normal_hours                 => p_normal_hours
14082     ,p_perf_review_period           => p_perf_review_period
14083     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14084     ,p_probation_period             => p_probation_period
14085     ,p_probation_unit               => p_probation_unit
14086     ,p_sal_review_period            => p_sal_review_period
14087     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14088     ,p_set_of_books_id              => p_set_of_books_id
14089     ,p_source_type                  => p_source_type
14090     ,p_time_normal_finish           => p_time_normal_finish
14091     ,p_time_normal_start            => p_time_normal_start
14092     ,p_bargaining_unit_code         => p_bargaining_unit_code
14093     ,p_labour_union_member_flag     => p_labour_union_member_flag
14094     ,p_hourly_salaried_code         => p_hourly_salaried_code
14095     ,p_ass_attribute_category       => p_ass_attribute_category
14096     ,p_ass_attribute1               => p_ass_attribute1
14097     ,p_ass_attribute2               => p_ass_attribute2
14098     ,p_ass_attribute3               => p_ass_attribute3
14099     ,p_ass_attribute4               => p_ass_attribute4
14100     ,p_ass_attribute5               => p_ass_attribute5
14101     ,p_ass_attribute6               => p_ass_attribute6
14102     ,p_ass_attribute7               => p_ass_attribute7
14103     ,p_ass_attribute8               => p_ass_attribute8
14104     ,p_ass_attribute9               => p_ass_attribute9
14105     ,p_ass_attribute10              => p_ass_attribute10
14106     ,p_ass_attribute11              => p_ass_attribute11
14107     ,p_ass_attribute12              => p_ass_attribute12
14108     ,p_ass_attribute13              => p_ass_attribute13
14109     ,p_ass_attribute14              => p_ass_attribute14
14110     ,p_ass_attribute15              => p_ass_attribute15
14111     ,p_ass_attribute16              => p_ass_attribute16
14112     ,p_ass_attribute17              => p_ass_attribute17
14113     ,p_ass_attribute18              => p_ass_attribute18
14114     ,p_ass_attribute19              => p_ass_attribute19
14115     ,p_ass_attribute20              => p_ass_attribute20
14116     ,p_ass_attribute21              => p_ass_attribute21
14117     ,p_ass_attribute22              => p_ass_attribute22
14118     ,p_ass_attribute23              => p_ass_attribute23
14119     ,p_ass_attribute24              => p_ass_attribute24
14120     ,p_ass_attribute25              => p_ass_attribute25
14121     ,p_ass_attribute26              => p_ass_attribute26
14122     ,p_ass_attribute27              => p_ass_attribute27
14123     ,p_ass_attribute28              => p_ass_attribute28
14124     ,p_ass_attribute29              => p_ass_attribute29
14125     ,p_ass_attribute30              => p_ass_attribute30
14126     ,p_title                        => p_title
14127     ,p_contract_id		    => p_contract_id
14128     ,p_establishment_id		    => p_establishment_id
14129     ,p_collective_agreement_id	    => p_collective_agreement_id
14130     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14131     ,p_notice_period		    => p_notice_period
14132     ,p_notice_period_uom	    => p_notice_period_uom
14133     ,p_employee_category	    => p_employee_category
14134     ,p_work_at_home		    => p_work_at_home
14135     ,p_job_post_source_name	    => p_job_post_source_name
14136     ,p_segment1                     => p_tax_unit
14137     ,p_segment2                     => p_timecard_approver
14138     ,p_segment3                     => p_timecard_required
14139     ,p_segment4                     => p_work_schedule
14140     ,p_segment5                     => p_shift
14141     ,p_segment6                     => p_spouse_salary
14142     ,p_segment7                     => p_legal_representative
14143     ,p_segment8                     => p_wc_override_code
14144     ,p_segment9                     => p_eeo_1_establishment
14145     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14146     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14147     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
14148     ,p_comment_id                   => p_comment_id
14149     ,p_effective_start_date         => p_effective_start_date
14150     ,p_effective_end_date           => p_effective_end_date
14151 -- Bug 944911
14152 -- Added new param
14153     ,p_concatenated_segments        => p_concatenated_segments
14154     ,p_concat_segments              => p_concat_segments
14155     ,p_no_managers_warning          => p_no_managers_warning
14156     ,p_other_manager_warning        => p_other_manager_warning
14157     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14158     );
14159  if g_debug then
14160   hr_utility.set_location(' Leaving:'||l_proc, 40);
14161  end if;
14162 end update_us_emp_asg;
14163 -- End of update_us_emp_asg OVERLOADED procedure
14164 
14165 --
14166 -- ----------------------------------------------------------------------------
14167 -- |--------------------------< update_us_emp_asg --NEW2 >--------------------|
14168 -- ----------------------------------------------------------------------------
14169 --
14170 -- added new parameters p_hourly_salaried_warning
14171 
14172 
14173 procedure update_us_emp_asg
14174   (p_validate                     in     boolean
14175   ,p_effective_date               in     date
14176   ,p_datetrack_update_mode        in     varchar2
14177   ,p_assignment_id                in     number
14178   ,p_object_version_number        in out nocopy number
14179   ,p_supervisor_id                in     number
14180   ,p_assignment_number            in     varchar2
14181   ,p_change_reason                in     varchar2
14182   ,p_comments                     in     varchar2
14183   ,p_date_probation_end           in     date
14184   ,p_default_code_comb_id         in     number
14185   ,p_frequency                    in     varchar2
14186   ,p_internal_address_line        in     varchar2
14187   ,p_manager_flag                 in     varchar2
14188   ,p_normal_hours                 in     number
14189   ,p_perf_review_period           in     number
14190   ,p_perf_review_period_frequency in     varchar2
14191   ,p_probation_period             in     number
14192   ,p_probation_unit               in     varchar2
14193   ,p_sal_review_period            in     number
14194   ,p_sal_review_period_frequency  in     varchar2
14195   ,p_set_of_books_id              in     number
14196   ,p_source_type                  in     varchar2
14197   ,p_time_normal_finish           in     varchar2
14198   ,p_time_normal_start            in     varchar2
14199   ,p_bargaining_unit_code         in     varchar2
14200   ,p_labour_union_member_flag     in     varchar2
14201   ,p_hourly_salaried_code         in     varchar2
14202   ,p_ass_attribute_category       in     varchar2
14203   ,p_ass_attribute1               in     varchar2
14204   ,p_ass_attribute2               in     varchar2
14205   ,p_ass_attribute3               in     varchar2
14206   ,p_ass_attribute4               in     varchar2
14207   ,p_ass_attribute5               in     varchar2
14208   ,p_ass_attribute6               in     varchar2
14209   ,p_ass_attribute7               in     varchar2
14210   ,p_ass_attribute8               in     varchar2
14211   ,p_ass_attribute9               in     varchar2
14212   ,p_ass_attribute10              in     varchar2
14213   ,p_ass_attribute11              in     varchar2
14214   ,p_ass_attribute12              in     varchar2
14215   ,p_ass_attribute13              in     varchar2
14216   ,p_ass_attribute14              in     varchar2
14217   ,p_ass_attribute15              in     varchar2
14218   ,p_ass_attribute16              in     varchar2
14219   ,p_ass_attribute17              in     varchar2
14220   ,p_ass_attribute18              in     varchar2
14221   ,p_ass_attribute19              in     varchar2
14222   ,p_ass_attribute20              in     varchar2
14223   ,p_ass_attribute21              in     varchar2
14224   ,p_ass_attribute22              in     varchar2
14225   ,p_ass_attribute23              in     varchar2
14226   ,p_ass_attribute24              in     varchar2
14227   ,p_ass_attribute25              in     varchar2
14228   ,p_ass_attribute26              in     varchar2
14229   ,p_ass_attribute27              in     varchar2
14230   ,p_ass_attribute28              in     varchar2
14231   ,p_ass_attribute29              in     varchar2
14232   ,p_ass_attribute30              in     varchar2
14233   ,p_title                        in     varchar2
14234   ,p_tax_unit                     in     varchar2
14235   ,p_timecard_approver            in     varchar2
14236   ,p_timecard_required            in     varchar2
14237   ,p_work_schedule                in     varchar2
14238   ,p_shift                        in     varchar2
14239   ,p_spouse_salary                in     varchar2
14240   ,p_legal_representative         in     varchar2
14241   ,p_wc_override_code             in     varchar2
14242   ,p_eeo_1_establishment          in     varchar2
14243   -- Added for bug 1889914
14244   ,p_contract_id		  in     number
14245   ,p_establishment_id		  in 	 number
14246   ,p_collective_agreement_id	  in     number
14247   ,p_cagr_id_flex_num		  in     number
14248   ,p_notice_period		  in     number
14249   ,p_notice_period_uom	      	  in     varchar2
14250   ,p_employee_category	          in     varchar2
14251   ,p_work_at_home		  in     varchar2
14252   ,p_job_post_source_name	  in     varchar2
14253   ,p_supervisor_assignment_id     in     number
14254   ,p_cagr_grade_def_id		     out nocopy number
14255   ,p_cagr_concatenated_segments      out nocopy varchar2
14256   -- End 1889914
14257   ,p_comment_id                      out nocopy number
14258   ,p_soft_coding_keyflex_id          out nocopy number
14259   ,p_effective_start_date            out nocopy date
14260   ,p_effective_end_date              out nocopy date
14261 -- Bug 944911
14262 -- Amended p_concatenated_segments to be out
14263 -- Added p_concat_segments  - in param
14264   ,p_concatenated_segments           out nocopy varchar2
14265   ,p_concat_segments              in     varchar2
14266   ,p_no_managers_warning             out nocopy boolean
14267   ,p_other_manager_warning           out nocopy boolean
14268   ,p_hourly_salaried_warning         out nocopy boolean
14269   )
14270 is
14271   --
14272   -- Declare cursors and local variables
14273   --
14274   l_proc                       varchar2(72);
14275   l_effective_date             date;
14276   l_legislation_code           per_business_groups.legislation_code%TYPE;
14277   l_gsp_post_process_warning   varchar2(2000); -- bug 2999562
14278 
14279   --
14280   cursor check_legislation
14281     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14282      c_effective_date date
14283     )
14284   is
14285     select bgp.legislation_code
14286     from per_all_assignments_f asg,
14287          per_business_groups_perf bgp
14288     where asg.business_group_id = bgp.business_group_id
14289     and   asg.assignment_id     = c_assignment_id
14290     and   c_effective_date
14291       between effective_start_date and effective_end_date;
14292   --
14293 begin
14294  if g_debug then
14295   l_proc := g_package||'update_us_emp_asg';
14296   hr_utility.set_location('Entering:'|| l_proc, 10);
14297  end if;
14298   --
14299   -- Truncate date variables
14300   --
14301   l_effective_date := trunc(p_effective_date);
14302   --
14303   -- Validate in addition to Table Handlers
14304   --
14305   -- Check that the assignment exists.
14306   --
14307   open check_legislation(p_assignment_id, l_effective_date);
14308   fetch check_legislation into l_legislation_code;
14309   if check_legislation%notfound then
14310     close check_legislation;
14311     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14312     hr_utility.raise_error;
14313   end if;
14314   close check_legislation;
14315  if g_debug then
14316   hr_utility.set_location(l_proc, 20);
14317  end if;
14318   --
14319   -- Check that the legislation of the specified business group is 'US'.
14320   --
14321   if l_legislation_code <> 'US' then
14322     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14323     hr_utility.set_message_token('LEG_CODE','US');
14324     hr_utility.raise_error;
14325   end if;
14326  if g_debug then
14327   hr_utility.set_location(l_proc, 30);
14328  end if;
14329   --
14330   -- Call update_emp_asg business process
14331   --
14332   hr_assignment_api.update_emp_asg
14333     (p_validate                     => p_validate
14334     ,p_effective_date               => p_effective_date
14335     ,p_datetrack_update_mode        => p_datetrack_update_mode
14336     ,p_assignment_id                => p_assignment_id
14337     ,p_object_version_number        => p_object_version_number
14338     ,p_supervisor_id                => p_supervisor_id
14339     ,p_assignment_number            => p_assignment_number
14340     ,p_change_reason                => p_change_reason
14341     ,p_comments                     => p_comments
14342     ,p_date_probation_end           => p_date_probation_end
14343     ,p_default_code_comb_id         => p_default_code_comb_id
14344     ,p_frequency                    => p_frequency
14345     ,p_internal_address_line        => p_internal_address_line
14346     ,p_manager_flag                 => p_manager_flag
14347     ,p_normal_hours                 => p_normal_hours
14348     ,p_perf_review_period           => p_perf_review_period
14349     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14350     ,p_probation_period             => p_probation_period
14351     ,p_probation_unit               => p_probation_unit
14352     ,p_sal_review_period            => p_sal_review_period
14353     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14354     ,p_set_of_books_id              => p_set_of_books_id
14355     ,p_source_type                  => p_source_type
14356     ,p_time_normal_finish           => p_time_normal_finish
14357     ,p_time_normal_start            => p_time_normal_start
14358     ,p_bargaining_unit_code         => p_bargaining_unit_code
14359     ,p_labour_union_member_flag     => p_labour_union_member_flag
14360     ,p_hourly_salaried_code         => p_hourly_salaried_code
14361     ,p_ass_attribute_category       => p_ass_attribute_category
14362     ,p_ass_attribute1               => p_ass_attribute1
14363     ,p_ass_attribute2               => p_ass_attribute2
14364     ,p_ass_attribute3               => p_ass_attribute3
14365     ,p_ass_attribute4               => p_ass_attribute4
14366     ,p_ass_attribute5               => p_ass_attribute5
14367     ,p_ass_attribute6               => p_ass_attribute6
14368     ,p_ass_attribute7               => p_ass_attribute7
14369     ,p_ass_attribute8               => p_ass_attribute8
14370     ,p_ass_attribute9               => p_ass_attribute9
14371     ,p_ass_attribute10              => p_ass_attribute10
14372     ,p_ass_attribute11              => p_ass_attribute11
14373     ,p_ass_attribute12              => p_ass_attribute12
14374     ,p_ass_attribute13              => p_ass_attribute13
14375     ,p_ass_attribute14              => p_ass_attribute14
14376     ,p_ass_attribute15              => p_ass_attribute15
14377     ,p_ass_attribute16              => p_ass_attribute16
14378     ,p_ass_attribute17              => p_ass_attribute17
14379     ,p_ass_attribute18              => p_ass_attribute18
14380     ,p_ass_attribute19              => p_ass_attribute19
14381     ,p_ass_attribute20              => p_ass_attribute20
14382     ,p_ass_attribute21              => p_ass_attribute21
14383     ,p_ass_attribute22              => p_ass_attribute22
14384     ,p_ass_attribute23              => p_ass_attribute23
14385     ,p_ass_attribute24              => p_ass_attribute24
14386     ,p_ass_attribute25              => p_ass_attribute25
14387     ,p_ass_attribute26              => p_ass_attribute26
14388     ,p_ass_attribute27              => p_ass_attribute27
14389     ,p_ass_attribute28              => p_ass_attribute28
14390     ,p_ass_attribute29              => p_ass_attribute29
14391     ,p_ass_attribute30              => p_ass_attribute30
14392     ,p_title                        => p_title
14393     ,p_contract_id		    => p_contract_id
14394     ,p_establishment_id		    => p_establishment_id
14395     ,p_collective_agreement_id	    => p_collective_agreement_id
14396     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14397     ,p_notice_period		    => p_notice_period
14398     ,p_notice_period_uom	    => p_notice_period_uom
14399     ,p_employee_category	    => p_employee_category
14400     ,p_work_at_home		    => p_work_at_home
14401     ,p_job_post_source_name	    => p_job_post_source_name
14402     ,p_segment1                     => p_tax_unit
14403     ,p_segment2                     => p_timecard_approver
14404     ,p_segment3                     => p_timecard_required
14405     ,p_segment4                     => p_work_schedule
14406     ,p_segment5                     => p_shift
14407     ,p_segment6                     => p_spouse_salary
14408     ,p_segment7                     => p_legal_representative
14409     ,p_segment8                     => p_wc_override_code
14410     ,p_segment9                     => p_eeo_1_establishment
14411     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14412     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14413     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
14414     ,p_comment_id                   => p_comment_id
14415     ,p_effective_start_date         => p_effective_start_date
14416     ,p_effective_end_date           => p_effective_end_date
14417 -- Bug 944911
14418 -- Added new param
14419     ,p_concatenated_segments        => p_concatenated_segments
14420     ,p_concat_segments              => p_concat_segments
14421     ,p_no_managers_warning          => p_no_managers_warning
14422     ,p_other_manager_warning        => p_other_manager_warning
14423     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
14424     ,p_gsp_post_process_warning     => l_gsp_post_process_warning -- bug 2999562
14425     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14426     );
14427  if g_debug then
14428   hr_utility.set_location(' Leaving:'||l_proc, 40);
14429  end if;
14430 end update_us_emp_asg;
14431 -- End of update_us_emp_asg OVERLOADED procedure
14432 
14433 --
14434 -- ----------------------------------------------------------------------------
14435 -- |--------------------------< update_us_emp_asg --NEW3 >--------------------|
14436 -- ----------------------------------------------------------------------------
14437 --
14438 -- added new parameters p_gsp_post_process_warning
14439 
14440 
14441 procedure update_us_emp_asg
14442   (p_validate                     in     boolean
14443   ,p_effective_date               in     date
14444   ,p_datetrack_update_mode        in     varchar2
14445   ,p_assignment_id                in     number
14446   ,p_object_version_number        in out nocopy number
14447   ,p_supervisor_id                in     number
14448   ,p_assignment_number            in     varchar2
14449   ,p_change_reason                in     varchar2
14450   ,p_comments                     in     varchar2
14451   ,p_date_probation_end           in     date
14452   ,p_default_code_comb_id         in     number
14453   ,p_frequency                    in     varchar2
14454   ,p_internal_address_line        in     varchar2
14455   ,p_manager_flag                 in     varchar2
14456   ,p_normal_hours                 in     number
14457   ,p_perf_review_period           in     number
14458   ,p_perf_review_period_frequency in     varchar2
14459   ,p_probation_period             in     number
14460   ,p_probation_unit               in     varchar2
14461   ,p_sal_review_period            in     number
14462   ,p_sal_review_period_frequency  in     varchar2
14463   ,p_set_of_books_id              in     number
14464   ,p_source_type                  in     varchar2
14465   ,p_time_normal_finish           in     varchar2
14466   ,p_time_normal_start            in     varchar2
14467   ,p_bargaining_unit_code         in     varchar2
14468   ,p_labour_union_member_flag     in     varchar2
14469   ,p_hourly_salaried_code         in     varchar2
14470   ,p_ass_attribute_category       in     varchar2
14471   ,p_ass_attribute1               in     varchar2
14472   ,p_ass_attribute2               in     varchar2
14473   ,p_ass_attribute3               in     varchar2
14474   ,p_ass_attribute4               in     varchar2
14475   ,p_ass_attribute5               in     varchar2
14476   ,p_ass_attribute6               in     varchar2
14477   ,p_ass_attribute7               in     varchar2
14478   ,p_ass_attribute8               in     varchar2
14479   ,p_ass_attribute9               in     varchar2
14480   ,p_ass_attribute10              in     varchar2
14481   ,p_ass_attribute11              in     varchar2
14482   ,p_ass_attribute12              in     varchar2
14483   ,p_ass_attribute13              in     varchar2
14484   ,p_ass_attribute14              in     varchar2
14485   ,p_ass_attribute15              in     varchar2
14486   ,p_ass_attribute16              in     varchar2
14487   ,p_ass_attribute17              in     varchar2
14488   ,p_ass_attribute18              in     varchar2
14489   ,p_ass_attribute19              in     varchar2
14490   ,p_ass_attribute20              in     varchar2
14491   ,p_ass_attribute21              in     varchar2
14492   ,p_ass_attribute22              in     varchar2
14493   ,p_ass_attribute23              in     varchar2
14494   ,p_ass_attribute24              in     varchar2
14495   ,p_ass_attribute25              in     varchar2
14496   ,p_ass_attribute26              in     varchar2
14497   ,p_ass_attribute27              in     varchar2
14498   ,p_ass_attribute28              in     varchar2
14499   ,p_ass_attribute29              in     varchar2
14500   ,p_ass_attribute30              in     varchar2
14501   ,p_title                        in     varchar2
14502   ,p_tax_unit                     in     varchar2
14503   ,p_timecard_approver            in     varchar2
14504   ,p_timecard_required            in     varchar2
14505   ,p_work_schedule                in     varchar2
14506   ,p_shift                        in     varchar2
14507   ,p_spouse_salary                in     varchar2
14508   ,p_legal_representative         in     varchar2
14509   ,p_wc_override_code             in     varchar2
14510   ,p_eeo_1_establishment          in     varchar2
14511   -- Added for bug 1889914
14512   ,p_contract_id		  in     number
14513   ,p_establishment_id		  in 	 number
14514   ,p_collective_agreement_id	  in     number
14515   ,p_cagr_id_flex_num		  in     number
14516   ,p_notice_period		  in     number
14517   ,p_notice_period_uom	      	  in     varchar2
14518   ,p_employee_category	          in     varchar2
14519   ,p_work_at_home		  in     varchar2
14520   ,p_job_post_source_name	  in     varchar2
14521   ,p_supervisor_assignment_id     in     number
14522   ,p_cagr_grade_def_id		     out nocopy number
14523   ,p_cagr_concatenated_segments      out nocopy varchar2
14524   -- End 1889914
14525   ,p_comment_id                      out nocopy number
14526   ,p_soft_coding_keyflex_id          out nocopy number
14527   ,p_effective_start_date            out nocopy date
14528   ,p_effective_end_date              out nocopy date
14529 -- Bug 944911
14530 -- Amended p_concatenated_segments to be out
14531 -- Added p_concat_segments  - in param
14532   ,p_concatenated_segments           out nocopy varchar2
14533   ,p_concat_segments              in     varchar2
14534   ,p_no_managers_warning             out nocopy boolean
14535   ,p_other_manager_warning           out nocopy boolean
14536   ,p_hourly_salaried_warning         out nocopy boolean
14537   ,p_gsp_post_process_warning        out nocopy varchar2
14538   )
14539 is
14540   --
14541   -- Declare cursors and local variables
14542   --
14543   l_proc                       varchar2(72);
14544   l_effective_date             date;
14545   l_legislation_code           per_business_groups.legislation_code%TYPE;
14546 
14547   --
14548   cursor check_legislation
14549     (c_assignment_id  per_all_assignments_f.assignment_id%TYPE,
14550      c_effective_date date
14551     )
14552   is
14553     select bgp.legislation_code
14554     from per_all_assignments_f asg,
14555          per_business_groups_perf bgp
14556     where asg.business_group_id = bgp.business_group_id
14557     and   asg.assignment_id     = c_assignment_id
14558     and   c_effective_date
14559       between effective_start_date and effective_end_date;
14560   --
14561 begin
14562  if g_debug then
14563   l_proc := g_package||'update_us_emp_asg';
14564   hr_utility.set_location('Entering:'|| l_proc, 10);
14565  end if;
14566   --
14567   -- Truncate date variables
14568   --
14569   l_effective_date := trunc(p_effective_date);
14570   --
14571   -- Validate in addition to Table Handlers
14572   --
14573   -- Check that the assignment exists.
14574   --
14575   open check_legislation(p_assignment_id, l_effective_date);
14576   fetch check_legislation into l_legislation_code;
14577   if check_legislation%notfound then
14578     close check_legislation;
14579     hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
14580     hr_utility.raise_error;
14581   end if;
14582   close check_legislation;
14583  if g_debug then
14584   hr_utility.set_location(l_proc, 20);
14585  end if;
14586   --
14587   -- Check that the legislation of the specified business group is 'US'.
14588   --
14589   if l_legislation_code <> 'US' then
14590     hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
14591     hr_utility.set_message_token('LEG_CODE','US');
14592     hr_utility.raise_error;
14593   end if;
14594  if g_debug then
14595   hr_utility.set_location(l_proc, 30);
14596  end if;
14597   --
14598   -- Call update_emp_asg business process
14599   --
14600   hr_assignment_api.update_emp_asg
14601     (p_validate                     => p_validate
14602     ,p_effective_date               => p_effective_date
14603     ,p_datetrack_update_mode        => p_datetrack_update_mode
14604     ,p_assignment_id                => p_assignment_id
14605     ,p_object_version_number        => p_object_version_number
14606     ,p_supervisor_id                => p_supervisor_id
14607     ,p_assignment_number            => p_assignment_number
14608     ,p_change_reason                => p_change_reason
14609     ,p_comments                     => p_comments
14610     ,p_date_probation_end           => p_date_probation_end
14611     ,p_default_code_comb_id         => p_default_code_comb_id
14612     ,p_frequency                    => p_frequency
14613     ,p_internal_address_line        => p_internal_address_line
14614     ,p_manager_flag                 => p_manager_flag
14615     ,p_normal_hours                 => p_normal_hours
14616     ,p_perf_review_period           => p_perf_review_period
14617     ,p_perf_review_period_frequency => p_perf_review_period_frequency
14618     ,p_probation_period             => p_probation_period
14619     ,p_probation_unit               => p_probation_unit
14620     ,p_sal_review_period            => p_sal_review_period
14621     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
14622     ,p_set_of_books_id              => p_set_of_books_id
14623     ,p_source_type                  => p_source_type
14624     ,p_time_normal_finish           => p_time_normal_finish
14625     ,p_time_normal_start            => p_time_normal_start
14626     ,p_bargaining_unit_code         => p_bargaining_unit_code
14627     ,p_labour_union_member_flag     => p_labour_union_member_flag
14628     ,p_hourly_salaried_code         => p_hourly_salaried_code
14629     ,p_ass_attribute_category       => p_ass_attribute_category
14630     ,p_ass_attribute1               => p_ass_attribute1
14631     ,p_ass_attribute2               => p_ass_attribute2
14632     ,p_ass_attribute3               => p_ass_attribute3
14633     ,p_ass_attribute4               => p_ass_attribute4
14634     ,p_ass_attribute5               => p_ass_attribute5
14635     ,p_ass_attribute6               => p_ass_attribute6
14636     ,p_ass_attribute7               => p_ass_attribute7
14637     ,p_ass_attribute8               => p_ass_attribute8
14638     ,p_ass_attribute9               => p_ass_attribute9
14639     ,p_ass_attribute10              => p_ass_attribute10
14640     ,p_ass_attribute11              => p_ass_attribute11
14641     ,p_ass_attribute12              => p_ass_attribute12
14642     ,p_ass_attribute13              => p_ass_attribute13
14643     ,p_ass_attribute14              => p_ass_attribute14
14644     ,p_ass_attribute15              => p_ass_attribute15
14645     ,p_ass_attribute16              => p_ass_attribute16
14646     ,p_ass_attribute17              => p_ass_attribute17
14647     ,p_ass_attribute18              => p_ass_attribute18
14648     ,p_ass_attribute19              => p_ass_attribute19
14649     ,p_ass_attribute20              => p_ass_attribute20
14650     ,p_ass_attribute21              => p_ass_attribute21
14651     ,p_ass_attribute22              => p_ass_attribute22
14652     ,p_ass_attribute23              => p_ass_attribute23
14653     ,p_ass_attribute24              => p_ass_attribute24
14654     ,p_ass_attribute25              => p_ass_attribute25
14655     ,p_ass_attribute26              => p_ass_attribute26
14656     ,p_ass_attribute27              => p_ass_attribute27
14657     ,p_ass_attribute28              => p_ass_attribute28
14658     ,p_ass_attribute29              => p_ass_attribute29
14659     ,p_ass_attribute30              => p_ass_attribute30
14660     ,p_title                        => p_title
14661     ,p_contract_id		    => p_contract_id
14662     ,p_establishment_id		    => p_establishment_id
14663     ,p_collective_agreement_id	    => p_collective_agreement_id
14664     ,p_cagr_id_flex_num		    => p_cagr_id_flex_num
14665     ,p_notice_period		    => p_notice_period
14666     ,p_notice_period_uom	    => p_notice_period_uom
14667     ,p_employee_category	    => p_employee_category
14668     ,p_work_at_home		    => p_work_at_home
14669     ,p_job_post_source_name	    => p_job_post_source_name
14670     ,p_segment1                     => p_tax_unit
14671     ,p_segment2                     => p_timecard_approver
14672     ,p_segment3                     => p_timecard_required
14673     ,p_segment4                     => p_work_schedule
14674     ,p_segment5                     => p_shift
14675     ,p_segment6                     => p_spouse_salary
14676     ,p_segment7                     => p_legal_representative
14677     ,p_segment8                     => p_wc_override_code
14678     ,p_segment9                     => p_eeo_1_establishment
14679     ,p_cagr_grade_def_id	    => p_cagr_grade_def_id
14680     ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
14681     ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
14682     ,p_comment_id                   => p_comment_id
14683     ,p_effective_start_date         => p_effective_start_date
14684     ,p_effective_end_date           => p_effective_end_date
14685 -- Bug 944911
14686 -- Added new param
14687     ,p_concatenated_segments        => p_concatenated_segments
14688     ,p_concat_segments              => p_concat_segments
14689     ,p_no_managers_warning          => p_no_managers_warning
14690     ,p_other_manager_warning        => p_other_manager_warning
14691     ,p_hourly_salaried_warning      => p_hourly_salaried_warning
14692     ,p_gsp_post_process_warning     => p_gsp_post_process_warning
14693     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
14694     );
14695  if g_debug then
14696   hr_utility.set_location(' Leaving:'||l_proc, 40);
14697  end if;
14698 end update_us_emp_asg;
14699 -- End of update_us_emp_asg OVERLOADED procedure
14700 
14701 --
14702 -- ----------------------------------------------------------------------------
14703 -- |---------------------< update_emp_asg_criteria -- OLD>---------------------|
14704 -- ----------------------------------------------------------------------------
14705 --
14706 
14707 procedure update_emp_asg_criteria
14708   (p_effective_date               in     date
14709   ,p_datetrack_update_mode        in     varchar2
14710   ,p_assignment_id                in     number
14711   ,p_validate                     in     boolean
14712   ,p_called_from_mass_update      in     boolean
14713   ,p_grade_id                     in     number
14714   ,p_position_id                  in     number
14715   ,p_job_id                       in     number
14716   ,p_payroll_id                   in     number
14717   ,p_location_id                  in     number
14718   ,p_organization_id              in     number
14719   ,p_pay_basis_id                 in     number
14720   ,p_segment1                     in     varchar2
14721   ,p_segment2                     in     varchar2
14722   ,p_segment3                     in     varchar2
14723   ,p_segment4                     in     varchar2
14724   ,p_segment5                     in     varchar2
14725   ,p_segment6                     in     varchar2
14726   ,p_segment7                     in     varchar2
14727   ,p_segment8                     in     varchar2
14728   ,p_segment9                     in     varchar2
14729   ,p_segment10                    in     varchar2
14730   ,p_segment11                    in     varchar2
14731   ,p_segment12                    in     varchar2
14732   ,p_segment13                    in     varchar2
14733   ,p_segment14                    in     varchar2
14734   ,p_segment15                    in     varchar2
14735   ,p_segment16                    in     varchar2
14736   ,p_segment17                    in     varchar2
14737   ,p_segment18                    in     varchar2
14738   ,p_segment19                    in     varchar2
14739   ,p_segment20                    in     varchar2
14740   ,p_segment21                    in     varchar2
14741   ,p_segment22                    in     varchar2
14742   ,p_segment23                    in     varchar2
14743   ,p_segment24                    in     varchar2
14744   ,p_segment25                    in     varchar2
14745   ,p_segment26                    in     varchar2
14746   ,p_segment27                    in     varchar2
14747   ,p_segment28                    in     varchar2
14748   ,p_segment29                    in     varchar2
14749   ,p_segment30                    in     varchar2
14750   ,p_employment_category          in     varchar2
14751 -- Bug 944911
14752 -- Amended p_group_name to out
14753 -- Added new param p_pgp_concat_segments - for sec asg procs
14754 -- for others added p_concat_segments
14755   ,p_concat_segments              in     varchar2
14756   ,p_grade_ladder_pgm_id          in     number
14757   ,p_supervisor_assignment_id     in     number
14758   ,p_people_group_id              in out nocopy number --bug 2359997
14759   ,p_object_version_number        in out nocopy number
14760   ,p_special_ceiling_step_id      in out nocopy number
14761   ,p_group_name                      out nocopy varchar2
14762   ,p_effective_start_date            out nocopy date
14763   ,p_effective_end_date              out nocopy date
14764   ,p_org_now_no_manager_warning      out nocopy boolean
14765   ,p_other_manager_warning           out nocopy boolean
14766   ,p_spp_delete_warning              out nocopy boolean
14767   ,p_entries_changed_warning         out nocopy varchar2
14768   ,p_tax_district_changed_warning    out nocopy boolean
14769   ) is
14770 
14771     --
14772     -- Declare cursors and local variables
14773     --
14774     -- Out variables
14775     --
14776     l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
14777     l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
14778     l_entries_changed_warning      varchar2(1) := 'N';
14779     l_group_name                   pay_people_groups.group_name%TYPE;
14780     l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
14781     l_org_now_no_manager_warning   boolean;
14782     l_other_manager_warning        boolean;
14783     l_people_group_id              per_all_assignments_f.people_group_id%TYPE
14784                                    := p_people_group_id; -- bug 2359997
14785     l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE
14786                                    := p_special_ceiling_step_id; --3485599
14787     l_spp_delete_warning           boolean;
14788     l_tax_district_changed_warning boolean;
14789 
14790     l_soft_coding_keyflex_id       number;
14791     l_concatenated_segments	   hr_soft_coding_keyflex.concatenated_segments%TYPE;
14792     l_contract_id		   number;
14793     l_establishment_id		   number;
14794     l_scl_segment1		   varchar2(60);
14795     l_proc                         varchar2(72) := g_package||'update_emp_asg_criteria';
14796 
14797     -- Start of fix 3553286
14798     -- Bug 2656155
14799     --p_jobid                        number := p_job_id;
14800     --p_org_id                       number := p_organization_id;
14801     --
14802     -- End of 3553286
14803 
14804  BEGIN
14805 
14806     l_object_version_number := p_object_version_number;
14807     --
14808  if g_debug then
14809     hr_utility.set_location('Entering:'|| l_proc, 5);
14810  end if;
14811 
14812  -- Start of fix 3553286
14813  -- Start of bug fix 2656155
14814  -- This procedure will return the job_id and organization_id of a position
14815  --
14816  -- Bug 3005283 : Starts here
14817  -- Description : This code should not be executed if position_id is null, otherwise org_id/job_id will be
14818  -- set to NULL if position_id is not passed to this procedure.  So added IF condition to check for that if
14819  -- position_id is not null and it is called from Mass Update form.
14820  --
14821  --  if (p_called_from_mass_update = TRUE and p_position_id is not null) then
14822  --    if (p_jobid is null) or (p_org_id is null) then
14823  --       hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
14824  --                                       p_jobid, p_org_id);
14825  --    end if;
14826  --   end if;
14827  --
14828  -- Bug 3005283 : Ends here.
14829  --
14830  -- End of fix 2656155
14831  -- End of fix 3553286
14832 
14833     --
14834     -- Calling New Overloaded Procedure
14835     --
14836 
14837     hr_assignment_api.update_emp_asg_criteria
14838       (p_validate                     =>  p_validate
14839       ,p_effective_date               =>  p_effective_date
14840       ,p_datetrack_update_mode        =>  p_datetrack_update_mode
14841       ,p_called_from_mass_update      =>  p_called_from_mass_update
14842       ,p_assignment_id                =>  p_assignment_id
14843       ,p_object_version_number        =>  l_object_version_number
14844       ,p_grade_id                     =>  p_grade_id
14845       ,p_position_id                  =>  p_position_id
14846       ,p_job_id                       =>  p_job_id -- Bug 2656155 -- 3553286
14847       ,p_payroll_id                   =>  p_payroll_id
14848       ,p_location_id                  =>  p_location_id
14849       ,p_special_ceiling_step_id      =>  l_special_ceiling_step_id
14850       ,p_organization_id              =>  p_organization_id -- Bug 2656155 -- 3553286
14851       ,p_pay_basis_id                 =>  p_pay_basis_id
14852       ,p_segment1                     =>  p_segment1
14853       ,p_segment2                     =>  p_segment2
14854       ,p_segment3                     =>  p_segment3
14855       ,p_segment4                     =>  p_segment4
14856       ,p_segment5                     =>  p_segment5
14857       ,p_segment6                     =>  p_segment6
14858       ,p_segment7                     =>  p_segment7
14859       ,p_segment8                     =>  p_segment8
14860       ,p_segment9                     =>  p_segment9
14861       ,p_segment10                    =>  p_segment10
14862       ,p_segment11                    =>  p_segment11
14863       ,p_segment12                    =>  p_segment12
14864       ,p_segment13                    =>  p_segment13
14865       ,p_segment14                    =>  p_segment14
14866       ,p_segment15                    =>  p_segment15
14867       ,p_segment16                    =>  p_segment16
14868       ,p_segment17                    =>  p_segment17
14869       ,p_segment18                    =>  p_segment18
14870       ,p_segment19                    =>  p_segment19
14871       ,p_segment20                    =>  p_segment20
14872       ,p_segment21                    =>  p_segment21
14873       ,p_segment22                    =>  p_segment22
14874       ,p_segment23                    =>  p_segment23
14875       ,p_segment24                    =>  p_segment24
14876       ,p_segment25                    =>  p_segment25
14877       ,p_segment26                    =>  p_segment26
14878       ,p_segment27                    =>  p_segment27
14879       ,p_segment28                    =>  p_segment28
14880       ,p_segment29                    =>  p_segment29
14881       ,p_segment30                    =>  p_segment30
14882       ,p_concat_segments              =>  p_concat_segments
14883       ,p_grade_ladder_pgm_id          =>  p_grade_ladder_pgm_id
14884       ,p_supervisor_assignment_id     =>  p_supervisor_assignment_id
14885       ,p_group_name                   =>  l_group_name
14886       ,p_employment_category          =>  p_employment_category
14887       ,p_effective_start_date         =>  l_effective_start_date
14888       ,p_effective_end_date           =>  l_effective_end_date
14889       ,p_people_group_id              =>  l_people_group_id
14890       ,p_org_now_no_manager_warning   =>  l_org_now_no_manager_warning
14891       ,p_other_manager_warning        =>  l_other_manager_warning
14892       ,p_spp_delete_warning           =>  l_spp_delete_warning
14893       ,p_entries_changed_warning      =>  l_entries_changed_warning
14894       ,p_tax_district_changed_warning =>  l_tax_district_changed_warning
14895       ,p_soft_coding_keyflex_id       =>  l_soft_coding_keyflex_id
14896       ,p_concatenated_segments        =>  l_concatenated_segments
14897 --2689059: changed the following: must pass hr_api defaults to NEW update API
14898       ,p_contract_id                  =>  hr_api.g_number  --l_contract_id
14899       ,p_establishment_id             =>  hr_api.g_number  --l_establishment_id
14900       ,p_scl_segment1                 =>  hr_api.g_varchar2  --l_scl_segment1
14901       ) ;
14902 
14903 
14904       --
14905       -- Set all output arguments
14906       --
14907       p_effective_end_date           := l_effective_end_date;
14908       p_effective_start_date         := l_effective_start_date;
14909       p_people_group_id              := l_people_group_id;
14910       p_group_name                   := l_group_name;
14911       p_entries_changed_warning      := l_entries_changed_warning;
14912       p_object_version_number        := l_object_version_number;
14913       p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
14914       p_other_manager_warning        := l_other_manager_warning;
14915       p_special_ceiling_step_id      := l_special_ceiling_step_id;
14916       p_spp_delete_warning           := l_spp_delete_warning;
14917       p_tax_district_changed_warning := l_tax_district_changed_warning;
14918 
14919  if g_debug then
14920     hr_utility.set_location('Leaving:'|| l_proc, 20);
14921  end if;
14922 
14923 End update_emp_asg_criteria;
14924 
14925 
14926 -- ----------------------------------------------------------------------------
14927 -- |---------------------< update_emp_asg_criteria-- NEW >---------------------|
14928 -- ----------------------------------------------------------------------------
14929 --
14930 
14931 procedure update_emp_asg_criteria
14932   (p_effective_date               in     date
14933   ,p_datetrack_update_mode        in     varchar2
14934   ,p_assignment_id                in     number
14935   ,p_validate                     in     boolean
14936   ,p_called_from_mass_update      in     boolean
14937   ,p_grade_id                     in     number
14938   ,p_position_id                  in     number
14939   ,p_job_id                       in     number
14940   ,p_payroll_id                   in     number
14941   ,p_location_id                  in     number
14942   ,p_organization_id              in     number
14943   ,p_pay_basis_id                 in     number
14944   ,p_segment1                     in     varchar2
14945   ,p_segment2                     in     varchar2
14946   ,p_segment3                     in     varchar2
14947   ,p_segment4                     in     varchar2
14948   ,p_segment5                     in     varchar2
14949   ,p_segment6                     in     varchar2
14950   ,p_segment7                     in     varchar2
14951   ,p_segment8                     in     varchar2
14952   ,p_segment9                     in     varchar2
14953   ,p_segment10                    in     varchar2
14954   ,p_segment11                    in     varchar2
14955   ,p_segment12                    in     varchar2
14956   ,p_segment13                    in     varchar2
14957   ,p_segment14                    in     varchar2
14958   ,p_segment15                    in     varchar2
14959   ,p_segment16                    in     varchar2
14960   ,p_segment17                    in     varchar2
14961   ,p_segment18                    in     varchar2
14962   ,p_segment19                    in     varchar2
14963   ,p_segment20                    in     varchar2
14964   ,p_segment21                    in     varchar2
14965   ,p_segment22                    in     varchar2
14966   ,p_segment23                    in     varchar2
14967   ,p_segment24                    in     varchar2
14968   ,p_segment25                    in     varchar2
14969   ,p_segment26                    in     varchar2
14970   ,p_segment27                    in     varchar2
14971   ,p_segment28                    in     varchar2
14972   ,p_segment29                    in     varchar2
14973   ,p_segment30                    in     varchar2
14974   ,p_employment_category          in     varchar2
14975 -- Bug 944911
14976 -- Amended p_group_name to out
14977 -- Added new param p_pgp_concat_segments - for sec asg procs
14978 -- for others added p_concat_segments
14979   ,p_concat_segments              in     varchar2
14980   ,p_contract_id                  in     number
14981   ,p_establishment_id             in     number
14982   ,p_scl_segment1                 in     varchar2
14983   ,p_grade_ladder_pgm_id          in     number
14984   ,p_supervisor_assignment_id     in     number
14985   ,p_object_version_number        in out nocopy number
14986   ,p_special_ceiling_step_id      in out nocopy number
14987   ,p_people_group_id              in out nocopy number
14988   ,p_soft_coding_keyflex_id       in out nocopy number
14989   ,p_group_name                      out nocopy varchar2
14990   ,p_effective_start_date            out nocopy date
14991   ,p_effective_end_date              out nocopy date
14992   ,p_org_now_no_manager_warning      out nocopy boolean
14993   ,p_other_manager_warning           out nocopy boolean
14994   ,p_spp_delete_warning              out nocopy boolean
14995   ,p_entries_changed_warning         out nocopy varchar2
14996   ,p_tax_district_changed_warning    out nocopy boolean
14997   ,p_concatenated_segments           out nocopy varchar2
14998   ) is
14999   --
15000   -- Declare cursors and local variables
15001   --
15002   -- Out variables
15003   --
15004   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
15005   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
15006   l_entries_changed_warning      varchar2(1) := 'N';
15007   l_group_name                   pay_people_groups.group_name%TYPE;
15008   l_old_group_name               pay_people_groups.group_name%TYPE;
15009   l_no_managers_warning          boolean;
15010   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
15011   l_org_now_no_manager_warning   boolean;
15012   l_other_manager_warning        boolean;
15013   l_hourly_salaried_warning      boolean;
15014   l_payroll_id_updated           boolean;
15015   l_people_group_id              per_all_assignments_f.people_group_id%TYPE
15016                                  := p_people_group_id; -- bug 2359997
15017   l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE
15018                                  := p_special_ceiling_step_id; -- bug 3485599
15019   l_spp_delete_warning           boolean;
15020   l_tax_district_changed_warning boolean;
15021   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
15022   --
15023   l_api_updating                 boolean;
15024   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
15025   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
15026   l_entries_changed              varchar2(1);
15027   l_legislation_code             per_business_groups.legislation_code%TYPE;
15028   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
15029   l_proc                         varchar2(72) :=
15030                                  g_package || 'update_emp_asg_criteria';
15031 
15032 -- Start of Fix for Bug 2622747
15033   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
15034   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15035   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15036 -- End of Fix for Bug 2622747
15037 
15038   l_gsp_post_process_warning varchar2(2000); -- bug 2999562
15039 
15040  BEGIN
15041 
15042     l_object_version_number := p_object_version_number;
15043     --
15044  if g_debug then
15045     hr_utility.set_location('Entering:'|| l_proc, 5);
15046  end if;
15047 
15048     --
15049     -- Calling New Overloaded Procedure
15050     --
15051 
15052     hr_assignment_api.update_emp_asg_criteria
15053       (p_validate                     =>  p_validate
15054       ,p_effective_date               =>  p_effective_date
15055       ,p_datetrack_update_mode        =>  p_datetrack_update_mode
15056       ,p_called_from_mass_update      =>  p_called_from_mass_update
15057       ,p_assignment_id                =>  p_assignment_id
15058       ,p_object_version_number        =>  l_object_version_number
15059       ,p_grade_id                     =>  p_grade_id
15060       ,p_position_id                  =>  p_position_id
15061       ,p_job_id                       =>  p_job_id
15062       ,p_payroll_id                   =>  p_payroll_id
15063       ,p_location_id                  =>  p_location_id
15064       ,p_special_ceiling_step_id      =>  l_special_ceiling_step_id
15065       ,p_organization_id              =>  p_organization_id
15066       ,p_pay_basis_id                 =>  p_pay_basis_id
15067       ,p_segment1                     =>  p_segment1
15068       ,p_segment2                     =>  p_segment2
15069       ,p_segment3                     =>  p_segment3
15070       ,p_segment4                     =>  p_segment4
15071       ,p_segment5                     =>  p_segment5
15072       ,p_segment6                     =>  p_segment6
15073       ,p_segment7                     =>  p_segment7
15074       ,p_segment8                     =>  p_segment8
15075       ,p_segment9                     =>  p_segment9
15076       ,p_segment10                    =>  p_segment10
15077       ,p_segment11                    =>  p_segment11
15078       ,p_segment12                    =>  p_segment12
15079       ,p_segment13                    =>  p_segment13
15080       ,p_segment14                    =>  p_segment14
15081       ,p_segment15                    =>  p_segment15
15082       ,p_segment16                    =>  p_segment16
15083       ,p_segment17                    =>  p_segment17
15084       ,p_segment18                    =>  p_segment18
15085       ,p_segment19                    =>  p_segment19
15086       ,p_segment20                    =>  p_segment20
15087       ,p_segment21                    =>  p_segment21
15088       ,p_segment22                    =>  p_segment22
15089       ,p_segment23                    =>  p_segment23
15090       ,p_segment24                    =>  p_segment24
15091       ,p_segment25                    =>  p_segment25
15092       ,p_segment26                    =>  p_segment26
15093       ,p_segment27                    =>  p_segment27
15094       ,p_segment28                    =>  p_segment28
15095       ,p_segment29                    =>  p_segment29
15096       ,p_segment30                    =>  p_segment30
15097       ,p_concat_segments              =>  p_concat_segments
15098       ,p_grade_ladder_pgm_id          =>  p_grade_ladder_pgm_id
15099       ,p_supervisor_assignment_id     =>  p_supervisor_assignment_id
15100       ,p_employment_category          =>  p_employment_category
15101       ,p_contract_id                  =>  p_contract_id
15102       ,p_establishment_id             =>  p_establishment_id
15103       ,p_scl_segment1                 =>  p_scl_segment1
15104       ,p_group_name                   =>  l_group_name
15105       ,p_effective_start_date         =>  l_effective_start_date
15106       ,p_effective_end_date           =>  l_effective_end_date
15107       ,p_people_group_id              =>  l_people_group_id
15108       ,p_org_now_no_manager_warning   =>  l_org_now_no_manager_warning
15109       ,p_other_manager_warning        =>  l_other_manager_warning
15110       ,p_spp_delete_warning           =>  l_spp_delete_warning
15111       ,p_entries_changed_warning      =>  l_entries_changed_warning
15112       ,p_tax_district_changed_warning =>  l_tax_district_changed_warning
15113       ,p_soft_coding_keyflex_id       =>  l_soft_coding_keyflex_id
15114       ,p_concatenated_segments        =>  l_concatenated_segments
15115       ,p_gsp_post_process_warning     =>  l_gsp_post_process_warning -- bug 2999562
15116       ) ;
15117 
15118   --
15119   -- Set all output arguments
15120   --
15121   p_effective_end_date           := l_effective_end_date;
15122   p_effective_start_date         := l_effective_start_date;
15123   p_people_group_id              := l_people_group_id;
15124   p_group_name                   := l_group_name;
15125   p_entries_changed_warning      := l_entries_changed_warning;
15126   p_object_version_number        := l_object_version_number;
15127   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
15128   p_other_manager_warning        := l_other_manager_warning;
15129   p_special_ceiling_step_id      := l_special_ceiling_step_id;
15130   p_spp_delete_warning           := l_spp_delete_warning;
15131   p_tax_district_changed_warning := l_tax_district_changed_warning;
15132   --
15133   --
15134  if g_debug then
15135   hr_utility.set_location(' Leaving:'||l_proc, 997);
15136  end if;
15137   --
15138 end update_emp_asg_criteria;
15139 -- ----------------------------------------------------------------------------
15140 -- |---------------------< update_emp_asg_criteria-- NEW2 >-------------------|
15141 -- ----------------------------------------------------------------------------
15142 --
15143 
15144 procedure update_emp_asg_criteria
15145   (p_effective_date               in     date
15146   ,p_datetrack_update_mode        in     varchar2
15147   ,p_assignment_id                in     number
15148   ,p_validate                     in     boolean
15149   ,p_called_from_mass_update      in     boolean
15150   ,p_grade_id                     in     number
15151   ,p_position_id                  in     number
15152   ,p_job_id                       in     number
15153   ,p_payroll_id                   in     number
15154   ,p_location_id                  in     number
15155   ,p_organization_id              in     number
15156   ,p_pay_basis_id                 in     number
15157   ,p_segment1                     in     varchar2
15158   ,p_segment2                     in     varchar2
15159   ,p_segment3                     in     varchar2
15160   ,p_segment4                     in     varchar2
15161   ,p_segment5                     in     varchar2
15162   ,p_segment6                     in     varchar2
15163   ,p_segment7                     in     varchar2
15164   ,p_segment8                     in     varchar2
15165   ,p_segment9                     in     varchar2
15166   ,p_segment10                    in     varchar2
15167   ,p_segment11                    in     varchar2
15168   ,p_segment12                    in     varchar2
15169   ,p_segment13                    in     varchar2
15170   ,p_segment14                    in     varchar2
15171   ,p_segment15                    in     varchar2
15172   ,p_segment16                    in     varchar2
15173   ,p_segment17                    in     varchar2
15174   ,p_segment18                    in     varchar2
15175   ,p_segment19                    in     varchar2
15176   ,p_segment20                    in     varchar2
15177   ,p_segment21                    in     varchar2
15178   ,p_segment22                    in     varchar2
15179   ,p_segment23                    in     varchar2
15180   ,p_segment24                    in     varchar2
15181   ,p_segment25                    in     varchar2
15182   ,p_segment26                    in     varchar2
15183   ,p_segment27                    in     varchar2
15184   ,p_segment28                    in     varchar2
15185   ,p_segment29                    in     varchar2
15186   ,p_segment30                    in     varchar2
15187   ,p_employment_category          in     varchar2
15188 -- Bug 944911
15189 -- Amended p_group_name to out
15190 -- Added new param p_pgp_concat_segments - for sec asg procs
15191 -- for others added p_concat_segments
15192   ,p_concat_segments              in     varchar2
15193   ,p_contract_id                  in     number
15194   ,p_establishment_id             in     number
15195   ,p_scl_segment1                 in     varchar2
15196   ,p_grade_ladder_pgm_id          in     number
15197   ,p_supervisor_assignment_id     in     number
15198   ,p_object_version_number        in out nocopy number
15199   ,p_special_ceiling_step_id      in out nocopy number
15200   ,p_people_group_id              in out nocopy number
15201   ,p_soft_coding_keyflex_id       in out nocopy number
15202   ,p_group_name                      out nocopy varchar2
15203   ,p_effective_start_date            out nocopy date
15204   ,p_effective_end_date              out nocopy date
15205   ,p_org_now_no_manager_warning      out nocopy boolean
15206   ,p_other_manager_warning           out nocopy boolean
15207   ,p_spp_delete_warning              out nocopy boolean
15208   ,p_entries_changed_warning         out nocopy varchar2
15209   ,p_tax_district_changed_warning    out nocopy boolean
15210   ,p_concatenated_segments           out nocopy varchar2
15211   ,p_gsp_post_process_warning        out nocopy varchar2
15212   ) is
15213   --
15214   -- Declare cursors and local variables
15215   --
15216   -- Out variables
15217   --
15218   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
15219   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
15220   l_entries_changed_warning      varchar2(1) := 'N';
15221   l_group_name                   pay_people_groups.group_name%TYPE;
15222   l_old_group_name               pay_people_groups.group_name%TYPE;
15223   l_no_managers_warning          boolean;
15224   l_object_version_number        per_all_assignments_f.object_version_number%TYPE;
15225   l_org_now_no_manager_warning   boolean;
15226   l_other_manager_warning        boolean;
15227   l_hourly_salaried_warning      boolean;
15228   l_payroll_id_updated           boolean;
15229   l_people_group_id              per_all_assignments_f.people_group_id%TYPE
15230                                  := p_people_group_id; -- bug 2359997
15231   l_special_ceiling_step_id      per_all_assignments_f.special_ceiling_step_id%TYPE;
15232   l_spp_delete_warning           boolean;
15233   l_tax_district_changed_warning boolean;
15234   l_flex_num                     fnd_id_flex_segments.id_flex_num%TYPE;
15235   l_gsp_post_process_warning     varchar2(2000); -- bug2999562
15236   --
15237   l_api_updating                 boolean;
15238   l_business_group_id            per_all_assignments_f.business_group_id%TYPE;
15239   l_comment_id                   per_all_assignments_f.comment_id%TYPE;
15240   l_entries_changed              varchar2(1);
15241   l_legislation_code             per_business_groups.legislation_code%TYPE;
15242   l_new_payroll_id               per_all_assignments_f.payroll_id%TYPE;
15243   l_proc                         varchar2(72) :=
15244                                  g_package || 'update_emp_asg_criteria';
15245   l_validation_end_date          date;
15246   l_validation_start_date        date;
15247   l_effective_date               date;
15248   l_element_entry_id             number;
15249   l_organization_id              per_all_assignments_f.organization_id%type;
15250   l_location_id                  per_all_assignments_f.location_id%type;
15251   l_session_id                   number;
15252   l_step_id                      per_spinal_point_steps_f.step_id%TYPE;
15253 
15254 -- Start of Fix for Bug 2622747
15255   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
15256   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15257   l_old_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
15258 -- End of Fix for Bug 2622747
15259 
15260   --
15261   -- bug 2359997 new variable to indicate whether people group key flex
15262   -- entered with a value.
15263   --
15264   l_pgp_null_ind               number(1) := 0;
15265   --
15266   -- bug 2359997 new variables for derived values where key flex id is known.
15267   --
15268   --
15269   l_pgp_segment1               varchar2(60) := p_segment1;
15270   l_pgp_segment2               varchar2(60) := p_segment2;
15271   l_pgp_segment3               varchar2(60) := p_segment3;
15272   l_pgp_segment4               varchar2(60) := p_segment4;
15273   l_pgp_segment5               varchar2(60) := p_segment5;
15274   l_pgp_segment6               varchar2(60) := p_segment6;
15275   l_pgp_segment7               varchar2(60) := p_segment7;
15276   l_pgp_segment8               varchar2(60) := p_segment8;
15277   l_pgp_segment9               varchar2(60) := p_segment9;
15278   l_pgp_segment10              varchar2(60) := p_segment10;
15279   l_pgp_segment11              varchar2(60) := p_segment11;
15280   l_pgp_segment12              varchar2(60) := p_segment12;
15281   l_pgp_segment13              varchar2(60) := p_segment13;
15282   l_pgp_segment14              varchar2(60) := p_segment14;
15283   l_pgp_segment15              varchar2(60) := p_segment15;
15284   l_pgp_segment16              varchar2(60) := p_segment16;
15285   l_pgp_segment17              varchar2(60) := p_segment17;
15286   l_pgp_segment18              varchar2(60) := p_segment18;
15287   l_pgp_segment19              varchar2(60) := p_segment19;
15288   l_pgp_segment20              varchar2(60) := p_segment20;
15289   l_pgp_segment21              varchar2(60) := p_segment21;
15290   l_pgp_segment22              varchar2(60) := p_segment22;
15291   l_pgp_segment23              varchar2(60) := p_segment23;
15292   l_pgp_segment24              varchar2(60) := p_segment24;
15293   l_pgp_segment25              varchar2(60) := p_segment25;
15294   l_pgp_segment26              varchar2(60) := p_segment26;
15295   l_pgp_segment27              varchar2(60) := p_segment27;
15296   l_pgp_segment28              varchar2(60) := p_segment28;
15297   l_pgp_segment29              varchar2(60) := p_segment29;
15298   l_pgp_segment30              varchar2(60) := p_segment30;
15299 
15300 -- Start of Fix for Bug 2622747
15301   l_scl_segment1               varchar2(60) := p_scl_segment1;
15302   l_scl_segment2               varchar2(60) := hr_api.g_varchar2 ;
15303   l_scl_segment3               varchar2(60) := hr_api.g_varchar2 ;
15304   l_scl_segment4               varchar2(60) := hr_api.g_varchar2 ;
15305   l_scl_segment5               varchar2(60) := hr_api.g_varchar2 ;
15306   l_scl_segment6               varchar2(60) := hr_api.g_varchar2 ;
15307   l_scl_segment7               varchar2(60) := hr_api.g_varchar2 ;
15308   l_scl_segment8               varchar2(60) := hr_api.g_varchar2 ;
15309   l_scl_segment9               varchar2(60) := hr_api.g_varchar2 ;
15310   l_scl_segment10              varchar2(60) := hr_api.g_varchar2 ;
15311   l_scl_segment11              varchar2(60) := hr_api.g_varchar2 ;
15312   l_scl_segment12              varchar2(60) := hr_api.g_varchar2 ;
15313   l_scl_segment13              varchar2(60) := hr_api.g_varchar2 ;
15314   l_scl_segment14              varchar2(60) := hr_api.g_varchar2 ;
15315   l_scl_segment15              varchar2(60) := hr_api.g_varchar2 ;
15316   l_scl_segment16              varchar2(60) := hr_api.g_varchar2 ;
15317   l_scl_segment17              varchar2(60) := hr_api.g_varchar2 ;
15318   l_scl_segment18              varchar2(60) := hr_api.g_varchar2 ;
15319   l_scl_segment19              varchar2(60) := hr_api.g_varchar2 ;
15320   l_scl_segment20              varchar2(60) := hr_api.g_varchar2 ;
15321   l_scl_segment21              varchar2(60) := hr_api.g_varchar2 ;
15322   l_scl_segment22              varchar2(60) := hr_api.g_varchar2 ;
15323   l_scl_segment23              varchar2(60) := hr_api.g_varchar2 ;
15324   l_scl_segment24              varchar2(60) := hr_api.g_varchar2 ;
15325   l_scl_segment25              varchar2(60) := hr_api.g_varchar2 ;
15326   l_scl_segment26              varchar2(60) := hr_api.g_varchar2 ;
15327   l_scl_segment27              varchar2(60) := hr_api.g_varchar2 ;
15328   l_scl_segment28              varchar2(60) := hr_api.g_varchar2 ;
15329   l_scl_segment29              varchar2(60) := hr_api.g_varchar2 ;
15330   l_scl_segment30              varchar2(60) := hr_api.g_varchar2 ;
15331   --
15332   lv_object_version_number        number := p_object_version_number ;
15333   lv_special_ceiling_step_id      number := p_special_ceiling_step_id ;
15334   lv_people_group_id              number := p_people_group_id ;
15335   lv_soft_coding_keyflex_id       number := p_soft_coding_keyflex_id ;
15336   --
15337 
15338 -- End of Fix for Bug 2622747
15339   l_element_entry_id1             number;  -- bug 4464072
15340   --
15341   -- bug 2359997 get pay_people_group segment values where
15342   -- people_group_id is known
15343   --
15344   cursor c_pgp_segments is
15345      select group_name,    --4103321
15346             segment1,
15347             segment2,
15348             segment3,
15349             segment4,
15350             segment5,
15351             segment6,
15352             segment7,
15353             segment8,
15354             segment9,
15355             segment10,
15356             segment11,
15357             segment12,
15358             segment13,
15359             segment14,
15360             segment15,
15361             segment16,
15362             segment17,
15363             segment18,
15364             segment19,
15365             segment20,
15366             segment21,
15367             segment22,
15368             segment23,
15369             segment24,
15370             segment25,
15371             segment26,
15372             segment27,
15373             segment28,
15374             segment29,
15375             segment30
15376      from   pay_people_groups
15377      where  people_group_id = l_people_group_id;
15378   --
15379   cursor csr_get_legislation_code is
15380     select bus.legislation_code
15381       from per_business_groups_perf bus
15382      where bus.business_group_id = l_business_group_id;
15383   --
15384   cursor csr_get_salary is
15385   select element_entry_id
15386   from   pay_element_entries_f
15387   where  assignment_id = p_assignment_id
15388   and    creator_type = 'SP'
15389   and    l_validation_start_date between
15390          effective_start_date and effective_end_date;
15391 
15392 -- start of fix for  bug 4464072
15393 cursor csr_chk_rec_exists is
15394   select element_entry_id
15395   from   pay_element_entries_f
15396   where  assignment_id = p_assignment_id
15397   and    creator_type = 'SP'
15398   and    (l_validation_start_date - 1) between
15399          effective_start_date and effective_end_date;
15400 
15401 -- end of fix for bug 4464072
15402   --
15403   cursor csr_grp_idsel is
15404   select bus.people_group_structure
15405   from  per_business_groups_perf bus
15406   where bus.business_group_id = l_business_group_id;
15407   --
15408   cursor get_sec_date_range is
15409   select asg.effective_start_date
15410   ,      asg.effective_end_date
15411   from   per_all_assignments_f asg
15412   where  asg.assignment_id=p_assignment_id
15413   and   ((sysdate between asg.effective_start_date
15414           and asg.effective_end_date)
15415          or
15416          (sysdate<asg.effective_start_date
15417           and not exists
15418           (select 1
15419            from per_all_assignments_f asg2
15420            where asg2.person_id=asg.person_id
15421            and asg2.period_of_service_id=asg.period_of_service_id
15422            and asg2.effective_start_date<asg.effective_start_date)
15423          )
15424         );
15425   --
15426   cursor csr_chk_grade_and_ceiling is
15427     select sps.step_id
15428     from   per_spinal_point_steps_f sps,
15429            per_grade_spines_f pgs
15430     where  pgs.grade_id       = p_grade_id
15431     and    pgs.grade_spine_id = sps.grade_spine_id
15432     and    sps.step_id        = p_special_ceiling_step_id;
15433   --
15434   l_sec_effective_start_date date;
15435   l_sec_effective_end_date date;
15436   --
15437   l_dt_update_mode     VARCHAR2(30);
15438   l_new_dt_update_mode VARCHAR2(30);
15439   --
15440   -- Start of bug 3553286
15441   l_job_id                       number := p_job_id;
15442   l_org_id                       number := p_organization_id;
15443   -- End of 3553286
15444   --
15445   -- Start of 4103321
15446     l_old_pgp_segments   c_pgp_segments%rowtype;
15447     l_old_conc_segs      pay_people_groups.group_name%type;
15448   -- End of 4103321
15449   --
15450 begin
15451   if g_debug then
15452    hr_utility.set_location('Entering:'|| l_proc, 30);
15453   end if;
15454 
15455   --
15456   -- Truncate the p_effective_date value to remove time element.
15457   --
15458   l_effective_date := trunc(p_effective_date);
15459   --
15460   -- Bug 944911
15461   -- Made p_group_name to be out param
15462   -- and add p_concat_segment to be IN
15463   -- in case of sec_asg alone made p_pgp_concat_segments as in param
15464   -- Replaced p_group_name by p_concat_segments
15465   --
15466   l_old_group_name := p_concat_segments;
15467   --
15468   -- Added as part of fix for bug 2473971
15469   --
15470   IF p_called_from_mass_update THEN
15471     --
15472     if g_debug then
15473       hr_utility.set_location(l_proc,40);
15474     end if;
15475     --
15476     l_dt_update_mode     := 'CORRECTION';
15477     l_new_dt_update_mode := p_datetrack_update_mode;
15478     --
15479   ELSE
15480     --
15481     if g_debug then
15482       hr_utility.set_location(l_proc,50);
15483     end if;
15484     --
15485     l_dt_update_mode     := p_datetrack_update_mode;
15486     l_new_dt_update_mode := p_datetrack_update_mode;
15487     --
15488   END IF;
15489   --
15490   -- Bug 2359997 - if p_people_group_id enters with
15491   -- a value then get segment values from pay_people_groups.
15492   --
15493   if g_debug then
15494     hr_utility.set_location(l_proc, 60);
15495   end if;
15496   --
15497   if l_people_group_id is null
15498   then
15499      l_pgp_null_ind := 0;
15500   else
15501     -- get segment values
15502      open c_pgp_segments;
15503       fetch c_pgp_segments into l_old_conc_segs,   -- 4103321
15504                                 l_pgp_segment1,
15505                                 l_pgp_segment2,
15506                                 l_pgp_segment3,
15507                                 l_pgp_segment4,
15508                                 l_pgp_segment5,
15509                                 l_pgp_segment6,
15510                                 l_pgp_segment7,
15511                                 l_pgp_segment8,
15512                                 l_pgp_segment9,
15513                                 l_pgp_segment10,
15514                                 l_pgp_segment11,
15515                                 l_pgp_segment12,
15516                                 l_pgp_segment13,
15517                                 l_pgp_segment14,
15518                                 l_pgp_segment15,
15519                                 l_pgp_segment16,
15520                                 l_pgp_segment17,
15521                                 l_pgp_segment18,
15522                                 l_pgp_segment19,
15523                                 l_pgp_segment20,
15524                                 l_pgp_segment21,
15525                                 l_pgp_segment22,
15526                                 l_pgp_segment23,
15527                                 l_pgp_segment24,
15528                                 l_pgp_segment25,
15529                                 l_pgp_segment26,
15530                                 l_pgp_segment27,
15531                                 l_pgp_segment28,
15532                                 l_pgp_segment29,
15533                                 l_pgp_segment30;
15534      close c_pgp_segments;
15535      l_pgp_null_ind := 1;
15536   end if;
15537 
15538 
15539   --
15540   -- Issue a savepoint.
15541   --
15542   savepoint update_emp_asg_criteria;
15543   --
15544   begin
15545   --
15546     -- Start of API User Hook for the before hook of update_emp_asg_criteria
15547     --
15548     hr_assignment_bk3.update_emp_asg_criteria_b
15549       (p_effective_date               => l_effective_date
15550       ,p_datetrack_update_mode        => l_dt_update_mode
15551       ,p_assignment_id                => p_assignment_id
15552       ,p_object_version_number        => p_object_version_number
15553       ,p_grade_id                     => p_grade_id
15554       ,p_position_id                  => p_position_id
15555       ,p_job_id                       => p_job_id
15556       ,p_payroll_id                   => p_payroll_id
15557       ,p_location_id                  => p_location_id
15558       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
15559       ,p_organization_id              => p_organization_id
15560       ,p_pay_basis_id                 => p_pay_basis_id
15561       ,p_segment1                     => l_pgp_segment1
15562       ,p_segment2                     => l_pgp_segment2
15563       ,p_segment3                     => l_pgp_segment3
15564       ,p_segment4                     => l_pgp_segment4
15565       ,p_segment5                     => l_pgp_segment5
15566       ,p_segment6                     => l_pgp_segment6
15567       ,p_segment7                     => l_pgp_segment7
15568       ,p_segment8                     => l_pgp_segment8
15569       ,p_segment9                     => l_pgp_segment9
15570       ,p_segment10                    => l_pgp_segment10
15571       ,p_segment11                    => l_pgp_segment11
15572       ,p_segment12                    => l_pgp_segment12
15573       ,p_segment13                    => l_pgp_segment13
15574       ,p_segment14                    => l_pgp_segment14
15575       ,p_segment15                    => l_pgp_segment15
15576       ,p_segment16                    => l_pgp_segment16
15577       ,p_segment17                    => l_pgp_segment17
15578       ,p_segment18                    => l_pgp_segment18
15579       ,p_segment19                    => l_pgp_segment19
15580       ,p_segment20                    => l_pgp_segment20
15581       ,p_segment21                    => l_pgp_segment21
15582       ,p_segment22                    => l_pgp_segment22
15583       ,p_segment23                    => l_pgp_segment23
15584       ,p_segment24                    => l_pgp_segment24
15585       ,p_segment25                    => l_pgp_segment25
15586       ,p_segment26                    => l_pgp_segment26
15587       ,p_segment27                    => l_pgp_segment27
15588       ,p_segment28                    => l_pgp_segment28
15589       ,p_segment29                    => l_pgp_segment29
15590       ,p_segment30                    => l_pgp_segment30
15591        --
15592        -- Bug 944911
15593        -- Amended p_group_name to p_concat_segments
15594        --
15595       ,p_concat_segments              => l_old_group_name
15596       ,p_employment_category          => p_employment_category
15597 -- Start of Fix for Bug 2622747
15598       ,p_contract_id                  => p_contract_id
15599       ,p_establishment_id             => p_establishment_id
15600       );
15601 -- End of Fix for Bug 2622747
15602 
15603   exception
15604     when hr_api.cannot_find_prog_unit then
15605       hr_api.cannot_find_prog_unit_error
15606         (p_module_name => 'UPDATE_EMP_ASG_CRITERIA'
15607         ,p_hook_type   => 'BP'
15608         );
15609     --
15610     -- End of API User Hook for the before hook of update_emp_asg_criteria
15611     --
15612   end;
15613   --
15614   if g_debug then
15615     hr_utility.set_location(l_proc, 70);
15616   end if;
15617   --
15618   l_object_version_number := p_object_version_number;
15619   --
15620   -- Validation in addition to Table Handlers
15621   --
15622   -- Retrieve current assignment details from database.
15623   --
15624   l_api_updating := per_asg_shd.api_updating
15625     (p_assignment_id         => p_assignment_id
15626     ,p_effective_date        => l_effective_date
15627     ,p_object_version_number => l_object_version_number);
15628   --
15629   if g_debug then
15630    hr_utility.set_location(l_proc, 80);
15631   end if;
15632   --
15633   if not l_api_updating
15634   then
15635     --
15636     if g_debug then
15637       hr_utility.set_location(l_proc, 90);
15638     end if;
15639     --
15640     -- As this is an updating API, the assignment should already exist.
15641     --
15642     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
15643     hr_utility.raise_error;
15644     -- else
15645     --
15646     if g_debug then
15647       hr_utility.set_location(l_proc, 100);
15648     end if;
15649     --
15650     -- l_people_group_id := per_asg_shd.g_old_rec.people_group_id; bug 2359997
15651   end if;
15652   --
15653   if g_debug then
15654    hr_utility.set_location(l_proc, 110);
15655   end if;
15656   --
15657   -- Check that the assignment is an employee assignment.
15658   --
15659   if per_asg_shd.g_old_rec.assignment_type <> 'E'
15660   then
15661     --
15662     if g_debug then
15663       hr_utility.set_location(l_proc, 120);
15664     end if;
15665     --
15666     hr_utility.set_message(801, 'HR_7948_ASG_ASG_NOT_EMP');
15667     hr_utility.raise_error;
15668   end if;
15669   --
15670   if g_debug then
15671    hr_utility.set_location(l_proc, 130);
15672   end if;
15673   --
15674   -- Removed as part of fix for bug
15675   --
15676   -- Process Logic
15677   --
15678   -- bug 2473971
15679   --
15680   -- Set special_ceiling_step_id to null if grade_id is being changed or is
15681   -- null.
15682   --
15683   --   if  per_asg_shd.g_old_rec.grade_id <> p_grade_id
15684   --       or p_grade_id is null
15685   --   then
15686   --     --
15687   --     --
15688   --     l_special_ceiling_step_id := null;
15689   --   else
15690   --     --
15691   --     --
15692   --     if p_special_ceiling_step_id = hr_api.g_number then
15693   --       --
15694   --       --
15695   --       l_special_ceiling_step_id := per_asg_shd.g_old_rec.special_ceiling_step_id;
15696   --       else
15697   --       --
15698   --       --
15699   --       l_special_ceiling_step_id := p_special_ceiling_step_id;
15700   --      end if;
15701   --     --
15702   --   end if;
15703   --
15704   --
15705   -- Process Logic
15706   --
15707   -- bug 2473971 and reworked to include
15708   -- cursor check as part of fix for bug 2564704
15709   --
15710   -- If the grade has been changed and the special ceiling
15711   -- id is populated then check that the ceiling id
15712   -- is for the grade.
15713   --
15714   --  Bug 348599 Added the condition to
15715   --  allow updation of p_ceiling_step_id even though
15716   --  the grade is assigned to assignment but not passed
15717   --  to api.
15718   --
15719   if (per_asg_shd.g_old_rec.grade_id <> p_grade_id AND
15720       p_grade_id <> hr_api.g_number AND -- 3485599
15721       p_special_ceiling_step_id IS NOT NULL) then
15722     --
15723     if g_debug then
15724       hr_utility.set_location(l_proc, 140);
15725     end if;
15726     --
15727     open csr_chk_grade_and_ceiling;
15728     fetch csr_chk_grade_and_ceiling into l_step_id;
15729     --
15730     -- If the ceiling id is not for the new grade then
15731     -- set the ceiling to be null
15732     --
15733     if csr_chk_grade_and_ceiling%NOTFOUND then
15734       --
15735       if g_debug then
15736         hr_utility.set_location(l_proc, 150);
15737       end if;
15738       --
15739       close csr_chk_grade_and_ceiling;
15740       --
15741       l_special_ceiling_step_id := NULL;
15742     --
15743     -- if the ceiling id is for the grade
15744     -- then set the local variable to the parameter.
15745     --
15746     else
15747       --
15748       if g_debug then
15749         hr_utility.set_location(l_proc, 160);
15750       end if;
15751       --
15752       close csr_chk_grade_and_ceiling;
15753       --
15754       l_special_ceiling_step_id := p_special_ceiling_step_id;
15755       --
15756     end if;
15757   --
15758   --  Set special_ceiling_step_id to null if grade_id
15759   --  is being changed or is null.
15760   --
15761   elsif p_grade_id is null then
15762     --
15763     if g_debug then
15764       hr_utility.set_location(l_proc, 170);
15765     end if;
15766     --
15767     l_special_ceiling_step_id := null;
15768     --
15769   else
15770     --
15771     if g_debug then
15772        hr_utility.set_location(l_proc, 180);
15773     end if;
15774     --
15775     if p_special_ceiling_step_id = hr_api.g_number then
15776       --
15777       if g_debug then
15778         hr_utility.set_location(l_proc, 190);
15779       end if;
15780       --
15781       l_special_ceiling_step_id := per_asg_shd.g_old_rec.special_ceiling_step_id;
15782       --
15783     else
15784       --
15785       if g_debug then
15786         hr_utility.set_location(l_proc, 200);
15787       end if;
15788       --
15789       l_special_ceiling_step_id := p_special_ceiling_step_id;
15790       --
15791     end if;
15792     --
15793   end if;
15794   if g_debug then
15795     hr_utility.set_location(l_proc, 210);
15796   end if;
15797   --
15798   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
15799   --
15800   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
15801   --
15802   -- Start of bug fix 3553286
15803   -- This procedure will return the job_id and organization_id of a position
15804   --
15805   if (p_called_from_mass_update = TRUE and p_position_id is not null) then
15806      if (l_job_id is null) or (l_org_id is null) then
15807          hr_psf_shd.get_position_job_org(p_position_id, p_effective_date,
15808                                          l_job_id, l_org_id);
15809      end if;
15810   end if;
15811   -- End of 3553286
15812   -- insert the profile options and effective date for the flexfield
15813   -- validation to work
15814   --
15815   --
15816   if (l_org_id = hr_api.g_number) then -- Bug 3553286
15817     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
15818   else
15819     l_organization_id:= l_org_id; -- Bug 3553286
15820   end if;
15821   --
15822   if (p_location_id=hr_api.g_number) then
15823     l_location_id:=per_asg_shd.g_old_rec.location_id;
15824   else
15825     l_location_id:=p_location_id;
15826   end if;
15827   --
15828   if g_debug then
15829     hr_utility.set_location(l_proc, 220);
15830   end if;
15831   --
15832   hr_kflex_utility.set_profiles
15833   (p_business_group_id => l_business_group_id
15834   ,p_assignment_id     => p_assignment_id
15835   ,p_organization_id   => l_organization_id
15836   ,p_location_id       => l_location_id);
15837   --
15838   if g_debug then
15839     hr_utility.set_location(l_proc, 230);
15840   end if;
15841   --
15842   hr_kflex_utility.set_session_date
15843   (p_effective_date => l_effective_date
15844   ,p_session_id     => l_session_id);
15845   --
15846   if g_debug then
15847     hr_utility.set_location(l_proc, 240);
15848   end if;
15849   --
15850   open csr_grp_idsel;
15851   fetch csr_grp_idsel
15852   into l_flex_num;
15853     if csr_grp_idsel%NOTFOUND then
15854        close csr_grp_idsel;
15855           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
15856           hr_utility.set_message_token('PROCEDURE', l_proc);
15857           hr_utility.set_message_token('STEP','5');
15858           hr_utility.raise_error;
15859      end if;
15860   close csr_grp_idsel;
15861   --
15862  if g_debug then
15863   hr_utility.set_location(l_proc, 250);
15864  end if;
15865   --
15866   -- Maintain the people group key flexfields.
15867   --
15868   -- Only call the flex code if a non-default value(includng null) is passed
15869   -- to the procedure.
15870   --
15871     --
15872   if  l_pgp_null_ind = 0 -- bug 2359997
15873   then
15874     --
15875     l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
15876     -- 4103321 modified the if statement
15877 
15878     if l_people_group_id is not null then
15879        open c_pgp_segments;
15880        fetch c_pgp_segments into l_old_pgp_segments;
15881        close c_pgp_segments;
15882     end if;
15883     --
15884     if   nvl(p_segment1, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment1, hr_api.g_varchar2)
15885       or nvl(p_segment2, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment2, hr_api.g_varchar2)
15886       or nvl(p_segment3, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment3, hr_api.g_varchar2)
15887       or nvl(p_segment4, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment4, hr_api.g_varchar2)
15888       or nvl(p_segment5, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment5, hr_api.g_varchar2)
15889       or nvl(p_segment6, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment6, hr_api.g_varchar2)
15890       or nvl(p_segment7, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment7, hr_api.g_varchar2)
15891       or nvl(p_segment8, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment8, hr_api.g_varchar2)
15892       or nvl(p_segment9, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment9, hr_api.g_varchar2)
15893       or nvl(p_segment10, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment10, hr_api.g_varchar2)
15894       or nvl(p_segment11, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment11, hr_api.g_varchar2)
15895       or nvl(p_segment12, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment12, hr_api.g_varchar2)
15896       or nvl(p_segment13, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment13, hr_api.g_varchar2)
15897       or nvl(p_segment14, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment14, hr_api.g_varchar2)
15898       or nvl(p_segment15, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment15, hr_api.g_varchar2)
15899       or nvl(p_segment16, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment16, hr_api.g_varchar2)
15900       or nvl(p_segment17, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment17, hr_api.g_varchar2)
15901       or nvl(p_segment18, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment18, hr_api.g_varchar2)
15902       or nvl(p_segment19, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment19, hr_api.g_varchar2)
15903       or nvl(p_segment20, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment20, hr_api.g_varchar2)
15904       or nvl(p_segment21, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment21, hr_api.g_varchar2)
15905       or nvl(p_segment22, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment22, hr_api.g_varchar2)
15906       or nvl(p_segment23, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment23, hr_api.g_varchar2)
15907       or nvl(p_segment24, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment24, hr_api.g_varchar2)
15908       or nvl(p_segment25, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment25, hr_api.g_varchar2)
15909       or nvl(p_segment26, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment26, hr_api.g_varchar2)
15910       or nvl(p_segment27, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment27, hr_api.g_varchar2)
15911       or nvl(p_segment28, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment28, hr_api.g_varchar2)
15912       or nvl(p_segment29, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment29, hr_api.g_varchar2)
15913       or nvl(p_segment30, hr_api.g_varchar2) <> nvl(l_old_pgp_segments.segment30, hr_api.g_varchar2)
15914       or nvl(l_old_group_name,hr_api.g_varchar2) <> nvl(l_old_pgp_segments.group_name, hr_api.g_varchar2)
15915       or l_people_group_id is  null -- fix for bug 4633742.
15916     then
15917       hr_kflex_utility.upd_or_sel_keyflex_comb
15918       (p_appl_short_name              => 'PAY'
15919       ,p_flex_code                    => 'GRP'
15920       ,p_flex_num                     => l_flex_num
15921       ,p_segment1                     => l_pgp_segment1
15922       ,p_segment2                     => l_pgp_segment2
15923       ,p_segment3                     => l_pgp_segment3
15924       ,p_segment4                     => l_pgp_segment4
15925       ,p_segment5                     => l_pgp_segment5
15926       ,p_segment6                     => l_pgp_segment6
15927       ,p_segment7                     => l_pgp_segment7
15928       ,p_segment8                     => l_pgp_segment8
15929       ,p_segment9                     => l_pgp_segment9
15930       ,p_segment10                    => l_pgp_segment10
15931       ,p_segment11                    => l_pgp_segment11
15932       ,p_segment12                    => l_pgp_segment12
15933       ,p_segment13                    => l_pgp_segment13
15934       ,p_segment14                    => l_pgp_segment14
15935       ,p_segment15                    => l_pgp_segment15
15936       ,p_segment16                    => l_pgp_segment16
15937       ,p_segment17                    => l_pgp_segment17
15938       ,p_segment18                    => l_pgp_segment18
15939       ,p_segment19                    => l_pgp_segment19
15940       ,p_segment20                    => l_pgp_segment20
15941       ,p_segment21                    => l_pgp_segment21
15942       ,p_segment22                    => l_pgp_segment22
15943       ,p_segment23                    => l_pgp_segment23
15944       ,p_segment24                    => l_pgp_segment24
15945       ,p_segment25                    => l_pgp_segment25
15946       ,p_segment26                    => l_pgp_segment26
15947       ,p_segment27                    => l_pgp_segment27
15948       ,p_segment28                    => l_pgp_segment28
15949       ,p_segment29                    => l_pgp_segment29
15950       ,p_segment30                    => l_pgp_segment30
15951       ,p_concat_segments_in           => l_old_group_name
15952       ,p_ccid                         => l_people_group_id
15953       ,p_concat_segments_out          => l_group_name
15954       );
15955     --
15956     --end if;--fix for bug 4633742.
15957     --
15958  if g_debug then
15959     hr_utility.set_location(l_proc, 260);
15960  end if;
15961     --
15962     -- update the combinations column
15963     --
15964     update_pgp_concat_segs
15965     (p_people_group_id        => l_people_group_id
15966     ,p_group_name             => l_group_name
15967     );
15968   --
15969   end if;
15970 end if;--fix for bug 4633742.
15971   --
15972  if g_debug then
15973   hr_utility.set_location(l_proc, 270);
15974  end if;
15975   --
15976 --
15977 -- Start of fix for Bug 2622747
15978 --
15979   validate_SCL (
15980    p_validate                     => FALSE -- Changed from p_validate to FALSE for fix of #3180527
15981   ,p_assignment_id                => p_assignment_id
15982   ,p_effective_date               => l_effective_date
15983   ,p_business_group_id            => l_business_group_id
15984   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
15985   ,p_concatenated_segments        => l_concatenated_segments
15986   ,p_concat_segments              => NULL
15987   ,p_segment1                     => l_scl_segment1
15988   ,p_segment2                     => l_scl_segment2
15989   ,p_segment3                     => l_scl_segment3
15990   ,p_segment4                     => l_scl_segment4
15991   ,p_segment5                     => l_scl_segment5
15992   ,p_segment6                     => l_scl_segment6
15993   ,p_segment7                     => l_scl_segment7
15994   ,p_segment8                     => l_scl_segment8
15995   ,p_segment9                     => l_scl_segment9
15996   ,p_segment10                    => l_scl_segment10
15997   ,p_segment11                    => l_scl_segment11
15998   ,p_segment12                    => l_scl_segment12
15999   ,p_segment13                    => l_scl_segment13
16000   ,p_segment14                    => l_scl_segment14
16001   ,p_segment15                    => l_scl_segment15
16002   ,p_segment16                    => l_scl_segment16
16003   ,p_segment17                    => l_scl_segment17
16004   ,p_segment18                    => l_scl_segment18
16005   ,p_segment19                    => l_scl_segment19
16006   ,p_segment20                    => l_scl_segment20
16007   ,p_segment21                    => l_scl_segment21
16008   ,p_segment22                    => l_scl_segment22
16009   ,p_segment23                    => l_scl_segment23
16010   ,p_segment24                    => l_scl_segment24
16011   ,p_segment25                    => l_scl_segment25
16012   ,p_segment26                    => l_scl_segment26
16013   ,p_segment27                    => l_scl_segment27
16014   ,p_segment28                    => l_scl_segment28
16015   ,p_segment29                    => l_scl_segment29
16016   ,p_segment30                    => l_scl_segment30
16017   );
16018 --End of fix for Bug 2622747
16019   --
16020   -- Update assignment.
16021   --
16022   per_asg_upd.upd
16023     (p_assignment_id                => p_assignment_id
16024     ,p_effective_start_date         => l_effective_start_date
16025     ,p_effective_end_date           => l_effective_end_date
16026     ,p_business_group_id            => l_business_group_id
16027     ,p_grade_id                     => p_grade_id
16028     ,p_position_id                  => p_position_id
16029     ,p_job_id                       => l_job_id -- Bug 3553286 p_job_id
16030     ,p_payroll_id                   => p_payroll_id
16031     ,p_location_id                  => p_location_id
16032     ,p_special_ceiling_step_id      => l_special_ceiling_step_id
16033     ,p_organization_id              => l_org_id -- Bug 3553286 p_organization_id
16034     ,p_people_group_id              => l_people_group_id
16035     ,p_pay_basis_id                 => p_pay_basis_id
16036     ,p_comment_id                   => l_comment_id
16037     ,p_employment_category          => p_employment_category
16038     ,p_payroll_id_updated           => l_payroll_id_updated
16039     ,p_other_manager_warning        => l_other_manager_warning
16040     ,p_no_managers_warning          => l_no_managers_warning
16041     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
16042     ,p_validation_start_date        => l_validation_start_date
16043     ,p_validation_end_date          => l_validation_end_date
16044     ,p_object_version_number        => l_object_version_number
16045     ,p_effective_date               => l_effective_date
16046     ,p_datetrack_mode               => l_dt_update_mode
16047     ,p_validate                     => FALSE
16048     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
16049     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
16050     ,p_contract_id                  => p_contract_id
16051     ,p_establishment_id             => p_establishment_id
16052     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
16053     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
16054     );
16055   --
16056  if g_debug then
16057   hr_utility.set_location(l_proc, 280);
16058  end if;
16059   --
16060   -- add to the security lists if neccesary
16061   --
16062   open get_sec_date_range;
16063   fetch get_sec_date_range into l_sec_effective_start_date,
16064                                 l_sec_effective_end_date;
16065   close get_sec_date_range;
16066   --
16067   if l_effective_date between l_sec_effective_start_date
16068   and l_sec_effective_end_date then
16069     if (per_asg_shd.g_old_rec.organization_id = l_business_group_id
16070     and l_org_id <> l_business_group_id) then  -- Bug 3553286
16071       hr_security_internal.clear_from_person_list
16072                            (per_asg_shd.g_old_rec.person_id);
16073     end if;
16074     hr_security_internal.add_to_person_list(l_effective_date,p_assignment_id);
16075   end if;
16076   --
16077  if g_debug then
16078   hr_utility.set_location(l_proc, 290);
16079  end if;
16080   --
16081   -- Bug 560185 fix starts
16082   --
16083   -- Delete the SP element entry if there is one when the pay_basis
16084   -- changes
16085   --
16086   if (p_pay_basis_id <> hr_api.g_number or
16087       p_pay_basis_id is null ) and
16088      (nvl(p_pay_basis_id,hr_api.g_number) <>
16089       nvl(per_asg_shd.g_old_rec.pay_basis_id, hr_api.g_number))
16090   then
16091  -- start of bug fix 4464072
16092  -- commented out the following part and newly defined
16093 
16094   /*  open csr_get_salary;
16095     fetch csr_get_salary into l_element_entry_id;
16096     if csr_get_salary%found then
16097       close csr_get_salary;
16098       --
16099       hr_entry_api.delete_element_entry
16100         ('DELETE'
16101         ,l_validation_start_date - 1
16102         ,l_element_entry_id);
16103       --
16104       l_entries_changed_warning := 'S';
16105     else
16106        close csr_get_salary;
16107     end if;
16108   end if; */
16109 
16110  open csr_get_salary;
16111     fetch csr_get_salary into l_element_entry_id;
16112     if csr_get_salary%found then
16113       close csr_get_salary;
16114 
16115       open csr_chk_rec_exists;
16116       fetch csr_chk_rec_exists into l_element_entry_id1;
16117 
16118   if csr_chk_rec_exists%found then
16119       close csr_chk_rec_exists;
16120 
16121       --
16122       hr_entry_api.delete_element_entry
16123         ('DELETE'
16124         ,l_validation_start_date - 1
16125         ,l_element_entry_id);
16126 
16127       else
16128 
16129       close csr_chk_rec_exists;
16130 
16131        hr_entry_api.delete_element_entry
16132         ('ZAP'
16133         ,l_validation_start_date
16134         ,l_element_entry_id);
16135 
16136  end if;
16137 
16138       l_entries_changed_warning := 'S';
16139     else
16140        close csr_get_salary;
16141     end if;
16142   end if;
16143   --
16144   -- end of fix for bug 4464072
16145   --
16146   -- Bug 560185 fix ends
16147   --
16148   -- Maintain standard element entries for this assignment.
16149   --
16150   -- Bug 638026 fix starts
16151   --
16152   if p_payroll_id = hr_api.g_number
16153    then
16154      --
16155  if g_debug then
16156      hr_utility.set_location(l_proc, 300);
16157  end if;
16158      --
16159      l_new_payroll_id := per_asg_shd.g_old_rec.payroll_id;
16160    else
16161      --
16162  if g_debug then
16163      hr_utility.set_location(l_proc, 310);
16164  end if;
16165      --
16166      l_new_payroll_id := p_payroll_id;
16167    end if;
16168   --
16169  if g_debug then
16170   hr_utility.set_location(l_proc, 320);
16171  end if;
16172   --
16173   hr_utility.set_location('p_old_pg_id :'||to_char(per_asg_shd.g_old_rec.payroll_id),325);
16174   hr_utility.set_location('p_new_pg_id :'||to_char(l_people_group_id),325);
16175   --
16176   hrentmnt.maintain_entries_asg
16177     (p_assignment_id                => p_assignment_id
16178     ,p_old_payroll_id               => per_asg_shd.g_old_rec.payroll_id
16179     ,p_new_payroll_id               => l_new_payroll_id
16180     ,p_business_group_id            => l_business_group_id
16181     ,p_operation                    => 'ASG_CRITERIA'
16182     ,p_actual_term_date             => null
16183     ,p_last_standard_date           => null
16184     ,p_final_process_date           => null
16185     ,p_dt_mode                      => l_new_dt_update_mode
16186     ,p_validation_start_date        => l_validation_start_date
16187     ,p_validation_end_date          => l_validation_end_date
16188     ,p_entries_changed              => l_entries_changed
16189     ,p_old_people_group_id          => per_asg_shd.g_old_rec.people_group_id
16190     ,p_new_people_group_id          => l_people_group_id
16191     );
16192   --
16193   -- Bug 630826 fix ends
16194   --
16195  if g_debug then
16196   hr_utility.set_location(l_proc, 330);
16197  end if;
16198   --
16199   if l_entries_changed_warning <> 'S' then
16200     l_entries_changed_warning := nvl(l_entries_changed, 'N');
16201   end if;
16202   --
16203   IF    (    per_asg_shd.g_old_rec.grade_id is not null
16204          AND p_grade_id is null)
16205      OR (    per_asg_shd.g_old_rec.grade_id is not null
16206          AND p_grade_id is not null
16207          AND per_asg_shd.g_old_rec.grade_id <> p_grade_id
16208          AND p_grade_id <> hr_api.g_number)
16209   then
16210     --
16211  if g_debug then
16212     hr_utility.set_location(l_proc, 340);
16213  end if;
16214     --
16215     -- Maintain spinal point placements.
16216     --
16217     hr_assignment_internal.maintain_spp_asg
16218       (p_assignment_id                => p_assignment_id
16219       ,p_datetrack_mode               => l_new_dt_update_mode
16220       ,p_validation_start_date        => l_validation_start_date
16221       ,p_validation_end_date          => l_validation_end_date
16222       ,p_grade_id		                   => p_grade_id
16223       ,p_spp_delete_warning           => l_spp_delete_warning
16224       );
16225   else
16226     --
16227  if g_debug then
16228     hr_utility.set_location(l_proc, 350);
16229  end if;
16230     --
16231     -- No SPPs to maintain.
16232     --
16233     l_spp_delete_warning := FALSE;
16234   end if;
16235   --
16236  if g_debug then
16237   hr_utility.set_location(l_proc, 360);
16238  end if;
16239   --
16240   -- IF GB legislation and payroll has changed, then delete latest balance
16241   -- values,
16242   --
16243   open  csr_get_legislation_code;
16244   fetch csr_get_legislation_code
16245    into l_legislation_code;
16246   --
16247   if csr_get_legislation_code%NOTFOUND then
16248     --
16249     close csr_get_legislation_code;
16250     --
16251  if g_debug then
16252     hr_utility.set_location(l_proc, 370);
16253  end if;
16254     --
16255     -- This should never happen!
16256     --
16257     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
16258     hr_utility.set_message_token('PROCEDURE', l_proc);
16259     hr_utility.set_message_token('STEP', '215');
16260     hr_utility.raise_error;
16261   end if;
16262   --
16263   close csr_get_legislation_code;
16264   --
16265  if g_debug then
16266   hr_utility.set_location(l_proc, 380);
16267  end if;
16268   --
16269   if  l_legislation_code = 'GB'
16270   and l_payroll_id_updated
16271   then
16272     --
16273  if g_debug then
16274     hr_utility.set_location(l_proc, 390);
16275  end if;
16276     --
16277     -- Delete latest balance values.
16278     --
16279     py_gb_asg.payroll_transfer
16280       (p_assignment_id => p_assignment_id);
16281     --
16282     -- When GB legislation, and the business group and the payroll has changed,
16283     -- set the Print P45 flag on the assignments extra info flexfield, and set
16284     -- the changed tax district warning out parameter.
16285     -- This functionality will be supported at a later date.
16286     --
16287     l_tax_district_changed_warning := FALSE;
16288   else
16289     --
16290  if g_debug then
16291     hr_utility.set_location(l_proc, 400);
16292  end if;
16293     --
16294     l_tax_district_changed_warning := FALSE;
16295   end if;
16296   --
16297  if g_debug then
16298   hr_utility.set_location(l_proc, 410);
16299  end if;
16300   --
16301   --
16302   begin
16303     --
16304     -- Start of API User Hook for the after hook of update_emp_asg_criteria
16305     --
16306     hr_assignment_bk3.update_emp_asg_criteria_a
16307       (p_effective_date               => l_effective_date
16308       ,p_datetrack_update_mode        => l_dt_update_mode
16309       ,p_assignment_id                => p_assignment_id
16310       ,p_object_version_number        => p_object_version_number
16311       ,p_grade_id                     => p_grade_id
16312       ,p_position_id                  => p_position_id
16313       ,p_job_id                       => l_job_id -- Bug 3553286 p_job_id
16314       ,p_payroll_id                   => p_payroll_id
16315       ,p_location_id                  => p_location_id
16316       ,p_special_ceiling_step_id      => p_special_ceiling_step_id
16317       ,p_organization_id              => l_org_id -- Bug 3553286 p_organization_id
16318       ,p_pay_basis_id                 => p_pay_basis_id
16319       ,p_segment1                     => l_pgp_segment1
16320       ,p_segment2                     => l_pgp_segment2
16321       ,p_segment3                     => l_pgp_segment3
16322       ,p_segment4                     => l_pgp_segment4
16323       ,p_segment5                     => l_pgp_segment5
16324       ,p_segment6                     => l_pgp_segment6
16325       ,p_segment7                     => l_pgp_segment7
16326       ,p_segment8                     => l_pgp_segment8
16327       ,p_segment9                     => l_pgp_segment9
16328       ,p_segment10                    => l_pgp_segment10
16329       ,p_segment11                    => l_pgp_segment11
16330       ,p_segment12                    => l_pgp_segment12
16331       ,p_segment13                    => l_pgp_segment13
16332       ,p_segment14                    => l_pgp_segment14
16333       ,p_segment15                    => l_pgp_segment15
16334       ,p_segment16                    => l_pgp_segment16
16335       ,p_segment17                    => l_pgp_segment17
16336       ,p_segment18                    => l_pgp_segment18
16337       ,p_segment19                    => l_pgp_segment19
16338       ,p_segment20                    => l_pgp_segment20
16339       ,p_segment21                    => l_pgp_segment21
16340       ,p_segment22                    => l_pgp_segment22
16341       ,p_segment23                    => l_pgp_segment23
16342       ,p_segment24                    => l_pgp_segment24
16343       ,p_segment25                    => l_pgp_segment25
16344       ,p_segment26                    => l_pgp_segment26
16345       ,p_segment27                    => l_pgp_segment27
16346       ,p_segment28                    => l_pgp_segment28
16347       ,p_segment29                    => l_pgp_segment29
16348       ,p_segment30                    => l_pgp_segment30
16349       ,p_group_name                   => l_group_name
16350       ,p_employment_category          => p_employment_category
16351       ,p_effective_start_date         => l_effective_start_date
16352       ,p_effective_end_date           => l_effective_end_date
16353       ,p_people_group_id              => l_people_group_id
16354       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
16355       ,p_other_manager_warning        => l_other_manager_warning
16356       ,p_spp_delete_warning           => l_spp_delete_warning
16357       ,p_entries_changed_warning      => l_entries_changed_warning
16358       ,p_tax_district_changed_warning => l_tax_district_changed_warning
16359        --
16360        -- Bug 944911
16361        -- Added the new in param
16362        --
16363       ,p_concat_segments              => l_old_group_name
16364 -- Start of Fix for Bug 2622747
16365       ,p_contract_id                  => p_contract_id
16366       ,p_establishment_id             => p_establishment_id
16367       ,p_concatenated_segments        => l_concatenated_segments
16368       ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
16369       ,p_scl_segment1                 => l_scl_segment1
16370 -- End of Fix for Bug 2622747
16371       );
16372   exception
16373     when hr_api.cannot_find_prog_unit then
16374       hr_api.cannot_find_prog_unit_error
16375         (p_module_name => 'UPDATE_EMP_ASG_CRITERIA'
16376         ,p_hook_type   => 'AP'
16377         );
16378     --
16379     -- End of API User Hook for the after hook of update_emp_asg_criteria
16380     --
16381   end;
16382 
16383   --
16384   -- call pqh post process procedure -- bug 2999562
16385   --
16386   pqh_gsp_post_process.call_pp_from_assignments(
16387       p_effective_date    => p_effective_date
16388      ,p_assignment_id     => p_assignment_id
16389      ,p_date_track_mode   => p_datetrack_update_mode
16390      ,p_warning_mesg      => l_gsp_post_process_warning
16391   );
16392 
16393   --
16394   --
16395   -- When in validation only mode raise the Validate_Enabled exception
16396   --
16397   if p_validate then
16398     raise hr_api.validate_enabled;
16399   end if;
16400   --
16401   -- Set all output arguments
16402   --
16403   p_effective_end_date           := l_effective_end_date;
16404   p_effective_start_date         := l_effective_start_date;
16405   p_people_group_id              := l_people_group_id;
16406   p_group_name                   := l_group_name;
16407   p_entries_changed_warning      := l_entries_changed_warning;
16408   p_object_version_number        := l_object_version_number;
16409   p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
16410   p_other_manager_warning        := l_other_manager_warning;
16411   p_special_ceiling_step_id      := l_special_ceiling_step_id;
16412   p_spp_delete_warning           := l_spp_delete_warning;
16413   p_tax_district_changed_warning := l_tax_district_changed_warning;
16414   p_gsp_post_process_warning     := l_gsp_post_process_warning; -- bug 2999562
16415   --
16416   --
16417   -- remove data from the session table
16418   hr_kflex_utility.unset_session_date
16419     (p_session_id     => l_session_id);
16420   --
16421  if g_debug then
16422   hr_utility.set_location(' Leaving:'||l_proc, 997);
16423  end if;
16424   --
16425 exception
16426   when hr_api.validate_enabled then
16427     --
16428  if g_debug then
16429     hr_utility.set_location(' Leaving:'||l_proc, 998);
16430  end if;
16431     --
16432     -- As the Validate_Enabled exception has been raised
16433     -- we must rollback to the savepoint
16434     --
16435     ROLLBACK TO update_emp_asg_criteria;
16436     --
16437     -- Only set output warning arguments
16438     -- (Any key or derived arguments must be set to null
16439     -- when validation only mode is being used.)
16440     --
16441     p_effective_end_date           := null;
16442     p_effective_start_date         := null;
16443     p_entries_changed_warning      := l_entries_changed_warning;
16444     p_group_name                   := l_old_group_name;
16445     p_object_version_number        := p_object_version_number;
16446     p_org_now_no_manager_warning   := l_org_now_no_manager_warning;
16447     p_other_manager_warning        := l_other_manager_warning;
16448     p_people_group_id              := null;
16449     p_special_ceiling_step_id      := p_special_ceiling_step_id;
16450     p_spp_delete_warning           := l_spp_delete_warning;
16451     p_tax_district_changed_warning := l_tax_district_changed_warning;
16452     p_concatenated_segments        := l_concatenated_segments;
16453     p_soft_coding_keyflex_id       := l_soft_coding_keyflex_id;
16454     p_gsp_post_process_warning     := l_gsp_post_process_warning; -- bug 2999562
16455     --
16456     if l_pgp_null_ind = 0   -- bug 2359997 only re-set to null if
16457                             -- p_people_group_id came in as null.
16458     then
16459        p_people_group_id    := null;
16460     end if;
16461     --
16462   when others then
16463     --
16464  if g_debug then
16465     hr_utility.set_location(' Leaving:'||l_proc, 999);
16466  end if;
16467     --
16468     -- A validation or unexpected error has occurred
16469     --
16470     -- Added as part of fix to bug 632479
16471     --
16472     p_object_version_number        := lv_object_version_number ;
16473     p_special_ceiling_step_id      := lv_special_ceiling_step_id ;
16474     p_people_group_id              := lv_people_group_id ;
16475     p_soft_coding_keyflex_id       := lv_soft_coding_keyflex_id ;
16476 
16477     p_group_name                      := null;
16478     p_effective_start_date            := null;
16479     p_effective_end_date              := null;
16480     p_org_now_no_manager_warning      := null;
16481     p_other_manager_warning           := null;
16482     p_spp_delete_warning              := null;
16483     p_entries_changed_warning         := null;
16484     p_tax_district_changed_warning    := null;
16485     p_concatenated_segments           := null;
16486     p_gsp_post_process_warning        := null;
16487 
16488     ROLLBACK TO update_emp_asg_criteria;
16489     raise;
16490     --
16491     -- End of fix.
16492     --
16493 end update_emp_asg_criteria;
16494 --
16495 -- ----------------------------------------------------------------------------
16496 -- |--------------------------< update_apl_asg >------------------------------|
16497 -- ----------------------------------------------------------------------------
16498 --
16499 -- added new parameters notice_period, units, employee_category,
16500 -- work_at_home and job_source on 05-OCT-01
16501 
16502 procedure update_apl_asg
16503   (p_validate                     in     boolean
16504   ,p_effective_date               in     date
16505   ,p_datetrack_update_mode        in     varchar2
16506   ,p_assignment_id                in     number
16507   ,p_object_version_number        in out nocopy number
16508   ,p_recruiter_id                 in     number
16509   ,p_grade_id                     in     number
16510   ,p_position_id                  in     number
16511   ,p_job_id                       in     number
16512   ,p_payroll_id                   in     number
16513   ,p_location_id                  in     number
16514   ,p_person_referred_by_id        in     number
16515   ,p_supervisor_id                in     number
16516   ,p_special_ceiling_step_id      in     number
16517   ,p_recruitment_activity_id      in     number
16518   ,p_source_organization_id       in     number
16519   ,p_organization_id              in     number
16520   ,p_vacancy_id                   in     number
16521   ,p_pay_basis_id                 in     number
16522   ,p_application_id               in     number
16523   ,p_change_reason                in     varchar2
16524   ,p_assignment_status_type_id    in     number
16525   ,p_comments                     in     varchar2
16526   ,p_date_probation_end           in     date
16527   ,p_default_code_comb_id         in     number
16528   ,p_employment_category          in     varchar2
16529   ,p_frequency                    in     varchar2
16530   ,p_internal_address_line        in     varchar2
16531   ,p_manager_flag                 in     varchar2
16532   ,p_normal_hours                 in     number
16533   ,p_perf_review_period           in     number
16534   ,p_perf_review_period_frequency in     varchar2
16535   ,p_probation_period             in     number
16536   ,p_probation_unit               in     varchar2
16537   ,p_sal_review_period            in     number
16538   ,p_sal_review_period_frequency  in     varchar2
16539   ,p_set_of_books_id              in     number
16540   ,p_source_type                  in     varchar2
16541   ,p_time_normal_finish           in     varchar2
16542   ,p_time_normal_start            in     varchar2
16543   ,p_bargaining_unit_code         in     varchar2
16544   ,p_ass_attribute_category       in     varchar2
16545   ,p_ass_attribute1               in     varchar2
16546   ,p_ass_attribute2               in     varchar2
16547   ,p_ass_attribute3               in     varchar2
16548   ,p_ass_attribute4               in     varchar2
16549   ,p_ass_attribute5               in     varchar2
16550   ,p_ass_attribute6               in     varchar2
16551   ,p_ass_attribute7               in     varchar2
16552   ,p_ass_attribute8               in     varchar2
16553   ,p_ass_attribute9               in     varchar2
16554   ,p_ass_attribute10              in     varchar2
16555   ,p_ass_attribute11              in     varchar2
16556   ,p_ass_attribute12              in     varchar2
16557   ,p_ass_attribute13              in     varchar2
16558   ,p_ass_attribute14              in     varchar2
16559   ,p_ass_attribute15              in     varchar2
16560   ,p_ass_attribute16              in     varchar2
16561   ,p_ass_attribute17              in     varchar2
16562   ,p_ass_attribute18              in     varchar2
16563   ,p_ass_attribute19              in     varchar2
16564   ,p_ass_attribute20              in     varchar2
16565   ,p_ass_attribute21              in     varchar2
16566   ,p_ass_attribute22              in     varchar2
16567   ,p_ass_attribute23              in     varchar2
16568   ,p_ass_attribute24              in     varchar2
16569   ,p_ass_attribute25              in     varchar2
16570   ,p_ass_attribute26              in     varchar2
16571   ,p_ass_attribute27              in     varchar2
16572   ,p_ass_attribute28              in     varchar2
16573   ,p_ass_attribute29              in     varchar2
16574   ,p_ass_attribute30              in     varchar2
16575   ,p_title                        in     varchar2
16576   ,p_scl_segment1                 in     varchar2
16577   ,p_scl_segment2                 in     varchar2
16578   ,p_scl_segment3                 in     varchar2
16579   ,p_scl_segment4                 in     varchar2
16580   ,p_scl_segment5                 in     varchar2
16581   ,p_scl_segment6                 in     varchar2
16582   ,p_scl_segment7                 in     varchar2
16583   ,p_scl_segment8                 in     varchar2
16584   ,p_scl_segment9                 in     varchar2
16585   ,p_scl_segment10                in     varchar2
16586   ,p_scl_segment11                in     varchar2
16587   ,p_scl_segment12                in     varchar2
16588   ,p_scl_segment13                in     varchar2
16589   ,p_scl_segment14                in     varchar2
16590   ,p_scl_segment15                in     varchar2
16591   ,p_scl_segment16                in     varchar2
16592   ,p_scl_segment17                in     varchar2
16593   ,p_scl_segment18                in     varchar2
16594   ,p_scl_segment19                in     varchar2
16595   ,p_scl_segment20                in     varchar2
16596   ,p_scl_segment21                in     varchar2
16597   ,p_scl_segment22                in     varchar2
16598   ,p_scl_segment23                in     varchar2
16599   ,p_scl_segment24                in     varchar2
16600   ,p_scl_segment25                in     varchar2
16601   ,p_scl_segment26                in     varchar2
16602   ,p_scl_segment27                in     varchar2
16603   ,p_scl_segment28                in     varchar2
16604   ,p_scl_segment29                in     varchar2
16605   ,p_scl_segment30                in     varchar2
16606 -- Bug 944911
16607 -- Amended p_scl_concatenated_segments to be an out instead of in out
16608 -- Added p_scl_concat_segments ( in param )
16609 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
16610   ,p_scl_concat_segments          in     varchar2
16611   ,p_concatenated_segments           out nocopy varchar2
16612   ,p_pgp_segment1                 in     varchar2
16613   ,p_pgp_segment2                 in     varchar2
16614   ,p_pgp_segment3                 in     varchar2
16615   ,p_pgp_segment4                 in     varchar2
16616   ,p_pgp_segment5                 in     varchar2
16617   ,p_pgp_segment6                 in     varchar2
16618   ,p_pgp_segment7                 in     varchar2
16619   ,p_pgp_segment8                 in     varchar2
16620   ,p_pgp_segment9                 in     varchar2
16621   ,p_pgp_segment10                in     varchar2
16622   ,p_pgp_segment11                in     varchar2
16623   ,p_pgp_segment12                in     varchar2
16624   ,p_pgp_segment13                in     varchar2
16625   ,p_pgp_segment14                in     varchar2
16626   ,p_pgp_segment15                in     varchar2
16627   ,p_pgp_segment16                in     varchar2
16628   ,p_pgp_segment17                in     varchar2
16629   ,p_pgp_segment18                in     varchar2
16630   ,p_pgp_segment19                in     varchar2
16631   ,p_pgp_segment20                in     varchar2
16632   ,p_pgp_segment21                in     varchar2
16633   ,p_pgp_segment22                in     varchar2
16634   ,p_pgp_segment23                in     varchar2
16635   ,p_pgp_segment24                in     varchar2
16636   ,p_pgp_segment25                in     varchar2
16637   ,p_pgp_segment26                in     varchar2
16638   ,p_pgp_segment27                in     varchar2
16639   ,p_pgp_segment28                in     varchar2
16640   ,p_pgp_segment29                in     varchar2
16641   ,p_pgp_segment30                in     varchar2
16642 -- Bug 944911
16643 -- Made p_group_name to be out param
16644 -- and add p_concat_segment to be IN
16645 -- in case of sec_asg alone made p_pgp_concat_segments as in param
16646   ,p_concat_segments              in     varchar2
16647   ,p_contract_id                  in     number
16648   ,p_establishment_id             in     number
16649   ,p_collective_agreement_id      in     number
16650   ,p_cagr_id_flex_num             in     number
16651   ,p_cag_segment1                 in     varchar2
16652   ,p_cag_segment2                 in     varchar2
16653   ,p_cag_segment3                 in     varchar2
16654   ,p_cag_segment4                 in     varchar2
16655   ,p_cag_segment5                 in     varchar2
16656   ,p_cag_segment6                 in     varchar2
16657   ,p_cag_segment7                 in     varchar2
16658   ,p_cag_segment8                 in     varchar2
16659   ,p_cag_segment9                 in     varchar2
16660   ,p_cag_segment10                in     varchar2
16661   ,p_cag_segment11                in     varchar2
16662   ,p_cag_segment12                in     varchar2
16663   ,p_cag_segment13                in     varchar2
16664   ,p_cag_segment14                in     varchar2
16665   ,p_cag_segment15                in     varchar2
16666   ,p_cag_segment16                in     varchar2
16667   ,p_cag_segment17                in     varchar2
16668   ,p_cag_segment18                in     varchar2
16669   ,p_cag_segment19                in     varchar2
16670   ,p_cag_segment20                in     varchar2
16671   ,p_notice_period		  in     number
16672   ,p_notice_period_uom	      	  in     varchar2
16673   ,p_employee_category	          in     varchar2
16674   ,p_work_at_home		  in     varchar2
16675   ,p_job_post_source_name	  in     varchar2
16676   ,p_posting_content_id           in     number
16677   ,p_applicant_rank               in     number
16678   ,p_grade_ladder_pgm_id          in     number
16679   ,p_supervisor_assignment_id     in     number
16680   ,p_cagr_grade_def_id            in out nocopy number
16681   ,p_cagr_concatenated_segments      out nocopy varchar2
16682   ,p_group_name                      out nocopy varchar2
16683   ,p_comment_id                      out nocopy number
16684   ,p_people_group_id              in out nocopy number
16685   ,p_soft_coding_keyflex_id       in out nocopy number
16686   ,p_effective_start_date            out nocopy date
16687   ,p_effective_end_date              out nocopy date
16688  ) is
16689   --
16690   -- Declare cursors and local variables
16691   --
16692   -- Out variables
16693   --
16694   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
16695   l_business_group_id          per_all_assignments_f.business_group_id%TYPE;
16696   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
16697   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
16698   l_dummy_payroll              boolean;
16699   l_dummy_manager1             boolean;
16700   l_dummy_manager2             boolean;
16701   l_dummy_manager3             boolean;
16702   l_hourly_salaried_warning    boolean;
16703   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
16704   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
16705   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
16706   l_effective_date             date;
16707   l_date_probation_end         date;
16708   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
16709   l_organization_id            per_all_assignments_f.organization_id%type;
16710   l_location_id                per_all_assignments_f.location_id%type;
16711   l_cagr_grade_def_id          per_cagr_grades_def.cagr_grade_def_id%TYPE         := p_cagr_grade_def_id;
16712   l_cagr_id_flex_num           per_cagr_grades_def.id_flex_num%TYPE;
16713   l_unused_start_date          date;
16714   l_unused_end_date            date;
16715   l_cagr_concatenated_segments varchar2(2000);
16716   --
16717   -- Internal working variables
16718   --
16719   l_assignment_status_id       number;
16720   l_asg_status_ovn             number;
16721   --
16722   l_people_group_id            per_all_assignments_f.people_group_id%TYPE         := p_people_group_id;
16723   l_group_name                 pay_people_groups.group_name%TYPE;
16724   l_old_group_name             pay_people_groups.group_name%TYPE;
16725   l_soft_coding_keyflex_id     per_all_assignments_f.soft_coding_keyflex_id%TYPE  := p_soft_coding_keyflex_id;
16726   l_scl_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE  ;
16727   l_old_scl_conc_segments hr_soft_coding_keyflex.concatenated_segments%TYPE;
16728   l_proc                       varchar2(72) := g_package||'update_apl_asg';
16729   l_api_updating               boolean;
16730   l_session_id                 number;
16731   l_old_asg_status per_assignment_status_types.per_system_status%type;
16732   l_new_asg_status per_assignment_status_types.per_system_status%type;
16733   --
16734   -- bug 2230915 new variables to indicate whether key flex id parameters
16735   -- enter the program with a value.
16736   --
16737   l_pgp_null_ind               number(1) := 0;
16738   l_scl_null_ind               number(1) := 0;
16739   l_cag_null_ind               number(1) := 0;
16740   --
16741   -- bug 2230915 new variables for derived values where key flex id is known.
16742   --
16743   l_scl_segment1               varchar2(60) := p_scl_segment1;
16744   l_scl_segment2               varchar2(60) := p_scl_segment2;
16745   l_scl_segment3               varchar2(60) := p_scl_segment3;
16746   l_scl_segment4               varchar2(60) := p_scl_segment4;
16747   l_scl_segment5               varchar2(60) := p_scl_segment5;
16748   l_scl_segment6               varchar2(60) := p_scl_segment6;
16749   l_scl_segment7               varchar2(60) := p_scl_segment7;
16750   l_scl_segment8               varchar2(60) := p_scl_segment8;
16751   l_scl_segment9               varchar2(60) := p_scl_segment9;
16752   l_scl_segment10              varchar2(60) := p_scl_segment10;
16753   l_scl_segment11              varchar2(60) := p_scl_segment11;
16754   l_scl_segment12              varchar2(60) := p_scl_segment12;
16755   l_scl_segment13              varchar2(60) := p_scl_segment13;
16756   l_scl_segment14              varchar2(60) := p_scl_segment14;
16757   l_scl_segment15              varchar2(60) := p_scl_segment15;
16758   l_scl_segment16              varchar2(60) := p_scl_segment16;
16759   l_scl_segment17              varchar2(60) := p_scl_segment17;
16760   l_scl_segment18              varchar2(60) := p_scl_segment18;
16761   l_scl_segment19              varchar2(60) := p_scl_segment19;
16762   l_scl_segment20              varchar2(60) := p_scl_segment20;
16763   l_scl_segment21              varchar2(60) := p_scl_segment21;
16764   l_scl_segment22              varchar2(60) := p_scl_segment22;
16765   l_scl_segment23              varchar2(60) := p_scl_segment23;
16766   l_scl_segment24              varchar2(60) := p_scl_segment24;
16767   l_scl_segment25              varchar2(60) := p_scl_segment25;
16768   l_scl_segment26              varchar2(60) := p_scl_segment26;
16769   l_scl_segment27              varchar2(60) := p_scl_segment27;
16770   l_scl_segment28              varchar2(60) := p_scl_segment28;
16771   l_scl_segment29              varchar2(60) := p_scl_segment29;
16772   l_scl_segment30              varchar2(60) := p_scl_segment30;
16773   --
16774   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
16775   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
16776   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
16777   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
16778   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
16779   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
16780   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
16781   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
16782   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
16783   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
16784   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
16785   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
16786   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
16787   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
16788   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
16789   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
16790   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
16791   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
16792   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
16793   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
16794   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
16795   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
16796   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
16797   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
16798   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
16799   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
16800   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
16801   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
16802   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
16803   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
16804   --
16805   l_cag_segment1               varchar2(60) := p_cag_segment1;
16806   l_cag_segment2               varchar2(60) := p_cag_segment2;
16807   l_cag_segment3               varchar2(60) := p_cag_segment3;
16808   l_cag_segment4               varchar2(60) := p_cag_segment4;
16809   l_cag_segment5               varchar2(60) := p_cag_segment5;
16810   l_cag_segment6               varchar2(60) := p_cag_segment6;
16811   l_cag_segment7               varchar2(60) := p_cag_segment7;
16812   l_cag_segment8               varchar2(60) := p_cag_segment8;
16813   l_cag_segment9               varchar2(60) := p_cag_segment9;
16814   l_cag_segment10              varchar2(60) := p_cag_segment10;
16815   l_cag_segment11              varchar2(60) := p_cag_segment11;
16816   l_cag_segment12              varchar2(60) := p_cag_segment12;
16817   l_cag_segment13              varchar2(60) := p_cag_segment13;
16818   l_cag_segment14              varchar2(60) := p_cag_segment14;
16819   l_cag_segment15              varchar2(60) := p_cag_segment15;
16820   l_cag_segment16              varchar2(60) := p_cag_segment16;
16821   l_cag_segment17              varchar2(60) := p_cag_segment17;
16822   l_cag_segment18              varchar2(60) := p_cag_segment18;
16823   l_cag_segment19              varchar2(60) := p_cag_segment19;
16824   l_cag_segment20              varchar2(60) := p_cag_segment20;
16825   --
16826   lv_object_version_number     number := p_object_version_number ;
16827   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
16828   lv_people_group_id           number := p_people_group_id ;
16829   lv_soft_coding_keyflex_id    number := p_soft_coding_keyflex_id ;
16830 
16831   --
16832   cursor csr_old_asg_status is
16833   select ast.per_system_status
16834   from per_assignment_status_types ast,
16835        per_all_assignments_f asg
16836   where ast.assignment_status_type_id = asg.assignment_status_type_id
16837   and   asg.assignment_id = p_assignment_id
16838   and   l_effective_date between asg.effective_start_date and asg.effective_end_date;
16839   --
16840   cursor csr_new_asg_status is
16841   select ast.per_system_status
16842   from per_assignment_status_types ast
16843   where ast.assignment_status_type_id = p_assignment_status_type_id;
16844   --
16845   --
16846   cursor csr_grp_idsel is
16847     select bus.people_group_structure
16848      from  per_business_groups_perf bus
16849      where bus.business_group_id = l_business_group_id;
16850   --
16851   cursor csr_scl_idsel is
16852     select plr.rule_mode                       id_flex_num
16853     from   pay_legislation_rules               plr,
16854            per_business_groups_perf            pgr
16855     where  plr.legislation_code                = pgr.legislation_code
16856     and    pgr.business_group_id               = l_business_group_id
16857     and    plr.rule_type                       = 'S'
16858     and    exists
16859           (select 1
16860            from   fnd_segment_attribute_values fsav
16861            where  fsav.id_flex_num             = plr.rule_mode
16862            and    fsav.application_id          = 800
16863            and    fsav.id_flex_code            = 'SCL'
16864            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
16865            and    fsav.attribute_value         = 'Y')
16866     and    exists
16867           (select 1
16868            from   pay_legislation_rules        plr2
16869            where  plr2.legislation_code        = plr.legislation_code
16870            and    plr2.rule_type               = 'SDL'
16871            and    plr2.rule_mode               = 'A') ;
16872   --
16873   cursor get_sec_date_range is
16874      select asg.effective_start_date
16875      ,      asg.effective_end_date
16876      from   per_all_assignments_f asg
16877      where  asg.assignment_id=p_assignment_id
16878      and   ((sysdate between asg.effective_start_date
16879             and asg.effective_end_date)
16880             or
16881            (sysdate<asg.effective_start_date
16882             and not exists
16883             (select 1
16884              from per_all_assignments_f asg2
16885              where asg2.person_id=asg.person_id
16886              and asg2.application_id=asg.application_id
16887              and asg2.effective_start_date<asg.effective_start_date)
16888              )
16889             );
16890   --
16891   l_sec_effective_start_date date;
16892   l_sec_effective_end_date date;
16893   --
16894   -- bug 2230915 get pay_people_group segment values where
16895   -- people_group_id is known
16896   --
16897   cursor c_pgp_segments is
16898      select segment1,
16899             segment2,
16900             segment3,
16901             segment4,
16902             segment5,
16903             segment6,
16904             segment7,
16905             segment8,
16906             segment9,
16907             segment10,
16908             segment11,
16909             segment12,
16910             segment13,
16911             segment14,
16912             segment15,
16913             segment16,
16914             segment17,
16915             segment18,
16916             segment19,
16917             segment20,
16918             segment21,
16919             segment22,
16920             segment23,
16921             segment24,
16922             segment25,
16923             segment26,
16924             segment27,
16925             segment28,
16926             segment29,
16927             segment30
16928      from   pay_people_groups
16929      where  people_group_id = l_people_group_id;
16930   --
16931   -- bug 2230915 get hr_soft_coding_keyflex segment values where
16932   -- soft_coding_keyflex_id is known
16933   --
16934   cursor c_scl_segments is
16935      select segment1,
16936             segment2,
16937             segment3,
16938             segment4,
16939             segment5,
16940             segment6,
16941             segment7,
16942             segment8,
16943             segment9,
16944             segment10,
16945             segment11,
16946             segment12,
16947             segment13,
16948             segment14,
16949             segment15,
16950             segment16,
16951             segment17,
16952             segment18,
16953             segment19,
16954             segment20,
16955             segment21,
16956             segment22,
16957             segment23,
16958             segment24,
16959             segment25,
16960             segment26,
16961             segment27,
16962             segment28,
16963             segment29,
16964             segment30
16965      from   hr_soft_coding_keyflex
16966      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
16967   --
16968   -- bug 2230915 get per_cagr_grades_def segment values where
16969   -- cagr_grade_def_id is known
16970   --
16971   cursor c_cag_segments is
16972      select segment1,
16973             segment2,
16974             segment3,
16975             segment4,
16976             segment5,
16977             segment6,
16978             segment7,
16979             segment8,
16980             segment9,
16981             segment10,
16982             segment11,
16983             segment12,
16984             segment13,
16985             segment14,
16986             segment15,
16987             segment16,
16988             segment17,
16989             segment18,
16990             segment19,
16991             segment20
16992      from   per_cagr_grades_def
16993      where  cagr_grade_def_id = l_cagr_grade_def_id;
16994 --
16995 -- fix for bug 5938120 starts here.
16996 l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
16997 
16998 cursor csr_get_assign(csr_person_id number) is
16999 select assignment_id
17000 from per_all_assignments_f
17001 where person_id=csr_person_id
17002 and business_group_id=l_business_group_id
17003 and l_effective_date between effective_start_date and effective_end_date
17004 and assignment_type not in ('B','O'); -- added for the bug 6925339
17005 -- fix for bug 5938120 ends here.
17006 --
17007 begin
17008 --
17009  if g_debug then
17010   hr_utility.set_location('Entering:'|| l_proc, 10);
17011  end if;
17012   --
17013   --Truncate the parameter p_effective_date to a local variable
17014   --
17015   l_effective_date       := trunc(p_effective_date);
17016   l_date_probation_end   := trunc(p_date_probation_end);
17017 -- Bug 944911
17018 -- Made p_group_name to be out param
17019 -- and add p_concat_segment to be IN
17020 -- in case of sec_asg alone made p_pgp_concat_segments as in param
17021 -- Replaced p_group_name by p_concat_segments
17022   l_old_group_name       := p_concat_segments;
17023 -- Bug 944911
17024 -- Amended p_scl_concatenated_segments to p_scl_concat_segments
17025   l_old_scl_conc_segments := p_scl_concat_segments;
17026   --
17027   -- Issue a savepoint.
17028   --
17029   savepoint update_apl_asg;
17030   --
17031  if g_debug then
17032   hr_utility.set_location(l_proc, 20);
17033  end if;
17034   --
17035   l_object_version_number := p_object_version_number;
17036   --
17037   -- Validation in addition to Table Handlers
17038   --
17039   -- Check mandatory arguments
17040   --
17041   hr_api.mandatory_arg_error
17042     (p_api_name       => l_proc
17043     ,p_argument       => 'assignment_id'
17044     ,p_argument_value => p_assignment_id);
17045   --
17046   hr_api.mandatory_arg_error
17047     (p_api_name       => l_proc
17048     ,p_argument       => 'effective_date'
17049     ,p_argument_value => l_effective_date);
17050   --
17051   hr_api.mandatory_arg_error
17052     (p_api_name       => l_proc
17053     ,p_argument       => 'datetrack_update_mode'
17054     ,p_argument_value => p_datetrack_update_mode);
17055   --
17056   hr_api.mandatory_arg_error
17057     (p_api_name       => l_proc
17058     ,p_argument       => 'object_version_number'
17059     ,p_argument_value => l_object_version_number);
17060   --
17061   -- Retrieve current assignment details from database.
17062   --
17063   l_api_updating := per_asg_shd.api_updating
17064     (p_assignment_id         => p_assignment_id
17065     ,p_effective_date        => l_effective_date
17066     ,p_object_version_number => l_object_version_number);
17067   --
17068  if g_debug then
17069   hr_utility.set_location(l_proc, 30);
17070  end if;
17071   --
17072   if not l_api_updating
17073   then
17074     --
17075  if g_debug then
17076     hr_utility.set_location(l_proc, 40);
17077  end if;
17078     --
17079     -- As this is an updating API, the assignment should already exist.
17080     --
17081     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
17082     hr_utility.raise_error;
17083   end if;
17084   --
17085   -- Populate l_business_group_id from g_old_rec for cursor csr_grp_idsel
17086   -- Populate l_people_group_id from g_old_rec for upd_or_sel_key_flex
17087   -- 2230915 only populate l_people_group_id from g_old_rec
17088   -- if p_people_group_id did not enter with a value.  If it did enter with
17089   -- a value then get segment values from pay_people_groups.
17090   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
17091   -- per_cagr_grades_def
17092   --
17093   l_business_group_id := per_asg_shd.g_old_rec.business_group_id;
17094   --
17095  if g_debug then
17096   hr_utility.set_location(l_proc, 45);
17097  end if;
17098   --
17099   if l_people_group_id is null
17100   then
17101     --
17102     l_people_group_id := per_asg_shd.g_old_rec.people_group_id;
17103     l_pgp_null_ind := 0;
17104   else
17105     -- get segment values
17106     open c_pgp_segments;
17107       fetch c_pgp_segments into l_pgp_segment1,
17108                                 l_pgp_segment2,
17109                                 l_pgp_segment3,
17110                                 l_pgp_segment4,
17111                                 l_pgp_segment5,
17112                                 l_pgp_segment6,
17113                                 l_pgp_segment7,
17114                                 l_pgp_segment8,
17115                                 l_pgp_segment9,
17116                                 l_pgp_segment10,
17117                                 l_pgp_segment11,
17118                                 l_pgp_segment12,
17119                                 l_pgp_segment13,
17120                                 l_pgp_segment14,
17121                                 l_pgp_segment15,
17122                                 l_pgp_segment16,
17123                                 l_pgp_segment17,
17124                                 l_pgp_segment18,
17125                                 l_pgp_segment19,
17126                                 l_pgp_segment20,
17127                                 l_pgp_segment21,
17128                                 l_pgp_segment22,
17129                                 l_pgp_segment23,
17130                                 l_pgp_segment24,
17131                                 l_pgp_segment25,
17132                                 l_pgp_segment26,
17133                                 l_pgp_segment27,
17134                                 l_pgp_segment28,
17135                                 l_pgp_segment29,
17136                                 l_pgp_segment30;
17137     close c_pgp_segments;
17138   end if;
17139   --  use cursor c_scl_segments to bring back segment values if
17140   --  l_soft_coding_keyflex_id has a value.
17141   if l_soft_coding_keyflex_id is not null
17142   then
17143     l_scl_null_ind := 1;
17144     open c_scl_segments;
17145       fetch c_scl_segments into l_scl_segment1,
17146                                l_scl_segment2,
17147                                l_scl_segment3,
17148                                l_scl_segment4,
17149                                l_scl_segment5,
17150                                l_scl_segment6,
17151                                l_scl_segment7,
17152                                l_scl_segment8,
17153                                l_scl_segment9,
17154                                l_scl_segment10,
17155                                l_scl_segment11,
17156                                l_scl_segment12,
17157                                l_scl_segment13,
17158                                l_scl_segment14,
17159                                l_scl_segment15,
17160                                l_scl_segment16,
17161                                l_scl_segment17,
17162                                l_scl_segment18,
17163                                l_scl_segment19,
17164                                l_scl_segment20,
17165                                l_scl_segment21,
17166                                l_scl_segment22,
17167                                l_scl_segment23,
17168                                l_scl_segment24,
17169                                l_scl_segment25,
17170                                l_scl_segment26,
17171                                l_scl_segment27,
17172                                l_scl_segment28,
17173                                l_scl_segment29,
17174                                l_scl_segment30;
17175     close c_scl_segments;
17176   else
17177     l_scl_null_ind := 0;
17178   end if;
17179   --
17180   -- if cagr_grade_def_id has a value then use it to get segment values using
17181   -- cursor cag_segments
17182   --
17183   if l_cagr_grade_def_id is not null
17184   then
17185     l_cag_null_ind := 1;
17186     open c_cag_segments;
17187       fetch c_cag_segments into l_cag_segment1,
17188                                 l_cag_segment2,
17189                                 l_cag_segment3,
17190                                 l_cag_segment4,
17191                                 l_cag_segment5,
17192                                 l_cag_segment6,
17193                                 l_cag_segment7,
17194                                 l_cag_segment8,
17195                                 l_cag_segment9,
17196                                 l_cag_segment10,
17197                                 l_cag_segment11,
17198                                 l_cag_segment12,
17199                                 l_cag_segment13,
17200                                 l_cag_segment14,
17201                                 l_cag_segment15,
17202                                 l_cag_segment16,
17203                                 l_cag_segment17,
17204                                 l_cag_segment18,
17205                                 l_cag_segment19,
17206                                 l_cag_segment20;
17207     close c_cag_segments;
17208   else
17209     l_cag_null_ind := 0;
17210   end if;
17211   --
17212  if g_debug then
17213   hr_utility.set_location(l_proc, 60);
17214  end if;
17215   --
17216   -- Check that the assignment is an applicant assignment.
17217   --
17218   if per_asg_shd.g_old_rec.assignment_type <> 'A'
17219   then
17220     --
17221  if g_debug then
17222     hr_utility.set_location(l_proc, 70);
17223  end if;
17224     --
17225     hr_utility.set_message(801, 'HR_51036_ASG_ASG_NOT_APL');
17226     hr_utility.raise_error;
17227   end if;
17228   --
17229   -- Start of API User Hook for the before hook of update_apl_asg.
17230   --
17231   begin
17232       hr_assignment_bk5.update_apl_asg_b
17233        (p_effective_date               =>     l_effective_date
17234        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
17235        ,p_assignment_id                =>     p_assignment_id
17236        ,p_object_version_number        =>     p_object_version_number
17237        ,p_grade_id                     =>     p_grade_id
17238        ,p_job_id                       =>     p_job_id
17239        ,p_payroll_id                   =>     p_payroll_id
17240        ,p_location_id                  =>     p_location_id
17241        ,p_organization_id              =>     p_organization_id
17242        ,p_position_id                  =>     p_position_id
17243        ,p_application_id               =>     p_application_id
17244        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
17245        ,p_recruiter_id                 =>     p_recruiter_id
17246        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
17247        ,p_vacancy_id                   =>     p_vacancy_id
17248        ,p_pay_basis_id                 =>     p_pay_basis_id
17249        ,p_person_referred_by_id        =>     p_person_referred_by_id
17250        ,p_supervisor_id                =>     p_supervisor_id
17251        ,p_source_organization_id       =>     p_source_organization_id
17252        ,p_change_reason                =>     p_change_reason
17253        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
17254        ,p_internal_address_line        =>     p_internal_address_line
17255        ,p_default_code_comb_id         =>     p_default_code_comb_id
17256        ,p_employment_category          =>     p_employment_category
17257        ,p_frequency                    =>     p_frequency
17258        ,p_manager_flag                 =>     p_manager_flag
17259        ,p_normal_hours                 =>     p_normal_hours
17260        ,p_perf_review_period           =>     p_perf_review_period
17261        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
17262        ,p_probation_period             =>     p_probation_period
17263        ,p_probation_unit               =>     p_probation_unit
17264        ,p_sal_review_period            =>     p_sal_review_period
17265        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
17266        ,p_set_of_books_id              =>     p_set_of_books_id
17267        ,p_source_type                  =>     p_source_type
17268        ,p_time_normal_finish           =>     p_time_normal_finish
17269        ,p_time_normal_start            =>     p_time_normal_start
17270        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
17271        ,p_comments                     =>     p_comments
17272        ,p_date_probation_end           =>     l_date_probation_end
17273        ,p_title                        =>     p_title
17274        ,p_ass_attribute_category       =>     p_ass_attribute_category
17275        ,p_ass_attribute1               =>     p_ass_attribute1
17276        ,p_ass_attribute2               =>     p_ass_attribute2
17277        ,p_ass_attribute3               =>     p_ass_attribute3
17278        ,p_ass_attribute4               =>     p_ass_attribute4
17279        ,p_ass_attribute5               =>     p_ass_attribute5
17280        ,p_ass_attribute6               =>     p_ass_attribute6
17281        ,p_ass_attribute7               =>     p_ass_attribute7
17282        ,p_ass_attribute8               =>     p_ass_attribute8
17283        ,p_ass_attribute9               =>     p_ass_attribute9
17284        ,p_ass_attribute10              =>     p_ass_attribute10
17285        ,p_ass_attribute11              =>     p_ass_attribute11
17286        ,p_ass_attribute12              =>     p_ass_attribute12
17287        ,p_ass_attribute13              =>     p_ass_attribute13
17288        ,p_ass_attribute14              =>     p_ass_attribute14
17289        ,p_ass_attribute15              =>     p_ass_attribute15
17290        ,p_ass_attribute16              =>     p_ass_attribute16
17291        ,p_ass_attribute17              =>     p_ass_attribute17
17292        ,p_ass_attribute18              =>     p_ass_attribute18
17293        ,p_ass_attribute19              =>     p_ass_attribute19
17294        ,p_ass_attribute20              =>     p_ass_attribute20
17295        ,p_ass_attribute21              =>     p_ass_attribute21
17296        ,p_ass_attribute22              =>     p_ass_attribute22
17297        ,p_ass_attribute23              =>     p_ass_attribute23
17298        ,p_ass_attribute24              =>     p_ass_attribute24
17299        ,p_ass_attribute25              =>     p_ass_attribute25
17300        ,p_ass_attribute26              =>     p_ass_attribute26
17301        ,p_ass_attribute27              =>     p_ass_attribute27
17302        ,p_ass_attribute28              =>     p_ass_attribute28
17303        ,p_ass_attribute29              =>     p_ass_attribute29
17304        ,p_ass_attribute30              =>     p_ass_attribute30
17305        ,p_scl_segment1                 =>     l_scl_segment1
17306        ,p_scl_segment2                 =>     l_scl_segment2
17307        ,p_scl_segment3                 =>     l_scl_segment3
17308        ,p_scl_segment4                 =>     l_scl_segment4
17309        ,p_scl_segment5                 =>     l_scl_segment5
17310        ,p_scl_segment6                 =>     l_scl_segment6
17311        ,p_scl_segment7                 =>     l_scl_segment7
17312        ,p_scl_segment8                 =>     l_scl_segment8
17313        ,p_scl_segment9                 =>     l_scl_segment9
17314        ,p_scl_segment10                =>     l_scl_segment10
17315        ,p_scl_segment11                =>     l_scl_segment11
17316        ,p_scl_segment12                =>     l_scl_segment12
17317        ,p_scl_segment13                =>     l_scl_segment13
17318        ,p_scl_segment14                =>     l_scl_segment14
17319        ,p_scl_segment15                =>     l_scl_segment15
17320        ,p_scl_segment16                =>     l_scl_segment16
17321        ,p_scl_segment17                =>     l_scl_segment17
17322        ,p_scl_segment18                =>     l_scl_segment18
17323        ,p_scl_segment19                =>     l_scl_segment19
17324        ,p_scl_segment20                =>     l_scl_segment20
17325        ,p_scl_segment21                =>     l_scl_segment21
17326        ,p_scl_segment22                =>     l_scl_segment22
17327        ,p_scl_segment23                =>     l_scl_segment23
17328        ,p_scl_segment24                =>     l_scl_segment24
17329        ,p_scl_segment25                =>     l_scl_segment25
17330        ,p_scl_segment26                =>     l_scl_segment26
17331        ,p_scl_segment27                =>     l_scl_segment27
17332        ,p_scl_segment28                =>     l_scl_segment28
17333        ,p_scl_segment29                =>     l_scl_segment29
17334        ,p_scl_segment30                =>     l_scl_segment30
17335 -- Bug 944911
17336 -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
17337        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
17338        ,p_pgp_segment1                 =>     l_pgp_segment1
17339        ,p_pgp_segment2                 =>     l_pgp_segment2
17340        ,p_pgp_segment3                 =>     l_pgp_segment3
17341        ,p_pgp_segment4                 =>     l_pgp_segment4
17342        ,p_pgp_segment5                 =>     l_pgp_segment5
17343        ,p_pgp_segment6                 =>     l_pgp_segment6
17344        ,p_pgp_segment7                 =>     l_pgp_segment7
17345        ,p_pgp_segment8                 =>     l_pgp_segment8
17346        ,p_pgp_segment9                 =>     l_pgp_segment9
17347        ,p_pgp_segment10                =>     l_pgp_segment10
17348        ,p_pgp_segment11                =>     l_pgp_segment11
17349        ,p_pgp_segment12                =>     l_pgp_segment12
17350        ,p_pgp_segment13                =>     l_pgp_segment13
17351        ,p_pgp_segment14                =>     l_pgp_segment14
17352        ,p_pgp_segment15                =>     l_pgp_segment15
17353        ,p_pgp_segment16                =>     l_pgp_segment16
17354        ,p_pgp_segment17                =>     l_pgp_segment17
17355        ,p_pgp_segment18                =>     l_pgp_segment18
17356        ,p_pgp_segment19                =>     l_pgp_segment19
17357        ,p_pgp_segment20                =>     l_pgp_segment20
17358        ,p_pgp_segment21                =>     l_pgp_segment21
17359        ,p_pgp_segment22                =>     l_pgp_segment22
17360        ,p_pgp_segment23                =>     l_pgp_segment23
17361        ,p_pgp_segment24                =>     l_pgp_segment24
17362        ,p_pgp_segment25                =>     l_pgp_segment25
17363        ,p_pgp_segment26                =>     l_pgp_segment26
17364        ,p_pgp_segment27                =>     l_pgp_segment27
17365        ,p_pgp_segment28                =>     l_pgp_segment28
17366        ,p_pgp_segment29                =>     l_pgp_segment29
17367        ,p_pgp_segment30                =>     l_pgp_segment30
17368        ,p_contract_id                  =>     p_contract_id
17369        ,p_establishment_id             =>     p_establishment_id
17370        ,p_collective_agreement_id      =>     p_collective_agreement_id
17371        ,p_cagr_id_flex_num             =>     p_cagr_id_flex_num
17372        ,p_cag_segment1                 =>     l_cag_segment1
17373        ,p_cag_segment2                 =>     l_cag_segment2
17374        ,p_cag_segment3                 =>     l_cag_segment3
17375        ,p_cag_segment4                 =>     l_cag_segment4
17376        ,p_cag_segment5                 =>     l_cag_segment5
17377        ,p_cag_segment6                 =>     l_cag_segment6
17378        ,p_cag_segment7                 =>     l_cag_segment7
17379        ,p_cag_segment8                 =>     l_cag_segment8
17380        ,p_cag_segment9                 =>     l_cag_segment9
17381        ,p_cag_segment10                =>     l_cag_segment10
17382        ,p_cag_segment11                =>     l_cag_segment11
17383        ,p_cag_segment12                =>     l_cag_segment12
17384        ,p_cag_segment13                =>     l_cag_segment13
17385        ,p_cag_segment14                =>     l_cag_segment14
17386        ,p_cag_segment15                =>     l_cag_segment15
17387        ,p_cag_segment16                =>     l_cag_segment16
17388        ,p_cag_segment17                =>     l_cag_segment17
17389        ,p_cag_segment18                =>     l_cag_segment18
17390        ,p_cag_segment19                =>     l_cag_segment19
17391        ,p_cag_segment20                =>     l_cag_segment20
17392        ,p_notice_period		       =>     p_notice_period
17393        ,p_notice_period_uom	       =>     p_notice_period_uom
17394        ,p_employee_category	       =>     p_employee_category
17395        ,p_work_at_home		       =>     p_work_at_home
17396        ,p_job_post_source_name	       =>     p_job_post_source_name
17397        ,p_posting_content_id           =>     p_posting_content_id
17398        ,p_applicant_rank               =>     p_applicant_rank
17399 
17400 -- Bug 944911
17401 -- Amended p_group_name to p_concat_segments
17402        ,p_concat_segments              =>     l_old_group_name
17403        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
17404        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
17405  );
17406   exception
17407      when hr_api.cannot_find_prog_unit then
17408        hr_api.cannot_find_prog_unit_error
17409          (p_module_name       => 'UPDATE_APL_ASG',
17410           p_hook_type         => 'BP'
17411          );
17412   end;
17413   --
17414   --
17415  if g_debug then
17416   hr_utility.set_location(l_proc, 80);
17417  end if;
17418   --
17419   --added validation for bug 1867720
17420   --
17421   if p_assignment_status_type_id <> hr_api.g_number then
17422     open csr_old_asg_status;
17423     fetch csr_old_asg_status into l_old_asg_status;
17424     close csr_old_asg_status;
17425     --
17426     open csr_new_asg_status;
17427     fetch csr_new_asg_status into l_new_asg_status;
17428       if csr_new_asg_status%notfound
17429         OR (csr_new_asg_status%found AND l_old_asg_status <> l_new_asg_status)
17430       then
17431        fnd_message.set_name('PER','HR_7949_ASG_DIF_SYSTEM_TYPE');
17432        fnd_message.set_token('SYSTYPE',l_old_asg_status);
17433        fnd_message.raise_error;
17434       end if;
17435     close csr_new_asg_status;
17436   end if;
17437   --
17438   --
17439   -- insert the profile options and effective date for the flexfield
17440   -- validation to work
17441   --
17442   if (p_organization_id=hr_api.g_number) then
17443     l_organization_id:=per_asg_shd.g_old_rec.organization_id;
17444   else
17445     l_organization_id:=p_organization_id;
17446   end if;
17447   --
17448   if (p_location_id=hr_api.g_number) then
17449     l_location_id:=per_asg_shd.g_old_rec.location_id;
17450   else
17451     l_location_id:=p_location_id;
17452   end if;
17453   --
17454   hr_kflex_utility.set_profiles
17455   (p_business_group_id => l_business_group_id
17456   ,p_assignment_id     => p_assignment_id
17457   ,p_organization_id   => l_organization_id
17458   ,p_location_id       => l_location_id);
17459   --
17460   hr_kflex_utility.set_session_date
17461   (p_effective_date => l_effective_date
17462   ,p_session_id     => l_session_id);
17463   --
17464   -- Maintain the people group key flexfields.
17465   --
17466   open csr_grp_idsel;
17467   fetch csr_grp_idsel
17468   into l_flex_num;
17469      if csr_grp_idsel%NOTFOUND then
17470        close csr_grp_idsel;
17471           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
17472           hr_utility.set_message_token('PROCEDURE', l_proc);
17473           hr_utility.set_message_token('STEP','10');
17474           hr_utility.raise_error;
17475      end if;
17476   close csr_grp_idsel;
17477   --
17478   if l_pgp_null_ind = 0
17479   then
17480     hr_kflex_utility.upd_or_sel_keyflex_comb
17481       (p_appl_short_name        => 'PAY'
17482       ,p_flex_code              => 'GRP'
17483       ,p_flex_num               => l_flex_num
17484       ,p_segment1               => l_pgp_segment1
17485       ,p_segment2               => l_pgp_segment2
17486       ,p_segment3               => l_pgp_segment3
17487       ,p_segment4               => l_pgp_segment4
17488       ,p_segment5               => l_pgp_segment5
17489       ,p_segment6               => l_pgp_segment6
17490       ,p_segment7               => l_pgp_segment7
17491       ,p_segment8               => l_pgp_segment8
17492       ,p_segment9               => l_pgp_segment9
17493       ,p_segment10              => l_pgp_segment10
17494       ,p_segment11              => l_pgp_segment11
17495       ,p_segment12              => l_pgp_segment12
17496       ,p_segment13              => l_pgp_segment13
17497       ,p_segment14              => l_pgp_segment14
17498       ,p_segment15              => l_pgp_segment15
17499       ,p_segment16              => l_pgp_segment16
17500       ,p_segment17              => l_pgp_segment17
17501       ,p_segment18              => l_pgp_segment18
17502       ,p_segment19              => l_pgp_segment19
17503       ,p_segment20              => l_pgp_segment20
17504       ,p_segment21              => l_pgp_segment21
17505       ,p_segment22              => l_pgp_segment22
17506       ,p_segment23              => l_pgp_segment23
17507       ,p_segment24              => l_pgp_segment24
17508       ,p_segment25              => l_pgp_segment25
17509       ,p_segment26              => l_pgp_segment26
17510       ,p_segment27              => l_pgp_segment27
17511       ,p_segment28              => l_pgp_segment28
17512       ,p_segment29              => l_pgp_segment29
17513       ,p_segment30              => l_pgp_segment30
17514       ,p_concat_segments_in     => l_old_group_name
17515       ,p_ccid                   => l_people_group_id
17516       ,p_concat_segments_out    => l_group_name
17517       );
17518   end if;
17519   --
17520   -- update the combinations column
17521   --
17522   update_pgp_concat_segs
17523     (p_people_group_id        => l_people_group_id
17524     ,p_group_name             => l_group_name
17525   );
17526   --
17527   -- Update or select the soft_coding_keyflex_id
17528   --
17529   if l_soft_coding_keyflex_id is null
17530   then
17531      if   l_scl_segment1 <> hr_api.g_varchar2
17532        or l_scl_segment2 <> hr_api.g_varchar2
17533        or l_scl_segment3 <> hr_api.g_varchar2
17534        or l_scl_segment4 <> hr_api.g_varchar2
17535        or l_scl_segment5 <> hr_api.g_varchar2
17536        or l_scl_segment6 <> hr_api.g_varchar2
17537        or l_scl_segment7 <> hr_api.g_varchar2
17538        or l_scl_segment8 <> hr_api.g_varchar2
17539        or l_scl_segment9 <> hr_api.g_varchar2
17540        or l_scl_segment10 <> hr_api.g_varchar2
17541        or l_scl_segment11 <> hr_api.g_varchar2
17542        or l_scl_segment12 <> hr_api.g_varchar2
17543        or l_scl_segment13 <> hr_api.g_varchar2
17544        or l_scl_segment14 <> hr_api.g_varchar2
17545        or l_scl_segment15 <> hr_api.g_varchar2
17546        or l_scl_segment16 <> hr_api.g_varchar2
17547        or l_scl_segment17 <> hr_api.g_varchar2
17548        or l_scl_segment18 <> hr_api.g_varchar2
17549        or l_scl_segment19 <> hr_api.g_varchar2
17550        or l_scl_segment20 <> hr_api.g_varchar2
17551        or l_scl_segment21 <> hr_api.g_varchar2
17552        or l_scl_segment22 <> hr_api.g_varchar2
17553        or l_scl_segment23 <> hr_api.g_varchar2
17554        or l_scl_segment24 <> hr_api.g_varchar2
17555        or l_scl_segment25 <> hr_api.g_varchar2
17556        or l_scl_segment26 <> hr_api.g_varchar2
17557        or l_scl_segment27 <> hr_api.g_varchar2
17558        or l_scl_segment28 <> hr_api.g_varchar2
17559        or l_scl_segment29 <> hr_api.g_varchar2
17560        or l_scl_segment30 <> hr_api.g_varchar2
17561        --
17562        -- Bug 944911
17563        -- Added this additional check
17564        or p_scl_concat_segments <> hr_api.g_varchar2
17565      then
17566        -- gets flex num id from pay_legislation_rules and
17567        -- per_business_groups_perf
17568        --
17569        open csr_scl_idsel;
17570        fetch csr_scl_idsel into l_flex_num;
17571        --
17572        if csr_scl_idsel%NOTFOUND
17573        then
17574           close csr_scl_idsel;
17575           if   l_scl_segment1 is not null
17576             or l_scl_segment2 is not null
17577             or l_scl_segment3 is not null
17578             or l_scl_segment4 is not null
17579             or l_scl_segment5 is not null
17580             or l_scl_segment6 is not null
17581             or l_scl_segment7 is not null
17582             or l_scl_segment8 is not null
17583             or l_scl_segment9 is not null
17584             or l_scl_segment10 is not null
17585             or l_scl_segment11 is not null
17586             or l_scl_segment12 is not null
17587             or l_scl_segment13 is not null
17588             or l_scl_segment14 is not null
17589             or l_scl_segment15 is not null
17590             or l_scl_segment16 is not null
17591             or l_scl_segment17 is not null
17592             or l_scl_segment18 is not null
17593             or l_scl_segment19 is not null
17594             or l_scl_segment20 is not null
17595             or l_scl_segment21 is not null
17596             or l_scl_segment22 is not null
17597             or l_scl_segment23 is not null
17598             or l_scl_segment24 is not null
17599             or l_scl_segment25 is not null
17600             or l_scl_segment26 is not null
17601             or l_scl_segment27 is not null
17602             or l_scl_segment28 is not null
17603             or l_scl_segment29 is not null
17604             or l_scl_segment30 is not null
17605             --
17606             -- Bug 944911
17607             -- Added this additional check
17608             or p_scl_concat_segments is not null
17609           then
17610              hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
17611              hr_utility.set_message_token('PROCEDURE', l_proc);
17612              hr_utility.set_message_token('STEP','5');
17613              hr_utility.raise_error;
17614           end if;  -- p_scl_segment1 is not null
17615        else -- csr_scl_idsel is found
17616           close csr_scl_idsel;
17617           --
17618           -- Process Logic
17619           --
17620           --
17621           -- Update or select the soft_coding_keyflex_id
17622           --
17623           hr_kflex_utility.upd_or_sel_keyflex_comb
17624             (p_appl_short_name        => 'PER'
17625             ,p_flex_code              => 'SCL'
17626             ,p_flex_num               => l_flex_num
17627             ,p_segment1               => l_scl_segment1
17628             ,p_segment2               => l_scl_segment2
17629             ,p_segment3               => l_scl_segment3
17630             ,p_segment4               => l_scl_segment4
17631             ,p_segment5               => l_scl_segment5
17632             ,p_segment6               => l_scl_segment6
17633             ,p_segment7               => l_scl_segment7
17634             ,p_segment8               => l_scl_segment8
17635             ,p_segment9               => l_scl_segment9
17636             ,p_segment10              => l_scl_segment10
17637             ,p_segment11              => l_scl_segment11
17638             ,p_segment12              => l_scl_segment12
17639             ,p_segment13              => l_scl_segment13
17640             ,p_segment14              => l_scl_segment14
17641             ,p_segment15              => l_scl_segment15
17642             ,p_segment16              => l_scl_segment16
17643             ,p_segment17              => l_scl_segment17
17644             ,p_segment18              => l_scl_segment18
17645             ,p_segment19              => l_scl_segment19
17646             ,p_segment20              => l_scl_segment20
17647             ,p_segment21              => l_scl_segment21
17648             ,p_segment22              => l_scl_segment22
17649             ,p_segment23              => l_scl_segment23
17650             ,p_segment24              => l_scl_segment24
17651             ,p_segment25              => l_scl_segment25
17652             ,p_segment26              => l_scl_segment26
17653             ,p_segment27              => l_scl_segment27
17654             ,p_segment28              => l_scl_segment28
17655             ,p_segment29              => l_scl_segment29
17656             ,p_segment30              => l_scl_segment30
17657             ,p_concat_segments_in     => l_old_scl_conc_segments
17658             ,p_ccid                   => l_soft_coding_keyflex_id
17659             ,p_concat_segments_out    => l_scl_concatenated_segments
17660             );
17661             --
17662             -- update the combinations column
17663             --
17664             update_scl_concat_segs
17665             (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
17666             ,p_concatenated_segments   => l_scl_concatenated_segments
17667             );
17668          --
17669         end if;  -- csr_scl_idsel%NOTFOUND
17670       --
17671      end if; -- l_scl_segment1 <> hr_api.g_varchar2
17672    --
17673   end if; -- l_soft_coding_key_flex_id is null
17674   --
17675   -- need to call the lck procedure early, to fetch the old value of
17676   -- cagr_id_flex_num
17677   -- before passing it into the hr_cgd_upd.upd_or_sel function.
17678   -- This is because the user may be updating a grade definition,
17679   -- but not changing
17680   -- or specifying the cagr_id_flex_num (ie the grade structure).
17681   -- Also, need to fetch the old cagr_grade_def_id, as the
17682   -- user may be updating some
17683   -- segments, and not changing others. Passing cagr_grade_id
17684   -- into the hr_cgd_upd.upd_or_sel
17685   -- function allows that function to derive the old values.
17686   --
17687   l_cagr_id_flex_num  := p_cagr_id_flex_num;
17688   --
17689   if (p_cagr_id_flex_num  = hr_api.g_number) THEN
17690     per_asg_shd.lck
17691       (p_effective_date          => l_effective_date,
17692        -- Bug 3430504. Pass l_effective_date in place of p_effective_date.
17693        p_datetrack_mode          => p_datetrack_update_mode,
17694        p_assignment_id           => p_assignment_id,
17695        p_object_version_number   => p_object_version_number,
17696        p_validation_start_date   => l_unused_start_date,
17697        p_validation_end_date     => l_unused_end_date
17698        );
17699     l_cagr_id_flex_num := per_asg_shd.g_old_rec.cagr_id_flex_num;
17700     --l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
17701   end if;
17702   --
17703   if l_cag_null_ind = 0
17704   then
17705      l_cagr_grade_def_id := per_asg_shd.g_old_rec.cagr_grade_def_id;
17706      --
17707      hr_cgd_upd.upd_or_sel
17708      (p_segment1               => l_cag_segment1
17709      ,p_segment2               => l_cag_segment2
17710      ,p_segment3               => l_cag_segment3
17711      ,p_segment4               => l_cag_segment4
17712      ,p_segment5               => l_cag_segment5
17713      ,p_segment6               => l_cag_segment6
17714      ,p_segment7               => l_cag_segment7
17715      ,p_segment8               => l_cag_segment8
17716      ,p_segment9               => l_cag_segment9
17717      ,p_segment10              => l_cag_segment10
17718      ,p_segment11              => l_cag_segment11
17719      ,p_segment12              => l_cag_segment12
17720      ,p_segment13              => l_cag_segment13
17721      ,p_segment14              => l_cag_segment14
17722      ,p_segment15              => l_cag_segment15
17723      ,p_segment16              => l_cag_segment16
17724      ,p_segment17              => l_cag_segment17
17725      ,p_segment18              => l_cag_segment18
17726      ,p_segment19              => l_cag_segment19
17727      ,p_segment20              => l_cag_segment20
17728      ,p_id_flex_num            => l_cagr_id_flex_num
17729      ,p_business_group_id      => per_asg_shd.g_old_rec.business_group_id
17730      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
17731      ,p_concatenated_segments  => l_cagr_concatenated_segments
17732      );
17733      --
17734  if g_debug then
17735      hr_utility.set_location(l_proc, 90);
17736  end if;
17737      --
17738   end if; --  l_cagr_grade_def_id is null
17739   --
17740  if g_debug then
17741   hr_utility.set_location(l_proc, 95);
17742  end if;
17743   --
17744   -- Update assignment.
17745   --
17746   per_asg_upd.upd
17747     (p_assignment_id                => p_assignment_id
17748     ,p_effective_start_date         => l_effective_start_date
17749     ,p_effective_end_date           => l_effective_end_date
17750     ,p_business_group_id            => l_business_group_id
17751     ,p_grade_id                     => p_grade_id
17752     ,p_job_id                       => p_job_id
17753     ,p_assignment_status_type_id    => p_assignment_status_type_id
17754     ,p_payroll_id                   => p_payroll_id
17755     ,p_location_id                  => p_location_id
17756     ,p_organization_id              => p_organization_id
17757     ,p_people_group_id              => l_people_group_id
17758     ,p_position_id                  => p_position_id
17759     ,p_application_id               => p_application_id
17760     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
17761     ,p_recruiter_id                 => p_recruiter_id
17762     ,p_recruitment_activity_id      => p_recruitment_activity_id
17763     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
17764     ,p_vacancy_id                   => p_vacancy_id
17765     ,p_pay_basis_id                 => p_pay_basis_id
17766     ,p_person_referred_by_id        => p_person_referred_by_id
17767     ,p_supervisor_id                => p_supervisor_id
17768     ,p_source_organization_id       => p_source_organization_id
17769     ,p_change_reason                => p_change_reason
17770     ,p_internal_address_line        => p_internal_address_line
17771     ,p_default_code_comb_id         => p_default_code_comb_id
17772     ,p_employment_category          => p_employment_category
17773     ,p_frequency                    => p_frequency
17774     ,p_manager_flag                 => p_manager_flag
17775     ,p_normal_hours                 => p_normal_hours
17776     ,p_perf_review_period           => p_perf_review_period
17777     ,p_perf_review_period_frequency => p_perf_review_period_frequency
17778     ,p_probation_period             => p_probation_period
17779     ,p_probation_unit               => p_probation_unit
17780     ,p_sal_review_period            => p_sal_review_period
17781     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
17782     ,p_set_of_books_id              => p_set_of_books_id
17783     ,p_source_type                  => p_source_type
17784     ,p_time_normal_finish           => p_time_normal_finish
17785     ,p_time_normal_start            => p_time_normal_start
17786     ,p_bargaining_unit_code         => p_bargaining_unit_code
17787     ,p_comments                     => p_comments
17788     ,p_date_probation_end           => l_date_probation_end
17789     ,p_title                        => p_title
17790     ,p_ass_attribute_category       => p_ass_attribute_category
17791     ,p_ass_attribute1               => p_ass_attribute1
17792     ,p_ass_attribute2               => p_ass_attribute2
17793     ,p_ass_attribute3               => p_ass_attribute3
17794     ,p_ass_attribute4               => p_ass_attribute4
17795     ,p_ass_attribute5               => p_ass_attribute5
17796     ,p_ass_attribute6               => p_ass_attribute6
17797     ,p_ass_attribute7               => p_ass_attribute7
17798     ,p_ass_attribute8               => p_ass_attribute8
17799     ,p_ass_attribute9               => p_ass_attribute9
17800     ,p_ass_attribute10              => p_ass_attribute10
17801     ,p_ass_attribute11              => p_ass_attribute11
17802     ,p_ass_attribute12              => p_ass_attribute12
17803     ,p_ass_attribute13              => p_ass_attribute13
17804     ,p_ass_attribute14              => p_ass_attribute14
17805     ,p_ass_attribute15              => p_ass_attribute15
17806     ,p_ass_attribute16              => p_ass_attribute16
17807     ,p_ass_attribute17              => p_ass_attribute17
17808     ,p_ass_attribute18              => p_ass_attribute18
17809     ,p_ass_attribute19              => p_ass_attribute19
17810     ,p_ass_attribute20              => p_ass_attribute20
17811     ,p_ass_attribute21              => p_ass_attribute21
17812     ,p_ass_attribute22              => p_ass_attribute22
17813     ,p_ass_attribute23              => p_ass_attribute23
17814     ,p_ass_attribute24              => p_ass_attribute24
17815     ,p_ass_attribute25              => p_ass_attribute25
17816     ,p_ass_attribute26              => p_ass_attribute26
17817     ,p_ass_attribute27              => p_ass_attribute27
17818     ,p_ass_attribute28              => p_ass_attribute28
17819     ,p_ass_attribute29              => p_ass_attribute29
17820     ,p_ass_attribute30              => p_ass_attribute30
17821     ,p_contract_id                  => p_contract_id
17822     ,p_establishment_id             => p_establishment_id
17823     ,p_collective_agreement_id      => p_collective_agreement_id
17824     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
17825     ,p_cagr_id_flex_num             => l_cagr_id_flex_num
17826     ,p_notice_period		    => p_notice_period
17827     ,p_notice_period_uom	    => p_notice_period_uom
17828     ,p_employee_category	    => p_employee_category
17829     ,p_work_at_home		    => p_work_at_home
17830     ,p_job_post_source_name	    => p_job_post_source_name
17831     ,p_payroll_id_updated           => l_dummy_payroll
17832     ,p_other_manager_warning        => l_dummy_manager1
17833     ,p_no_managers_warning          => l_dummy_manager2
17834     ,p_org_now_no_manager_warning   => l_dummy_manager3
17835     ,p_comment_id                   => l_comment_id
17836     ,p_validation_start_date        => l_validation_start_date
17837     ,p_validation_end_date          => l_validation_end_date
17838     ,p_object_version_number        => l_object_version_number
17839     ,p_effective_date               => l_effective_date
17840     ,p_datetrack_mode               => p_datetrack_update_mode
17841     ,p_validate                     => FALSE
17842     ,p_hourly_salaried_warning      => l_hourly_salaried_warning
17843     ,p_applicant_rank               => p_applicant_rank
17844     ,p_posting_content_id           => p_posting_content_id
17845     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
17846     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
17847     );
17848   --
17849   -- ***** Start new code for bug 2276928 **************
17850   if per_asg_shd.g_old_rec.assignment_status_type_id<>p_assignment_status_type_id
17851      and p_assignment_status_type_id<>hr_api.g_number then
17852     IRC_ASG_STATUS_API.create_irc_asg_status
17853     (p_assignment_id                => p_assignment_id
17854      , p_assignment_status_type_id  => p_assignment_status_type_id
17855      , p_status_change_date         => p_effective_date
17856      , p_status_change_reason       => p_change_reason   -- Bug 2676934
17857      , p_assignment_status_id       => l_assignment_status_id
17858      , p_object_version_number      => l_asg_status_ovn);
17859   end if;
17860   -- ***** End new code for bug 2276928 **************
17861   --
17862   -- Fix for bug 3680947 starts here.
17863   -- When the vacancy is changes, move the letter request line to a letter request
17864   -- with that vacancy.
17865   -- When the assignemnt status is changed, create new letter request lines.
17866   --
17867   IF (per_asg_shd.g_old_rec.assignment_status_type_id<>p_assignment_status_type_id
17868     AND p_assignment_status_type_id<>hr_api.g_number
17869    )
17870    OR
17871    ( nvl(per_asg_shd.g_old_rec.vacancy_id,-1) <> nvl(p_vacancy_id,-1) AND
17872      nvl(p_vacancy_id,-1) <> hr_api.g_number
17873    ) THEN
17874   --
17875   IF ( nvl(per_asg_shd.g_old_rec.vacancy_id,-1) <> nvl(p_vacancy_id,-1) AND
17876      nvl(p_vacancy_id,-1) <> hr_api.g_number ) THEN
17877     --
17878     delete from per_letter_request_lines plrl
17879     where plrl.assignment_id = p_assignment_id
17880     and   plrl.assignment_status_type_id = p_assignment_status_type_id
17881     and   exists
17882          (select null
17883           from per_letter_requests plr
17884           where plr.letter_request_id = plrl.letter_request_id
17885           and   plr.request_status = 'PENDING'
17886           and   plr.auto_or_manual = 'AUTO');
17887     --
17888  END IF;
17889   --
17890   per_app_asg_pkg.cleanup_letters
17891         ( p_assignment_id => p_assignment_id);
17892   --
17893   --
17894     delete from per_letter_requests plr
17895     where  plr.business_group_id     = l_business_group_id
17896     and    plr.request_status        = 'PENDING'
17897     and    plr.auto_or_manual        = 'AUTO'
17898     and not exists
17899      ( select 1
17900 	   from   per_letter_request_lines plrl
17901 	   where  plrl.letter_request_id = plr.letter_request_id
17902       ) ;
17903    --
17904    per_applicant_pkg.check_for_letter_requests
17905     (p_business_group_id            => l_business_group_id
17906     ,p_per_system_status            => null
17907     ,p_assignment_status_type_id    => p_assignment_status_type_id
17908     ,p_person_id                    => per_asg_shd.g_old_rec.person_id
17909     ,p_assignment_id                => p_assignment_id
17910     ,p_effective_start_date         => l_effective_start_date
17911     ,p_validation_start_date        => l_effective_start_date
17912     ,p_vacancy_id 		            => p_vacancy_id
17913     );
17914    --
17915  END IF;
17916   --
17917   -- Fix for bug 3680947 ends here.
17918   --
17919   -- insert in to security lists if neccesary
17920   --
17921   --
17922   open get_sec_date_range;
17923   fetch get_sec_date_range into l_sec_effective_start_date,
17924                                 l_sec_effective_end_date;
17925   close get_sec_date_range;
17926   --
17927   if l_effective_date between l_sec_effective_start_date
17928                           and l_sec_effective_end_date
17929   then
17930      if(per_asg_shd.g_old_rec.organization_id = l_business_group_id
17931        and p_organization_id <> l_business_group_id)
17932      then
17933         hr_security_internal.clear_from_person_list
17934                                              (per_asg_shd.g_old_rec.person_id);
17935      end if;
17936   --fix for bug 5938120 starts here
17937      open csr_get_assign(per_asg_shd.g_old_rec.person_id);
17938      LOOP
17939      fetch csr_get_assign into l_assignment_id;
17940      exit when csr_get_assign%NOTFOUND;
17941      hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
17942      end loop;
17943      --fix for bug 5938120 ends here
17944   end if;
17945   --
17946   -- Start of API User Hook for the after hook of suspend_emp_asg.
17947   --
17948   begin
17949      hr_assignment_bk5.update_apl_asg_a
17950        (p_effective_date               =>     l_effective_date
17951        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
17952        ,p_assignment_id                =>     p_assignment_id
17953        ,p_object_version_number        =>     l_object_version_number
17954        ,p_grade_id                     =>     p_grade_id
17955        ,p_job_id                       =>     p_job_id
17956        ,p_payroll_id                   =>     p_payroll_id
17957        ,p_location_id                  =>     p_location_id
17958        ,p_organization_id              =>     p_organization_id
17959        ,p_position_id                  =>     p_position_id
17960        ,p_application_id               =>     p_application_id
17961        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
17962        ,p_recruiter_id                 =>     p_recruiter_id
17963        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
17964        ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
17965        ,p_vacancy_id                   =>     p_vacancy_id
17966        ,p_pay_basis_id                 =>     p_pay_basis_id
17967        ,p_person_referred_by_id        =>     p_person_referred_by_id
17968        ,p_supervisor_id                =>     p_supervisor_id
17969        ,p_source_organization_id       =>     p_source_organization_id
17970        ,p_change_reason                =>     p_change_reason
17971        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
17972        ,p_internal_address_line        =>     p_internal_address_line
17973        ,p_default_code_comb_id         =>     p_default_code_comb_id
17974        ,p_employment_category          =>     p_employment_category
17975        ,p_frequency                    =>     p_frequency
17976        ,p_manager_flag                 =>     p_manager_flag
17977        ,p_normal_hours                 =>     p_normal_hours
17978        ,p_perf_review_period           =>     p_perf_review_period
17979        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
17980        ,p_probation_period             =>     p_probation_period
17981        ,p_probation_unit               =>     p_probation_unit
17982        ,p_sal_review_period            =>     p_sal_review_period
17983        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
17984        ,p_set_of_books_id              =>     p_set_of_books_id
17985        ,p_source_type                  =>     p_source_type
17986        ,p_time_normal_finish           =>     p_time_normal_finish
17987        ,p_time_normal_start            =>     p_time_normal_start
17988        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
17989        ,p_comments                     =>     p_comments
17990        ,p_date_probation_end           =>     l_date_probation_end
17991        ,p_title                        =>     p_title
17992        ,p_ass_attribute_category       =>     p_ass_attribute_category
17993        ,p_ass_attribute1               =>     p_ass_attribute1
17994        ,p_ass_attribute2               =>     p_ass_attribute2
17995        ,p_ass_attribute3               =>     p_ass_attribute3
17996        ,p_ass_attribute4               =>     p_ass_attribute4
17997        ,p_ass_attribute5               =>     p_ass_attribute5
17998        ,p_ass_attribute6               =>     p_ass_attribute6
17999        ,p_ass_attribute7               =>     p_ass_attribute7
18000        ,p_ass_attribute8               =>     p_ass_attribute8
18001        ,p_ass_attribute9               =>     p_ass_attribute9
18002        ,p_ass_attribute10              =>     p_ass_attribute10
18003        ,p_ass_attribute11              =>     p_ass_attribute11
18004        ,p_ass_attribute12              =>     p_ass_attribute12
18005        ,p_ass_attribute13              =>     p_ass_attribute13
18006        ,p_ass_attribute14              =>     p_ass_attribute14
18007        ,p_ass_attribute15              =>     p_ass_attribute15
18008        ,p_ass_attribute16              =>     p_ass_attribute16
18009        ,p_ass_attribute17              =>     p_ass_attribute17
18010        ,p_ass_attribute18              =>     p_ass_attribute18
18011        ,p_ass_attribute19              =>     p_ass_attribute19
18012        ,p_ass_attribute20              =>     p_ass_attribute20
18013        ,p_ass_attribute21              =>     p_ass_attribute21
18014        ,p_ass_attribute22              =>     p_ass_attribute22
18015        ,p_ass_attribute23              =>     p_ass_attribute23
18016        ,p_ass_attribute24              =>     p_ass_attribute24
18017        ,p_ass_attribute25              =>     p_ass_attribute25
18018        ,p_ass_attribute26              =>     p_ass_attribute26
18019        ,p_ass_attribute27              =>     p_ass_attribute27
18020        ,p_ass_attribute28              =>     p_ass_attribute28
18021        ,p_ass_attribute29              =>     p_ass_attribute29
18022        ,p_ass_attribute30              =>     p_ass_attribute30
18023        ,p_scl_segment1                 =>     l_scl_segment1
18024        ,p_scl_segment2                 =>     l_scl_segment2
18025        ,p_scl_segment3                 =>     l_scl_segment3
18026        ,p_scl_segment4                 =>     l_scl_segment4
18027        ,p_scl_segment5                 =>     l_scl_segment5
18028        ,p_scl_segment6                 =>     l_scl_segment6
18029        ,p_scl_segment7                 =>     l_scl_segment7
18030        ,p_scl_segment8                 =>     l_scl_segment8
18031        ,p_scl_segment9                 =>     l_scl_segment9
18032        ,p_scl_segment10                =>     l_scl_segment10
18033        ,p_scl_segment11                =>     l_scl_segment11
18034        ,p_scl_segment12                =>     l_scl_segment12
18035        ,p_scl_segment13                =>     l_scl_segment13
18036        ,p_scl_segment14                =>     l_scl_segment14
18037        ,p_scl_segment15                =>     l_scl_segment15
18038        ,p_scl_segment16                =>     l_scl_segment16
18039        ,p_scl_segment17                =>     l_scl_segment17
18040        ,p_scl_segment18                =>     l_scl_segment18
18041        ,p_scl_segment19                =>     l_scl_segment19
18042        ,p_scl_segment20                =>     l_scl_segment20
18043        ,p_scl_segment21                =>     l_scl_segment21
18044        ,p_scl_segment22                =>     l_scl_segment22
18045        ,p_scl_segment23                =>     l_scl_segment23
18046        ,p_scl_segment24                =>     l_scl_segment24
18047        ,p_scl_segment25                =>     l_scl_segment25
18048        ,p_scl_segment26                =>     l_scl_segment26
18049        ,p_scl_segment27                =>     l_scl_segment27
18050        ,p_scl_segment28                =>     l_scl_segment28
18051        ,p_scl_segment29                =>     l_scl_segment29
18052        ,p_scl_segment30                =>     l_scl_segment30
18053        --
18054        -- Amended p_scl_concatenated_segments to be p_concatenated_segments
18055        -- Bug 944911
18056        ,p_concatenated_segments        =>     l_scl_concatenated_segments
18057        ,p_pgp_segment1                 =>     l_pgp_segment1
18058        ,p_pgp_segment2                 =>     l_pgp_segment2
18059        ,p_pgp_segment3                 =>     l_pgp_segment3
18060        ,p_pgp_segment4                 =>     l_pgp_segment4
18061        ,p_pgp_segment5                 =>     l_pgp_segment5
18062        ,p_pgp_segment6                 =>     l_pgp_segment6
18063        ,p_pgp_segment7                 =>     l_pgp_segment7
18064        ,p_pgp_segment8                 =>     l_pgp_segment8
18065        ,p_pgp_segment9                 =>     l_pgp_segment9
18066        ,p_pgp_segment10                =>     l_pgp_segment10
18067        ,p_pgp_segment11                =>     l_pgp_segment11
18068        ,p_pgp_segment12                =>     l_pgp_segment12
18069        ,p_pgp_segment13                =>     l_pgp_segment13
18070        ,p_pgp_segment14                =>     l_pgp_segment14
18071        ,p_pgp_segment15                =>     l_pgp_segment15
18072        ,p_pgp_segment16                =>     l_pgp_segment16
18073        ,p_pgp_segment17                =>     l_pgp_segment17
18074        ,p_pgp_segment18                =>     l_pgp_segment18
18075        ,p_pgp_segment19                =>     l_pgp_segment19
18076        ,p_pgp_segment20                =>     l_pgp_segment20
18077        ,p_pgp_segment21                =>     l_pgp_segment21
18078        ,p_pgp_segment22                =>     l_pgp_segment22
18079        ,p_pgp_segment23                =>     l_pgp_segment23
18080        ,p_pgp_segment24                =>     l_pgp_segment24
18081        ,p_pgp_segment25                =>     l_pgp_segment25
18082        ,p_pgp_segment26                =>     l_pgp_segment26
18083        ,p_pgp_segment27                =>     l_pgp_segment27
18084        ,p_pgp_segment28                =>     l_pgp_segment28
18085        ,p_pgp_segment29                =>     l_pgp_segment29
18086        ,p_pgp_segment30                =>     l_pgp_segment30
18087        ,p_contract_id                  =>     p_contract_id
18088        ,p_establishment_id             =>     p_establishment_id
18089        ,p_collective_agreement_id      =>     p_collective_agreement_id
18090        ,p_cagr_id_flex_num             =>     l_cagr_id_flex_num
18091        ,p_cag_segment1                 =>     l_cag_segment1
18092        ,p_cag_segment2                 =>     l_cag_segment2
18093        ,p_cag_segment3                 =>     l_cag_segment3
18094        ,p_cag_segment4                 =>     l_cag_segment4
18095        ,p_cag_segment5                 =>     l_cag_segment5
18096        ,p_cag_segment6                 =>     l_cag_segment6
18097        ,p_cag_segment7                 =>     l_cag_segment7
18098        ,p_cag_segment8                 =>     l_cag_segment8
18099        ,p_cag_segment9                 =>     l_cag_segment9
18100        ,p_cag_segment10                =>     l_cag_segment10
18101        ,p_cag_segment11                =>     l_cag_segment11
18102        ,p_cag_segment12                =>     l_cag_segment12
18103        ,p_cag_segment13                =>     l_cag_segment13
18104        ,p_cag_segment14                =>     l_cag_segment14
18105        ,p_cag_segment15                =>     l_cag_segment15
18106        ,p_cag_segment16                =>     l_cag_segment16
18107        ,p_cag_segment17                =>     l_cag_segment17
18108        ,p_cag_segment18                =>     l_cag_segment18
18109        ,p_cag_segment19                =>     l_cag_segment19
18110        ,p_cag_segment20                =>     l_cag_segment20
18111        ,p_notice_period		       =>     p_notice_period
18112        ,p_notice_period_uom	       =>     p_notice_period_uom
18113        ,p_employee_category	       =>     p_employee_category
18114        ,p_work_at_home		       =>     p_work_at_home
18115        ,p_job_post_source_name	       =>     p_job_post_source_name
18116        ,p_cagr_grade_def_id            =>     l_cagr_grade_def_id
18117        ,p_cagr_concatenated_segments   =>     l_cagr_concatenated_segments
18118        ,p_group_name                   =>     l_group_name
18119        ,p_comment_id                   =>     l_comment_id
18120        ,p_people_group_id              =>     l_people_group_id
18121        ,p_effective_start_date         =>     l_effective_start_date
18122        ,p_effective_end_date           =>     l_effective_end_date
18123        ,p_applicant_rank               =>     p_applicant_rank
18124        ,p_posting_content_id           =>     p_posting_content_id
18125        --
18126        -- Bug 944911
18127        -- Added the 2 additional IN param
18128        -- Bug 944911
18129        -- Amended p_group_name to p_concat_segments
18130        --
18131        ,p_concat_segments              =>     l_old_group_name
18132        --
18133        -- Bug 944911
18134        -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
18135        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
18136        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
18137        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
18138        );
18139   exception
18140      when hr_api.cannot_find_prog_unit then
18141        hr_api.cannot_find_prog_unit_error
18142          (p_module_name       => 'UPDATE_APL_ASG',
18143           p_hook_type         => 'AP'
18144          );
18145   end;
18146   --
18147   -- End of API User Hook for the after hook of suspend_emp_asg.
18148   --
18149   --
18150   -- When in validation only mode raise the Validate_Enabled exception
18151   --
18152   if p_validate then
18153     raise hr_api.validate_enabled;
18154   end if;
18155   --
18156   -- Set all output arguments
18157   --
18158 -- Bug 944911
18159 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
18160   p_object_version_number  := l_object_version_number;
18161   p_comment_id             := l_comment_id;
18162   p_effective_start_date   := l_effective_start_date;
18163   p_effective_end_date     := l_effective_end_date;
18164   p_people_group_id        := l_people_group_id;
18165   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
18166   p_concatenated_segments  := l_scl_concatenated_segments;
18167   p_group_name             := l_group_name;
18168   --
18169   p_cagr_grade_def_id          := l_cagr_grade_def_id;
18170   p_cagr_concatenated_segments := l_cagr_concatenated_segments;
18171   --
18172   -- remove data from the session table
18173   hr_kflex_utility.unset_session_date
18174     (p_session_id     => l_session_id);
18175   --
18176  if g_debug then
18177   hr_utility.set_location(' Leaving:'||l_proc, 6);
18178  end if;
18179 exception
18180   when hr_api.validate_enabled then
18181     --
18182     -- As the Validate_Enabled exception has been raised
18183     -- we must rollback to the savepoint
18184     --
18185     ROLLBACK TO update_apl_asg;
18186     --
18187     -- Only set output warning arguments
18188     -- (Any key or derived arguments must be set to null
18189     -- when validation only mode is being used.)
18190     --
18191     p_object_version_number  := p_object_version_number;
18192     p_comment_id             := null;
18193     p_effective_start_date   := null;
18194     p_effective_end_date     := null;
18195     --
18196     -- bug 2230915 only re-set to null if key flex ids came in as null.
18197     --
18198     if l_scl_null_ind = 0
18199     then
18200        p_soft_coding_keyflex_id  := null;
18201     end if;
18202     --
18203     if l_pgp_null_ind = 0
18204     then
18205        p_people_group_id         := null;
18206     end if;
18207     --
18208     if l_cag_null_ind = 0
18209     then
18210        p_cagr_grade_def_id       := null;
18211     end if;
18212     --
18213     -- Bug 944911
18214     -- Amended scl_concatenated_segments to be concatenated_segments
18215     p_concatenated_segments := l_old_scl_conc_segments;
18216     p_group_name            := l_old_group_name;
18217     p_cagr_concatenated_segments := null;
18218     --
18219     --
18220     when others then
18221        --
18222        -- A validation or unexpected error has occurred
18223        --
18224        -- Added as part of fix to bug 632479
18225        --
18226        p_object_version_number     := lv_object_version_number ;
18227        p_cagr_grade_def_id         := lv_cagr_grade_def_id ;
18228        p_people_group_id           := lv_people_group_id ;
18229        p_soft_coding_keyflex_id    := lv_soft_coding_keyflex_id ;
18230 
18231        p_concatenated_segments      := null;
18232        p_cagr_concatenated_segments := null;
18233        p_group_name                 := null;
18234        p_comment_id                 := null;
18235        p_effective_start_date       := null;
18236        p_effective_end_date         := null;
18237 
18238        ROLLBACK TO update_apl_asg;
18239        raise;
18240        --
18241        -- End of fix.
18242        --
18243 end update_apl_asg;
18244 --
18245 -- ----------------------------------------------------------------------------
18246 -- |--------------------------< update_apl_asg >-----R11-----------------------|
18247 -- ----------------------------------------------------------------------------
18248 --
18249 -- This is an overloaded procedure to include new parms
18250 -- for contracts and collective agreements
18251 --
18252 procedure update_apl_asg
18253   (p_validate                     in     boolean
18254   ,p_effective_date               in     date
18255   ,p_datetrack_update_mode        in     varchar2
18256   ,p_assignment_id                in     number
18257   ,p_object_version_number        in out nocopy number
18258   ,p_grade_id                     in     number
18259   ,p_job_id                       in     number
18260   ,p_location_id                  in     number
18261   ,p_organization_id              in     number
18262   ,p_position_id                  in     number
18263   ,p_application_id               in     number
18264   ,p_recruiter_id                 in     number
18265   ,p_recruitment_activity_id      in     number
18266   ,p_vacancy_id                   in     number
18267   ,p_person_referred_by_id        in     number
18268   ,p_supervisor_id                in     number
18269   ,p_source_organization_id       in     number
18270   ,p_change_reason                in     varchar2
18271   ,p_frequency                    in     varchar2
18272   ,p_manager_flag                 in     varchar2
18273   ,p_normal_hours                 in     number
18274   ,p_probation_period             in     number
18275   ,p_probation_unit               in     varchar2
18276   ,p_source_type                  in     varchar2
18277   ,p_time_normal_finish           in     varchar2
18278   ,p_time_normal_start            in     varchar2
18279   ,p_comments                     in     varchar2
18280   ,p_date_probation_end           in     date
18281   ,p_title                        in     varchar2
18282   ,p_ass_attribute_category       in     varchar2
18283   ,p_ass_attribute1               in     varchar2
18284   ,p_ass_attribute2               in     varchar2
18285   ,p_ass_attribute3               in     varchar2
18286   ,p_ass_attribute4               in     varchar2
18287   ,p_ass_attribute5               in     varchar2
18288   ,p_ass_attribute6               in     varchar2
18289   ,p_ass_attribute7               in     varchar2
18290   ,p_ass_attribute8               in     varchar2
18291   ,p_ass_attribute9               in     varchar2
18292   ,p_ass_attribute10              in     varchar2
18293   ,p_ass_attribute11              in     varchar2
18294   ,p_ass_attribute12              in     varchar2
18295   ,p_ass_attribute13              in     varchar2
18296   ,p_ass_attribute14              in     varchar2
18297   ,p_ass_attribute15              in     varchar2
18298   ,p_ass_attribute16              in     varchar2
18299   ,p_ass_attribute17              in     varchar2
18300   ,p_ass_attribute18              in     varchar2
18301   ,p_ass_attribute19              in     varchar2
18302   ,p_ass_attribute20              in     varchar2
18303   ,p_ass_attribute21              in     varchar2
18304   ,p_ass_attribute22              in     varchar2
18305   ,p_ass_attribute23              in     varchar2
18306   ,p_ass_attribute24              in     varchar2
18307   ,p_ass_attribute25              in     varchar2
18308   ,p_ass_attribute26              in     varchar2
18309   ,p_ass_attribute27              in     varchar2
18310   ,p_ass_attribute28              in     varchar2
18311   ,p_ass_attribute29              in     varchar2
18312   ,p_ass_attribute30              in     varchar2
18313   ,p_segment1                     in     varchar2
18314   ,p_segment2                     in     varchar2
18315   ,p_segment3                     in     varchar2
18316   ,p_segment4                     in     varchar2
18317   ,p_segment5                     in     varchar2
18318   ,p_segment6                     in     varchar2
18319   ,p_segment7                     in     varchar2
18320   ,p_segment8                     in     varchar2
18321   ,p_segment9                     in     varchar2
18322   ,p_segment10                    in     varchar2
18323   ,p_segment11                    in     varchar2
18324   ,p_segment12                    in     varchar2
18325   ,p_segment13                    in     varchar2
18326   ,p_segment14                    in     varchar2
18327   ,p_segment15                    in     varchar2
18328   ,p_segment16                    in     varchar2
18329   ,p_segment17                    in     varchar2
18330   ,p_segment18                    in     varchar2
18331   ,p_segment19                    in     varchar2
18332   ,p_segment20                    in     varchar2
18333   ,p_segment21                    in     varchar2
18334   ,p_segment22                    in     varchar2
18335   ,p_segment23                    in     varchar2
18336   ,p_segment24                    in     varchar2
18337   ,p_segment25                    in     varchar2
18338   ,p_segment26                    in     varchar2
18339   ,p_segment27                    in     varchar2
18340   ,p_segment28                    in     varchar2
18341   ,p_segment29                    in     varchar2
18342   ,p_segment30                    in     varchar2
18343 -- Bug 944911
18344 -- Amended p_concat_segments to be an in instead of in out
18345 -- Added p_concatenated_segments to be out
18346 -- Reverting back changes as this for compatibilty with v11
18347   --,p_concat_segments              in     varchar2
18348   ,p_supervisor_assignment_id     in     number
18349   ,p_concatenated_segments           in out nocopy varchar2
18350   ,p_comment_id                      out nocopy number
18351   ,p_people_group_id                 out nocopy number  -- in out?
18352   ,p_effective_start_date            out nocopy date
18353   ,p_effective_end_date              out nocopy date
18354  ) is
18355   --
18356   -- Declare cursors and local variables
18357   --
18358   -- Out variables
18359   --
18360   l_comment_id                 per_all_assignments_f.comment_id%TYPE;
18361   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
18362   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
18363   l_dummy_payroll              boolean;
18364   l_dummy_manager1             boolean;
18365   l_dummy_manager2             boolean;
18366   l_dummy_manager3             boolean;
18367   l_validation_start_date      per_all_assignments_f.effective_start_date%TYPE;
18368   l_validation_end_date        per_all_assignments_f.effective_end_date%TYPE;
18369   l_object_version_number      per_all_assignments_f.object_version_number%TYPE;
18370   l_effective_date             date;
18371   l_date_probation_end         date;
18372   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
18373   l_concatenated_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
18374   l_cagr_concatenated_segments varchar2(2000);
18375   l_cagr_grade_def_id          per_cagr_grades_def.cagr_grade_def_id%TYPE;
18376 --
18377 
18378 -- Bug 944911
18379 -- added an new var to handle in and out
18380   l_concat_segments      hr_soft_coding_keyflex.concatenated_segments%TYPE;
18381   l_soft_coding_keyflex_id      hr_soft_coding_keyflex.soft_coding_keyflex_id%TYPE;
18382   --
18383   -- Internal working variables
18384   --
18385   l_business_group_id          per_business_groups.business_group_id%TYPE;
18386   l_people_group_id            per_all_assignments_f.people_group_id%TYPE;
18387   l_group_name                 pay_people_groups.group_name%TYPE;
18388   l_proc                       varchar2(72);
18389   l_api_updating               boolean;
18390   --
18391 begin
18392  if g_debug then
18393   l_proc := g_package||'update_apl_asg';
18394   hr_utility.set_location('Entering:'|| l_proc, 1);
18395  end if;
18396   --
18397   l_object_version_number := p_object_version_number ;
18398 -- bug 944911
18399 -- made concatenated to concat
18400 -- changing p_concat to p_concatenated
18401   l_concat_segments := p_concatenated_segments;
18402   --
18403   -- Call the new code
18404 -- bug 944911
18405 -- made no changes to p_group_name as it is out , while in is
18406   hr_assignment_api.update_apl_asg(
18407    p_validate                     => p_validate
18408   ,p_effective_date               => p_effective_date
18409   ,p_datetrack_update_mode        => p_datetrack_update_mode
18410   ,p_assignment_id                => p_assignment_id
18411   ,p_object_version_number        => l_object_version_number
18412   ,p_grade_id                     => p_grade_id
18413   ,p_job_id                       => p_job_id
18414   ,p_location_id                  => p_location_id
18415   ,p_organization_id              => p_organization_id
18416   ,p_position_id                  => p_position_id
18417   ,p_application_id               => p_application_id
18418   ,p_recruiter_id                 => p_recruiter_id
18419   ,p_recruitment_activity_id      => p_recruitment_activity_id
18420   ,p_vacancy_id                   => p_vacancy_id
18421   ,p_person_referred_by_id        => p_person_referred_by_id
18422   ,p_supervisor_id                => p_supervisor_id
18423   ,p_source_organization_id       => p_source_organization_id
18424   ,p_change_reason                => p_change_reason
18425   ,p_frequency                    => p_frequency
18426   ,p_manager_flag                 => p_manager_flag
18427   ,p_normal_hours                 => p_normal_hours
18428   ,p_probation_period             => p_probation_period
18429   ,p_probation_unit               => p_probation_unit
18430   ,p_source_type                  => p_source_type
18431   ,p_time_normal_finish           => p_time_normal_finish
18432   ,p_time_normal_start            => p_time_normal_start
18433   ,p_comments                     => p_comments
18434   ,p_date_probation_end           => p_date_probation_end
18435   ,p_title                        => p_title
18436   ,p_ass_attribute_category       => p_ass_attribute_category
18437   ,p_ass_attribute1               => p_ass_attribute1
18438   ,p_ass_attribute2               => p_ass_attribute2
18439   ,p_ass_attribute3               => p_ass_attribute3
18440   ,p_ass_attribute4               => p_ass_attribute4
18441   ,p_ass_attribute5               => p_ass_attribute5
18442   ,p_ass_attribute6               => p_ass_attribute6
18443   ,p_ass_attribute7               => p_ass_attribute7
18444   ,p_ass_attribute8               => p_ass_attribute8
18445   ,p_ass_attribute9               => p_ass_attribute9
18446   ,p_ass_attribute10              => p_ass_attribute10
18447   ,p_ass_attribute11              => p_ass_attribute11
18448   ,p_ass_attribute12              => p_ass_attribute12
18449   ,p_ass_attribute13              => p_ass_attribute13
18450   ,p_ass_attribute14              => p_ass_attribute14
18451   ,p_ass_attribute15              => p_ass_attribute15
18452   ,p_ass_attribute16              => p_ass_attribute16
18453   ,p_ass_attribute17              => p_ass_attribute17
18454   ,p_ass_attribute18              => p_ass_attribute18
18455   ,p_ass_attribute19              => p_ass_attribute19
18456   ,p_ass_attribute20              => p_ass_attribute20
18457   ,p_ass_attribute21              => p_ass_attribute21
18458   ,p_ass_attribute22              => p_ass_attribute22
18459   ,p_ass_attribute23              => p_ass_attribute23
18460   ,p_ass_attribute24              => p_ass_attribute24
18461   ,p_ass_attribute25              => p_ass_attribute25
18462   ,p_ass_attribute26              => p_ass_attribute26
18463   ,p_ass_attribute27              => p_ass_attribute27
18464   ,p_ass_attribute28              => p_ass_attribute28
18465   ,p_ass_attribute29              => p_ass_attribute29
18466   ,p_ass_attribute30              => p_ass_attribute30
18467   ,p_scl_segment1                     => p_segment1
18468   ,p_scl_segment2                     => p_segment2
18469   ,p_scl_segment3                     => p_segment3
18470   ,p_scl_segment4                     => p_segment4
18471   ,p_scl_segment5                     => p_segment5
18472   ,p_scl_segment6                     => p_segment6
18473   ,p_scl_segment7                     => p_segment7
18474   ,p_scl_segment8                     => p_segment8
18475   ,p_scl_segment9                     => p_segment9
18476   ,p_scl_segment10                    => p_segment10
18477   ,p_scl_segment11                    => p_segment11
18478   ,p_scl_segment12                    => p_segment12
18479   ,p_scl_segment13                    => p_segment13
18480   ,p_scl_segment14                    => p_segment14
18481   ,p_scl_segment15                    => p_segment15
18482   ,p_scl_segment16                    => p_segment16
18483   ,p_scl_segment17                    => p_segment17
18484   ,p_scl_segment18                    => p_segment18
18485   ,p_scl_segment19                    => p_segment19
18486   ,p_scl_segment20                    => p_segment20
18487   ,p_scl_segment21                    => p_segment21
18488   ,p_scl_segment22                    => p_segment22
18489   ,p_scl_segment23                    => p_segment23
18490   ,p_scl_segment24                    => p_segment24
18491   ,p_scl_segment25                    => p_segment25
18492   ,p_scl_segment26                    => p_segment26
18493   ,p_scl_segment27                    => p_segment27
18494   ,p_scl_segment28                    => p_segment28
18495   ,p_scl_segment29                    => p_segment29
18496   ,p_scl_segment30                    => p_segment30
18497   ,p_comment_id                   => l_comment_id
18498   ,p_people_group_id              => l_people_group_id
18499   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
18500   ,p_effective_start_date         => l_effective_start_date
18501   ,p_effective_end_date           => l_effective_end_date
18502   ,p_group_name                   => l_group_name
18503   ,p_scl_concat_segments    => l_concat_segments
18504   ,p_concatenated_segments    => l_concatenated_segments
18505   ,p_cagr_grade_def_id            =>     l_cagr_grade_def_id
18506   ,p_cagr_concatenated_segments   =>     l_cagr_concatenated_segments
18507   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
18508   );
18509   -- Set all output arguments
18510   -- Ignore the overloaded out arguments
18511   --
18512   p_object_version_number  := l_object_version_number;
18513   p_comment_id             := l_comment_id;
18514   p_effective_start_date   := l_effective_start_date;
18515   p_effective_end_date     := l_effective_end_date;
18516   p_people_group_id        := l_people_group_id;
18517   --
18518  if g_debug then
18519   hr_utility.set_location(' Leaving:'||l_proc, 6);
18520  end if;
18521 end update_apl_asg;
18522 --
18523 -- OLD
18524 -- ----------------------------------------------------------------------------
18525 -- |---------------------< create_secondary_apl_asg >-------------------------|
18526 -- ----------------------------------------------------------------------------
18527 procedure create_secondary_apl_asg
18528   (p_validate                     in     boolean
18529   ,p_effective_date               in     date
18530   ,p_person_id                    in     number
18531   ,p_organization_id              in     number
18532   ,p_recruiter_id                 in     number
18533   ,p_grade_id                     in     number
18534   ,p_position_id                  in     number
18535   ,p_job_id                       in     number
18536   ,p_assignment_status_type_id    in     number
18537   ,p_payroll_id                   in     number
18538   ,p_location_id                  in     number
18539   ,p_person_referred_by_id        in     number
18540   ,p_supervisor_id                in     number
18541   ,p_special_ceiling_step_id      in     number
18542   ,p_recruitment_activity_id      in     number
18543   ,p_source_organization_id       in     number
18544   ,p_vacancy_id                   in     number
18545   ,p_pay_basis_id                 in     number
18546   ,p_change_reason                in     varchar2
18547   ,p_comments                     in     varchar2
18548   ,p_date_probation_end           in     date
18549   ,p_default_code_comb_id         in     number
18550   ,p_employment_category          in     varchar2
18551   ,p_frequency                    in     varchar2
18552   ,p_internal_address_line        in     varchar2
18553   ,p_manager_flag                 in     varchar2
18554   ,p_normal_hours                 in     number
18555   ,p_perf_review_period           in     number
18556   ,p_perf_review_period_frequency in     varchar2
18557   ,p_probation_period             in     number
18558   ,p_probation_unit               in     varchar2
18559   ,p_sal_review_period            in     number
18560   ,p_sal_review_period_frequency  in     varchar2
18561   ,p_set_of_books_id              in     number
18562   ,p_source_type                  in     varchar2
18563   ,p_time_normal_finish           in     varchar2
18564   ,p_time_normal_start            in     varchar2
18565   ,p_bargaining_unit_code         in     varchar2
18566   ,p_ass_attribute_category       in     varchar2
18567   ,p_ass_attribute1               in     varchar2
18568   ,p_ass_attribute2               in     varchar2
18569   ,p_ass_attribute3               in     varchar2
18570   ,p_ass_attribute4               in     varchar2
18571   ,p_ass_attribute5               in     varchar2
18572   ,p_ass_attribute6               in     varchar2
18573   ,p_ass_attribute7               in     varchar2
18574   ,p_ass_attribute8               in     varchar2
18575   ,p_ass_attribute9               in     varchar2
18576   ,p_ass_attribute10              in     varchar2
18577   ,p_ass_attribute11              in     varchar2
18578   ,p_ass_attribute12              in     varchar2
18579   ,p_ass_attribute13              in     varchar2
18580   ,p_ass_attribute14              in     varchar2
18581   ,p_ass_attribute15              in     varchar2
18582   ,p_ass_attribute16              in     varchar2
18583   ,p_ass_attribute17              in     varchar2
18584   ,p_ass_attribute18              in     varchar2
18585   ,p_ass_attribute19              in     varchar2
18586   ,p_ass_attribute20              in     varchar2
18587   ,p_ass_attribute21              in     varchar2
18588   ,p_ass_attribute22              in     varchar2
18589   ,p_ass_attribute23              in     varchar2
18590   ,p_ass_attribute24              in     varchar2
18591   ,p_ass_attribute25              in     varchar2
18592   ,p_ass_attribute26              in     varchar2
18593   ,p_ass_attribute27              in     varchar2
18594   ,p_ass_attribute28              in     varchar2
18595   ,p_ass_attribute29              in     varchar2
18596   ,p_ass_attribute30              in     varchar2
18597   ,p_title                        in     varchar2
18598   ,p_scl_segment1                 in     varchar2
18599   ,p_scl_segment2                 in     varchar2
18600   ,p_scl_segment3                 in     varchar2
18601   ,p_scl_segment4                 in     varchar2
18602   ,p_scl_segment5                 in     varchar2
18603   ,p_scl_segment6                 in     varchar2
18604   ,p_scl_segment7                 in     varchar2
18605   ,p_scl_segment8                 in     varchar2
18606   ,p_scl_segment9                 in     varchar2
18607   ,p_scl_segment10                in     varchar2
18608   ,p_scl_segment11                in     varchar2
18609   ,p_scl_segment12                in     varchar2
18610   ,p_scl_segment13                in     varchar2
18611   ,p_scl_segment14                in     varchar2
18612   ,p_scl_segment15                in     varchar2
18613   ,p_scl_segment16                in     varchar2
18614   ,p_scl_segment17                in     varchar2
18615   ,p_scl_segment18                in     varchar2
18616   ,p_scl_segment19                in     varchar2
18617   ,p_scl_segment20                in     varchar2
18618   ,p_scl_segment21                in     varchar2
18619   ,p_scl_segment22                in     varchar2
18620   ,p_scl_segment23                in     varchar2
18621   ,p_scl_segment24                in     varchar2
18622   ,p_scl_segment25                in     varchar2
18623   ,p_scl_segment26                in     varchar2
18624   ,p_scl_segment27                in     varchar2
18625   ,p_scl_segment28                in     varchar2
18626   ,p_scl_segment29                in     varchar2
18627   ,p_scl_segment30                in     varchar2
18628   ,p_scl_concat_segments          in     varchar2
18629   ,p_concatenated_segments           out nocopy varchar2
18630   ,p_pgp_segment1                 in     varchar2
18631   ,p_pgp_segment2                 in     varchar2
18632   ,p_pgp_segment3                 in     varchar2
18633   ,p_pgp_segment4                 in     varchar2
18634   ,p_pgp_segment5                 in     varchar2
18635   ,p_pgp_segment6                 in     varchar2
18636   ,p_pgp_segment7                 in     varchar2
18637   ,p_pgp_segment8                 in     varchar2
18638   ,p_pgp_segment9                 in     varchar2
18639   ,p_pgp_segment10                in     varchar2
18640   ,p_pgp_segment11                in     varchar2
18641   ,p_pgp_segment12                in     varchar2
18642   ,p_pgp_segment13                in     varchar2
18643   ,p_pgp_segment14                in     varchar2
18644   ,p_pgp_segment15                in     varchar2
18645   ,p_pgp_segment16                in     varchar2
18646   ,p_pgp_segment17                in     varchar2
18647   ,p_pgp_segment18                in     varchar2
18648   ,p_pgp_segment19                in     varchar2
18649   ,p_pgp_segment20                in     varchar2
18650   ,p_pgp_segment21                in     varchar2
18651   ,p_pgp_segment22                in     varchar2
18652   ,p_pgp_segment23                in     varchar2
18653   ,p_pgp_segment24                in     varchar2
18654   ,p_pgp_segment25                in     varchar2
18655   ,p_pgp_segment26                in     varchar2
18656   ,p_pgp_segment27                in     varchar2
18657   ,p_pgp_segment28                in     varchar2
18658   ,p_pgp_segment29                in     varchar2
18659   ,p_pgp_segment30                in     varchar2
18660   ,p_concat_segments		  in     varchar2
18661   ,p_contract_id                  in     number
18662   ,p_establishment_id             in     number
18663   ,p_collective_agreement_id      in     number
18664   ,p_cagr_id_flex_num             in     number
18665   ,p_cag_segment1                 in     varchar2
18666   ,p_cag_segment2                 in     varchar2
18667   ,p_cag_segment3                 in     varchar2
18668   ,p_cag_segment4                 in     varchar2
18669   ,p_cag_segment5                 in     varchar2
18670   ,p_cag_segment6                 in     varchar2
18671   ,p_cag_segment7                 in     varchar2
18672   ,p_cag_segment8                 in     varchar2
18673   ,p_cag_segment9                 in     varchar2
18674   ,p_cag_segment10                in     varchar2
18675   ,p_cag_segment11                in     varchar2
18676   ,p_cag_segment12                in     varchar2
18677   ,p_cag_segment13                in     varchar2
18678   ,p_cag_segment14                in     varchar2
18679   ,p_cag_segment15                in     varchar2
18680   ,p_cag_segment16                in     varchar2
18681   ,p_cag_segment17                in     varchar2
18682   ,p_cag_segment18                in     varchar2
18683   ,p_cag_segment19                in     varchar2
18684   ,p_cag_segment20                in     varchar2
18685   ,p_notice_period		  in	 number
18686   ,p_notice_period_uom		  in     varchar2
18687   ,p_employee_category		  in     varchar2
18688   ,p_work_at_home		  in	 varchar2
18689   ,p_job_post_source_name         in     varchar2
18690   ,p_applicant_rank               in     number
18691   ,p_posting_content_id           in     number
18692   ,p_grade_ladder_pgm_id          in     number
18693   ,p_supervisor_assignment_id     in     number
18694   ,p_cagr_grade_def_id            in out nocopy number
18695   ,p_cagr_concatenated_segments      out nocopy varchar2
18696   ,p_group_name                      out nocopy varchar2
18697   ,p_assignment_id                   out nocopy number
18698   ,p_people_group_id              in out nocopy number
18699   ,p_soft_coding_keyflex_id       in out nocopy number
18700   ,p_comment_id                      out nocopy number
18701   ,p_object_version_number           out nocopy number
18702   ,p_effective_start_date            out nocopy date
18703   ,p_effective_end_date              out nocopy date
18704   ,p_assignment_sequence             out nocopy number
18705   ) is
18706   l_warning boolean;
18707 BEGIN
18708  create_secondary_apl_asg
18709   (p_validate                     => p_validate
18710   ,p_effective_date               => p_effective_date
18711   ,p_person_id                    => p_person_id
18712   ,p_organization_id              => p_organization_id
18713   ,p_recruiter_id                 => p_recruiter_id
18714   ,p_grade_id                     => p_grade_id
18715   ,p_position_id                  =>  p_position_id
18716   ,p_job_id                       => p_job_id
18717   ,p_assignment_status_type_id    => p_assignment_status_type_id
18718   ,p_payroll_id                   => p_payroll_id
18719   ,p_location_id                  => p_location_id
18720   ,p_person_referred_by_id        => p_person_referred_by_id
18721   ,p_supervisor_id                => p_supervisor_id
18722   ,p_special_ceiling_step_id      => p_special_ceiling_step_id
18723   ,p_recruitment_activity_id      => p_recruitment_activity_id
18724   ,p_source_organization_id       => p_source_organization_id
18725   ,p_vacancy_id                   => p_vacancy_id
18726   ,p_pay_basis_id                 => p_pay_basis_id
18727   ,p_change_reason                => p_change_reason
18728   ,p_comments                     => p_comments
18729   ,p_date_probation_end           => p_date_probation_end
18730   ,p_default_code_comb_id         => p_default_code_comb_id
18731   ,p_employment_category          => p_employment_category
18732   ,p_frequency                    => p_frequency
18733   ,p_internal_address_line        => p_internal_address_line
18734   ,p_manager_flag                 => p_manager_flag
18735   ,p_normal_hours                 => p_normal_hours
18736   ,p_perf_review_period           => p_perf_review_period
18737   ,p_perf_review_period_frequency => p_perf_review_period_frequency
18738   ,p_probation_period             => p_probation_period
18739   ,p_probation_unit               => p_probation_unit
18740   ,p_sal_review_period            => p_sal_review_period
18741   ,p_sal_review_period_frequency  => p_sal_review_period_frequency
18742   ,p_set_of_books_id              => p_set_of_books_id
18743   ,p_source_type                  => p_source_type
18744   ,p_time_normal_finish           => p_time_normal_finish
18745   ,p_time_normal_start            => p_time_normal_start
18746   ,p_bargaining_unit_code         => p_bargaining_unit_code
18747   ,p_ass_attribute_category       => p_ass_attribute_category
18748   ,p_ass_attribute1               => p_ass_attribute1
18749   ,p_ass_attribute2               => p_ass_attribute2
18750   ,p_ass_attribute3               => p_ass_attribute3
18751   ,p_ass_attribute4               => p_ass_attribute4
18752   ,p_ass_attribute5               => p_ass_attribute5
18753   ,p_ass_attribute6               => p_ass_attribute6
18754   ,p_ass_attribute7               => p_ass_attribute7
18755   ,p_ass_attribute8               => p_ass_attribute8
18756   ,p_ass_attribute9               => p_ass_attribute9
18757   ,p_ass_attribute10              => p_ass_attribute10
18758   ,p_ass_attribute11              => p_ass_attribute11
18759   ,p_ass_attribute12              => p_ass_attribute12
18760   ,p_ass_attribute13              => p_ass_attribute13
18761   ,p_ass_attribute14              => p_ass_attribute14
18762   ,p_ass_attribute15              => p_ass_attribute15
18763   ,p_ass_attribute16              => p_ass_attribute16
18764   ,p_ass_attribute17              => p_ass_attribute17
18765   ,p_ass_attribute18              => p_ass_attribute18
18766   ,p_ass_attribute19              => p_ass_attribute19
18767   ,p_ass_attribute20              => p_ass_attribute20
18768   ,p_ass_attribute21              => p_ass_attribute21
18769   ,p_ass_attribute22              => p_ass_attribute22
18770   ,p_ass_attribute23              => p_ass_attribute23
18771   ,p_ass_attribute24              => p_ass_attribute24
18772   ,p_ass_attribute25              => p_ass_attribute25
18773   ,p_ass_attribute26              => p_ass_attribute26
18774   ,p_ass_attribute27              => p_ass_attribute27
18775   ,p_ass_attribute28              => p_ass_attribute28
18776   ,p_ass_attribute29              => p_ass_attribute29
18777   ,p_ass_attribute30              => p_ass_attribute30
18778   ,p_title                        => p_title
18779   ,p_scl_segment1                 => p_scl_segment1
18780   ,p_scl_segment2                 => p_scl_segment2
18781   ,p_scl_segment3                 => p_scl_segment3
18782   ,p_scl_segment4                 => p_scl_segment4
18783   ,p_scl_segment5                 => p_scl_segment5
18784   ,p_scl_segment6                 => p_scl_segment6
18785   ,p_scl_segment7                 => p_scl_segment7
18786   ,p_scl_segment8                 => p_scl_segment8
18787   ,p_scl_segment9                 => p_scl_segment9
18788   ,p_scl_segment10                => p_scl_segment10
18789   ,p_scl_segment11                => p_scl_segment11
18790   ,p_scl_segment12                => p_scl_segment12
18791   ,p_scl_segment13                => p_scl_segment13
18792   ,p_scl_segment14                => p_scl_segment14
18793   ,p_scl_segment15                => p_scl_segment15
18794   ,p_scl_segment16                => p_scl_segment16
18795   ,p_scl_segment17                => p_scl_segment17
18796   ,p_scl_segment18                => p_scl_segment18
18797   ,p_scl_segment19                => p_scl_segment19
18798   ,p_scl_segment20                => p_scl_segment20
18799   ,p_scl_segment21                => p_scl_segment21
18800   ,p_scl_segment22                => p_scl_segment22
18801   ,p_scl_segment23                => p_scl_segment23
18802   ,p_scl_segment24                => p_scl_segment24
18803   ,p_scl_segment25                => p_scl_segment25
18804   ,p_scl_segment26                => p_scl_segment26
18805   ,p_scl_segment27                => p_scl_segment27
18806   ,p_scl_segment28                => p_scl_segment28
18807   ,p_scl_segment29                => p_scl_segment29
18808   ,p_scl_segment30                => p_scl_segment30
18809   ,p_scl_concat_segments          => p_scl_concat_segments
18810   ,p_concatenated_segments        => p_concatenated_segments
18811   ,p_pgp_segment1                 => p_pgp_segment1
18812   ,p_pgp_segment2                 => p_pgp_segment2
18813   ,p_pgp_segment3                 => p_pgp_segment3
18814   ,p_pgp_segment4                 => p_pgp_segment4
18815   ,p_pgp_segment5                 => p_pgp_segment5
18816   ,p_pgp_segment6                 => p_pgp_segment6
18817   ,p_pgp_segment7                 => p_pgp_segment7
18818   ,p_pgp_segment8                 => p_pgp_segment8
18819   ,p_pgp_segment9                 => p_pgp_segment9
18820   ,p_pgp_segment10                => p_pgp_segment10
18821   ,p_pgp_segment11                => p_pgp_segment11
18822   ,p_pgp_segment12                => p_pgp_segment12
18823   ,p_pgp_segment13                => p_pgp_segment13
18824   ,p_pgp_segment14                => p_pgp_segment14
18825   ,p_pgp_segment15                => p_pgp_segment15
18826   ,p_pgp_segment16                => p_pgp_segment16
18827   ,p_pgp_segment17                => p_pgp_segment17
18828   ,p_pgp_segment18                => p_pgp_segment18
18829   ,p_pgp_segment19                => p_pgp_segment19
18830   ,p_pgp_segment20                => p_pgp_segment20
18831   ,p_pgp_segment21                => p_pgp_segment21
18832   ,p_pgp_segment22                => p_pgp_segment22
18833   ,p_pgp_segment23                => p_pgp_segment23
18834   ,p_pgp_segment24                => p_pgp_segment24
18835   ,p_pgp_segment25                => p_pgp_segment25
18836   ,p_pgp_segment26                => p_pgp_segment26
18837   ,p_pgp_segment27                => p_pgp_segment27
18838   ,p_pgp_segment28                => p_pgp_segment28
18839   ,p_pgp_segment29                => p_pgp_segment29
18840   ,p_pgp_segment30                => p_pgp_segment30
18841   ,p_concat_segments		      => p_concat_segments
18842   ,p_contract_id                  => p_contract_id
18843   ,p_establishment_id             => p_establishment_id
18844   ,p_collective_agreement_id      => p_collective_agreement_id
18845   ,p_cagr_id_flex_num             => p_cagr_id_flex_num
18846   ,p_cag_segment1                 => p_cag_segment1
18847   ,p_cag_segment2                 => p_cag_segment2
18848   ,p_cag_segment3                 => p_cag_segment3
18849   ,p_cag_segment4                 => p_cag_segment4
18850   ,p_cag_segment5                 => p_cag_segment5
18851   ,p_cag_segment6                 => p_cag_segment6
18852   ,p_cag_segment7                 => p_cag_segment7
18853   ,p_cag_segment8                 => p_cag_segment8
18854   ,p_cag_segment9                 => p_cag_segment9
18855   ,p_cag_segment10                => p_cag_segment10
18856   ,p_cag_segment11                => p_cag_segment11
18857   ,p_cag_segment12                => p_cag_segment12
18858   ,p_cag_segment13                => p_cag_segment13
18859   ,p_cag_segment14                => p_cag_segment14
18860   ,p_cag_segment15                => p_cag_segment15
18861   ,p_cag_segment16                => p_cag_segment16
18862   ,p_cag_segment17                => p_cag_segment17
18863   ,p_cag_segment18                => p_cag_segment18
18864   ,p_cag_segment19                => p_cag_segment19
18865   ,p_cag_segment20                => p_cag_segment20
18866   ,p_notice_period		          => p_notice_period
18867   ,p_notice_period_uom		      => p_notice_period_uom
18868   ,p_employee_category		      => p_employee_category
18869   ,p_work_at_home		          => p_work_at_home
18870   ,p_job_post_source_name         => p_job_post_source_name
18871   ,p_applicant_rank               => p_applicant_rank
18872   ,p_posting_content_id           => p_posting_content_id
18873   ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
18874   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
18875   ,p_cagr_grade_def_id            => p_cagr_grade_def_id
18876   ,p_cagr_concatenated_segments   => p_cagr_concatenated_segments
18877   ,p_group_name                   => p_group_name
18878   ,p_assignment_id                => p_assignment_id
18879   ,p_people_group_id              => p_people_group_id
18880   ,p_soft_coding_keyflex_id       => p_soft_coding_keyflex_id
18881   ,p_comment_id                   => p_comment_id
18882   ,p_object_version_number        => p_object_version_number
18883   ,p_effective_start_date         => p_effective_start_date
18884   ,p_effective_end_date           => p_effective_end_date
18885   ,p_assignment_sequence          => p_assignment_sequence
18886   ,p_appl_override_warning        => l_warning
18887   );
18888 
18889 END;
18890 -- NEW
18891 -- ----------------------------------------------------------------------------
18892 -- |---------------------< create_secondary_apl_asg >-------------------------|
18893 -- ----------------------------------------------------------------------------
18894 -- NEW
18895 procedure create_secondary_apl_asg
18896   (p_validate                     in     boolean
18897   ,p_effective_date               in     date
18898   ,p_person_id                    in     number
18899   ,p_organization_id              in     number
18900   ,p_recruiter_id                 in     number
18901   ,p_grade_id                     in     number
18902   ,p_position_id                  in     number
18903   ,p_job_id                       in     number
18904   ,p_assignment_status_type_id    in     number
18905   ,p_payroll_id                   in     number
18906   ,p_location_id                  in     number
18907   ,p_person_referred_by_id        in     number
18908   ,p_supervisor_id                in     number
18909   ,p_special_ceiling_step_id      in     number
18910   ,p_recruitment_activity_id      in     number
18911   ,p_source_organization_id       in     number
18912   ,p_vacancy_id                   in     number
18913   ,p_pay_basis_id                 in     number
18914   ,p_change_reason                in     varchar2
18915   ,p_comments                     in     varchar2
18916   ,p_date_probation_end           in     date
18917   ,p_default_code_comb_id         in     number
18918   ,p_employment_category          in     varchar2
18919   ,p_frequency                    in     varchar2
18920   ,p_internal_address_line        in     varchar2
18921   ,p_manager_flag                 in     varchar2
18922   ,p_normal_hours                 in     number
18923   ,p_perf_review_period           in     number
18924   ,p_perf_review_period_frequency in     varchar2
18925   ,p_probation_period             in     number
18926   ,p_probation_unit               in     varchar2
18927   ,p_sal_review_period            in     number
18928   ,p_sal_review_period_frequency  in     varchar2
18929   ,p_set_of_books_id              in     number
18930   ,p_source_type                  in     varchar2
18931   ,p_time_normal_finish           in     varchar2
18932   ,p_time_normal_start            in     varchar2
18933   ,p_bargaining_unit_code         in     varchar2
18934   ,p_ass_attribute_category       in     varchar2
18935   ,p_ass_attribute1               in     varchar2
18936   ,p_ass_attribute2               in     varchar2
18937   ,p_ass_attribute3               in     varchar2
18938   ,p_ass_attribute4               in     varchar2
18939   ,p_ass_attribute5               in     varchar2
18940   ,p_ass_attribute6               in     varchar2
18941   ,p_ass_attribute7               in     varchar2
18942   ,p_ass_attribute8               in     varchar2
18943   ,p_ass_attribute9               in     varchar2
18944   ,p_ass_attribute10              in     varchar2
18945   ,p_ass_attribute11              in     varchar2
18946   ,p_ass_attribute12              in     varchar2
18947   ,p_ass_attribute13              in     varchar2
18948   ,p_ass_attribute14              in     varchar2
18949   ,p_ass_attribute15              in     varchar2
18950   ,p_ass_attribute16              in     varchar2
18951   ,p_ass_attribute17              in     varchar2
18952   ,p_ass_attribute18              in     varchar2
18953   ,p_ass_attribute19              in     varchar2
18954   ,p_ass_attribute20              in     varchar2
18955   ,p_ass_attribute21              in     varchar2
18956   ,p_ass_attribute22              in     varchar2
18957   ,p_ass_attribute23              in     varchar2
18958   ,p_ass_attribute24              in     varchar2
18959   ,p_ass_attribute25              in     varchar2
18960   ,p_ass_attribute26              in     varchar2
18961   ,p_ass_attribute27              in     varchar2
18962   ,p_ass_attribute28              in     varchar2
18963   ,p_ass_attribute29              in     varchar2
18964   ,p_ass_attribute30              in     varchar2
18965   ,p_title                        in     varchar2
18966   ,p_scl_segment1                 in     varchar2
18967   ,p_scl_segment2                 in     varchar2
18968   ,p_scl_segment3                 in     varchar2
18969   ,p_scl_segment4                 in     varchar2
18970   ,p_scl_segment5                 in     varchar2
18971   ,p_scl_segment6                 in     varchar2
18972   ,p_scl_segment7                 in     varchar2
18973   ,p_scl_segment8                 in     varchar2
18974   ,p_scl_segment9                 in     varchar2
18975   ,p_scl_segment10                in     varchar2
18976   ,p_scl_segment11                in     varchar2
18977   ,p_scl_segment12                in     varchar2
18978   ,p_scl_segment13                in     varchar2
18979   ,p_scl_segment14                in     varchar2
18980   ,p_scl_segment15                in     varchar2
18981   ,p_scl_segment16                in     varchar2
18982   ,p_scl_segment17                in     varchar2
18983   ,p_scl_segment18                in     varchar2
18984   ,p_scl_segment19                in     varchar2
18985   ,p_scl_segment20                in     varchar2
18986   ,p_scl_segment21                in     varchar2
18987   ,p_scl_segment22                in     varchar2
18988   ,p_scl_segment23                in     varchar2
18989   ,p_scl_segment24                in     varchar2
18990   ,p_scl_segment25                in     varchar2
18991   ,p_scl_segment26                in     varchar2
18992   ,p_scl_segment27                in     varchar2
18993   ,p_scl_segment28                in     varchar2
18994   ,p_scl_segment29                in     varchar2
18995   ,p_scl_segment30                in     varchar2
18996 -- Bug 944911
18997 -- Amended p_scl_concatenated_segments to be an out instead of in out
18998 -- Added new param p_scl_concat_segments
18999 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
19000   ,p_scl_concat_segments          in     varchar2
19001   ,p_concatenated_segments           out nocopy varchar2
19002   ,p_pgp_segment1                 in     varchar2
19003   ,p_pgp_segment2                 in     varchar2
19004   ,p_pgp_segment3                 in     varchar2
19005   ,p_pgp_segment4                 in     varchar2
19006   ,p_pgp_segment5                 in     varchar2
19007   ,p_pgp_segment6                 in     varchar2
19008   ,p_pgp_segment7                 in     varchar2
19009   ,p_pgp_segment8                 in     varchar2
19010   ,p_pgp_segment9                 in     varchar2
19011   ,p_pgp_segment10                in     varchar2
19012   ,p_pgp_segment11                in     varchar2
19013   ,p_pgp_segment12                in     varchar2
19014   ,p_pgp_segment13                in     varchar2
19015   ,p_pgp_segment14                in     varchar2
19016   ,p_pgp_segment15                in     varchar2
19017   ,p_pgp_segment16                in     varchar2
19018   ,p_pgp_segment17                in     varchar2
19019   ,p_pgp_segment18                in     varchar2
19020   ,p_pgp_segment19                in     varchar2
19021   ,p_pgp_segment20                in     varchar2
19022   ,p_pgp_segment21                in     varchar2
19023   ,p_pgp_segment22                in     varchar2
19024   ,p_pgp_segment23                in     varchar2
19025   ,p_pgp_segment24                in     varchar2
19026   ,p_pgp_segment25                in     varchar2
19027   ,p_pgp_segment26                in     varchar2
19028   ,p_pgp_segment27                in     varchar2
19029   ,p_pgp_segment28                in     varchar2
19030   ,p_pgp_segment29                in     varchar2
19031   ,p_pgp_segment30                in     varchar2
19032 -- Bug 944911
19033 -- Made p_group_name to be out param
19034 -- and add p_concat_segment to be IN
19035 -- in case of sec_asg alone made p_pgp_concat_segments as in param
19036   ,p_concat_segments		  in     varchar2
19037   ,p_contract_id                  in     number
19038   ,p_establishment_id             in     number
19039   ,p_collective_agreement_id      in     number
19040   ,p_cagr_id_flex_num             in     number
19041   ,p_cag_segment1                 in     varchar2
19042   ,p_cag_segment2                 in     varchar2
19043   ,p_cag_segment3                 in     varchar2
19044   ,p_cag_segment4                 in     varchar2
19045   ,p_cag_segment5                 in     varchar2
19046   ,p_cag_segment6                 in     varchar2
19047   ,p_cag_segment7                 in     varchar2
19048   ,p_cag_segment8                 in     varchar2
19049   ,p_cag_segment9                 in     varchar2
19050   ,p_cag_segment10                in     varchar2
19051   ,p_cag_segment11                in     varchar2
19052   ,p_cag_segment12                in     varchar2
19053   ,p_cag_segment13                in     varchar2
19054   ,p_cag_segment14                in     varchar2
19055   ,p_cag_segment15                in     varchar2
19056   ,p_cag_segment16                in     varchar2
19057   ,p_cag_segment17                in     varchar2
19058   ,p_cag_segment18                in     varchar2
19059   ,p_cag_segment19                in     varchar2
19060   ,p_cag_segment20                in     varchar2
19061   ,p_notice_period		  in	 number
19062   ,p_notice_period_uom		  in     varchar2
19063   ,p_employee_category		  in     varchar2
19064   ,p_work_at_home		  in	 varchar2
19065   ,p_job_post_source_name         in     varchar2
19066   ,p_applicant_rank               in     number
19067   ,p_posting_content_id           in     number
19068   ,p_grade_ladder_pgm_id          in     number
19069   ,p_supervisor_assignment_id     in     number
19070   ,p_cagr_grade_def_id            in out nocopy number
19071   ,p_cagr_concatenated_segments      out nocopy varchar2
19072   ,p_group_name                      out nocopy varchar2
19073   ,p_assignment_id                   out nocopy number
19074   ,p_people_group_id              in out nocopy number
19075   ,p_soft_coding_keyflex_id       in out nocopy number
19076   ,p_comment_id                      out nocopy number
19077   ,p_object_version_number           out nocopy number
19078   ,p_effective_start_date            out nocopy date
19079   ,p_effective_end_date              out nocopy date
19080   ,p_assignment_sequence             out nocopy number
19081   ,p_appl_override_warning           OUT NOCOPY boolean  -- 3652025
19082   ) is
19083   --
19084   -- Declare cursors and local variables
19085   --
19086   -- Out variables
19087   --
19088   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
19089   l_people_group_id        per_all_assignments_f.people_group_id%TYPE := p_people_group_id;
19090   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
19091   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
19092   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
19093   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
19094   l_comment_id             per_all_assignments_f.comment_id%TYPE;
19095   l_group_name             pay_people_groups.group_name%TYPE;
19096   l_old_group_name         pay_people_groups.group_name%TYPE;
19097   --
19098   l_application_id         per_applications.application_id%TYPE;
19099   l_business_group_id      per_business_groups.business_group_id%TYPE;
19100   l_legislation_code       per_business_groups.legislation_code%TYPE;
19101   l_period_of_service_id   per_all_assignments_f.period_of_service_id%TYPE;
19102   l_proc                 varchar2(72) := g_package||'create_secondary_apl_asg';
19103   l_effective_date         date;
19104   l_date_probation_end     date;
19105   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE := p_soft_coding_keyflex_id;
19106   l_scl_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE  ;
19107   l_old_scl_conc_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
19108   l_flex_num                   fnd_id_flex_segments.id_flex_num%TYPE;
19109   l_session_id             number;
19110   l_cagr_grade_def_id      per_cagr_grades_def.cagr_grade_def_id%TYPE := p_cagr_grade_def_id;
19111   l_cagr_concatenated_segments varchar2(2000);
19112   l_appl_date_end          per_applications.date_end%TYPE;
19113   --
19114   -- bug 2230915 new variables to indicate whether key flex id parameters
19115   -- enter the program with a value.
19116   --
19117   l_pgp_null_ind               number(1) := 0;
19118   l_scl_null_ind               number(1) := 0;
19119   l_cag_null_ind               number(1) := 0;
19120   --
19121   -- Bug 2230915 new variables for derived values where key flex id is known.
19122   --
19123   l_scl_segment1               varchar2(60) := p_scl_segment1;
19124   l_scl_segment2               varchar2(60) := p_scl_segment2;
19125   l_scl_segment3               varchar2(60) := p_scl_segment3;
19126   l_scl_segment4               varchar2(60) := p_scl_segment4;
19127   l_scl_segment5               varchar2(60) := p_scl_segment5;
19128   l_scl_segment6               varchar2(60) := p_scl_segment6;
19129   l_scl_segment7               varchar2(60) := p_scl_segment7;
19130   l_scl_segment8               varchar2(60) := p_scl_segment8;
19131   l_scl_segment9               varchar2(60) := p_scl_segment9;
19132   l_scl_segment10              varchar2(60) := p_scl_segment10;
19133   l_scl_segment11              varchar2(60) := p_scl_segment11;
19134   l_scl_segment12              varchar2(60) := p_scl_segment12;
19135   l_scl_segment13              varchar2(60) := p_scl_segment13;
19136   l_scl_segment14              varchar2(60) := p_scl_segment14;
19137   l_scl_segment15              varchar2(60) := p_scl_segment15;
19138   l_scl_segment16              varchar2(60) := p_scl_segment16;
19139   l_scl_segment17              varchar2(60) := p_scl_segment17;
19140   l_scl_segment18              varchar2(60) := p_scl_segment18;
19141   l_scl_segment19              varchar2(60) := p_scl_segment19;
19142   l_scl_segment20              varchar2(60) := p_scl_segment20;
19143   l_scl_segment21              varchar2(60) := p_scl_segment21;
19144   l_scl_segment22              varchar2(60) := p_scl_segment22;
19145   l_scl_segment23              varchar2(60) := p_scl_segment23;
19146   l_scl_segment24              varchar2(60) := p_scl_segment24;
19147   l_scl_segment25              varchar2(60) := p_scl_segment25;
19148   l_scl_segment26              varchar2(60) := p_scl_segment26;
19149   l_scl_segment27              varchar2(60) := p_scl_segment27;
19150   l_scl_segment28              varchar2(60) := p_scl_segment28;
19151   l_scl_segment29              varchar2(60) := p_scl_segment29;
19152   l_scl_segment30              varchar2(60) := p_scl_segment30;
19153   --
19154   l_pgp_segment1               varchar2(60) := p_pgp_segment1;
19155   l_pgp_segment2               varchar2(60) := p_pgp_segment2;
19156   l_pgp_segment3               varchar2(60) := p_pgp_segment3;
19157   l_pgp_segment4               varchar2(60) := p_pgp_segment4;
19158   l_pgp_segment5               varchar2(60) := p_pgp_segment5;
19159   l_pgp_segment6               varchar2(60) := p_pgp_segment6;
19160   l_pgp_segment7               varchar2(60) := p_pgp_segment7;
19161   l_pgp_segment8               varchar2(60) := p_pgp_segment8;
19162   l_pgp_segment9               varchar2(60) := p_pgp_segment9;
19163   l_pgp_segment10              varchar2(60) := p_pgp_segment10;
19164   l_pgp_segment11              varchar2(60) := p_pgp_segment11;
19165   l_pgp_segment12              varchar2(60) := p_pgp_segment12;
19166   l_pgp_segment13              varchar2(60) := p_pgp_segment13;
19167   l_pgp_segment14              varchar2(60) := p_pgp_segment14;
19168   l_pgp_segment15              varchar2(60) := p_pgp_segment15;
19169   l_pgp_segment16              varchar2(60) := p_pgp_segment16;
19170   l_pgp_segment17              varchar2(60) := p_pgp_segment17;
19171   l_pgp_segment18              varchar2(60) := p_pgp_segment18;
19172   l_pgp_segment19              varchar2(60) := p_pgp_segment19;
19173   l_pgp_segment20              varchar2(60) := p_pgp_segment20;
19174   l_pgp_segment21              varchar2(60) := p_pgp_segment21;
19175   l_pgp_segment22              varchar2(60) := p_pgp_segment22;
19176   l_pgp_segment23              varchar2(60) := p_pgp_segment23;
19177   l_pgp_segment24              varchar2(60) := p_pgp_segment24;
19178   l_pgp_segment25              varchar2(60) := p_pgp_segment25;
19179   l_pgp_segment26              varchar2(60) := p_pgp_segment26;
19180   l_pgp_segment27              varchar2(60) := p_pgp_segment27;
19181   l_pgp_segment28              varchar2(60) := p_pgp_segment28;
19182   l_pgp_segment29              varchar2(60) := p_pgp_segment29;
19183   l_pgp_segment30              varchar2(60) := p_pgp_segment30;
19184   --
19185   l_cag_segment1               varchar2(60) := p_cag_segment1;
19186   l_cag_segment2               varchar2(60) := p_cag_segment2;
19187   l_cag_segment3               varchar2(60) := p_cag_segment3;
19188   l_cag_segment4               varchar2(60) := p_cag_segment4;
19189   l_cag_segment5               varchar2(60) := p_cag_segment5;
19190   l_cag_segment6               varchar2(60) := p_cag_segment6;
19191   l_cag_segment7               varchar2(60) := p_cag_segment7;
19192   l_cag_segment8               varchar2(60) := p_cag_segment8;
19193   l_cag_segment9               varchar2(60) := p_cag_segment9;
19194   l_cag_segment10              varchar2(60) := p_cag_segment10;
19195   l_cag_segment11              varchar2(60) := p_cag_segment11;
19196   l_cag_segment12              varchar2(60) := p_cag_segment12;
19197   l_cag_segment13              varchar2(60) := p_cag_segment13;
19198   l_cag_segment14              varchar2(60) := p_cag_segment14;
19199   l_cag_segment15              varchar2(60) := p_cag_segment15;
19200   l_cag_segment16              varchar2(60) := p_cag_segment16;
19201   l_cag_segment17              varchar2(60) := p_cag_segment17;
19202   l_cag_segment18              varchar2(60) := p_cag_segment18;
19203   l_cag_segment19              varchar2(60) := p_cag_segment19;
19204   l_cag_segment20              varchar2(60) := p_cag_segment20;
19205   --
19206   lv_cagr_grade_def_id         number := p_cagr_grade_def_id ;
19207   lv_people_group_id           number := p_people_group_id ;
19208   lv_soft_coding_keyflex_id    number := p_people_group_id ;
19209   --
19210   l_applicant_number          per_all_people_f.applicant_number%TYPE;
19211   l_per_object_version_number per_all_people_f.object_version_number%TYPE;
19212   l_appl_override_warning     boolean;
19213   l_per_effective_start_date  per_all_people_f.effective_start_date%TYPE;
19214   l_per_effective_end_date    per_all_people_f.effective_end_date%TYPE;
19215   l_apl_object_version_number per_applications.object_version_number%TYPE;
19216   --
19217 
19218   cursor csr_get_derived_details is
19219     select bus.business_group_id
19220          , bus.legislation_code
19221          , per.applicant_number, per.object_version_number  --3652025
19222       from per_all_people_f    per
19223          , per_business_groups_perf bus
19224      where per.person_id         = p_person_id
19225      and   l_effective_date      between per.effective_start_date
19226                                  and     per.effective_end_date
19227      and   bus.business_group_id = per.business_group_id;
19228   --
19229   -- 3652025 >>
19230   cursor csr_get_application is
19231    select apl.application_id, apl.date_end
19232      from per_applications apl
19233     where apl.person_id = p_person_id
19234       and l_effective_date between apl.date_received
19235                                and nvl(apl.date_end,hr_api.g_eot);
19236   -- <<
19237   cursor csr_get_apl_asg is
19238     select asg.application_id
19239       from per_all_assignments_f asg
19240      where asg.person_id    = p_person_id
19241      and   l_effective_date between asg.effective_start_date
19242                             and     asg.effective_end_date
19243      and   asg.assignment_type = 'A';
19244   --
19245   --
19246   cursor csr_grp_idsel is
19247     select bus.people_group_structure
19248      from  per_business_groups_perf bus
19249      where bus.business_group_id = l_business_group_id;
19250   --
19251   cursor csr_scl_idsel is
19252     select plr.rule_mode                       id_flex_num
19253     from   pay_legislation_rules               plr,
19254            per_business_groups_perf            pgr
19255     where  plr.legislation_code                = pgr.legislation_code
19256     and    pgr.business_group_id               = l_business_group_id
19257     and    plr.rule_type                       = 'S'
19258     and    exists
19259           (select 1
19260            from   fnd_segment_attribute_values fsav
19261            where  fsav.id_flex_num             = plr.rule_mode
19262            and    fsav.application_id          = 800
19263            and    fsav.id_flex_code            = 'SCL'
19264            and    fsav.segment_attribute_type  = 'ASSIGNMENT'
19265            and    fsav.attribute_value         = 'Y')
19266     and    exists
19267           (select 1
19268            from   pay_legislation_rules        plr2
19269            where  plr2.legislation_code        = plr.legislation_code
19270            and    plr2.rule_type               = 'SDL'
19271            and    plr2.rule_mode               = 'A') ;
19272   --
19273   --
19274   -- bug 2230915 get pay_people_group segment values where
19275   -- people_group_id is known
19276   --
19277   cursor c_pgp_segments is
19278      select segment1,
19279             segment2,
19280             segment3,
19281             segment4,
19282             segment5,
19283             segment6,
19284             segment7,
19285             segment8,
19286             segment9,
19287             segment10,
19288             segment11,
19289             segment12,
19290             segment13,
19291             segment14,
19292             segment15,
19293             segment16,
19294             segment17,
19295             segment18,
19296             segment19,
19297             segment20,
19298             segment21,
19299             segment22,
19300             segment23,
19301             segment24,
19302             segment25,
19303             segment26,
19304             segment27,
19305             segment28,
19306             segment29,
19307             segment30
19308      from   pay_people_groups
19309      where  people_group_id = l_people_group_id;
19310   --
19311   -- bug 2230915 get hr_soft_coding_keyflex segment values where
19312   -- soft_coding_keyflex_id is known
19313   --
19314   cursor c_scl_segments is
19315      select segment1,
19316             segment2,
19317             segment3,
19318             segment4,
19319             segment5,
19320             segment6,
19321             segment7,
19322             segment8,
19323             segment9,
19324             segment10,
19325             segment11,
19326             segment12,
19327             segment13,
19328             segment14,
19329             segment15,
19330             segment16,
19331             segment17,
19332             segment18,
19333             segment19,
19334             segment20,
19335             segment21,
19336             segment22,
19337             segment23,
19338             segment24,
19339             segment25,
19340             segment26,
19341             segment27,
19342             segment28,
19343             segment29,
19344             segment30
19345      from   hr_soft_coding_keyflex
19346      where  soft_coding_keyflex_id = l_soft_coding_keyflex_id;
19347   --
19348   -- bug 2230915 get per_cagr_grades_def segment values where
19349   -- cagr_grade_def_id is known
19350   --
19351   cursor c_cag_segments is
19352      select segment1,
19353             segment2,
19354             segment3,
19355             segment4,
19356             segment5,
19357             segment6,
19358             segment7,
19359             segment8,
19360             segment9,
19361             segment10,
19362             segment11,
19363             segment12,
19364             segment13,
19365             segment14,
19366             segment15,
19367             segment16,
19368             segment17,
19369             segment18,
19370             segment19,
19371             segment20
19372      from   per_cagr_grades_def
19373      where  cagr_grade_def_id = l_cagr_grade_def_id;
19374   --
19375   l_assignment_status_type_id  per_all_assignments_f.assignment_status_type_id%TYPE;
19376 --
19377 begin
19378 --
19379  if g_debug then
19380   hr_utility.set_location('Entering:'|| l_proc, 5);
19381  end if;
19382   --
19383   -- Truncate date value p_effective_date to remove time element.
19384   --
19385   l_effective_date := trunc(p_effective_date);
19386   l_date_probation_end := trunc(p_date_probation_end);
19387 -- Bug 944911
19388 -- Made p_group_name to be out param
19389 -- and add p_concat_segment to be IN
19390 -- in case of sec_asg alone made p_pgp_concat_segments as in param
19391 -- replaced p_group_name by p_concat_segments
19392   l_old_group_name       := p_concat_segments;
19393 -- Bug 944911
19394 -- Amended p_scl_concatenated_segments to p_scl_concat_segments
19395   l_old_scl_conc_segments := p_scl_concat_segments;
19396   --
19397   -- Issue a savepoint.
19398   --
19399   savepoint create_secondary_apl_asg;
19400   --
19401  if g_debug then
19402   hr_utility.set_location(l_proc, 10);
19403  end if;
19404   --
19405   -- Validation in addition to Table Handlers
19406   --
19407   -- Get person details.
19408   --
19409   hr_api.mandatory_arg_error
19410      (p_api_name       => l_proc
19411      ,p_argument       => 'person_id'
19412      ,p_argument_value => p_person_id
19413      );
19414   --
19415   hr_api.mandatory_arg_error
19416      (p_api_name       => l_proc
19417      ,p_argument       => 'effective_date'
19418      ,p_argument_value => l_effective_date
19419      );
19420   --
19421   -- Validate the person_id exists, if it does get the business group and
19422   -- legislation code.
19423   --
19424   open  csr_get_derived_details;
19425   fetch csr_get_derived_details
19426    into l_business_group_id
19427       , l_legislation_code, l_applicant_number, l_per_object_version_number;
19428   --
19429   if csr_get_derived_details%NOTFOUND then
19430     --
19431     close csr_get_derived_details;
19432     --
19433  if g_debug then
19434     hr_utility.set_location(l_proc, 15);
19435  end if;
19436     --
19437     hr_utility.set_message(801,'HR_7432_ASG_INVALID_PERSON');
19438     hr_utility.raise_error;
19439   end if;
19440   --
19441   close csr_get_derived_details;
19442   --
19443   -- Bug 2230915 - if p_people_group_id enters with
19444   -- a value then get segment values from pay_people_groups.
19445   -- Do the same with the key flex ids for hr_soft_coding_keyflex and
19446   -- per_cagr_grades_def
19447   --
19448   --
19449  if g_debug then
19450   hr_utility.set_location(l_proc, 20);
19451  end if;
19452   --
19453   if l_people_group_id is not null
19454   then
19455      l_pgp_null_ind := 1;
19456      --
19457      open c_pgp_segments;
19458        fetch c_pgp_segments into l_pgp_segment1,
19459                                  l_pgp_segment2,
19460                                  l_pgp_segment3,
19461                                  l_pgp_segment4,
19462                                  l_pgp_segment5,
19463                                  l_pgp_segment6,
19464                                  l_pgp_segment7,
19465                                  l_pgp_segment8,
19466                                  l_pgp_segment9,
19467                                  l_pgp_segment10,
19468                                  l_pgp_segment11,
19469                                  l_pgp_segment12,
19470                                  l_pgp_segment13,
19471                                  l_pgp_segment14,
19472                                  l_pgp_segment15,
19473                                  l_pgp_segment16,
19474                                  l_pgp_segment17,
19475                                  l_pgp_segment18,
19476                                  l_pgp_segment19,
19477                                  l_pgp_segment20,
19478                                  l_pgp_segment21,
19479                                  l_pgp_segment22,
19480                                  l_pgp_segment23,
19481                                  l_pgp_segment24,
19482                                  l_pgp_segment25,
19483                                  l_pgp_segment26,
19484                                  l_pgp_segment27,
19485                                  l_pgp_segment28,
19486                                  l_pgp_segment29,
19487                                  l_pgp_segment30;
19488      close c_pgp_segments;
19489   else
19490      l_pgp_null_ind := 0;
19491   end if;
19492   --  use cursor c_scl_segments to bring back segment values if
19493   --  l_soft_coding_keyflex has a value.
19494   if l_soft_coding_keyflex_id is not null
19495   then
19496      l_scl_null_ind := 1;
19497      open c_scl_segments;
19498        fetch c_scl_segments into l_scl_segment1,
19499                                  l_scl_segment2,
19500                                  l_scl_segment3,
19501                                  l_scl_segment4,
19502                                  l_scl_segment5,
19503                                  l_scl_segment6,
19504                                  l_scl_segment7,
19505                                  l_scl_segment8,
19506                                  l_scl_segment9,
19507                                  l_scl_segment10,
19508                                  l_scl_segment11,
19509                                  l_scl_segment12,
19510                                  l_scl_segment13,
19511                                  l_scl_segment14,
19512                                  l_scl_segment15,
19513                                  l_scl_segment16,
19514                                  l_scl_segment17,
19515                                  l_scl_segment18,
19516                                  l_scl_segment19,
19517                                  l_scl_segment20,
19518                                  l_scl_segment21,
19519                                  l_scl_segment22,
19520                                  l_scl_segment23,
19521                                  l_scl_segment24,
19522                                  l_scl_segment25,
19523                                  l_scl_segment26,
19524                                  l_scl_segment27,
19525                                  l_scl_segment28,
19526                                  l_scl_segment29,
19527                                  l_scl_segment30;
19528      close c_scl_segments;
19529   else
19530      l_scl_null_ind := 0;
19531   end if;
19532   --
19533   -- if cagr_grade_def_id has a value then use it to get segment values using
19534   -- cursor cag_segments
19535   --
19536   if l_cagr_grade_def_id is not null
19537   then
19538      l_cag_null_ind := 1;
19539      open c_cag_segments;
19540        fetch c_cag_segments into l_cag_segment1,
19541                                  l_cag_segment2,
19542                                  l_cag_segment3,
19543                                  l_cag_segment4,
19544                                  l_cag_segment5,
19545                                  l_cag_segment6,
19546                                  l_cag_segment7,
19547                                  l_cag_segment8,
19548                                  l_cag_segment9,
19549                                  l_cag_segment10,
19550                                  l_cag_segment11,
19551                                  l_cag_segment12,
19552                                  l_cag_segment13,
19553                                  l_cag_segment14,
19554                                  l_cag_segment15,
19555                                  l_cag_segment16,
19556                                  l_cag_segment17,
19557                                  l_cag_segment18,
19558                                  l_cag_segment19,
19559                                  l_cag_segment20;
19560      close c_cag_segments;
19561   else
19562      l_cag_null_ind := 0;
19563   end if;
19564   --
19565   -- Start of API User Hook for the before hook of create_secondary_apl_asg.
19566   --
19567   begin
19568      hr_assignment_bk8.create_secondary_apl_asg_b
19569        (p_effective_date               =>     l_effective_date
19570        ,p_person_id                    =>     p_person_id
19571        ,p_organization_id              =>     p_organization_id
19572        ,p_recruiter_id                 =>     p_recruiter_id
19573        ,p_grade_id                     =>     p_grade_id
19574        ,p_position_id                  =>     p_position_id
19575        ,p_job_id                       =>     p_job_id
19576        ,p_payroll_id                   =>     p_payroll_id
19577        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
19578        ,p_location_id                  =>     p_location_id
19579        ,p_person_referred_by_id        =>     p_person_referred_by_id
19580        ,p_supervisor_id                =>     p_supervisor_id
19581        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
19582        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
19583        ,p_source_organization_id       =>     p_source_organization_id
19584        ,p_vacancy_id                   =>     p_vacancy_id
19585        ,p_pay_basis_id                 =>     p_pay_basis_id
19586        ,p_change_reason                =>     p_change_reason
19587        ,p_internal_address_line        =>     p_internal_address_line
19588        ,p_comments                     =>     p_comments
19589        ,p_date_probation_end           =>     l_date_probation_end
19590        ,p_default_code_comb_id         =>     p_default_code_comb_id
19591        ,p_employment_category          =>     p_employment_category
19592        ,p_frequency                    =>     p_frequency
19593        ,p_manager_flag                 =>     p_manager_flag
19594        ,p_normal_hours                 =>     p_normal_hours
19595        ,p_perf_review_period           =>     p_perf_review_period
19596        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
19597        ,p_probation_period             =>     p_probation_period
19598        ,p_probation_unit               =>     p_probation_unit
19599        ,p_sal_review_period            =>     p_sal_review_period
19600        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
19601        ,p_set_of_books_id              =>     p_set_of_books_id
19602        ,p_source_type                  =>     p_source_type
19603        ,p_time_normal_finish           =>     p_time_normal_finish
19604        ,p_time_normal_start            =>     p_time_normal_start
19605        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
19606        ,p_ass_attribute_category       =>     p_ass_attribute_category
19607        ,p_ass_attribute1               =>     p_ass_attribute1
19608        ,p_ass_attribute2               =>     p_ass_attribute2
19609        ,p_ass_attribute3               =>     p_ass_attribute3
19610        ,p_ass_attribute4               =>     p_ass_attribute4
19611        ,p_ass_attribute5               =>     p_ass_attribute5
19612        ,p_ass_attribute6               =>     p_ass_attribute6
19613        ,p_ass_attribute7               =>     p_ass_attribute7
19614        ,p_ass_attribute8               =>     p_ass_attribute8
19615        ,p_ass_attribute9               =>     p_ass_attribute9
19616        ,p_ass_attribute10              =>     p_ass_attribute10
19617        ,p_ass_attribute11              =>     p_ass_attribute11
19618        ,p_ass_attribute12              =>     p_ass_attribute12
19619        ,p_ass_attribute13              =>     p_ass_attribute13
19620        ,p_ass_attribute14              =>     p_ass_attribute14
19621        ,p_ass_attribute15              =>     p_ass_attribute15
19622        ,p_ass_attribute16              =>     p_ass_attribute16
19623        ,p_ass_attribute17              =>     p_ass_attribute17
19624        ,p_ass_attribute18              =>     p_ass_attribute18
19625        ,p_ass_attribute19              =>     p_ass_attribute19
19626        ,p_ass_attribute20              =>     p_ass_attribute20
19627        ,p_ass_attribute21              =>     p_ass_attribute21
19628        ,p_ass_attribute22              =>     p_ass_attribute22
19629        ,p_ass_attribute23              =>     p_ass_attribute23
19630        ,p_ass_attribute24              =>     p_ass_attribute24
19631        ,p_ass_attribute25              =>     p_ass_attribute25
19632        ,p_ass_attribute26              =>     p_ass_attribute26
19633        ,p_ass_attribute27              =>     p_ass_attribute27
19634        ,p_ass_attribute28              =>     p_ass_attribute28
19635        ,p_ass_attribute29              =>     p_ass_attribute29
19636        ,p_ass_attribute30              =>     p_ass_attribute30
19637        ,p_title                        =>     p_title
19638        --
19639        -- Bug 2230915
19640        -- Amended p_scl/pgp/cag_segments to be l_scl/pgp/cag_segments
19641        --
19642        ,p_scl_segment1                 =>     l_scl_segment1
19643        ,p_scl_segment2                 =>     l_scl_segment2
19644        ,p_scl_segment3                 =>     l_scl_segment3
19645        ,p_scl_segment4                 =>     l_scl_segment4
19646        ,p_scl_segment5                 =>     l_scl_segment5
19647        ,p_scl_segment6                 =>     l_scl_segment6
19648        ,p_scl_segment7                 =>     l_scl_segment7
19649        ,p_scl_segment8                 =>     l_scl_segment8
19650        ,p_scl_segment9                 =>     l_scl_segment9
19651        ,p_scl_segment10                =>     l_scl_segment10
19652        ,p_scl_segment11                =>     l_scl_segment11
19653        ,p_scl_segment12                =>     l_scl_segment12
19654        ,p_scl_segment13                =>     l_scl_segment13
19655        ,p_scl_segment14                =>     l_scl_segment14
19656        ,p_scl_segment15                =>     l_scl_segment15
19657        ,p_scl_segment16                =>     l_scl_segment16
19658        ,p_scl_segment17                =>     l_scl_segment17
19659        ,p_scl_segment18                =>     l_scl_segment18
19660        ,p_scl_segment19                =>     l_scl_segment19
19661        ,p_scl_segment20                =>     l_scl_segment20
19662        ,p_scl_segment21                =>     l_scl_segment21
19663        ,p_scl_segment22                =>     l_scl_segment22
19664        ,p_scl_segment23                =>     l_scl_segment23
19665        ,p_scl_segment24                =>     l_scl_segment24
19666        ,p_scl_segment25                =>     l_scl_segment25
19667        ,p_scl_segment26                =>     l_scl_segment26
19668        ,p_scl_segment27                =>     l_scl_segment27
19669        ,p_scl_segment28                =>     l_scl_segment28
19670        ,p_scl_segment29                =>     l_scl_segment29
19671        ,p_scl_segment30                =>     l_scl_segment30
19672        --
19673        -- Bug 944911
19674        -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
19675        --
19676        ,p_scl_concat_segments          =>     l_old_scl_conc_segments
19677        ,p_pgp_segment1                 =>     l_pgp_segment1
19678        ,p_pgp_segment2                 =>     l_pgp_segment2
19679        ,p_pgp_segment3                 =>     l_pgp_segment3
19680        ,p_pgp_segment4                 =>     l_pgp_segment4
19681        ,p_pgp_segment5                 =>     l_pgp_segment5
19682        ,p_pgp_segment6                 =>     l_pgp_segment6
19683        ,p_pgp_segment7                 =>     l_pgp_segment7
19684        ,p_pgp_segment8                 =>     l_pgp_segment8
19685        ,p_pgp_segment9                 =>     l_pgp_segment9
19686        ,p_pgp_segment10                =>     l_pgp_segment10
19687        ,p_pgp_segment11                =>     l_pgp_segment11
19688        ,p_pgp_segment12                =>     l_pgp_segment12
19689        ,p_pgp_segment13                =>     l_pgp_segment13
19690        ,p_pgp_segment14                =>     l_pgp_segment14
19691        ,p_pgp_segment15                =>     l_pgp_segment15
19692        ,p_pgp_segment16                =>     l_pgp_segment16
19693        ,p_pgp_segment17                =>     l_pgp_segment17
19694        ,p_pgp_segment18                =>     l_pgp_segment18
19695        ,p_pgp_segment19                =>     l_pgp_segment19
19696        ,p_pgp_segment20                =>     l_pgp_segment20
19697        ,p_pgp_segment21                =>     l_pgp_segment21
19698        ,p_pgp_segment22                =>     l_pgp_segment22
19699        ,p_pgp_segment23                =>     l_pgp_segment23
19700        ,p_pgp_segment24                =>     l_pgp_segment24
19701        ,p_pgp_segment25                =>     l_pgp_segment25
19702        ,p_pgp_segment26                =>     l_pgp_segment26
19703        ,p_pgp_segment27                =>     l_pgp_segment27
19704        ,p_pgp_segment28                =>     l_pgp_segment28
19705        ,p_pgp_segment29                =>     l_pgp_segment29
19706        ,p_pgp_segment30                =>     l_pgp_segment30
19707        --
19708        -- Bug 944911
19709        -- Amended p_group_name to be p_concat_segments
19710        --
19711        ,p_concat_segments              => l_old_group_name
19712        ,p_business_group_id            => l_business_group_id
19713        ,p_contract_id                  => p_contract_id
19714        ,p_establishment_id             => p_establishment_id
19715        ,p_collective_agreement_id      => p_collective_agreement_id
19716        ,p_cagr_id_flex_num             => p_cagr_id_flex_num
19717        ,p_cag_segment1                 => l_cag_segment1
19718        ,p_cag_segment2                 => l_cag_segment2
19719        ,p_cag_segment3                 => l_cag_segment3
19720        ,p_cag_segment4                 => l_cag_segment4
19721        ,p_cag_segment5                 => l_cag_segment5
19722        ,p_cag_segment6                 => l_cag_segment6
19723        ,p_cag_segment7                 => l_cag_segment7
19724        ,p_cag_segment8                 => l_cag_segment8
19725        ,p_cag_segment9                 => l_cag_segment9
19726        ,p_cag_segment10                => l_cag_segment10
19727        ,p_cag_segment11                => l_cag_segment11
19728        ,p_cag_segment12                => l_cag_segment12
19729        ,p_cag_segment13                => l_cag_segment13
19730        ,p_cag_segment14                => l_cag_segment14
19731        ,p_cag_segment15                => l_cag_segment15
19732        ,p_cag_segment16                => l_cag_segment16
19733        ,p_cag_segment17                => l_cag_segment17
19734        ,p_cag_segment18                => l_cag_segment18
19735        ,p_cag_segment19                => l_cag_segment19
19736        ,p_cag_segment20                => l_cag_segment20
19737        ,p_notice_period		       => p_notice_period
19738        ,p_notice_period_uom	       => p_notice_period_uom
19739        ,p_employee_category	       => p_employee_category
19740        ,p_work_at_home		       => p_work_at_home
19741        ,p_job_post_source_name	       => p_job_post_source_name
19742        ,p_applicant_rank               => p_applicant_rank
19743        ,p_posting_content_id           => p_posting_content_id
19744        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
19745        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
19746        );
19747   exception
19748      when hr_api.cannot_find_prog_unit then
19749        hr_api.cannot_find_prog_unit_error
19750          (p_module_name       => 'CREATE_SECONDARY_APL_ASG',
19751           p_hook_type         => 'BP'
19752          );
19753   end;
19754   --
19755   --
19756  if g_debug then
19757   hr_utility.set_location(l_proc, 20);
19758  end if;
19759   --
19760   -- Process Logic
19761   --
19762   -- Get the application_id from an existing applicant assignment for the
19763   -- person specified. If no applicant assignment exists then this person
19764   -- cannot be an applicant.
19765   --
19766   -- 3652025 >>
19767   --open  csr_get_apl_asg;
19768   --fetch csr_get_apl_asg
19769    --into l_application_id;
19770   --
19771   open csr_get_application;
19772   fetch csr_get_application into l_application_id, l_appl_date_end;
19773 
19774   if csr_get_application%NOTFOUND then
19775     --
19776     close csr_get_application;
19777     --
19778     if g_debug then
19779        hr_utility.set_location(l_proc, 25);
19780     end if;
19781     --
19782     hr_utility.set_message(801,'HR_51231_ASG_MISSING_ASG');
19783     hr_utility.raise_error;
19784   end if;
19785   --
19786   close csr_get_application;
19787   -- <<
19788  if g_debug then
19789   hr_utility.set_location(l_proc, 30);
19790  end if;
19791   --
19792   --
19793   -- insert the profile options and effective date for the flexfield
19794   -- validation to work
19795   --
19796   --
19797   hr_kflex_utility.set_profiles
19798   (p_business_group_id => l_business_group_id
19799   ,p_assignment_id     => l_assignment_id
19800   ,p_organization_id   => p_organization_id
19801   ,p_location_id       => p_location_id);
19802   --
19803   hr_kflex_utility.set_session_date
19804   (p_effective_date => l_effective_date
19805   ,p_session_id     => l_session_id);
19806   --
19807   -- Maintain the people group key flexfields.
19808   --
19809   open csr_grp_idsel;
19810   fetch csr_grp_idsel
19811   into l_flex_num;
19812      if csr_grp_idsel%NOTFOUND then
19813        close csr_grp_idsel;
19814           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
19815           hr_utility.set_message_token('PROCEDURE', l_proc);
19816           hr_utility.set_message_token('STEP','10');
19817           hr_utility.raise_error;
19818      end if;
19819   close csr_grp_idsel;
19820   --
19821   --
19822   -- Maintain the people group key flexfields.
19823   --
19824   open csr_grp_idsel;
19825   fetch csr_grp_idsel
19826   into l_flex_num;
19827      if csr_grp_idsel%NOTFOUND then
19828        close csr_grp_idsel;
19829           hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
19830           hr_utility.set_message_token('PROCEDURE', l_proc);
19831           hr_utility.set_message_token('STEP','10');
19832           hr_utility.raise_error;
19833      end if;
19834   close csr_grp_idsel;
19835   --
19836   -- Bug 2230915 - if key flex parameters have a value then derive segment
19837   -- values from them
19838   --
19839   if l_people_group_id is null
19840   then
19841      --
19842      hr_kflex_utility.upd_or_sel_keyflex_comb
19843        (p_appl_short_name        => 'PAY'
19844        ,p_flex_code              => 'GRP'
19845        ,p_flex_num               => l_flex_num
19846        ,p_segment1               => l_pgp_segment1
19847        ,p_segment2               => l_pgp_segment2
19848        ,p_segment3               => l_pgp_segment3
19849        ,p_segment4               => l_pgp_segment4
19850        ,p_segment5               => l_pgp_segment5
19851        ,p_segment6               => l_pgp_segment6
19852        ,p_segment7               => l_pgp_segment7
19853        ,p_segment8               => l_pgp_segment8
19854        ,p_segment9               => l_pgp_segment9
19855        ,p_segment10              => l_pgp_segment10
19856        ,p_segment11              => l_pgp_segment11
19857        ,p_segment12              => l_pgp_segment12
19858        ,p_segment13              => l_pgp_segment13
19859        ,p_segment14              => l_pgp_segment14
19860        ,p_segment15              => l_pgp_segment15
19861        ,p_segment16              => l_pgp_segment16
19862        ,p_segment17              => l_pgp_segment17
19863        ,p_segment18              => l_pgp_segment18
19864        ,p_segment19              => l_pgp_segment19
19865        ,p_segment20              => l_pgp_segment20
19866        ,p_segment21              => l_pgp_segment21
19867        ,p_segment22              => l_pgp_segment22
19868        ,p_segment23              => l_pgp_segment23
19869        ,p_segment24              => l_pgp_segment24
19870        ,p_segment25              => l_pgp_segment25
19871        ,p_segment26              => l_pgp_segment26
19872        ,p_segment27              => l_pgp_segment27
19873        ,p_segment28              => l_pgp_segment28
19874        ,p_segment29              => l_pgp_segment29
19875        ,p_segment30              => l_pgp_segment30
19876        ,p_concat_segments_in     => l_old_group_name
19877        ,p_ccid                   => l_people_group_id
19878        ,p_concat_segments_out    => l_group_name
19879        );
19880   end if;
19881   --
19882   -- update the combinations column
19883   --
19884   update_pgp_concat_segs
19885     (p_people_group_id        => l_people_group_id
19886     ,p_group_name             => l_group_name
19887     );
19888   --
19889   -- select or insert the Collective Agreement grade
19890   --
19891  if g_debug then
19892   hr_utility.set_location(l_proc, 36);
19893  end if;
19894   --
19895   if l_cagr_grade_def_id is null
19896   then
19897      hr_cgd_ins.ins_or_sel
19898      (p_segment1               => l_cag_segment1
19899      ,p_segment2               => l_cag_segment2
19900      ,p_segment3               => l_cag_segment3
19901      ,p_segment4               => l_cag_segment4
19902      ,p_segment5               => l_cag_segment5
19903      ,p_segment6               => l_cag_segment6
19904      ,p_segment7               => l_cag_segment7
19905      ,p_segment8               => l_cag_segment8
19906      ,p_segment9               => l_cag_segment9
19907      ,p_segment10              => l_cag_segment10
19908      ,p_segment11              => l_cag_segment11
19909      ,p_segment12              => l_cag_segment12
19910      ,p_segment13              => l_cag_segment13
19911      ,p_segment14              => l_cag_segment14
19912      ,p_segment15              => l_cag_segment15
19913      ,p_segment16              => l_cag_segment16
19914      ,p_segment17              => l_cag_segment17
19915      ,p_segment18              => l_cag_segment18
19916      ,p_segment19              => l_cag_segment19
19917      ,p_segment20              => l_cag_segment20
19918      ,p_id_flex_num            => p_cagr_id_flex_num
19919      ,p_business_group_id      => l_business_group_id
19920      ,p_cagr_grade_def_id      => l_cagr_grade_def_id
19921      ,p_concatenated_segments  => l_cagr_concatenated_segments
19922       );
19923   end if;
19924      --
19925   if l_soft_coding_keyflex_id is null
19926   then
19927      --
19928      if   l_scl_segment1 is not null
19929        or l_scl_segment2 is not null
19930        or l_scl_segment3 is not null
19931        or l_scl_segment4 is not null
19932        or l_scl_segment5 is not null
19933        or l_scl_segment6 is not null
19934        or l_scl_segment7 is not null
19935        or l_scl_segment8 is not null
19936        or l_scl_segment9 is not null
19937        or l_scl_segment10 is not null
19938        or l_scl_segment11 is not null
19939        or l_scl_segment12 is not null
19940        or l_scl_segment13 is not null
19941        or l_scl_segment14 is not null
19942        or l_scl_segment15 is not null
19943        or l_scl_segment16 is not null
19944        or l_scl_segment17 is not null
19945        or l_scl_segment18 is not null
19946        or l_scl_segment19 is not null
19947        or l_scl_segment20 is not null
19948        or l_scl_segment21 is not null
19949        or l_scl_segment22 is not null
19950        or l_scl_segment23 is not null
19951        or l_scl_segment24 is not null
19952        or l_scl_segment25 is not null
19953        or l_scl_segment26 is not null
19954        or l_scl_segment27 is not null
19955        or l_scl_segment28 is not null
19956        or l_scl_segment29 is not null
19957        or l_scl_segment30 is not null
19958        --
19959        -- bug 944911
19960        -- Added this additional check
19961        --
19962        or p_scl_concat_segments is not null
19963      then
19964         open csr_scl_idsel;
19965         fetch csr_scl_idsel into l_flex_num;
19966         if csr_scl_idsel%NOTFOUND
19967         then
19968            close csr_scl_idsel;
19969  if g_debug then
19970            hr_utility.set_location(l_proc, 28);
19971  end if;
19972            --
19973            hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
19974            hr_utility.set_message_token('PROCEDURE', l_proc);
19975            hr_utility.set_message_token('STEP','10');
19976            hr_utility.raise_error;
19977         else
19978            close csr_scl_idsel;
19979            --
19980            --
19981  if g_debug then
19982            hr_utility.set_location(l_proc, 30);
19983  end if;
19984            --
19985            -- Insert or select the soft_coding_keyflex_id
19986            --
19987            hr_kflex_utility.ins_or_sel_keyflex_comb
19988            (p_appl_short_name        => 'PER'
19989            ,p_flex_code              => 'SCL'
19990            ,p_flex_num               => l_flex_num
19991            ,p_segment1               => l_scl_segment1
19992            ,p_segment2               => l_scl_segment2
19993            ,p_segment3               => l_scl_segment3
19994            ,p_segment4               => l_scl_segment4
19995            ,p_segment5               => l_scl_segment5
19996            ,p_segment6               => l_scl_segment6
19997            ,p_segment7               => l_scl_segment7
19998            ,p_segment8               => l_scl_segment8
19999            ,p_segment9               => l_scl_segment9
20000            ,p_segment10              => l_scl_segment10
20001            ,p_segment11              => l_scl_segment11
20002            ,p_segment12              => l_scl_segment12
20003            ,p_segment13              => l_scl_segment13
20004            ,p_segment14              => l_scl_segment14
20005            ,p_segment15              => l_scl_segment15
20006            ,p_segment16              => l_scl_segment16
20007            ,p_segment17              => l_scl_segment17
20008            ,p_segment18              => l_scl_segment18
20009            ,p_segment19              => l_scl_segment19
20010            ,p_segment20              => l_scl_segment20
20011            ,p_segment21              => l_scl_segment21
20012            ,p_segment22              => l_scl_segment22
20013            ,p_segment23              => l_scl_segment23
20014            ,p_segment24              => l_scl_segment24
20015            ,p_segment25              => l_scl_segment25
20016            ,p_segment26              => l_scl_segment26
20017            ,p_segment27              => l_scl_segment27
20018            ,p_segment28              => l_scl_segment28
20019            ,p_segment29              => l_scl_segment29
20020            ,p_segment30              => l_scl_segment30
20021            ,p_concat_segments_in     => l_old_scl_conc_segments
20022            ,p_ccid                   => l_soft_coding_keyflex_id
20023            ,p_concat_segments_out    => l_scl_concatenated_segments
20024            );
20025            --
20026            -- update the combinations column
20027            --
20028            update_scl_concat_segs
20029            (p_soft_coding_keyflex_id  => l_soft_coding_keyflex_id
20030            ,p_concatenated_segments   => l_scl_concatenated_segments
20031            );
20032         --
20033        end if;
20034      --
20035     end if;
20036    --
20037   end if;
20038   --
20039  if g_debug then
20040   hr_utility.set_location(l_proc, 35);
20041  end if;
20042   --
20043   -- 3652025: if application is end dated then call internal procedure
20044   --
20045   if l_appl_date_end is not null then
20046   --
20047   -- Application is end dated
20048   --
20049       if g_debug then
20050         hr_utility.set_location(l_proc, 40);
20051       end if;
20052 
20053       hr_applicant_internal.create_applicant_anytime
20054         (p_effective_date                => l_effective_date
20055         ,p_person_id                     => p_person_id
20056         ,p_applicant_number              => l_applicant_number
20057         ,p_per_object_version_number     => l_per_object_version_number
20058         ,p_vacancy_id                    => p_vacancy_id
20059         ,p_person_type_id                => null
20060         ,p_assignment_status_type_id     => p_assignment_status_type_id
20061         ,p_application_id                => l_application_id
20062         ,p_assignment_id                 => l_assignment_id
20063         ,p_apl_object_version_number     => l_apl_object_version_number
20064         ,p_asg_object_version_number     => l_object_version_number
20065         ,p_assignment_sequence           => l_assignment_sequence
20066         ,p_per_effective_start_date      => l_per_effective_start_date
20067         ,p_per_effective_end_date        => l_per_effective_end_date
20068         ,p_appl_override_warning         => l_appl_override_warning
20069         );
20070 
20071       if g_debug then
20072         hr_utility.set_location(l_proc, 45);
20073       end if;
20074       --
20075       -- 3972045: If p_assignment_status_type_id is null, derive default status for
20076       -- person's business group.
20077       --
20078       if p_assignment_status_type_id is null then
20079          per_people3_pkg.get_default_person_type
20080            (p_required_type     => 'ACTIVE_APL'
20081            ,p_business_group_id => l_business_group_id
20082            ,p_legislation_code  => l_legislation_code
20083            ,p_person_type       => l_assignment_status_type_id
20084           );
20085       else
20086          l_assignment_status_type_id := p_assignment_status_type_id;
20087       end if;
20088       --
20089       hr_assignment_api.update_apl_asg
20090             (p_validate                    => FALSE
20091             ,p_effective_date              => l_effective_date
20092             ,p_datetrack_update_mode       => hr_api.g_correction
20093             ,p_assignment_id               => l_assignment_id
20094             ,p_object_version_number       => l_object_version_number
20095             ,p_recruiter_id                => p_recruiter_id
20096             ,p_grade_id                    => p_grade_id
20097             ,p_position_id                 => p_position_id
20098             ,p_job_id                      => p_job_id
20099             ,p_payroll_id                  => p_payroll_id
20100             ,p_location_id                 => p_location_id
20101             ,p_person_referred_by_id       => p_person_referred_by_id
20102             ,p_supervisor_id               => p_supervisor_id
20103             ,p_special_ceiling_step_id     => p_special_ceiling_step_id
20104             ,p_recruitment_activity_id     => p_recruitment_activity_id
20105             ,p_source_organization_id      => p_source_organization_id
20106             ,p_organization_id             => p_organization_id
20107             ,p_vacancy_id                  => p_vacancy_id
20108             ,p_pay_basis_id                => p_pay_basis_id
20109             ,p_application_id              => l_application_id
20110             ,p_change_reason               => p_change_reason
20111             ,p_assignment_status_type_id   => l_assignment_status_type_id
20112             ,p_comments                    => p_comments
20113             ,p_date_probation_end          => l_date_probation_end
20114             ,p_default_code_comb_id        => p_default_code_comb_id
20115             ,p_employment_category         => p_employment_category
20116             ,p_frequency                    => p_frequency
20117             ,p_internal_address_line        => p_internal_address_line
20118             ,p_manager_flag                 => p_manager_flag
20119             ,p_normal_hours                 => p_normal_hours
20120             ,p_perf_review_period           => p_perf_review_period
20121             ,p_perf_review_period_frequency => p_perf_review_period_frequency
20122             ,p_probation_period             => p_probation_period
20123             ,p_probation_unit               => p_probation_unit
20124             ,p_sal_review_period            => p_sal_review_period
20125             ,p_sal_review_period_frequency  => p_sal_review_period_frequency
20126             ,p_set_of_books_id              => p_set_of_books_id
20127             ,p_source_type                  => p_source_type
20128             ,p_time_normal_finish           => p_time_normal_finish
20129             ,p_time_normal_start            => p_time_normal_start
20130             ,p_bargaining_unit_code         => p_bargaining_unit_code
20131             ,p_ass_attribute_category       => p_ass_attribute_category
20132             ,p_ass_attribute1               => p_ass_attribute1
20133             ,p_ass_attribute2               => p_ass_attribute2
20134             ,p_ass_attribute3               => p_ass_attribute3
20135             ,p_ass_attribute4               => p_ass_attribute4
20136             ,p_ass_attribute5               => p_ass_attribute5
20137             ,p_ass_attribute6               => p_ass_attribute6
20138             ,p_ass_attribute7               => p_ass_attribute7
20139             ,p_ass_attribute8               => p_ass_attribute8
20140             ,p_ass_attribute9               => p_ass_attribute9
20141             ,p_ass_attribute10              => p_ass_attribute10
20142             ,p_ass_attribute11              => p_ass_attribute11
20143             ,p_ass_attribute12              => p_ass_attribute12
20144             ,p_ass_attribute13              => p_ass_attribute13
20145             ,p_ass_attribute14              => p_ass_attribute14
20146             ,p_ass_attribute15              => p_ass_attribute15
20147             ,p_ass_attribute16              => p_ass_attribute16
20148             ,p_ass_attribute17              => p_ass_attribute17
20149             ,p_ass_attribute18              => p_ass_attribute18
20150             ,p_ass_attribute19              => p_ass_attribute19
20151             ,p_ass_attribute20              => p_ass_attribute20
20152             ,p_ass_attribute21              => p_ass_attribute21
20153             ,p_ass_attribute22              => p_ass_attribute22
20154             ,p_ass_attribute23              => p_ass_attribute23
20155             ,p_ass_attribute24              => p_ass_attribute24
20156             ,p_ass_attribute25              => p_ass_attribute25
20157             ,p_ass_attribute26              => p_ass_attribute26
20158             ,p_ass_attribute27              => p_ass_attribute27
20159             ,p_ass_attribute28              => p_ass_attribute28
20160             ,p_ass_attribute29              => p_ass_attribute29
20161             ,p_ass_attribute30              => p_ass_attribute30
20162             ,p_scl_segment1                 =>     l_scl_segment1
20163             ,p_scl_segment2                 =>     l_scl_segment2
20164             ,p_scl_segment3                 =>     l_scl_segment3
20165             ,p_scl_segment4                 =>     l_scl_segment4
20166             ,p_scl_segment5                 =>     l_scl_segment5
20167             ,p_scl_segment6                 =>     l_scl_segment6
20168             ,p_scl_segment7                 =>     l_scl_segment7
20169             ,p_scl_segment8                 =>     l_scl_segment8
20170             ,p_scl_segment9                 =>     l_scl_segment9
20171             ,p_scl_segment10                =>     l_scl_segment10
20172             ,p_scl_segment11                =>     l_scl_segment11
20173             ,p_scl_segment12                =>     l_scl_segment12
20174             ,p_scl_segment13                =>     l_scl_segment13
20175             ,p_scl_segment14                =>     l_scl_segment14
20176             ,p_scl_segment15                =>     l_scl_segment15
20177             ,p_scl_segment16                =>     l_scl_segment16
20178             ,p_scl_segment17                =>     l_scl_segment17
20179             ,p_scl_segment18                =>     l_scl_segment18
20180             ,p_scl_segment19                =>     l_scl_segment19
20181             ,p_scl_segment20                =>     l_scl_segment20
20182             ,p_scl_segment21                =>     l_scl_segment21
20183             ,p_scl_segment22                =>     l_scl_segment22
20184             ,p_scl_segment23                =>     l_scl_segment23
20185             ,p_scl_segment24                =>     l_scl_segment24
20186             ,p_scl_segment25                =>     l_scl_segment25
20187             ,p_scl_segment26                =>     l_scl_segment26
20188             ,p_scl_segment27                =>     l_scl_segment27
20189             ,p_scl_segment28                => l_scl_segment28
20190             ,p_scl_segment29                => l_scl_segment29
20191             ,p_scl_segment30                => l_scl_segment30
20192             ,p_scl_concat_segments          => l_old_scl_conc_segments
20193             ,p_concatenated_segments        => l_scl_concatenated_segments
20194             ,p_pgp_segment1                 =>     l_pgp_segment1
20195             ,p_pgp_segment2                 =>     l_pgp_segment2
20196             ,p_pgp_segment3                 =>     l_pgp_segment3
20197             ,p_pgp_segment4                 =>     l_pgp_segment4
20198             ,p_pgp_segment5                 =>     l_pgp_segment5
20199             ,p_pgp_segment6                 =>     l_pgp_segment6
20200             ,p_pgp_segment7                 =>     l_pgp_segment7
20201             ,p_pgp_segment8                 =>     l_pgp_segment8
20202             ,p_pgp_segment9                 =>     l_pgp_segment9
20203             ,p_pgp_segment10                =>     l_pgp_segment10
20204             ,p_pgp_segment11                =>     l_pgp_segment11
20205             ,p_pgp_segment12                =>     l_pgp_segment12
20206             ,p_pgp_segment13                =>     l_pgp_segment13
20207             ,p_pgp_segment14                =>     l_pgp_segment14
20208             ,p_pgp_segment15                =>     l_pgp_segment15
20209             ,p_pgp_segment16                =>     l_pgp_segment16
20210             ,p_pgp_segment17                =>     l_pgp_segment17
20211             ,p_pgp_segment18                =>     l_pgp_segment18
20212             ,p_pgp_segment19                =>     l_pgp_segment19
20213             ,p_pgp_segment20                =>     l_pgp_segment20
20214             ,p_pgp_segment21                =>     l_pgp_segment21
20215             ,p_pgp_segment22                =>     l_pgp_segment22
20216             ,p_pgp_segment23                =>     l_pgp_segment23
20217             ,p_pgp_segment24                =>     l_pgp_segment24
20218             ,p_pgp_segment25                =>     l_pgp_segment25
20219             ,p_pgp_segment26                =>     l_pgp_segment26
20220             ,p_pgp_segment27                =>     l_pgp_segment27
20221             ,p_pgp_segment28                =>     l_pgp_segment28
20222             ,p_pgp_segment29                =>     l_pgp_segment29
20223             ,p_pgp_segment30                =>     l_pgp_segment30
20224             ,p_concat_segments              => l_old_group_name
20225             ,p_contract_id                  => p_contract_id
20226             ,p_establishment_id             => p_establishment_id
20227             ,p_collective_agreement_id      => p_collective_agreement_id
20228             ,p_cagr_id_flex_num             => p_cagr_id_flex_num
20229             ,p_cag_segment1                 => l_cag_segment1
20230             ,p_cag_segment2                 => l_cag_segment2
20231             ,p_cag_segment3                 => l_cag_segment3
20232             ,p_cag_segment4                 => l_cag_segment4
20233             ,p_cag_segment5                 => l_cag_segment5
20234             ,p_cag_segment6                 => l_cag_segment6
20235             ,p_cag_segment7                 => l_cag_segment7
20236             ,p_cag_segment8                 => l_cag_segment8
20237             ,p_cag_segment9                 => l_cag_segment9
20238             ,p_cag_segment10                => l_cag_segment10
20239             ,p_cag_segment11                => l_cag_segment11
20240             ,p_cag_segment12                => l_cag_segment12
20241             ,p_cag_segment13                => l_cag_segment13
20242             ,p_cag_segment14                => l_cag_segment14
20243             ,p_cag_segment15                => l_cag_segment15
20244             ,p_cag_segment16                => l_cag_segment16
20245             ,p_cag_segment17                => l_cag_segment17
20246             ,p_cag_segment18                => l_cag_segment18
20247             ,p_cag_segment19                => l_cag_segment19
20248             ,p_cag_segment20                => l_cag_segment20
20249             ,p_title                        => p_title
20250             ,p_notice_period                    => p_notice_period
20251             ,p_notice_period_uom                => p_notice_period_uom
20252             ,p_employee_category                => p_employee_category
20253             ,p_work_at_home                         => p_work_at_home
20254             ,p_job_post_source_name             => p_job_post_source_name
20255             ,p_cagr_grade_def_id            => l_cagr_grade_def_id
20256             ,p_effective_start_date         => l_effective_start_date
20257             ,p_effective_end_date           => l_effective_end_date
20258             ,p_comment_id                   => l_comment_id
20259             ,p_applicant_rank               => p_applicant_rank
20260             ,p_posting_content_id           => p_posting_content_id
20261             ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
20262             ,p_supervisor_assignment_id     => p_supervisor_assignment_id
20263             ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
20264             ,p_group_name                   => l_group_name
20265             ,p_people_group_id              => l_people_group_id
20266             ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
20267          );
20268 
20269       if g_debug then
20270         hr_utility.set_location(l_proc, 50);
20271       end if;
20272   else -- application is not end dated
20273   --
20274   -- Insert secondary assignment
20275   --
20276     hr_assignment_internal.create_apl_asg
20277     (p_effective_date               => l_effective_date
20278     ,p_legislation_code             => l_legislation_code
20279     ,p_business_group_id            => l_business_group_id
20280     ,p_person_id                    => p_person_id
20281     ,p_organization_id              => p_organization_id
20282     ,p_application_id               => l_application_id
20283     ,p_recruiter_id                 => p_recruiter_id
20284     ,p_grade_id                     => p_grade_id
20285     ,p_position_id                  => p_position_id
20286     ,p_job_id                       => p_job_id
20287     ,p_assignment_status_type_id    => p_assignment_status_type_id
20288     ,p_payroll_id                   => p_payroll_id
20289     ,p_location_id                  => p_location_id
20290     ,p_person_referred_by_id        => p_person_referred_by_id
20291     ,p_supervisor_id                => p_supervisor_id
20292     ,p_special_ceiling_step_id      => p_special_ceiling_step_id
20293     ,p_recruitment_activity_id      => p_recruitment_activity_id
20294     ,p_source_organization_id       => p_source_organization_id
20295     ,p_people_group_id              => l_people_group_id
20296     ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
20297     ,p_vacancy_id                   => p_vacancy_id
20298     ,p_pay_basis_id                 => p_pay_basis_id
20299     ,p_change_reason                => p_change_reason
20300     ,p_comments                     => p_comments
20301     ,p_date_probation_end           => l_date_probation_end
20302     ,p_default_code_comb_id         => p_default_code_comb_id
20303     ,p_employment_category          => p_employment_category
20304     ,p_frequency                    => p_frequency
20305     ,p_internal_address_line        => p_internal_address_line
20306     ,p_manager_flag                 => p_manager_flag
20307     ,p_normal_hours                 => p_normal_hours
20308     ,p_perf_review_period           => p_perf_review_period
20309     ,p_perf_review_period_frequency => p_perf_review_period_frequency
20310     ,p_probation_period             => p_probation_period
20311     ,p_probation_unit               => p_probation_unit
20312     ,p_sal_review_period            => p_sal_review_period
20313     ,p_sal_review_period_frequency  => p_sal_review_period_frequency
20314     ,p_set_of_books_id              => p_set_of_books_id
20315     ,p_source_type                  => p_source_type
20316     ,p_time_normal_finish           => p_time_normal_finish
20317     ,p_time_normal_start            => p_time_normal_start
20318     ,p_bargaining_unit_code         => p_bargaining_unit_code
20319     ,p_ass_attribute_category       => p_ass_attribute_category
20320     ,p_ass_attribute1               => p_ass_attribute1
20321     ,p_ass_attribute2               => p_ass_attribute2
20322     ,p_ass_attribute3               => p_ass_attribute3
20323     ,p_ass_attribute4               => p_ass_attribute4
20324     ,p_ass_attribute5               => p_ass_attribute5
20325     ,p_ass_attribute6               => p_ass_attribute6
20326     ,p_ass_attribute7               => p_ass_attribute7
20327     ,p_ass_attribute8               => p_ass_attribute8
20328     ,p_ass_attribute9               => p_ass_attribute9
20329     ,p_ass_attribute10              => p_ass_attribute10
20330     ,p_ass_attribute11              => p_ass_attribute11
20331     ,p_ass_attribute12              => p_ass_attribute12
20332     ,p_ass_attribute13              => p_ass_attribute13
20333     ,p_ass_attribute14              => p_ass_attribute14
20334     ,p_ass_attribute15              => p_ass_attribute15
20335     ,p_ass_attribute16              => p_ass_attribute16
20336     ,p_ass_attribute17              => p_ass_attribute17
20337     ,p_ass_attribute18              => p_ass_attribute18
20338     ,p_ass_attribute19              => p_ass_attribute19
20339     ,p_ass_attribute20              => p_ass_attribute20
20340     ,p_ass_attribute21              => p_ass_attribute21
20341     ,p_ass_attribute22              => p_ass_attribute22
20342     ,p_ass_attribute23              => p_ass_attribute23
20343     ,p_ass_attribute24              => p_ass_attribute24
20344     ,p_ass_attribute25              => p_ass_attribute25
20345     ,p_ass_attribute26              => p_ass_attribute26
20346     ,p_ass_attribute27              => p_ass_attribute27
20347     ,p_ass_attribute28              => p_ass_attribute28
20348     ,p_ass_attribute29              => p_ass_attribute29
20349     ,p_ass_attribute30              => p_ass_attribute30
20350     ,p_title                        => p_title
20351     ,p_contract_id                  => p_contract_id
20352     ,p_establishment_id             => p_establishment_id
20353     ,p_collective_agreement_id      => p_collective_agreement_id
20354     ,p_cagr_id_flex_num             => p_cagr_id_flex_num
20355     ,p_notice_period		    => p_notice_period
20356     ,p_notice_period_uom	    => p_notice_period_uom
20357     ,p_employee_category	    => p_employee_category
20358     ,p_work_at_home		    => p_work_at_home
20359     ,p_job_post_source_name	    => p_job_post_source_name
20360     ,p_cagr_grade_def_id            => l_cagr_grade_def_id
20361     ,p_assignment_id                => l_assignment_id
20362     ,p_object_version_number        => l_object_version_number
20363     ,p_effective_start_date         => l_effective_start_date
20364     ,p_effective_end_date           => l_effective_end_date
20365     ,p_assignment_sequence          => l_assignment_sequence
20366     ,p_comment_id                   => l_comment_id
20367     ,p_applicant_rank               => p_applicant_rank
20368     ,p_posting_content_id           => p_posting_content_id
20369     ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
20370     ,p_supervisor_assignment_id     => p_supervisor_assignment_id
20371     );
20372   --
20373  if g_debug then
20374   hr_utility.set_location(l_proc, 40);
20375  end if;
20376 
20377   end if; -- application is end dated?
20378   --
20379   -- add to the security list if neccesary
20380   --
20381   if(l_effective_date<=sysdate) then
20382     hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
20383   end if;
20384   --
20385   --
20386   -- Start of API User Hook for the after hook of create_secondary_apl_asg.
20387   --
20388   begin
20389      hr_assignment_bk8.create_secondary_apl_asg_a
20390        (p_effective_date               =>     l_effective_date
20391        ,p_person_id                    =>     p_person_id
20392        ,p_organization_id              =>     p_organization_id
20393        ,p_recruiter_id                 =>     p_recruiter_id
20394        ,p_grade_id                     =>     p_grade_id
20395        ,p_position_id                  =>     p_position_id
20396        ,p_job_id                       =>     p_job_id
20397        ,p_payroll_id                   =>     p_payroll_id
20398        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
20399        ,p_location_id                  =>     p_location_id
20400        ,p_person_referred_by_id        =>     p_person_referred_by_id
20401        ,p_supervisor_id                =>     p_supervisor_id
20402        ,p_special_ceiling_step_id      =>     p_special_ceiling_step_id
20403        ,p_recruitment_activity_id      =>     p_recruitment_activity_id
20404        ,p_source_organization_id       =>     p_source_organization_id
20405        ,p_vacancy_id                   =>     p_vacancy_id
20406        ,p_pay_basis_id                 =>     p_pay_basis_id
20407        ,p_change_reason                =>     p_change_reason
20408        ,p_internal_address_line        =>     p_internal_address_line
20409        ,p_comments                     =>     p_comments
20410        ,p_date_probation_end           =>     l_date_probation_end
20411        ,p_default_code_comb_id         =>     p_default_code_comb_id
20412        ,p_employment_category          =>     p_employment_category
20413        ,p_frequency                    =>     p_frequency
20414        ,p_manager_flag                 =>     p_manager_flag
20415        ,p_normal_hours                 =>     p_normal_hours
20416        ,p_perf_review_period           =>     p_perf_review_period
20417        ,p_perf_review_period_frequency =>     p_perf_review_period_frequency
20418        ,p_probation_period             =>     p_probation_period
20419        ,p_probation_unit               =>     p_probation_unit
20420        ,p_sal_review_period            =>     p_sal_review_period
20421        ,p_sal_review_period_frequency  =>     p_sal_review_period_frequency
20422        ,p_set_of_books_id              =>     p_set_of_books_id
20423        ,p_source_type                  =>     p_source_type
20424        ,p_time_normal_finish           =>     p_time_normal_finish
20425        ,p_time_normal_start            =>     p_time_normal_start
20426        ,p_bargaining_unit_code         =>     p_bargaining_unit_code
20427        ,p_ass_attribute_category       =>     p_ass_attribute_category
20428        ,p_ass_attribute1               =>     p_ass_attribute1
20429        ,p_ass_attribute2               =>     p_ass_attribute2
20430        ,p_ass_attribute3               =>     p_ass_attribute3
20431        ,p_ass_attribute4               =>     p_ass_attribute4
20432        ,p_ass_attribute5               =>     p_ass_attribute5
20433        ,p_ass_attribute6               =>     p_ass_attribute6
20434        ,p_ass_attribute7               =>     p_ass_attribute7
20435        ,p_ass_attribute8               =>     p_ass_attribute8
20436        ,p_ass_attribute9               =>     p_ass_attribute9
20437        ,p_ass_attribute10              =>     p_ass_attribute10
20438        ,p_ass_attribute11              =>     p_ass_attribute11
20439        ,p_ass_attribute12              =>     p_ass_attribute12
20440        ,p_ass_attribute13              =>     p_ass_attribute13
20441        ,p_ass_attribute14              =>     p_ass_attribute14
20442        ,p_ass_attribute15              =>     p_ass_attribute15
20443        ,p_ass_attribute16              =>     p_ass_attribute16
20444        ,p_ass_attribute17              =>     p_ass_attribute17
20445        ,p_ass_attribute18              =>     p_ass_attribute18
20446        ,p_ass_attribute19              =>     p_ass_attribute19
20447        ,p_ass_attribute20              =>     p_ass_attribute20
20448        ,p_ass_attribute21              =>     p_ass_attribute21
20449        ,p_ass_attribute22              =>     p_ass_attribute22
20450        ,p_ass_attribute23              =>     p_ass_attribute23
20451        ,p_ass_attribute24              =>     p_ass_attribute24
20452        ,p_ass_attribute25              =>     p_ass_attribute25
20453        ,p_ass_attribute26              =>     p_ass_attribute26
20454        ,p_ass_attribute27              =>     p_ass_attribute27
20455        ,p_ass_attribute28              =>     p_ass_attribute28
20456        ,p_ass_attribute29              =>     p_ass_attribute29
20457        ,p_ass_attribute30              =>     p_ass_attribute30
20458        ,p_title                        =>     p_title
20459        ,p_scl_segment1                 =>     l_scl_segment1
20460        ,p_scl_segment2                 =>     l_scl_segment2
20461        ,p_scl_segment3                 =>     l_scl_segment3
20462        ,p_scl_segment4                 =>     l_scl_segment4
20463        ,p_scl_segment5                 =>     l_scl_segment5
20464        ,p_scl_segment6                 =>     l_scl_segment6
20465        ,p_scl_segment7                 =>     l_scl_segment7
20466        ,p_scl_segment8                 =>     l_scl_segment8
20467        ,p_scl_segment9                 =>     l_scl_segment9
20468        ,p_scl_segment10                =>     l_scl_segment10
20469        ,p_scl_segment11                =>     l_scl_segment11
20470        ,p_scl_segment12                =>     l_scl_segment12
20471        ,p_scl_segment13                =>     l_scl_segment13
20472        ,p_scl_segment14                =>     l_scl_segment14
20473        ,p_scl_segment15                =>     l_scl_segment15
20474        ,p_scl_segment16                =>     l_scl_segment16
20475        ,p_scl_segment17                =>     l_scl_segment17
20476        ,p_scl_segment18                =>     l_scl_segment18
20477        ,p_scl_segment19                =>     l_scl_segment19
20478        ,p_scl_segment20                =>     l_scl_segment20
20479        ,p_scl_segment21                =>     l_scl_segment21
20480        ,p_scl_segment22                =>     l_scl_segment22
20481        ,p_scl_segment23                =>     l_scl_segment23
20482        ,p_scl_segment24                =>     l_scl_segment24
20483        ,p_scl_segment25                =>     l_scl_segment25
20484        ,p_scl_segment26                =>     l_scl_segment26
20485        ,p_scl_segment27                =>     l_scl_segment27
20486        ,p_scl_segment28                =>     l_scl_segment28
20487        ,p_scl_segment29                =>     l_scl_segment29
20488        ,p_scl_segment30                =>     l_scl_segment30
20489 -- Bug 944911
20490 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
20491        ,p_concatenated_segments        =>     l_scl_concatenated_segments
20492        ,p_pgp_segment1                 =>     l_pgp_segment1
20493        ,p_pgp_segment2                 =>     l_pgp_segment2
20494        ,p_pgp_segment3                 =>     l_pgp_segment3
20495        ,p_pgp_segment4                 =>     l_pgp_segment4
20496        ,p_pgp_segment5                 =>     l_pgp_segment5
20497        ,p_pgp_segment6                 =>     l_pgp_segment6
20498        ,p_pgp_segment7                 =>     l_pgp_segment7
20499        ,p_pgp_segment8                 =>     l_pgp_segment8
20500        ,p_pgp_segment9                 =>     l_pgp_segment9
20501        ,p_pgp_segment10                =>     l_pgp_segment10
20502        ,p_pgp_segment11                =>     l_pgp_segment11
20503        ,p_pgp_segment12                =>     l_pgp_segment12
20504        ,p_pgp_segment13                =>     l_pgp_segment13
20505        ,p_pgp_segment14                =>     l_pgp_segment14
20506        ,p_pgp_segment15                =>     l_pgp_segment15
20507        ,p_pgp_segment16                =>     l_pgp_segment16
20508        ,p_pgp_segment17                =>     l_pgp_segment17
20509        ,p_pgp_segment18                =>     l_pgp_segment18
20510        ,p_pgp_segment19                =>     l_pgp_segment19
20511        ,p_pgp_segment20                =>     l_pgp_segment20
20512        ,p_pgp_segment21                =>     l_pgp_segment21
20513        ,p_pgp_segment22                =>     l_pgp_segment22
20514        ,p_pgp_segment23                =>     l_pgp_segment23
20515        ,p_pgp_segment24                =>     l_pgp_segment24
20516        ,p_pgp_segment25                =>     l_pgp_segment25
20517        ,p_pgp_segment26                =>     l_pgp_segment26
20518        ,p_pgp_segment27                =>     l_pgp_segment27
20519        ,p_pgp_segment28                =>     l_pgp_segment28
20520        ,p_pgp_segment29                =>     l_pgp_segment29
20521        ,p_pgp_segment30                =>     l_pgp_segment30
20522        ,p_group_name                   =>     l_group_name
20523        ,p_assignment_id                =>     l_assignment_id
20524        ,p_object_version_number        =>     l_object_version_number
20525        ,p_effective_start_date         =>     l_effective_start_date
20526        ,p_effective_end_date           =>     l_effective_end_date
20527        ,p_assignment_sequence          =>     l_assignment_sequence
20528        ,p_comment_id                   =>     l_comment_id
20529        ,p_people_group_id              =>     l_people_group_id
20530        ,p_soft_coding_keyflex_id       =>     l_soft_coding_keyflex_id
20531        ,p_business_group_id            =>     l_business_group_id
20532        ,p_contract_id                  => p_contract_id
20533        ,p_establishment_id             => p_establishment_id
20534        ,p_collective_agreement_id      => p_collective_agreement_id
20535        ,p_cagr_id_flex_num             => p_cagr_id_flex_num
20536        ,p_cag_segment1                 => l_cag_segment1
20537        ,p_cag_segment2                 => l_cag_segment2
20538        ,p_cag_segment3                 => l_cag_segment3
20539        ,p_cag_segment4                 => l_cag_segment4
20540        ,p_cag_segment5                 => l_cag_segment5
20541        ,p_cag_segment6                 => l_cag_segment6
20542        ,p_cag_segment7                 => l_cag_segment7
20543        ,p_cag_segment8                 => l_cag_segment8
20544        ,p_cag_segment9                 => l_cag_segment9
20545        ,p_cag_segment10                => l_cag_segment10
20546        ,p_cag_segment11                => l_cag_segment11
20547        ,p_cag_segment12                => l_cag_segment12
20548        ,p_cag_segment13                => l_cag_segment13
20549        ,p_cag_segment14                => l_cag_segment14
20550        ,p_cag_segment15                => l_cag_segment15
20551        ,p_cag_segment16                => l_cag_segment16
20552        ,p_cag_segment17                => l_cag_segment17
20553        ,p_cag_segment18                => l_cag_segment18
20554        ,p_cag_segment19                => l_cag_segment19
20555        ,p_cag_segment20                => l_cag_segment20
20556        ,p_notice_period		       => p_notice_period
20557        ,p_notice_period_uom	       => p_notice_period_uom
20558        ,p_employee_category	       => p_employee_category
20559        ,p_work_at_home		       => p_work_at_home
20560        ,p_job_post_source_name	       => p_job_post_source_name
20561        ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
20562        ,p_cagr_grade_def_id            => l_cagr_grade_def_id
20563 -- Added the 2 new in params
20564 -- Bug 944911
20565 -- Amended p_scl_concatenated_segments to be p_scl_concat_segments
20566        ,p_scl_concat_segments          => l_old_scl_conc_segments
20567 -- Bug 944911
20568 -- Amended p_group_name to be p_concat_segments
20569        ,p_concat_segments              => l_old_group_name
20570        ,p_applicant_rank               => p_applicant_rank
20571        ,p_posting_content_id           => p_posting_content_id
20572        ,p_grade_ladder_pgm_id          => p_grade_ladder_pgm_id
20573        ,p_supervisor_assignment_id     => p_supervisor_assignment_id
20574  );
20575   exception
20576      when hr_api.cannot_find_prog_unit then
20577        hr_api.cannot_find_prog_unit_error
20578          (p_module_name       => 'CREATE_SECONDARY_APL_ASG',
20579           p_hook_type         => 'AP'
20580          );
20581   end;
20582   --
20583   -- End of API User Hook for the after hook of create_secondary_apl_asg.
20584   --
20585   --
20586   -- When in validation only mode raise the Validate_Enabled exception
20587   --
20588   if p_validate then
20589     raise hr_api.validate_enabled;
20590   end if;
20591   --
20592   -- Set remaining output arguments
20593   --
20594   p_assignment_id          := l_assignment_id;
20595   p_people_group_id        := l_people_group_id;
20596   p_object_version_number  := l_object_version_number;
20597   p_effective_start_date   := l_effective_start_date;
20598   p_effective_end_date     := l_effective_end_date;
20599   p_assignment_sequence    := l_assignment_sequence;
20600   p_comment_id             := l_comment_id;
20601   p_group_name             := l_group_name;
20602   p_soft_coding_keyflex_id := l_soft_coding_keyflex_id;
20603   p_appl_override_warning  := l_appl_override_warning; -- 3652025
20604 -- Bug 944911
20605 -- Amended p_scl_concatenated_segments to be p_concatenated_segments
20606   p_concatenated_segments  := l_scl_concatenated_segments;
20607   p_cagr_grade_def_id           := l_cagr_grade_def_id;
20608   p_cagr_concatenated_segments  := l_cagr_concatenated_segments;
20609 
20610   --
20611   --
20612   -- remove data from the session table
20613   hr_kflex_utility.unset_session_date
20614     (p_session_id     => l_session_id);
20615   --
20616  if g_debug then
20617   hr_utility.set_location(' Leaving:'||l_proc, 50);
20618  end if;
20619 exception
20620   when hr_api.validate_enabled then
20621     --
20622     -- As the Validate_Enabled exception has been raised
20623     -- we must rollback to the savepoint
20624     --
20625     ROLLBACK TO create_secondary_apl_asg;
20626     --
20627     -- Only set output warning arguments
20628     -- (Any key or derived arguments must be set to null
20629     -- when validation only mode is being used.)
20630     --
20631     p_assignment_id          := null;
20632     p_object_version_number  := null;
20633     p_effective_start_date   := null;
20634     p_effective_end_date     := null;
20635     p_assignment_sequence    := null;
20636     p_comment_id             := null;
20637     --
20638     -- bug 2230915 only re-set to null if key flex ids came in as null.
20639     --
20640     if l_pgp_null_ind = 0
20641     then
20642        p_people_group_id           := null;
20643     end if;
20644     --
20645     p_group_name                   := l_old_group_name;
20646     --
20647     if l_scl_null_ind = 0
20648     then
20649        p_soft_coding_keyflex_id    := null;
20650     end if;
20651     --
20652     --Bug 944911
20653     p_concatenated_segments        := l_old_scl_conc_segments;
20654     --
20655     if l_cag_null_ind = 0
20656     then
20657        p_cagr_grade_def_id         := null;
20658     end if;
20659     --
20660     p_cagr_concatenated_segments   := null;
20661     --
20662   when others then
20663     --
20664     -- A validation or unexpected error has occurred
20665     --
20666     -- Added as part of fix to bug 632479
20667     --
20668 
20669     p_cagr_grade_def_id         := lv_cagr_grade_def_id ;
20670     p_people_group_id           := lv_people_group_id ;
20671     p_soft_coding_keyflex_id    := lv_people_group_id ;
20672 
20673     p_concatenated_segments           := null;
20674     p_cagr_concatenated_segments      := null;
20675     p_group_name                      := null;
20676     p_assignment_id                   := null;
20677     p_comment_id                      := null;
20678     p_object_version_number           := null;
20679     p_effective_start_date            := null;
20680     p_effective_end_date              := null;
20681     p_assignment_sequence             := null;
20682 
20683     ROLLBACK TO create_secondary_apl_asg;
20684     raise;
20685     --
20686     -- End of fix.
20687     --
20688 end create_secondary_apl_asg;
20689 --
20690 -- ----------------------------------------------------------------------------
20691 -- |---------------------< create_secondary_apl_asg >--R11---------------------|
20692 -- ----------------------------------------------------------------------------
20693 --
20694 procedure create_secondary_apl_asg
20695   (p_validate                     in     boolean
20696   ,p_effective_date               in     date
20697   ,p_person_id                    in     number
20698   ,p_organization_id              in     number
20699   ,p_recruiter_id                 in     number
20700   ,p_grade_id                     in     number
20701   ,p_position_id                  in     number
20702   ,p_job_id                       in     number
20703   ,p_assignment_status_type_id    in     number
20704   ,p_location_id                  in     number
20705   ,p_person_referred_by_id        in     number
20706   ,p_supervisor_id                in     number
20707   ,p_recruitment_activity_id      in     number
20708   ,p_source_organization_id       in     number
20709   ,p_vacancy_id                   in     number
20710   ,p_change_reason                in     varchar2
20711   ,p_comments                     in     varchar2
20712   ,p_date_probation_end           in     date
20713   ,p_frequency                    in     varchar2
20714   ,p_manager_flag                 in     varchar2
20715   ,p_normal_hours                 in     number
20716   ,p_probation_period             in     number
20717   ,p_probation_unit               in     varchar2
20718   ,p_source_type                  in     varchar2
20719   ,p_time_normal_finish           in     varchar2
20720   ,p_time_normal_start            in     varchar2
20721   ,p_ass_attribute_category       in     varchar2
20722   ,p_ass_attribute1               in     varchar2
20723   ,p_ass_attribute2               in     varchar2
20724   ,p_ass_attribute3               in     varchar2
20725   ,p_ass_attribute4               in     varchar2
20726   ,p_ass_attribute5               in     varchar2
20727   ,p_ass_attribute6               in     varchar2
20728   ,p_ass_attribute7               in     varchar2
20729   ,p_ass_attribute8               in     varchar2
20730   ,p_ass_attribute9               in     varchar2
20731   ,p_ass_attribute10              in     varchar2
20732   ,p_ass_attribute11              in     varchar2
20733   ,p_ass_attribute12              in     varchar2
20734   ,p_ass_attribute13              in     varchar2
20735   ,p_ass_attribute14              in     varchar2
20736   ,p_ass_attribute15              in     varchar2
20737   ,p_ass_attribute16              in     varchar2
20738   ,p_ass_attribute17              in     varchar2
20739   ,p_ass_attribute18              in     varchar2
20740   ,p_ass_attribute19              in     varchar2
20741   ,p_ass_attribute20              in     varchar2
20742   ,p_ass_attribute21              in     varchar2
20743   ,p_ass_attribute22              in     varchar2
20744   ,p_ass_attribute23              in     varchar2
20745   ,p_ass_attribute24              in     varchar2
20746   ,p_ass_attribute25              in     varchar2
20747   ,p_ass_attribute26              in     varchar2
20748   ,p_ass_attribute27              in     varchar2
20749   ,p_ass_attribute28              in     varchar2
20750   ,p_ass_attribute29              in     varchar2
20751   ,p_ass_attribute30              in     varchar2
20752   ,p_title                        in     varchar2
20753   ,p_segment1                     in     varchar2
20754   ,p_segment2                     in     varchar2
20755   ,p_segment3                     in     varchar2
20756   ,p_segment4                     in     varchar2
20757   ,p_segment5                     in     varchar2
20758   ,p_segment6                     in     varchar2
20759   ,p_segment7                     in     varchar2
20760   ,p_segment8                     in     varchar2
20761   ,p_segment9                     in     varchar2
20762   ,p_segment10                    in     varchar2
20763   ,p_segment11                    in     varchar2
20764   ,p_segment12                    in     varchar2
20765   ,p_segment13                    in     varchar2
20766   ,p_segment14                    in     varchar2
20767   ,p_segment15                    in     varchar2
20768   ,p_segment16                    in     varchar2
20769   ,p_segment17                    in     varchar2
20770   ,p_segment18                    in     varchar2
20771   ,p_segment19                    in     varchar2
20772   ,p_segment20                    in     varchar2
20773   ,p_segment21                    in     varchar2
20774   ,p_segment22                    in     varchar2
20775   ,p_segment23                    in     varchar2
20776   ,p_segment24                    in     varchar2
20777   ,p_segment25                    in     varchar2
20778   ,p_segment26                    in     varchar2
20779   ,p_segment27                    in     varchar2
20780   ,p_segment28                    in     varchar2
20781   ,p_segment29                    in     varchar2
20782   ,p_segment30                    in     varchar2
20783 -- Bug 944911
20784 -- Made p_group_name to be out param
20785 -- and add p_concat_segment to be IN
20786 -- in case of sec_asg alone made p_pgp_concat_segments as in param
20787 -- Reverting changes are it is for R11
20788   -- ,p_concat_segments              in     varchar2
20789   ,p_supervisor_assignment_id     in     number
20790   ,p_group_name                   in out nocopy varchar2
20791   ,p_assignment_id                   out nocopy number
20792   ,p_object_version_number           out nocopy number
20793   ,p_effective_start_date            out nocopy date
20794   ,p_effective_end_date              out nocopy date
20795   ,p_assignment_sequence             out nocopy number
20796   ,p_comment_id                      out nocopy number
20797   ,p_people_group_id                 out nocopy number
20798   ) is
20799   --
20800   -- Declare cursors and local variables
20801   --
20802   -- Out variables
20803   --
20804   l_assignment_id          per_all_assignments_f.assignment_id%TYPE;
20805   l_people_group_id        per_all_assignments_f.people_group_id%TYPE;
20806   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
20807   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
20808   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
20809   l_assignment_sequence    per_all_assignments_f.assignment_sequence%TYPE;
20810   l_comment_id             per_all_assignments_f.comment_id%TYPE;
20811   l_group_name             pay_people_groups.group_name%TYPE;
20812   l_flex_num	           fnd_id_flex_segments.id_flex_num%TYPE;
20813   l_application_id         per_applications.application_id%TYPE;
20814   l_business_group_id      per_business_groups.business_group_id%TYPE;
20815   l_legislation_code       per_business_groups.legislation_code%TYPE;
20816   l_period_of_service_id   per_all_assignments_f.period_of_service_id%TYPE;
20817   l_proc                   varchar2(72);
20818   l_soft_coding_keyflex_id per_all_assignments_f.soft_coding_keyflex_id%TYPE;
20819   l_concatenated_segments  hr_soft_coding_keyflex.concatenated_segments%TYPE;
20820   l_effective_date         date;
20821   l_date_probation_end     date;
20822   l_cagr_concatenated_segments varchar2(3000);
20823   l_cagr_grade_def_id      number;
20824 
20825   --
20826 begin
20827   --
20828  if g_debug then
20829  l_proc := g_package||'create_secondary_apl_asg';
20830   hr_utility.set_location('Entering:'|| l_proc, 5);
20831  end if;
20832    -- Call the new code
20833 -- Bug 944911
20834 -- No change to call point as all outs are present while the ins have defaults
20835   hr_assignment_api.create_secondary_apl_asg(
20836    p_validate                     => p_validate
20837   ,p_effective_date               => p_effective_date
20838   ,p_person_id                    => p_person_id
20839   ,p_organization_id              => p_organization_id
20840   ,p_recruiter_id                 => p_recruiter_id
20841   ,p_grade_id                     => p_grade_id
20842   ,p_position_id                  => p_position_id
20843   ,p_job_id                       => p_job_id
20844   ,p_assignment_status_type_id    => p_assignment_status_type_id
20845   ,p_location_id                  => p_location_id
20846   ,p_person_referred_by_id        => p_person_referred_by_id
20847   ,p_supervisor_id                => p_supervisor_id
20848   ,p_recruitment_activity_id      => p_recruitment_activity_id
20849   ,p_source_organization_id       => p_source_organization_id
20850   ,p_vacancy_id                   => p_vacancy_id
20851   ,p_change_reason                => p_change_reason
20852   ,p_comments                     => p_comments
20853   ,p_date_probation_end           => p_date_probation_end
20854   ,p_frequency                    => p_frequency
20855   ,p_manager_flag                 => p_manager_flag
20856   ,p_normal_hours                 => p_normal_hours
20857   ,p_probation_period             => p_probation_period
20858   ,p_probation_unit               => p_probation_unit
20859   ,p_source_type                  => p_source_type
20860   ,p_time_normal_finish           => p_time_normal_finish
20861   ,p_time_normal_start            => p_time_normal_start
20862   ,p_ass_attribute_category       => p_ass_attribute_category
20863   ,p_ass_attribute1               => p_ass_attribute1
20864   ,p_ass_attribute2               => p_ass_attribute2
20865   ,p_ass_attribute3               => p_ass_attribute3
20866   ,p_ass_attribute4               => p_ass_attribute4
20867   ,p_ass_attribute5               => p_ass_attribute5
20868   ,p_ass_attribute6               => p_ass_attribute6
20869   ,p_ass_attribute7               => p_ass_attribute7
20870   ,p_ass_attribute8               => p_ass_attribute8
20871   ,p_ass_attribute9               => p_ass_attribute9
20872   ,p_ass_attribute10              => p_ass_attribute10
20873   ,p_ass_attribute11              => p_ass_attribute11
20874   ,p_ass_attribute12              => p_ass_attribute12
20875   ,p_ass_attribute13              => p_ass_attribute13
20876   ,p_ass_attribute14              => p_ass_attribute14
20877   ,p_ass_attribute15              => p_ass_attribute15
20878   ,p_ass_attribute16              => p_ass_attribute16
20879   ,p_ass_attribute17              => p_ass_attribute17
20880   ,p_ass_attribute18              => p_ass_attribute18
20881   ,p_ass_attribute19              => p_ass_attribute19
20882   ,p_ass_attribute20              => p_ass_attribute20
20883   ,p_ass_attribute21              => p_ass_attribute21
20884   ,p_ass_attribute22              => p_ass_attribute22
20885   ,p_ass_attribute23              => p_ass_attribute23
20886   ,p_ass_attribute24              => p_ass_attribute24
20887   ,p_ass_attribute25              => p_ass_attribute25
20888   ,p_ass_attribute26              => p_ass_attribute26
20889   ,p_ass_attribute27              => p_ass_attribute27
20890   ,p_ass_attribute28              => p_ass_attribute28
20891   ,p_ass_attribute29              => p_ass_attribute29
20892   ,p_ass_attribute30              => p_ass_attribute30
20893   ,p_title                        => p_title
20894   ,p_pgp_segment1                     => p_segment1
20895   ,p_pgp_segment2                     => p_segment2
20896   ,p_pgp_segment3                     => p_segment3
20897   ,p_pgp_segment4                     => p_segment4
20898   ,p_pgp_segment5                     => p_segment5
20899   ,p_pgp_segment6                     => p_segment6
20900   ,p_pgp_segment7                     => p_segment7
20901   ,p_pgp_segment8                     => p_segment8
20902   ,p_pgp_segment9                     => p_segment9
20903   ,p_pgp_segment10                    => p_segment10
20904   ,p_pgp_segment11                    => p_segment11
20905   ,p_pgp_segment12                    => p_segment12
20906   ,p_pgp_segment13                    => p_segment13
20907   ,p_pgp_segment14                    => p_segment14
20908   ,p_pgp_segment15                    => p_segment15
20909   ,p_pgp_segment16                    => p_segment16
20910   ,p_pgp_segment17                    => p_segment17
20911   ,p_pgp_segment18                    => p_segment18
20912   ,p_pgp_segment19                    => p_segment19
20913   ,p_pgp_segment20                    => p_segment20
20914   ,p_pgp_segment21                    => p_segment21
20915   ,p_pgp_segment22                    => p_segment22
20916   ,p_pgp_segment23                    => p_segment23
20917   ,p_pgp_segment24                    => p_segment24
20918   ,p_pgp_segment25                    => p_segment25
20919   ,p_pgp_segment26                    => p_segment26
20920   ,p_pgp_segment27                    => p_segment27
20921   ,p_pgp_segment28                    => p_segment28
20922   ,p_pgp_segment29                    => p_segment29
20923   ,p_pgp_segment30                    => p_segment30
20924   ,p_assignment_id                => l_assignment_id
20925   ,p_people_group_id              => l_people_group_id
20926   ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id
20927   ,p_comment_id                   => l_comment_id
20928   ,p_object_version_number        => l_object_version_number
20929   ,p_effective_start_date         => l_effective_start_date
20930   ,p_effective_end_date           => l_effective_end_date
20931   ,p_group_name                   => l_group_name
20932 -- Bug 944911
20933   ,p_concatenated_segments    => l_concatenated_segments
20934   ,p_assignment_sequence          => l_assignment_sequence
20935   ,p_cagr_grade_def_id            => l_cagr_grade_def_id
20936   ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
20937   ,p_supervisor_assignment_id     => p_supervisor_assignment_id
20938   );
20939   -- Set remaining output arguments
20940   -- Ignore the new out parameters
20941   --
20942   p_assignment_id          := l_assignment_id;
20943   p_people_group_id        := l_people_group_id;
20944   p_object_version_number  := l_object_version_number;
20945   p_effective_start_date   := l_effective_start_date;
20946   p_effective_end_date     := l_effective_end_date;
20947   p_assignment_sequence    := l_assignment_sequence;
20948   p_comment_id             := l_comment_id;
20949   p_group_name             := l_group_name;
20950   --
20951  if g_debug then
20952   hr_utility.set_location(' Leaving:'||l_proc, 50);
20953  end if;
20954 end create_secondary_apl_asg;
20955 --
20956 -- ----------------------------------------------------------------------------
20957 -- |---------------------------< offer_apl_asg >------------------------------|
20958 -- ----------------------------------------------------------------------------
20959 --
20960 procedure offer_apl_asg
20961   (p_validate                     in     boolean
20962   ,p_effective_date               in     date
20963   ,p_datetrack_update_mode        in     varchar2
20964   ,p_assignment_id                in     number
20965   ,p_object_version_number        in out nocopy number
20966   ,p_assignment_status_type_id    in     number
20967   ,p_change_reason                in     varchar2
20968   ,p_effective_start_date            out nocopy date
20969   ,p_effective_end_date              out nocopy date
20970   ) is
20971   --
20972   -- Declare cursors and local variables
20973   --
20974   l_object_version_number_orig number;
20975   l_effective_date             date;
20976   --
20977   -- Out variables
20978   --
20979   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
20980   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
20981   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
20982   --
20983   lv_object_version_number     number := p_object_version_number ;
20984   --
20985   l_proc                 varchar2(72);
20986   --
20987 begin
20988  if g_debug then
20989   l_proc := g_package||'offer_apl_asg';
20990   hr_utility.set_location('Entering:'|| l_proc, 5);
20991  end if;
20992   --
20993   -- Initialise local variable - added 25-Aug-97. RMF.
20994   --
20995   l_effective_date := trunc(p_effective_date);
20996   --
20997   -- Issue a savepoint.
20998   --
20999   savepoint offer_apl_asg;
21000   --
21001   -- Preserve IN OUT parameters for later use
21002   --
21003   l_object_version_number_orig := p_object_version_number;
21004   l_object_version_number      := p_object_version_number;
21005   --
21006  if g_debug then
21007   hr_utility.set_location(l_proc, 10);
21008  end if;
21009   --
21010   -- Process Logic
21011   --
21012   --
21013   -- Start of API User Hook for the before hook of offer_apl_asg.
21014   --
21015   begin
21016      hr_assignment_bk9.offer_apl_asg_b
21017        (p_effective_date               =>     l_effective_date
21018        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21019        ,p_assignment_id                =>     p_assignment_id
21020        ,p_object_version_number        =>     p_object_version_number
21021        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21022        ,p_change_reason                =>     p_change_reason
21023        );
21024   exception
21025      when hr_api.cannot_find_prog_unit then
21026        hr_api.cannot_find_prog_unit_error
21027          (p_module_name       => 'OFFER_APL_ASG',
21028           p_hook_type         => 'BP'
21029          );
21030   end;
21031   --
21032   hr_assignment_internal.update_status_type_apl_asg
21033       (p_effective_date            => l_effective_date
21034       ,p_datetrack_update_mode     => p_datetrack_update_mode
21035       ,p_assignment_id             => p_assignment_id
21036       ,p_object_version_number     => l_object_version_number
21037       ,p_expected_system_status    => 'OFFER'
21038       ,p_assignment_status_type_id => p_assignment_status_type_id
21039       ,p_change_reason             => p_change_reason
21040       ,p_effective_start_date      => l_effective_start_date
21041       ,p_effective_end_date        => l_effective_end_date
21042       );
21043   --
21044  if g_debug then
21045   hr_utility.set_location(l_proc, 20);
21046  end if;
21047   --
21048   -- Start of API User Hook for the after hook of offer_apl_asg.
21049   --
21050   begin
21051      hr_assignment_bk9.offer_apl_asg_a
21052        (p_effective_date               =>     l_effective_date
21053        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21054        ,p_assignment_id                =>     p_assignment_id
21055        ,p_object_version_number        =>     l_object_version_number
21056        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21057        ,p_change_reason                =>     p_change_reason
21058        ,p_effective_start_date         =>     l_effective_start_date
21059        ,p_effective_end_date           =>     l_effective_end_date
21060        );
21061   exception
21062      when hr_api.cannot_find_prog_unit then
21063        hr_api.cannot_find_prog_unit_error
21064          (p_module_name       => 'OFFER_APL_ASG',
21065           p_hook_type         => 'AP'
21066          );
21067   end;
21068   --
21069   -- End of API User Hook for the after hook of offer_apl_asg.
21070   --
21071   --
21072   -- When in validation only mode raise the Validate_Enabled exception
21073   --
21074   if p_validate then
21075     raise hr_api.validate_enabled;
21076   end if;
21077   --
21078   -- Set remaining output arguments
21079   --
21080   p_object_version_number  := l_object_version_number;
21081   p_effective_start_date   := l_effective_start_date;
21082   p_effective_end_date     := l_effective_end_date;
21083  --
21084  if g_debug then
21085   hr_utility.set_location(' Leaving:'||l_proc, 50);
21086  end if;
21087 exception
21088   when hr_api.validate_enabled then
21089     --
21090     -- As the Validate_Enabled exception has been raised
21091     -- we must rollback to the savepoint
21092     --
21093     ROLLBACK TO offer_apl_asg;
21094     --
21095     -- Only set output warning arguments
21096     -- (Any key or derived arguments must be set to null
21097     -- when validation only mode is being used.)
21098     --
21099     p_object_version_number  := l_object_version_number_orig;
21100     p_effective_start_date   := null;
21101     p_effective_end_date     := null;
21102     --
21103   when others then
21104     --
21105     -- A validation or unexpected error has occurred
21106     --
21107     -- Added as part of fix to bug 632479
21108     --
21109     p_object_version_number := lv_object_version_number;
21110     p_effective_start_date   := null;
21111     p_effective_end_date     := null;
21112 
21113     ROLLBACK TO offer_apl_asg;
21114     raise;
21115     --
21116     -- End of fix.
21117     --
21118 end offer_apl_asg;
21119 --
21120 
21121 -- ----------------------------------------------------------------------------
21122 -- |---------------------------< accept_apl_asg >------------------------------|
21123 -- ----------------------------------------------------------------------------
21124 --
21125 procedure accept_apl_asg
21126   (p_validate                     in     boolean
21127   ,p_effective_date               in     date
21128   ,p_datetrack_update_mode        in     varchar2
21129   ,p_assignment_id                in     number
21130   ,p_object_version_number        in out nocopy number
21131   ,p_assignment_status_type_id    in     number
21132   ,p_change_reason                in     varchar2
21133   ,p_effective_start_date            out nocopy date
21134   ,p_effective_end_date              out nocopy date
21135   ) is
21136   --
21137   -- Declare cursors and local variables
21138   --
21139   l_object_version_number_orig number;
21140   l_effective_date             date;
21141   --
21142   -- Out variables
21143   --
21144   l_object_version_number  per_all_assignments_f.object_version_number%TYPE;
21145   l_effective_start_date   per_all_assignments_f.effective_start_date%TYPE;
21146   l_effective_end_date     per_all_assignments_f.effective_end_date%TYPE;
21147   --
21148   lv_object_version_number     number := p_object_version_number ;
21149   --
21150 l_proc                 varchar2(72);
21151   --
21152 begin
21153  if g_debug then
21154  l_proc := g_package||'accept_apl_asg';
21155   hr_utility.set_location('Entering:'|| l_proc, 5);
21156  end if;
21157   --
21158   --
21159   l_effective_date := trunc(p_effective_date);
21160   --
21161     savepoint accept_apl_asg;
21162   --
21163   -- Preserve IN OUT parameters for later use
21164   --
21165   l_object_version_number_orig := p_object_version_number;
21166   l_object_version_number      := p_object_version_number;
21167   --
21168  if g_debug then
21169   hr_utility.set_location(l_proc, 10);
21170  end if;
21171   --
21172   -- Process Logic
21173   --
21174   -- Start of API User Hook for the before hook of accept_apl_asg.
21175   --
21176   begin
21177      hr_assignment_bkb.accept_apl_asg_b
21178        (p_effective_date               =>     l_effective_date
21179        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21180        ,p_assignment_id                =>     p_assignment_id
21181        ,p_object_version_number        =>     p_object_version_number
21182        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21183        ,p_change_reason                =>     p_change_reason
21184        );
21185   exception
21186      when hr_api.cannot_find_prog_unit then
21187        hr_api.cannot_find_prog_unit_error
21188          (p_module_name       => 'ACCEPT_APL_ASG',
21189           p_hook_type         => 'BP'
21190          );
21191   end;
21192   -- End of API User Hook for the before hook of accept_apl_asg.
21193 
21194   --
21195   hr_assignment_internal.update_status_type_apl_asg
21196       (p_effective_date            => l_effective_date
21197       ,p_datetrack_update_mode     => p_datetrack_update_mode
21198       ,p_assignment_id             => p_assignment_id
21199     ,p_object_version_number     => l_object_version_number
21200       ,p_expected_system_status    => 'ACCEPTED'
21201       ,p_assignment_status_type_id => p_assignment_status_type_id
21202       ,p_change_reason             => p_change_reason
21203       ,p_effective_start_date      => l_effective_start_date
21204       ,p_effective_end_date        => l_effective_end_date
21205       );
21206   --
21207  if g_debug then
21208   hr_utility.set_location(l_proc, 20);
21209  end if;
21210   --
21211   -- Start of API User Hook for the after hook of accept_apl_asg.
21212   --
21213   begin
21214      hr_assignment_bkb.accept_apl_asg_a
21215        (p_effective_date               =>     l_effective_date
21216        ,p_datetrack_update_mode        =>     p_datetrack_update_mode
21217        ,p_assignment_id                =>     p_assignment_id
21218        ,p_object_version_number        =>     l_object_version_number
21219        ,p_assignment_status_type_id    =>     p_assignment_status_type_id
21220        ,p_change_reason                =>     p_change_reason
21221        ,p_effective_start_date         =>     l_effective_start_date
21222        ,p_effective_end_date           =>     l_effective_end_date
21223        );
21224   exception
21225      when hr_api.cannot_find_prog_unit then
21226        hr_api.cannot_find_prog_unit_error
21227          (p_module_name       => 'OFFER_APL_ASG',
21228           p_hook_type         => 'AP'
21229          );
21230   end;
21231   --
21232   -- End of API User Hook for the after hook of accept_apl_asg.
21233   --
21234 
21235 --
21236   -- When in validation only mode raise the Validate_Enabled exception
21237   --
21238   if p_validate then
21239     raise hr_api.validate_enabled;
21240   end if;
21241   --
21242   -- Set remaining output arguments
21243   --
21244   p_object_version_number  := l_object_version_number;
21245   p_effective_start_date   := l_effective_start_date;
21246   p_effective_end_date     := l_effective_end_date;
21247  --
21248  if g_debug then
21249   hr_utility.set_location(' Leaving:'||l_proc, 50);
21250  end if;
21251 exception
21252   when hr_api.validate_enabled then
21253 -- As the Validate_Enabled exception has been raised
21254     -- we must rollback to the savepoint
21255     --
21256     ROLLBACK TO accept_apl_asg;
21257     --
21258     -- Only set output warning arguments
21259     -- (Any key or derived arguments must be set to null
21260     -- when validation only mode is being used.)
21261     --
21262     p_object_version_number  := l_object_version_number_orig;
21263     p_effective_start_date   := null;
21264     p_effective_end_date     := null;
21265 
21266   When others then
21267 
21268     p_object_version_number := lv_object_version_number;
21269     p_effective_start_date   := null;
21270     p_effective_end_date     := null;
21271 
21272       ROLLBACK TO accept_apl_asg;
21273        raise;
21274 end accept_apl_asg;
21275 --
21276 -- -----------------------------------------------------------------------------
21277 -- |--------------------------< activate_apl_asg >-----------------------------|
21278 -- -----------------------------------------------------------------------------
21279 --
21280 PROCEDURE activate_apl_asg
21281   (p_validate                     IN     BOOLEAN
21282   ,p_effective_date               IN     DATE
21283   ,p_datetrack_update_mode        IN     VARCHAR2
21284   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
21285   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
21286   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
21287   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
21288   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
21289   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
21290   )
21291 IS
21292   --
21293   -- Local variables
21294   --
21295   l_proc                         VARCHAR2(72);
21296   --
21297   l_effective_date               DATE;
21298   --
21299   l_object_version_number        CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
21300   --
21301   l_expected_system_status       per_assignment_status_types.per_system_status%TYPE    := 'ACTIVE_APL';
21302   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
21303   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
21304  --
21305  lv_object_version_number     number := p_object_version_number ;
21306  --
21307 --
21308 BEGIN
21309   --
21310  if g_debug then
21311   l_proc := g_package||'activate_apl_asg';
21312   hr_utility.set_location('Entering:'||l_proc,10);
21313  end if;
21314   --
21315   -- Truncate all date parameters passed in
21316   --
21317   l_effective_date := TRUNC(p_effective_date);
21318   --
21319   -- Issue savepoint
21320   --
21321   SAVEPOINT activate_apl_asg;
21322   --
21323  if g_debug then
21324   hr_utility.set_location(l_proc,20);
21325  end if;
21326   --
21327   -- Call Before Process User Hook
21328   --
21329   BEGIN
21330      hr_assignment_bkc.activate_apl_asg_b
21331        (p_effective_date               => l_effective_date
21332        ,p_datetrack_update_mode        => p_datetrack_update_mode
21333        ,p_assignment_id                => p_assignment_id
21334        ,p_object_version_number        => p_object_version_number
21335        ,p_assignment_status_type_id    => p_assignment_status_type_id
21336        ,p_change_reason                => p_change_reason
21337        );
21338   EXCEPTION
21339      WHEN hr_api.cannot_find_prog_unit
21340      THEN
21341        hr_api.cannot_find_prog_unit_error
21342          (p_module_name       => 'ACTIVATE_APL_ASG',
21343           p_hook_type         => 'BP'
21344          );
21345   END;
21346   --
21347  if g_debug then
21348   hr_utility.set_location(l_proc,30);
21349  end if;
21350   --
21351   -- Call business support process to update status type
21352   --
21353   hr_assignment_internal.update_status_type_apl_asg
21354     (p_effective_date               => l_effective_date
21355     ,p_datetrack_update_mode        => p_datetrack_update_mode
21356     ,p_assignment_id                => p_assignment_id
21357     ,p_object_version_number        => p_object_version_number
21358     ,p_expected_system_status       => l_expected_system_status
21359     ,p_assignment_status_type_id    => p_assignment_status_type_id
21360     ,p_change_reason                => p_change_reason
21361     ,p_effective_start_date         => l_effective_start_date
21362     ,p_effective_end_date           => l_effective_end_date
21363     );
21364   --
21365  if g_debug then
21366   hr_utility.set_location(l_proc,40);
21367  end if;
21368   --
21369   -- Call After Process User Hook
21370   --
21371   BEGIN
21372      hr_assignment_bkc.activate_apl_asg_a
21373        (p_effective_date               => l_effective_date
21374        ,p_datetrack_update_mode        => p_datetrack_update_mode
21375        ,p_assignment_id                => p_assignment_id
21376        ,p_object_version_number        => p_object_version_number
21377        ,p_assignment_status_type_id    => p_assignment_status_type_id
21378        ,p_change_reason                => p_change_reason
21379        ,p_effective_start_date         => l_effective_start_date
21380        ,p_effective_end_date           => l_effective_end_date
21381        );
21382   EXCEPTION
21383      WHEN hr_api.cannot_find_prog_unit
21384      THEN
21385        hr_api.cannot_find_prog_unit_error
21386          (p_module_name => 'ACTIVATE_APL_ASG',
21387           p_hook_type   => 'AP'
21388          );
21389   END;
21390   --
21391  if g_debug then
21392   hr_utility.set_location(l_proc,50);
21393  end if;
21394   --
21395   -- When in validation only mode raise validate_enabled exception
21396   --
21397   IF p_validate
21398   THEN
21399     RAISE hr_api.validate_enabled;
21400   END IF;
21401   --
21402   -- Set OUT parameters
21403   --
21404   p_effective_start_date         := l_effective_start_date;
21405   p_effective_end_date           := l_effective_end_date;
21406   --
21407  if g_debug then
21408   hr_utility.set_location(' Leaving:'||l_proc,100);
21409  end if;
21410 --
21411 EXCEPTION
21412   WHEN hr_api.validate_enabled
21413   THEN
21414     --
21415     -- In validation only mode
21416     -- Rollback to savepoint
21417     -- Set relevant output warning arguments
21418     -- Reset any key or derived arguments
21419     --
21420     ROLLBACK TO activate_apl_asg;
21421     p_object_version_number        := l_object_version_number;
21422     p_effective_start_date         := NULL;
21423     p_effective_end_date           := NULL;
21424   --
21425   WHEN OTHERS
21426   THEN
21427     --
21428     -- Validation or unexpected error occured
21429     -- Rollback to savepoint
21430     -- Re-raise exception
21431     --
21432     p_object_version_number := lv_object_version_number;
21433     p_effective_start_date   := null;
21434     p_effective_end_date     := null;
21435 
21436     ROLLBACK TO activate_apl_asg;
21437     RAISE;
21438 --
21439 END activate_apl_asg;
21440 --
21441 -- -----------------------------------------------------------------------------
21442 -- |-------------------------< terminate_apl_asg >-----------------------------|
21443 -- -----------------------------------------------------------------------------
21444 --
21445 PROCEDURE terminate_apl_asg
21446   (p_validate                     IN     BOOLEAN
21447   ,p_effective_date               IN     DATE
21448   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
21449   ,p_assignment_status_type_id    IN  per_all_assignments_f.assignment_status_type_id%TYPE
21450   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
21451   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
21452   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
21453   )
21454 IS
21455 BEGIN
21456    hr_assignment_api.terminate_apl_asg
21457   (p_validate                   => p_validate
21458   ,p_effective_date             => p_effective_date
21459   ,p_assignment_id              => p_assignment_id
21460   ,p_assignment_status_type_id  => p_assignment_status_type_id
21461   ,p_object_version_number      => p_object_version_number
21462   ,p_effective_start_date       => p_effective_start_date
21463   ,p_effective_end_date         => p_effective_end_date
21464   ,p_change_reason              => NULL -- 4066579
21465   );
21466 END;
21467 --
21468 -- -----------------------------------------------------------------------------
21469 -- |-----------------------< terminate_apl_asg(NEW) >---------------------------|
21470 -- -----------------------------------------------------------------------------
21471 --
21472 PROCEDURE terminate_apl_asg
21473   (p_validate                     IN     BOOLEAN
21474   ,p_effective_date               IN     DATE
21475   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
21476   ,p_assignment_status_type_id    IN  per_all_assignments_f.assignment_status_type_id%TYPE
21477   ,p_change_reason                IN  per_all_assignments_f.change_reason%TYPE -- 4066579
21478   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
21479   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
21480   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
21481   )
21482 IS
21483   --
21484   -- Local variables
21485   --
21486   l_proc                         VARCHAR2(72) := g_package||'terminate_apl_asg';
21487   --
21488   l_effective_date               DATE;
21489   --
21490   l_object_version_number        CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
21491   --
21492   l_effective_start_date         per_all_assignments_f.effective_start_date%TYPE;
21493   l_effective_end_date           per_all_assignments_f.effective_end_date%TYPE;
21494   --
21495   l_assignment_status_type_id    per_all_assignments_f.assignment_status_type_id%TYPE;
21496   l_business_group_id            hr_all_organization_units.organization_id%TYPE;
21497   l_validation_start_date        DATE;
21498   l_validation_end_date          DATE;
21499   l_org_now_no_manager_warning   BOOLEAN;
21500   --
21501   lv_object_version_number     number;
21502   --
21503   l_assignment_status_id  irc_assignment_statuses.assignment_status_id%type;
21504   l_asg_status_ovn        irc_assignment_statuses.object_version_number%type;
21505   -- 3652025 >>
21506   l_new_application_id          per_applications.application_id%TYPE;
21507   l_fut_asg_start_date          date;
21508   l_fut_asg_end_date            date;
21509   l_comment_id                  number;
21510   l_payroll_id_updated          boolean;
21511   l_other_manager_warning       boolean;
21512   l_no_managers_warning         boolean;
21513   l_asg_ovn                     number;
21514   l_asg_eff_date                date;
21515   l_hourly_salaried_warning     boolean;
21516   -- <<
21517   -- Local cursors
21518   --
21519   CURSOR csr_assignments
21520     (p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
21521     ,p_effective_date               IN     DATE
21522     )
21523   IS
21524     SELECT asg.assignment_type
21525           ,asg.business_group_id
21526           ,bus.legislation_code
21527           ,person_id ,effective_end_date, application_id
21528 	  ,asg.assignment_status_type_id --7229710
21529       FROM per_all_assignments_f asg
21530           ,per_business_groups_perf bus
21531      WHERE asg.assignment_id = p_assignment_id
21532        AND bus.business_group_id = asg.business_group_id
21533        AND p_effective_date BETWEEN asg.effective_start_date
21534                                 AND asg.effective_end_date;
21535   -- 3652025 >>
21536   CURSOR csr_get_current_apl_asg(cp_asg_id number, cp_effective_date date) IS
21537     SELECT as2.assignment_id, as2.effective_start_date
21538           ,as2.effective_end_date
21539     FROM per_all_assignments_f as2
21540         ,per_all_assignments_f as1
21541     WHERE as2.person_id = as1.person_id
21542     AND as2.assignment_type = as1.assignment_type
21543     AND cp_effective_date BETWEEN as2.effective_start_date
21544                              AND as2.effective_end_date
21545     AND as2.assignment_id <> as1.assignment_id
21546     AND as1.assignment_id = cp_asg_id;
21547   --
21548   CURSOR csr_get_future_apl_asg(cp_asg_id number, cp_effective_date date) IS
21549     SELECT as2.assignment_id, as2.business_group_id
21550          , as2.effective_start_date, as2.effective_end_date
21551          , as2.application_id, as2.person_id, as2.object_version_number
21552     FROM per_all_assignments_f as2
21553         ,per_all_assignments_f as1
21554     WHERE as2.person_id = as1.person_id
21555     AND as2.assignment_type = as1.assignment_type
21556     AND as2.effective_start_date > cp_effective_date
21557     AND as2.assignment_id <> as1.assignment_id
21558     AND as1.assignment_id = cp_asg_id
21559     ORDER BY as2.effective_start_date, as2.assignment_id ASC;
21560   --
21561   CURSOR csr_appl_details(cp_application_id number) IS
21562      select *
21563        from per_applications
21564       where application_id = cp_application_id;
21565 
21566   --  <<
21567   l_assignment            csr_assignments%ROWTYPE;
21568   l_fut_asg               csr_get_future_apl_asg%ROWTYPE;  -- 3652025 >>
21569   l_cur_asg               csr_get_current_apl_asg%ROWTYPE;
21570   l_appl_details          csr_appl_details%ROWTYPE;
21571   l_apl_object_version_number number;
21572   l_per_effective_start_date  date;
21573   l_per_effective_end_date    date; -- <<
21574   l_mx_end_dated              date;
21575   l_min_no_end_dated          date;
21576   --
21577   -- ----------------------------------------------------------------------- +
21578   -- ----------------------------------------------------------------------- +
21579   procedure end_assignment is
21580    --fix for bug 7229710 Start here.
21581    l_vacancy_id                   number;
21582    l_person_id number;
21583 
21584     Cursor csr_vacancy_id(l_assg_id number) is
21585 Select vacancy_id
21586 From per_all_assignments_f
21587 Where assignment_id = l_assg_id
21588 And p_effective_date between effective_start_date and effective_end_date;
21589 
21590 cursor csr_person_id(l_assg_id number) is
21591 select person_id
21592 from per_all_assignments_f
21593 where assignment_id=l_assg_id;
21594   --fix for bug 7229710 Ends here.
21595 
21596   begin
21597   per_asg_del.del
21598     (p_assignment_id                => p_assignment_id
21599     ,p_object_version_number        => p_object_version_number
21600     ,p_effective_date               => l_effective_date
21601     ,p_datetrack_mode               => hr_api.g_delete
21602     ,p_effective_start_date         => l_effective_start_date
21603     ,p_effective_end_date           => l_effective_end_date
21604     ,p_business_group_id            => l_business_group_id
21605     ,p_validation_start_date        => l_validation_start_date
21606     ,p_validation_end_date          => l_validation_end_date
21607     ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
21608     );
21609     --
21610     if g_debug then
21611     hr_utility.set_location(l_proc,70);
21612     end if;
21613     --
21614     per_asg_bus1.chk_assignment_status_type
21615       (p_assignment_status_type_id => l_assignment_status_type_id
21616       ,p_business_group_id         => l_assignment.business_group_id
21617       ,p_legislation_code          => l_assignment.legislation_code
21618       ,p_expected_system_status    => 'TERM_APL'
21619       );
21620     --fix for bug 7229710 Start here.
21621     delete from per_letter_request_lines plrl
21622     where plrl.assignment_id = p_assignment_id
21623     and   plrl.assignment_status_type_id = l_assignment.assignment_status_type_id
21624     and   exists
21625          (select null
21626           from per_letter_requests plr
21627           where plr.letter_request_id = plrl.letter_request_id
21628           and   plr.request_status = 'PENDING'
21629           and   plr.auto_or_manual = 'AUTO');
21630 
21631   per_app_asg_pkg.cleanup_letters
21632     (p_assignment_id => p_assignment_id);
21633   --
21634   -- Check if a letter request is necessary for the assignment.
21635   --
21636 open csr_vacancy_id(p_assignment_id);
21637 fetch csr_vacancy_id into l_vacancy_id;
21638 if csr_vacancy_id%NOTFOUND then null;
21639 end if;
21640 close csr_vacancy_id;
21641 
21642 open csr_person_id(p_assignment_id);
21643 fetch csr_person_id into l_person_id;
21644 if csr_person_id%NOTFOUND then null;
21645 end if;
21646 close csr_person_id;
21647 
21648 
21649   per_applicant_pkg.check_for_letter_requests
21650     (p_business_group_id            => l_assignment.business_group_id
21651     ,p_per_system_status            => null
21652     ,p_assignment_status_type_id    => l_assignment_status_type_id
21653     ,p_person_id                    => l_person_id
21654     ,p_assignment_id                => p_assignment_id
21655     ,p_effective_start_date         => l_effective_start_date
21656     ,p_validation_start_date        => l_validation_start_date
21657     ,p_vacancy_id 		    => l_vacancy_id
21658     );
21659  --fix for bug 7229710 Ends here.
21660 
21661     IRC_ASG_STATUS_API.create_irc_asg_status
21662          (p_assignment_id               => p_assignment_id
21663          , p_assignment_status_type_id  => l_assignment_status_type_id
21664          , p_status_change_date         => p_effective_date
21665          , p_assignment_status_id       => l_assignment_status_id
21666          , p_status_change_reason       => p_change_reason -- 4066579
21667          , p_object_version_number      => l_asg_status_ovn);
21668 
21669     --
21670     -- Close the offers (if any) for this applicant
21671     --
21672    IRC_OFFERS_API.close_offer
21673        ( p_validate                   => p_validate
21674         ,p_effective_date             => p_effective_date
21675         ,p_applicant_assignment_id    => p_assignment_id
21676         ,p_change_reason              => 'WITHDRAWAL'
21677        );
21678 
21679   end end_assignment;
21680   --
21681 BEGIN
21682   --
21683  if g_debug then
21684   hr_utility.set_location('Entering:'||l_proc,10);
21685  end if;
21686   --
21687   -- Ensure mandatory arguments have been passed
21688   --
21689   hr_api.mandatory_arg_error
21690     (p_api_name                     => l_proc
21691     ,p_argument                     => 'assignment_id'
21692     ,p_argument_value               => p_assignment_id
21693     );
21694   --
21695   hr_api.mandatory_arg_error
21696     (p_api_name                     => l_proc
21697     ,p_argument                     => 'effective_date'
21698     ,p_argument_value               => p_effective_date
21699     );
21700   --
21701   -- Truncate all date parameters passed in
21702   --
21703   l_effective_date := TRUNC(p_effective_date);
21704   l_assignment_status_type_id  := p_assignment_status_type_id;
21705   lv_object_version_number     := p_object_version_number ;
21706   --
21707   -- Issue savepoint
21708   --
21709   SAVEPOINT terminate_apl_asg;
21710   --
21711  if g_debug then
21712   hr_utility.set_location(l_proc,20);
21713  end if;
21714   --
21715   -- Call Before Process User Hook
21716   --
21717   BEGIN
21718     hr_assignment_bkd.terminate_apl_asg_b
21719       (p_effective_date               => l_effective_date
21720       ,p_assignment_id                => p_assignment_id
21721       ,p_object_version_number        => p_object_version_number
21722       );
21723   EXCEPTION
21724     WHEN hr_api.cannot_find_prog_unit
21725     THEN
21726        hr_api.cannot_find_prog_unit_error
21727          (p_module_name       => 'TERMINATE_APL_ASG'
21728          ,p_hook_type         => 'B'
21729          );
21730   END;
21731   --
21732  if g_debug then
21733   hr_utility.set_location(l_proc,30);
21734  end if;
21735   --
21736   -- Retrieve derived assignment details
21737   --
21738   OPEN csr_assignments
21739     (p_assignment_id                => p_assignment_id
21740     ,p_effective_date               => l_effective_date
21741     );
21742   FETCH csr_assignments INTO l_assignment;
21743   IF csr_assignments%NOTFOUND
21744   THEN
21745     CLOSE csr_assignments;
21746     hr_utility.set_message(801,'HR_52360_ASG_DOES_NOT_EXIST');
21747     hr_utility.raise_error;
21748   END IF;
21749   CLOSE csr_assignments;
21750   --
21751  if g_debug then
21752   hr_utility.set_location(l_proc,40);
21753  end if;
21754   --
21755   -- Ensure this is an applicant assignment
21756   --
21757   IF l_assignment.assignment_type <> 'A'
21758   THEN
21759     hr_utility.set_message(801,'HR_51036_ASG_ASG_NOT_APL');
21760     hr_utility.raise_error;
21761   END IF;
21762   --
21763  if g_debug then
21764   hr_utility.set_location(l_proc,50);
21765  end if;
21766   --
21767   -- 3652025 >> Ensure this is not the last applicant assignment
21768   --
21769   --IF last_apl_asg
21770   --  (p_assignment_id                => p_assignment_id
21771   --  ,p_effective_date               => l_effective_date + 1
21772   --  )
21773   --THEN
21774     --
21775   --  hr_utility.set_message(800,'HR_7987_PER_INV_TYPE_CHANGE');
21776   --  hr_utility.raise_error;
21777   --
21778   --END IF; <<
21779   --
21780   open csr_get_current_apl_asg(p_assignment_id, l_effective_date+1);
21781   fetch csr_get_current_apl_asg into l_cur_asg;
21782   if csr_get_current_apl_asg%NOTFOUND then -- no current
21783     if g_debug then
21784         hr_utility.set_location(l_proc,60);
21785     end if;
21786     --
21787     close csr_get_current_apl_asg;
21788     open csr_get_future_apl_asg(p_assignment_id, l_effective_date);
21789     fetch csr_get_future_apl_asg into l_fut_asg;
21790     if csr_get_future_apl_asg%NOTFOUND then -- no current, no future
21791         close csr_get_future_apl_asg;
21792         hr_utility.set_message(800,'HR_7987_PER_INV_TYPE_CHANGE');
21793         hr_utility.raise_error;
21794     else                                    -- no current, yes future
21795         if g_debug then
21796             hr_utility.set_location(l_proc,62);
21797         end if;
21798         hr_utility.trace('  ex_apl date  = '||to_char(l_effective_date+1));
21799         hr_utility.trace('  apl date = '||to_char(l_fut_asg.effective_start_date));
21800         -- End assignment
21801         end_assignment;
21802         -- update the person and PTU records
21803         hr_applicant_internal.upd_person_ex_apl_and_apl(
21804               p_business_group_id           => l_fut_asg.business_group_id
21805              ,p_person_id                   => l_fut_asg.person_id
21806              ,p_ex_apl_effective_date       => l_effective_date+1
21807              ,p_apl_effective_date          => l_fut_asg.effective_start_date
21808              ,p_per_effective_start_date    => l_per_effective_start_date
21809              ,p_per_effective_end_date      => l_per_effective_end_date);
21810         --
21811         -- terminate current application
21812         --
21813         hr_utility.trace('   terminate current application on '||to_char(l_effective_date));
21814         --
21815         UPDATE per_applications
21816            SET date_end = l_effective_date
21817           where application_id = l_fut_asg.application_id;
21818         --
21819         open csr_appl_details(l_fut_asg.application_id);
21820         fetch csr_appl_details into l_appl_details;
21821         close csr_appl_details;
21822         -- create new application for future assignments
21823         per_apl_ins.ins
21824               (p_application_id            => l_new_application_id
21825               ,p_business_group_id         => l_fut_asg.business_group_id
21826               ,p_person_id                 => l_fut_asg.person_id
21827               ,p_date_received             => l_fut_asg.effective_start_date
21828               ,p_object_version_number     => l_apl_object_version_number
21829               ,p_effective_date            => l_fut_asg.effective_start_date
21830               ,p_comments                => l_appl_details.comments
21831               ,p_current_employer        => l_appl_details.current_employer
21832               ,p_projected_hire_date     => l_appl_details.projected_hire_date
21833               ,p_successful_flag         => l_appl_details.successful_flag
21834               ,p_termination_reason      => l_appl_details.termination_reason
21835               ,p_request_id              => l_appl_details.request_id
21836               ,p_program_application_id  => l_appl_details.program_application_id
21837               ,p_program_id              => l_appl_details.program_id
21838               ,p_program_update_date     => l_appl_details.program_update_date
21839               ,p_appl_attribute_category => l_appl_details.appl_attribute_category
21840               ,p_appl_attribute1         => l_appl_details.appl_attribute1
21841               ,p_appl_attribute2         => l_appl_details.appl_attribute2
21842               ,p_appl_attribute3         => l_appl_details.appl_attribute3
21843               ,p_appl_attribute4         => l_appl_details.appl_attribute4
21844               ,p_appl_attribute5         => l_appl_details.appl_attribute5
21845               ,p_appl_attribute6         => l_appl_details.appl_attribute6
21846               ,p_appl_attribute7         => l_appl_details.appl_attribute7
21847               ,p_appl_attribute8         => l_appl_details.appl_attribute8
21848               ,p_appl_attribute9         => l_appl_details.appl_attribute9
21849               ,p_appl_attribute10        => l_appl_details.appl_attribute10
21850               ,p_appl_attribute11        => l_appl_details.appl_attribute11
21851               ,p_appl_attribute12        => l_appl_details.appl_attribute12
21852               ,p_appl_attribute13        => l_appl_details.appl_attribute13
21853               ,p_appl_attribute14        => l_appl_details.appl_attribute14
21854               ,p_appl_attribute15        => l_appl_details.appl_attribute15
21855               ,p_appl_attribute16        => l_appl_details.appl_attribute16
21856               ,p_appl_attribute17        => l_appl_details.appl_attribute17
21857               ,p_appl_attribute18        => l_appl_details.appl_attribute18
21858               ,p_appl_attribute19        => l_appl_details.appl_attribute19
21859               ,p_appl_attribute20        => l_appl_details.appl_attribute20
21860               );
21861         hr_utility.trace('   new application ID = '||to_char(l_new_application_id));
21862 
21863         -- update future assignments with new application ID
21864         hr_utility.trace('   update all future assignments');
21865         -- update first assignment found
21866         l_asg_ovn := l_fut_asg.object_version_number;
21867         l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
21868         --
21869         hr_utility.trace('    => asg id = '||l_fut_asg.assignment_id);
21870         hr_utility.trace('    =>     SD = '||to_char(l_fut_asg.effective_start_date));
21871         hr_utility.trace('    =>     ED = '||to_char(l_fut_asg.effective_end_date));
21872         per_asg_upd.upd
21873             (p_assignment_id                => l_fut_asg.assignment_id
21874             ,p_effective_start_date         => l_fut_asg.effective_start_date
21875             ,p_effective_end_date           => l_fut_asg.effective_end_date
21876             ,p_business_group_id            => l_fut_asg.business_group_id
21877             ,p_comment_id                   => l_comment_id
21878             ,p_application_id               => l_new_application_id  -- override exsiting appl id
21879             ,p_payroll_id_updated           => l_payroll_id_updated
21880             ,p_other_manager_warning        => l_other_manager_warning
21881             ,p_no_managers_warning          => l_no_managers_warning
21882             ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
21883             ,p_validation_start_date        => l_validation_start_date
21884             ,p_validation_end_date          => l_validation_end_date
21885             ,p_object_version_number        => l_asg_ovn
21886             ,p_effective_date               => l_asg_eff_date
21887             ,p_datetrack_mode               => hr_api.g_correction
21888             ,p_validate                     => FALSE
21889             ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
21890         -- update all other future assignments
21891         hr_utility.trace('  update all other assignments');
21892         LOOP
21893           fetch csr_get_future_apl_asg into l_fut_asg;
21894           exit when csr_get_future_apl_asg%NOTFOUND;
21895              l_asg_ovn := l_fut_asg.object_version_number;
21896              l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
21897              per_asg_upd.upd
21898                 (p_assignment_id                => l_fut_asg.assignment_id
21899                 ,p_effective_start_date         => l_fut_asg.effective_start_date
21900                 ,p_effective_end_date           => l_fut_asg.effective_end_date
21901                 ,p_business_group_id            => l_fut_asg.business_group_id
21902                 ,p_comment_id                   => l_comment_id
21903                 ,p_application_id               => l_new_application_id
21904                 ,p_payroll_id_updated           => l_payroll_id_updated
21905                 ,p_other_manager_warning        => l_other_manager_warning
21906                 ,p_no_managers_warning          => l_no_managers_warning
21907                 ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
21908                 ,p_validation_start_date        => l_validation_start_date
21909                 ,p_validation_end_date          => l_validation_end_date
21910                 ,p_object_version_number        => l_asg_ovn
21911                 ,p_effective_date               => l_asg_eff_date
21912                 ,p_datetrack_mode               => hr_api.g_correction
21913                 ,p_validate                     => FALSE
21914                 ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
21915         END LOOP;
21916         --
21917         close csr_get_future_apl_asg;
21918         if g_debug then
21919             hr_utility.set_location(l_proc,68);
21920         end if;
21921 
21922 
21923     end if;
21924   else -- yes current
21925     close csr_get_current_apl_asg;
21926     if l_cur_asg.effective_end_date < hr_general.end_of_time then
21927       --
21928       -- current assignment is end dated
21929       --
21930       if g_debug then
21931           hr_utility.set_location(l_proc,100);
21932       end if;
21933       select max(effective_end_date) into l_mx_end_dated
21934         from per_assignments_f
21935        where person_id = l_assignment.person_id
21936          and assignment_type = 'A'
21937          and effective_end_date < hr_general.end_of_time
21938          and assignment_id <> p_assignment_id;
21939       --
21940       select min(effective_start_date) into l_min_no_end_dated
21941         from per_assignments_f
21942        where person_id = l_assignment.person_id
21943          and assignment_type = 'A'
21944          and effective_end_date = hr_general.end_of_time
21945          and assignment_id <> p_assignment_id;
21946       --
21947       if l_mx_end_dated is not null then -- if A
21948         --
21949         if l_min_no_end_dated is not null then -- if B
21950           --
21951           if l_mx_end_dated + 1 = l_min_no_end_dated then -- if C
21952             --
21953             -- end assignment as normal
21954             if g_debug then
21955                 hr_utility.set_location(l_proc,110);
21956             end if;
21957             end_assignment;
21958             --
21959           else -- else C
21960             if l_min_no_end_dated <= l_mx_end_dated then -- if D
21961               --
21962               end_assignment; -- terminate assignment as normal.
21963             else -- else D
21964               -- this means person becomes ex-apl after "max end date"
21965               -- 1. End assignment as normal
21966               -- 2. Transform person onto EX-APL after "max end date" and before "min sd"
21967               -- 3. Create new application and update all future applicant assignments
21968               --    on "min sd"
21969               if g_debug then
21970                   hr_utility.set_location(l_proc,120);
21971               end if;
21972               -- End assignment
21973               end_assignment;
21974               -- update the person and PTU records
21975               hr_applicant_internal.upd_person_ex_apl_and_apl(
21976                     p_business_group_id           => l_assignment.business_group_id
21977                    ,p_person_id                   => l_assignment.person_id
21978                    ,p_ex_apl_effective_date       => l_mx_end_dated+1
21979                    ,p_apl_effective_date          => l_min_no_end_dated
21980                    ,p_per_effective_start_date    => l_per_effective_start_date
21981                    ,p_per_effective_end_date      => l_per_effective_end_date);
21982               --
21983               -- terminate current application
21984               --
21985               hr_utility.trace('   terminate current application on '||to_char(l_mx_end_dated));
21986               --
21987               UPDATE per_applications
21988                  SET date_end = l_mx_end_dated
21989                 where application_id = l_assignment.application_id;
21990               --
21991               open csr_appl_details(l_assignment.application_id);
21992               fetch csr_appl_details into l_appl_details;
21993               close csr_appl_details;
21994               -- create new application for future assignments
21995               per_apl_ins.ins
21996                     (p_application_id            => l_new_application_id
21997                     ,p_business_group_id         => l_assignment.business_group_id
21998                     ,p_person_id                 => l_assignment.person_id
21999                     ,p_date_received             => l_min_no_end_dated
22000                     ,p_object_version_number     => l_apl_object_version_number
22001                     ,p_effective_date            => l_min_no_end_dated
22002                     ,p_comments                => l_appl_details.comments
22003                     ,p_current_employer        => l_appl_details.current_employer
22004                     ,p_projected_hire_date     => l_appl_details.projected_hire_date
22005                     ,p_successful_flag         => l_appl_details.successful_flag
22006                     ,p_termination_reason      => l_appl_details.termination_reason
22007                     ,p_request_id              => l_appl_details.request_id
22008                     ,p_program_application_id  => l_appl_details.program_application_id
22009                     ,p_program_id              => l_appl_details.program_id
22010                     ,p_program_update_date     => l_appl_details.program_update_date
22011                     ,p_appl_attribute_category => l_appl_details.appl_attribute_category
22012                     ,p_appl_attribute1         => l_appl_details.appl_attribute1
22013                     ,p_appl_attribute2         => l_appl_details.appl_attribute2
22014                     ,p_appl_attribute3         => l_appl_details.appl_attribute3
22015                     ,p_appl_attribute4         => l_appl_details.appl_attribute4
22016                     ,p_appl_attribute5         => l_appl_details.appl_attribute5
22017                     ,p_appl_attribute6         => l_appl_details.appl_attribute6
22018                     ,p_appl_attribute7         => l_appl_details.appl_attribute7
22019                     ,p_appl_attribute8         => l_appl_details.appl_attribute8
22020                     ,p_appl_attribute9         => l_appl_details.appl_attribute9
22021                     ,p_appl_attribute10        => l_appl_details.appl_attribute10
22022                     ,p_appl_attribute11        => l_appl_details.appl_attribute11
22023                     ,p_appl_attribute12        => l_appl_details.appl_attribute12
22024                     ,p_appl_attribute13        => l_appl_details.appl_attribute13
22025                     ,p_appl_attribute14        => l_appl_details.appl_attribute14
22026                     ,p_appl_attribute15        => l_appl_details.appl_attribute15
22027                     ,p_appl_attribute16        => l_appl_details.appl_attribute16
22028                     ,p_appl_attribute17        => l_appl_details.appl_attribute17
22029                     ,p_appl_attribute18        => l_appl_details.appl_attribute18
22030                     ,p_appl_attribute19        => l_appl_details.appl_attribute19
22031                     ,p_appl_attribute20        => l_appl_details.appl_attribute20
22032                     );
22033               hr_utility.trace('   new application ID = '||to_char(l_new_application_id));
22034 
22035               -- update future assignments with new application ID
22036               hr_utility.trace('   update all future assignments');
22037               -- update first assignment found
22038               open csr_get_future_apl_asg(p_assignment_id, l_mx_end_dated+1);
22039               fetch csr_get_future_apl_asg into l_fut_asg;
22040               l_asg_ovn := l_fut_asg.object_version_number;
22041               l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
22042               --
22043               hr_utility.trace('    => asg id = '||l_fut_asg.assignment_id);
22044               hr_utility.trace('    =>     SD = '||to_char(l_fut_asg.effective_start_date));
22045               hr_utility.trace('    =>     ED = '||to_char(l_fut_asg.effective_end_date));
22046               per_asg_upd.upd
22047                   (p_assignment_id                => l_fut_asg.assignment_id
22048                   ,p_effective_start_date         => l_fut_asg.effective_start_date
22049                   ,p_effective_end_date           => l_fut_asg.effective_end_date
22050                   ,p_business_group_id            => l_fut_asg.business_group_id
22051                   ,p_comment_id                   => l_comment_id
22052                   ,p_application_id               => l_new_application_id  -- override exsiting appl id
22053                   ,p_payroll_id_updated           => l_payroll_id_updated
22054                   ,p_other_manager_warning        => l_other_manager_warning
22055                   ,p_no_managers_warning          => l_no_managers_warning
22056                   ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
22057                   ,p_validation_start_date        => l_validation_start_date
22058                   ,p_validation_end_date          => l_validation_end_date
22059                   ,p_object_version_number        => l_asg_ovn
22060                   ,p_effective_date               => l_asg_eff_date
22061                   ,p_datetrack_mode               => hr_api.g_correction
22062                   ,p_validate                     => FALSE
22063                   ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
22064               -- update all other future assignments
22065               hr_utility.trace('  update all other assignments');
22066               LOOP
22067                 fetch csr_get_future_apl_asg into l_fut_asg;
22068                 exit when csr_get_future_apl_asg%NOTFOUND;
22069                    l_asg_ovn := l_fut_asg.object_version_number;
22070                    l_asg_eff_date := trunc(l_fut_asg.effective_start_date);
22071                    per_asg_upd.upd
22072                       (p_assignment_id                => l_fut_asg.assignment_id
22073                       ,p_effective_start_date         => l_fut_asg.effective_start_date
22074                       ,p_effective_end_date           => l_fut_asg.effective_end_date
22075                       ,p_business_group_id            => l_fut_asg.business_group_id
22076                       ,p_comment_id                   => l_comment_id
22077                       ,p_application_id               => l_new_application_id
22078                       ,p_payroll_id_updated           => l_payroll_id_updated
22079                       ,p_other_manager_warning        => l_other_manager_warning
22080                       ,p_no_managers_warning          => l_no_managers_warning
22081                       ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
22082                       ,p_validation_start_date        => l_validation_start_date
22083                       ,p_validation_end_date          => l_validation_end_date
22084                       ,p_object_version_number        => l_asg_ovn
22085                       ,p_effective_date               => l_asg_eff_date
22086                       ,p_datetrack_mode               => hr_api.g_correction
22087                       ,p_validate                     => FALSE
22088                       ,p_hourly_salaried_warning      => l_hourly_salaried_warning);
22089               END LOOP;
22090               --
22091               close csr_get_future_apl_asg;
22092               if g_debug then
22093                   hr_utility.set_location(l_proc,150);
22094               end if;
22095               --
22096             end if; -- end if D
22097           end if; -- end if C
22098           --
22099         else-- else B
22100           -- assignment being terminated is the only one available
22101           -- 1. End assignment as normal
22102           -- 2. Transform person onto EX-APL on "max end date" + 1
22103           if g_debug then
22104               hr_utility.set_location(l_proc,160);
22105           end if;
22106           null; -- not implemented.
22107         end if; -- end if B
22108         --
22109       else -- else A
22110         --
22111         if g_debug then
22112             hr_utility.set_location(l_proc,170);
22113         end if;
22114 
22115       end if; -- end if A
22116     else
22117        if g_debug then
22118            hr_utility.set_location(l_proc,180);
22119        end if;
22120        -- terminate assignment as normal
22121        end_assignment;
22122     end if;
22123 
22124   end if; -- end "yes current"
22125   --
22126   if g_debug then
22127     hr_utility.set_location(l_proc,200);
22128   end if;
22129   --
22130   -- Call After Process User Hook
22131   --
22132   BEGIN
22133     hr_assignment_bkd.terminate_apl_asg_a
22134       (p_effective_date               => l_effective_date
22135       ,p_assignment_id                => p_assignment_id
22136       ,p_object_version_number        => p_object_version_number
22137       ,p_effective_start_date         => l_effective_start_date
22138       ,p_effective_end_date           => l_effective_end_date
22139       );
22140   EXCEPTION
22141     WHEN hr_api.cannot_find_prog_unit
22142     THEN
22143        hr_api.cannot_find_prog_unit_error
22144          (p_module_name       => 'TERMINATE_APL_ASG'
22145          ,p_hook_type         => 'A'
22146          );
22147   END;
22148   --
22149  if g_debug then
22150   hr_utility.set_location(l_proc,300);
22151  end if;
22152   --
22153   -- When in validation only mode raise validate enabled exception
22154   --
22155   IF p_validate
22156   THEN
22157     RAISE hr_api.validate_enabled;
22158   END IF;
22159   --
22160   -- Set OUT parameters
22161   --
22162   p_effective_start_date         := l_effective_start_date;
22163   p_effective_end_date           := l_effective_end_date;
22164   --
22165  if g_debug then
22166   hr_utility.set_location(' Leaving:'||l_proc,1000);
22167  end if;
22168 --
22169 EXCEPTION
22170   WHEN hr_api.validate_enabled
22171   THEN
22172     --
22173     -- In validation only mode
22174     -- Rollback to savepoint
22175     -- Set relevant output warning arguments
22176     -- Reset any key or derived arguments
22177     --
22178     ROLLBACK TO terminate_apl_asg;
22179     p_object_version_number        := l_object_version_number;
22180     p_effective_start_date         := NULL;
22181     p_effective_end_date           := NULL;
22182   --
22183   WHEN OTHERS
22184   THEN
22185     --
22186     -- Validation or unexpected error occured
22187     -- Rollback to savepoint
22188     -- Re-raise exception
22189     p_object_version_number := lv_object_version_number;
22190     p_effective_start_date   := null;
22191     p_effective_end_date     := null;
22192     --
22193     ROLLBACK TO terminate_apl_asg;
22194     RAISE;
22195 --
22196 END terminate_apl_asg;
22197 --
22198 --
22199 PROCEDURE set_new_primary_asg
22200   (p_validate                    IN     BOOLEAN
22201   ,p_effective_date              IN     DATE
22202   ,p_person_id                   IN     per_all_people_f.person_id%TYPE
22203   ,p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
22204   ,p_object_version_number       IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22205   ,p_effective_start_date           OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22206   ,p_effective_end_date             OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22207   )
22208 IS
22209   --
22210   -- Local Variables
22211   --
22212   l_proc                        VARCHAR2(72) := g_package||'set_new_primary_asg';
22213   --
22214   l_effective_date              DATE;
22215   l_object_version_number       CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
22216   l_effective_start_date        per_all_assignments_f.effective_start_date%TYPE;
22217   l_effective_end_date          per_all_assignments_f.effective_end_date%TYPE;
22218   --
22219   lv_object_version_number     number := p_object_version_number ;
22220   --
22221   -- Local cursors
22222   --
22223   CURSOR csr_new_assignment
22224     (p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
22225     ,p_effective_date              IN     DATE
22226     )
22227   IS
22228     SELECT asg.object_version_number
22229           ,asg.assignment_type
22230           ,asg.period_of_service_id
22231           ,asg.person_id
22232           ,asg.primary_flag
22233           ,asg.effective_start_date
22234           ,asg.effective_end_date
22235           ,MAX(mxa.effective_end_date) AS max_effective_end_date
22236           ,pds.actual_termination_date
22237       FROM per_all_assignments_f asg
22238           ,per_all_assignments_f mxa
22239           ,per_periods_of_service pds
22240      WHERE pds.period_of_service_id(+) = asg.period_of_service_id
22241        AND mxa.assignment_id = asg.assignment_id
22242        AND asg.assignment_id = csr_new_assignment.p_assignment_id
22243        AND csr_new_assignment.p_effective_date BETWEEN asg.effective_start_date
22244                                                    AND asg.effective_end_date
22245   GROUP BY asg.object_version_number
22246           ,asg.assignment_type
22247           ,asg.period_of_service_id
22248           ,asg.person_id
22249           ,asg.primary_flag
22250           ,asg.effective_start_date
22251           ,asg.effective_end_date
22252           ,pds.actual_termination_date;
22253   l_new_assignment               csr_new_assignment%ROWTYPE;
22254   --
22255   CURSOR csr_old_assignment
22256     (p_person_id                  IN     per_all_people_f.person_id%TYPE
22257     ,p_effective_date             IN     DATE
22258     )
22259   IS
22260     SELECT asg.assignment_id
22261           ,asg.period_of_service_id
22262           ,asg.assignment_type
22263           ,asg.primary_flag
22264           ,asg.person_id
22265           ,asg.effective_start_date
22266           ,asg.effective_end_date
22267       FROM per_all_assignments_f asg
22268      WHERE asg.person_id = csr_old_assignment.p_person_id
22269        AND csr_old_assignment.p_effective_date BETWEEN asg.effective_start_date
22270                                                    AND asg.effective_end_date
22271        AND asg.primary_flag = 'Y'
22272        AND asg.assignment_type = 'E';
22273  l_old_assignment               csr_old_assignment%ROWTYPE;
22274 --
22275 BEGIN
22276   --
22277  if g_debug then
22278   hr_utility.set_location('Entering:'||l_proc,10);
22279  end if;
22280   --
22281   -- Ensure mandatory parameters have been passed
22282   --
22283   hr_api.mandatory_arg_error
22284     (p_api_name                     => l_proc
22285     ,p_argument                     => 'effective_date'
22286     ,p_argument_value               => p_effective_date
22287     );
22288   --
22289   hr_api.mandatory_arg_error
22290     (p_api_name                     => l_proc
22291     ,p_argument                     => 'person_id'
22292     ,p_argument_value               => p_person_id
22293     );
22294   --
22295   hr_api.mandatory_arg_error
22296     (p_api_name                     => l_proc
22297     ,p_argument                     => 'assignment_id'
22298     ,p_argument_value               => p_assignment_id
22299     );
22300   --
22301   -- Truncate all date parameters
22302   --
22303   l_effective_date := TRUNC(p_effective_date);
22304   --
22305   -- Issue Savepoint
22306   --
22307   SAVEPOINT set_new_primary_asg;
22308   --
22309  if g_debug then
22310   hr_utility.set_location(l_proc,20);
22311  end if;
22312   --
22313   -- Call Before Process User Hook
22314   --
22315   BEGIN
22316     hr_assignment_bke.set_new_primary_asg_b
22317       (p_effective_date               => l_effective_date
22318       ,p_person_id                    => p_person_id
22319       ,p_assignment_id                => p_assignment_id
22320       ,p_object_version_number        => p_object_version_number
22321       );
22322   EXCEPTION
22323     WHEN hr_api.cannot_find_prog_unit
22324     THEN
22325       hr_api.cannot_find_prog_unit_error
22326         (p_module_name => 'SET_NEW_PRIMARY_ASG'
22327         ,p_hook_type   => 'BP'
22328         );
22329   END;
22330   --
22331  if g_debug then
22332   hr_utility.set_location(l_proc,30);
22333  end if;
22334   --
22335   -- Retrieve old primary assignment details
22336   --
22337   OPEN csr_old_assignment
22338     (p_person_id      => p_person_id
22339     ,p_effective_date => l_effective_date
22340     );
22341   FETCH csr_old_assignment INTO l_old_assignment;
22342   IF csr_old_assignment%NOTFOUND
22343   THEN
22344     CLOSE csr_old_assignment;
22345     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22346     hr_utility.raise_error;
22347   END IF;
22348   CLOSE csr_old_assignment;
22349   --
22350  if g_debug then
22351   hr_utility.set_location(l_proc,40);
22352  end if;
22353   --
22354   -- Retrieve new primary assignment details
22355   --
22356   OPEN csr_new_assignment
22357     (p_assignment_id  => p_assignment_id
22358     ,p_effective_date => l_effective_date
22359     );
22360   FETCH csr_new_assignment INTO l_new_assignment;
22361   IF csr_new_assignment%NOTFOUND
22362   THEN
22363     CLOSE csr_new_assignment;
22364     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22365     hr_utility.raise_error;
22366   END IF;
22367   CLOSE csr_new_assignment;
22368   --
22369  if g_debug then
22370   hr_utility.set_location(l_proc,50);
22371  end if;
22372   --
22373   -- Validate assignment selected to be new primary
22374   --
22375   IF l_new_assignment.person_id <> p_person_id
22376   THEN
22377     hr_utility.set_message(801,'HR_51253_PYP_ASS__NOT_VALID');
22378     hr_utility.raise_error;
22379   END IF;
22380   IF l_new_assignment.assignment_type <> 'E'
22381   THEN
22382     hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
22383     hr_utility.raise_error;
22384   END IF;
22385   IF l_new_assignment.primary_flag = 'Y'
22386   THEN
22387     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
22388     hr_utility.raise_error;
22389   END IF;
22390   IF l_new_assignment.max_effective_end_date <> NVL(l_new_assignment.actual_termination_date,hr_api.g_eot)
22391   THEN
22392     hr_utility.set_message(800,'HR_6438_EMP_ASS_NOT_CONTIN');
22393     hr_utility.raise_error;
22394   END IF;
22395   --
22396  if g_debug then
22397   hr_utility.set_location(l_proc,60);
22398  end if;
22399   --
22400   -- End the previous primary assignment
22401   --
22402   -- # 2468916: This should be executed after creating NEW primary
22403   -- assignment. This call is replaced by do_primary_update proc.
22404   --
22405   -- hr_assignment.update_primary
22406   --  (p_assignment_id        => l_old_assignment.assignment_id
22407   --  ,p_period_of_service_id => l_old_assignment.period_of_service_id
22408   --  ,p_new_primary_ass_id   => p_assignment_id
22409   --  ,p_sdate                => l_effective_date
22410   --  ,p_new_primary_flag     => 'Y'
22411   --  ,p_mode                 => hr_api.g_update
22412   --  ,p_last_updated_by      => TO_NUMBER(NULL)
22413   --  ,p_last_update_login    => TO_NUMBER(NULL)
22414   --   );
22415   --
22416  if g_debug then
22417   hr_utility.set_location(l_proc,70);
22418  end if;
22419   --
22420   -- Start the new primary assignment
22421   --
22422   hr_assignment.update_primary
22423     (p_assignment_id        => l_old_assignment.assignment_id        -- #2468916:instead of p_assignment_id
22424     ,p_period_of_service_id => l_old_assignment.period_of_service_id -- #2468916:instead of new.
22425     ,p_new_primary_ass_id   => p_assignment_id
22426     ,p_sdate                => l_effective_date
22427     ,p_new_primary_flag     => 'Y'
22428     ,p_mode                 => hr_api.g_update
22429     ,p_last_updated_by      => TO_NUMBER(NULL)
22430     ,p_last_update_login    => TO_NUMBER(NULL)
22431     );
22432   --
22433  if g_debug then
22434   hr_utility.set_location(l_proc,75);
22435  end if;
22436   --
22437   -- #2468916: End previous assignment
22438   --
22439      hr_assignment.do_primary_update(l_old_assignment.assignment_id   --p_assignment_id
22440                        ,l_effective_date -- p_sdate
22441                        ,'N'              -- primary flag
22442                        ,'N'              -- current asg
22443                        ,TO_NUMBER(NULL)  --p_last_updated_by
22444                        ,TO_NUMBER(NULL)  --p_last_update_login
22445                        );
22446   -- end #2468916
22447   --
22448  if g_debug then
22449   hr_utility.set_location(l_proc,80);
22450  end if;
22451   --
22452   -- Retrieve new primary assignment details
22453   --
22454   OPEN csr_new_assignment
22455     (p_assignment_id  => p_assignment_id
22456     ,p_effective_date => l_effective_date
22457     );
22458   FETCH csr_new_assignment INTO l_new_assignment;
22459   IF csr_new_assignment%NOTFOUND
22460   THEN
22461     CLOSE csr_new_assignment;
22462     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22463     hr_utility.raise_error;
22464   END IF;
22465   CLOSE csr_new_assignment;
22466   --
22467  if g_debug then
22468   hr_utility.set_location(l_proc,90);
22469  end if;
22470   --
22471   -- Call After Process User Hook
22472   --
22473   BEGIN
22474     hr_assignment_bke.set_new_primary_asg_a
22475       (p_effective_date               => l_effective_date
22476       ,p_person_id                    => p_person_id
22477       ,p_assignment_id                => p_assignment_id
22478       ,p_object_version_number        => l_new_assignment.object_version_number
22479       ,p_effective_start_date         => l_new_assignment.effective_start_date
22480       ,p_effective_end_date           => l_new_assignment.effective_end_date
22481       );
22482   EXCEPTION
22483     WHEN hr_api.cannot_find_prog_unit
22484     THEN
22485       hr_api.cannot_find_prog_unit_error
22486         (p_module_name => 'SET_NEW_PRIMARY_ASG'
22487         ,p_hook_type   => 'AP'
22488         );
22489   END;
22490   --
22491  if g_debug then
22492   hr_utility.set_location(l_proc,100);
22493  end if;
22494   --
22495   -- When in validation only mode raise validate enabled exception
22496   --
22497   IF p_validate
22498   THEN
22499     RAISE hr_api.validate_enabled;
22500   END IF;
22501   --
22502   -- Set OUT parameters
22503   --
22504   p_object_version_number := l_new_assignment.object_version_number;
22505   p_effective_start_date  := l_new_assignment.effective_start_date;
22506   p_effective_end_date    := l_new_assignment.effective_end_date;
22507   --
22508  if g_debug then
22509   hr_utility.set_location(' Leaving:'||l_proc,1000);
22510  end if;
22511 --
22512 EXCEPTION
22513   WHEN hr_api.validate_enabled
22514   THEN
22515     --
22516     -- In validation only mode
22517     -- Rollback to savepoint
22518     -- Set relevant output warning parmeters
22519     -- Reset any key or derived values
22520     --
22521     ROLLBACK TO set_new_primary_asg;
22522     p_object_version_number := l_object_version_number;
22523     p_effective_start_date  := NULL;
22524     p_effective_end_date    := NULL;
22525   --
22526   WHEN OTHERS
22527   THEN
22528     --
22529     -- Validation or unexpected error
22530     -- Rollback to savepoint
22531     -- Re-raise exception
22532     --
22533     p_object_version_number := lv_object_version_number;
22534     p_effective_start_date   := null;
22535     p_effective_end_date     := null;
22536 
22537     ROLLBACK TO set_new_primary_asg;
22538     RAISE;
22539 --
22540 END set_new_primary_asg;
22541 --
22542 PROCEDURE set_new_primary_cwk_asg
22543   (p_validate                    IN     BOOLEAN
22544   ,p_effective_date              IN     DATE
22545   ,p_person_id                   IN     per_all_people_f.person_id%TYPE
22546   ,p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
22547   ,p_object_version_number       IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22548   ,p_effective_start_date           OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22549   ,p_effective_end_date             OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22550   )
22551 IS
22552   --
22553   -- Local Variables
22554   --
22555   l_proc                        VARCHAR2(72) := g_package||'set_new_primary_cwk_asg';
22556   --
22557   l_effective_date              DATE;
22558   l_object_version_number       CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
22559   l_effective_start_date        per_all_assignments_f.effective_start_date%TYPE;
22560   l_effective_end_date          per_all_assignments_f.effective_end_date%TYPE;
22561   --
22562   lv_object_version_number     number := p_object_version_number ;
22563   --
22564   -- Local cursors
22565   --
22566   CURSOR csr_new_assignment
22567     (p_assignment_id               IN     per_all_assignments_f.assignment_id%TYPE
22568     ,p_effective_date              IN     DATE) IS
22569     SELECT asg.object_version_number
22570           ,asg.assignment_type
22571           ,asg.period_of_placement_date_start
22572           ,asg.person_id
22573           ,asg.primary_flag
22574           ,asg.effective_start_date
22575           ,asg.effective_end_date
22576           ,MAX(mxa.effective_end_date) AS max_effective_end_date
22577           ,pop.actual_termination_date
22578       FROM per_all_assignments_f asg
22579           ,per_all_assignments_f mxa
22580           ,per_periods_of_placement pop
22581      WHERE pop.person_id  (+) = asg.person_id
22582 	   AND pop.date_start (+) = asg.period_of_placement_date_start
22583        AND mxa.assignment_id = asg.assignment_id
22584        AND asg.assignment_id = csr_new_assignment.p_assignment_id
22585        AND csr_new_assignment.p_effective_date BETWEEN asg.effective_start_date
22586                                                    AND asg.effective_end_date
22587   GROUP BY asg.object_version_number
22588           ,asg.assignment_type
22589           ,asg.period_of_placement_date_start
22590           ,asg.person_id
22591           ,asg.primary_flag
22592           ,asg.effective_start_date
22593           ,asg.effective_end_date
22594           ,pop.actual_termination_date;
22595   --
22596   CURSOR csr_old_assignment
22597     (p_person_id       IN     per_all_people_f.person_id%TYPE
22598     ,p_effective_date  IN     DATE) IS
22599     SELECT asg.assignment_id
22600           ,asg.assignment_type
22601           ,asg.period_of_placement_date_start
22602           ,asg.primary_flag
22603           ,asg.person_id
22604           ,asg.effective_start_date
22605           ,asg.effective_end_date
22606       FROM per_all_assignments_f asg
22607      WHERE asg.person_id = csr_old_assignment.p_person_id
22608        AND csr_old_assignment.p_effective_date BETWEEN asg.effective_start_date
22609                                                    AND asg.effective_end_date
22610        AND asg.primary_flag = 'Y'
22611        AND asg.assignment_type = 'C';
22612  --
22613  l_old_assignment csr_old_assignment%ROWTYPE;
22614  l_new_assignment csr_new_assignment%ROWTYPE;
22615   --
22616 BEGIN
22617   --
22618  if g_debug then
22619   hr_utility.set_location('Entering:'||l_proc,10);
22620  end if;
22621   --
22622   -- Ensure mandatory parameters have been passed
22623   --
22624   hr_api.mandatory_arg_error
22625     (p_api_name                     => l_proc
22626     ,p_argument                     => 'effective_date'
22627     ,p_argument_value               => p_effective_date
22628     );
22629   --
22630   hr_api.mandatory_arg_error
22631     (p_api_name                     => l_proc
22632     ,p_argument                     => 'person_id'
22633     ,p_argument_value               => p_person_id
22634     );
22635   --
22636   hr_api.mandatory_arg_error
22637     (p_api_name                     => l_proc
22638     ,p_argument                     => 'assignment_id'
22639     ,p_argument_value               => p_assignment_id
22640     );
22641   --
22642   -- Truncate all date parameters
22643   --
22644   l_effective_date := TRUNC(p_effective_date);
22645   --
22646   -- Issue Savepoint
22647   --
22648   SAVEPOINT set_new_primary_cwk_asg;
22649   --
22650  if g_debug then
22651   hr_utility.set_location(l_proc,20);
22652  end if;
22653   --
22654   -- Call Before Process User Hook
22655   --
22656   BEGIN
22657     --
22658     hr_assignment_bki.set_new_primary_cwk_asg_b
22659       (p_effective_date               => l_effective_date
22660       ,p_person_id                    => p_person_id
22661       ,p_assignment_id                => p_assignment_id
22662       ,p_object_version_number        => p_object_version_number);
22663     --
22664   EXCEPTION
22665     --
22666     WHEN hr_api.cannot_find_prog_unit THEN
22667       --
22668       hr_api.cannot_find_prog_unit_error
22669         (p_module_name => 'set_new_primary_cwk_asg'
22670         ,p_hook_type   => 'BP');
22671       --
22672   END;
22673   --
22674  if g_debug then
22675   hr_utility.set_location(l_proc,30);
22676  end if;
22677   --
22678   -- Retrieve old primary assignment details
22679   --
22680   OPEN csr_old_assignment
22681     (p_person_id      => p_person_id
22682     ,p_effective_date => l_effective_date);
22683   --
22684   FETCH csr_old_assignment INTO l_old_assignment;
22685   --
22686   IF csr_old_assignment%NOTFOUND THEN
22687     --
22688     CLOSE csr_old_assignment;
22689     --
22690     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22691     hr_utility.raise_error;
22692 	--
22693   END IF;
22694   --
22695   CLOSE csr_old_assignment;
22696   --
22697  if g_debug then
22698   hr_utility.set_location(l_proc,40);
22699  end if;
22700   --
22701   -- Retrieve new primary assignment details
22702   --
22703   OPEN csr_new_assignment
22704     (p_assignment_id  => p_assignment_id
22705     ,p_effective_date => l_effective_date);
22706   --
22707   FETCH csr_new_assignment INTO l_new_assignment;
22708   --
22709   IF csr_new_assignment%NOTFOUND THEN
22710     --
22711     CLOSE csr_new_assignment;
22712 	--
22713     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22714     hr_utility.raise_error;
22715 	--
22716   END IF;
22717   --
22718   CLOSE csr_new_assignment;
22719   --
22720  if g_debug then
22721   hr_utility.set_location(l_proc,50);
22722  end if;
22723   --
22724   -- Validate assignment selected to be new primary
22725   --
22726   IF l_new_assignment.person_id <> p_person_id THEN
22727     --
22728     hr_utility.set_message(801,'HR_51253_PYP_ASS__NOT_VALID');
22729     hr_utility.raise_error;
22730 	--
22731   END IF;
22732   --
22733   IF l_new_assignment.assignment_type <> 'C' THEN
22734     --
22735 	--hr_utility.set_message(801,'HR_7948_ASG_ASG_NOT_EMP');
22736     hr_utility.set_message(801,'XXX');
22737     hr_utility.raise_error;
22738 	--
22739   END IF;
22740   --
22741   IF l_new_assignment.primary_flag = 'Y' THEN
22742     --
22743     hr_utility.set_message(801,'HR_7999_ASG_INV_PRIM_ASG');
22744     hr_utility.raise_error;
22745 	--
22746   END IF;
22747   --
22748   IF l_new_assignment.max_effective_end_date <>
22749      NVL(l_new_assignment.actual_termination_date,hr_api.g_eot) THEN
22750     --
22751     hr_utility.set_message(800,'HR_6438_EMP_ASS_NOT_CONTIN');
22752     hr_utility.raise_error;
22753 	--
22754   END IF;
22755   --
22756  if g_debug then
22757   hr_utility.set_location(l_proc,60);
22758  end if;
22759   --
22760   -- End the previous primary assignment
22761   --
22762   hr_assignment.update_primary_cwk
22763     (p_assignment_id        => l_old_assignment.assignment_id
22764     ,p_person_id            => p_person_id
22765     ,p_pop_date_start       => l_old_assignment.period_of_placement_date_start
22766     ,p_new_primary_ass_id   => p_assignment_id
22767     ,p_sdate                => l_effective_date
22768     ,p_new_primary_flag     => 'Y'
22769     ,p_mode                 => hr_api.g_update
22770     ,p_last_updated_by      => TO_NUMBER(NULL)
22771     ,p_last_update_login    => TO_NUMBER(NULL)
22772     );
22773   --
22774  if g_debug then
22775   hr_utility.set_location(l_proc,70);
22776  end if;
22777   --
22778   -- Start the new primary assignment
22779   --
22780   hr_assignment.update_primary_cwk
22781     (p_assignment_id        => p_assignment_id
22782     ,p_person_id            => p_person_id
22783     ,p_pop_date_start       => l_new_assignment.period_of_placement_date_start
22784     ,p_new_primary_ass_id   => p_assignment_id
22785     ,p_sdate                => l_effective_date
22786     ,p_new_primary_flag     => 'Y'
22787     ,p_mode                 => hr_api.g_update
22788     ,p_last_updated_by      => TO_NUMBER(NULL)
22789     ,p_last_update_login    => TO_NUMBER(NULL)
22790     );
22791   --
22792  if g_debug then
22793   hr_utility.set_location(l_proc,80);
22794  end if;
22795   --
22796   -- Retrieve new primary assignment details
22797   --
22798   OPEN csr_new_assignment
22799     (p_assignment_id  => p_assignment_id
22800     ,p_effective_date => l_effective_date);
22801   --
22802   FETCH csr_new_assignment INTO l_new_assignment;
22803   --
22804   IF csr_new_assignment%NOTFOUND THEN
22805     --
22806     CLOSE csr_new_assignment;
22807     --
22808     hr_utility.set_message(800,'HR_51253_PYP_ASS__NOT_VALID');
22809     hr_utility.raise_error;
22810 	--
22811   END IF;
22812   --
22813   CLOSE csr_new_assignment;
22814   --
22815  if g_debug then
22816   hr_utility.set_location(l_proc,90);
22817  end if;
22818   --
22819   -- Call After Process User Hook
22820   --
22821   BEGIN
22822     --
22823     hr_assignment_bki.set_new_primary_cwk_asg_a
22824       (p_effective_date               => l_effective_date
22825       ,p_person_id                    => p_person_id
22826       ,p_assignment_id                => p_assignment_id
22827       ,p_object_version_number        => l_new_assignment.object_version_number
22828       ,p_effective_start_date         => l_new_assignment.effective_start_date
22829       ,p_effective_end_date           => l_new_assignment.effective_end_date);
22830     --
22831   EXCEPTION
22832     --
22833     WHEN hr_api.cannot_find_prog_unit THEN
22834       --
22835       hr_api.cannot_find_prog_unit_error
22836         (p_module_name => 'set_new_primary_cwk_asg'
22837         ,p_hook_type   => 'AP');
22838       --
22839   END;
22840   --
22841  if g_debug then
22842   hr_utility.set_location(l_proc,100);
22843  end if;
22844   --
22845   -- When in validation only mode raise validate enabled exception
22846   --
22847   IF p_validate THEN
22848     --
22849     RAISE hr_api.validate_enabled;
22850 	--
22851   END IF;
22852   --
22853   -- Set OUT parameters
22854   --
22855   p_object_version_number := l_new_assignment.object_version_number;
22856   p_effective_start_date  := l_new_assignment.effective_start_date;
22857   p_effective_end_date    := l_new_assignment.effective_end_date;
22858   --
22859  if g_debug then
22860   hr_utility.set_location(' Leaving:'||l_proc,999);
22861  end if;
22862   --
22863 EXCEPTION
22864   --
22865   WHEN hr_api.validate_enabled THEN
22866     --
22867     -- In validation only mode
22868     -- Rollback to savepoint
22869     -- Set relevant output warning parmeters
22870     -- Reset any key or derived values
22871     --
22872     ROLLBACK TO set_new_primary_cwk_asg;
22873     --
22874     p_object_version_number := l_object_version_number;
22875     p_effective_start_date  := NULL;
22876     p_effective_end_date    := NULL;
22877     --
22878   WHEN OTHERS THEN
22879     --
22880     -- Validation or unexpected error
22881     -- Rollback to savepoint
22882     -- Re-raise exception
22883     --
22884     p_object_version_number := lv_object_version_number;
22885     p_effective_start_date   := null;
22886     p_effective_end_date     := null;
22887 
22888     ROLLBACK TO set_new_primary_cwk_asg;
22889     RAISE;
22890     --
22891 END set_new_primary_cwk_asg;
22892 --
22893 --
22894 -- -----------------------------------------------------------------------------
22895 -- |--------------------------< interview1_apl_asg >---------------------------|
22896 -- -----------------------------------------------------------------------------
22897 --
22898 PROCEDURE interview1_apl_asg
22899   (p_validate                     IN     BOOLEAN
22900   ,p_effective_date               IN     DATE
22901   ,p_datetrack_update_mode        IN     VARCHAR2
22902   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
22903   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
22904   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
22905   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
22906   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
22907   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
22908   )
22909 IS
22910   --
22911   -- Local variables
22912   --
22913   l_proc                       VARCHAR2(72);
22914   --
22915   l_effective_date             DATE;
22916   --
22917   l_object_version_number      CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
22918   --
22919   l_expected_system_status     per_assignment_status_types.per_system_status%TYPE := 'INTERVIEW1';
22920   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
22921   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
22922 --
22923   lv_object_version_number     number := p_object_version_number ;
22924 --
22925 BEGIN
22926   --
22927  if g_debug then
22928   l_proc := g_package||'interview1_apl_asg';
22929   hr_utility.set_location('Entering:'||l_proc,10);
22930  end if;
22931   --
22932   -- Truncate all date parameters passed in
22933   --
22934   l_effective_date := TRUNC(p_effective_date);
22935   --
22936   -- Issue savepoint
22937   --
22938   SAVEPOINT interview1_apl_asg;
22939   --
22940  if g_debug then
22941   hr_utility.set_location(l_proc,20);
22942  end if;
22943   --
22944   -- Call Before Process User Hook
22945   --
22946   BEGIN
22947      hr_assignment_bkf.interview1_apl_asg_b
22948        (p_effective_date               => l_effective_date
22949        ,p_datetrack_update_mode        => p_datetrack_update_mode
22950        ,p_assignment_id                => p_assignment_id
22951        ,p_object_version_number        => p_object_version_number
22952        ,p_assignment_status_type_id    => p_assignment_status_type_id
22953        ,p_change_reason                => p_change_reason
22954        );
22955   EXCEPTION
22956      WHEN hr_api.cannot_find_prog_unit
22957      THEN
22958        hr_api.cannot_find_prog_unit_error
22959          (p_module_name       => 'INTERVIEW1_APL_ASG',
22960           p_hook_type         => 'BP'
22961          );
22962   END;
22963   --
22964  if g_debug then
22965   hr_utility.set_location(l_proc,30);
22966  end if;
22967   --
22968   -- Call business support process to update status type
22969   --
22970   hr_assignment_internal.update_status_type_apl_asg
22971     (p_effective_date               => l_effective_date
22972     ,p_datetrack_update_mode        => p_datetrack_update_mode
22973     ,p_assignment_id                => p_assignment_id
22974     ,p_object_version_number        => p_object_version_number
22975     ,p_expected_system_status       => l_expected_system_status
22976     ,p_assignment_status_type_id    => p_assignment_status_type_id
22977     ,p_change_reason                => p_change_reason
22978     ,p_effective_start_date         => l_effective_start_date
22979     ,p_effective_end_date           => l_effective_end_date
22980     );
22981   --
22982  if g_debug then
22983   hr_utility.set_location(l_proc,40);
22984  end if;
22985   --
22986   -- Call After Process User Hook
22987   --
22988   BEGIN
22989      hr_assignment_bkf.interview1_apl_asg_a
22990        (p_effective_date               => l_effective_date
22991        ,p_datetrack_update_mode        => p_datetrack_update_mode
22992        ,p_assignment_id                => p_assignment_id
22993        ,p_object_version_number        => p_object_version_number
22994        ,p_assignment_status_type_id    => p_assignment_status_type_id
22995        ,p_change_reason                => p_change_reason
22996        ,p_effective_start_date         => l_effective_start_date
22997        ,p_effective_end_date           => l_effective_end_date
22998        );
22999   EXCEPTION
23000      WHEN hr_api.cannot_find_prog_unit
23001      THEN
23002        hr_api.cannot_find_prog_unit_error
23003          (p_module_name => 'INTERVIEW1_APL_ASG',
23004           p_hook_type   => 'AP'
23005          );
23006   END;
23007   --
23008  if g_debug then
23009   hr_utility.set_location(l_proc,50);
23010  end if;
23011   --
23012   -- When in validation only mode raise validate_enabled exception
23013   --
23014   IF p_validate
23015   THEN
23016     RAISE hr_api.validate_enabled;
23017   END IF;
23018   --
23019   -- Set OUT parameters
23020   --
23021   p_effective_start_date         := l_effective_start_date;
23022   p_effective_end_date           := l_effective_end_date;
23023   --
23024  if g_debug then
23025   hr_utility.set_location(' Leaving:'||l_proc,100);
23026  end if;
23027 --
23028 EXCEPTION
23029   WHEN hr_api.validate_enabled
23030   THEN
23031     --
23032     -- In validation only mode
23033     -- Rollback to savepoint
23034     -- Set relevant output warning arguments
23035     -- Reset any key or derived arguments
23036     --
23037     ROLLBACK TO interview1_apl_asg;
23038     p_object_version_number        := l_object_version_number;
23039     p_effective_start_date         := NULL;
23040     p_effective_end_date           := NULL;
23041   --
23042   WHEN OTHERS
23043   THEN
23044     --
23045     -- Validation or unexpected error occured
23046     -- Rollback to savepoint
23047     -- Re-raise exception
23048     --
23049     p_object_version_number := lv_object_version_number;
23050     p_effective_start_date   := null;
23051     p_effective_end_date     := null;
23052 
23053     ROLLBACK TO interview1_apl_asg;
23054     RAISE;
23055 --
23056 END interview1_apl_asg;
23057 --
23058 -- -----------------------------------------------------------------------------
23059 -- |--------------------------< interview2_apl_asg >---------------------------|
23060 -- -----------------------------------------------------------------------------
23061 --
23062 PROCEDURE interview2_apl_asg
23063   (p_validate                     IN     BOOLEAN
23064   ,p_effective_date               IN     DATE
23065   ,p_datetrack_update_mode        IN     VARCHAR2
23066   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
23067   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
23068   ,p_assignment_status_type_id    IN     per_assignment_status_types.assignment_status_type_id%TYPE
23069   ,p_change_reason                IN     per_all_assignments_f.change_reason%TYPE
23070   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
23071   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
23072   )
23073 IS
23074   --
23075   -- Local variables
23076   --
23077   l_proc                       VARCHAR2(72);
23078   --
23079   l_effective_date             DATE;
23080   --
23081   l_object_version_number      CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
23082   --
23083   l_expected_system_status     per_assignment_status_types.per_system_status%TYPE := 'INTERVIEW2';
23084   l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
23085   l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
23086 --
23087   lv_object_version_number     number := p_object_version_number ;
23088 --
23089 BEGIN
23090   --
23091  if g_debug then
23092   l_proc := g_package||'interview2_apl_asg';
23093   hr_utility.set_location('Entering:'||l_proc,10);
23094  end if;
23095   --
23096   -- Truncate all date parameters passed in
23097   --
23098   l_effective_date := TRUNC(p_effective_date);
23099   --
23100   -- Issue savepoint
23101   --
23102   SAVEPOINT interview2_apl_asg;
23103   --
23104  if g_debug then
23105   hr_utility.set_location(l_proc,20);
23106  end if;
23107   --
23108   -- Call Before Process User Hook
23109   --
23110   BEGIN
23111      hr_assignment_bkg.interview2_apl_asg_b
23112        (p_effective_date               => l_effective_date
23113        ,p_datetrack_update_mode        => p_datetrack_update_mode
23114        ,p_assignment_id                => p_assignment_id
23115        ,p_object_version_number        => p_object_version_number
23116        ,p_assignment_status_type_id    => p_assignment_status_type_id
23117        ,p_change_reason                => p_change_reason
23118        );
23119   EXCEPTION
23120      WHEN hr_api.cannot_find_prog_unit
23121      THEN
23122        hr_api.cannot_find_prog_unit_error
23123          (p_module_name       => 'INTERVIEW2_APL_ASG',
23124           p_hook_type         => 'BP'
23125          );
23126   END;
23127   --
23128  if g_debug then
23129   hr_utility.set_location(l_proc,30);
23130  end if;
23131   --
23132   -- Call business support process to update status type
23133   --
23134   hr_assignment_internal.update_status_type_apl_asg
23135     (p_effective_date               => l_effective_date
23136     ,p_datetrack_update_mode        => p_datetrack_update_mode
23137     ,p_assignment_id                => p_assignment_id
23138     ,p_object_version_number        => p_object_version_number
23139     ,p_expected_system_status       => l_expected_system_status
23140     ,p_assignment_status_type_id    => p_assignment_status_type_id
23141     ,p_change_reason                => p_change_reason
23142     ,p_effective_start_date         => l_effective_start_date
23143     ,p_effective_end_date           => l_effective_end_date
23144     );
23145   --
23146  if g_debug then
23147   hr_utility.set_location(l_proc,40);
23148  end if;
23149   --
23150   -- Call After Process User Hook
23151   --
23152   BEGIN
23153      hr_assignment_bkg.interview2_apl_asg_a
23154        (p_effective_date               => l_effective_date
23155        ,p_datetrack_update_mode        => p_datetrack_update_mode
23156        ,p_assignment_id                => p_assignment_id
23157        ,p_object_version_number        => p_object_version_number
23158        ,p_assignment_status_type_id    => p_assignment_status_type_id
23159        ,p_change_reason                => p_change_reason
23160        ,p_effective_start_date         => l_effective_start_date
23161        ,p_effective_end_date           => l_effective_end_date
23162        );
23163   EXCEPTION
23164      WHEN hr_api.cannot_find_prog_unit
23165      THEN
23166        hr_api.cannot_find_prog_unit_error
23167          (p_module_name => 'INTERVIEW2_APL_ASG',
23168           p_hook_type   => 'AP'
23169          );
23170   END;
23171   --
23172  if g_debug then
23173   hr_utility.set_location(l_proc,50);
23174  end if;
23175   --
23176   -- When in validation only mode raise validate_enabled exception
23177   --
23178   IF p_validate
23179   THEN
23180     RAISE hr_api.validate_enabled;
23181   END IF;
23182   --
23183   -- Set OUT parameters
23184   --
23185   p_effective_start_date         := l_effective_start_date;
23186   p_effective_end_date           := l_effective_end_date;
23187   --
23188  if g_debug then
23189   hr_utility.set_location(' Leaving:'||l_proc,100);
23190  end if;
23191 --
23192 EXCEPTION
23193   WHEN hr_api.validate_enabled
23194   THEN
23195     --
23196     -- In validation only mode
23197     -- Rollback to savepoint
23198     -- Set relevant output warning arguments
23199     -- Reset any key or derived arguments
23200     --
23201     ROLLBACK TO interview2_apl_asg;
23202     p_object_version_number        := l_object_version_number;
23203     p_effective_start_date         := NULL;
23204     p_effective_end_date           := NULL;
23205   --
23206   WHEN OTHERS
23207   THEN
23208     --
23209     -- Validation or unexpected error occured
23210     -- Rollback to savepoint
23211     -- Re-raise exception
23212     --
23213     p_object_version_number := lv_object_version_number;
23214     p_effective_start_date   := null;
23215     p_effective_end_date     := null;
23216 
23217     ROLLBACK TO interview2_apl_asg;
23218     RAISE;
23219 --
23220 END interview2_apl_asg;
23221 --
23222 --
23223 -- -----------------------------------------------------------------------------
23224 -- |--------------------------< delete_assignment >-----------------------------|
23225 -- -----------------------------------------------------------------------------
23226 --
23227 PROCEDURE delete_assignment
23228   (p_validate                     IN     boolean default false
23229   ,p_effective_date               IN     DATE
23230   ,p_datetrack_mode               IN     VARCHAR2
23231   ,p_assignment_id                IN     per_all_assignments_f.assignment_id%TYPE
23232   ,p_object_version_number        IN OUT NOCOPY per_all_assignments_f.object_version_number%TYPE
23233   ,p_effective_start_date            OUT NOCOPY per_all_assignments_f.effective_start_date%TYPE
23234   ,p_effective_end_date              OUT NOCOPY per_all_assignments_f.effective_end_date%TYPE
23235   ,p_loc_change_tax_issues           OUT NOCOPY boolean
23236   ,p_delete_asg_budgets              OUT NOCOPY boolean
23237   ,p_org_now_no_manager_warning      OUT NOCOPY boolean
23238   ,p_element_salary_warning          OUT NOCOPY boolean
23239   ,p_element_entries_warning         OUT NOCOPY boolean
23240   ,p_spp_warning                     OUT NOCOPY boolean
23241   ,P_cost_warning                    OUT NOCOPY Boolean
23242   ,p_life_events_exists   	     OUT NOCOPY Boolean
23243   ,p_cobra_coverage_elements         OUT NOCOPY Boolean
23244   ,p_assgt_term_elements             OUT NOCOPY Boolean)
23245 IS
23246   l_effective_date date;
23247   l_validate boolean;
23248   --
23249   l_proc    varchar2(72) := g_package||'delete_assignment';
23250   asg_type  varchar2(10);
23251   --
23252   cursor get_asgt_type is
23253      select assignment_type
23254        from per_all_assignments_f
23255       where assignment_id = p_assignment_id
23256         and p_effective_date between effective_start_date and effective_end_date;
23257   --
23258 BEGIN
23259   --
23260   if g_debug then
23261     hr_utility.set_location('Entering:'|| l_proc, 5);
23262     hr_utility.set_location('p_effective_date:'|| to_char(p_effective_date,'DD/MM/YYYY'), 5);
23263     hr_utility.set_location('p_assignment_id :'|| p_assignment_id, 5);
23264   end if;
23265   --
23266   l_effective_date  := trunc(p_effective_date);
23267   l_validate        := p_validate ;
23268   --
23269   -- Issue a savepoint.
23270   --
23271   savepoint hr_delete_assignment;
23272   --
23273   if g_debug then
23274     hr_utility.set_location(l_proc, 6);
23275   end if;
23276   --
23277   open get_asgt_type;
23278   fetch get_asgt_type into asg_type;
23279   if get_asgt_type%notfound then
23280      close get_asgt_type;
23281   else
23282       --
23283       close get_asgt_type;
23284       if asg_type = 'B' then
23285          if g_debug then
23286             hr_utility.set_location('Selected assignment is of type Benifit', 10);
23287          end if;
23288          --
23289          fnd_message.set_name('PER', 'HR_449746_DEL_BEN_ASG');
23290          fnd_message.raise_error;
23291       end if;
23292       --
23293   end if;
23294   --
23295   begin
23296     --
23297     -- Start of API User Hook for the before hook of delete_assignment
23298     --
23299     hr_assignment_bkp.delete_assignment_b
23300       (p_effective_date               => l_effective_date
23301       ,p_assignment_id                => p_assignment_id
23302       ,p_datetrack_mode               => p_datetrack_mode
23303       );
23304     --
23305   exception
23306     when hr_api.cannot_find_prog_unit then
23307       hr_api.cannot_find_prog_unit_error
23308         (p_module_name => 'DELETE_ASSIGNMENT'
23309         ,p_hook_type   => 'BP'
23310         );
23311     --
23312     -- End of API User Hook for the before hook of delete_assignment
23313     --
23314   end;
23315   --
23316   per_asg_del.del(
23317      p_validate                     =>  p_validate
23318     ,p_assignment_id                =>  p_assignment_id
23319     ,p_effective_date               =>  p_effective_date
23320     ,p_datetrack_mode               =>  p_datetrack_mode
23321     ,p_object_version_number        =>  p_object_version_number
23322     ,p_effective_start_date         =>  p_effective_start_date
23323     ,p_effective_end_date           =>  p_effective_end_date
23324     ,p_loc_change_tax_issues        =>  p_loc_change_tax_issues
23325     ,p_delete_asg_budgets           =>  p_delete_asg_budgets
23326     ,p_org_now_no_manager_warning   =>  p_org_now_no_manager_warning
23327     ,p_element_salary_warning       =>  p_element_salary_warning
23328     ,p_element_entries_warning      =>  p_element_entries_warning
23329     ,p_spp_warning                  =>  p_spp_warning
23330     ,P_cost_warning                 =>  P_cost_warning
23331     ,p_life_events_exists           =>  p_life_events_exists
23332     ,p_cobra_coverage_elements      =>  p_cobra_coverage_elements
23333     ,p_assgt_term_elements          =>  p_assgt_term_elements );
23334   --
23335   begin
23336     --
23337     -- Start of API User Hook for the after hook of delete_assignment
23338     --
23339     hr_assignment_bkp.delete_assignment_a
23340       (p_effective_date               => l_effective_date
23341       ,p_assignment_id                => p_assignment_id
23342       ,p_datetrack_mode               => p_datetrack_mode
23343       ,p_loc_change_tax_issues        => p_loc_change_tax_issues
23344       ,p_delete_asg_budgets           => p_delete_asg_budgets
23345       ,p_org_now_no_manager_warning   => p_org_now_no_manager_warning
23346       ,p_element_salary_warning       => p_element_salary_warning
23347       ,p_element_entries_warning      => p_element_entries_warning
23348       ,p_spp_warning                  => p_spp_warning
23349       ,P_cost_warning                 => P_cost_warning
23350       ,p_life_events_exists           => p_life_events_exists
23351       ,p_cobra_coverage_elements      => p_cobra_coverage_elements
23352       ,p_assgt_term_elements          => p_assgt_term_elements );
23353   exception
23354     when hr_api.cannot_find_prog_unit then
23355       hr_api.cannot_find_prog_unit_error
23356         (p_module_name => 'DELETE_ASSIGNMENT'
23357         ,p_hook_type   => 'AP'
23358         );
23359     --
23360     -- End of API User Hook for the after hook of delete_person
23361     --
23362   end;
23363   --
23364 
23365   if p_validate then
23366     raise hr_api.validate_enabled;
23367   end if;
23368   --
23369   if g_debug then
23370     hr_utility.set_location(' Leaving:'||l_proc, 100);
23371   end if;
23372   --
23373   exception
23374    when hr_api.validate_enabled then
23375     --
23376     -- As the Validate_Enabled exception has been raised
23377     -- we must rollback to the savepoint
23378     --
23379     p_loc_change_tax_issues          := null;
23380     p_delete_asg_budgets             := null;
23381     p_org_now_no_manager_warning     := null;
23382     p_element_salary_warning         := null;
23383     p_element_entries_warning        := null;
23384     p_spp_warning                    := null;
23385     P_cost_warning                   := null;
23386     p_life_events_exists   	     := null;
23387     p_cobra_coverage_elements        := null;
23388     p_assgt_term_elements            := null;
23389     --
23390     ROLLBACK TO hr_delete_assignment;
23391     --
23392   when others then
23393     --
23394     -- A validation or unexpected error has occurred
23395     --
23396     p_loc_change_tax_issues          := null;
23397     p_delete_asg_budgets             := null;
23398     p_org_now_no_manager_warning     := null;
23399     p_element_salary_warning         := null;
23400     p_element_entries_warning        := null;
23401     p_spp_warning                    := null;
23402     P_cost_warning                   := null;
23403     p_life_events_exists   	     := null;
23404     p_cobra_coverage_elements        := null;
23405     p_assgt_term_elements            := null;
23406     --
23407     ROLLBACK TO hr_delete_assignment;
23408     raise;
23409   --
23410 END; -- End of delete_assignment Procedure
23411 --
23412 END hr_assignment_api;